blob: b254e90b47ca3da193dee9eb663c88da365cf8da [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 Ranostayc39555d2008-11-14 17:46:22 -050039
40#define STAC_VREF_EVENT 0x00
41#define STAC_INSERT_EVENT 0x10
Matthew Ranostaya64135a2008-01-10 16:55:06 +010042#define STAC_PWR_EVENT 0x20
43#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
46 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010047 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020048 STAC_9200_DELL_D21,
49 STAC_9200_DELL_D22,
50 STAC_9200_DELL_D23,
51 STAC_9200_DELL_M21,
52 STAC_9200_DELL_M22,
53 STAC_9200_DELL_M23,
54 STAC_9200_DELL_M24,
55 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020058 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010059 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010060 STAC_9200_MODELS
61};
62
63enum {
64 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020065 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020066 STAC_9205_DELL_M43,
67 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_9205_MODELS
69};
70
71enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010072 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010073 STAC_DELL_M6,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050074 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010075 STAC_92HD73XX_MODELS
76};
77
78enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020079 STAC_92HD83XXX_REF,
80 STAC_92HD83XXX_MODELS
81};
82
83enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010084 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010085 STAC_DELL_M4_1,
86 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040087 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010088 STAC_92HD71BXX_MODELS
89};
90
91enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010092 STAC_925x_REF,
93 STAC_M2_2,
94 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020095 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010096 STAC_925x_MODELS
97};
98
99enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100100 STAC_D945_REF,
101 STAC_D945GTP3,
102 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200103 STAC_INTEL_MAC_V1,
104 STAC_INTEL_MAC_V2,
105 STAC_INTEL_MAC_V3,
106 STAC_INTEL_MAC_V4,
107 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800108 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
109 * is given, one of the above models will be
110 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200111 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100112 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100113 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100114 STAC_MACBOOK_PRO_V1,
115 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200116 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200117 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300118 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200119 STAC_922X_DELL_D81,
120 STAC_922X_DELL_D82,
121 STAC_922X_DELL_M81,
122 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100123 STAC_922X_MODELS
124};
125
126enum {
127 STAC_D965_REF,
128 STAC_D965_3ST,
129 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200130 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100131 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100132 STAC_927X_MODELS
133};
Matt Porter403d1942005-11-29 15:00:51 +0100134
Matt2f2f4252005-04-13 14:45:30 +0200135struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100136 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200137 unsigned int num_mixers;
138
Matt Porter403d1942005-11-29 15:00:51 +0100139 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200140 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100141 unsigned int line_switch: 1;
142 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100143 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100144 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400145 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200146
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100147 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200148 unsigned int eapd_mask;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100149 unsigned int gpio_mask;
150 unsigned int gpio_dir;
151 unsigned int gpio_data;
152 unsigned int gpio_mute;
153
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200154 /* stream */
155 unsigned int stream_delay;
156
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100157 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100158 unsigned char aloopback_mask;
159 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200160
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100161 /* power management */
162 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200163 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100164 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100165 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100166
Matt2f2f4252005-04-13 14:45:30 +0200167 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100168 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400169 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100170 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200171 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100172 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200173
174 /* capture */
175 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200176 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200177 hda_nid_t *mux_nids;
178 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200179 hda_nid_t *dmic_nids;
180 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100181 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100182 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200183 hda_nid_t *smux_nids;
184 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400185 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200186
Mattdabbed62005-06-14 10:19:34 +0200187 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100188 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200189 hda_nid_t anabeep_nid;
190 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200191
Matt2f2f4252005-04-13 14:45:30 +0200192 /* pin widgets */
193 hda_nid_t *pin_nids;
194 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200195 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200196 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200197
198 /* codec specific stuff */
199 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100200 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200201
202 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200203 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100204 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200205 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100206 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200207 struct hda_input_mux *sinput_mux;
208 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400209 unsigned int cur_amux;
210 hda_nid_t *amp_nids;
211 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200212 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200213
Matt Porter403d1942005-11-29 15:00:51 +0100214 /* i/o switches */
215 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200216 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100217 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200218 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200219
Mattc7d4b2f2005-06-27 14:59:41 +0200220 struct hda_pcm pcm_rec[2]; /* PCM information */
221
222 /* dynamic controls and input_mux */
223 struct auto_pin_cfg autocfg;
224 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100225 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200226 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200227 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200228 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400229 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100230 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200231};
232
233static hda_nid_t stac9200_adc_nids[1] = {
234 0x03,
235};
236
237static hda_nid_t stac9200_mux_nids[1] = {
238 0x0c,
239};
240
241static hda_nid_t stac9200_dac_nids[1] = {
242 0x02,
243};
244
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100245static hda_nid_t stac92hd73xx_pwr_nids[8] = {
246 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
247 0x0f, 0x10, 0x11
248};
249
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400250static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
251 0x26, 0,
252};
253
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100254static hda_nid_t stac92hd73xx_adc_nids[2] = {
255 0x1a, 0x1b
256};
257
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400258#define DELL_M6_AMP 2
259static hda_nid_t stac92hd73xx_amp_nids[3] = {
260 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400261};
262
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100263#define STAC92HD73XX_NUM_DMICS 2
264static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
265 0x13, 0x14, 0
266};
267
268#define STAC92HD73_DAC_COUNT 5
269static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
270 0x15, 0x16, 0x17, 0x18, 0x19,
271};
272
273static hda_nid_t stac92hd73xx_mux_nids[4] = {
274 0x28, 0x29, 0x2a, 0x2b,
275};
276
277static hda_nid_t stac92hd73xx_dmux_nids[2] = {
278 0x20, 0x21,
279};
280
Matthew Ranostayd9737752008-09-07 12:03:41 +0200281static hda_nid_t stac92hd73xx_smux_nids[2] = {
282 0x22, 0x23,
283};
284
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200285#define STAC92HD83XXX_NUM_DMICS 2
286static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
287 0x11, 0x12, 0
288};
289
290#define STAC92HD81_DAC_COUNT 2
291#define STAC92HD83_DAC_COUNT 3
292static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
293 0x13, 0x14, 0x22,
294};
295
296static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
297 0x17, 0x18,
298};
299
300static hda_nid_t stac92hd83xxx_adc_nids[2] = {
301 0x15, 0x16,
302};
303
304static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
305 0xa, 0xb, 0xd, 0xe,
306};
307
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400308static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
309 0x1e, 0,
310};
311
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200312static unsigned int stac92hd83xxx_pwr_mapping[4] = {
313 0x03, 0x0c, 0x10, 0x40,
314};
315
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100316static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
317 0x0a, 0x0d, 0x0f
318};
319
Matthew Ranostaye035b842007-11-06 11:53:55 +0100320static hda_nid_t stac92hd71bxx_adc_nids[2] = {
321 0x12, 0x13,
322};
323
324static hda_nid_t stac92hd71bxx_mux_nids[2] = {
325 0x1a, 0x1b
326};
327
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400328static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
329 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100330};
331
Matthew Ranostayd9737752008-09-07 12:03:41 +0200332static hda_nid_t stac92hd71bxx_smux_nids[2] = {
333 0x24, 0x25,
334};
335
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100336static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100337 0x10, /*0x11, */
338};
339
340#define STAC92HD71BXX_NUM_DMICS 2
341static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
342 0x18, 0x19, 0
343};
344
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400345static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
346 0x22, 0
347};
348
Tobin Davis8e21c342007-01-08 11:04:17 +0100349static hda_nid_t stac925x_adc_nids[1] = {
350 0x03,
351};
352
353static hda_nid_t stac925x_mux_nids[1] = {
354 0x0f,
355};
356
357static hda_nid_t stac925x_dac_nids[1] = {
358 0x02,
359};
360
Takashi Iwaif6e98522007-10-16 14:27:04 +0200361#define STAC925X_NUM_DMICS 1
362static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
363 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200364};
365
Takashi Iwai1697055e2007-12-18 18:05:52 +0100366static hda_nid_t stac925x_dmux_nids[1] = {
367 0x14,
368};
369
Matt2f2f4252005-04-13 14:45:30 +0200370static hda_nid_t stac922x_adc_nids[2] = {
371 0x06, 0x07,
372};
373
374static hda_nid_t stac922x_mux_nids[2] = {
375 0x12, 0x13,
376};
377
Matt Porter3cc08dc2006-01-23 15:27:49 +0100378static hda_nid_t stac927x_adc_nids[3] = {
379 0x07, 0x08, 0x09
380};
381
382static hda_nid_t stac927x_mux_nids[3] = {
383 0x15, 0x16, 0x17
384};
385
Matthew Ranostayd9737752008-09-07 12:03:41 +0200386static hda_nid_t stac927x_smux_nids[1] = {
387 0x21,
388};
389
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100390static hda_nid_t stac927x_dac_nids[6] = {
391 0x02, 0x03, 0x04, 0x05, 0x06, 0
392};
393
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100394static hda_nid_t stac927x_dmux_nids[1] = {
395 0x1b,
396};
397
Matthew Ranostay7f168592007-10-18 17:38:17 +0200398#define STAC927X_NUM_DMICS 2
399static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
400 0x13, 0x14, 0
401};
402
Matthew Ranostay65973632008-09-16 10:39:37 -0400403static const char *stac927x_spdif_labels[5] = {
404 "Digital Playback", "ADAT", "Analog Mux 1",
405 "Analog Mux 2", "Analog Mux 3"
406};
407
Matt Porterf3302a52006-07-31 12:49:34 +0200408static hda_nid_t stac9205_adc_nids[2] = {
409 0x12, 0x13
410};
411
412static hda_nid_t stac9205_mux_nids[2] = {
413 0x19, 0x1a
414};
415
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100416static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100417 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100418};
419
Matthew Ranostayd9737752008-09-07 12:03:41 +0200420static hda_nid_t stac9205_smux_nids[1] = {
421 0x21,
422};
423
Takashi Iwaif6e98522007-10-16 14:27:04 +0200424#define STAC9205_NUM_DMICS 2
425static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
426 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200427};
428
Mattc7d4b2f2005-06-27 14:59:41 +0200429static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200430 0x08, 0x09, 0x0d, 0x0e,
431 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200432};
433
Tobin Davis8e21c342007-01-08 11:04:17 +0100434static hda_nid_t stac925x_pin_nids[8] = {
435 0x07, 0x08, 0x0a, 0x0b,
436 0x0c, 0x0d, 0x10, 0x11,
437};
438
Matt2f2f4252005-04-13 14:45:30 +0200439static hda_nid_t stac922x_pin_nids[10] = {
440 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
441 0x0f, 0x10, 0x11, 0x15, 0x1b,
442};
443
Matthew Ranostaya7662642008-02-21 07:51:14 +0100444static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100445 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
446 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200447 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100448};
449
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200450static hda_nid_t stac92hd83xxx_pin_nids[14] = {
451 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
452 0x0f, 0x10, 0x11, 0x12, 0x13,
453 0x1d, 0x1e, 0x1f, 0x20
454};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400455static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100456 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
457 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400458 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100459};
460
Matt Porter3cc08dc2006-01-23 15:27:49 +0100461static hda_nid_t stac927x_pin_nids[14] = {
462 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
463 0x0f, 0x10, 0x11, 0x12, 0x13,
464 0x14, 0x21, 0x22, 0x23,
465};
466
Matt Porterf3302a52006-07-31 12:49:34 +0200467static hda_nid_t stac9205_pin_nids[12] = {
468 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
469 0x0f, 0x14, 0x16, 0x17, 0x18,
470 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200471};
472
Matthew Ranostay89385032008-09-11 09:49:39 -0400473#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
474
475static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
476 struct snd_ctl_elem_value *ucontrol)
477{
478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
479 struct sigmatel_spec *spec = codec->spec;
480 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
481
482 kcontrol->private_value ^= get_amp_nid(kcontrol);
483 kcontrol->private_value |= nid;
484
485 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
486}
487
488static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
489 struct snd_ctl_elem_value *ucontrol)
490{
491 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
492 struct sigmatel_spec *spec = codec->spec;
493 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
494
495 kcontrol->private_value ^= get_amp_nid(kcontrol);
496 kcontrol->private_value |= nid;
497
498 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
499}
500
Matt Porter8b657272006-10-26 17:12:59 +0200501static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
502 struct snd_ctl_elem_info *uinfo)
503{
504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
505 struct sigmatel_spec *spec = codec->spec;
506 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
507}
508
509static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_value *ucontrol)
511{
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100514 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200515
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100516 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200517 return 0;
518}
519
520static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_value *ucontrol)
522{
523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
524 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100525 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200526
527 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100528 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200529}
530
Matthew Ranostayd9737752008-09-07 12:03:41 +0200531static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
532 struct snd_ctl_elem_info *uinfo)
533{
534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 struct sigmatel_spec *spec = codec->spec;
536 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
537}
538
539static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
541{
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 struct sigmatel_spec *spec = codec->spec;
544 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
545
546 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
547 return 0;
548}
549
550static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
552{
553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
554 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400555 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200556 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400557 int err, val;
558 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200559
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400560 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400562 if (err < 0)
563 return err;
564
565 if (spec->spdif_mute) {
566 if (smux_idx == 0)
567 nid = spec->multiout.dig_out_nid;
568 else
569 nid = codec->slave_dig_outs[smux_idx - 1];
570 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
571 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400572 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100573 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400574 /* un/mute SPDIF out */
575 snd_hda_codec_write_cache(codec, nid, 0,
576 AC_VERB_SET_AMP_GAIN_MUTE, val);
577 }
578 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200579}
580
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100581static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200582{
583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
584 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200585 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200586}
587
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100588static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200589{
590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
591 struct sigmatel_spec *spec = codec->spec;
592 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
593
594 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
595 return 0;
596}
597
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100598static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200599{
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 struct sigmatel_spec *spec = codec->spec;
602 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
603
Mattc7d4b2f2005-06-27 14:59:41 +0200604 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200605 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
606}
607
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100608static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_info *uinfo)
610{
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
613 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
614}
615
616static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
617 struct snd_ctl_elem_value *ucontrol)
618{
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 struct sigmatel_spec *spec = codec->spec;
621
622 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
623 return 0;
624}
625
626static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631
632 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
633 spec->mono_nid, &spec->cur_mmux);
634}
635
Matthew Ranostay89385032008-09-11 09:49:39 -0400636static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
637 struct snd_ctl_elem_info *uinfo)
638{
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 struct sigmatel_spec *spec = codec->spec;
641 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
642}
643
644static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646{
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
649
650 ucontrol->value.enumerated.item[0] = spec->cur_amux;
651 return 0;
652}
653
654static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
655 struct snd_ctl_elem_value *ucontrol)
656{
657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
658 struct sigmatel_spec *spec = codec->spec;
659 struct snd_kcontrol *ctl =
660 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
661 if (!ctl)
662 return -EINVAL;
663
664 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
665 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
666
667 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
668 0, &spec->cur_amux);
669}
670
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200671#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
672
673static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
674 struct snd_ctl_elem_value *ucontrol)
675{
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100677 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200678 struct sigmatel_spec *spec = codec->spec;
679
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100680 ucontrol->value.integer.value[0] = !!(spec->aloopback &
681 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200682 return 0;
683}
684
685static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
686 struct snd_ctl_elem_value *ucontrol)
687{
688 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
689 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100690 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200691 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100692 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200693
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100694 idx_val = spec->aloopback_mask << idx;
695 if (ucontrol->value.integer.value[0])
696 val = spec->aloopback | idx_val;
697 else
698 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100699 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200700 return 0;
701
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100702 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200703
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100704 /* Only return the bits defined by the shift value of the
705 * first two bytes of the mask
706 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100708 kcontrol->private_value & 0xFFFF, 0x0);
709 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200710
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100711 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200712 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200714 } else {
715 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100716 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200717 }
718
719 snd_hda_codec_write_cache(codec, codec->afg, 0,
720 kcontrol->private_value >> 16, dac_mode);
721
722 return 1;
723}
724
Mattc7d4b2f2005-06-27 14:59:41 +0200725static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200726 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200727 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200728 {}
729};
730
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200731static struct hda_verb stac9200_eapd_init[] = {
732 /* set dac0mux for dac converter */
733 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
734 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
735 {}
736};
737
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100738static struct hda_verb stac92hd73xx_6ch_core_init[] = {
739 /* set master volume and direct control */
740 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
741 /* setup audio connections */
742 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
743 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
744 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
745 /* setup adcs to point to mixer */
746 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
747 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100748 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
749 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
750 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
751 /* setup import muxs */
752 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
753 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
754 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
755 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
756 {}
757};
758
Matthew Ranostayd654a662008-03-14 08:46:51 +0100759static struct hda_verb dell_eq_core_init[] = {
760 /* set master volume to max value without distortion
761 * and direct control */
762 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
763 /* setup audio connections */
764 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400765 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
766 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100767 /* setup adcs to point to mixer */
768 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
769 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
770 /* setup import muxs */
771 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
772 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
773 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
774 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
775 {}
776};
777
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100778static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500779 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
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 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
864 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
865 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
866 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100867};
868
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400869#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100870static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200871 /* start of config #1 */
872
873 /* connect port 0f to audio mixer */
874 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200875 /* unmute right and left channels for node 0x0f */
876 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
877 /* start of config #2 */
878
Matthew Ranostay541eee82007-12-14 12:08:04 +0100879 /* set master volume and direct control */
880 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
881 /* connect headphone jack to dac1 */
882 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200883 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100884 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
885 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100886 {}
887};
888
Tobin Davis8e21c342007-01-08 11:04:17 +0100889static struct hda_verb stac925x_core_init[] = {
890 /* set dac0mux for dac converter */
891 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
892 {}
893};
894
Mattc7d4b2f2005-06-27 14:59:41 +0200895static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200896 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200897 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200898 {}
899};
900
Tobin Davis93ed1502006-09-01 21:03:12 +0200901static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200902 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200903 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200904 /* unmute node 0x1b */
905 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
906 /* select node 0x03 as DAC */
907 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
908 {}
909};
910
Matt Porter3cc08dc2006-01-23 15:27:49 +0100911static struct hda_verb stac927x_core_init[] = {
912 /* set master volume and direct control */
913 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200914 /* enable analog pc beep path */
915 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100916 {}
917};
918
Matt Porterf3302a52006-07-31 12:49:34 +0200919static struct hda_verb stac9205_core_init[] = {
920 /* set master volume and direct control */
921 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200922 /* enable analog pc beep path */
923 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200924 {}
925};
926
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100927#define STAC_MONO_MUX \
928 { \
929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
930 .name = "Mono Mux", \
931 .count = 1, \
932 .info = stac92xx_mono_mux_enum_info, \
933 .get = stac92xx_mono_mux_enum_get, \
934 .put = stac92xx_mono_mux_enum_put, \
935 }
936
Matthew Ranostay89385032008-09-11 09:49:39 -0400937#define STAC_AMP_MUX \
938 { \
939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
940 .name = "Amp Selector Capture Switch", \
941 .count = 1, \
942 .info = stac92xx_amp_mux_enum_info, \
943 .get = stac92xx_amp_mux_enum_get, \
944 .put = stac92xx_amp_mux_enum_put, \
945 }
946
947#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
948 { \
949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
950 .name = xname, \
951 .index = 0, \
952 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
953 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
954 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
955 .info = stac92xx_amp_volume_info, \
956 .get = stac92xx_amp_volume_get, \
957 .put = stac92xx_amp_volume_put, \
958 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
959 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
960 }
961
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200962#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200963 { \
964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
965 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200966 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200967 .info = stac92xx_mux_enum_info, \
968 .get = stac92xx_mux_enum_get, \
969 .put = stac92xx_mux_enum_put, \
970 }
971
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100972#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200973 { \
974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
975 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100976 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200977 .info = stac92xx_aloopback_info, \
978 .get = stac92xx_aloopback_get, \
979 .put = stac92xx_aloopback_put, \
980 .private_value = verb_read | (verb_write << 16), \
981 }
982
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100983static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200984 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
985 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200986 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200987 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
988 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200989 { } /* end */
990};
991
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400992#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100993static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400994 /* start of config #1 */
995 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
996 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
997
998 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
999 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1000
1001 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1002 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1003
1004 /* start of config #2 */
1005 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1006 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1007
1008 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1009 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1010
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001011 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1012
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001013 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1014 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1015
1016 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1017 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1018
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001019 { } /* end */
1020};
1021
1022static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001023 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1024
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001025 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1026 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1027
1028 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1029 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1030
1031 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1032 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1033
1034 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1035 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1036
1037 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1038 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1039
1040 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1041 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1042
1043 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1044 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1045 { } /* end */
1046};
1047
1048static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001049 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1050
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001051 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1053
1054 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1055 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1056
1057 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1058 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1059
1060 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1061 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1062
1063 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1064 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1065
1066 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1067 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1068
1069 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1070 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1071 { } /* end */
1072};
1073
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001074
1075static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1076 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1077 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1078
1079 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1080 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1081
1082 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1083 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1084
1085 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1086 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1087
1088 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1089 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1090
1091 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1092 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1093
1094 /*
1095 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1096 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1097 */
1098 { } /* end */
1099};
1100
Matthew Ranostay541eee82007-12-14 12:08:04 +01001101static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001102 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001103 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001104
Matthew Ranostay9b359472007-11-07 13:03:12 +01001105 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1106 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001107
1108 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1109 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001110 /* analog pc-beep replaced with digital beep support */
1111 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001112 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1113 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001114 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001115
Matthew Ranostay687cb982008-10-11 13:52:43 -04001116 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1117 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001118
Matthew Ranostay687cb982008-10-11 13:52:43 -04001119 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1120 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001121
1122 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1123 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1124
1125 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1126 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001127 { } /* end */
1128};
1129
Matthew Ranostay541eee82007-12-14 12:08:04 +01001130static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001131 STAC_INPUT_SOURCE(2),
1132 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1133
Matthew Ranostay541eee82007-12-14 12:08:04 +01001134 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1135 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001136
1137 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001139 { } /* end */
1140};
1141
Tobin Davis8e21c342007-01-08 11:04:17 +01001142static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001143 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001144 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001145 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001146 { } /* end */
1147};
1148
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001149static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001150 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001151 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001152
1153 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1154 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155
1156 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1157 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001158 { } /* end */
1159};
1160
1161/* This needs to be generated dynamically based on sequence */
1162static struct snd_kcontrol_new stac922x_mixer[] = {
1163 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001164 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1165 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166
1167 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001169 { } /* end */
1170};
1171
1172
1173static struct snd_kcontrol_new stac927x_mixer[] = {
1174 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001175 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001176
1177 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001179
1180 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001182
1183 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1184 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001185 { } /* end */
1186};
1187
Takashi Iwai1697055e2007-12-18 18:05:52 +01001188static struct snd_kcontrol_new stac_dmux_mixer = {
1189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1190 .name = "Digital Input Source",
1191 /* count set later */
1192 .info = stac92xx_dmux_enum_info,
1193 .get = stac92xx_dmux_enum_get,
1194 .put = stac92xx_dmux_enum_put,
1195};
1196
Matthew Ranostayd9737752008-09-07 12:03:41 +02001197static struct snd_kcontrol_new stac_smux_mixer = {
1198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001199 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001200 /* count set later */
1201 .info = stac92xx_smux_enum_info,
1202 .get = stac92xx_smux_enum_get,
1203 .put = stac92xx_smux_enum_put,
1204};
1205
Takashi Iwai2134ea42008-01-10 16:53:55 +01001206static const char *slave_vols[] = {
1207 "Front Playback Volume",
1208 "Surround Playback Volume",
1209 "Center Playback Volume",
1210 "LFE Playback Volume",
1211 "Side Playback Volume",
1212 "Headphone Playback Volume",
1213 "Headphone Playback Volume",
1214 "Speaker Playback Volume",
1215 "External Speaker Playback Volume",
1216 "Speaker2 Playback Volume",
1217 NULL
1218};
1219
1220static const char *slave_sws[] = {
1221 "Front Playback Switch",
1222 "Surround Playback Switch",
1223 "Center Playback Switch",
1224 "LFE Playback Switch",
1225 "Side Playback Switch",
1226 "Headphone Playback Switch",
1227 "Headphone Playback Switch",
1228 "Speaker Playback Switch",
1229 "External Speaker Playback Switch",
1230 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001231 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001232 NULL
1233};
1234
Matt2f2f4252005-04-13 14:45:30 +02001235static int stac92xx_build_controls(struct hda_codec *codec)
1236{
1237 struct sigmatel_spec *spec = codec->spec;
1238 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001239 int i;
Matt2f2f4252005-04-13 14:45:30 +02001240
1241 err = snd_hda_add_new_ctls(codec, spec->mixer);
1242 if (err < 0)
1243 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001244
1245 for (i = 0; i < spec->num_mixers; i++) {
1246 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1247 if (err < 0)
1248 return err;
1249 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001250 if (spec->num_dmuxes > 0) {
1251 stac_dmux_mixer.count = spec->num_dmuxes;
1252 err = snd_ctl_add(codec->bus->card,
1253 snd_ctl_new1(&stac_dmux_mixer, codec));
1254 if (err < 0)
1255 return err;
1256 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001257 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001258 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1259 struct hda_input_mux *smux = &spec->private_smux;
1260 /* check for mute support on SPDIF out */
1261 if (wcaps & AC_WCAP_OUT_AMP) {
1262 smux->items[smux->num_items].label = "Off";
1263 smux->items[smux->num_items].index = 0;
1264 smux->num_items++;
1265 spec->spdif_mute = 1;
1266 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001267 stac_smux_mixer.count = spec->num_smuxes;
1268 err = snd_ctl_add(codec->bus->card,
1269 snd_ctl_new1(&stac_smux_mixer, codec));
1270 if (err < 0)
1271 return err;
1272 }
Mattc7d4b2f2005-06-27 14:59:41 +02001273
Mattdabbed62005-06-14 10:19:34 +02001274 if (spec->multiout.dig_out_nid) {
1275 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1276 if (err < 0)
1277 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001278 err = snd_hda_create_spdif_share_sw(codec,
1279 &spec->multiout);
1280 if (err < 0)
1281 return err;
1282 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001283 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001284 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001285 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1286 if (err < 0)
1287 return err;
1288 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001289
1290 /* if we have no master control, let's create it */
1291 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001292 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001293 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001294 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001295 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001296 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001297 if (err < 0)
1298 return err;
1299 }
1300 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1301 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1302 NULL, slave_sws);
1303 if (err < 0)
1304 return err;
1305 }
1306
Mattdabbed62005-06-14 10:19:34 +02001307 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001308}
1309
Matt Porter403d1942005-11-29 15:00:51 +01001310static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001311 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001312 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1313};
1314
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001315/*
1316 STAC 9200 pin configs for
1317 102801A8
1318 102801DE
1319 102801E8
1320*/
1321static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001322 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1323 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001324};
1325
1326/*
1327 STAC 9200 pin configs for
1328 102801C0
1329 102801C1
1330*/
1331static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001332 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1333 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001334};
1335
1336/*
1337 STAC 9200 pin configs for
1338 102801C4 (Dell Dimension E310)
1339 102801C5
1340 102801C7
1341 102801D9
1342 102801DA
1343 102801E3
1344*/
1345static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001346 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1347 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001348};
1349
1350
1351/*
1352 STAC 9200-32 pin configs for
1353 102801B5 (Dell Inspiron 630m)
1354 102801D8 (Dell Inspiron 640m)
1355*/
1356static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001357 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1358 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001359};
1360
1361/*
1362 STAC 9200-32 pin configs for
1363 102801C2 (Dell Latitude D620)
1364 102801C8
1365 102801CC (Dell Latitude D820)
1366 102801D4
1367 102801D6
1368*/
1369static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001370 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1371 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001372};
1373
1374/*
1375 STAC 9200-32 pin configs for
1376 102801CE (Dell XPS M1710)
1377 102801CF (Dell Precision M90)
1378*/
1379static unsigned int dell9200_m23_pin_configs[8] = {
1380 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1381 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1382};
1383
1384/*
1385 STAC 9200-32 pin configs for
1386 102801C9
1387 102801CA
1388 102801CB (Dell Latitude 120L)
1389 102801D3
1390*/
1391static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001392 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1393 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001394};
1395
1396/*
1397 STAC 9200-32 pin configs for
1398 102801BD (Dell Inspiron E1505n)
1399 102801EE
1400 102801EF
1401*/
1402static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001403 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1404 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001405};
1406
1407/*
1408 STAC 9200-32 pin configs for
1409 102801F5 (Dell Inspiron 1501)
1410 102801F6
1411*/
1412static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001413 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1414 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001415};
1416
1417/*
1418 STAC 9200-32
1419 102801CD (Dell Inspiron E1705/9400)
1420*/
1421static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001422 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1423 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001424};
1425
Tobin Davisbf277782008-02-03 20:31:47 +01001426static unsigned int oqo9200_pin_configs[8] = {
1427 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1428 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1429};
1430
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001431
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001432static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1433 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001434 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001435 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1436 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1437 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1438 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1439 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1440 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1441 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1442 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1443 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1444 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001445 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001446};
1447
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001448static const char *stac9200_models[STAC_9200_MODELS] = {
1449 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001450 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001451 [STAC_9200_DELL_D21] = "dell-d21",
1452 [STAC_9200_DELL_D22] = "dell-d22",
1453 [STAC_9200_DELL_D23] = "dell-d23",
1454 [STAC_9200_DELL_M21] = "dell-m21",
1455 [STAC_9200_DELL_M22] = "dell-m22",
1456 [STAC_9200_DELL_M23] = "dell-m23",
1457 [STAC_9200_DELL_M24] = "dell-m24",
1458 [STAC_9200_DELL_M25] = "dell-m25",
1459 [STAC_9200_DELL_M26] = "dell-m26",
1460 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001461 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001462 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001463};
1464
1465static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1466 /* SigmaTel reference board */
1467 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1468 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001469 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1471 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001473 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1475 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1477 "unknown Dell", STAC_9200_DELL_D22),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1479 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001481 "Dell Latitude D620", STAC_9200_DELL_M22),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1483 "unknown Dell", STAC_9200_DELL_D23),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1485 "unknown Dell", STAC_9200_DELL_D23),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1487 "unknown Dell", STAC_9200_DELL_M22),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1489 "unknown Dell", STAC_9200_DELL_M24),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1491 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001493 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001495 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001497 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001499 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001501 "Dell Precision M90", STAC_9200_DELL_M23),
1502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1503 "unknown Dell", STAC_9200_DELL_M22),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1505 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001507 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001509 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1511 "unknown Dell", STAC_9200_DELL_D23),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1513 "unknown Dell", STAC_9200_DELL_D23),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1515 "unknown Dell", STAC_9200_DELL_D21),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1517 "unknown Dell", STAC_9200_DELL_D23),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1519 "unknown Dell", STAC_9200_DELL_D21),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1521 "unknown Dell", STAC_9200_DELL_M25),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1523 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001525 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1527 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001528 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001529 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001530 /* Gateway machines needs EAPD to be set on resume */
1531 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1532 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1533 STAC_9200_GATEWAY),
1534 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1535 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001536 /* OQO Mobile */
1537 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001538 {} /* terminator */
1539};
1540
Tobin Davis8e21c342007-01-08 11:04:17 +01001541static unsigned int ref925x_pin_configs[8] = {
1542 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001543 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001544};
1545
1546static unsigned int stac925x_MA6_pin_configs[8] = {
1547 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1548 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1549};
1550
Tobin Davis2c11f952007-05-17 09:36:34 +02001551static unsigned int stac925x_PA6_pin_configs[8] = {
1552 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1553 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1554};
1555
Tobin Davis8e21c342007-01-08 11:04:17 +01001556static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001557 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1558 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001559};
1560
1561static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1562 [STAC_REF] = ref925x_pin_configs,
1563 [STAC_M2_2] = stac925xM2_2_pin_configs,
1564 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001565 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001566};
1567
1568static const char *stac925x_models[STAC_925x_MODELS] = {
1569 [STAC_REF] = "ref",
1570 [STAC_M2_2] = "m2-2",
1571 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001572 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001573};
1574
1575static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1576 /* SigmaTel reference board */
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001578 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001579 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1580 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1581 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001582 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001583 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1584 {} /* terminator */
1585};
1586
Matthew Ranostaya7662642008-02-21 07:51:14 +01001587static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001588 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1589 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1590 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001591 0x01452050,
1592};
1593
1594static unsigned int dell_m6_pin_configs[13] = {
1595 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001596 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001597 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1598 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001599};
1600
1601static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001602 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1603 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001604 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001605};
1606
1607static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1608 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001609 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001610 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001611};
1612
1613static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1614 /* SigmaTel reference board */
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001616 "DFI LanParty", STAC_92HD73XX_REF),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1618 "unknown Dell", STAC_DELL_M6),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1620 "unknown Dell", STAC_DELL_M6),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1622 "unknown Dell", STAC_DELL_M6),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1624 "unknown Dell", STAC_DELL_M6),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1626 "unknown Dell", STAC_DELL_M6),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1628 "unknown Dell", STAC_DELL_M6),
1629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1630 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001631 {} /* terminator */
1632};
1633
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001634static unsigned int ref92hd83xxx_pin_configs[14] = {
1635 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1636 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1637 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1638 0x01451160, 0x98560170,
1639};
1640
1641static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1642 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1643};
1644
1645static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1646 [STAC_92HD83XXX_REF] = "ref",
1647};
1648
1649static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1650 /* SigmaTel reference board */
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1652 "DFI LanParty", STAC_92HD71BXX_REF),
1653};
1654
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001655static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001656 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001657 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001658 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001659};
1660
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001661static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001662 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001663 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001664 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001665};
1666
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001667static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001668 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1669 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001670 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001671};
1672
Matthew Ranostaye035b842007-11-06 11:53:55 +01001673static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1674 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001675 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1676 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001677 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001678};
1679
1680static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1681 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001682 [STAC_DELL_M4_1] = "dell-m4-1",
1683 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001684 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001685};
1686
1687static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1688 /* SigmaTel reference board */
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1690 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1692 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1694 "unknown Dell", STAC_DELL_M4_1),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1696 "unknown Dell", STAC_DELL_M4_1),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1698 "unknown Dell", STAC_DELL_M4_1),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1700 "unknown Dell", STAC_DELL_M4_1),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1702 "unknown Dell", STAC_DELL_M4_1),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1704 "unknown Dell", STAC_DELL_M4_1),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1706 "unknown Dell", STAC_DELL_M4_1),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1708 "unknown Dell", STAC_DELL_M4_2),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1710 "unknown Dell", STAC_DELL_M4_2),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1712 "unknown Dell", STAC_DELL_M4_2),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1714 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001715 {} /* terminator */
1716};
1717
Matt Porter403d1942005-11-29 15:00:51 +01001718static unsigned int ref922x_pin_configs[10] = {
1719 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1720 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001721 0x40000100, 0x40000100,
1722};
1723
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001724/*
1725 STAC 922X pin configs for
1726 102801A7
1727 102801AB
1728 102801A9
1729 102801D1
1730 102801D2
1731*/
1732static unsigned int dell_922x_d81_pin_configs[10] = {
1733 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1734 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1735 0x01813122, 0x400001f2,
1736};
1737
1738/*
1739 STAC 922X pin configs for
1740 102801AC
1741 102801D0
1742*/
1743static unsigned int dell_922x_d82_pin_configs[10] = {
1744 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1745 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1746 0x01813122, 0x400001f1,
1747};
1748
1749/*
1750 STAC 922X pin configs for
1751 102801BF
1752*/
1753static unsigned int dell_922x_m81_pin_configs[10] = {
1754 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1755 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1756 0x40C003f1, 0x405003f0,
1757};
1758
1759/*
1760 STAC 9221 A1 pin configs for
1761 102801D7 (Dell XPS M1210)
1762*/
1763static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001764 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1765 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001766 0x508003f3, 0x405003f4,
1767};
1768
Matt Porter403d1942005-11-29 15:00:51 +01001769static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001770 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001771 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1772 0x02a19120, 0x40000100,
1773};
1774
1775static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001776 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1777 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001778 0x02a19320, 0x40000100,
1779};
1780
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001781static unsigned int intel_mac_v1_pin_configs[10] = {
1782 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1783 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001784 0x400000fc, 0x400000fb,
1785};
1786
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001787static unsigned int intel_mac_v2_pin_configs[10] = {
1788 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1789 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001790 0x400000fc, 0x400000fb,
1791};
1792
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001793static unsigned int intel_mac_v3_pin_configs[10] = {
1794 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1795 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1796 0x400000fc, 0x400000fb,
1797};
1798
1799static unsigned int intel_mac_v4_pin_configs[10] = {
1800 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1801 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1802 0x400000fc, 0x400000fb,
1803};
1804
1805static unsigned int intel_mac_v5_pin_configs[10] = {
1806 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1807 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1808 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001809};
1810
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001811static unsigned int ecs202_pin_configs[10] = {
1812 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1813 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1814 0x9037012e, 0x40e000f2,
1815};
Takashi Iwai76c08822007-06-19 12:17:42 +02001816
Takashi Iwai19039bd2006-06-28 15:52:16 +02001817static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001818 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001819 [STAC_D945GTP3] = d945gtp3_pin_configs,
1820 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001821 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1822 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1823 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1824 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1825 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001826 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001827 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001828 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1829 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1830 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1831 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1832 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1833 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001834 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001835 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1836 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1837 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1838 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001839};
1840
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001841static const char *stac922x_models[STAC_922X_MODELS] = {
1842 [STAC_D945_REF] = "ref",
1843 [STAC_D945GTP5] = "5stack",
1844 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001845 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1846 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1847 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1848 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1849 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001850 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001851 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001852 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001853 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001854 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1855 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001856 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001857 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001858 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001859 [STAC_922X_DELL_D81] = "dell-d81",
1860 [STAC_922X_DELL_D82] = "dell-d82",
1861 [STAC_922X_DELL_M81] = "dell-m81",
1862 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001863};
1864
1865static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1866 /* SigmaTel reference board */
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1868 "DFI LanParty", STAC_D945_REF),
1869 /* Intel 945G based systems */
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1871 "Intel D945G", STAC_D945GTP3),
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1873 "Intel D945G", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1875 "Intel D945G", STAC_D945GTP3),
1876 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1877 "Intel D945G", STAC_D945GTP3),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1879 "Intel D945G", STAC_D945GTP3),
1880 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1881 "Intel D945G", STAC_D945GTP3),
1882 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1883 "Intel D945G", STAC_D945GTP3),
1884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1885 "Intel D945G", STAC_D945GTP3),
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1887 "Intel D945G", STAC_D945GTP3),
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1893 "Intel D945G", STAC_D945GTP3),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1895 "Intel D945G", STAC_D945GTP3),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1899 "Intel D945G", STAC_D945GTP3),
1900 /* Intel D945G 5-stack systems */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1902 "Intel D945G", STAC_D945GTP5),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1904 "Intel D945G", STAC_D945GTP5),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1906 "Intel D945G", STAC_D945GTP5),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1908 "Intel D945G", STAC_D945GTP5),
1909 /* Intel 945P based systems */
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1911 "Intel D945P", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1913 "Intel D945P", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1915 "Intel D945P", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1917 "Intel D945P", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1919 "Intel D945P", STAC_D945GTP3),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1921 "Intel D945P", STAC_D945GTP5),
1922 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001923 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001924 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001925 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001926 /* Dell systems */
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1928 "unknown Dell", STAC_922X_DELL_D81),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1930 "unknown Dell", STAC_922X_DELL_D81),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1932 "unknown Dell", STAC_922X_DELL_D81),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1934 "unknown Dell", STAC_922X_DELL_D82),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1936 "unknown Dell", STAC_922X_DELL_M81),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1938 "unknown Dell", STAC_922X_DELL_D82),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1940 "unknown Dell", STAC_922X_DELL_D81),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1942 "unknown Dell", STAC_922X_DELL_D81),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1944 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001945 /* ECS/PC Chips boards */
1946 SND_PCI_QUIRK(0x1019, 0x2144,
1947 "ECS/PC chips", STAC_ECS_202),
1948 SND_PCI_QUIRK(0x1019, 0x2608,
1949 "ECS/PC chips", STAC_ECS_202),
1950 SND_PCI_QUIRK(0x1019, 0x2633,
1951 "ECS/PC chips P17G/1333", STAC_ECS_202),
1952 SND_PCI_QUIRK(0x1019, 0x2811,
1953 "ECS/PC chips", STAC_ECS_202),
1954 SND_PCI_QUIRK(0x1019, 0x2812,
1955 "ECS/PC chips", STAC_ECS_202),
1956 SND_PCI_QUIRK(0x1019, 0x2813,
1957 "ECS/PC chips", STAC_ECS_202),
1958 SND_PCI_QUIRK(0x1019, 0x2814,
1959 "ECS/PC chips", STAC_ECS_202),
1960 SND_PCI_QUIRK(0x1019, 0x2815,
1961 "ECS/PC chips", STAC_ECS_202),
1962 SND_PCI_QUIRK(0x1019, 0x2816,
1963 "ECS/PC chips", STAC_ECS_202),
1964 SND_PCI_QUIRK(0x1019, 0x2817,
1965 "ECS/PC chips", STAC_ECS_202),
1966 SND_PCI_QUIRK(0x1019, 0x2818,
1967 "ECS/PC chips", STAC_ECS_202),
1968 SND_PCI_QUIRK(0x1019, 0x2819,
1969 "ECS/PC chips", STAC_ECS_202),
1970 SND_PCI_QUIRK(0x1019, 0x2820,
1971 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001972 {} /* terminator */
1973};
1974
Matt Porter3cc08dc2006-01-23 15:27:49 +01001975static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001976 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1977 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1978 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1979 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001980};
1981
Tobin Davis93ed1502006-09-01 21:03:12 +02001982static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001983 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1984 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1985 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1986 0x40000100, 0x40000100
1987};
1988
Tobin Davis93ed1502006-09-01 21:03:12 +02001989static unsigned int d965_5st_pin_configs[14] = {
1990 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1991 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1992 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1993 0x40000100, 0x40000100
1994};
1995
Tobin Davis4ff076e2007-08-07 11:48:12 +02001996static unsigned int dell_3st_pin_configs[14] = {
1997 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1998 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001999 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002000 0x40c003fc, 0x40000100
2001};
2002
Tobin Davis93ed1502006-09-01 21:03:12 +02002003static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002004 [STAC_D965_REF] = ref927x_pin_configs,
2005 [STAC_D965_3ST] = d965_3st_pin_configs,
2006 [STAC_D965_5ST] = d965_5st_pin_configs,
2007 [STAC_DELL_3ST] = dell_3st_pin_configs,
2008 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002009};
2010
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002011static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002012 [STAC_D965_REF] = "ref",
2013 [STAC_D965_3ST] = "3stack",
2014 [STAC_D965_5ST] = "5stack",
2015 [STAC_DELL_3ST] = "dell-3stack",
2016 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002017};
2018
2019static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2020 /* SigmaTel reference board */
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2022 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002023 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002026 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002043 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002048 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002057 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002067 {} /* terminator */
2068};
2069
Matt Porterf3302a52006-07-31 12:49:34 +02002070static unsigned int ref9205_pin_configs[12] = {
2071 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002072 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002073 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002074};
2075
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002076/*
2077 STAC 9205 pin configs for
2078 102801F1
2079 102801F2
2080 102801FC
2081 102801FD
2082 10280204
2083 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002084 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002085*/
2086static unsigned int dell_9205_m42_pin_configs[12] = {
2087 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2088 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2089 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2090};
2091
2092/*
2093 STAC 9205 pin configs for
2094 102801F9
2095 102801FA
2096 102801FE
2097 102801FF (Dell Precision M4300)
2098 10280206
2099 10280200
2100 10280201
2101*/
2102static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002103 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2104 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2105 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2106};
2107
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002108static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002109 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2110 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2111 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2112};
2113
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002114static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002115 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002116 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2117 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2118 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002119};
2120
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002121static const char *stac9205_models[STAC_9205_MODELS] = {
2122 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002123 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002124 [STAC_9205_DELL_M43] = "dell-m43",
2125 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002126};
2127
2128static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2129 /* SigmaTel reference board */
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2131 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2133 "unknown Dell", STAC_9205_DELL_M42),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2135 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002137 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2139 "Dell Precision", STAC_9205_DELL_M43),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2141 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2143 "unknown Dell", STAC_9205_DELL_M42),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2145 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2147 "Dell Precision", STAC_9205_DELL_M43),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002149 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2151 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2153 "Dell Precision", STAC_9205_DELL_M43),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2155 "Dell Precision", STAC_9205_DELL_M43),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2157 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2159 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2161 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002162 {} /* terminator */
2163};
2164
Richard Fish11b44bb2006-08-23 18:31:34 +02002165static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2166{
2167 int i;
2168 struct sigmatel_spec *spec = codec->spec;
2169
2170 if (! spec->bios_pin_configs) {
2171 spec->bios_pin_configs = kcalloc(spec->num_pins,
2172 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2173 if (! spec->bios_pin_configs)
2174 return -ENOMEM;
2175 }
2176
2177 for (i = 0; i < spec->num_pins; i++) {
2178 hda_nid_t nid = spec->pin_nids[i];
2179 unsigned int pin_cfg;
2180
2181 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2182 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2183 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2184 nid, pin_cfg);
2185 spec->bios_pin_configs[i] = pin_cfg;
2186 }
2187
2188 return 0;
2189}
2190
Matthew Ranostay87d48362007-07-17 11:52:24 +02002191static void stac92xx_set_config_reg(struct hda_codec *codec,
2192 hda_nid_t pin_nid, unsigned int pin_config)
2193{
2194 int i;
2195 snd_hda_codec_write(codec, pin_nid, 0,
2196 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2197 pin_config & 0x000000ff);
2198 snd_hda_codec_write(codec, pin_nid, 0,
2199 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2200 (pin_config & 0x0000ff00) >> 8);
2201 snd_hda_codec_write(codec, pin_nid, 0,
2202 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2203 (pin_config & 0x00ff0000) >> 16);
2204 snd_hda_codec_write(codec, pin_nid, 0,
2205 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2206 pin_config >> 24);
2207 i = snd_hda_codec_read(codec, pin_nid, 0,
2208 AC_VERB_GET_CONFIG_DEFAULT,
2209 0x00);
2210 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2211 pin_nid, i);
2212}
2213
Matt2f2f4252005-04-13 14:45:30 +02002214static void stac92xx_set_config_regs(struct hda_codec *codec)
2215{
2216 int i;
2217 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002218
Matthew Ranostay87d48362007-07-17 11:52:24 +02002219 if (!spec->pin_configs)
2220 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002221
Matthew Ranostay87d48362007-07-17 11:52:24 +02002222 for (i = 0; i < spec->num_pins; i++)
2223 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2224 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002225}
Matt2f2f4252005-04-13 14:45:30 +02002226
Matt2f2f4252005-04-13 14:45:30 +02002227/*
2228 * Analog playback callbacks
2229 */
2230static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2231 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002232 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002233{
2234 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002235 if (spec->stream_delay)
2236 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002237 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2238 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002239}
2240
2241static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2242 struct hda_codec *codec,
2243 unsigned int stream_tag,
2244 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002245 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002246{
2247 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002248 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002249}
2250
2251static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2252 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002253 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002254{
2255 struct sigmatel_spec *spec = codec->spec;
2256 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2257}
2258
2259/*
Mattdabbed62005-06-14 10:19:34 +02002260 * Digital playback callbacks
2261 */
2262static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2263 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002264 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002265{
2266 struct sigmatel_spec *spec = codec->spec;
2267 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2268}
2269
2270static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2271 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002272 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002273{
2274 struct sigmatel_spec *spec = codec->spec;
2275 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2276}
2277
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002278static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2279 struct hda_codec *codec,
2280 unsigned int stream_tag,
2281 unsigned int format,
2282 struct snd_pcm_substream *substream)
2283{
2284 struct sigmatel_spec *spec = codec->spec;
2285 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2286 stream_tag, format, substream);
2287}
2288
Mattdabbed62005-06-14 10:19:34 +02002289
2290/*
Matt2f2f4252005-04-13 14:45:30 +02002291 * Analog capture callbacks
2292 */
2293static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2294 struct hda_codec *codec,
2295 unsigned int stream_tag,
2296 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002297 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002298{
2299 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002300 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002301
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002302 if (spec->powerdown_adcs) {
2303 msleep(40);
2304 snd_hda_codec_write_cache(codec, nid, 0,
2305 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2306 }
2307 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002308 return 0;
2309}
2310
2311static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002313 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002314{
2315 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002316 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002317
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002318 snd_hda_codec_cleanup_stream(codec, nid);
2319 if (spec->powerdown_adcs)
2320 snd_hda_codec_write_cache(codec, nid, 0,
2321 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002322 return 0;
2323}
2324
Mattdabbed62005-06-14 10:19:34 +02002325static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2326 .substreams = 1,
2327 .channels_min = 2,
2328 .channels_max = 2,
2329 /* NID is set in stac92xx_build_pcms */
2330 .ops = {
2331 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002332 .close = stac92xx_dig_playback_pcm_close,
2333 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002334 },
2335};
2336
2337static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2338 .substreams = 1,
2339 .channels_min = 2,
2340 .channels_max = 2,
2341 /* NID is set in stac92xx_build_pcms */
2342};
2343
Matt2f2f4252005-04-13 14:45:30 +02002344static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2345 .substreams = 1,
2346 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002347 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002348 .nid = 0x02, /* NID to query formats and rates */
2349 .ops = {
2350 .open = stac92xx_playback_pcm_open,
2351 .prepare = stac92xx_playback_pcm_prepare,
2352 .cleanup = stac92xx_playback_pcm_cleanup
2353 },
2354};
2355
Matt Porter3cc08dc2006-01-23 15:27:49 +01002356static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2357 .substreams = 1,
2358 .channels_min = 2,
2359 .channels_max = 2,
2360 .nid = 0x06, /* NID to query formats and rates */
2361 .ops = {
2362 .open = stac92xx_playback_pcm_open,
2363 .prepare = stac92xx_playback_pcm_prepare,
2364 .cleanup = stac92xx_playback_pcm_cleanup
2365 },
2366};
2367
Matt2f2f4252005-04-13 14:45:30 +02002368static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002369 .channels_min = 2,
2370 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002371 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002372 .ops = {
2373 .prepare = stac92xx_capture_pcm_prepare,
2374 .cleanup = stac92xx_capture_pcm_cleanup
2375 },
2376};
2377
2378static int stac92xx_build_pcms(struct hda_codec *codec)
2379{
2380 struct sigmatel_spec *spec = codec->spec;
2381 struct hda_pcm *info = spec->pcm_rec;
2382
2383 codec->num_pcms = 1;
2384 codec->pcm_info = info;
2385
Mattc7d4b2f2005-06-27 14:59:41 +02002386 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002387 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002388 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002389 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002390 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002391
2392 if (spec->alt_switch) {
2393 codec->num_pcms++;
2394 info++;
2395 info->name = "STAC92xx Analog Alt";
2396 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2397 }
Matt2f2f4252005-04-13 14:45:30 +02002398
Mattdabbed62005-06-14 10:19:34 +02002399 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2400 codec->num_pcms++;
2401 info++;
2402 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002403 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002404 if (spec->multiout.dig_out_nid) {
2405 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2406 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2407 }
2408 if (spec->dig_in_nid) {
2409 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2410 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2411 }
2412 }
2413
Matt2f2f4252005-04-13 14:45:30 +02002414 return 0;
2415}
2416
Takashi Iwaic960a032006-03-23 17:06:28 +01002417static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2418{
2419 unsigned int pincap = snd_hda_param_read(codec, nid,
2420 AC_PAR_PIN_CAP);
2421 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2422 if (pincap & AC_PINCAP_VREF_100)
2423 return AC_PINCTL_VREF_100;
2424 if (pincap & AC_PINCAP_VREF_80)
2425 return AC_PINCTL_VREF_80;
2426 if (pincap & AC_PINCAP_VREF_50)
2427 return AC_PINCTL_VREF_50;
2428 if (pincap & AC_PINCAP_VREF_GRD)
2429 return AC_PINCTL_VREF_GRD;
2430 return 0;
2431}
2432
Matt Porter403d1942005-11-29 15:00:51 +01002433static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2434
2435{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002436 snd_hda_codec_write_cache(codec, nid, 0,
2437 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002438}
2439
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002440#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2441
2442static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2443 struct snd_ctl_elem_value *ucontrol)
2444{
2445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2446 struct sigmatel_spec *spec = codec->spec;
2447
Takashi Iwaid7a89432008-11-12 09:48:04 +01002448 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002449 return 0;
2450}
2451
2452static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2453 struct snd_ctl_elem_value *ucontrol)
2454{
2455 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2456 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002457 int nid = kcontrol->private_value;
2458
2459 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002460
2461 /* check to be sure that the ports are upto date with
2462 * switch changes
2463 */
2464 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2465
2466 return 1;
2467}
2468
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002469#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002470
2471static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2472{
2473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2474 struct sigmatel_spec *spec = codec->spec;
2475 int io_idx = kcontrol-> private_value & 0xff;
2476
2477 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2478 return 0;
2479}
2480
2481static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2482{
2483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2484 struct sigmatel_spec *spec = codec->spec;
2485 hda_nid_t nid = kcontrol->private_value >> 8;
2486 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002487 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002488
2489 spec->io_switch[io_idx] = val;
2490
2491 if (val)
2492 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002493 else {
2494 unsigned int pinctl = AC_PINCTL_IN_EN;
2495 if (io_idx) /* set VREF for mic */
2496 pinctl |= stac92xx_get_vref(codec, nid);
2497 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2498 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002499
2500 /* check the auto-mute again: we need to mute/unmute the speaker
2501 * appropriately according to the pin direction
2502 */
2503 if (spec->hp_detect)
2504 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2505
Matt Porter403d1942005-11-29 15:00:51 +01002506 return 1;
2507}
2508
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002509#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2510
2511static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2512 struct snd_ctl_elem_value *ucontrol)
2513{
2514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2515 struct sigmatel_spec *spec = codec->spec;
2516
2517 ucontrol->value.integer.value[0] = spec->clfe_swap;
2518 return 0;
2519}
2520
2521static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2522 struct snd_ctl_elem_value *ucontrol)
2523{
2524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2525 struct sigmatel_spec *spec = codec->spec;
2526 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002527 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002528
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002529 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002530 return 0;
2531
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002532 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002533
2534 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2535 spec->clfe_swap ? 0x4 : 0x0);
2536
2537 return 1;
2538}
2539
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002540#define STAC_CODEC_HP_SWITCH(xname) \
2541 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2542 .name = xname, \
2543 .index = 0, \
2544 .info = stac92xx_hp_switch_info, \
2545 .get = stac92xx_hp_switch_get, \
2546 .put = stac92xx_hp_switch_put, \
2547 }
2548
Matt Porter403d1942005-11-29 15:00:51 +01002549#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2550 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2551 .name = xname, \
2552 .index = 0, \
2553 .info = stac92xx_io_switch_info, \
2554 .get = stac92xx_io_switch_get, \
2555 .put = stac92xx_io_switch_put, \
2556 .private_value = xpval, \
2557 }
2558
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002559#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2560 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2561 .name = xname, \
2562 .index = 0, \
2563 .info = stac92xx_clfe_switch_info, \
2564 .get = stac92xx_clfe_switch_get, \
2565 .put = stac92xx_clfe_switch_put, \
2566 .private_value = xpval, \
2567 }
Matt Porter403d1942005-11-29 15:00:51 +01002568
Mattc7d4b2f2005-06-27 14:59:41 +02002569enum {
2570 STAC_CTL_WIDGET_VOL,
2571 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002572 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002573 STAC_CTL_WIDGET_AMP_MUX,
2574 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002575 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002576 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002577 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002578};
2579
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002580static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002581 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2582 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002583 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002584 STAC_AMP_MUX,
2585 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002586 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002587 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002588 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002589};
2590
2591/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002592static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2593 struct snd_kcontrol_new *ktemp,
2594 int idx, const char *name,
2595 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002596{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002597 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002598
2599 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2600 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2601
2602 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2603 if (! knew)
2604 return -ENOMEM;
2605 if (spec->kctl_alloc) {
2606 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2607 kfree(spec->kctl_alloc);
2608 }
2609 spec->kctl_alloc = knew;
2610 spec->num_kctl_alloc = num;
2611 }
2612
2613 knew = &spec->kctl_alloc[spec->num_kctl_used];
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002614 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002615 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002616 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002617 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002618 return -ENOMEM;
2619 knew->private_value = val;
2620 spec->num_kctl_used++;
2621 return 0;
2622}
2623
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002624static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2625 int type, int idx, const char *name,
2626 unsigned long val)
2627{
2628 return stac92xx_add_control_temp(spec,
2629 &stac92xx_control_templates[type],
2630 idx, name, val);
2631}
2632
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002633
2634/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002635static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2636 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002637{
2638 return stac92xx_add_control_idx(spec, type, 0, name, val);
2639}
2640
Matt Porter403d1942005-11-29 15:00:51 +01002641/* flag inputs as additional dynamic lineouts */
2642static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2643{
2644 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002645 unsigned int wcaps, wtype;
2646 int i, num_dacs = 0;
2647
2648 /* use the wcaps cache to count all DACs available for line-outs */
2649 for (i = 0; i < codec->num_nodes; i++) {
2650 wcaps = codec->wcaps[i];
2651 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002652
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002653 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2654 num_dacs++;
2655 }
Matt Porter403d1942005-11-29 15:00:51 +01002656
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002657 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2658
Matt Porter403d1942005-11-29 15:00:51 +01002659 switch (cfg->line_outs) {
2660 case 3:
2661 /* add line-in as side */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002662 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002663 cfg->line_out_pins[cfg->line_outs] =
2664 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002665 spec->line_switch = 1;
2666 cfg->line_outs++;
2667 }
2668 break;
2669 case 2:
2670 /* add line-in as clfe and mic as side */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002671 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002672 cfg->line_out_pins[cfg->line_outs] =
2673 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002674 spec->line_switch = 1;
2675 cfg->line_outs++;
2676 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002677 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002678 cfg->line_out_pins[cfg->line_outs] =
2679 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002680 spec->mic_switch = 1;
2681 cfg->line_outs++;
2682 }
2683 break;
2684 case 1:
2685 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002686 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002687 cfg->line_out_pins[cfg->line_outs] =
2688 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002689 spec->line_switch = 1;
2690 cfg->line_outs++;
2691 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002692 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002693 cfg->line_out_pins[cfg->line_outs] =
2694 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002695 spec->mic_switch = 1;
2696 cfg->line_outs++;
2697 }
2698 break;
2699 }
2700
2701 return 0;
2702}
2703
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002704
2705static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2706{
2707 int i;
2708
2709 for (i = 0; i < spec->multiout.num_dacs; i++) {
2710 if (spec->multiout.dac_nids[i] == nid)
2711 return 1;
2712 }
2713
2714 return 0;
2715}
2716
Matt Porter3cc08dc2006-01-23 15:27:49 +01002717/*
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002718 * Fill in the dac_nids table from the parsed pin configuration
2719 * This function only works when every pin in line_out_pins[]
2720 * contains atleast one DAC in its connection list. Some 92xx
2721 * codecs are not connected directly to a DAC, such as the 9200
2722 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002723 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002724static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002725 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002726{
2727 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002728 int i, j, conn_len = 0;
2729 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2730 unsigned int wcaps, wtype;
2731
Mattc7d4b2f2005-06-27 14:59:41 +02002732 for (i = 0; i < cfg->line_outs; i++) {
2733 nid = cfg->line_out_pins[i];
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002734 conn_len = snd_hda_get_connections(codec, nid, conn,
2735 HDA_MAX_CONNECTIONS);
2736 for (j = 0; j < conn_len; j++) {
2737 wcaps = snd_hda_param_read(codec, conn[j],
2738 AC_PAR_AUDIO_WIDGET_CAP);
2739 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002740 if (wtype != AC_WID_AUD_OUT ||
2741 (wcaps & AC_WCAP_DIGITAL))
2742 continue;
2743 /* conn[j] is a DAC routed to this line-out */
2744 if (!is_in_dac_nids(spec, conn[j]))
2745 break;
2746 }
2747
2748 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002749 if (spec->multiout.num_dacs > 0) {
2750 /* we have already working output pins,
2751 * so let's drop the broken ones again
2752 */
2753 cfg->line_outs = spec->multiout.num_dacs;
2754 break;
2755 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002756 /* error out, no available DAC found */
2757 snd_printk(KERN_ERR
2758 "%s: No available DAC for pin 0x%x\n",
2759 __func__, nid);
2760 return -ENODEV;
2761 }
2762
2763 spec->multiout.dac_nids[i] = conn[j];
2764 spec->multiout.num_dacs++;
2765 if (conn_len > 1) {
2766 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002767 snd_hda_codec_write_cache(codec, nid, 0,
2768 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002769
2770 }
Mattc7d4b2f2005-06-27 14:59:41 +02002771 }
2772
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002773 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2774 spec->multiout.num_dacs,
2775 spec->multiout.dac_nids[0],
2776 spec->multiout.dac_nids[1],
2777 spec->multiout.dac_nids[2],
2778 spec->multiout.dac_nids[3],
2779 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002780 return 0;
2781}
2782
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002783/* create volume control/switch for the given prefx type */
2784static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2785{
2786 char name[32];
2787 int err;
2788
2789 sprintf(name, "%s Playback Volume", pfx);
2790 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2791 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2792 if (err < 0)
2793 return err;
2794 sprintf(name, "%s Playback Switch", pfx);
2795 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2796 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2797 if (err < 0)
2798 return err;
2799 return 0;
2800}
2801
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002802static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2803{
2804 if (!spec->multiout.hp_nid)
2805 spec->multiout.hp_nid = nid;
2806 else if (spec->multiout.num_dacs > 4) {
2807 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2808 return 1;
2809 } else {
2810 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2811 spec->multiout.num_dacs++;
2812 }
2813 return 0;
2814}
2815
2816static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2817{
2818 if (is_in_dac_nids(spec, nid))
2819 return 1;
2820 if (spec->multiout.hp_nid == nid)
2821 return 1;
2822 return 0;
2823}
2824
Mattc7d4b2f2005-06-27 14:59:41 +02002825/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002826static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002827 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002828{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002829 static const char *chname[4] = {
2830 "Front", "Surround", NULL /*CLFE*/, "Side"
2831 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002832 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002833 int i, err;
2834
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002835 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002836 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002837
2838
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002839 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002840 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002841 continue;
2842
2843 nid = spec->multiout.dac_nids[i];
2844
2845 if (i == 2) {
2846 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002847 err = create_controls(spec, "Center", nid, 1);
2848 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002849 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002850 err = create_controls(spec, "LFE", nid, 2);
2851 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002852 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002853
2854 wid_caps = get_wcaps(codec, nid);
2855
2856 if (wid_caps & AC_WCAP_LR_SWAP) {
2857 err = stac92xx_add_control(spec,
2858 STAC_CTL_WIDGET_CLFE_SWITCH,
2859 "Swap Center/LFE Playback Switch", nid);
2860
2861 if (err < 0)
2862 return err;
2863 }
2864
Mattc7d4b2f2005-06-27 14:59:41 +02002865 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002866 err = create_controls(spec, chname[i], nid, 3);
2867 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002868 return err;
2869 }
2870 }
2871
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002872 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2873 cfg->hp_outs && !spec->multiout.hp_nid)
2874 spec->multiout.hp_nid = nid;
2875
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002876 if (cfg->hp_outs > 1) {
2877 err = stac92xx_add_control(spec,
2878 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002879 "Headphone as Line Out Switch",
2880 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002881 if (err < 0)
2882 return err;
2883 }
2884
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002885 if (spec->line_switch) {
2886 nid = cfg->input_pins[AUTO_PIN_LINE];
2887 pincap = snd_hda_param_read(codec, nid,
2888 AC_PAR_PIN_CAP);
2889 if (pincap & AC_PINCAP_OUT) {
2890 err = stac92xx_add_control(spec,
2891 STAC_CTL_WIDGET_IO_SWITCH,
2892 "Line In as Output Switch", nid << 8);
2893 if (err < 0)
2894 return err;
2895 }
2896 }
Matt Porter403d1942005-11-29 15:00:51 +01002897
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002898 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002899 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002900 unsigned int mic_pin = AUTO_PIN_MIC;
2901again:
2902 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002903 def_conf = snd_hda_codec_read(codec, nid, 0,
2904 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002905 /* some laptops have an internal analog microphone
2906 * which can't be used as a output */
2907 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2908 pincap = snd_hda_param_read(codec, nid,
2909 AC_PAR_PIN_CAP);
2910 if (pincap & AC_PINCAP_OUT) {
2911 err = stac92xx_add_control(spec,
2912 STAC_CTL_WIDGET_IO_SWITCH,
2913 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002914 nid = snd_hda_codec_read(codec, nid, 0,
2915 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2916 if (!check_in_dac_nids(spec, nid))
2917 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002918 if (err < 0)
2919 return err;
2920 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002921 } else if (mic_pin == AUTO_PIN_MIC) {
2922 mic_pin = AUTO_PIN_FRONT_MIC;
2923 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002924 }
2925 }
Matt Porter403d1942005-11-29 15:00:51 +01002926
Mattc7d4b2f2005-06-27 14:59:41 +02002927 return 0;
2928}
2929
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002930/* add playback controls for Speaker and HP outputs */
2931static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2932 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002933{
2934 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002935 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002936 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002937
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002938 old_num_dacs = spec->multiout.num_dacs;
2939 for (i = 0; i < cfg->hp_outs; i++) {
2940 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2941 if (wid_caps & AC_WCAP_UNSOL_CAP)
2942 spec->hp_detect = 1;
2943 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2944 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2945 if (check_in_dac_nids(spec, nid))
2946 nid = 0;
2947 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002948 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002949 add_spec_dacs(spec, nid);
2950 }
2951 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002952 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002953 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2954 if (check_in_dac_nids(spec, nid))
2955 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002956 if (! nid)
2957 continue;
2958 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002959 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002960 for (i = 0; i < cfg->line_outs; i++) {
2961 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2962 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2963 if (check_in_dac_nids(spec, nid))
2964 nid = 0;
2965 if (! nid)
2966 continue;
2967 add_spec_dacs(spec, nid);
2968 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002969 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2970 static const char *pfxs[] = {
2971 "Speaker", "External Speaker", "Speaker2",
2972 };
2973 err = create_controls(spec, pfxs[i - old_num_dacs],
2974 spec->multiout.dac_nids[i], 3);
2975 if (err < 0)
2976 return err;
2977 }
2978 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002979 err = create_controls(spec, "Headphone",
2980 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002981 if (err < 0)
2982 return err;
2983 }
Mattc7d4b2f2005-06-27 14:59:41 +02002984
2985 return 0;
2986}
2987
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002988/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002989static const char *stac92xx_mono_labels[4] = {
2990 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002991};
2992
2993/* create mono mux for mono out on capable codecs */
2994static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2995{
2996 struct sigmatel_spec *spec = codec->spec;
2997 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2998 int i, num_cons;
2999 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3000
3001 num_cons = snd_hda_get_connections(codec,
3002 spec->mono_nid,
3003 con_lst,
3004 HDA_MAX_NUM_INPUTS);
3005 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3006 return -EINVAL;
3007
3008 for (i = 0; i < num_cons; i++) {
3009 mono_mux->items[mono_mux->num_items].label =
3010 stac92xx_mono_labels[i];
3011 mono_mux->items[mono_mux->num_items].index = i;
3012 mono_mux->num_items++;
3013 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003014
3015 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3016 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003017}
3018
Matthew Ranostay89385032008-09-11 09:49:39 -04003019/* labels for amp mux outputs */
3020static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003021 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003022};
3023
3024/* create amp out controls mux on capable codecs */
3025static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3026{
3027 struct sigmatel_spec *spec = codec->spec;
3028 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3029 int i, err;
3030
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003031 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003032 amp_mux->items[amp_mux->num_items].label =
3033 stac92xx_amp_labels[i];
3034 amp_mux->items[amp_mux->num_items].index = i;
3035 amp_mux->num_items++;
3036 }
3037
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003038 if (spec->num_amps > 1) {
3039 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3040 "Amp Selector Capture Switch", 0);
3041 if (err < 0)
3042 return err;
3043 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003044 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3045 "Amp Capture Volume",
3046 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3047}
3048
3049
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003050/* create PC beep volume controls */
3051static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3052 hda_nid_t nid)
3053{
3054 struct sigmatel_spec *spec = codec->spec;
3055 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3056 int err;
3057
3058 /* check for mute support for the the amp */
3059 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3060 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3061 "PC Beep Playback Switch",
3062 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3063 if (err < 0)
3064 return err;
3065 }
3066
3067 /* check to see if there is volume support for the amp */
3068 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3069 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3070 "PC Beep Playback Volume",
3071 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3072 if (err < 0)
3073 return err;
3074 }
3075 return 0;
3076}
3077
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003078#ifdef CONFIG_SND_HDA_INPUT_BEEP
3079#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3080
3081static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3082 struct snd_ctl_elem_value *ucontrol)
3083{
3084 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3085 ucontrol->value.integer.value[0] = codec->beep->enabled;
3086 return 0;
3087}
3088
3089static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3090 struct snd_ctl_elem_value *ucontrol)
3091{
3092 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3093 int enabled = !!ucontrol->value.integer.value[0];
3094 if (codec->beep->enabled != enabled) {
3095 codec->beep->enabled = enabled;
3096 return 1;
3097 }
3098 return 0;
3099}
3100
3101static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3103 .info = stac92xx_dig_beep_switch_info,
3104 .get = stac92xx_dig_beep_switch_get,
3105 .put = stac92xx_dig_beep_switch_put,
3106};
3107
3108static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3109{
3110 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3111 0, "PC Beep Playback Switch", 0);
3112}
3113#endif
3114
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003115static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3116{
3117 struct sigmatel_spec *spec = codec->spec;
3118 int wcaps, nid, i, err = 0;
3119
3120 for (i = 0; i < spec->num_muxes; i++) {
3121 nid = spec->mux_nids[i];
3122 wcaps = get_wcaps(codec, nid);
3123
3124 if (wcaps & AC_WCAP_OUT_AMP) {
3125 err = stac92xx_add_control_idx(spec,
3126 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3127 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3128 if (err < 0)
3129 return err;
3130 }
3131 }
3132 return 0;
3133};
3134
Matthew Ranostayd9737752008-09-07 12:03:41 +02003135static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003136 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003137};
3138
3139static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3140{
3141 struct sigmatel_spec *spec = codec->spec;
3142 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003143 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003144 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003145 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003146
3147 num_cons = snd_hda_get_connections(codec,
3148 spec->smux_nids[0],
3149 con_lst,
3150 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003151 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003152 return -EINVAL;
3153
Matthew Ranostay65973632008-09-16 10:39:37 -04003154 if (!labels)
3155 labels = stac92xx_spdif_labels;
3156
Matthew Ranostayd9737752008-09-07 12:03:41 +02003157 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003158 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003159 spdif_mux->items[spdif_mux->num_items].index = i;
3160 spdif_mux->num_items++;
3161 }
3162
3163 return 0;
3164}
3165
Matt Porter8b657272006-10-26 17:12:59 +02003166/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003167static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003168 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3169 "Digital Mic 3", "Digital Mic 4"
3170};
3171
3172/* create playback/capture controls for input pins on dmic capable codecs */
3173static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3174 const struct auto_pin_cfg *cfg)
3175{
3176 struct sigmatel_spec *spec = codec->spec;
3177 struct hda_input_mux *dimux = &spec->private_dimux;
3178 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003179 int err, i, j;
3180 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003181
3182 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3183 dimux->items[dimux->num_items].index = 0;
3184 dimux->num_items++;
3185
3186 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003187 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003188 int index;
3189 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003190 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003191 unsigned int def_conf;
3192
3193 def_conf = snd_hda_codec_read(codec,
3194 spec->dmic_nids[i],
3195 0,
3196 AC_VERB_GET_CONFIG_DEFAULT,
3197 0);
3198 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3199 continue;
3200
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003201 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003202 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003203 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003204 con_lst,
3205 HDA_MAX_NUM_INPUTS);
3206 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003207 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003208 index = j;
3209 goto found;
3210 }
3211 continue;
3212found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003213 wcaps = get_wcaps(codec, nid) &
3214 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003215
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003216 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003217 sprintf(name, "%s Capture Volume",
3218 stac92xx_dmic_labels[dimux->num_items]);
3219
3220 err = stac92xx_add_control(spec,
3221 STAC_CTL_WIDGET_VOL,
3222 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003223 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3224 (wcaps & AC_WCAP_OUT_AMP) ?
3225 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003226 if (err < 0)
3227 return err;
3228 }
3229
Matt Porter8b657272006-10-26 17:12:59 +02003230 dimux->items[dimux->num_items].label =
3231 stac92xx_dmic_labels[dimux->num_items];
3232 dimux->items[dimux->num_items].index = index;
3233 dimux->num_items++;
3234 }
3235
3236 return 0;
3237}
3238
Mattc7d4b2f2005-06-27 14:59:41 +02003239/* create playback/capture controls for input pins */
3240static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3241{
3242 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003243 struct hda_input_mux *imux = &spec->private_imux;
3244 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3245 int i, j, k;
3246
3247 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003248 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003249
Takashi Iwai314634b2006-09-21 11:56:18 +02003250 if (!cfg->input_pins[i])
3251 continue;
3252 index = -1;
3253 for (j = 0; j < spec->num_muxes; j++) {
3254 int num_cons;
3255 num_cons = snd_hda_get_connections(codec,
3256 spec->mux_nids[j],
3257 con_lst,
3258 HDA_MAX_NUM_INPUTS);
3259 for (k = 0; k < num_cons; k++)
3260 if (con_lst[k] == cfg->input_pins[i]) {
3261 index = k;
3262 goto found;
3263 }
Mattc7d4b2f2005-06-27 14:59:41 +02003264 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003265 continue;
3266 found:
3267 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3268 imux->items[imux->num_items].index = index;
3269 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003270 }
3271
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003272 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003273 /*
3274 * Set the current input for the muxes.
3275 * The STAC9221 has two input muxes with identical source
3276 * NID lists. Hopefully this won't get confused.
3277 */
3278 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003279 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3280 AC_VERB_SET_CONNECT_SEL,
3281 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003282 }
3283 }
3284
Mattc7d4b2f2005-06-27 14:59:41 +02003285 return 0;
3286}
3287
Mattc7d4b2f2005-06-27 14:59:41 +02003288static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3289{
3290 struct sigmatel_spec *spec = codec->spec;
3291 int i;
3292
3293 for (i = 0; i < spec->autocfg.line_outs; i++) {
3294 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3295 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3296 }
3297}
3298
3299static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3300{
3301 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003302 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003303
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003304 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3305 hda_nid_t pin;
3306 pin = spec->autocfg.hp_pins[i];
3307 if (pin) /* connect to front */
3308 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3309 }
3310 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3311 hda_nid_t pin;
3312 pin = spec->autocfg.speaker_pins[i];
3313 if (pin) /* connect to front */
3314 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3315 }
Mattc7d4b2f2005-06-27 14:59:41 +02003316}
3317
Matt Porter3cc08dc2006-01-23 15:27:49 +01003318static 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 +02003319{
3320 struct sigmatel_spec *spec = codec->spec;
3321 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003322 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003323
Matt Porter8b657272006-10-26 17:12:59 +02003324 if ((err = snd_hda_parse_pin_def_config(codec,
3325 &spec->autocfg,
3326 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003327 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003328 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003329 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003330
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003331 /* If we have no real line-out pin and multiple hp-outs, HPs should
3332 * be set up as multi-channel outputs.
3333 */
3334 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3335 spec->autocfg.hp_outs > 1) {
3336 /* Copy hp_outs to line_outs, backup line_outs in
3337 * speaker_outs so that the following routines can handle
3338 * HP pins as primary outputs.
3339 */
3340 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3341 sizeof(spec->autocfg.line_out_pins));
3342 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3343 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3344 sizeof(spec->autocfg.hp_pins));
3345 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3346 hp_speaker_swap = 1;
3347 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003348 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003349 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3350 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003351 u32 caps = query_amp_caps(codec,
3352 spec->autocfg.mono_out_pin, dir);
3353 hda_nid_t conn_list[1];
3354
3355 /* get the mixer node and then the mono mux if it exists */
3356 if (snd_hda_get_connections(codec,
3357 spec->autocfg.mono_out_pin, conn_list, 1) &&
3358 snd_hda_get_connections(codec, conn_list[0],
3359 conn_list, 1)) {
3360
3361 int wcaps = get_wcaps(codec, conn_list[0]);
3362 int wid_type = (wcaps & AC_WCAP_TYPE)
3363 >> AC_WCAP_TYPE_SHIFT;
3364 /* LR swap check, some stac925x have a mux that
3365 * changes the DACs output path instead of the
3366 * mono-mux path.
3367 */
3368 if (wid_type == AC_WID_AUD_SEL &&
3369 !(wcaps & AC_WCAP_LR_SWAP))
3370 spec->mono_nid = conn_list[0];
3371 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003372 if (dir) {
3373 hda_nid_t nid = spec->autocfg.mono_out_pin;
3374
3375 /* most mono outs have a least a mute/unmute switch */
3376 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3377 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3378 "Mono Playback Switch",
3379 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003380 if (err < 0)
3381 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003382 /* check for volume support for the amp */
3383 if ((caps & AC_AMPCAP_NUM_STEPS)
3384 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3385 err = stac92xx_add_control(spec,
3386 STAC_CTL_WIDGET_VOL,
3387 "Mono Playback Volume",
3388 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3389 if (err < 0)
3390 return err;
3391 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003392 }
3393
3394 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3395 AC_PINCTL_OUT_EN);
3396 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003397
Matt Porter403d1942005-11-29 15:00:51 +01003398 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3399 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003400 if (spec->multiout.num_dacs == 0)
3401 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3402 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003403
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003404 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3405
3406 if (err < 0)
3407 return err;
3408
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003409 /* setup analog beep controls */
3410 if (spec->anabeep_nid > 0) {
3411 err = stac92xx_auto_create_beep_ctls(codec,
3412 spec->anabeep_nid);
3413 if (err < 0)
3414 return err;
3415 }
3416
3417 /* setup digital beep controls and input device */
3418#ifdef CONFIG_SND_HDA_INPUT_BEEP
3419 if (spec->digbeep_nid > 0) {
3420 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003421 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003422
3423 err = stac92xx_auto_create_beep_ctls(codec, nid);
3424 if (err < 0)
3425 return err;
3426 err = snd_hda_attach_beep_device(codec, nid);
3427 if (err < 0)
3428 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003429 /* if no beep switch is available, make its own one */
3430 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3431 if (codec->beep &&
3432 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3433 err = stac92xx_beep_switch_ctl(codec);
3434 if (err < 0)
3435 return err;
3436 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003437 }
3438#endif
3439
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003440 if (hp_speaker_swap == 1) {
3441 /* Restore the hp_outs and line_outs */
3442 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3443 sizeof(spec->autocfg.line_out_pins));
3444 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3445 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3446 sizeof(spec->autocfg.speaker_pins));
3447 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3448 memset(spec->autocfg.speaker_pins, 0,
3449 sizeof(spec->autocfg.speaker_pins));
3450 spec->autocfg.speaker_outs = 0;
3451 }
3452
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003453 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3454
3455 if (err < 0)
3456 return err;
3457
3458 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3459
3460 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003461 return err;
3462
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003463 if (spec->mono_nid > 0) {
3464 err = stac92xx_auto_create_mono_output_ctls(codec);
3465 if (err < 0)
3466 return err;
3467 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003468 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003469 err = stac92xx_auto_create_amp_output_ctls(codec);
3470 if (err < 0)
3471 return err;
3472 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003473 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003474 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3475 &spec->autocfg)) < 0)
3476 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003477 if (spec->num_muxes > 0) {
3478 err = stac92xx_auto_create_mux_input_ctls(codec);
3479 if (err < 0)
3480 return err;
3481 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003482 if (spec->num_smuxes > 0) {
3483 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3484 if (err < 0)
3485 return err;
3486 }
Matt Porter8b657272006-10-26 17:12:59 +02003487
Mattc7d4b2f2005-06-27 14:59:41 +02003488 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003489 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003490 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003491
Takashi Iwai82bc9552006-03-21 11:24:42 +01003492 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003493 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003494 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003495 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003496
3497 if (spec->kctl_alloc)
3498 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3499
3500 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003501 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003502 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003503 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003504 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003505 return 1;
3506}
3507
Takashi Iwai82bc9552006-03-21 11:24:42 +01003508/* add playback controls for HP output */
3509static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3510 struct auto_pin_cfg *cfg)
3511{
3512 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003513 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003514 unsigned int wid_caps;
3515
3516 if (! pin)
3517 return 0;
3518
3519 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003520 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003521 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003522
3523 return 0;
3524}
3525
Richard Fish160ea0d2006-09-06 13:58:25 +02003526/* add playback controls for LFE output */
3527static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3528 struct auto_pin_cfg *cfg)
3529{
3530 struct sigmatel_spec *spec = codec->spec;
3531 int err;
3532 hda_nid_t lfe_pin = 0x0;
3533 int i;
3534
3535 /*
3536 * search speaker outs and line outs for a mono speaker pin
3537 * with an amp. If one is found, add LFE controls
3538 * for it.
3539 */
3540 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3541 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003542 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003543 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3544 if (wcaps == AC_WCAP_OUT_AMP)
3545 /* found a mono speaker with an amp, must be lfe */
3546 lfe_pin = pin;
3547 }
3548
3549 /* if speaker_outs is 0, then speakers may be in line_outs */
3550 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3551 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3552 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003553 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003554 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003555 AC_VERB_GET_CONFIG_DEFAULT,
3556 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003557 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003558 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003559 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3560 if (wcaps == AC_WCAP_OUT_AMP)
3561 /* found a mono speaker with an amp,
3562 must be lfe */
3563 lfe_pin = pin;
3564 }
3565 }
3566 }
3567
3568 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003569 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003570 if (err < 0)
3571 return err;
3572 }
3573
3574 return 0;
3575}
3576
Mattc7d4b2f2005-06-27 14:59:41 +02003577static int stac9200_parse_auto_config(struct hda_codec *codec)
3578{
3579 struct sigmatel_spec *spec = codec->spec;
3580 int err;
3581
Kailang Yangdf694da2005-12-05 19:42:22 +01003582 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003583 return err;
3584
3585 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3586 return err;
3587
Takashi Iwai82bc9552006-03-21 11:24:42 +01003588 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3589 return err;
3590
Richard Fish160ea0d2006-09-06 13:58:25 +02003591 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3592 return err;
3593
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003594 if (spec->num_muxes > 0) {
3595 err = stac92xx_auto_create_mux_input_ctls(codec);
3596 if (err < 0)
3597 return err;
3598 }
3599
Takashi Iwai82bc9552006-03-21 11:24:42 +01003600 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003601 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003602 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003603 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003604
3605 if (spec->kctl_alloc)
3606 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3607
3608 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003609 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003610
3611 return 1;
3612}
3613
Sam Revitch62fe78e2006-05-10 15:09:17 +02003614/*
3615 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3616 * funky external mute control using GPIO pins.
3617 */
3618
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003619static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003620 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003621{
3622 unsigned int gpiostate, gpiomask, gpiodir;
3623
3624 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3625 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003626 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003627
3628 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3629 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003630 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003631
3632 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3633 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003634 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003635
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003636 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003637 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3638
3639 snd_hda_codec_write(codec, codec->afg, 0,
3640 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003641 snd_hda_codec_read(codec, codec->afg, 0,
3642 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003643
3644 msleep(1);
3645
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003646 snd_hda_codec_read(codec, codec->afg, 0,
3647 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003648}
3649
Takashi Iwai314634b2006-09-21 11:56:18 +02003650static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3651 unsigned int event)
3652{
3653 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003654 snd_hda_codec_write_cache(codec, nid, 0,
3655 AC_VERB_SET_UNSOLICITED_ENABLE,
3656 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003657}
3658
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003659static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3660{
3661 int i;
3662 for (i = 0; i < cfg->hp_outs; i++)
3663 if (cfg->hp_pins[i] == nid)
3664 return 1; /* nid is a HP-Out */
3665
3666 return 0; /* nid is not a HP-Out */
3667};
3668
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003669static void stac92xx_power_down(struct hda_codec *codec)
3670{
3671 struct sigmatel_spec *spec = codec->spec;
3672
3673 /* power down inactive DACs */
3674 hda_nid_t *dac;
3675 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003676 if (!is_in_dac_nids(spec, *dac) &&
3677 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003678 snd_hda_codec_write_cache(codec, *dac, 0,
3679 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3680}
3681
Mattc7d4b2f2005-06-27 14:59:41 +02003682static int stac92xx_init(struct hda_codec *codec)
3683{
3684 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003685 struct auto_pin_cfg *cfg = &spec->autocfg;
3686 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003687
Mattc7d4b2f2005-06-27 14:59:41 +02003688 snd_hda_sequence_write(codec, spec->init);
3689
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003690 /* power down adcs initially */
3691 if (spec->powerdown_adcs)
3692 for (i = 0; i < spec->num_adcs; i++)
3693 snd_hda_codec_write_cache(codec,
3694 spec->adc_nids[i], 0,
3695 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003696 /* set up pins */
3697 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003698 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003699 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003700 enable_pin_detect(codec, cfg->hp_pins[i],
3701 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003702 /* force to enable the first line-out; the others are set up
3703 * in unsol_event
3704 */
3705 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3706 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003707 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003708 /* fake event to set up pins */
3709 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3710 } else {
3711 stac92xx_auto_init_multi_out(codec);
3712 stac92xx_auto_init_hp_out(codec);
3713 }
3714 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003715 hda_nid_t nid = cfg->input_pins[i];
3716 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003717 unsigned int pinctl;
3718 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3719 /* for mic pins, force to initialize */
3720 pinctl = stac92xx_get_vref(codec, nid);
3721 } else {
3722 pinctl = snd_hda_codec_read(codec, nid, 0,
3723 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3724 /* if PINCTL already set then skip */
3725 if (pinctl & AC_PINCTL_IN_EN)
3726 continue;
3727 }
3728 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003729 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3730 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003731 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003732 for (i = 0; i < spec->num_dmics; i++)
3733 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3734 AC_PINCTL_IN_EN);
3735 for (i = 0; i < spec->num_pwrs; i++) {
3736 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3737 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3738 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3739 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003740 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3741 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003742 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003743 /* outputs are only ports capable of power management
3744 * any attempts on powering down a input port cause the
3745 * referenced VREF to act quirky.
3746 */
3747 if (pinctl & AC_PINCTL_IN_EN)
3748 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003749 /* skip any ports that don't have jacks since presence
3750 * detection is useless */
3751 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003752 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003753 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3754 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3755 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003756 if (spec->dac_list)
3757 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003758 if (cfg->dig_out_pin)
3759 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3760 AC_PINCTL_OUT_EN);
3761 if (cfg->dig_in_pin)
3762 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3763 AC_PINCTL_IN_EN);
3764
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003765 stac_gpio_set(codec, spec->gpio_mask,
3766 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003767
Mattc7d4b2f2005-06-27 14:59:41 +02003768 return 0;
3769}
3770
Matt2f2f4252005-04-13 14:45:30 +02003771static void stac92xx_free(struct hda_codec *codec)
3772{
Mattc7d4b2f2005-06-27 14:59:41 +02003773 struct sigmatel_spec *spec = codec->spec;
3774 int i;
3775
3776 if (! spec)
3777 return;
3778
3779 if (spec->kctl_alloc) {
3780 for (i = 0; i < spec->num_kctl_used; i++)
3781 kfree(spec->kctl_alloc[i].name);
3782 kfree(spec->kctl_alloc);
3783 }
3784
Richard Fish11b44bb2006-08-23 18:31:34 +02003785 if (spec->bios_pin_configs)
3786 kfree(spec->bios_pin_configs);
3787
Mattc7d4b2f2005-06-27 14:59:41 +02003788 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003789 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003790}
3791
Matt4e550962005-07-04 17:51:39 +02003792static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3793 unsigned int flag)
3794{
3795 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3796 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003797
Takashi Iwaif9acba42007-05-29 18:01:06 +02003798 if (pin_ctl & AC_PINCTL_IN_EN) {
3799 /*
3800 * we need to check the current set-up direction of
3801 * shared input pins since they can be switched via
3802 * "xxx as Output" mixer switch
3803 */
3804 struct sigmatel_spec *spec = codec->spec;
3805 struct auto_pin_cfg *cfg = &spec->autocfg;
3806 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3807 spec->line_switch) ||
3808 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3809 spec->mic_switch))
3810 return;
3811 }
3812
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003813 /* if setting pin direction bits, clear the current
3814 direction bits first */
3815 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3816 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3817
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003818 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003819 AC_VERB_SET_PIN_WIDGET_CONTROL,
3820 pin_ctl | flag);
3821}
3822
3823static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3824 unsigned int flag)
3825{
3826 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3827 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003828 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003829 AC_VERB_SET_PIN_WIDGET_CONTROL,
3830 pin_ctl & ~flag);
3831}
3832
Jiang Zhe40c1d302007-11-12 13:05:16 +01003833static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003834{
3835 if (!nid)
3836 return 0;
3837 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003838 & (1 << 31)) {
3839 unsigned int pinctl;
3840 pinctl = snd_hda_codec_read(codec, nid, 0,
3841 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3842 if (pinctl & AC_PINCTL_IN_EN)
3843 return 0; /* mic- or line-input */
3844 else
3845 return 1; /* HP-output */
3846 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003847 return 0;
3848}
3849
Takashi Iwaid7a89432008-11-12 09:48:04 +01003850/* return non-zero if the hp-pin of the given array index isn't
3851 * a jack-detection target
3852 */
3853static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3854{
3855 struct auto_pin_cfg *cfg = &spec->autocfg;
3856
3857 /* ignore sensing of shared line and mic jacks */
3858 if (spec->line_switch &&
3859 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3860 return 1;
3861 if (spec->mic_switch &&
3862 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3863 return 1;
3864 /* ignore if the pin is set as line-out */
3865 if (cfg->hp_pins[i] == spec->hp_switch)
3866 return 1;
3867 return 0;
3868}
3869
Takashi Iwai314634b2006-09-21 11:56:18 +02003870static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003871{
3872 struct sigmatel_spec *spec = codec->spec;
3873 struct auto_pin_cfg *cfg = &spec->autocfg;
3874 int i, presence;
3875
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003876 presence = 0;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003877 if (spec->gpio_mute)
3878 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3879 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3880
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003881 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003882 if (presence)
3883 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003884 if (no_hp_sensing(spec, i))
3885 continue;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003886 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003887 }
Matt4e550962005-07-04 17:51:39 +02003888
3889 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003890 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003891 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003892 stac92xx_reset_pinctl(codec, spec->hp_switch,
3893 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003894 for (i = 0; i < cfg->line_outs; i++)
3895 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3896 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003897 for (i = 0; i < cfg->speaker_outs; i++)
3898 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3899 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003900 if (spec->eapd_mask)
3901 stac_gpio_set(codec, spec->gpio_mask,
3902 spec->gpio_dir, spec->gpio_data &
3903 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003904 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003905 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003906 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003907 stac92xx_set_pinctl(codec, spec->hp_switch,
3908 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003909 for (i = 0; i < cfg->line_outs; i++)
3910 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3911 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003912 for (i = 0; i < cfg->speaker_outs; i++)
3913 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3914 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003915 if (spec->eapd_mask)
3916 stac_gpio_set(codec, spec->gpio_mask,
3917 spec->gpio_dir, spec->gpio_data |
3918 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003919 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01003920 /* toggle hp outs */
3921 for (i = 0; i < cfg->hp_outs; i++) {
3922 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3923 if (no_hp_sensing(spec, i))
3924 continue;
3925 if (presence)
3926 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3927 else
3928 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3929 }
Matt4e550962005-07-04 17:51:39 +02003930}
3931
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003932static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3933{
3934 struct sigmatel_spec *spec = codec->spec;
3935 hda_nid_t nid = spec->pwr_nids[idx];
3936 int presence, val;
3937 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3938 & 0x000000ff;
3939 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003940
3941 /* several codecs have two power down bits */
3942 if (spec->pwr_mapping)
3943 idx = spec->pwr_mapping[idx];
3944 else
3945 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003946
3947 if (presence)
3948 val &= ~idx;
3949 else
3950 val |= idx;
3951
3952 /* power down unused output ports */
3953 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3954};
3955
Takashi Iwai314634b2006-09-21 11:56:18 +02003956static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3957{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003958 struct sigmatel_spec *spec = codec->spec;
3959 int idx = res >> 26 & 0x0f;
3960
Matthew Ranostay72474be2008-10-09 09:32:17 -04003961 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003962 case STAC_HP_EVENT:
3963 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003964 /* fallthru */
3965 case STAC_PWR_EVENT:
3966 if (spec->num_pwrs > 0)
3967 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04003968 break;
3969 case STAC_VREF_EVENT: {
3970 int data = snd_hda_codec_read(codec, codec->afg, 0,
3971 AC_VERB_GET_GPIO_DATA, 0);
3972 /* toggle VREF state based on GPIOx status */
3973 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
3974 !!(data & (1 << idx)));
3975 break;
3976 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003977 }
3978}
3979
Takashi Iwaicb53c622007-08-10 17:21:45 +02003980#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003981static int stac92xx_resume(struct hda_codec *codec)
3982{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003983 struct sigmatel_spec *spec = codec->spec;
3984
Richard Fish11b44bb2006-08-23 18:31:34 +02003985 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003986 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003987 stac_gpio_set(codec, spec->gpio_mask,
3988 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003989 snd_hda_codec_resume_amp(codec);
3990 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003991 /* power down inactive DACs */
3992 if (spec->dac_list)
3993 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003994 /* invoke unsolicited event to reset the HP state */
3995 if (spec->hp_detect)
3996 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003997 return 0;
3998}
3999#endif
4000
Matt2f2f4252005-04-13 14:45:30 +02004001static struct hda_codec_ops stac92xx_patch_ops = {
4002 .build_controls = stac92xx_build_controls,
4003 .build_pcms = stac92xx_build_pcms,
4004 .init = stac92xx_init,
4005 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004006 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004007#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004008 .resume = stac92xx_resume,
4009#endif
Matt2f2f4252005-04-13 14:45:30 +02004010};
4011
4012static int patch_stac9200(struct hda_codec *codec)
4013{
4014 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004015 int err;
Matt2f2f4252005-04-13 14:45:30 +02004016
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004017 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004018 if (spec == NULL)
4019 return -ENOMEM;
4020
4021 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004022 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004023 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004024 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4025 stac9200_models,
4026 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004027 if (spec->board_config < 0) {
4028 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4029 err = stac92xx_save_bios_config_regs(codec);
4030 if (err < 0) {
4031 stac92xx_free(codec);
4032 return err;
4033 }
4034 spec->pin_configs = spec->bios_pin_configs;
4035 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004036 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4037 stac92xx_set_config_regs(codec);
4038 }
Matt2f2f4252005-04-13 14:45:30 +02004039
4040 spec->multiout.max_channels = 2;
4041 spec->multiout.num_dacs = 1;
4042 spec->multiout.dac_nids = stac9200_dac_nids;
4043 spec->adc_nids = stac9200_adc_nids;
4044 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004045 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004046 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004047 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004048 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004049
Tobin Davisbf277782008-02-03 20:31:47 +01004050 if (spec->board_config == STAC_9200_GATEWAY ||
4051 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004052 spec->init = stac9200_eapd_init;
4053 else
4054 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004055 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004056
Takashi Iwai117f2572008-03-18 09:53:23 +01004057 if (spec->board_config == STAC_9200_PANASONIC) {
4058 spec->gpio_mask = spec->gpio_dir = 0x09;
4059 spec->gpio_data = 0x00;
4060 }
4061
Mattc7d4b2f2005-06-27 14:59:41 +02004062 err = stac9200_parse_auto_config(codec);
4063 if (err < 0) {
4064 stac92xx_free(codec);
4065 return err;
4066 }
Matt2f2f4252005-04-13 14:45:30 +02004067
4068 codec->patch_ops = stac92xx_patch_ops;
4069
4070 return 0;
4071}
4072
Tobin Davis8e21c342007-01-08 11:04:17 +01004073static int patch_stac925x(struct hda_codec *codec)
4074{
4075 struct sigmatel_spec *spec;
4076 int err;
4077
4078 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4079 if (spec == NULL)
4080 return -ENOMEM;
4081
4082 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004083 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004084 spec->pin_nids = stac925x_pin_nids;
4085 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4086 stac925x_models,
4087 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004088 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004089 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004090 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4091 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004092 err = stac92xx_save_bios_config_regs(codec);
4093 if (err < 0) {
4094 stac92xx_free(codec);
4095 return err;
4096 }
4097 spec->pin_configs = spec->bios_pin_configs;
4098 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4099 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4100 stac92xx_set_config_regs(codec);
4101 }
4102
4103 spec->multiout.max_channels = 2;
4104 spec->multiout.num_dacs = 1;
4105 spec->multiout.dac_nids = stac925x_dac_nids;
4106 spec->adc_nids = stac925x_adc_nids;
4107 spec->mux_nids = stac925x_mux_nids;
4108 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004109 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004110 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004111 switch (codec->vendor_id) {
4112 case 0x83847632: /* STAC9202 */
4113 case 0x83847633: /* STAC9202D */
4114 case 0x83847636: /* STAC9251 */
4115 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004116 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004117 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004118 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4119 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004120 break;
4121 default:
4122 spec->num_dmics = 0;
4123 break;
4124 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004125
4126 spec->init = stac925x_core_init;
4127 spec->mixer = stac925x_mixer;
4128
4129 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004130 if (!err) {
4131 if (spec->board_config < 0) {
4132 printk(KERN_WARNING "hda_codec: No auto-config is "
4133 "available, default to model=ref\n");
4134 spec->board_config = STAC_925x_REF;
4135 goto again;
4136 }
4137 err = -EINVAL;
4138 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004139 if (err < 0) {
4140 stac92xx_free(codec);
4141 return err;
4142 }
4143
4144 codec->patch_ops = stac92xx_patch_ops;
4145
4146 return 0;
4147}
4148
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004149static struct hda_input_mux stac92hd73xx_dmux = {
4150 .num_items = 4,
4151 .items = {
4152 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004153 { "Digital Mic 1", 0x09 },
4154 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004155 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004156 }
4157};
4158
4159static int patch_stac92hd73xx(struct hda_codec *codec)
4160{
4161 struct sigmatel_spec *spec;
4162 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4163 int err = 0;
4164
4165 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4166 if (spec == NULL)
4167 return -ENOMEM;
4168
4169 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004170 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004171 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4172 spec->pin_nids = stac92hd73xx_pin_nids;
4173 spec->board_config = snd_hda_check_board_config(codec,
4174 STAC_92HD73XX_MODELS,
4175 stac92hd73xx_models,
4176 stac92hd73xx_cfg_tbl);
4177again:
4178 if (spec->board_config < 0) {
4179 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4180 " STAC92HD73XX, using BIOS defaults\n");
4181 err = stac92xx_save_bios_config_regs(codec);
4182 if (err < 0) {
4183 stac92xx_free(codec);
4184 return err;
4185 }
4186 spec->pin_configs = spec->bios_pin_configs;
4187 } else {
4188 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4189 stac92xx_set_config_regs(codec);
4190 }
4191
4192 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4193 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4194
4195 if (spec->multiout.num_dacs < 0) {
4196 printk(KERN_WARNING "hda_codec: Could not determine "
4197 "number of channels defaulting to DAC count\n");
4198 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4199 }
4200
4201 switch (spec->multiout.num_dacs) {
4202 case 0x3: /* 6 Channel */
4203 spec->mixer = stac92hd73xx_6ch_mixer;
4204 spec->init = stac92hd73xx_6ch_core_init;
4205 break;
4206 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004207 spec->mixer = stac92hd73xx_8ch_mixer;
4208 spec->init = stac92hd73xx_8ch_core_init;
4209 break;
4210 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004211 spec->mixer = stac92hd73xx_10ch_mixer;
4212 spec->init = stac92hd73xx_10ch_core_init;
4213 };
4214
4215 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4216 spec->aloopback_mask = 0x01;
4217 spec->aloopback_shift = 8;
4218
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004219 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004220 spec->mux_nids = stac92hd73xx_mux_nids;
4221 spec->adc_nids = stac92hd73xx_adc_nids;
4222 spec->dmic_nids = stac92hd73xx_dmic_nids;
4223 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004224 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004225 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004226 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004227
4228 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4229 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004230 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004231 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4232 sizeof(stac92hd73xx_dmux));
4233
Matthew Ranostaya7662642008-02-21 07:51:14 +01004234 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004235 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004236 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004237 /* fallthru */
4238 case STAC_DELL_M6:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004239 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004240 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4241 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4242 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004243
4244 if (!spec->init)
4245 spec->init = dell_m6_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004246 switch (codec->subsystem_id) {
4247 case 0x1028025e: /* Analog Mics */
4248 case 0x1028025f:
4249 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4250 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004251 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004252 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004253 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004254 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004255 case 0x10280254:
4256 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004257 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4258 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004259 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004260 break;
4261 case 0x10280256: /* Both */
4262 case 0x10280057:
4263 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4264 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4265 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004266 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004267 break;
4268 }
4269 break;
4270 default:
4271 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004272 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004273 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004274 if (spec->board_config > STAC_92HD73XX_REF) {
4275 /* GPIO0 High = Enable EAPD */
4276 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4277 spec->gpio_data = 0x01;
4278 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004279 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004280
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004281 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4282 spec->pwr_nids = stac92hd73xx_pwr_nids;
4283
Matthew Ranostayd9737752008-09-07 12:03:41 +02004284 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004285
4286 if (!err) {
4287 if (spec->board_config < 0) {
4288 printk(KERN_WARNING "hda_codec: No auto-config is "
4289 "available, default to model=ref\n");
4290 spec->board_config = STAC_92HD73XX_REF;
4291 goto again;
4292 }
4293 err = -EINVAL;
4294 }
4295
4296 if (err < 0) {
4297 stac92xx_free(codec);
4298 return err;
4299 }
4300
4301 codec->patch_ops = stac92xx_patch_ops;
4302
4303 return 0;
4304}
4305
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004306static struct hda_input_mux stac92hd83xxx_dmux = {
4307 .num_items = 3,
4308 .items = {
4309 { "Analog Inputs", 0x03 },
4310 { "Digital Mic 1", 0x04 },
4311 { "Digital Mic 2", 0x05 },
4312 }
4313};
4314
4315static int patch_stac92hd83xxx(struct hda_codec *codec)
4316{
4317 struct sigmatel_spec *spec;
4318 int err;
4319
4320 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4321 if (spec == NULL)
4322 return -ENOMEM;
4323
4324 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004325 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004326 spec->mono_nid = 0x19;
4327 spec->digbeep_nid = 0x21;
4328 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4329 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4330 spec->adc_nids = stac92hd83xxx_adc_nids;
4331 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4332 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4333 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4334 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4335
4336 spec->init = stac92hd83xxx_core_init;
4337 switch (codec->vendor_id) {
4338 case 0x111d7605:
4339 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4340 break;
4341 default:
4342 spec->num_pwrs--;
4343 spec->init++; /* switch to config #2 */
4344 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4345 }
4346
4347 spec->mixer = stac92hd83xxx_mixer;
4348 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4349 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4350 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4351 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4352 spec->dinput_mux = &stac92hd83xxx_dmux;
4353 spec->pin_nids = stac92hd83xxx_pin_nids;
4354 spec->board_config = snd_hda_check_board_config(codec,
4355 STAC_92HD83XXX_MODELS,
4356 stac92hd83xxx_models,
4357 stac92hd83xxx_cfg_tbl);
4358again:
4359 if (spec->board_config < 0) {
4360 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4361 " STAC92HD83XXX, using BIOS defaults\n");
4362 err = stac92xx_save_bios_config_regs(codec);
4363 if (err < 0) {
4364 stac92xx_free(codec);
4365 return err;
4366 }
4367 spec->pin_configs = spec->bios_pin_configs;
4368 } else {
4369 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4370 stac92xx_set_config_regs(codec);
4371 }
4372
4373 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4374 if (!err) {
4375 if (spec->board_config < 0) {
4376 printk(KERN_WARNING "hda_codec: No auto-config is "
4377 "available, default to model=ref\n");
4378 spec->board_config = STAC_92HD83XXX_REF;
4379 goto again;
4380 }
4381 err = -EINVAL;
4382 }
4383
4384 if (err < 0) {
4385 stac92xx_free(codec);
4386 return err;
4387 }
4388
4389 codec->patch_ops = stac92xx_patch_ops;
4390
4391 return 0;
4392}
4393
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004394#ifdef SND_HDA_NEEDS_RESUME
4395static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4396{
4397 struct sigmatel_spec *spec = codec->spec;
4398 int i;
4399 snd_hda_codec_write_cache(codec, codec->afg, 0,
4400 AC_VERB_SET_POWER_STATE, pwr);
4401
4402 msleep(1);
4403 for (i = 0; i < spec->num_adcs; i++) {
4404 snd_hda_codec_write_cache(codec,
4405 spec->adc_nids[i], 0,
4406 AC_VERB_SET_POWER_STATE, pwr);
4407 }
4408};
4409
4410static int stac92hd71xx_resume(struct hda_codec *codec)
4411{
4412 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4413 return stac92xx_resume(codec);
4414}
4415
4416static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4417{
4418 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4419 return 0;
4420};
4421
4422#endif
4423
4424static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4425 .build_controls = stac92xx_build_controls,
4426 .build_pcms = stac92xx_build_pcms,
4427 .init = stac92xx_init,
4428 .free = stac92xx_free,
4429 .unsol_event = stac92xx_unsol_event,
4430#ifdef SND_HDA_NEEDS_RESUME
4431 .resume = stac92hd71xx_resume,
4432 .suspend = stac92hd71xx_suspend,
4433#endif
4434};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004435
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004436static struct hda_input_mux stac92hd71bxx_dmux = {
4437 .num_items = 4,
4438 .items = {
4439 { "Analog Inputs", 0x00 },
4440 { "Mixer", 0x01 },
4441 { "Digital Mic 1", 0x02 },
4442 { "Digital Mic 2", 0x03 },
4443 }
4444};
4445
Matthew Ranostaye035b842007-11-06 11:53:55 +01004446static int patch_stac92hd71bxx(struct hda_codec *codec)
4447{
4448 struct sigmatel_spec *spec;
4449 int err = 0;
4450
4451 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4452 if (spec == NULL)
4453 return -ENOMEM;
4454
4455 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004456 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004457 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004458 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004459 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004460 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4461 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004462 spec->board_config = snd_hda_check_board_config(codec,
4463 STAC_92HD71BXX_MODELS,
4464 stac92hd71bxx_models,
4465 stac92hd71bxx_cfg_tbl);
4466again:
4467 if (spec->board_config < 0) {
4468 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4469 " STAC92HD71BXX, using BIOS defaults\n");
4470 err = stac92xx_save_bios_config_regs(codec);
4471 if (err < 0) {
4472 stac92xx_free(codec);
4473 return err;
4474 }
4475 spec->pin_configs = spec->bios_pin_configs;
4476 } else {
4477 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4478 stac92xx_set_config_regs(codec);
4479 }
4480
Takashi Iwai41c3b642008-11-18 10:45:15 +01004481 if (spec->board_config > STAC_92HD71BXX_REF) {
4482 /* GPIO0 = EAPD */
4483 spec->gpio_mask = 0x01;
4484 spec->gpio_dir = 0x01;
4485 spec->gpio_data = 0x01;
4486 }
4487
Matthew Ranostay541eee82007-12-14 12:08:04 +01004488 switch (codec->vendor_id) {
4489 case 0x111d76b6: /* 4 Port without Analog Mixer */
4490 case 0x111d76b7:
4491 case 0x111d76b4: /* 6 Port without Analog Mixer */
4492 case 0x111d76b5:
4493 spec->mixer = stac92hd71bxx_mixer;
4494 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004495 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004496 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004497 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004498 switch (spec->board_config) {
4499 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004500 /* Enable VREF power saving on GPIO1 detect */
4501 snd_hda_codec_write(codec, codec->afg, 0,
4502 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4503 snd_hda_codec_write_cache(codec, codec->afg, 0,
4504 AC_VERB_SET_UNSOLICITED_ENABLE,
4505 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4506 spec->gpio_mask |= 0x02;
4507 break;
4508 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004509 if ((codec->revision_id & 0xf) == 0 ||
4510 (codec->revision_id & 0xf) == 1) {
4511#ifdef SND_HDA_NEEDS_RESUME
4512 codec->patch_ops = stac92hd71bxx_patch_ops;
4513#endif
4514 spec->stream_delay = 40; /* 40 milliseconds */
4515 }
4516
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004517 /* no output amps */
4518 spec->num_pwrs = 0;
4519 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004520 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004521
4522 /* disable VSW */
4523 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4524 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4525 break;
4526 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004527 if ((codec->revision_id & 0xf) == 1) {
4528#ifdef SND_HDA_NEEDS_RESUME
4529 codec->patch_ops = stac92hd71bxx_patch_ops;
4530#endif
4531 spec->stream_delay = 40; /* 40 milliseconds */
4532 }
4533
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004534 /* no output amps */
4535 spec->num_pwrs = 0;
4536 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004537 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004538 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004539 spec->mixer = stac92hd71bxx_analog_mixer;
4540 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004541 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004542 }
4543
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004544 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004545 spec->aloopback_shift = 0;
4546
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004547 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004548 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004549 spec->mux_nids = stac92hd71bxx_mux_nids;
4550 spec->adc_nids = stac92hd71bxx_adc_nids;
4551 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004552 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004553 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004554 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004555
4556 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4557 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004558
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004559 switch (spec->board_config) {
4560 case STAC_HP_M4:
4561 spec->num_dmics = 0;
Matthew Ranostayb9aea7152008-10-09 08:37:28 -04004562 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004563 spec->num_dmuxes = 0;
4564
4565 /* enable internal microphone */
Matthew Ranostayb9aea7152008-10-09 08:37:28 -04004566 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4567 stac92xx_auto_set_pinctl(codec, 0x0e,
4568 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004569 break;
4570 default:
4571 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4572 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4573 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4574 };
4575
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004576 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004577 spec->multiout.hp_nid = 0x11;
4578 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004579 if (spec->dinput_mux)
4580 spec->private_dimux.num_items +=
4581 spec->num_dmics -
4582 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004583
4584 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4585 if (!err) {
4586 if (spec->board_config < 0) {
4587 printk(KERN_WARNING "hda_codec: No auto-config is "
4588 "available, default to model=ref\n");
4589 spec->board_config = STAC_92HD71BXX_REF;
4590 goto again;
4591 }
4592 err = -EINVAL;
4593 }
4594
4595 if (err < 0) {
4596 stac92xx_free(codec);
4597 return err;
4598 }
4599
Matthew Ranostaye035b842007-11-06 11:53:55 +01004600 return 0;
4601};
4602
Matt2f2f4252005-04-13 14:45:30 +02004603static int patch_stac922x(struct hda_codec *codec)
4604{
4605 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004606 int err;
Matt2f2f4252005-04-13 14:45:30 +02004607
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004608 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004609 if (spec == NULL)
4610 return -ENOMEM;
4611
4612 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004613 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004614 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004615 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4616 stac922x_models,
4617 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004618 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004619 spec->gpio_mask = spec->gpio_dir = 0x03;
4620 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004621 /* Intel Macs have all same PCI SSID, so we need to check
4622 * codec SSID to distinguish the exact models
4623 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004624 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004625 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004626
4627 case 0x106b0800:
4628 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004629 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004630 case 0x106b0600:
4631 case 0x106b0700:
4632 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004633 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004634 case 0x106b0e00:
4635 case 0x106b0f00:
4636 case 0x106b1600:
4637 case 0x106b1700:
4638 case 0x106b0200:
4639 case 0x106b1e00:
4640 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004641 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004642 case 0x106b1a00:
4643 case 0x00000100:
4644 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004645 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004646 case 0x106b0a00:
4647 case 0x106b2200:
4648 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004649 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004650 default:
4651 spec->board_config = STAC_INTEL_MAC_V3;
4652 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004653 }
4654 }
4655
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004656 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004657 if (spec->board_config < 0) {
4658 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4659 "using BIOS defaults\n");
4660 err = stac92xx_save_bios_config_regs(codec);
4661 if (err < 0) {
4662 stac92xx_free(codec);
4663 return err;
4664 }
4665 spec->pin_configs = spec->bios_pin_configs;
4666 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004667 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4668 stac92xx_set_config_regs(codec);
4669 }
Matt2f2f4252005-04-13 14:45:30 +02004670
Matt2f2f4252005-04-13 14:45:30 +02004671 spec->adc_nids = stac922x_adc_nids;
4672 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004673 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004674 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004675 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004676 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004677
4678 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004679 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004680
4681 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004682
Matt Porter3cc08dc2006-01-23 15:27:49 +01004683 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004684 if (!err) {
4685 if (spec->board_config < 0) {
4686 printk(KERN_WARNING "hda_codec: No auto-config is "
4687 "available, default to model=ref\n");
4688 spec->board_config = STAC_D945_REF;
4689 goto again;
4690 }
4691 err = -EINVAL;
4692 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004693 if (err < 0) {
4694 stac92xx_free(codec);
4695 return err;
4696 }
4697
4698 codec->patch_ops = stac92xx_patch_ops;
4699
Takashi Iwai807a46362007-05-29 19:01:37 +02004700 /* Fix Mux capture level; max to 2 */
4701 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4702 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4703 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4704 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4705 (0 << AC_AMPCAP_MUTE_SHIFT));
4706
Matt Porter3cc08dc2006-01-23 15:27:49 +01004707 return 0;
4708}
4709
4710static int patch_stac927x(struct hda_codec *codec)
4711{
4712 struct sigmatel_spec *spec;
4713 int err;
4714
4715 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4716 if (spec == NULL)
4717 return -ENOMEM;
4718
4719 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004720 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004721 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004722 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4723 stac927x_models,
4724 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004725 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004726 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4727 if (spec->board_config < 0)
4728 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4729 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004730 err = stac92xx_save_bios_config_regs(codec);
4731 if (err < 0) {
4732 stac92xx_free(codec);
4733 return err;
4734 }
4735 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004736 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004737 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4738 stac92xx_set_config_regs(codec);
4739 }
4740
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004741 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004742 spec->adc_nids = stac927x_adc_nids;
4743 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4744 spec->mux_nids = stac927x_mux_nids;
4745 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004746 spec->smux_nids = stac927x_smux_nids;
4747 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004748 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004749 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004750 spec->multiout.dac_nids = spec->dac_nids;
4751
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004752 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004753 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004754 case STAC_D965_5ST:
4755 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004756 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004757 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004758 spec->num_dmics = 0;
4759
Tobin Davis93ed1502006-09-01 21:03:12 +02004760 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004761 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004762 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004763 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004764 switch (codec->subsystem_id) {
4765 case 0x10280209:
4766 case 0x1028022e:
4767 /* correct the device field to SPDIF out */
4768 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4769 break;
4770 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004771 /* configure the analog microphone on some laptops */
4772 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004773 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004774 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004775 /* correct the front input jack as a mic */
4776 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4777 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004778 case STAC_DELL_3ST:
4779 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004780 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004781 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004782 spec->dmic_nids = stac927x_dmic_nids;
4783 spec->num_dmics = STAC927X_NUM_DMICS;
4784
Tobin Davis93ed1502006-09-01 21:03:12 +02004785 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004786 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004787 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004788 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004789 break;
4790 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004791 if (spec->board_config > STAC_D965_REF) {
4792 /* GPIO0 High = Enable EAPD */
4793 spec->eapd_mask = spec->gpio_mask = 0x01;
4794 spec->gpio_dir = spec->gpio_data = 0x01;
4795 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004796 spec->num_dmics = 0;
4797
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004798 spec->init = stac927x_core_init;
4799 spec->mixer = stac927x_mixer;
4800 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004801
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004802 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004803 spec->aloopback_mask = 0x40;
4804 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004805
Matt Porter3cc08dc2006-01-23 15:27:49 +01004806 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004807 if (!err) {
4808 if (spec->board_config < 0) {
4809 printk(KERN_WARNING "hda_codec: No auto-config is "
4810 "available, default to model=ref\n");
4811 spec->board_config = STAC_D965_REF;
4812 goto again;
4813 }
4814 err = -EINVAL;
4815 }
Mattc7d4b2f2005-06-27 14:59:41 +02004816 if (err < 0) {
4817 stac92xx_free(codec);
4818 return err;
4819 }
Matt2f2f4252005-04-13 14:45:30 +02004820
4821 codec->patch_ops = stac92xx_patch_ops;
4822
Takashi Iwai52987652008-01-16 16:09:47 +01004823 /*
4824 * !!FIXME!!
4825 * The STAC927x seem to require fairly long delays for certain
4826 * command sequences. With too short delays (even if the answer
4827 * is set to RIRB properly), it results in the silence output
4828 * on some hardwares like Dell.
4829 *
4830 * The below flag enables the longer delay (see get_response
4831 * in hda_intel.c).
4832 */
4833 codec->bus->needs_damn_long_delay = 1;
4834
Matt2f2f4252005-04-13 14:45:30 +02004835 return 0;
4836}
4837
Matt Porterf3302a52006-07-31 12:49:34 +02004838static int patch_stac9205(struct hda_codec *codec)
4839{
4840 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004841 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004842
4843 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4844 if (spec == NULL)
4845 return -ENOMEM;
4846
4847 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004848 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004849 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004850 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4851 stac9205_models,
4852 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004853 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004854 if (spec->board_config < 0) {
4855 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4856 err = stac92xx_save_bios_config_regs(codec);
4857 if (err < 0) {
4858 stac92xx_free(codec);
4859 return err;
4860 }
4861 spec->pin_configs = spec->bios_pin_configs;
4862 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004863 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4864 stac92xx_set_config_regs(codec);
4865 }
4866
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004867 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004868 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004869 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004870 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004871 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004872 spec->smux_nids = stac9205_smux_nids;
4873 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004874 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004875 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004876 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004877 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004878 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004879
4880 spec->init = stac9205_core_init;
4881 spec->mixer = stac9205_mixer;
4882
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004883 spec->aloopback_mask = 0x40;
4884 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004885 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004886
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004887 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004888 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004889 /* Enable SPDIF in/out */
4890 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4891 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004892
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004893 /* Enable unsol response for GPIO4/Dock HP connection */
4894 snd_hda_codec_write(codec, codec->afg, 0,
4895 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4896 snd_hda_codec_write_cache(codec, codec->afg, 0,
4897 AC_VERB_SET_UNSOLICITED_ENABLE,
4898 (AC_USRSP_EN | STAC_HP_EVENT));
4899
4900 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004901 spec->eapd_mask = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004902 spec->gpio_mask = 0x1b;
4903 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004904 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004905 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004906 */
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004907 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004908 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004909 case STAC_9205_REF:
4910 /* SPDIF-In enabled */
4911 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004912 default:
4913 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004914 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004915 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004916 break;
4917 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004918
Matt Porterf3302a52006-07-31 12:49:34 +02004919 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004920 if (!err) {
4921 if (spec->board_config < 0) {
4922 printk(KERN_WARNING "hda_codec: No auto-config is "
4923 "available, default to model=ref\n");
4924 spec->board_config = STAC_9205_REF;
4925 goto again;
4926 }
4927 err = -EINVAL;
4928 }
Matt Porterf3302a52006-07-31 12:49:34 +02004929 if (err < 0) {
4930 stac92xx_free(codec);
4931 return err;
4932 }
4933
4934 codec->patch_ops = stac92xx_patch_ops;
4935
4936 return 0;
4937}
4938
Matt2f2f4252005-04-13 14:45:30 +02004939/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004940 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004941 */
4942
Guillaume Munch99ccc562006-08-16 19:35:12 +02004943/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004944static hda_nid_t vaio_dacs[] = { 0x2 };
4945#define VAIO_HP_DAC 0x5
4946static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4947static hda_nid_t vaio_mux_nids[] = { 0x15 };
4948
4949static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004950 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004951 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004952 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004953 { "Mic Jack", 0x1 },
4954 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004955 { "PCM", 0x3 },
4956 }
4957};
4958
4959static struct hda_verb vaio_init[] = {
4960 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004961 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004962 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4963 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4964 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004967 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4968 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4972 {}
4973};
4974
Guillaume Munch6d859062006-08-22 17:15:47 +02004975static struct hda_verb vaio_ar_init[] = {
4976 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4977 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4978 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4979 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4980/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004983 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4984 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4985/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4986 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4988 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4989 {}
4990};
4991
Takashi Iwaidb064e52006-03-16 16:04:58 +01004992/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004993static struct hda_bind_ctls vaio_bind_master_vol = {
4994 .ops = &snd_hda_bind_vol,
4995 .values = {
4996 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4997 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4998 0
4999 },
5000};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005001
5002/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005003static struct hda_bind_ctls vaio_bind_master_sw = {
5004 .ops = &snd_hda_bind_sw,
5005 .values = {
5006 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5007 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5008 0,
5009 },
5010};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005011
5012static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005013 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5014 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005015 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5016 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5017 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5018 {
5019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5020 .name = "Capture Source",
5021 .count = 1,
5022 .info = stac92xx_mux_enum_info,
5023 .get = stac92xx_mux_enum_get,
5024 .put = stac92xx_mux_enum_put,
5025 },
5026 {}
5027};
5028
Guillaume Munch6d859062006-08-22 17:15:47 +02005029static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005030 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5031 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02005032 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5033 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5034 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5035 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5036 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5037 {
5038 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5039 .name = "Capture Source",
5040 .count = 1,
5041 .info = stac92xx_mux_enum_info,
5042 .get = stac92xx_mux_enum_get,
5043 .put = stac92xx_mux_enum_put,
5044 },
5045 {}
5046};
5047
5048static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005049 .build_controls = stac92xx_build_controls,
5050 .build_pcms = stac92xx_build_pcms,
5051 .init = stac92xx_init,
5052 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005053#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005054 .resume = stac92xx_resume,
5055#endif
5056};
5057
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005058static int stac9872_vaio_init(struct hda_codec *codec)
5059{
5060 int err;
5061
5062 err = stac92xx_init(codec);
5063 if (err < 0)
5064 return err;
5065 if (codec->patch_ops.unsol_event)
5066 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5067 return 0;
5068}
5069
5070static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5071{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005072 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005073 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5074 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5075 } else {
5076 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5077 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5078 }
5079}
5080
5081static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5082{
5083 switch (res >> 26) {
5084 case STAC_HP_EVENT:
5085 stac9872_vaio_hp_detect(codec, res);
5086 break;
5087 }
5088}
5089
5090static struct hda_codec_ops stac9872_vaio_patch_ops = {
5091 .build_controls = stac92xx_build_controls,
5092 .build_pcms = stac92xx_build_pcms,
5093 .init = stac9872_vaio_init,
5094 .free = stac92xx_free,
5095 .unsol_event = stac9872_vaio_unsol_event,
5096#ifdef CONFIG_PM
5097 .resume = stac92xx_resume,
5098#endif
5099};
5100
Guillaume Munch6d859062006-08-22 17:15:47 +02005101enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5102 CXD9872RD_VAIO,
5103 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5104 STAC9872AK_VAIO,
5105 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5106 STAC9872K_VAIO,
5107 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005108 CXD9872AKD_VAIO,
5109 STAC_9872_MODELS,
5110};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005111
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005112static const char *stac9872_models[STAC_9872_MODELS] = {
5113 [CXD9872RD_VAIO] = "vaio",
5114 [CXD9872AKD_VAIO] = "vaio-ar",
5115};
5116
5117static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5118 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5119 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5120 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005121 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005122 {}
5123};
5124
Guillaume Munch6d859062006-08-22 17:15:47 +02005125static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005126{
5127 struct sigmatel_spec *spec;
5128 int board_config;
5129
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005130 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5131 stac9872_models,
5132 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005133 if (board_config < 0)
5134 /* unknown config, let generic-parser do its job... */
5135 return snd_hda_parse_generic_codec(codec);
5136
5137 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5138 if (spec == NULL)
5139 return -ENOMEM;
5140
5141 codec->spec = spec;
5142 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005143 case CXD9872RD_VAIO:
5144 case STAC9872AK_VAIO:
5145 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005146 spec->mixer = vaio_mixer;
5147 spec->init = vaio_init;
5148 spec->multiout.max_channels = 2;
5149 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5150 spec->multiout.dac_nids = vaio_dacs;
5151 spec->multiout.hp_nid = VAIO_HP_DAC;
5152 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5153 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005154 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005155 spec->input_mux = &vaio_mux;
5156 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005157 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005158 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005159
5160 case CXD9872AKD_VAIO:
5161 spec->mixer = vaio_ar_mixer;
5162 spec->init = vaio_ar_init;
5163 spec->multiout.max_channels = 2;
5164 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5165 spec->multiout.dac_nids = vaio_dacs;
5166 spec->multiout.hp_nid = VAIO_HP_DAC;
5167 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005168 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005169 spec->adc_nids = vaio_adcs;
5170 spec->input_mux = &vaio_mux;
5171 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005172 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005173 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005174 }
5175
Takashi Iwaidb064e52006-03-16 16:04:58 +01005176 return 0;
5177}
5178
5179
5180/*
Matt2f2f4252005-04-13 14:45:30 +02005181 * patch entries
5182 */
5183struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5184 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5185 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5186 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5187 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5188 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5189 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5190 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005191 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5192 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5193 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5194 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5195 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5196 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005197 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5198 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5199 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5200 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5201 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5202 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5203 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5204 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5205 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5206 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005207 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5208 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5209 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5210 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5211 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5212 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005213 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5214 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005215 /* The following does not take into account .id=0x83847661 when subsys =
5216 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5217 * currently not fully supported.
5218 */
5219 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5220 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5221 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005222 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5223 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5224 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5225 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5226 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5227 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5228 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5229 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005230 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005231 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5232 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005233 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005234 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5235 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005236 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005237 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5238 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5239 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5240 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5241 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5242 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5243 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5244 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005245 {} /* terminator */
5246};