blob: 5c65f7d4606faa92077426d6405d6ee62434b107 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include "hda_codec.h"
34#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010035#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Matt4e550962005-07-04 17:51:39 +020038#define NUM_CONTROL_ALLOC 32
Matthew Ranostaya64135a2008-01-10 16:55:06 +010039#define STAC_PWR_EVENT 0x20
40#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020041
Takashi Iwaif5fcc132006-11-24 17:07:44 +010042enum {
43 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010044 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020045 STAC_9200_DELL_D21,
46 STAC_9200_DELL_D22,
47 STAC_9200_DELL_D23,
48 STAC_9200_DELL_M21,
49 STAC_9200_DELL_M22,
50 STAC_9200_DELL_M23,
51 STAC_9200_DELL_M24,
52 STAC_9200_DELL_M25,
53 STAC_9200_DELL_M26,
54 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020055 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010056 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010057 STAC_9200_MODELS
58};
59
60enum {
61 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020062 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020063 STAC_9205_DELL_M43,
64 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010065 STAC_9205_MODELS
66};
67
68enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010069 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010070 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010071 STAC_92HD73XX_MODELS
72};
73
74enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020075 STAC_92HD83XXX_REF,
76 STAC_92HD83XXX_MODELS
77};
78
79enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010080 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010081 STAC_DELL_M4_1,
82 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040083 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010084 STAC_92HD71BXX_MODELS
85};
86
87enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010088 STAC_925x_REF,
89 STAC_M2_2,
90 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020091 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010092 STAC_925x_MODELS
93};
94
95enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010096 STAC_D945_REF,
97 STAC_D945GTP3,
98 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020099 STAC_INTEL_MAC_V1,
100 STAC_INTEL_MAC_V2,
101 STAC_INTEL_MAC_V3,
102 STAC_INTEL_MAC_V4,
103 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800104 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
105 * is given, one of the above models will be
106 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200107 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100108 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100109 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100110 STAC_MACBOOK_PRO_V1,
111 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200112 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200113 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300114 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200115 STAC_922X_DELL_D81,
116 STAC_922X_DELL_D82,
117 STAC_922X_DELL_M81,
118 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100119 STAC_922X_MODELS
120};
121
122enum {
123 STAC_D965_REF,
124 STAC_D965_3ST,
125 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200126 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100127 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100128 STAC_927X_MODELS
129};
Matt Porter403d1942005-11-29 15:00:51 +0100130
Matt2f2f4252005-04-13 14:45:30 +0200131struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100132 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200133 unsigned int num_mixers;
134
Matt Porter403d1942005-11-29 15:00:51 +0100135 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200136 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100137 unsigned int line_switch: 1;
138 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100139 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100140 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400141 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200142
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100143 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200144 unsigned int eapd_mask;
Matthew Ranostay4fe5195c2008-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 Ranostay4fe5195c2008-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;
220 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100221 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200222 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200223 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200224 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400225 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100226 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200227};
228
229static hda_nid_t stac9200_adc_nids[1] = {
230 0x03,
231};
232
233static hda_nid_t stac9200_mux_nids[1] = {
234 0x0c,
235};
236
237static hda_nid_t stac9200_dac_nids[1] = {
238 0x02,
239};
240
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100241static hda_nid_t stac92hd73xx_pwr_nids[8] = {
242 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
243 0x0f, 0x10, 0x11
244};
245
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400246static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
247 0x26, 0,
248};
249
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100250static hda_nid_t stac92hd73xx_adc_nids[2] = {
251 0x1a, 0x1b
252};
253
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400254#define DELL_M6_AMP 2
255static hda_nid_t stac92hd73xx_amp_nids[3] = {
256 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400257};
258
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100259#define STAC92HD73XX_NUM_DMICS 2
260static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
261 0x13, 0x14, 0
262};
263
264#define STAC92HD73_DAC_COUNT 5
265static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
266 0x15, 0x16, 0x17, 0x18, 0x19,
267};
268
269static hda_nid_t stac92hd73xx_mux_nids[4] = {
270 0x28, 0x29, 0x2a, 0x2b,
271};
272
273static hda_nid_t stac92hd73xx_dmux_nids[2] = {
274 0x20, 0x21,
275};
276
Matthew Ranostayd9737752008-09-07 12:03:41 +0200277static hda_nid_t stac92hd73xx_smux_nids[2] = {
278 0x22, 0x23,
279};
280
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200281#define STAC92HD83XXX_NUM_DMICS 2
282static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
283 0x11, 0x12, 0
284};
285
286#define STAC92HD81_DAC_COUNT 2
287#define STAC92HD83_DAC_COUNT 3
288static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
289 0x13, 0x14, 0x22,
290};
291
292static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
293 0x17, 0x18,
294};
295
296static hda_nid_t stac92hd83xxx_adc_nids[2] = {
297 0x15, 0x16,
298};
299
300static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
301 0xa, 0xb, 0xd, 0xe,
302};
303
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400304static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
305 0x1e, 0,
306};
307
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200308static unsigned int stac92hd83xxx_pwr_mapping[4] = {
309 0x03, 0x0c, 0x10, 0x40,
310};
311
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100312static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
313 0x0a, 0x0d, 0x0f
314};
315
Matthew Ranostaye035b842007-11-06 11:53:55 +0100316static hda_nid_t stac92hd71bxx_adc_nids[2] = {
317 0x12, 0x13,
318};
319
320static hda_nid_t stac92hd71bxx_mux_nids[2] = {
321 0x1a, 0x1b
322};
323
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100324static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
325 0x1c,
326};
327
Matthew Ranostayd9737752008-09-07 12:03:41 +0200328static hda_nid_t stac92hd71bxx_smux_nids[2] = {
329 0x24, 0x25,
330};
331
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100332static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100333 0x10, /*0x11, */
334};
335
336#define STAC92HD71BXX_NUM_DMICS 2
337static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
338 0x18, 0x19, 0
339};
340
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400341static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
342 0x22, 0
343};
344
Tobin Davis8e21c342007-01-08 11:04:17 +0100345static hda_nid_t stac925x_adc_nids[1] = {
346 0x03,
347};
348
349static hda_nid_t stac925x_mux_nids[1] = {
350 0x0f,
351};
352
353static hda_nid_t stac925x_dac_nids[1] = {
354 0x02,
355};
356
Takashi Iwaif6e98522007-10-16 14:27:04 +0200357#define STAC925X_NUM_DMICS 1
358static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
359 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200360};
361
Takashi Iwai1697055e2007-12-18 18:05:52 +0100362static hda_nid_t stac925x_dmux_nids[1] = {
363 0x14,
364};
365
Matt2f2f4252005-04-13 14:45:30 +0200366static hda_nid_t stac922x_adc_nids[2] = {
367 0x06, 0x07,
368};
369
370static hda_nid_t stac922x_mux_nids[2] = {
371 0x12, 0x13,
372};
373
Matt Porter3cc08dc2006-01-23 15:27:49 +0100374static hda_nid_t stac927x_adc_nids[3] = {
375 0x07, 0x08, 0x09
376};
377
378static hda_nid_t stac927x_mux_nids[3] = {
379 0x15, 0x16, 0x17
380};
381
Matthew Ranostayd9737752008-09-07 12:03:41 +0200382static hda_nid_t stac927x_smux_nids[1] = {
383 0x21,
384};
385
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100386static hda_nid_t stac927x_dac_nids[6] = {
387 0x02, 0x03, 0x04, 0x05, 0x06, 0
388};
389
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100390static hda_nid_t stac927x_dmux_nids[1] = {
391 0x1b,
392};
393
Matthew Ranostay7f168592007-10-18 17:38:17 +0200394#define STAC927X_NUM_DMICS 2
395static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
396 0x13, 0x14, 0
397};
398
Matthew Ranostay65973632008-09-16 10:39:37 -0400399static const char *stac927x_spdif_labels[5] = {
400 "Digital Playback", "ADAT", "Analog Mux 1",
401 "Analog Mux 2", "Analog Mux 3"
402};
403
Matt Porterf3302a52006-07-31 12:49:34 +0200404static hda_nid_t stac9205_adc_nids[2] = {
405 0x12, 0x13
406};
407
408static hda_nid_t stac9205_mux_nids[2] = {
409 0x19, 0x1a
410};
411
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100412static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100413 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100414};
415
Matthew Ranostayd9737752008-09-07 12:03:41 +0200416static hda_nid_t stac9205_smux_nids[1] = {
417 0x21,
418};
419
Takashi Iwaif6e98522007-10-16 14:27:04 +0200420#define STAC9205_NUM_DMICS 2
421static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
422 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200423};
424
Mattc7d4b2f2005-06-27 14:59:41 +0200425static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200426 0x08, 0x09, 0x0d, 0x0e,
427 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200428};
429
Tobin Davis8e21c342007-01-08 11:04:17 +0100430static hda_nid_t stac925x_pin_nids[8] = {
431 0x07, 0x08, 0x0a, 0x0b,
432 0x0c, 0x0d, 0x10, 0x11,
433};
434
Matt2f2f4252005-04-13 14:45:30 +0200435static hda_nid_t stac922x_pin_nids[10] = {
436 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
437 0x0f, 0x10, 0x11, 0x15, 0x1b,
438};
439
Matthew Ranostaya7662642008-02-21 07:51:14 +0100440static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100441 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
442 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200443 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100444};
445
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200446static hda_nid_t stac92hd83xxx_pin_nids[14] = {
447 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
448 0x0f, 0x10, 0x11, 0x12, 0x13,
449 0x1d, 0x1e, 0x1f, 0x20
450};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400451static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100452 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
453 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400454 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100455};
456
Matt Porter3cc08dc2006-01-23 15:27:49 +0100457static hda_nid_t stac927x_pin_nids[14] = {
458 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
459 0x0f, 0x10, 0x11, 0x12, 0x13,
460 0x14, 0x21, 0x22, 0x23,
461};
462
Matt Porterf3302a52006-07-31 12:49:34 +0200463static hda_nid_t stac9205_pin_nids[12] = {
464 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
465 0x0f, 0x14, 0x16, 0x17, 0x18,
466 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200467};
468
Matthew Ranostay89385032008-09-11 09:49:39 -0400469#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
470
471static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_value *ucontrol)
473{
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct sigmatel_spec *spec = codec->spec;
476 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
477
478 kcontrol->private_value ^= get_amp_nid(kcontrol);
479 kcontrol->private_value |= nid;
480
481 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
482}
483
484static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_value *ucontrol)
486{
487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
488 struct sigmatel_spec *spec = codec->spec;
489 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
490
491 kcontrol->private_value ^= get_amp_nid(kcontrol);
492 kcontrol->private_value |= nid;
493
494 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
495}
496
Matt Porter8b657272006-10-26 17:12:59 +0200497static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
498 struct snd_ctl_elem_info *uinfo)
499{
500 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
501 struct sigmatel_spec *spec = codec->spec;
502 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
503}
504
505static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_value *ucontrol)
507{
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100510 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200511
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100512 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200513 return 0;
514}
515
516static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_value *ucontrol)
518{
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100521 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200522
523 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100524 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200525}
526
Matthew Ranostayd9737752008-09-07 12:03:41 +0200527static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
528 struct snd_ctl_elem_info *uinfo)
529{
530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
531 struct sigmatel_spec *spec = codec->spec;
532 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
533}
534
535static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
540 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
541
542 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
543 return 0;
544}
545
546static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
548{
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400551 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200552 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400553 int err, val;
554 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200555
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400556 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200557 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400558 if (err < 0)
559 return err;
560
561 if (spec->spdif_mute) {
562 if (smux_idx == 0)
563 nid = spec->multiout.dig_out_nid;
564 else
565 nid = codec->slave_dig_outs[smux_idx - 1];
566 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
567 val = AMP_OUT_MUTE;
568 if (smux_idx == 0)
569 nid = spec->multiout.dig_out_nid;
570 else
571 nid = codec->slave_dig_outs[smux_idx - 1];
572 /* un/mute SPDIF out */
573 snd_hda_codec_write_cache(codec, nid, 0,
574 AC_VERB_SET_AMP_GAIN_MUTE, val);
575 }
576 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200577}
578
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100579static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200580{
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200583 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200584}
585
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100586static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200587{
588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
589 struct sigmatel_spec *spec = codec->spec;
590 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
591
592 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
593 return 0;
594}
595
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100596static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200597{
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
601
Mattc7d4b2f2005-06-27 14:59:41 +0200602 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200603 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
604}
605
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100606static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_info *uinfo)
608{
609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
610 struct sigmatel_spec *spec = codec->spec;
611 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
612}
613
614static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
616{
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 struct sigmatel_spec *spec = codec->spec;
619
620 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
621 return 0;
622}
623
624static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_value *ucontrol)
626{
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
629
630 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
631 spec->mono_nid, &spec->cur_mmux);
632}
633
Matthew Ranostay89385032008-09-11 09:49:39 -0400634static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_info *uinfo)
636{
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 struct sigmatel_spec *spec = codec->spec;
639 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
640}
641
642static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
644{
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
647
648 ucontrol->value.enumerated.item[0] = spec->cur_amux;
649 return 0;
650}
651
652static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
657 struct snd_kcontrol *ctl =
658 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
659 if (!ctl)
660 return -EINVAL;
661
662 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
663 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
664
665 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
666 0, &spec->cur_amux);
667}
668
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200669#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
670
671static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
673{
674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100675 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200676 struct sigmatel_spec *spec = codec->spec;
677
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100678 ucontrol->value.integer.value[0] = !!(spec->aloopback &
679 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200680 return 0;
681}
682
683static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *ucontrol)
685{
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100688 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200689 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100690 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200691
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100692 idx_val = spec->aloopback_mask << idx;
693 if (ucontrol->value.integer.value[0])
694 val = spec->aloopback | idx_val;
695 else
696 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100697 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200698 return 0;
699
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100700 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200701
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100702 /* Only return the bits defined by the shift value of the
703 * first two bytes of the mask
704 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200705 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100706 kcontrol->private_value & 0xFFFF, 0x0);
707 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200708
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100709 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200710 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100711 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200712 } else {
713 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100714 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200715 }
716
717 snd_hda_codec_write_cache(codec, codec->afg, 0,
718 kcontrol->private_value >> 16, dac_mode);
719
720 return 1;
721}
722
Mattc7d4b2f2005-06-27 14:59:41 +0200723static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200724 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200725 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200726 {}
727};
728
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200729static struct hda_verb stac9200_eapd_init[] = {
730 /* set dac0mux for dac converter */
731 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
732 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
733 {}
734};
735
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100736static struct hda_verb stac92hd73xx_6ch_core_init[] = {
737 /* set master volume and direct control */
738 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
739 /* setup audio connections */
740 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
741 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
742 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
743 /* setup adcs to point to mixer */
744 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
745 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100746 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
747 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
748 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
749 /* setup import muxs */
750 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
751 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
752 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
753 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
754 {}
755};
756
Matthew Ranostayd654a662008-03-14 08:46:51 +0100757static struct hda_verb dell_eq_core_init[] = {
758 /* set master volume to max value without distortion
759 * and direct control */
760 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
761 /* setup audio connections */
762 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400763 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
764 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100765 /* setup adcs to point to mixer */
766 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
767 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
768 /* setup import muxs */
769 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
772 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
773 {}
774};
775
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100776static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200777 /* set master volume to max value without distortion
778 * and direct control */
779 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100780 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100781 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
782 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100783 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
784 /* setup adcs to point to mixer */
785 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
786 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
787 /* setup import muxs */
788 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
791 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
792 {}
793};
794
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100795static struct hda_verb stac92hd73xx_8ch_core_init[] = {
796 /* set master volume and direct control */
797 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
798 /* setup audio connections */
799 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
800 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
801 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
802 /* connect hp ports to dac3 */
803 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
804 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
805 /* setup adcs to point to mixer */
806 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
807 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100808 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
809 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
810 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
811 /* setup import muxs */
812 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
816 {}
817};
818
819static struct hda_verb stac92hd73xx_10ch_core_init[] = {
820 /* set master volume and direct control */
821 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
822 /* setup audio connections */
823 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
824 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
825 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
826 /* dac3 is connected to import3 mux */
827 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
828 /* connect hp ports to dac4 */
829 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
830 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
831 /* setup adcs to point to mixer */
832 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
833 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
835 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 /* setup import muxs */
838 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
839 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
840 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
842 {}
843};
844
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200845static struct hda_verb stac92hd83xxx_core_init[] = {
846 /* start of config #1 */
847 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
848
849 /* start of config #2 */
850 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
851 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
852 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
853
854 /* power state controls amps */
855 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
856};
857
Matthew Ranostaye035b842007-11-06 11:53:55 +0100858static struct hda_verb stac92hd71bxx_core_init[] = {
859 /* set master volume and direct control */
860 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
861 /* connect headphone jack to dac1 */
862 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100863 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
864 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
865 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
866 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
867 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100868};
869
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200870#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100871static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200872 /* start of config #1 */
873
874 /* connect port 0f to audio mixer */
875 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
876 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
877 /* unmute right and left channels for node 0x0f */
878 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
879 /* start of config #2 */
880
Matthew Ranostay541eee82007-12-14 12:08:04 +0100881 /* set master volume and direct control */
882 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
883 /* connect headphone jack to dac1 */
884 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200885 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100886 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100887 /* unmute dac0 input in audio mixer */
888 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200889 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100890 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
891 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100892 {}
893};
894
Tobin Davis8e21c342007-01-08 11:04:17 +0100895static struct hda_verb stac925x_core_init[] = {
896 /* set dac0mux for dac converter */
897 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
898 {}
899};
900
Mattc7d4b2f2005-06-27 14:59:41 +0200901static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200902 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200903 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200904 {}
905};
906
Tobin Davis93ed1502006-09-01 21:03:12 +0200907static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200908 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200909 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200910 /* unmute node 0x1b */
911 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
912 /* select node 0x03 as DAC */
913 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
914 {}
915};
916
Matt Porter3cc08dc2006-01-23 15:27:49 +0100917static struct hda_verb stac927x_core_init[] = {
918 /* set master volume and direct control */
919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200920 /* enable analog pc beep path */
921 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100922 {}
923};
924
Matt Porterf3302a52006-07-31 12:49:34 +0200925static struct hda_verb stac9205_core_init[] = {
926 /* set master volume and direct control */
927 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200928 /* enable analog pc beep path */
929 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200930 {}
931};
932
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100933#define STAC_MONO_MUX \
934 { \
935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
936 .name = "Mono Mux", \
937 .count = 1, \
938 .info = stac92xx_mono_mux_enum_info, \
939 .get = stac92xx_mono_mux_enum_get, \
940 .put = stac92xx_mono_mux_enum_put, \
941 }
942
Matthew Ranostay89385032008-09-11 09:49:39 -0400943#define STAC_AMP_MUX \
944 { \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Amp Selector Capture Switch", \
947 .count = 1, \
948 .info = stac92xx_amp_mux_enum_info, \
949 .get = stac92xx_amp_mux_enum_get, \
950 .put = stac92xx_amp_mux_enum_put, \
951 }
952
953#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
954 { \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = xname, \
957 .index = 0, \
958 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
960 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
961 .info = stac92xx_amp_volume_info, \
962 .get = stac92xx_amp_volume_get, \
963 .put = stac92xx_amp_volume_put, \
964 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
965 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
966 }
967
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200968#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200969 { \
970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
971 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200972 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200973 .info = stac92xx_mux_enum_info, \
974 .get = stac92xx_mux_enum_get, \
975 .put = stac92xx_mux_enum_put, \
976 }
977
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100978#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200979 { \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100982 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200983 .info = stac92xx_aloopback_info, \
984 .get = stac92xx_aloopback_get, \
985 .put = stac92xx_aloopback_put, \
986 .private_value = verb_read | (verb_write << 16), \
987 }
988
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100989static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200990 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200992 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200993 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200995 { } /* end */
996};
997
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400998#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100999static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001000 /* start of config #1 */
1001 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1002 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1003
1004 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1005 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1006
1007 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1008 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1009
1010 /* start of config #2 */
1011 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1013
1014 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1015 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1016
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1018
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1021
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1024
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001025 { } /* end */
1026};
1027
1028static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001029 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1030
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1033
1034 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1036
1037 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1038 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1039
1040 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1041 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1042
1043 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1044 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1045
1046 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1047 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1048
1049 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1050 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1051 { } /* end */
1052};
1053
1054static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001055 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1056
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001057 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1059
1060 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1062
1063 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1064 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1065
1066 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1068
1069 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1070 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1071
1072 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1073 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1074
1075 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1076 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1077 { } /* end */
1078};
1079
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001080
1081static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1082 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1084
1085 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1087
1088 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1089 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1090
1091 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1092 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1093
1094 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1095 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1096
1097 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1098 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1099
1100 /*
1101 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1102 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1103 */
1104 { } /* end */
1105};
1106
Matthew Ranostay541eee82007-12-14 12:08:04 +01001107static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001108 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001109
Matthew Ranostay9b359472007-11-07 13:03:12 +01001110 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001112
1113 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001115 /* analog pc-beep replaced with digital beep support */
1116 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001117 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1118 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001119 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001120
Matthew Ranostay9b359472007-11-07 13:03:12 +01001121 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
1122 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001123 { } /* end */
1124};
1125
Matthew Ranostay541eee82007-12-14 12:08:04 +01001126static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001127 STAC_INPUT_SOURCE(2),
1128 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1129
Matthew Ranostay541eee82007-12-14 12:08:04 +01001130 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001132
1133 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135 { } /* end */
1136};
1137
Tobin Davis8e21c342007-01-08 11:04:17 +01001138static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001139 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001140 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001141 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001142 { } /* end */
1143};
1144
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001145static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001146 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001147 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001148
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001151
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001154 { } /* end */
1155};
1156
1157/* This needs to be generated dynamically based on sequence */
1158static struct snd_kcontrol_new stac922x_mixer[] = {
1159 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1161 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001162
1163 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001165 { } /* end */
1166};
1167
1168
1169static struct snd_kcontrol_new stac927x_mixer[] = {
1170 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001171 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001172
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001175
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001178
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001181 { } /* end */
1182};
1183
Takashi Iwai1697055e2007-12-18 18:05:52 +01001184static struct snd_kcontrol_new stac_dmux_mixer = {
1185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1186 .name = "Digital Input Source",
1187 /* count set later */
1188 .info = stac92xx_dmux_enum_info,
1189 .get = stac92xx_dmux_enum_get,
1190 .put = stac92xx_dmux_enum_put,
1191};
1192
Matthew Ranostayd9737752008-09-07 12:03:41 +02001193static struct snd_kcontrol_new stac_smux_mixer = {
1194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001195 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001196 /* count set later */
1197 .info = stac92xx_smux_enum_info,
1198 .get = stac92xx_smux_enum_get,
1199 .put = stac92xx_smux_enum_put,
1200};
1201
Takashi Iwai2134ea42008-01-10 16:53:55 +01001202static const char *slave_vols[] = {
1203 "Front Playback Volume",
1204 "Surround Playback Volume",
1205 "Center Playback Volume",
1206 "LFE Playback Volume",
1207 "Side Playback Volume",
1208 "Headphone Playback Volume",
1209 "Headphone Playback Volume",
1210 "Speaker Playback Volume",
1211 "External Speaker Playback Volume",
1212 "Speaker2 Playback Volume",
1213 NULL
1214};
1215
1216static const char *slave_sws[] = {
1217 "Front Playback Switch",
1218 "Surround Playback Switch",
1219 "Center Playback Switch",
1220 "LFE Playback Switch",
1221 "Side Playback Switch",
1222 "Headphone Playback Switch",
1223 "Headphone Playback Switch",
1224 "Speaker Playback Switch",
1225 "External Speaker Playback Switch",
1226 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001227 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001228 NULL
1229};
1230
Matt2f2f4252005-04-13 14:45:30 +02001231static int stac92xx_build_controls(struct hda_codec *codec)
1232{
1233 struct sigmatel_spec *spec = codec->spec;
1234 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001235 int i;
Matt2f2f4252005-04-13 14:45:30 +02001236
1237 err = snd_hda_add_new_ctls(codec, spec->mixer);
1238 if (err < 0)
1239 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001240
1241 for (i = 0; i < spec->num_mixers; i++) {
1242 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1243 if (err < 0)
1244 return err;
1245 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001246 if (spec->num_dmuxes > 0) {
1247 stac_dmux_mixer.count = spec->num_dmuxes;
1248 err = snd_ctl_add(codec->bus->card,
1249 snd_ctl_new1(&stac_dmux_mixer, codec));
1250 if (err < 0)
1251 return err;
1252 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001253 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001254 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1255 struct hda_input_mux *smux = &spec->private_smux;
1256 /* check for mute support on SPDIF out */
1257 if (wcaps & AC_WCAP_OUT_AMP) {
1258 smux->items[smux->num_items].label = "Off";
1259 smux->items[smux->num_items].index = 0;
1260 smux->num_items++;
1261 spec->spdif_mute = 1;
1262 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001263 stac_smux_mixer.count = spec->num_smuxes;
1264 err = snd_ctl_add(codec->bus->card,
1265 snd_ctl_new1(&stac_smux_mixer, codec));
1266 if (err < 0)
1267 return err;
1268 }
Mattc7d4b2f2005-06-27 14:59:41 +02001269
Mattdabbed62005-06-14 10:19:34 +02001270 if (spec->multiout.dig_out_nid) {
1271 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1272 if (err < 0)
1273 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001274 err = snd_hda_create_spdif_share_sw(codec,
1275 &spec->multiout);
1276 if (err < 0)
1277 return err;
1278 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001279 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04001280 if (spec->dig_in_nid && (!spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001281 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1282 if (err < 0)
1283 return err;
1284 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001285
1286 /* if we have no master control, let's create it */
1287 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001288 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001289 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001290 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001291 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001292 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001293 if (err < 0)
1294 return err;
1295 }
1296 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1297 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1298 NULL, slave_sws);
1299 if (err < 0)
1300 return err;
1301 }
1302
Mattdabbed62005-06-14 10:19:34 +02001303 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001304}
1305
Matt Porter403d1942005-11-29 15:00:51 +01001306static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001307 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001308 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1309};
1310
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001311/*
1312 STAC 9200 pin configs for
1313 102801A8
1314 102801DE
1315 102801E8
1316*/
1317static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001318 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1319 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001320};
1321
1322/*
1323 STAC 9200 pin configs for
1324 102801C0
1325 102801C1
1326*/
1327static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001328 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1329 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001330};
1331
1332/*
1333 STAC 9200 pin configs for
1334 102801C4 (Dell Dimension E310)
1335 102801C5
1336 102801C7
1337 102801D9
1338 102801DA
1339 102801E3
1340*/
1341static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001342 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1343 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001344};
1345
1346
1347/*
1348 STAC 9200-32 pin configs for
1349 102801B5 (Dell Inspiron 630m)
1350 102801D8 (Dell Inspiron 640m)
1351*/
1352static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001353 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1354 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001355};
1356
1357/*
1358 STAC 9200-32 pin configs for
1359 102801C2 (Dell Latitude D620)
1360 102801C8
1361 102801CC (Dell Latitude D820)
1362 102801D4
1363 102801D6
1364*/
1365static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001366 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1367 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001368};
1369
1370/*
1371 STAC 9200-32 pin configs for
1372 102801CE (Dell XPS M1710)
1373 102801CF (Dell Precision M90)
1374*/
1375static unsigned int dell9200_m23_pin_configs[8] = {
1376 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1377 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1378};
1379
1380/*
1381 STAC 9200-32 pin configs for
1382 102801C9
1383 102801CA
1384 102801CB (Dell Latitude 120L)
1385 102801D3
1386*/
1387static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001388 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1389 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390};
1391
1392/*
1393 STAC 9200-32 pin configs for
1394 102801BD (Dell Inspiron E1505n)
1395 102801EE
1396 102801EF
1397*/
1398static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001399 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1400 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001401};
1402
1403/*
1404 STAC 9200-32 pin configs for
1405 102801F5 (Dell Inspiron 1501)
1406 102801F6
1407*/
1408static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001409 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1410 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001411};
1412
1413/*
1414 STAC 9200-32
1415 102801CD (Dell Inspiron E1705/9400)
1416*/
1417static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001418 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1419 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001420};
1421
Tobin Davisbf277782008-02-03 20:31:47 +01001422static unsigned int oqo9200_pin_configs[8] = {
1423 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1424 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1425};
1426
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001427
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001428static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1429 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001430 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001431 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1432 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1433 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1434 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1435 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1436 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1437 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1438 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1439 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1440 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001441 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001442};
1443
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001444static const char *stac9200_models[STAC_9200_MODELS] = {
1445 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001446 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001447 [STAC_9200_DELL_D21] = "dell-d21",
1448 [STAC_9200_DELL_D22] = "dell-d22",
1449 [STAC_9200_DELL_D23] = "dell-d23",
1450 [STAC_9200_DELL_M21] = "dell-m21",
1451 [STAC_9200_DELL_M22] = "dell-m22",
1452 [STAC_9200_DELL_M23] = "dell-m23",
1453 [STAC_9200_DELL_M24] = "dell-m24",
1454 [STAC_9200_DELL_M25] = "dell-m25",
1455 [STAC_9200_DELL_M26] = "dell-m26",
1456 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001457 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001458 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001459};
1460
1461static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1462 /* SigmaTel reference board */
1463 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1464 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001465 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1467 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001469 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1471 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1473 "unknown Dell", STAC_9200_DELL_D22),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1475 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001477 "Dell Latitude D620", STAC_9200_DELL_M22),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1479 "unknown Dell", STAC_9200_DELL_D23),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1481 "unknown Dell", STAC_9200_DELL_D23),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1483 "unknown Dell", STAC_9200_DELL_M22),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1485 "unknown Dell", STAC_9200_DELL_M24),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1487 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001489 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001491 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001493 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001495 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001497 "Dell Precision M90", STAC_9200_DELL_M23),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1499 "unknown Dell", STAC_9200_DELL_M22),
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1501 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001505 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1507 "unknown Dell", STAC_9200_DELL_D23),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1509 "unknown Dell", STAC_9200_DELL_D23),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1511 "unknown Dell", STAC_9200_DELL_D21),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1513 "unknown Dell", STAC_9200_DELL_D23),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1515 "unknown Dell", STAC_9200_DELL_D21),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1517 "unknown Dell", STAC_9200_DELL_M25),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1519 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001521 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1523 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001524 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001525 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001526 /* Gateway machines needs EAPD to be set on resume */
1527 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1528 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1529 STAC_9200_GATEWAY),
1530 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1531 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001532 /* OQO Mobile */
1533 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001534 {} /* terminator */
1535};
1536
Tobin Davis8e21c342007-01-08 11:04:17 +01001537static unsigned int ref925x_pin_configs[8] = {
1538 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001539 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001540};
1541
1542static unsigned int stac925x_MA6_pin_configs[8] = {
1543 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1544 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1545};
1546
Tobin Davis2c11f952007-05-17 09:36:34 +02001547static unsigned int stac925x_PA6_pin_configs[8] = {
1548 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1549 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1550};
1551
Tobin Davis8e21c342007-01-08 11:04:17 +01001552static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001553 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1554 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001555};
1556
1557static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1558 [STAC_REF] = ref925x_pin_configs,
1559 [STAC_M2_2] = stac925xM2_2_pin_configs,
1560 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001561 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001562};
1563
1564static const char *stac925x_models[STAC_925x_MODELS] = {
1565 [STAC_REF] = "ref",
1566 [STAC_M2_2] = "m2-2",
1567 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001568 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001569};
1570
1571static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1572 /* SigmaTel reference board */
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001574 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001575 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1576 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1577 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001578 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001579 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1580 {} /* terminator */
1581};
1582
Matthew Ranostaya7662642008-02-21 07:51:14 +01001583static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001584 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1585 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1586 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001587 0x01452050,
1588};
1589
1590static unsigned int dell_m6_pin_configs[13] = {
1591 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001592 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001593 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1594 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001595};
1596
1597static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001598 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1599 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001600};
1601
1602static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1603 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001604 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001605};
1606
1607static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1608 /* SigmaTel reference board */
1609 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001610 "DFI LanParty", STAC_92HD73XX_REF),
1611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1612 "unknown Dell", STAC_DELL_M6),
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1614 "unknown Dell", STAC_DELL_M6),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1616 "unknown Dell", STAC_DELL_M6),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1618 "unknown Dell", STAC_DELL_M6),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1620 "unknown Dell", STAC_DELL_M6),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1622 "unknown Dell", STAC_DELL_M6),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1624 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001625 {} /* terminator */
1626};
1627
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001628static unsigned int ref92hd83xxx_pin_configs[14] = {
1629 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1630 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1631 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1632 0x01451160, 0x98560170,
1633};
1634
1635static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1636 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1637};
1638
1639static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1640 [STAC_92HD83XXX_REF] = "ref",
1641};
1642
1643static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1644 /* SigmaTel reference board */
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1646 "DFI LanParty", STAC_92HD71BXX_REF),
1647};
1648
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001649static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001650 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001651 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001652 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001653};
1654
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001655static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001656 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001657 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001658 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001659};
1660
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001661static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001662 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1663 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001664 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001665};
1666
Matthew Ranostaye035b842007-11-06 11:53:55 +01001667static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1668 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001669 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1670 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001671 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001672};
1673
1674static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1675 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001676 [STAC_DELL_M4_1] = "dell-m4-1",
1677 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001678 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001679};
1680
1681static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1682 /* SigmaTel reference board */
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1684 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001685 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1686 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1688 "unknown Dell", STAC_DELL_M4_1),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1690 "unknown Dell", STAC_DELL_M4_1),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1692 "unknown Dell", STAC_DELL_M4_1),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1694 "unknown Dell", STAC_DELL_M4_1),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1696 "unknown Dell", STAC_DELL_M4_1),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1698 "unknown Dell", STAC_DELL_M4_1),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1700 "unknown Dell", STAC_DELL_M4_1),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1702 "unknown Dell", STAC_DELL_M4_2),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1704 "unknown Dell", STAC_DELL_M4_2),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1706 "unknown Dell", STAC_DELL_M4_2),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1708 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001709 {} /* terminator */
1710};
1711
Matt Porter403d1942005-11-29 15:00:51 +01001712static unsigned int ref922x_pin_configs[10] = {
1713 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1714 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001715 0x40000100, 0x40000100,
1716};
1717
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001718/*
1719 STAC 922X pin configs for
1720 102801A7
1721 102801AB
1722 102801A9
1723 102801D1
1724 102801D2
1725*/
1726static unsigned int dell_922x_d81_pin_configs[10] = {
1727 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1728 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1729 0x01813122, 0x400001f2,
1730};
1731
1732/*
1733 STAC 922X pin configs for
1734 102801AC
1735 102801D0
1736*/
1737static unsigned int dell_922x_d82_pin_configs[10] = {
1738 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1739 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1740 0x01813122, 0x400001f1,
1741};
1742
1743/*
1744 STAC 922X pin configs for
1745 102801BF
1746*/
1747static unsigned int dell_922x_m81_pin_configs[10] = {
1748 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1749 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1750 0x40C003f1, 0x405003f0,
1751};
1752
1753/*
1754 STAC 9221 A1 pin configs for
1755 102801D7 (Dell XPS M1210)
1756*/
1757static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001758 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1759 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001760 0x508003f3, 0x405003f4,
1761};
1762
Matt Porter403d1942005-11-29 15:00:51 +01001763static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001764 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001765 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1766 0x02a19120, 0x40000100,
1767};
1768
1769static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001770 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1771 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001772 0x02a19320, 0x40000100,
1773};
1774
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001775static unsigned int intel_mac_v1_pin_configs[10] = {
1776 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1777 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001778 0x400000fc, 0x400000fb,
1779};
1780
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001781static unsigned int intel_mac_v2_pin_configs[10] = {
1782 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1783 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001784 0x400000fc, 0x400000fb,
1785};
1786
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001787static unsigned int intel_mac_v3_pin_configs[10] = {
1788 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1789 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1790 0x400000fc, 0x400000fb,
1791};
1792
1793static unsigned int intel_mac_v4_pin_configs[10] = {
1794 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1795 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1796 0x400000fc, 0x400000fb,
1797};
1798
1799static unsigned int intel_mac_v5_pin_configs[10] = {
1800 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1801 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1802 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001803};
1804
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001805static unsigned int ecs202_pin_configs[10] = {
1806 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1807 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1808 0x9037012e, 0x40e000f2,
1809};
Takashi Iwai76c08822007-06-19 12:17:42 +02001810
Takashi Iwai19039bd2006-06-28 15:52:16 +02001811static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001812 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001813 [STAC_D945GTP3] = d945gtp3_pin_configs,
1814 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001815 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1816 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1817 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1818 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1819 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001820 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001821 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001822 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1823 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1824 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1825 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1826 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1827 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001828 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001829 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1830 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1831 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1832 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001833};
1834
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001835static const char *stac922x_models[STAC_922X_MODELS] = {
1836 [STAC_D945_REF] = "ref",
1837 [STAC_D945GTP5] = "5stack",
1838 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001839 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1840 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1841 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1842 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1843 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001844 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001845 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001846 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001847 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001848 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1849 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001850 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001851 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001852 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001853 [STAC_922X_DELL_D81] = "dell-d81",
1854 [STAC_922X_DELL_D82] = "dell-d82",
1855 [STAC_922X_DELL_M81] = "dell-m81",
1856 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001857};
1858
1859static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1860 /* SigmaTel reference board */
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1862 "DFI LanParty", STAC_D945_REF),
1863 /* Intel 945G based systems */
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1865 "Intel D945G", STAC_D945GTP3),
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1867 "Intel D945G", STAC_D945GTP3),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1869 "Intel D945G", STAC_D945GTP3),
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1871 "Intel D945G", STAC_D945GTP3),
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1873 "Intel D945G", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1875 "Intel D945G", STAC_D945GTP3),
1876 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1877 "Intel D945G", STAC_D945GTP3),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1879 "Intel D945G", STAC_D945GTP3),
1880 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1881 "Intel D945G", STAC_D945GTP3),
1882 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1883 "Intel D945G", STAC_D945GTP3),
1884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1885 "Intel D945G", STAC_D945GTP3),
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1887 "Intel D945G", STAC_D945GTP3),
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1893 "Intel D945G", STAC_D945GTP3),
1894 /* Intel D945G 5-stack systems */
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1896 "Intel D945G", STAC_D945GTP5),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1898 "Intel D945G", STAC_D945GTP5),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1900 "Intel D945G", STAC_D945GTP5),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1902 "Intel D945G", STAC_D945GTP5),
1903 /* Intel 945P based systems */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1905 "Intel D945P", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1907 "Intel D945P", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1909 "Intel D945P", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1911 "Intel D945P", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1913 "Intel D945P", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1915 "Intel D945P", STAC_D945GTP5),
1916 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001917 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001918 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001919 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001920 /* Dell systems */
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1922 "unknown Dell", STAC_922X_DELL_D81),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1924 "unknown Dell", STAC_922X_DELL_D81),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1926 "unknown Dell", STAC_922X_DELL_D81),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1928 "unknown Dell", STAC_922X_DELL_D82),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1930 "unknown Dell", STAC_922X_DELL_M81),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1932 "unknown Dell", STAC_922X_DELL_D82),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1934 "unknown Dell", STAC_922X_DELL_D81),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1936 "unknown Dell", STAC_922X_DELL_D81),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1938 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001939 /* ECS/PC Chips boards */
1940 SND_PCI_QUIRK(0x1019, 0x2144,
1941 "ECS/PC chips", STAC_ECS_202),
1942 SND_PCI_QUIRK(0x1019, 0x2608,
1943 "ECS/PC chips", STAC_ECS_202),
1944 SND_PCI_QUIRK(0x1019, 0x2633,
1945 "ECS/PC chips P17G/1333", STAC_ECS_202),
1946 SND_PCI_QUIRK(0x1019, 0x2811,
1947 "ECS/PC chips", STAC_ECS_202),
1948 SND_PCI_QUIRK(0x1019, 0x2812,
1949 "ECS/PC chips", STAC_ECS_202),
1950 SND_PCI_QUIRK(0x1019, 0x2813,
1951 "ECS/PC chips", STAC_ECS_202),
1952 SND_PCI_QUIRK(0x1019, 0x2814,
1953 "ECS/PC chips", STAC_ECS_202),
1954 SND_PCI_QUIRK(0x1019, 0x2815,
1955 "ECS/PC chips", STAC_ECS_202),
1956 SND_PCI_QUIRK(0x1019, 0x2816,
1957 "ECS/PC chips", STAC_ECS_202),
1958 SND_PCI_QUIRK(0x1019, 0x2817,
1959 "ECS/PC chips", STAC_ECS_202),
1960 SND_PCI_QUIRK(0x1019, 0x2818,
1961 "ECS/PC chips", STAC_ECS_202),
1962 SND_PCI_QUIRK(0x1019, 0x2819,
1963 "ECS/PC chips", STAC_ECS_202),
1964 SND_PCI_QUIRK(0x1019, 0x2820,
1965 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001966 {} /* terminator */
1967};
1968
Matt Porter3cc08dc2006-01-23 15:27:49 +01001969static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001970 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1971 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1972 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1973 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001974};
1975
Tobin Davis93ed1502006-09-01 21:03:12 +02001976static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001977 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1978 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1979 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1980 0x40000100, 0x40000100
1981};
1982
Tobin Davis93ed1502006-09-01 21:03:12 +02001983static unsigned int d965_5st_pin_configs[14] = {
1984 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1985 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1986 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1987 0x40000100, 0x40000100
1988};
1989
Tobin Davis4ff076e2007-08-07 11:48:12 +02001990static unsigned int dell_3st_pin_configs[14] = {
1991 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1992 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001993 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001994 0x40c003fc, 0x40000100
1995};
1996
Tobin Davis93ed1502006-09-01 21:03:12 +02001997static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001998 [STAC_D965_REF] = ref927x_pin_configs,
1999 [STAC_D965_3ST] = d965_3st_pin_configs,
2000 [STAC_D965_5ST] = d965_5st_pin_configs,
2001 [STAC_DELL_3ST] = dell_3st_pin_configs,
2002 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002003};
2004
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002005static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002006 [STAC_D965_REF] = "ref",
2007 [STAC_D965_3ST] = "3stack",
2008 [STAC_D965_5ST] = "5stack",
2009 [STAC_DELL_3ST] = "dell-3stack",
2010 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002011};
2012
2013static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2014 /* SigmaTel reference board */
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2016 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002017 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002020 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002037 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002040 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002042 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002051 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002061 {} /* terminator */
2062};
2063
Matt Porterf3302a52006-07-31 12:49:34 +02002064static unsigned int ref9205_pin_configs[12] = {
2065 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002066 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002067 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002068};
2069
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002070/*
2071 STAC 9205 pin configs for
2072 102801F1
2073 102801F2
2074 102801FC
2075 102801FD
2076 10280204
2077 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002078 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002079*/
2080static unsigned int dell_9205_m42_pin_configs[12] = {
2081 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2082 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2083 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2084};
2085
2086/*
2087 STAC 9205 pin configs for
2088 102801F9
2089 102801FA
2090 102801FE
2091 102801FF (Dell Precision M4300)
2092 10280206
2093 10280200
2094 10280201
2095*/
2096static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002097 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2098 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2099 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2100};
2101
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002102static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002103 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2104 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2105 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2106};
2107
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002108static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002109 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002110 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2111 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2112 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002113};
2114
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002115static const char *stac9205_models[STAC_9205_MODELS] = {
2116 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002117 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002118 [STAC_9205_DELL_M43] = "dell-m43",
2119 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002120};
2121
2122static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2123 /* SigmaTel reference board */
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2125 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002126 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2127 "unknown Dell", STAC_9205_DELL_M42),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2129 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002131 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2133 "Dell Precision", STAC_9205_DELL_M43),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2135 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2137 "unknown Dell", STAC_9205_DELL_M42),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2139 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2141 "Dell Precision", STAC_9205_DELL_M43),
2142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002143 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2145 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2147 "Dell Precision", STAC_9205_DELL_M43),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2149 "Dell Precision", STAC_9205_DELL_M43),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2151 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2153 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2155 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002156 {} /* terminator */
2157};
2158
Richard Fish11b44bb2006-08-23 18:31:34 +02002159static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2160{
2161 int i;
2162 struct sigmatel_spec *spec = codec->spec;
2163
2164 if (! spec->bios_pin_configs) {
2165 spec->bios_pin_configs = kcalloc(spec->num_pins,
2166 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2167 if (! spec->bios_pin_configs)
2168 return -ENOMEM;
2169 }
2170
2171 for (i = 0; i < spec->num_pins; i++) {
2172 hda_nid_t nid = spec->pin_nids[i];
2173 unsigned int pin_cfg;
2174
2175 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2176 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2177 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2178 nid, pin_cfg);
2179 spec->bios_pin_configs[i] = pin_cfg;
2180 }
2181
2182 return 0;
2183}
2184
Matthew Ranostay87d48362007-07-17 11:52:24 +02002185static void stac92xx_set_config_reg(struct hda_codec *codec,
2186 hda_nid_t pin_nid, unsigned int pin_config)
2187{
2188 int i;
2189 snd_hda_codec_write(codec, pin_nid, 0,
2190 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2191 pin_config & 0x000000ff);
2192 snd_hda_codec_write(codec, pin_nid, 0,
2193 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2194 (pin_config & 0x0000ff00) >> 8);
2195 snd_hda_codec_write(codec, pin_nid, 0,
2196 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2197 (pin_config & 0x00ff0000) >> 16);
2198 snd_hda_codec_write(codec, pin_nid, 0,
2199 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2200 pin_config >> 24);
2201 i = snd_hda_codec_read(codec, pin_nid, 0,
2202 AC_VERB_GET_CONFIG_DEFAULT,
2203 0x00);
2204 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2205 pin_nid, i);
2206}
2207
Matt2f2f4252005-04-13 14:45:30 +02002208static void stac92xx_set_config_regs(struct hda_codec *codec)
2209{
2210 int i;
2211 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002212
Matthew Ranostay87d48362007-07-17 11:52:24 +02002213 if (!spec->pin_configs)
2214 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002215
Matthew Ranostay87d48362007-07-17 11:52:24 +02002216 for (i = 0; i < spec->num_pins; i++)
2217 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2218 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002219}
Matt2f2f4252005-04-13 14:45:30 +02002220
Matt2f2f4252005-04-13 14:45:30 +02002221/*
2222 * Analog playback callbacks
2223 */
2224static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2225 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002226 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002227{
2228 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002229 if (spec->stream_delay)
2230 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002231 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2232 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002233}
2234
2235static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2236 struct hda_codec *codec,
2237 unsigned int stream_tag,
2238 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002239 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002240{
2241 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002242 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002243}
2244
2245static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2246 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002247 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002248{
2249 struct sigmatel_spec *spec = codec->spec;
2250 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2251}
2252
2253/*
Mattdabbed62005-06-14 10:19:34 +02002254 * Digital playback callbacks
2255 */
2256static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2257 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002258 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002259{
2260 struct sigmatel_spec *spec = codec->spec;
2261 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2262}
2263
2264static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2265 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002266 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002267{
2268 struct sigmatel_spec *spec = codec->spec;
2269 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2270}
2271
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002272static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2273 struct hda_codec *codec,
2274 unsigned int stream_tag,
2275 unsigned int format,
2276 struct snd_pcm_substream *substream)
2277{
2278 struct sigmatel_spec *spec = codec->spec;
2279 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2280 stream_tag, format, substream);
2281}
2282
Mattdabbed62005-06-14 10:19:34 +02002283
2284/*
Matt2f2f4252005-04-13 14:45:30 +02002285 * Analog capture callbacks
2286 */
2287static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2288 struct hda_codec *codec,
2289 unsigned int stream_tag,
2290 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002291 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002292{
2293 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002294 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002295
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002296 if (spec->powerdown_adcs) {
2297 msleep(40);
2298 snd_hda_codec_write_cache(codec, nid, 0,
2299 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2300 }
2301 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002302 return 0;
2303}
2304
2305static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2306 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002307 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002308{
2309 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002310 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002311
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002312 snd_hda_codec_cleanup_stream(codec, nid);
2313 if (spec->powerdown_adcs)
2314 snd_hda_codec_write_cache(codec, nid, 0,
2315 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002316 return 0;
2317}
2318
Mattdabbed62005-06-14 10:19:34 +02002319static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2320 .substreams = 1,
2321 .channels_min = 2,
2322 .channels_max = 2,
2323 /* NID is set in stac92xx_build_pcms */
2324 .ops = {
2325 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002326 .close = stac92xx_dig_playback_pcm_close,
2327 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002328 },
2329};
2330
2331static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2332 .substreams = 1,
2333 .channels_min = 2,
2334 .channels_max = 2,
2335 /* NID is set in stac92xx_build_pcms */
2336};
2337
Matt2f2f4252005-04-13 14:45:30 +02002338static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2339 .substreams = 1,
2340 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002341 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002342 .nid = 0x02, /* NID to query formats and rates */
2343 .ops = {
2344 .open = stac92xx_playback_pcm_open,
2345 .prepare = stac92xx_playback_pcm_prepare,
2346 .cleanup = stac92xx_playback_pcm_cleanup
2347 },
2348};
2349
Matt Porter3cc08dc2006-01-23 15:27:49 +01002350static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2351 .substreams = 1,
2352 .channels_min = 2,
2353 .channels_max = 2,
2354 .nid = 0x06, /* NID to query formats and rates */
2355 .ops = {
2356 .open = stac92xx_playback_pcm_open,
2357 .prepare = stac92xx_playback_pcm_prepare,
2358 .cleanup = stac92xx_playback_pcm_cleanup
2359 },
2360};
2361
Matt2f2f4252005-04-13 14:45:30 +02002362static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002363 .channels_min = 2,
2364 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002365 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002366 .ops = {
2367 .prepare = stac92xx_capture_pcm_prepare,
2368 .cleanup = stac92xx_capture_pcm_cleanup
2369 },
2370};
2371
2372static int stac92xx_build_pcms(struct hda_codec *codec)
2373{
2374 struct sigmatel_spec *spec = codec->spec;
2375 struct hda_pcm *info = spec->pcm_rec;
2376
2377 codec->num_pcms = 1;
2378 codec->pcm_info = info;
2379
Mattc7d4b2f2005-06-27 14:59:41 +02002380 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002381 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002382 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002383 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002384 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002385
2386 if (spec->alt_switch) {
2387 codec->num_pcms++;
2388 info++;
2389 info->name = "STAC92xx Analog Alt";
2390 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2391 }
Matt2f2f4252005-04-13 14:45:30 +02002392
Mattdabbed62005-06-14 10:19:34 +02002393 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2394 codec->num_pcms++;
2395 info++;
2396 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002397 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002398 if (spec->multiout.dig_out_nid) {
2399 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2400 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2401 }
2402 if (spec->dig_in_nid) {
2403 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2404 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2405 }
2406 }
2407
Matt2f2f4252005-04-13 14:45:30 +02002408 return 0;
2409}
2410
Takashi Iwaic960a032006-03-23 17:06:28 +01002411static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2412{
2413 unsigned int pincap = snd_hda_param_read(codec, nid,
2414 AC_PAR_PIN_CAP);
2415 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2416 if (pincap & AC_PINCAP_VREF_100)
2417 return AC_PINCTL_VREF_100;
2418 if (pincap & AC_PINCAP_VREF_80)
2419 return AC_PINCTL_VREF_80;
2420 if (pincap & AC_PINCAP_VREF_50)
2421 return AC_PINCTL_VREF_50;
2422 if (pincap & AC_PINCAP_VREF_GRD)
2423 return AC_PINCTL_VREF_GRD;
2424 return 0;
2425}
2426
Matt Porter403d1942005-11-29 15:00:51 +01002427static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2428
2429{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002430 snd_hda_codec_write_cache(codec, nid, 0,
2431 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002432}
2433
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002434#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2435
2436static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2437 struct snd_ctl_elem_value *ucontrol)
2438{
2439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2440 struct sigmatel_spec *spec = codec->spec;
2441
2442 ucontrol->value.integer.value[0] = spec->hp_switch;
2443 return 0;
2444}
2445
2446static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2447 struct snd_ctl_elem_value *ucontrol)
2448{
2449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2450 struct sigmatel_spec *spec = codec->spec;
2451
2452 spec->hp_switch = ucontrol->value.integer.value[0];
2453
2454 /* check to be sure that the ports are upto date with
2455 * switch changes
2456 */
2457 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2458
2459 return 1;
2460}
2461
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002462#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002463
2464static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2465{
2466 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2467 struct sigmatel_spec *spec = codec->spec;
2468 int io_idx = kcontrol-> private_value & 0xff;
2469
2470 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2471 return 0;
2472}
2473
2474static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2475{
2476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2477 struct sigmatel_spec *spec = codec->spec;
2478 hda_nid_t nid = kcontrol->private_value >> 8;
2479 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002480 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002481
2482 spec->io_switch[io_idx] = val;
2483
2484 if (val)
2485 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002486 else {
2487 unsigned int pinctl = AC_PINCTL_IN_EN;
2488 if (io_idx) /* set VREF for mic */
2489 pinctl |= stac92xx_get_vref(codec, nid);
2490 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2491 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002492
2493 /* check the auto-mute again: we need to mute/unmute the speaker
2494 * appropriately according to the pin direction
2495 */
2496 if (spec->hp_detect)
2497 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2498
Matt Porter403d1942005-11-29 15:00:51 +01002499 return 1;
2500}
2501
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002502#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2503
2504static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2505 struct snd_ctl_elem_value *ucontrol)
2506{
2507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2508 struct sigmatel_spec *spec = codec->spec;
2509
2510 ucontrol->value.integer.value[0] = spec->clfe_swap;
2511 return 0;
2512}
2513
2514static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2515 struct snd_ctl_elem_value *ucontrol)
2516{
2517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2518 struct sigmatel_spec *spec = codec->spec;
2519 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002520 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002521
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002522 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002523 return 0;
2524
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002525 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002526
2527 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2528 spec->clfe_swap ? 0x4 : 0x0);
2529
2530 return 1;
2531}
2532
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002533#define STAC_CODEC_HP_SWITCH(xname) \
2534 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2535 .name = xname, \
2536 .index = 0, \
2537 .info = stac92xx_hp_switch_info, \
2538 .get = stac92xx_hp_switch_get, \
2539 .put = stac92xx_hp_switch_put, \
2540 }
2541
Matt Porter403d1942005-11-29 15:00:51 +01002542#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2543 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2544 .name = xname, \
2545 .index = 0, \
2546 .info = stac92xx_io_switch_info, \
2547 .get = stac92xx_io_switch_get, \
2548 .put = stac92xx_io_switch_put, \
2549 .private_value = xpval, \
2550 }
2551
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002552#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2553 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2554 .name = xname, \
2555 .index = 0, \
2556 .info = stac92xx_clfe_switch_info, \
2557 .get = stac92xx_clfe_switch_get, \
2558 .put = stac92xx_clfe_switch_put, \
2559 .private_value = xpval, \
2560 }
Matt Porter403d1942005-11-29 15:00:51 +01002561
Mattc7d4b2f2005-06-27 14:59:41 +02002562enum {
2563 STAC_CTL_WIDGET_VOL,
2564 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002565 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002566 STAC_CTL_WIDGET_AMP_MUX,
2567 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002568 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002569 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002570 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002571};
2572
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002573static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002574 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2575 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002576 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002577 STAC_AMP_MUX,
2578 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002579 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002580 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002581 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002582};
2583
2584/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002585static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2586 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002587{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002588 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002589
2590 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2591 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2592
2593 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2594 if (! knew)
2595 return -ENOMEM;
2596 if (spec->kctl_alloc) {
2597 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2598 kfree(spec->kctl_alloc);
2599 }
2600 spec->kctl_alloc = knew;
2601 spec->num_kctl_alloc = num;
2602 }
2603
2604 knew = &spec->kctl_alloc[spec->num_kctl_used];
2605 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002606 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002607 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002608 if (! knew->name)
2609 return -ENOMEM;
2610 knew->private_value = val;
2611 spec->num_kctl_used++;
2612 return 0;
2613}
2614
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002615
2616/* add dynamic controls */
2617static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2618 const char *name, unsigned long val)
2619{
2620 return stac92xx_add_control_idx(spec, type, 0, name, val);
2621}
2622
Matt Porter403d1942005-11-29 15:00:51 +01002623/* flag inputs as additional dynamic lineouts */
2624static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2625{
2626 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002627 unsigned int wcaps, wtype;
2628 int i, num_dacs = 0;
2629
2630 /* use the wcaps cache to count all DACs available for line-outs */
2631 for (i = 0; i < codec->num_nodes; i++) {
2632 wcaps = codec->wcaps[i];
2633 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002634
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002635 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2636 num_dacs++;
2637 }
Matt Porter403d1942005-11-29 15:00:51 +01002638
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002639 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2640
Matt Porter403d1942005-11-29 15:00:51 +01002641 switch (cfg->line_outs) {
2642 case 3:
2643 /* add line-in as side */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002644 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002645 cfg->line_out_pins[cfg->line_outs] =
2646 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002647 spec->line_switch = 1;
2648 cfg->line_outs++;
2649 }
2650 break;
2651 case 2:
2652 /* add line-in as clfe and mic as side */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002653 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002654 cfg->line_out_pins[cfg->line_outs] =
2655 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002656 spec->line_switch = 1;
2657 cfg->line_outs++;
2658 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002659 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002660 cfg->line_out_pins[cfg->line_outs] =
2661 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002662 spec->mic_switch = 1;
2663 cfg->line_outs++;
2664 }
2665 break;
2666 case 1:
2667 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002668 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002669 cfg->line_out_pins[cfg->line_outs] =
2670 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002671 spec->line_switch = 1;
2672 cfg->line_outs++;
2673 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002674 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002675 cfg->line_out_pins[cfg->line_outs] =
2676 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002677 spec->mic_switch = 1;
2678 cfg->line_outs++;
2679 }
2680 break;
2681 }
2682
2683 return 0;
2684}
2685
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002686
2687static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2688{
2689 int i;
2690
2691 for (i = 0; i < spec->multiout.num_dacs; i++) {
2692 if (spec->multiout.dac_nids[i] == nid)
2693 return 1;
2694 }
2695
2696 return 0;
2697}
2698
Matt Porter3cc08dc2006-01-23 15:27:49 +01002699/*
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002700 * Fill in the dac_nids table from the parsed pin configuration
2701 * This function only works when every pin in line_out_pins[]
2702 * contains atleast one DAC in its connection list. Some 92xx
2703 * codecs are not connected directly to a DAC, such as the 9200
2704 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002705 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002706static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002707 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002708{
2709 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002710 int i, j, conn_len = 0;
2711 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2712 unsigned int wcaps, wtype;
2713
Mattc7d4b2f2005-06-27 14:59:41 +02002714 for (i = 0; i < cfg->line_outs; i++) {
2715 nid = cfg->line_out_pins[i];
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002716 conn_len = snd_hda_get_connections(codec, nid, conn,
2717 HDA_MAX_CONNECTIONS);
2718 for (j = 0; j < conn_len; j++) {
2719 wcaps = snd_hda_param_read(codec, conn[j],
2720 AC_PAR_AUDIO_WIDGET_CAP);
2721 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002722 if (wtype != AC_WID_AUD_OUT ||
2723 (wcaps & AC_WCAP_DIGITAL))
2724 continue;
2725 /* conn[j] is a DAC routed to this line-out */
2726 if (!is_in_dac_nids(spec, conn[j]))
2727 break;
2728 }
2729
2730 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002731 if (spec->multiout.num_dacs > 0) {
2732 /* we have already working output pins,
2733 * so let's drop the broken ones again
2734 */
2735 cfg->line_outs = spec->multiout.num_dacs;
2736 break;
2737 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002738 /* error out, no available DAC found */
2739 snd_printk(KERN_ERR
2740 "%s: No available DAC for pin 0x%x\n",
2741 __func__, nid);
2742 return -ENODEV;
2743 }
2744
2745 spec->multiout.dac_nids[i] = conn[j];
2746 spec->multiout.num_dacs++;
2747 if (conn_len > 1) {
2748 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002749 snd_hda_codec_write_cache(codec, nid, 0,
2750 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002751
2752 }
Mattc7d4b2f2005-06-27 14:59:41 +02002753 }
2754
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002755 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2756 spec->multiout.num_dacs,
2757 spec->multiout.dac_nids[0],
2758 spec->multiout.dac_nids[1],
2759 spec->multiout.dac_nids[2],
2760 spec->multiout.dac_nids[3],
2761 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002762 return 0;
2763}
2764
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002765/* create volume control/switch for the given prefx type */
2766static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2767{
2768 char name[32];
2769 int err;
2770
2771 sprintf(name, "%s Playback Volume", pfx);
2772 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2773 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2774 if (err < 0)
2775 return err;
2776 sprintf(name, "%s Playback Switch", pfx);
2777 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2778 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2779 if (err < 0)
2780 return err;
2781 return 0;
2782}
2783
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002784static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2785{
2786 if (!spec->multiout.hp_nid)
2787 spec->multiout.hp_nid = nid;
2788 else if (spec->multiout.num_dacs > 4) {
2789 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2790 return 1;
2791 } else {
2792 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2793 spec->multiout.num_dacs++;
2794 }
2795 return 0;
2796}
2797
2798static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2799{
2800 if (is_in_dac_nids(spec, nid))
2801 return 1;
2802 if (spec->multiout.hp_nid == nid)
2803 return 1;
2804 return 0;
2805}
2806
Mattc7d4b2f2005-06-27 14:59:41 +02002807/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002808static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002809 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002810{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002811 static const char *chname[4] = {
2812 "Front", "Surround", NULL /*CLFE*/, "Side"
2813 };
Mattc7d4b2f2005-06-27 14:59:41 +02002814 hda_nid_t nid;
2815 int i, err;
2816
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002817 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002818 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002819
2820
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002821 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002822 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002823 continue;
2824
2825 nid = spec->multiout.dac_nids[i];
2826
2827 if (i == 2) {
2828 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002829 err = create_controls(spec, "Center", nid, 1);
2830 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002831 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002832 err = create_controls(spec, "LFE", nid, 2);
2833 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002834 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002835
2836 wid_caps = get_wcaps(codec, nid);
2837
2838 if (wid_caps & AC_WCAP_LR_SWAP) {
2839 err = stac92xx_add_control(spec,
2840 STAC_CTL_WIDGET_CLFE_SWITCH,
2841 "Swap Center/LFE Playback Switch", nid);
2842
2843 if (err < 0)
2844 return err;
2845 }
2846
Mattc7d4b2f2005-06-27 14:59:41 +02002847 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002848 err = create_controls(spec, chname[i], nid, 3);
2849 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002850 return err;
2851 }
2852 }
2853
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002854 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2855 cfg->hp_outs && !spec->multiout.hp_nid)
2856 spec->multiout.hp_nid = nid;
2857
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002858 if (cfg->hp_outs > 1) {
2859 err = stac92xx_add_control(spec,
2860 STAC_CTL_WIDGET_HP_SWITCH,
2861 "Headphone as Line Out Switch", 0);
2862 if (err < 0)
2863 return err;
2864 }
2865
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002866 if (spec->line_switch) {
2867 nid = cfg->input_pins[AUTO_PIN_LINE];
2868 pincap = snd_hda_param_read(codec, nid,
2869 AC_PAR_PIN_CAP);
2870 if (pincap & AC_PINCAP_OUT) {
2871 err = stac92xx_add_control(spec,
2872 STAC_CTL_WIDGET_IO_SWITCH,
2873 "Line In as Output Switch", nid << 8);
2874 if (err < 0)
2875 return err;
2876 }
2877 }
Matt Porter403d1942005-11-29 15:00:51 +01002878
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002879 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002880 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002881 unsigned int mic_pin = AUTO_PIN_MIC;
2882again:
2883 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002884 def_conf = snd_hda_codec_read(codec, nid, 0,
2885 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002886 /* some laptops have an internal analog microphone
2887 * which can't be used as a output */
2888 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2889 pincap = snd_hda_param_read(codec, nid,
2890 AC_PAR_PIN_CAP);
2891 if (pincap & AC_PINCAP_OUT) {
2892 err = stac92xx_add_control(spec,
2893 STAC_CTL_WIDGET_IO_SWITCH,
2894 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002895 nid = snd_hda_codec_read(codec, nid, 0,
2896 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2897 if (!check_in_dac_nids(spec, nid))
2898 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002899 if (err < 0)
2900 return err;
2901 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002902 } else if (mic_pin == AUTO_PIN_MIC) {
2903 mic_pin = AUTO_PIN_FRONT_MIC;
2904 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002905 }
2906 }
Matt Porter403d1942005-11-29 15:00:51 +01002907
Mattc7d4b2f2005-06-27 14:59:41 +02002908 return 0;
2909}
2910
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002911/* add playback controls for Speaker and HP outputs */
2912static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2913 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002914{
2915 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002916 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002917 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002918
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002919 old_num_dacs = spec->multiout.num_dacs;
2920 for (i = 0; i < cfg->hp_outs; i++) {
2921 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2922 if (wid_caps & AC_WCAP_UNSOL_CAP)
2923 spec->hp_detect = 1;
2924 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2925 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2926 if (check_in_dac_nids(spec, nid))
2927 nid = 0;
2928 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002929 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002930 add_spec_dacs(spec, nid);
2931 }
2932 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002933 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002934 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2935 if (check_in_dac_nids(spec, nid))
2936 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002937 if (! nid)
2938 continue;
2939 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002940 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002941 for (i = 0; i < cfg->line_outs; i++) {
2942 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2943 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2944 if (check_in_dac_nids(spec, nid))
2945 nid = 0;
2946 if (! nid)
2947 continue;
2948 add_spec_dacs(spec, nid);
2949 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002950 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2951 static const char *pfxs[] = {
2952 "Speaker", "External Speaker", "Speaker2",
2953 };
2954 err = create_controls(spec, pfxs[i - old_num_dacs],
2955 spec->multiout.dac_nids[i], 3);
2956 if (err < 0)
2957 return err;
2958 }
2959 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002960 err = create_controls(spec, "Headphone",
2961 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002962 if (err < 0)
2963 return err;
2964 }
Mattc7d4b2f2005-06-27 14:59:41 +02002965
2966 return 0;
2967}
2968
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002969/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002970static const char *stac92xx_mono_labels[4] = {
2971 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002972};
2973
2974/* create mono mux for mono out on capable codecs */
2975static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2976{
2977 struct sigmatel_spec *spec = codec->spec;
2978 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2979 int i, num_cons;
2980 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2981
2982 num_cons = snd_hda_get_connections(codec,
2983 spec->mono_nid,
2984 con_lst,
2985 HDA_MAX_NUM_INPUTS);
2986 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2987 return -EINVAL;
2988
2989 for (i = 0; i < num_cons; i++) {
2990 mono_mux->items[mono_mux->num_items].label =
2991 stac92xx_mono_labels[i];
2992 mono_mux->items[mono_mux->num_items].index = i;
2993 mono_mux->num_items++;
2994 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002995
2996 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2997 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002998}
2999
Matthew Ranostay89385032008-09-11 09:49:39 -04003000/* labels for amp mux outputs */
3001static const char *stac92xx_amp_labels[3] = {
3002 "Front Microphone", "Microphone", "Line In"
3003};
3004
3005/* create amp out controls mux on capable codecs */
3006static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3007{
3008 struct sigmatel_spec *spec = codec->spec;
3009 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3010 int i, err;
3011
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003012 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003013 amp_mux->items[amp_mux->num_items].label =
3014 stac92xx_amp_labels[i];
3015 amp_mux->items[amp_mux->num_items].index = i;
3016 amp_mux->num_items++;
3017 }
3018
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003019 if (spec->num_amps > 1) {
3020 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3021 "Amp Selector Capture Switch", 0);
3022 if (err < 0)
3023 return err;
3024 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003025 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3026 "Amp Capture Volume",
3027 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3028}
3029
3030
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003031/* create PC beep volume controls */
3032static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3033 hda_nid_t nid)
3034{
3035 struct sigmatel_spec *spec = codec->spec;
3036 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3037 int err;
3038
3039 /* check for mute support for the the amp */
3040 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3041 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3042 "PC Beep Playback Switch",
3043 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3044 if (err < 0)
3045 return err;
3046 }
3047
3048 /* check to see if there is volume support for the amp */
3049 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3050 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3051 "PC Beep Playback Volume",
3052 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3053 if (err < 0)
3054 return err;
3055 }
3056 return 0;
3057}
3058
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003059static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3060{
3061 struct sigmatel_spec *spec = codec->spec;
3062 int wcaps, nid, i, err = 0;
3063
3064 for (i = 0; i < spec->num_muxes; i++) {
3065 nid = spec->mux_nids[i];
3066 wcaps = get_wcaps(codec, nid);
3067
3068 if (wcaps & AC_WCAP_OUT_AMP) {
3069 err = stac92xx_add_control_idx(spec,
3070 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3071 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3072 if (err < 0)
3073 return err;
3074 }
3075 }
3076 return 0;
3077};
3078
Matthew Ranostayd9737752008-09-07 12:03:41 +02003079static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003080 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003081};
3082
3083static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3084{
3085 struct sigmatel_spec *spec = codec->spec;
3086 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003087 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003088 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003089 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003090
3091 num_cons = snd_hda_get_connections(codec,
3092 spec->smux_nids[0],
3093 con_lst,
3094 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003095 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003096 return -EINVAL;
3097
Matthew Ranostay65973632008-09-16 10:39:37 -04003098 if (!labels)
3099 labels = stac92xx_spdif_labels;
3100
Matthew Ranostayd9737752008-09-07 12:03:41 +02003101 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003102 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003103 spdif_mux->items[spdif_mux->num_items].index = i;
3104 spdif_mux->num_items++;
3105 }
3106
3107 return 0;
3108}
3109
Matt Porter8b657272006-10-26 17:12:59 +02003110/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003111static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003112 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3113 "Digital Mic 3", "Digital Mic 4"
3114};
3115
3116/* create playback/capture controls for input pins on dmic capable codecs */
3117static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3118 const struct auto_pin_cfg *cfg)
3119{
3120 struct sigmatel_spec *spec = codec->spec;
3121 struct hda_input_mux *dimux = &spec->private_dimux;
3122 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003123 int err, i, j;
3124 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003125
3126 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3127 dimux->items[dimux->num_items].index = 0;
3128 dimux->num_items++;
3129
3130 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003131 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003132 int index;
3133 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003134 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003135 unsigned int def_conf;
3136
3137 def_conf = snd_hda_codec_read(codec,
3138 spec->dmic_nids[i],
3139 0,
3140 AC_VERB_GET_CONFIG_DEFAULT,
3141 0);
3142 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3143 continue;
3144
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003145 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003146 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003147 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003148 con_lst,
3149 HDA_MAX_NUM_INPUTS);
3150 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003151 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003152 index = j;
3153 goto found;
3154 }
3155 continue;
3156found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003157 wcaps = get_wcaps(codec, nid) &
3158 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003159
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003160 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003161 sprintf(name, "%s Capture Volume",
3162 stac92xx_dmic_labels[dimux->num_items]);
3163
3164 err = stac92xx_add_control(spec,
3165 STAC_CTL_WIDGET_VOL,
3166 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003167 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3168 (wcaps & AC_WCAP_OUT_AMP) ?
3169 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003170 if (err < 0)
3171 return err;
3172 }
3173
Matt Porter8b657272006-10-26 17:12:59 +02003174 dimux->items[dimux->num_items].label =
3175 stac92xx_dmic_labels[dimux->num_items];
3176 dimux->items[dimux->num_items].index = index;
3177 dimux->num_items++;
3178 }
3179
3180 return 0;
3181}
3182
Mattc7d4b2f2005-06-27 14:59:41 +02003183/* create playback/capture controls for input pins */
3184static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3185{
3186 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003187 struct hda_input_mux *imux = &spec->private_imux;
3188 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3189 int i, j, k;
3190
3191 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003192 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003193
Takashi Iwai314634b2006-09-21 11:56:18 +02003194 if (!cfg->input_pins[i])
3195 continue;
3196 index = -1;
3197 for (j = 0; j < spec->num_muxes; j++) {
3198 int num_cons;
3199 num_cons = snd_hda_get_connections(codec,
3200 spec->mux_nids[j],
3201 con_lst,
3202 HDA_MAX_NUM_INPUTS);
3203 for (k = 0; k < num_cons; k++)
3204 if (con_lst[k] == cfg->input_pins[i]) {
3205 index = k;
3206 goto found;
3207 }
Mattc7d4b2f2005-06-27 14:59:41 +02003208 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003209 continue;
3210 found:
3211 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3212 imux->items[imux->num_items].index = index;
3213 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003214 }
3215
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003216 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003217 /*
3218 * Set the current input for the muxes.
3219 * The STAC9221 has two input muxes with identical source
3220 * NID lists. Hopefully this won't get confused.
3221 */
3222 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003223 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3224 AC_VERB_SET_CONNECT_SEL,
3225 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003226 }
3227 }
3228
Mattc7d4b2f2005-06-27 14:59:41 +02003229 return 0;
3230}
3231
Mattc7d4b2f2005-06-27 14:59:41 +02003232static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3233{
3234 struct sigmatel_spec *spec = codec->spec;
3235 int i;
3236
3237 for (i = 0; i < spec->autocfg.line_outs; i++) {
3238 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3239 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3240 }
3241}
3242
3243static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3244{
3245 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003246 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003247
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003248 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3249 hda_nid_t pin;
3250 pin = spec->autocfg.hp_pins[i];
3251 if (pin) /* connect to front */
3252 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3253 }
3254 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3255 hda_nid_t pin;
3256 pin = spec->autocfg.speaker_pins[i];
3257 if (pin) /* connect to front */
3258 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3259 }
Mattc7d4b2f2005-06-27 14:59:41 +02003260}
3261
Matt Porter3cc08dc2006-01-23 15:27:49 +01003262static 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 +02003263{
3264 struct sigmatel_spec *spec = codec->spec;
3265 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003266 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003267
Matt Porter8b657272006-10-26 17:12:59 +02003268 if ((err = snd_hda_parse_pin_def_config(codec,
3269 &spec->autocfg,
3270 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003271 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003272 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003273 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003274
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003275 /* If we have no real line-out pin and multiple hp-outs, HPs should
3276 * be set up as multi-channel outputs.
3277 */
3278 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3279 spec->autocfg.hp_outs > 1) {
3280 /* Copy hp_outs to line_outs, backup line_outs in
3281 * speaker_outs so that the following routines can handle
3282 * HP pins as primary outputs.
3283 */
3284 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3285 sizeof(spec->autocfg.line_out_pins));
3286 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3287 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3288 sizeof(spec->autocfg.hp_pins));
3289 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3290 hp_speaker_swap = 1;
3291 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003292 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003293 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3294 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003295 u32 caps = query_amp_caps(codec,
3296 spec->autocfg.mono_out_pin, dir);
3297 hda_nid_t conn_list[1];
3298
3299 /* get the mixer node and then the mono mux if it exists */
3300 if (snd_hda_get_connections(codec,
3301 spec->autocfg.mono_out_pin, conn_list, 1) &&
3302 snd_hda_get_connections(codec, conn_list[0],
3303 conn_list, 1)) {
3304
3305 int wcaps = get_wcaps(codec, conn_list[0]);
3306 int wid_type = (wcaps & AC_WCAP_TYPE)
3307 >> AC_WCAP_TYPE_SHIFT;
3308 /* LR swap check, some stac925x have a mux that
3309 * changes the DACs output path instead of the
3310 * mono-mux path.
3311 */
3312 if (wid_type == AC_WID_AUD_SEL &&
3313 !(wcaps & AC_WCAP_LR_SWAP))
3314 spec->mono_nid = conn_list[0];
3315 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003316 if (dir) {
3317 hda_nid_t nid = spec->autocfg.mono_out_pin;
3318
3319 /* most mono outs have a least a mute/unmute switch */
3320 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3321 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3322 "Mono Playback Switch",
3323 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003324 if (err < 0)
3325 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003326 /* check for volume support for the amp */
3327 if ((caps & AC_AMPCAP_NUM_STEPS)
3328 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3329 err = stac92xx_add_control(spec,
3330 STAC_CTL_WIDGET_VOL,
3331 "Mono Playback Volume",
3332 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3333 if (err < 0)
3334 return err;
3335 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003336 }
3337
3338 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3339 AC_PINCTL_OUT_EN);
3340 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003341
Matt Porter403d1942005-11-29 15:00:51 +01003342 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3343 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003344 if (spec->multiout.num_dacs == 0)
3345 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3346 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003347
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003348 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3349
3350 if (err < 0)
3351 return err;
3352
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003353 /* setup analog beep controls */
3354 if (spec->anabeep_nid > 0) {
3355 err = stac92xx_auto_create_beep_ctls(codec,
3356 spec->anabeep_nid);
3357 if (err < 0)
3358 return err;
3359 }
3360
3361 /* setup digital beep controls and input device */
3362#ifdef CONFIG_SND_HDA_INPUT_BEEP
3363 if (spec->digbeep_nid > 0) {
3364 hda_nid_t nid = spec->digbeep_nid;
3365
3366 err = stac92xx_auto_create_beep_ctls(codec, nid);
3367 if (err < 0)
3368 return err;
3369 err = snd_hda_attach_beep_device(codec, nid);
3370 if (err < 0)
3371 return err;
3372 }
3373#endif
3374
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003375 if (hp_speaker_swap == 1) {
3376 /* Restore the hp_outs and line_outs */
3377 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3378 sizeof(spec->autocfg.line_out_pins));
3379 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3380 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3381 sizeof(spec->autocfg.speaker_pins));
3382 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3383 memset(spec->autocfg.speaker_pins, 0,
3384 sizeof(spec->autocfg.speaker_pins));
3385 spec->autocfg.speaker_outs = 0;
3386 }
3387
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003388 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3389
3390 if (err < 0)
3391 return err;
3392
3393 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3394
3395 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003396 return err;
3397
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003398 if (spec->mono_nid > 0) {
3399 err = stac92xx_auto_create_mono_output_ctls(codec);
3400 if (err < 0)
3401 return err;
3402 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003403 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003404 err = stac92xx_auto_create_amp_output_ctls(codec);
3405 if (err < 0)
3406 return err;
3407 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003408 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003409 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3410 &spec->autocfg)) < 0)
3411 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003412 if (spec->num_muxes > 0) {
3413 err = stac92xx_auto_create_mux_input_ctls(codec);
3414 if (err < 0)
3415 return err;
3416 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003417 if (spec->num_smuxes > 0) {
3418 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3419 if (err < 0)
3420 return err;
3421 }
Matt Porter8b657272006-10-26 17:12:59 +02003422
Mattc7d4b2f2005-06-27 14:59:41 +02003423 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003424 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003425 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003426
Takashi Iwai82bc9552006-03-21 11:24:42 +01003427 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003428 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003429 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003430 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003431
3432 if (spec->kctl_alloc)
3433 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3434
3435 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003436 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003437 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003438 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003439 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003440 return 1;
3441}
3442
Takashi Iwai82bc9552006-03-21 11:24:42 +01003443/* add playback controls for HP output */
3444static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3445 struct auto_pin_cfg *cfg)
3446{
3447 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003448 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003449 unsigned int wid_caps;
3450
3451 if (! pin)
3452 return 0;
3453
3454 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003455 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003456 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003457
3458 return 0;
3459}
3460
Richard Fish160ea0d2006-09-06 13:58:25 +02003461/* add playback controls for LFE output */
3462static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3463 struct auto_pin_cfg *cfg)
3464{
3465 struct sigmatel_spec *spec = codec->spec;
3466 int err;
3467 hda_nid_t lfe_pin = 0x0;
3468 int i;
3469
3470 /*
3471 * search speaker outs and line outs for a mono speaker pin
3472 * with an amp. If one is found, add LFE controls
3473 * for it.
3474 */
3475 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3476 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003477 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003478 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3479 if (wcaps == AC_WCAP_OUT_AMP)
3480 /* found a mono speaker with an amp, must be lfe */
3481 lfe_pin = pin;
3482 }
3483
3484 /* if speaker_outs is 0, then speakers may be in line_outs */
3485 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3486 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3487 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003488 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003489 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003490 AC_VERB_GET_CONFIG_DEFAULT,
3491 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003492 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003493 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003494 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3495 if (wcaps == AC_WCAP_OUT_AMP)
3496 /* found a mono speaker with an amp,
3497 must be lfe */
3498 lfe_pin = pin;
3499 }
3500 }
3501 }
3502
3503 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003504 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003505 if (err < 0)
3506 return err;
3507 }
3508
3509 return 0;
3510}
3511
Mattc7d4b2f2005-06-27 14:59:41 +02003512static int stac9200_parse_auto_config(struct hda_codec *codec)
3513{
3514 struct sigmatel_spec *spec = codec->spec;
3515 int err;
3516
Kailang Yangdf694da2005-12-05 19:42:22 +01003517 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003518 return err;
3519
3520 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3521 return err;
3522
Takashi Iwai82bc9552006-03-21 11:24:42 +01003523 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3524 return err;
3525
Richard Fish160ea0d2006-09-06 13:58:25 +02003526 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3527 return err;
3528
Takashi Iwai82bc9552006-03-21 11:24:42 +01003529 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003530 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003531 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003532 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003533
3534 if (spec->kctl_alloc)
3535 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3536
3537 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003538 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003539
3540 return 1;
3541}
3542
Sam Revitch62fe78e2006-05-10 15:09:17 +02003543/*
3544 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3545 * funky external mute control using GPIO pins.
3546 */
3547
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003548static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003549 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003550{
3551 unsigned int gpiostate, gpiomask, gpiodir;
3552
3553 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3554 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003555 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003556
3557 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3558 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003559 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003560
3561 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3562 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003563 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003564
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003565 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003566 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3567
3568 snd_hda_codec_write(codec, codec->afg, 0,
3569 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003570 snd_hda_codec_read(codec, codec->afg, 0,
3571 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003572
3573 msleep(1);
3574
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003575 snd_hda_codec_read(codec, codec->afg, 0,
3576 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003577}
3578
Takashi Iwai314634b2006-09-21 11:56:18 +02003579static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3580 unsigned int event)
3581{
3582 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003583 snd_hda_codec_write_cache(codec, nid, 0,
3584 AC_VERB_SET_UNSOLICITED_ENABLE,
3585 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003586}
3587
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003588static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3589{
3590 int i;
3591 for (i = 0; i < cfg->hp_outs; i++)
3592 if (cfg->hp_pins[i] == nid)
3593 return 1; /* nid is a HP-Out */
3594
3595 return 0; /* nid is not a HP-Out */
3596};
3597
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003598static void stac92xx_power_down(struct hda_codec *codec)
3599{
3600 struct sigmatel_spec *spec = codec->spec;
3601
3602 /* power down inactive DACs */
3603 hda_nid_t *dac;
3604 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003605 if (!is_in_dac_nids(spec, *dac) &&
3606 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003607 snd_hda_codec_write_cache(codec, *dac, 0,
3608 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3609}
3610
Mattc7d4b2f2005-06-27 14:59:41 +02003611static int stac92xx_init(struct hda_codec *codec)
3612{
3613 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003614 struct auto_pin_cfg *cfg = &spec->autocfg;
3615 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003616
Mattc7d4b2f2005-06-27 14:59:41 +02003617 snd_hda_sequence_write(codec, spec->init);
3618
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003619 /* power down adcs initially */
3620 if (spec->powerdown_adcs)
3621 for (i = 0; i < spec->num_adcs; i++)
3622 snd_hda_codec_write_cache(codec,
3623 spec->adc_nids[i], 0,
3624 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003625 /* set up pins */
3626 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003627 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003628 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003629 enable_pin_detect(codec, cfg->hp_pins[i],
3630 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003631 /* force to enable the first line-out; the others are set up
3632 * in unsol_event
3633 */
3634 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3635 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003636 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003637 /* fake event to set up pins */
3638 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3639 } else {
3640 stac92xx_auto_init_multi_out(codec);
3641 stac92xx_auto_init_hp_out(codec);
3642 }
3643 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003644 hda_nid_t nid = cfg->input_pins[i];
3645 if (nid) {
Matthew Ranostayb9aea7152008-10-09 08:37:28 -04003646 unsigned int pinctl = snd_hda_codec_read(codec, nid,
3647 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3648 /* if PINCTL already set then skip */
3649 if (pinctl & AC_PINCAP_IN)
3650 continue;
3651 pinctl = AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003652 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3653 pinctl |= stac92xx_get_vref(codec, nid);
3654 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3655 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003656 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003657 for (i = 0; i < spec->num_dmics; i++)
3658 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3659 AC_PINCTL_IN_EN);
3660 for (i = 0; i < spec->num_pwrs; i++) {
3661 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3662 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3663 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3664 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003665 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3666 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003667 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003668 /* outputs are only ports capable of power management
3669 * any attempts on powering down a input port cause the
3670 * referenced VREF to act quirky.
3671 */
3672 if (pinctl & AC_PINCTL_IN_EN)
3673 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003674 /* skip any ports that don't have jacks since presence
3675 * detection is useless */
3676 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003677 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003678 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3679 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3680 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003681 if (spec->dac_list)
3682 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003683 if (cfg->dig_out_pin)
3684 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3685 AC_PINCTL_OUT_EN);
3686 if (cfg->dig_in_pin)
3687 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3688 AC_PINCTL_IN_EN);
3689
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003690 stac_gpio_set(codec, spec->gpio_mask,
3691 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003692
Mattc7d4b2f2005-06-27 14:59:41 +02003693 return 0;
3694}
3695
Matt2f2f4252005-04-13 14:45:30 +02003696static void stac92xx_free(struct hda_codec *codec)
3697{
Mattc7d4b2f2005-06-27 14:59:41 +02003698 struct sigmatel_spec *spec = codec->spec;
3699 int i;
3700
3701 if (! spec)
3702 return;
3703
3704 if (spec->kctl_alloc) {
3705 for (i = 0; i < spec->num_kctl_used; i++)
3706 kfree(spec->kctl_alloc[i].name);
3707 kfree(spec->kctl_alloc);
3708 }
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 Longerbeam7b0438992007-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 Longerbeam7b0438992007-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 Ranostay4fe5195c2008-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 Ranostay4fe5195c2008-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
3857 switch ((res >> 26) & 0x30) {
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);
Takashi Iwai314634b2006-09-21 11:56:18 +02003864 }
3865}
3866
Takashi Iwaicb53c622007-08-10 17:21:45 +02003867#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003868static int stac92xx_resume(struct hda_codec *codec)
3869{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003870 struct sigmatel_spec *spec = codec->spec;
3871
Richard Fish11b44bb2006-08-23 18:31:34 +02003872 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003873 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003874 stac_gpio_set(codec, spec->gpio_mask,
3875 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003876 snd_hda_codec_resume_amp(codec);
3877 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003878 /* power down inactive DACs */
3879 if (spec->dac_list)
3880 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003881 /* invoke unsolicited event to reset the HP state */
3882 if (spec->hp_detect)
3883 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003884 return 0;
3885}
3886#endif
3887
Matt2f2f4252005-04-13 14:45:30 +02003888static struct hda_codec_ops stac92xx_patch_ops = {
3889 .build_controls = stac92xx_build_controls,
3890 .build_pcms = stac92xx_build_pcms,
3891 .init = stac92xx_init,
3892 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003893 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003894#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003895 .resume = stac92xx_resume,
3896#endif
Matt2f2f4252005-04-13 14:45:30 +02003897};
3898
3899static int patch_stac9200(struct hda_codec *codec)
3900{
3901 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003902 int err;
Matt2f2f4252005-04-13 14:45:30 +02003903
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003904 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003905 if (spec == NULL)
3906 return -ENOMEM;
3907
3908 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003909 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003910 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3912 stac9200_models,
3913 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003914 if (spec->board_config < 0) {
3915 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3916 err = stac92xx_save_bios_config_regs(codec);
3917 if (err < 0) {
3918 stac92xx_free(codec);
3919 return err;
3920 }
3921 spec->pin_configs = spec->bios_pin_configs;
3922 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003923 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3924 stac92xx_set_config_regs(codec);
3925 }
Matt2f2f4252005-04-13 14:45:30 +02003926
3927 spec->multiout.max_channels = 2;
3928 spec->multiout.num_dacs = 1;
3929 spec->multiout.dac_nids = stac9200_dac_nids;
3930 spec->adc_nids = stac9200_adc_nids;
3931 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003932 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003933 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003934 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003935 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003936
Tobin Davisbf277782008-02-03 20:31:47 +01003937 if (spec->board_config == STAC_9200_GATEWAY ||
3938 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003939 spec->init = stac9200_eapd_init;
3940 else
3941 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003942 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003943
Takashi Iwai117f2572008-03-18 09:53:23 +01003944 if (spec->board_config == STAC_9200_PANASONIC) {
3945 spec->gpio_mask = spec->gpio_dir = 0x09;
3946 spec->gpio_data = 0x00;
3947 }
3948
Mattc7d4b2f2005-06-27 14:59:41 +02003949 err = stac9200_parse_auto_config(codec);
3950 if (err < 0) {
3951 stac92xx_free(codec);
3952 return err;
3953 }
Matt2f2f4252005-04-13 14:45:30 +02003954
3955 codec->patch_ops = stac92xx_patch_ops;
3956
3957 return 0;
3958}
3959
Tobin Davis8e21c342007-01-08 11:04:17 +01003960static int patch_stac925x(struct hda_codec *codec)
3961{
3962 struct sigmatel_spec *spec;
3963 int err;
3964
3965 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3966 if (spec == NULL)
3967 return -ENOMEM;
3968
3969 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003970 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003971 spec->pin_nids = stac925x_pin_nids;
3972 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3973 stac925x_models,
3974 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003975 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003976 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003977 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3978 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003979 err = stac92xx_save_bios_config_regs(codec);
3980 if (err < 0) {
3981 stac92xx_free(codec);
3982 return err;
3983 }
3984 spec->pin_configs = spec->bios_pin_configs;
3985 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3986 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3987 stac92xx_set_config_regs(codec);
3988 }
3989
3990 spec->multiout.max_channels = 2;
3991 spec->multiout.num_dacs = 1;
3992 spec->multiout.dac_nids = stac925x_dac_nids;
3993 spec->adc_nids = stac925x_adc_nids;
3994 spec->mux_nids = stac925x_mux_nids;
3995 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003996 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003997 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003998 switch (codec->vendor_id) {
3999 case 0x83847632: /* STAC9202 */
4000 case 0x83847633: /* STAC9202D */
4001 case 0x83847636: /* STAC9251 */
4002 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004003 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004004 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004005 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4006 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004007 break;
4008 default:
4009 spec->num_dmics = 0;
4010 break;
4011 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004012
4013 spec->init = stac925x_core_init;
4014 spec->mixer = stac925x_mixer;
4015
4016 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004017 if (!err) {
4018 if (spec->board_config < 0) {
4019 printk(KERN_WARNING "hda_codec: No auto-config is "
4020 "available, default to model=ref\n");
4021 spec->board_config = STAC_925x_REF;
4022 goto again;
4023 }
4024 err = -EINVAL;
4025 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004026 if (err < 0) {
4027 stac92xx_free(codec);
4028 return err;
4029 }
4030
4031 codec->patch_ops = stac92xx_patch_ops;
4032
4033 return 0;
4034}
4035
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004036static struct hda_input_mux stac92hd73xx_dmux = {
4037 .num_items = 4,
4038 .items = {
4039 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004040 { "Digital Mic 1", 0x09 },
4041 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004042 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004043 }
4044};
4045
4046static int patch_stac92hd73xx(struct hda_codec *codec)
4047{
4048 struct sigmatel_spec *spec;
4049 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4050 int err = 0;
4051
4052 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4053 if (spec == NULL)
4054 return -ENOMEM;
4055
4056 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004057 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004058 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4059 spec->pin_nids = stac92hd73xx_pin_nids;
4060 spec->board_config = snd_hda_check_board_config(codec,
4061 STAC_92HD73XX_MODELS,
4062 stac92hd73xx_models,
4063 stac92hd73xx_cfg_tbl);
4064again:
4065 if (spec->board_config < 0) {
4066 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4067 " STAC92HD73XX, using BIOS defaults\n");
4068 err = stac92xx_save_bios_config_regs(codec);
4069 if (err < 0) {
4070 stac92xx_free(codec);
4071 return err;
4072 }
4073 spec->pin_configs = spec->bios_pin_configs;
4074 } else {
4075 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4076 stac92xx_set_config_regs(codec);
4077 }
4078
4079 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4080 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4081
4082 if (spec->multiout.num_dacs < 0) {
4083 printk(KERN_WARNING "hda_codec: Could not determine "
4084 "number of channels defaulting to DAC count\n");
4085 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4086 }
4087
4088 switch (spec->multiout.num_dacs) {
4089 case 0x3: /* 6 Channel */
4090 spec->mixer = stac92hd73xx_6ch_mixer;
4091 spec->init = stac92hd73xx_6ch_core_init;
4092 break;
4093 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004094 spec->mixer = stac92hd73xx_8ch_mixer;
4095 spec->init = stac92hd73xx_8ch_core_init;
4096 break;
4097 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004098 spec->mixer = stac92hd73xx_10ch_mixer;
4099 spec->init = stac92hd73xx_10ch_core_init;
4100 };
4101
4102 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4103 spec->aloopback_mask = 0x01;
4104 spec->aloopback_shift = 8;
4105
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004106 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004107 spec->mux_nids = stac92hd73xx_mux_nids;
4108 spec->adc_nids = stac92hd73xx_adc_nids;
4109 spec->dmic_nids = stac92hd73xx_dmic_nids;
4110 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004111 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004112 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004113 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004114
4115 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4116 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004117 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004118 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4119 sizeof(stac92hd73xx_dmux));
4120
Matthew Ranostaya7662642008-02-21 07:51:14 +01004121 switch (spec->board_config) {
4122 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004123 spec->init = dell_eq_core_init;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004124 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004125 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4126 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4127 spec->num_amps = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004128 switch (codec->subsystem_id) {
4129 case 0x1028025e: /* Analog Mics */
4130 case 0x1028025f:
4131 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4132 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004133 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004134 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004135 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004136 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004137 spec->init = dell_m6_core_init;
4138 /* fall-through */
4139 case 0x10280254:
4140 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004141 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4142 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004143 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004144 break;
4145 case 0x10280256: /* Both */
4146 case 0x10280057:
4147 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4148 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4149 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004150 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004151 break;
4152 }
4153 break;
4154 default:
4155 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004156 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004157 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004158 if (spec->board_config > STAC_92HD73XX_REF) {
4159 /* GPIO0 High = Enable EAPD */
4160 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4161 spec->gpio_data = 0x01;
4162 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004163 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004164
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004165 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4166 spec->pwr_nids = stac92hd73xx_pwr_nids;
4167
Matthew Ranostayd9737752008-09-07 12:03:41 +02004168 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004169
4170 if (!err) {
4171 if (spec->board_config < 0) {
4172 printk(KERN_WARNING "hda_codec: No auto-config is "
4173 "available, default to model=ref\n");
4174 spec->board_config = STAC_92HD73XX_REF;
4175 goto again;
4176 }
4177 err = -EINVAL;
4178 }
4179
4180 if (err < 0) {
4181 stac92xx_free(codec);
4182 return err;
4183 }
4184
4185 codec->patch_ops = stac92xx_patch_ops;
4186
4187 return 0;
4188}
4189
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004190static struct hda_input_mux stac92hd83xxx_dmux = {
4191 .num_items = 3,
4192 .items = {
4193 { "Analog Inputs", 0x03 },
4194 { "Digital Mic 1", 0x04 },
4195 { "Digital Mic 2", 0x05 },
4196 }
4197};
4198
4199static int patch_stac92hd83xxx(struct hda_codec *codec)
4200{
4201 struct sigmatel_spec *spec;
4202 int err;
4203
4204 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4205 if (spec == NULL)
4206 return -ENOMEM;
4207
4208 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004209 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004210 spec->mono_nid = 0x19;
4211 spec->digbeep_nid = 0x21;
4212 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4213 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4214 spec->adc_nids = stac92hd83xxx_adc_nids;
4215 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4216 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4217 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4218 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4219
4220 spec->init = stac92hd83xxx_core_init;
4221 switch (codec->vendor_id) {
4222 case 0x111d7605:
4223 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4224 break;
4225 default:
4226 spec->num_pwrs--;
4227 spec->init++; /* switch to config #2 */
4228 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4229 }
4230
4231 spec->mixer = stac92hd83xxx_mixer;
4232 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4233 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4234 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4235 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4236 spec->dinput_mux = &stac92hd83xxx_dmux;
4237 spec->pin_nids = stac92hd83xxx_pin_nids;
4238 spec->board_config = snd_hda_check_board_config(codec,
4239 STAC_92HD83XXX_MODELS,
4240 stac92hd83xxx_models,
4241 stac92hd83xxx_cfg_tbl);
4242again:
4243 if (spec->board_config < 0) {
4244 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4245 " STAC92HD83XXX, using BIOS defaults\n");
4246 err = stac92xx_save_bios_config_regs(codec);
4247 if (err < 0) {
4248 stac92xx_free(codec);
4249 return err;
4250 }
4251 spec->pin_configs = spec->bios_pin_configs;
4252 } else {
4253 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4254 stac92xx_set_config_regs(codec);
4255 }
4256
4257 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4258 if (!err) {
4259 if (spec->board_config < 0) {
4260 printk(KERN_WARNING "hda_codec: No auto-config is "
4261 "available, default to model=ref\n");
4262 spec->board_config = STAC_92HD83XXX_REF;
4263 goto again;
4264 }
4265 err = -EINVAL;
4266 }
4267
4268 if (err < 0) {
4269 stac92xx_free(codec);
4270 return err;
4271 }
4272
4273 codec->patch_ops = stac92xx_patch_ops;
4274
4275 return 0;
4276}
4277
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004278#ifdef SND_HDA_NEEDS_RESUME
4279static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4280{
4281 struct sigmatel_spec *spec = codec->spec;
4282 int i;
4283 snd_hda_codec_write_cache(codec, codec->afg, 0,
4284 AC_VERB_SET_POWER_STATE, pwr);
4285
4286 msleep(1);
4287 for (i = 0; i < spec->num_adcs; i++) {
4288 snd_hda_codec_write_cache(codec,
4289 spec->adc_nids[i], 0,
4290 AC_VERB_SET_POWER_STATE, pwr);
4291 }
4292};
4293
4294static int stac92hd71xx_resume(struct hda_codec *codec)
4295{
4296 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4297 return stac92xx_resume(codec);
4298}
4299
4300static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4301{
4302 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4303 return 0;
4304};
4305
4306#endif
4307
4308static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4309 .build_controls = stac92xx_build_controls,
4310 .build_pcms = stac92xx_build_pcms,
4311 .init = stac92xx_init,
4312 .free = stac92xx_free,
4313 .unsol_event = stac92xx_unsol_event,
4314#ifdef SND_HDA_NEEDS_RESUME
4315 .resume = stac92hd71xx_resume,
4316 .suspend = stac92hd71xx_suspend,
4317#endif
4318};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004319
Matthew Ranostaye035b842007-11-06 11:53:55 +01004320static int patch_stac92hd71bxx(struct hda_codec *codec)
4321{
4322 struct sigmatel_spec *spec;
4323 int err = 0;
4324
4325 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4326 if (spec == NULL)
4327 return -ENOMEM;
4328
4329 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004330 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004331 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004332 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004333 spec->pin_nids = stac92hd71bxx_pin_nids;
4334 spec->board_config = snd_hda_check_board_config(codec,
4335 STAC_92HD71BXX_MODELS,
4336 stac92hd71bxx_models,
4337 stac92hd71bxx_cfg_tbl);
4338again:
4339 if (spec->board_config < 0) {
4340 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4341 " STAC92HD71BXX, using BIOS defaults\n");
4342 err = stac92xx_save_bios_config_regs(codec);
4343 if (err < 0) {
4344 stac92xx_free(codec);
4345 return err;
4346 }
4347 spec->pin_configs = spec->bios_pin_configs;
4348 } else {
4349 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4350 stac92xx_set_config_regs(codec);
4351 }
4352
Matthew Ranostay541eee82007-12-14 12:08:04 +01004353 switch (codec->vendor_id) {
4354 case 0x111d76b6: /* 4 Port without Analog Mixer */
4355 case 0x111d76b7:
4356 case 0x111d76b4: /* 6 Port without Analog Mixer */
4357 case 0x111d76b5:
4358 spec->mixer = stac92hd71bxx_mixer;
4359 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004360 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004361 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004362 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004363 if ((codec->revision_id & 0xf) == 0 ||
4364 (codec->revision_id & 0xf) == 1) {
4365#ifdef SND_HDA_NEEDS_RESUME
4366 codec->patch_ops = stac92hd71bxx_patch_ops;
4367#endif
4368 spec->stream_delay = 40; /* 40 milliseconds */
4369 }
4370
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004371 /* no output amps */
4372 spec->num_pwrs = 0;
4373 spec->mixer = stac92hd71bxx_analog_mixer;
4374
4375 /* disable VSW */
4376 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4377 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4378 break;
4379 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004380 if ((codec->revision_id & 0xf) == 1) {
4381#ifdef SND_HDA_NEEDS_RESUME
4382 codec->patch_ops = stac92hd71bxx_patch_ops;
4383#endif
4384 spec->stream_delay = 40; /* 40 milliseconds */
4385 }
4386
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004387 /* no output amps */
4388 spec->num_pwrs = 0;
4389 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004390 default:
4391 spec->mixer = stac92hd71bxx_analog_mixer;
4392 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004393 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004394 }
4395
4396 spec->aloopback_mask = 0x20;
4397 spec->aloopback_shift = 0;
4398
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004399 if (spec->board_config > STAC_92HD71BXX_REF) {
4400 /* GPIO0 = EAPD */
4401 spec->gpio_mask = 0x01;
4402 spec->gpio_dir = 0x01;
4403 spec->gpio_data = 0x01;
4404 }
Matthew Ranostaye035b842007-11-06 11:53:55 +01004405
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004406 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004407 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004408 spec->mux_nids = stac92hd71bxx_mux_nids;
4409 spec->adc_nids = stac92hd71bxx_adc_nids;
4410 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004411 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004412 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004413 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004414
4415 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4416 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004417
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004418 switch (spec->board_config) {
4419 case STAC_HP_M4:
4420 spec->num_dmics = 0;
Matthew Ranostayb9aea7152008-10-09 08:37:28 -04004421 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004422 spec->num_dmuxes = 0;
4423
4424 /* enable internal microphone */
Matthew Ranostayb9aea7152008-10-09 08:37:28 -04004425 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4426 stac92xx_auto_set_pinctl(codec, 0x0e,
4427 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004428 break;
4429 default:
4430 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4431 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4432 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4433 };
4434
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004435 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004436 spec->multiout.hp_nid = 0x11;
4437 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4438
4439 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4440 if (!err) {
4441 if (spec->board_config < 0) {
4442 printk(KERN_WARNING "hda_codec: No auto-config is "
4443 "available, default to model=ref\n");
4444 spec->board_config = STAC_92HD71BXX_REF;
4445 goto again;
4446 }
4447 err = -EINVAL;
4448 }
4449
4450 if (err < 0) {
4451 stac92xx_free(codec);
4452 return err;
4453 }
4454
Matthew Ranostaye035b842007-11-06 11:53:55 +01004455 return 0;
4456};
4457
Matt2f2f4252005-04-13 14:45:30 +02004458static int patch_stac922x(struct hda_codec *codec)
4459{
4460 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004461 int err;
Matt2f2f4252005-04-13 14:45:30 +02004462
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004463 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004464 if (spec == NULL)
4465 return -ENOMEM;
4466
4467 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004468 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004469 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004470 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4471 stac922x_models,
4472 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004473 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004474 spec->gpio_mask = spec->gpio_dir = 0x03;
4475 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004476 /* Intel Macs have all same PCI SSID, so we need to check
4477 * codec SSID to distinguish the exact models
4478 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004479 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004480 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004481
4482 case 0x106b0800:
4483 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004484 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004485 case 0x106b0600:
4486 case 0x106b0700:
4487 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004488 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004489 case 0x106b0e00:
4490 case 0x106b0f00:
4491 case 0x106b1600:
4492 case 0x106b1700:
4493 case 0x106b0200:
4494 case 0x106b1e00:
4495 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004496 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004497 case 0x106b1a00:
4498 case 0x00000100:
4499 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004500 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004501 case 0x106b0a00:
4502 case 0x106b2200:
4503 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004504 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004505 default:
4506 spec->board_config = STAC_INTEL_MAC_V3;
4507 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004508 }
4509 }
4510
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004511 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004512 if (spec->board_config < 0) {
4513 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4514 "using BIOS defaults\n");
4515 err = stac92xx_save_bios_config_regs(codec);
4516 if (err < 0) {
4517 stac92xx_free(codec);
4518 return err;
4519 }
4520 spec->pin_configs = spec->bios_pin_configs;
4521 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004522 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4523 stac92xx_set_config_regs(codec);
4524 }
Matt2f2f4252005-04-13 14:45:30 +02004525
Matt2f2f4252005-04-13 14:45:30 +02004526 spec->adc_nids = stac922x_adc_nids;
4527 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004528 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004529 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004530 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004531 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004532
4533 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004534 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004535
4536 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004537
Matt Porter3cc08dc2006-01-23 15:27:49 +01004538 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004539 if (!err) {
4540 if (spec->board_config < 0) {
4541 printk(KERN_WARNING "hda_codec: No auto-config is "
4542 "available, default to model=ref\n");
4543 spec->board_config = STAC_D945_REF;
4544 goto again;
4545 }
4546 err = -EINVAL;
4547 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004548 if (err < 0) {
4549 stac92xx_free(codec);
4550 return err;
4551 }
4552
4553 codec->patch_ops = stac92xx_patch_ops;
4554
Takashi Iwai807a46362007-05-29 19:01:37 +02004555 /* Fix Mux capture level; max to 2 */
4556 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4557 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4558 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4559 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4560 (0 << AC_AMPCAP_MUTE_SHIFT));
4561
Matt Porter3cc08dc2006-01-23 15:27:49 +01004562 return 0;
4563}
4564
4565static int patch_stac927x(struct hda_codec *codec)
4566{
4567 struct sigmatel_spec *spec;
4568 int err;
4569
4570 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4571 if (spec == NULL)
4572 return -ENOMEM;
4573
4574 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004575 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004576 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004577 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4578 stac927x_models,
4579 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004580 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004581 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4582 if (spec->board_config < 0)
4583 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4584 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004585 err = stac92xx_save_bios_config_regs(codec);
4586 if (err < 0) {
4587 stac92xx_free(codec);
4588 return err;
4589 }
4590 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004591 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004592 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4593 stac92xx_set_config_regs(codec);
4594 }
4595
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004596 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004597 spec->adc_nids = stac927x_adc_nids;
4598 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4599 spec->mux_nids = stac927x_mux_nids;
4600 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004601 spec->smux_nids = stac927x_smux_nids;
4602 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004603 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004604 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004605 spec->multiout.dac_nids = spec->dac_nids;
4606
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004607 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004608 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004609 case STAC_D965_5ST:
4610 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004611 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004612 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004613 spec->num_dmics = 0;
4614
Tobin Davis93ed1502006-09-01 21:03:12 +02004615 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004616 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004617 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004618 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004619 switch (codec->subsystem_id) {
4620 case 0x10280209:
4621 case 0x1028022e:
4622 /* correct the device field to SPDIF out */
4623 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4624 break;
4625 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004626 /* configure the analog microphone on some laptops */
4627 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004628 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004629 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004630 /* correct the front input jack as a mic */
4631 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4632 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004633 case STAC_DELL_3ST:
4634 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004635 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004636 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004637 spec->dmic_nids = stac927x_dmic_nids;
4638 spec->num_dmics = STAC927X_NUM_DMICS;
4639
Tobin Davis93ed1502006-09-01 21:03:12 +02004640 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004641 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004642 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004643 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004644 break;
4645 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004646 if (spec->board_config > STAC_D965_REF) {
4647 /* GPIO0 High = Enable EAPD */
4648 spec->eapd_mask = spec->gpio_mask = 0x01;
4649 spec->gpio_dir = spec->gpio_data = 0x01;
4650 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004651 spec->num_dmics = 0;
4652
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004653 spec->init = stac927x_core_init;
4654 spec->mixer = stac927x_mixer;
4655 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004656
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004657 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004658 spec->aloopback_mask = 0x40;
4659 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004660
Matt Porter3cc08dc2006-01-23 15:27:49 +01004661 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004662 if (!err) {
4663 if (spec->board_config < 0) {
4664 printk(KERN_WARNING "hda_codec: No auto-config is "
4665 "available, default to model=ref\n");
4666 spec->board_config = STAC_D965_REF;
4667 goto again;
4668 }
4669 err = -EINVAL;
4670 }
Mattc7d4b2f2005-06-27 14:59:41 +02004671 if (err < 0) {
4672 stac92xx_free(codec);
4673 return err;
4674 }
Matt2f2f4252005-04-13 14:45:30 +02004675
4676 codec->patch_ops = stac92xx_patch_ops;
4677
Takashi Iwai52987652008-01-16 16:09:47 +01004678 /*
4679 * !!FIXME!!
4680 * The STAC927x seem to require fairly long delays for certain
4681 * command sequences. With too short delays (even if the answer
4682 * is set to RIRB properly), it results in the silence output
4683 * on some hardwares like Dell.
4684 *
4685 * The below flag enables the longer delay (see get_response
4686 * in hda_intel.c).
4687 */
4688 codec->bus->needs_damn_long_delay = 1;
4689
Matt2f2f4252005-04-13 14:45:30 +02004690 return 0;
4691}
4692
Matt Porterf3302a52006-07-31 12:49:34 +02004693static int patch_stac9205(struct hda_codec *codec)
4694{
4695 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004696 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004697
4698 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4699 if (spec == NULL)
4700 return -ENOMEM;
4701
4702 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004703 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004704 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004705 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4706 stac9205_models,
4707 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004708 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004709 if (spec->board_config < 0) {
4710 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4711 err = stac92xx_save_bios_config_regs(codec);
4712 if (err < 0) {
4713 stac92xx_free(codec);
4714 return err;
4715 }
4716 spec->pin_configs = spec->bios_pin_configs;
4717 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004718 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4719 stac92xx_set_config_regs(codec);
4720 }
4721
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004722 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004723 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004724 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004725 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004726 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004727 spec->smux_nids = stac9205_smux_nids;
4728 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004729 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004730 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004731 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004732 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004733 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004734
4735 spec->init = stac9205_core_init;
4736 spec->mixer = stac9205_mixer;
4737
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004738 spec->aloopback_mask = 0x40;
4739 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004740 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004741
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004742 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004743 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004744 /* Enable SPDIF in/out */
4745 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4746 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004747
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004748 /* Enable unsol response for GPIO4/Dock HP connection */
4749 snd_hda_codec_write(codec, codec->afg, 0,
4750 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4751 snd_hda_codec_write_cache(codec, codec->afg, 0,
4752 AC_VERB_SET_UNSOLICITED_ENABLE,
4753 (AC_USRSP_EN | STAC_HP_EVENT));
4754
4755 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004756 spec->eapd_mask = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004757 spec->gpio_mask = 0x1b;
4758 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004759 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004760 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004761 */
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004762 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004763 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004764 case STAC_9205_REF:
4765 /* SPDIF-In enabled */
4766 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004767 default:
4768 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004769 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004770 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004771 break;
4772 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004773
Matt Porterf3302a52006-07-31 12:49:34 +02004774 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004775 if (!err) {
4776 if (spec->board_config < 0) {
4777 printk(KERN_WARNING "hda_codec: No auto-config is "
4778 "available, default to model=ref\n");
4779 spec->board_config = STAC_9205_REF;
4780 goto again;
4781 }
4782 err = -EINVAL;
4783 }
Matt Porterf3302a52006-07-31 12:49:34 +02004784 if (err < 0) {
4785 stac92xx_free(codec);
4786 return err;
4787 }
4788
4789 codec->patch_ops = stac92xx_patch_ops;
4790
4791 return 0;
4792}
4793
Matt2f2f4252005-04-13 14:45:30 +02004794/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004795 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004796 */
4797
Guillaume Munch99ccc562006-08-16 19:35:12 +02004798/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004799static hda_nid_t vaio_dacs[] = { 0x2 };
4800#define VAIO_HP_DAC 0x5
4801static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4802static hda_nid_t vaio_mux_nids[] = { 0x15 };
4803
4804static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004805 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004806 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004807 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004808 { "Mic Jack", 0x1 },
4809 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004810 { "PCM", 0x3 },
4811 }
4812};
4813
4814static struct hda_verb vaio_init[] = {
4815 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004816 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004817 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4818 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4819 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004821 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004822 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4823 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4827 {}
4828};
4829
Guillaume Munch6d859062006-08-22 17:15:47 +02004830static struct hda_verb vaio_ar_init[] = {
4831 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4832 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4833 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4834 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4835/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004838 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4839 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4840/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4841 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4844 {}
4845};
4846
Takashi Iwaidb064e52006-03-16 16:04:58 +01004847/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004848static struct hda_bind_ctls vaio_bind_master_vol = {
4849 .ops = &snd_hda_bind_vol,
4850 .values = {
4851 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4852 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4853 0
4854 },
4855};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004856
4857/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004858static struct hda_bind_ctls vaio_bind_master_sw = {
4859 .ops = &snd_hda_bind_sw,
4860 .values = {
4861 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4862 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4863 0,
4864 },
4865};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004866
4867static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004868 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4869 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004870 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4871 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4872 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4873 {
4874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4875 .name = "Capture Source",
4876 .count = 1,
4877 .info = stac92xx_mux_enum_info,
4878 .get = stac92xx_mux_enum_get,
4879 .put = stac92xx_mux_enum_put,
4880 },
4881 {}
4882};
4883
Guillaume Munch6d859062006-08-22 17:15:47 +02004884static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004885 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4886 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004887 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4888 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4889 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4890 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4891 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4892 {
4893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4894 .name = "Capture Source",
4895 .count = 1,
4896 .info = stac92xx_mux_enum_info,
4897 .get = stac92xx_mux_enum_get,
4898 .put = stac92xx_mux_enum_put,
4899 },
4900 {}
4901};
4902
4903static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004904 .build_controls = stac92xx_build_controls,
4905 .build_pcms = stac92xx_build_pcms,
4906 .init = stac92xx_init,
4907 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004908#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004909 .resume = stac92xx_resume,
4910#endif
4911};
4912
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004913static int stac9872_vaio_init(struct hda_codec *codec)
4914{
4915 int err;
4916
4917 err = stac92xx_init(codec);
4918 if (err < 0)
4919 return err;
4920 if (codec->patch_ops.unsol_event)
4921 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4922 return 0;
4923}
4924
4925static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4926{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004927 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004928 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4929 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4930 } else {
4931 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4932 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4933 }
4934}
4935
4936static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4937{
4938 switch (res >> 26) {
4939 case STAC_HP_EVENT:
4940 stac9872_vaio_hp_detect(codec, res);
4941 break;
4942 }
4943}
4944
4945static struct hda_codec_ops stac9872_vaio_patch_ops = {
4946 .build_controls = stac92xx_build_controls,
4947 .build_pcms = stac92xx_build_pcms,
4948 .init = stac9872_vaio_init,
4949 .free = stac92xx_free,
4950 .unsol_event = stac9872_vaio_unsol_event,
4951#ifdef CONFIG_PM
4952 .resume = stac92xx_resume,
4953#endif
4954};
4955
Guillaume Munch6d859062006-08-22 17:15:47 +02004956enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4957 CXD9872RD_VAIO,
4958 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4959 STAC9872AK_VAIO,
4960 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4961 STAC9872K_VAIO,
4962 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004963 CXD9872AKD_VAIO,
4964 STAC_9872_MODELS,
4965};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004966
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004967static const char *stac9872_models[STAC_9872_MODELS] = {
4968 [CXD9872RD_VAIO] = "vaio",
4969 [CXD9872AKD_VAIO] = "vaio-ar",
4970};
4971
4972static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4973 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4974 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4975 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004976 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004977 {}
4978};
4979
Guillaume Munch6d859062006-08-22 17:15:47 +02004980static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004981{
4982 struct sigmatel_spec *spec;
4983 int board_config;
4984
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004985 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4986 stac9872_models,
4987 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004988 if (board_config < 0)
4989 /* unknown config, let generic-parser do its job... */
4990 return snd_hda_parse_generic_codec(codec);
4991
4992 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4993 if (spec == NULL)
4994 return -ENOMEM;
4995
4996 codec->spec = spec;
4997 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004998 case CXD9872RD_VAIO:
4999 case STAC9872AK_VAIO:
5000 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005001 spec->mixer = vaio_mixer;
5002 spec->init = vaio_init;
5003 spec->multiout.max_channels = 2;
5004 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5005 spec->multiout.dac_nids = vaio_dacs;
5006 spec->multiout.hp_nid = VAIO_HP_DAC;
5007 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5008 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005009 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005010 spec->input_mux = &vaio_mux;
5011 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005012 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005013 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005014
5015 case CXD9872AKD_VAIO:
5016 spec->mixer = vaio_ar_mixer;
5017 spec->init = vaio_ar_init;
5018 spec->multiout.max_channels = 2;
5019 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5020 spec->multiout.dac_nids = vaio_dacs;
5021 spec->multiout.hp_nid = VAIO_HP_DAC;
5022 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005023 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005024 spec->adc_nids = vaio_adcs;
5025 spec->input_mux = &vaio_mux;
5026 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005027 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005028 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005029 }
5030
Takashi Iwaidb064e52006-03-16 16:04:58 +01005031 return 0;
5032}
5033
5034
5035/*
Matt2f2f4252005-04-13 14:45:30 +02005036 * patch entries
5037 */
5038struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5039 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5040 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5041 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5042 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5043 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5044 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5045 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005046 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5047 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5048 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5049 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5050 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5051 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005052 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5053 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5054 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5055 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5056 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5057 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5058 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5059 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5060 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5061 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005062 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5063 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5064 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5065 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5066 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5067 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005068 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5069 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005070 /* The following does not take into account .id=0x83847661 when subsys =
5071 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5072 * currently not fully supported.
5073 */
5074 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5075 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5076 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005077 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5078 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5079 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5080 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5081 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5082 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5083 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5084 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005085 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005086 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5087 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005088 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005089 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5090 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005091 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005092 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5093 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5094 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5095 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5096 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5097 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5098 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5099 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005100 {} /* terminator */
5101};