blob: d6fa401791c59d6ab554bd5edd531daa32f48ea7 [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,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010073 STAC_DELL_M6_AMIC,
74 STAC_DELL_M6_DMIC,
75 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050076 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010077 STAC_92HD73XX_MODELS
78};
79
80enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020081 STAC_92HD83XXX_REF,
82 STAC_92HD83XXX_MODELS
83};
84
85enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010086 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010087 STAC_DELL_M4_1,
88 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050089 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040090 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010091 STAC_92HD71BXX_MODELS
92};
93
94enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010095 STAC_925x_REF,
96 STAC_M2_2,
97 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020098 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010099 STAC_925x_MODELS
100};
101
102enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100103 STAC_D945_REF,
104 STAC_D945GTP3,
105 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200106 STAC_INTEL_MAC_V1,
107 STAC_INTEL_MAC_V2,
108 STAC_INTEL_MAC_V3,
109 STAC_INTEL_MAC_V4,
110 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800111 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
112 * is given, one of the above models will be
113 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200114 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100115 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100116 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100117 STAC_MACBOOK_PRO_V1,
118 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200119 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200120 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300121 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200122 STAC_922X_DELL_D81,
123 STAC_922X_DELL_D82,
124 STAC_922X_DELL_M81,
125 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100126 STAC_922X_MODELS
127};
128
129enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100130 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100131 STAC_D965_REF,
132 STAC_D965_3ST,
133 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200134 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100135 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100136 STAC_927X_MODELS
137};
Matt Porter403d1942005-11-29 15:00:51 +0100138
Matt2f2f4252005-04-13 14:45:30 +0200139struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100140 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200141 unsigned int num_mixers;
142
Matt Porter403d1942005-11-29 15:00:51 +0100143 int board_config;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -0500144 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200145 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100146 unsigned int line_switch: 1;
147 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100148 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100149 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400150 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200151
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100152 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200153 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100154 unsigned int gpio_mask;
155 unsigned int gpio_dir;
156 unsigned int gpio_data;
157 unsigned int gpio_mute;
158
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200159 /* stream */
160 unsigned int stream_delay;
161
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100162 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100163 unsigned char aloopback_mask;
164 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200165
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100166 /* power management */
167 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200168 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100169 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100170 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100171
Matt2f2f4252005-04-13 14:45:30 +0200172 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100173 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400174 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100175 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200176 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100177 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200178
179 /* capture */
180 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200181 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200182 hda_nid_t *mux_nids;
183 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200184 hda_nid_t *dmic_nids;
185 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100186 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100187 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200188 hda_nid_t *smux_nids;
189 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400190 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200191
Mattdabbed62005-06-14 10:19:34 +0200192 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100193 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200194 hda_nid_t anabeep_nid;
195 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200196
Matt2f2f4252005-04-13 14:45:30 +0200197 /* pin widgets */
198 hda_nid_t *pin_nids;
199 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200200 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200201 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200202
203 /* codec specific stuff */
204 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100205 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200206
207 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200208 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100209 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200210 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100211 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200212 struct hda_input_mux *sinput_mux;
213 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400214 unsigned int cur_amux;
215 hda_nid_t *amp_nids;
216 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200217 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200218
Matt Porter403d1942005-11-29 15:00:51 +0100219 /* i/o switches */
220 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200221 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100222 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200223 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200224
Mattc7d4b2f2005-06-27 14:59:41 +0200225 struct hda_pcm pcm_rec[2]; /* PCM information */
226
227 /* dynamic controls and input_mux */
228 struct auto_pin_cfg autocfg;
229 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100230 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200231 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200232 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200233 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400234 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100235 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200236};
237
238static hda_nid_t stac9200_adc_nids[1] = {
239 0x03,
240};
241
242static hda_nid_t stac9200_mux_nids[1] = {
243 0x0c,
244};
245
246static hda_nid_t stac9200_dac_nids[1] = {
247 0x02,
248};
249
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100250static hda_nid_t stac92hd73xx_pwr_nids[8] = {
251 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
252 0x0f, 0x10, 0x11
253};
254
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400255static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
256 0x26, 0,
257};
258
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100259static hda_nid_t stac92hd73xx_adc_nids[2] = {
260 0x1a, 0x1b
261};
262
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400263#define DELL_M6_AMP 2
264static hda_nid_t stac92hd73xx_amp_nids[3] = {
265 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400266};
267
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100268#define STAC92HD73XX_NUM_DMICS 2
269static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
270 0x13, 0x14, 0
271};
272
273#define STAC92HD73_DAC_COUNT 5
274static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
275 0x15, 0x16, 0x17, 0x18, 0x19,
276};
277
278static hda_nid_t stac92hd73xx_mux_nids[4] = {
279 0x28, 0x29, 0x2a, 0x2b,
280};
281
282static hda_nid_t stac92hd73xx_dmux_nids[2] = {
283 0x20, 0x21,
284};
285
Matthew Ranostayd9737752008-09-07 12:03:41 +0200286static hda_nid_t stac92hd73xx_smux_nids[2] = {
287 0x22, 0x23,
288};
289
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200290#define STAC92HD83XXX_NUM_DMICS 2
291static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
292 0x11, 0x12, 0
293};
294
295#define STAC92HD81_DAC_COUNT 2
296#define STAC92HD83_DAC_COUNT 3
297static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
298 0x13, 0x14, 0x22,
299};
300
301static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
302 0x17, 0x18,
303};
304
305static hda_nid_t stac92hd83xxx_adc_nids[2] = {
306 0x15, 0x16,
307};
308
309static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
310 0xa, 0xb, 0xd, 0xe,
311};
312
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400313static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
314 0x1e, 0,
315};
316
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200317static unsigned int stac92hd83xxx_pwr_mapping[4] = {
318 0x03, 0x0c, 0x10, 0x40,
319};
320
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100321static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
322 0x0a, 0x0d, 0x0f
323};
324
Matthew Ranostaye035b842007-11-06 11:53:55 +0100325static hda_nid_t stac92hd71bxx_adc_nids[2] = {
326 0x12, 0x13,
327};
328
329static hda_nid_t stac92hd71bxx_mux_nids[2] = {
330 0x1a, 0x1b
331};
332
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400333static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
334 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100335};
336
Matthew Ranostayd9737752008-09-07 12:03:41 +0200337static hda_nid_t stac92hd71bxx_smux_nids[2] = {
338 0x24, 0x25,
339};
340
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100341static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100342 0x10, /*0x11, */
343};
344
345#define STAC92HD71BXX_NUM_DMICS 2
346static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
347 0x18, 0x19, 0
348};
349
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400350static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
351 0x22, 0
352};
353
Tobin Davis8e21c342007-01-08 11:04:17 +0100354static hda_nid_t stac925x_adc_nids[1] = {
355 0x03,
356};
357
358static hda_nid_t stac925x_mux_nids[1] = {
359 0x0f,
360};
361
362static hda_nid_t stac925x_dac_nids[1] = {
363 0x02,
364};
365
Takashi Iwaif6e98522007-10-16 14:27:04 +0200366#define STAC925X_NUM_DMICS 1
367static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
368 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200369};
370
Takashi Iwai1697055e2007-12-18 18:05:52 +0100371static hda_nid_t stac925x_dmux_nids[1] = {
372 0x14,
373};
374
Matt2f2f4252005-04-13 14:45:30 +0200375static hda_nid_t stac922x_adc_nids[2] = {
376 0x06, 0x07,
377};
378
379static hda_nid_t stac922x_mux_nids[2] = {
380 0x12, 0x13,
381};
382
Matt Porter3cc08dc2006-01-23 15:27:49 +0100383static hda_nid_t stac927x_adc_nids[3] = {
384 0x07, 0x08, 0x09
385};
386
387static hda_nid_t stac927x_mux_nids[3] = {
388 0x15, 0x16, 0x17
389};
390
Matthew Ranostayd9737752008-09-07 12:03:41 +0200391static hda_nid_t stac927x_smux_nids[1] = {
392 0x21,
393};
394
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100395static hda_nid_t stac927x_dac_nids[6] = {
396 0x02, 0x03, 0x04, 0x05, 0x06, 0
397};
398
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100399static hda_nid_t stac927x_dmux_nids[1] = {
400 0x1b,
401};
402
Matthew Ranostay7f168592007-10-18 17:38:17 +0200403#define STAC927X_NUM_DMICS 2
404static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
405 0x13, 0x14, 0
406};
407
Matthew Ranostay65973632008-09-16 10:39:37 -0400408static const char *stac927x_spdif_labels[5] = {
409 "Digital Playback", "ADAT", "Analog Mux 1",
410 "Analog Mux 2", "Analog Mux 3"
411};
412
Matt Porterf3302a52006-07-31 12:49:34 +0200413static hda_nid_t stac9205_adc_nids[2] = {
414 0x12, 0x13
415};
416
417static hda_nid_t stac9205_mux_nids[2] = {
418 0x19, 0x1a
419};
420
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100421static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100422 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100423};
424
Matthew Ranostayd9737752008-09-07 12:03:41 +0200425static hda_nid_t stac9205_smux_nids[1] = {
426 0x21,
427};
428
Takashi Iwaif6e98522007-10-16 14:27:04 +0200429#define STAC9205_NUM_DMICS 2
430static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
431 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200432};
433
Mattc7d4b2f2005-06-27 14:59:41 +0200434static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200435 0x08, 0x09, 0x0d, 0x0e,
436 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200437};
438
Tobin Davis8e21c342007-01-08 11:04:17 +0100439static hda_nid_t stac925x_pin_nids[8] = {
440 0x07, 0x08, 0x0a, 0x0b,
441 0x0c, 0x0d, 0x10, 0x11,
442};
443
Matt2f2f4252005-04-13 14:45:30 +0200444static hda_nid_t stac922x_pin_nids[10] = {
445 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
446 0x0f, 0x10, 0x11, 0x15, 0x1b,
447};
448
Matthew Ranostaya7662642008-02-21 07:51:14 +0100449static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100450 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
451 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200452 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100453};
454
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200455static hda_nid_t stac92hd83xxx_pin_nids[14] = {
456 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
457 0x0f, 0x10, 0x11, 0x12, 0x13,
458 0x1d, 0x1e, 0x1f, 0x20
459};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400460static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100461 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
462 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400463 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100464};
465
Matt Porter3cc08dc2006-01-23 15:27:49 +0100466static hda_nid_t stac927x_pin_nids[14] = {
467 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
468 0x0f, 0x10, 0x11, 0x12, 0x13,
469 0x14, 0x21, 0x22, 0x23,
470};
471
Matt Porterf3302a52006-07-31 12:49:34 +0200472static hda_nid_t stac9205_pin_nids[12] = {
473 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
474 0x0f, 0x14, 0x16, 0x17, 0x18,
475 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200476};
477
Matthew Ranostay89385032008-09-11 09:49:39 -0400478#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
479
480static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
481 struct snd_ctl_elem_value *ucontrol)
482{
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 struct sigmatel_spec *spec = codec->spec;
485 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
486
487 kcontrol->private_value ^= get_amp_nid(kcontrol);
488 kcontrol->private_value |= nid;
489
490 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
491}
492
493static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
494 struct snd_ctl_elem_value *ucontrol)
495{
496 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
497 struct sigmatel_spec *spec = codec->spec;
498 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
499
500 kcontrol->private_value ^= get_amp_nid(kcontrol);
501 kcontrol->private_value |= nid;
502
503 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
504}
505
Matt Porter8b657272006-10-26 17:12:59 +0200506static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_info *uinfo)
508{
509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
510 struct sigmatel_spec *spec = codec->spec;
511 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
512}
513
514static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
516{
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100519 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200520
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100521 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200522 return 0;
523}
524
525static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100530 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200531
532 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100533 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200534}
535
Matthew Ranostayd9737752008-09-07 12:03:41 +0200536static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_info *uinfo)
538{
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct sigmatel_spec *spec = codec->spec;
541 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
542}
543
544static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_value *ucontrol)
546{
547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
548 struct sigmatel_spec *spec = codec->spec;
549 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
550
551 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
552 return 0;
553}
554
555static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
557{
558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400560 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400562 int err, val;
563 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200564
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400565 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200566 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400567 if (err < 0)
568 return err;
569
570 if (spec->spdif_mute) {
571 if (smux_idx == 0)
572 nid = spec->multiout.dig_out_nid;
573 else
574 nid = codec->slave_dig_outs[smux_idx - 1];
575 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
576 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400577 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100578 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400579 /* un/mute SPDIF out */
580 snd_hda_codec_write_cache(codec, nid, 0,
581 AC_VERB_SET_AMP_GAIN_MUTE, val);
582 }
583 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200584}
585
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100586static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200587{
588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
589 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200590 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200591}
592
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100593static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200594{
595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
596 struct sigmatel_spec *spec = codec->spec;
597 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
598
599 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
600 return 0;
601}
602
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100603static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200604{
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
608
Mattc7d4b2f2005-06-27 14:59:41 +0200609 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200610 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
611}
612
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100613static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_info *uinfo)
615{
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
619}
620
621static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626
627 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
628 return 0;
629}
630
631static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
633{
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 struct sigmatel_spec *spec = codec->spec;
636
637 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
638 spec->mono_nid, &spec->cur_mmux);
639}
640
Matthew Ranostay89385032008-09-11 09:49:39 -0400641static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_info *uinfo)
643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
646 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
647}
648
649static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_value *ucontrol)
651{
652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
653 struct sigmatel_spec *spec = codec->spec;
654
655 ucontrol->value.enumerated.item[0] = spec->cur_amux;
656 return 0;
657}
658
659static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
661{
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 struct sigmatel_spec *spec = codec->spec;
664 struct snd_kcontrol *ctl =
665 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
666 if (!ctl)
667 return -EINVAL;
668
669 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
670 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
671
672 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
673 0, &spec->cur_amux);
674}
675
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200676#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
677
678static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
679 struct snd_ctl_elem_value *ucontrol)
680{
681 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100682 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200683 struct sigmatel_spec *spec = codec->spec;
684
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100685 ucontrol->value.integer.value[0] = !!(spec->aloopback &
686 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200687 return 0;
688}
689
690static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
691 struct snd_ctl_elem_value *ucontrol)
692{
693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
694 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100695 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200696 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100697 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200698
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100699 idx_val = spec->aloopback_mask << idx;
700 if (ucontrol->value.integer.value[0])
701 val = spec->aloopback | idx_val;
702 else
703 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100704 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200705 return 0;
706
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100707 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200708
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100709 /* Only return the bits defined by the shift value of the
710 * first two bytes of the mask
711 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200712 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713 kcontrol->private_value & 0xFFFF, 0x0);
714 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200715
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100716 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200717 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100718 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719 } else {
720 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100721 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200722 }
723
724 snd_hda_codec_write_cache(codec, codec->afg, 0,
725 kcontrol->private_value >> 16, dac_mode);
726
727 return 1;
728}
729
Mattc7d4b2f2005-06-27 14:59:41 +0200730static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200731 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200732 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200733 {}
734};
735
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200736static struct hda_verb stac9200_eapd_init[] = {
737 /* set dac0mux for dac converter */
738 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
739 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
740 {}
741};
742
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100743static struct hda_verb stac92hd73xx_6ch_core_init[] = {
744 /* set master volume and direct control */
745 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
746 /* setup audio connections */
747 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
748 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
749 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
750 /* setup adcs to point to mixer */
751 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
752 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100753 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
754 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
755 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
756 /* setup import muxs */
757 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
758 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
761 {}
762};
763
Matthew Ranostayd654a662008-03-14 08:46:51 +0100764static struct hda_verb dell_eq_core_init[] = {
765 /* set master volume to max value without distortion
766 * and direct control */
767 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
768 /* setup audio connections */
769 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400770 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
771 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100772 /* setup adcs to point to mixer */
773 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
774 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
775 /* setup import muxs */
776 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
777 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
779 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
780 {}
781};
782
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100783static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500784 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100785 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100786 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
787 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100788 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
789 /* setup adcs to point to mixer */
790 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
792 /* setup import muxs */
793 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
794 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
796 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
797 {}
798};
799
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100800static struct hda_verb stac92hd73xx_8ch_core_init[] = {
801 /* set master volume and direct control */
802 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
803 /* setup audio connections */
804 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
805 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
807 /* connect hp ports to dac3 */
808 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
809 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
810 /* setup adcs to point to mixer */
811 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
812 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100813 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
814 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
815 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
816 /* setup import muxs */
817 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
818 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
819 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
820 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
821 {}
822};
823
824static struct hda_verb stac92hd73xx_10ch_core_init[] = {
825 /* set master volume and direct control */
826 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
827 /* setup audio connections */
828 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
829 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
830 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
831 /* dac3 is connected to import3 mux */
832 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
833 /* connect hp ports to dac4 */
834 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
835 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
836 /* setup adcs to point to mixer */
837 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
838 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100839 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
841 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
842 /* setup import muxs */
843 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
845 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
846 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
847 {}
848};
849
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200850static struct hda_verb stac92hd83xxx_core_init[] = {
851 /* start of config #1 */
852 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
853
854 /* start of config #2 */
855 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
856 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
857 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
858
859 /* power state controls amps */
860 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
861};
862
Matthew Ranostaye035b842007-11-06 11:53:55 +0100863static struct hda_verb stac92hd71bxx_core_init[] = {
864 /* set master volume and direct control */
865 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
866 /* connect headphone jack to dac1 */
867 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100868 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
869 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
871 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100872};
873
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400874#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100875static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200876 /* start of config #1 */
877
878 /* connect port 0f to audio mixer */
879 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200880 /* unmute right and left channels for node 0x0f */
881 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
882 /* start of config #2 */
883
Matthew Ranostay541eee82007-12-14 12:08:04 +0100884 /* set master volume and direct control */
885 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
886 /* connect headphone jack to dac1 */
887 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200888 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100889 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
890 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100891 {}
892};
893
Tobin Davis8e21c342007-01-08 11:04:17 +0100894static struct hda_verb stac925x_core_init[] = {
895 /* set dac0mux for dac converter */
896 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
897 {}
898};
899
Mattc7d4b2f2005-06-27 14:59:41 +0200900static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200901 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200902 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200903 {}
904};
905
Tobin Davis93ed1502006-09-01 21:03:12 +0200906static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200907 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200908 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200909 /* unmute node 0x1b */
910 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
911 /* select node 0x03 as DAC */
912 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
913 {}
914};
915
Matt Porter3cc08dc2006-01-23 15:27:49 +0100916static struct hda_verb stac927x_core_init[] = {
917 /* set master volume and direct control */
918 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200919 /* enable analog pc beep path */
920 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100921 {}
922};
923
Matt Porterf3302a52006-07-31 12:49:34 +0200924static struct hda_verb stac9205_core_init[] = {
925 /* set master volume and direct control */
926 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200927 /* enable analog pc beep path */
928 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200929 {}
930};
931
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100932#define STAC_MONO_MUX \
933 { \
934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
935 .name = "Mono Mux", \
936 .count = 1, \
937 .info = stac92xx_mono_mux_enum_info, \
938 .get = stac92xx_mono_mux_enum_get, \
939 .put = stac92xx_mono_mux_enum_put, \
940 }
941
Matthew Ranostay89385032008-09-11 09:49:39 -0400942#define STAC_AMP_MUX \
943 { \
944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
945 .name = "Amp Selector Capture Switch", \
946 .count = 1, \
947 .info = stac92xx_amp_mux_enum_info, \
948 .get = stac92xx_amp_mux_enum_get, \
949 .put = stac92xx_amp_mux_enum_put, \
950 }
951
952#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
953 { \
954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
955 .name = xname, \
956 .index = 0, \
957 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
958 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
960 .info = stac92xx_amp_volume_info, \
961 .get = stac92xx_amp_volume_get, \
962 .put = stac92xx_amp_volume_put, \
963 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
964 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
965 }
966
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200967#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200968 { \
969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
970 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200971 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200972 .info = stac92xx_mux_enum_info, \
973 .get = stac92xx_mux_enum_get, \
974 .put = stac92xx_mux_enum_put, \
975 }
976
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100977#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200978 { \
979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
980 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100981 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200982 .info = stac92xx_aloopback_info, \
983 .get = stac92xx_aloopback_get, \
984 .put = stac92xx_aloopback_put, \
985 .private_value = verb_read | (verb_write << 16), \
986 }
987
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100988static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200989 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
990 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200991 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200992 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200994 { } /* end */
995};
996
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400997#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100998static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400999 /* start of config #1 */
1000 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1001 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1002
1003 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1004 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1005
1006 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1007 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1008
1009 /* start of config #2 */
1010 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1011 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1012
1013 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1014 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1015
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001016 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1017
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001018 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1019 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020
1021 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001024 { } /* end */
1025};
1026
1027static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1029
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001030 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032
1033 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035
1036 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1037 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1038
1039 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1040 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1041
1042 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1043 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1044
1045 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1046 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1047
1048 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1049 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1050 { } /* end */
1051};
1052
1053static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001054 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1055
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001056 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058
1059 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061
1062 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1063 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1064
1065 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1066 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1069 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1070
1071 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1072 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1073
1074 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1075 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1076 { } /* end */
1077};
1078
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001079
1080static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086
1087 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1088 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1089
1090 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1091 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1092
1093 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1094 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1095
1096 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1097 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1098
1099 /*
1100 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1101 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1102 */
1103 { } /* end */
1104};
1105
Matthew Ranostay541eee82007-12-14 12:08:04 +01001106static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001107 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001108 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001109
Matthew Ranostay9b359472007-11-07 13:03:12 +01001110 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001112
1113 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001115 /* analog pc-beep replaced with digital beep support */
1116 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001117 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1118 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001119 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001120
Matthew Ranostay687cb982008-10-11 13:52:43 -04001121 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1122 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001123
Matthew Ranostay687cb982008-10-11 13:52:43 -04001124 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1125 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001126
1127 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1128 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1129
1130 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1131 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001132 { } /* end */
1133};
1134
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001136 STAC_INPUT_SOURCE(2),
1137 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1138
Matthew Ranostay541eee82007-12-14 12:08:04 +01001139 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001141
1142 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001144 { } /* end */
1145};
1146
Tobin Davis8e21c342007-01-08 11:04:17 +01001147static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001148 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001149 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001150 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001151 { } /* end */
1152};
1153
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001154static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001156 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001157
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001163 { } /* end */
1164};
1165
1166/* This needs to be generated dynamically based on sequence */
1167static struct snd_kcontrol_new stac922x_mixer[] = {
1168 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001169 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001171
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001174 { } /* end */
1175};
1176
1177
1178static struct snd_kcontrol_new stac927x_mixer[] = {
1179 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001180 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001181
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001184
1185 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001187
1188 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1189 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001190 { } /* end */
1191};
1192
Takashi Iwai1697055e2007-12-18 18:05:52 +01001193static struct snd_kcontrol_new stac_dmux_mixer = {
1194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1195 .name = "Digital Input Source",
1196 /* count set later */
1197 .info = stac92xx_dmux_enum_info,
1198 .get = stac92xx_dmux_enum_get,
1199 .put = stac92xx_dmux_enum_put,
1200};
1201
Matthew Ranostayd9737752008-09-07 12:03:41 +02001202static struct snd_kcontrol_new stac_smux_mixer = {
1203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001204 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001205 /* count set later */
1206 .info = stac92xx_smux_enum_info,
1207 .get = stac92xx_smux_enum_get,
1208 .put = stac92xx_smux_enum_put,
1209};
1210
Takashi Iwai2134ea42008-01-10 16:53:55 +01001211static const char *slave_vols[] = {
1212 "Front Playback Volume",
1213 "Surround Playback Volume",
1214 "Center Playback Volume",
1215 "LFE Playback Volume",
1216 "Side Playback Volume",
1217 "Headphone Playback Volume",
1218 "Headphone Playback Volume",
1219 "Speaker Playback Volume",
1220 "External Speaker Playback Volume",
1221 "Speaker2 Playback Volume",
1222 NULL
1223};
1224
1225static const char *slave_sws[] = {
1226 "Front Playback Switch",
1227 "Surround Playback Switch",
1228 "Center Playback Switch",
1229 "LFE Playback Switch",
1230 "Side Playback Switch",
1231 "Headphone Playback Switch",
1232 "Headphone Playback Switch",
1233 "Speaker Playback Switch",
1234 "External Speaker Playback Switch",
1235 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001236 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001237 NULL
1238};
1239
Matt2f2f4252005-04-13 14:45:30 +02001240static int stac92xx_build_controls(struct hda_codec *codec)
1241{
1242 struct sigmatel_spec *spec = codec->spec;
1243 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001244 int i;
Matt2f2f4252005-04-13 14:45:30 +02001245
1246 err = snd_hda_add_new_ctls(codec, spec->mixer);
1247 if (err < 0)
1248 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001249
1250 for (i = 0; i < spec->num_mixers; i++) {
1251 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1252 if (err < 0)
1253 return err;
1254 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001255 if (spec->num_dmuxes > 0) {
1256 stac_dmux_mixer.count = spec->num_dmuxes;
1257 err = snd_ctl_add(codec->bus->card,
1258 snd_ctl_new1(&stac_dmux_mixer, codec));
1259 if (err < 0)
1260 return err;
1261 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001262 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001263 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1264 struct hda_input_mux *smux = &spec->private_smux;
1265 /* check for mute support on SPDIF out */
1266 if (wcaps & AC_WCAP_OUT_AMP) {
1267 smux->items[smux->num_items].label = "Off";
1268 smux->items[smux->num_items].index = 0;
1269 smux->num_items++;
1270 spec->spdif_mute = 1;
1271 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001272 stac_smux_mixer.count = spec->num_smuxes;
1273 err = snd_ctl_add(codec->bus->card,
1274 snd_ctl_new1(&stac_smux_mixer, codec));
1275 if (err < 0)
1276 return err;
1277 }
Mattc7d4b2f2005-06-27 14:59:41 +02001278
Mattdabbed62005-06-14 10:19:34 +02001279 if (spec->multiout.dig_out_nid) {
1280 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1281 if (err < 0)
1282 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001283 err = snd_hda_create_spdif_share_sw(codec,
1284 &spec->multiout);
1285 if (err < 0)
1286 return err;
1287 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001288 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001289 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001290 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1291 if (err < 0)
1292 return err;
1293 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001294
1295 /* if we have no master control, let's create it */
1296 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001297 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001298 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001299 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001300 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001301 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001302 if (err < 0)
1303 return err;
1304 }
1305 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1306 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1307 NULL, slave_sws);
1308 if (err < 0)
1309 return err;
1310 }
1311
Mattdabbed62005-06-14 10:19:34 +02001312 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001313}
1314
Matt Porter403d1942005-11-29 15:00:51 +01001315static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001316 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001317 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1318};
1319
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001320/*
1321 STAC 9200 pin configs for
1322 102801A8
1323 102801DE
1324 102801E8
1325*/
1326static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001327 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1328 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001329};
1330
1331/*
1332 STAC 9200 pin configs for
1333 102801C0
1334 102801C1
1335*/
1336static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001337 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1338 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001339};
1340
1341/*
1342 STAC 9200 pin configs for
1343 102801C4 (Dell Dimension E310)
1344 102801C5
1345 102801C7
1346 102801D9
1347 102801DA
1348 102801E3
1349*/
1350static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001351 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1352 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001353};
1354
1355
1356/*
1357 STAC 9200-32 pin configs for
1358 102801B5 (Dell Inspiron 630m)
1359 102801D8 (Dell Inspiron 640m)
1360*/
1361static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001362 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1363 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364};
1365
1366/*
1367 STAC 9200-32 pin configs for
1368 102801C2 (Dell Latitude D620)
1369 102801C8
1370 102801CC (Dell Latitude D820)
1371 102801D4
1372 102801D6
1373*/
1374static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001375 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1376 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001377};
1378
1379/*
1380 STAC 9200-32 pin configs for
1381 102801CE (Dell XPS M1710)
1382 102801CF (Dell Precision M90)
1383*/
1384static unsigned int dell9200_m23_pin_configs[8] = {
1385 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1386 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1387};
1388
1389/*
1390 STAC 9200-32 pin configs for
1391 102801C9
1392 102801CA
1393 102801CB (Dell Latitude 120L)
1394 102801D3
1395*/
1396static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001397 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1398 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399};
1400
1401/*
1402 STAC 9200-32 pin configs for
1403 102801BD (Dell Inspiron E1505n)
1404 102801EE
1405 102801EF
1406*/
1407static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001408 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1409 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001410};
1411
1412/*
1413 STAC 9200-32 pin configs for
1414 102801F5 (Dell Inspiron 1501)
1415 102801F6
1416*/
1417static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001418 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1419 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001420};
1421
1422/*
1423 STAC 9200-32
1424 102801CD (Dell Inspiron E1705/9400)
1425*/
1426static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001427 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1428 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001429};
1430
Tobin Davisbf277782008-02-03 20:31:47 +01001431static unsigned int oqo9200_pin_configs[8] = {
1432 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1433 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1434};
1435
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001436
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001437static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1438 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001439 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001440 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1441 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1442 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1443 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1444 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1445 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1446 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1447 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1448 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1449 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001450 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001451};
1452
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001453static const char *stac9200_models[STAC_9200_MODELS] = {
1454 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001455 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001456 [STAC_9200_DELL_D21] = "dell-d21",
1457 [STAC_9200_DELL_D22] = "dell-d22",
1458 [STAC_9200_DELL_D23] = "dell-d23",
1459 [STAC_9200_DELL_M21] = "dell-m21",
1460 [STAC_9200_DELL_M22] = "dell-m22",
1461 [STAC_9200_DELL_M23] = "dell-m23",
1462 [STAC_9200_DELL_M24] = "dell-m24",
1463 [STAC_9200_DELL_M25] = "dell-m25",
1464 [STAC_9200_DELL_M26] = "dell-m26",
1465 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001466 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001467 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001468};
1469
1470static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1471 /* SigmaTel reference board */
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1473 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001474 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1476 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001478 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1480 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1482 "unknown Dell", STAC_9200_DELL_D22),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1484 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001486 "Dell Latitude D620", STAC_9200_DELL_M22),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1488 "unknown Dell", STAC_9200_DELL_D23),
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1490 "unknown Dell", STAC_9200_DELL_D23),
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1492 "unknown Dell", STAC_9200_DELL_M22),
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1494 "unknown Dell", STAC_9200_DELL_M24),
1495 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1496 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001497 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001498 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001499 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001500 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001501 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001502 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001503 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001504 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001506 "Dell Precision M90", STAC_9200_DELL_M23),
1507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1508 "unknown Dell", STAC_9200_DELL_M22),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1510 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001512 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001514 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1516 "unknown Dell", STAC_9200_DELL_D23),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1518 "unknown Dell", STAC_9200_DELL_D23),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1520 "unknown Dell", STAC_9200_DELL_D21),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1522 "unknown Dell", STAC_9200_DELL_D23),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1524 "unknown Dell", STAC_9200_DELL_D21),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1526 "unknown Dell", STAC_9200_DELL_M25),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1528 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001530 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1532 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001533 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001534 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001535 /* Gateway machines needs EAPD to be set on resume */
1536 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1537 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1538 STAC_9200_GATEWAY),
1539 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1540 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001541 /* OQO Mobile */
1542 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001543 {} /* terminator */
1544};
1545
Tobin Davis8e21c342007-01-08 11:04:17 +01001546static unsigned int ref925x_pin_configs[8] = {
1547 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001548 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001549};
1550
1551static unsigned int stac925x_MA6_pin_configs[8] = {
1552 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1553 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1554};
1555
Tobin Davis2c11f952007-05-17 09:36:34 +02001556static unsigned int stac925x_PA6_pin_configs[8] = {
1557 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1558 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1559};
1560
Tobin Davis8e21c342007-01-08 11:04:17 +01001561static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001562 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1563 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001564};
1565
1566static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1567 [STAC_REF] = ref925x_pin_configs,
1568 [STAC_M2_2] = stac925xM2_2_pin_configs,
1569 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001570 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001571};
1572
1573static const char *stac925x_models[STAC_925x_MODELS] = {
1574 [STAC_REF] = "ref",
1575 [STAC_M2_2] = "m2-2",
1576 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001577 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001578};
1579
1580static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1581 /* SigmaTel reference board */
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001583 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001584 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1585 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1586 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001587 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001588 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1589 {} /* terminator */
1590};
1591
Matthew Ranostaya7662642008-02-21 07:51:14 +01001592static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001593 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1594 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1595 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001596 0x01452050,
1597};
1598
1599static unsigned int dell_m6_pin_configs[13] = {
1600 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001601 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001602 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1603 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001604};
1605
1606static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001607 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001608 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1609 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1610 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001611 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001612};
1613
1614static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1615 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001616 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1617 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1618 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001619 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001620};
1621
1622static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1623 /* SigmaTel reference board */
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001625 "DFI LanParty", STAC_92HD73XX_REF),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001627 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001629 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001631 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001633 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001635 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001637 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001639 "unknown Dell", STAC_DELL_M6_DMIC),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1641 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001643 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001644 {} /* terminator */
1645};
1646
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001647static unsigned int ref92hd83xxx_pin_configs[14] = {
1648 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1649 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1650 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1651 0x01451160, 0x98560170,
1652};
1653
1654static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1655 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1656};
1657
1658static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1659 [STAC_92HD83XXX_REF] = "ref",
1660};
1661
1662static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1663 /* SigmaTel reference board */
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1665 "DFI LanParty", STAC_92HD71BXX_REF),
1666};
1667
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001668static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001669 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001670 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001671 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001672};
1673
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001674static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001675 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001676 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001677 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001678};
1679
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001680static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001681 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1682 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001683 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001684};
1685
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001686static unsigned int dell_m4_3_pin_configs[11] = {
1687 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1688 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1689 0x40f000f0, 0x044413b0, 0x044413b0,
1690};
1691
Matthew Ranostaye035b842007-11-06 11:53:55 +01001692static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1693 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001694 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1695 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001696 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001697 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001698};
1699
1700static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1701 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001702 [STAC_DELL_M4_1] = "dell-m4-1",
1703 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001704 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001705 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001706};
1707
1708static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1709 /* SigmaTel reference board */
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1711 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1713 "HP dv5", STAC_HP_M4),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1715 "HP dv7", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1717 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1719 "unknown Dell", STAC_DELL_M4_1),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1721 "unknown Dell", STAC_DELL_M4_1),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1723 "unknown Dell", STAC_DELL_M4_1),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1725 "unknown Dell", STAC_DELL_M4_1),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1727 "unknown Dell", STAC_DELL_M4_1),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1729 "unknown Dell", STAC_DELL_M4_1),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1731 "unknown Dell", STAC_DELL_M4_1),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1733 "unknown Dell", STAC_DELL_M4_2),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1735 "unknown Dell", STAC_DELL_M4_2),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1737 "unknown Dell", STAC_DELL_M4_2),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1739 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001740 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1741 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001742 {} /* terminator */
1743};
1744
Matt Porter403d1942005-11-29 15:00:51 +01001745static unsigned int ref922x_pin_configs[10] = {
1746 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1747 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001748 0x40000100, 0x40000100,
1749};
1750
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001751/*
1752 STAC 922X pin configs for
1753 102801A7
1754 102801AB
1755 102801A9
1756 102801D1
1757 102801D2
1758*/
1759static unsigned int dell_922x_d81_pin_configs[10] = {
1760 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1761 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1762 0x01813122, 0x400001f2,
1763};
1764
1765/*
1766 STAC 922X pin configs for
1767 102801AC
1768 102801D0
1769*/
1770static unsigned int dell_922x_d82_pin_configs[10] = {
1771 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1772 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1773 0x01813122, 0x400001f1,
1774};
1775
1776/*
1777 STAC 922X pin configs for
1778 102801BF
1779*/
1780static unsigned int dell_922x_m81_pin_configs[10] = {
1781 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1782 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1783 0x40C003f1, 0x405003f0,
1784};
1785
1786/*
1787 STAC 9221 A1 pin configs for
1788 102801D7 (Dell XPS M1210)
1789*/
1790static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001791 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1792 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001793 0x508003f3, 0x405003f4,
1794};
1795
Matt Porter403d1942005-11-29 15:00:51 +01001796static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001797 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001798 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1799 0x02a19120, 0x40000100,
1800};
1801
1802static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001803 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1804 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001805 0x02a19320, 0x40000100,
1806};
1807
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001808static unsigned int intel_mac_v1_pin_configs[10] = {
1809 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1810 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001811 0x400000fc, 0x400000fb,
1812};
1813
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001814static unsigned int intel_mac_v2_pin_configs[10] = {
1815 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1816 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001817 0x400000fc, 0x400000fb,
1818};
1819
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001820static unsigned int intel_mac_v3_pin_configs[10] = {
1821 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1822 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1823 0x400000fc, 0x400000fb,
1824};
1825
1826static unsigned int intel_mac_v4_pin_configs[10] = {
1827 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1828 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1829 0x400000fc, 0x400000fb,
1830};
1831
1832static unsigned int intel_mac_v5_pin_configs[10] = {
1833 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1834 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1835 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001836};
1837
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001838static unsigned int ecs202_pin_configs[10] = {
1839 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1840 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1841 0x9037012e, 0x40e000f2,
1842};
Takashi Iwai76c08822007-06-19 12:17:42 +02001843
Takashi Iwai19039bd2006-06-28 15:52:16 +02001844static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001845 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001846 [STAC_D945GTP3] = d945gtp3_pin_configs,
1847 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001848 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1849 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1850 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1851 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1852 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001853 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001854 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001855 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1856 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1857 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1858 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1859 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1860 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001861 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001862 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1863 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1864 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1865 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001866};
1867
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001868static const char *stac922x_models[STAC_922X_MODELS] = {
1869 [STAC_D945_REF] = "ref",
1870 [STAC_D945GTP5] = "5stack",
1871 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001872 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1873 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1874 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1875 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1876 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001877 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001878 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001879 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001880 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001881 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1882 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001883 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001884 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001885 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001886 [STAC_922X_DELL_D81] = "dell-d81",
1887 [STAC_922X_DELL_D82] = "dell-d82",
1888 [STAC_922X_DELL_M81] = "dell-m81",
1889 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001890};
1891
1892static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1893 /* SigmaTel reference board */
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1895 "DFI LanParty", STAC_D945_REF),
1896 /* Intel 945G based systems */
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1898 "Intel D945G", STAC_D945GTP3),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1900 "Intel D945G", STAC_D945GTP3),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1902 "Intel D945G", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1904 "Intel D945G", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1906 "Intel D945G", STAC_D945GTP3),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1908 "Intel D945G", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1910 "Intel D945G", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1912 "Intel D945G", STAC_D945GTP3),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1914 "Intel D945G", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1916 "Intel D945G", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1918 "Intel D945G", STAC_D945GTP3),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1920 "Intel D945G", STAC_D945GTP3),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1922 "Intel D945G", STAC_D945GTP3),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1924 "Intel D945G", STAC_D945GTP3),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1926 "Intel D945G", STAC_D945GTP3),
1927 /* Intel D945G 5-stack systems */
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1929 "Intel D945G", STAC_D945GTP5),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1931 "Intel D945G", STAC_D945GTP5),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1933 "Intel D945G", STAC_D945GTP5),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1935 "Intel D945G", STAC_D945GTP5),
1936 /* Intel 945P based systems */
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1938 "Intel D945P", STAC_D945GTP3),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1940 "Intel D945P", STAC_D945GTP3),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1942 "Intel D945P", STAC_D945GTP3),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1944 "Intel D945P", STAC_D945GTP3),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1946 "Intel D945P", STAC_D945GTP3),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1948 "Intel D945P", STAC_D945GTP5),
1949 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001950 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001951 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001952 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001953 /* Dell systems */
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1955 "unknown Dell", STAC_922X_DELL_D81),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1957 "unknown Dell", STAC_922X_DELL_D81),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1959 "unknown Dell", STAC_922X_DELL_D81),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1961 "unknown Dell", STAC_922X_DELL_D82),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1963 "unknown Dell", STAC_922X_DELL_M81),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1965 "unknown Dell", STAC_922X_DELL_D82),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1967 "unknown Dell", STAC_922X_DELL_D81),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1969 "unknown Dell", STAC_922X_DELL_D81),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1971 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001972 /* ECS/PC Chips boards */
1973 SND_PCI_QUIRK(0x1019, 0x2144,
1974 "ECS/PC chips", STAC_ECS_202),
1975 SND_PCI_QUIRK(0x1019, 0x2608,
1976 "ECS/PC chips", STAC_ECS_202),
1977 SND_PCI_QUIRK(0x1019, 0x2633,
1978 "ECS/PC chips P17G/1333", STAC_ECS_202),
1979 SND_PCI_QUIRK(0x1019, 0x2811,
1980 "ECS/PC chips", STAC_ECS_202),
1981 SND_PCI_QUIRK(0x1019, 0x2812,
1982 "ECS/PC chips", STAC_ECS_202),
1983 SND_PCI_QUIRK(0x1019, 0x2813,
1984 "ECS/PC chips", STAC_ECS_202),
1985 SND_PCI_QUIRK(0x1019, 0x2814,
1986 "ECS/PC chips", STAC_ECS_202),
1987 SND_PCI_QUIRK(0x1019, 0x2815,
1988 "ECS/PC chips", STAC_ECS_202),
1989 SND_PCI_QUIRK(0x1019, 0x2816,
1990 "ECS/PC chips", STAC_ECS_202),
1991 SND_PCI_QUIRK(0x1019, 0x2817,
1992 "ECS/PC chips", STAC_ECS_202),
1993 SND_PCI_QUIRK(0x1019, 0x2818,
1994 "ECS/PC chips", STAC_ECS_202),
1995 SND_PCI_QUIRK(0x1019, 0x2819,
1996 "ECS/PC chips", STAC_ECS_202),
1997 SND_PCI_QUIRK(0x1019, 0x2820,
1998 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001999 {} /* terminator */
2000};
2001
Matt Porter3cc08dc2006-01-23 15:27:49 +01002002static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002003 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2004 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2005 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2006 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002007};
2008
Tobin Davis93ed1502006-09-01 21:03:12 +02002009static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002010 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2011 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2012 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2013 0x40000100, 0x40000100
2014};
2015
Tobin Davis93ed1502006-09-01 21:03:12 +02002016static unsigned int d965_5st_pin_configs[14] = {
2017 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2018 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2019 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2020 0x40000100, 0x40000100
2021};
2022
Tobin Davis4ff076e2007-08-07 11:48:12 +02002023static unsigned int dell_3st_pin_configs[14] = {
2024 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2025 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002026 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002027 0x40c003fc, 0x40000100
2028};
2029
Tobin Davis93ed1502006-09-01 21:03:12 +02002030static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002031 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002032 [STAC_D965_REF] = ref927x_pin_configs,
2033 [STAC_D965_3ST] = d965_3st_pin_configs,
2034 [STAC_D965_5ST] = d965_5st_pin_configs,
2035 [STAC_DELL_3ST] = dell_3st_pin_configs,
2036 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002037};
2038
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002039static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002040 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002041 [STAC_D965_REF] = "ref",
2042 [STAC_D965_3ST] = "3stack",
2043 [STAC_D965_5ST] = "5stack",
2044 [STAC_DELL_3ST] = "dell-3stack",
2045 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002046};
2047
2048static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2049 /* SigmaTel reference board */
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2051 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002052 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002055 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002072 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002077 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002086 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002096 {} /* terminator */
2097};
2098
Matt Porterf3302a52006-07-31 12:49:34 +02002099static unsigned int ref9205_pin_configs[12] = {
2100 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002101 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002102 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002103};
2104
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002105/*
2106 STAC 9205 pin configs for
2107 102801F1
2108 102801F2
2109 102801FC
2110 102801FD
2111 10280204
2112 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002113 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002114*/
2115static unsigned int dell_9205_m42_pin_configs[12] = {
2116 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2117 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2118 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2119};
2120
2121/*
2122 STAC 9205 pin configs for
2123 102801F9
2124 102801FA
2125 102801FE
2126 102801FF (Dell Precision M4300)
2127 10280206
2128 10280200
2129 10280201
2130*/
2131static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002132 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2133 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2134 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2135};
2136
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002137static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002138 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2139 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2140 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2141};
2142
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002143static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002144 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002145 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2146 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2147 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002148};
2149
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150static const char *stac9205_models[STAC_9205_MODELS] = {
2151 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002152 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002153 [STAC_9205_DELL_M43] = "dell-m43",
2154 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002155};
2156
2157static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2158 /* SigmaTel reference board */
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2160 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2162 "unknown Dell", STAC_9205_DELL_M42),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2164 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002166 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2168 "Dell Precision", STAC_9205_DELL_M43),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2170 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2172 "unknown Dell", STAC_9205_DELL_M42),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2174 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2176 "Dell Precision", STAC_9205_DELL_M43),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002178 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2180 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2182 "Dell Precision", STAC_9205_DELL_M43),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2184 "Dell Precision", STAC_9205_DELL_M43),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2186 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002187 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2188 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2190 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002191 {} /* terminator */
2192};
2193
Richard Fish11b44bb2006-08-23 18:31:34 +02002194static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2195{
2196 int i;
2197 struct sigmatel_spec *spec = codec->spec;
2198
2199 if (! spec->bios_pin_configs) {
2200 spec->bios_pin_configs = kcalloc(spec->num_pins,
2201 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2202 if (! spec->bios_pin_configs)
2203 return -ENOMEM;
2204 }
2205
2206 for (i = 0; i < spec->num_pins; i++) {
2207 hda_nid_t nid = spec->pin_nids[i];
2208 unsigned int pin_cfg;
2209
2210 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2211 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2212 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2213 nid, pin_cfg);
2214 spec->bios_pin_configs[i] = pin_cfg;
2215 }
2216
2217 return 0;
2218}
2219
Matthew Ranostay87d48362007-07-17 11:52:24 +02002220static void stac92xx_set_config_reg(struct hda_codec *codec,
2221 hda_nid_t pin_nid, unsigned int pin_config)
2222{
2223 int i;
2224 snd_hda_codec_write(codec, pin_nid, 0,
2225 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2226 pin_config & 0x000000ff);
2227 snd_hda_codec_write(codec, pin_nid, 0,
2228 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2229 (pin_config & 0x0000ff00) >> 8);
2230 snd_hda_codec_write(codec, pin_nid, 0,
2231 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2232 (pin_config & 0x00ff0000) >> 16);
2233 snd_hda_codec_write(codec, pin_nid, 0,
2234 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2235 pin_config >> 24);
2236 i = snd_hda_codec_read(codec, pin_nid, 0,
2237 AC_VERB_GET_CONFIG_DEFAULT,
2238 0x00);
2239 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2240 pin_nid, i);
2241}
2242
Matt2f2f4252005-04-13 14:45:30 +02002243static void stac92xx_set_config_regs(struct hda_codec *codec)
2244{
2245 int i;
2246 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002247
Matthew Ranostay87d48362007-07-17 11:52:24 +02002248 if (!spec->pin_configs)
2249 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002250
Matthew Ranostay87d48362007-07-17 11:52:24 +02002251 for (i = 0; i < spec->num_pins; i++)
2252 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2253 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002254}
Matt2f2f4252005-04-13 14:45:30 +02002255
Matt2f2f4252005-04-13 14:45:30 +02002256/*
2257 * Analog playback callbacks
2258 */
2259static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002261 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002262{
2263 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002264 if (spec->stream_delay)
2265 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002266 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2267 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002268}
2269
2270static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2271 struct hda_codec *codec,
2272 unsigned int stream_tag,
2273 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002274 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002275{
2276 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002277 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002278}
2279
2280static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2281 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002282 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002283{
2284 struct sigmatel_spec *spec = codec->spec;
2285 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2286}
2287
2288/*
Mattdabbed62005-06-14 10:19:34 +02002289 * Digital playback callbacks
2290 */
2291static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2292 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002293 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002294{
2295 struct sigmatel_spec *spec = codec->spec;
2296 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2297}
2298
2299static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2300 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002301 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002302{
2303 struct sigmatel_spec *spec = codec->spec;
2304 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2305}
2306
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002307static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2308 struct hda_codec *codec,
2309 unsigned int stream_tag,
2310 unsigned int format,
2311 struct snd_pcm_substream *substream)
2312{
2313 struct sigmatel_spec *spec = codec->spec;
2314 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2315 stream_tag, format, substream);
2316}
2317
Mattdabbed62005-06-14 10:19:34 +02002318
2319/*
Matt2f2f4252005-04-13 14:45:30 +02002320 * Analog capture callbacks
2321 */
2322static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2323 struct hda_codec *codec,
2324 unsigned int stream_tag,
2325 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002326 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002327{
2328 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002329 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002330
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002331 if (spec->powerdown_adcs) {
2332 msleep(40);
2333 snd_hda_codec_write_cache(codec, nid, 0,
2334 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2335 }
2336 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002337 return 0;
2338}
2339
2340static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002342 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002343{
2344 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002345 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002346
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002347 snd_hda_codec_cleanup_stream(codec, nid);
2348 if (spec->powerdown_adcs)
2349 snd_hda_codec_write_cache(codec, nid, 0,
2350 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002351 return 0;
2352}
2353
Mattdabbed62005-06-14 10:19:34 +02002354static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2355 .substreams = 1,
2356 .channels_min = 2,
2357 .channels_max = 2,
2358 /* NID is set in stac92xx_build_pcms */
2359 .ops = {
2360 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002361 .close = stac92xx_dig_playback_pcm_close,
2362 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002363 },
2364};
2365
2366static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2367 .substreams = 1,
2368 .channels_min = 2,
2369 .channels_max = 2,
2370 /* NID is set in stac92xx_build_pcms */
2371};
2372
Matt2f2f4252005-04-13 14:45:30 +02002373static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2374 .substreams = 1,
2375 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002376 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002377 .nid = 0x02, /* NID to query formats and rates */
2378 .ops = {
2379 .open = stac92xx_playback_pcm_open,
2380 .prepare = stac92xx_playback_pcm_prepare,
2381 .cleanup = stac92xx_playback_pcm_cleanup
2382 },
2383};
2384
Matt Porter3cc08dc2006-01-23 15:27:49 +01002385static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2386 .substreams = 1,
2387 .channels_min = 2,
2388 .channels_max = 2,
2389 .nid = 0x06, /* NID to query formats and rates */
2390 .ops = {
2391 .open = stac92xx_playback_pcm_open,
2392 .prepare = stac92xx_playback_pcm_prepare,
2393 .cleanup = stac92xx_playback_pcm_cleanup
2394 },
2395};
2396
Matt2f2f4252005-04-13 14:45:30 +02002397static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002398 .channels_min = 2,
2399 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002400 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002401 .ops = {
2402 .prepare = stac92xx_capture_pcm_prepare,
2403 .cleanup = stac92xx_capture_pcm_cleanup
2404 },
2405};
2406
2407static int stac92xx_build_pcms(struct hda_codec *codec)
2408{
2409 struct sigmatel_spec *spec = codec->spec;
2410 struct hda_pcm *info = spec->pcm_rec;
2411
2412 codec->num_pcms = 1;
2413 codec->pcm_info = info;
2414
Mattc7d4b2f2005-06-27 14:59:41 +02002415 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002416 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002417 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002418 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002419 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002420
2421 if (spec->alt_switch) {
2422 codec->num_pcms++;
2423 info++;
2424 info->name = "STAC92xx Analog Alt";
2425 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2426 }
Matt2f2f4252005-04-13 14:45:30 +02002427
Mattdabbed62005-06-14 10:19:34 +02002428 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2429 codec->num_pcms++;
2430 info++;
2431 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002432 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002433 if (spec->multiout.dig_out_nid) {
2434 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2435 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2436 }
2437 if (spec->dig_in_nid) {
2438 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2439 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2440 }
2441 }
2442
Matt2f2f4252005-04-13 14:45:30 +02002443 return 0;
2444}
2445
Takashi Iwaic960a032006-03-23 17:06:28 +01002446static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2447{
2448 unsigned int pincap = snd_hda_param_read(codec, nid,
2449 AC_PAR_PIN_CAP);
2450 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2451 if (pincap & AC_PINCAP_VREF_100)
2452 return AC_PINCTL_VREF_100;
2453 if (pincap & AC_PINCAP_VREF_80)
2454 return AC_PINCTL_VREF_80;
2455 if (pincap & AC_PINCAP_VREF_50)
2456 return AC_PINCTL_VREF_50;
2457 if (pincap & AC_PINCAP_VREF_GRD)
2458 return AC_PINCTL_VREF_GRD;
2459 return 0;
2460}
2461
Matt Porter403d1942005-11-29 15:00:51 +01002462static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2463
2464{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002465 snd_hda_codec_write_cache(codec, nid, 0,
2466 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002467}
2468
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002469#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2470
2471static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2472 struct snd_ctl_elem_value *ucontrol)
2473{
2474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2475 struct sigmatel_spec *spec = codec->spec;
2476
Takashi Iwaid7a89432008-11-12 09:48:04 +01002477 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002478 return 0;
2479}
2480
2481static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2482 struct snd_ctl_elem_value *ucontrol)
2483{
2484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2485 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002486 int nid = kcontrol->private_value;
2487
2488 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002489
2490 /* check to be sure that the ports are upto date with
2491 * switch changes
2492 */
2493 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2494
2495 return 1;
2496}
2497
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002498#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002499
2500static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2501{
2502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2503 struct sigmatel_spec *spec = codec->spec;
2504 int io_idx = kcontrol-> private_value & 0xff;
2505
2506 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2507 return 0;
2508}
2509
2510static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2511{
2512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2513 struct sigmatel_spec *spec = codec->spec;
2514 hda_nid_t nid = kcontrol->private_value >> 8;
2515 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002516 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002517
2518 spec->io_switch[io_idx] = val;
2519
2520 if (val)
2521 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002522 else {
2523 unsigned int pinctl = AC_PINCTL_IN_EN;
2524 if (io_idx) /* set VREF for mic */
2525 pinctl |= stac92xx_get_vref(codec, nid);
2526 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2527 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002528
2529 /* check the auto-mute again: we need to mute/unmute the speaker
2530 * appropriately according to the pin direction
2531 */
2532 if (spec->hp_detect)
2533 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2534
Matt Porter403d1942005-11-29 15:00:51 +01002535 return 1;
2536}
2537
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002538#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2539
2540static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2541 struct snd_ctl_elem_value *ucontrol)
2542{
2543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2544 struct sigmatel_spec *spec = codec->spec;
2545
2546 ucontrol->value.integer.value[0] = spec->clfe_swap;
2547 return 0;
2548}
2549
2550static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2551 struct snd_ctl_elem_value *ucontrol)
2552{
2553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2554 struct sigmatel_spec *spec = codec->spec;
2555 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002556 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002557
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002558 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002559 return 0;
2560
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002561 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002562
2563 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2564 spec->clfe_swap ? 0x4 : 0x0);
2565
2566 return 1;
2567}
2568
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002569#define STAC_CODEC_HP_SWITCH(xname) \
2570 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2571 .name = xname, \
2572 .index = 0, \
2573 .info = stac92xx_hp_switch_info, \
2574 .get = stac92xx_hp_switch_get, \
2575 .put = stac92xx_hp_switch_put, \
2576 }
2577
Matt Porter403d1942005-11-29 15:00:51 +01002578#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2579 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2580 .name = xname, \
2581 .index = 0, \
2582 .info = stac92xx_io_switch_info, \
2583 .get = stac92xx_io_switch_get, \
2584 .put = stac92xx_io_switch_put, \
2585 .private_value = xpval, \
2586 }
2587
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002588#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2589 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2590 .name = xname, \
2591 .index = 0, \
2592 .info = stac92xx_clfe_switch_info, \
2593 .get = stac92xx_clfe_switch_get, \
2594 .put = stac92xx_clfe_switch_put, \
2595 .private_value = xpval, \
2596 }
Matt Porter403d1942005-11-29 15:00:51 +01002597
Mattc7d4b2f2005-06-27 14:59:41 +02002598enum {
2599 STAC_CTL_WIDGET_VOL,
2600 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002601 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002602 STAC_CTL_WIDGET_AMP_MUX,
2603 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002604 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002605 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002606 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002607};
2608
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002609static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002610 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2611 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002612 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002613 STAC_AMP_MUX,
2614 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002615 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002616 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002617 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002618};
2619
2620/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002621static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2622 struct snd_kcontrol_new *ktemp,
2623 int idx, const char *name,
2624 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002625{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002626 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002627
2628 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2629 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2630
2631 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2632 if (! knew)
2633 return -ENOMEM;
2634 if (spec->kctl_alloc) {
2635 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2636 kfree(spec->kctl_alloc);
2637 }
2638 spec->kctl_alloc = knew;
2639 spec->num_kctl_alloc = num;
2640 }
2641
2642 knew = &spec->kctl_alloc[spec->num_kctl_used];
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002643 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002644 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002645 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002646 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002647 return -ENOMEM;
2648 knew->private_value = val;
2649 spec->num_kctl_used++;
2650 return 0;
2651}
2652
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002653static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2654 int type, int idx, const char *name,
2655 unsigned long val)
2656{
2657 return stac92xx_add_control_temp(spec,
2658 &stac92xx_control_templates[type],
2659 idx, name, val);
2660}
2661
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002662
2663/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002664static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2665 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002666{
2667 return stac92xx_add_control_idx(spec, type, 0, name, val);
2668}
2669
Matt Porter403d1942005-11-29 15:00:51 +01002670/* flag inputs as additional dynamic lineouts */
2671static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2672{
2673 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002674 unsigned int wcaps, wtype;
2675 int i, num_dacs = 0;
2676
2677 /* use the wcaps cache to count all DACs available for line-outs */
2678 for (i = 0; i < codec->num_nodes; i++) {
2679 wcaps = codec->wcaps[i];
2680 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002681
Steve Longerbeam7b043892007-05-03 20:50:03 +02002682 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2683 num_dacs++;
2684 }
Matt Porter403d1942005-11-29 15:00:51 +01002685
Steve Longerbeam7b043892007-05-03 20:50:03 +02002686 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2687
Matt Porter403d1942005-11-29 15:00:51 +01002688 switch (cfg->line_outs) {
2689 case 3:
2690 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002691 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002692 cfg->line_out_pins[cfg->line_outs] =
2693 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002694 spec->line_switch = 1;
2695 cfg->line_outs++;
2696 }
2697 break;
2698 case 2:
2699 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002700 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002701 cfg->line_out_pins[cfg->line_outs] =
2702 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002703 spec->line_switch = 1;
2704 cfg->line_outs++;
2705 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002706 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002707 cfg->line_out_pins[cfg->line_outs] =
2708 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002709 spec->mic_switch = 1;
2710 cfg->line_outs++;
2711 }
2712 break;
2713 case 1:
2714 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002715 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002716 cfg->line_out_pins[cfg->line_outs] =
2717 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002718 spec->line_switch = 1;
2719 cfg->line_outs++;
2720 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002721 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002722 cfg->line_out_pins[cfg->line_outs] =
2723 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002724 spec->mic_switch = 1;
2725 cfg->line_outs++;
2726 }
2727 break;
2728 }
2729
2730 return 0;
2731}
2732
Steve Longerbeam7b043892007-05-03 20:50:03 +02002733
2734static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2735{
2736 int i;
2737
2738 for (i = 0; i < spec->multiout.num_dacs; i++) {
2739 if (spec->multiout.dac_nids[i] == nid)
2740 return 1;
2741 }
2742
2743 return 0;
2744}
2745
Matt Porter3cc08dc2006-01-23 15:27:49 +01002746/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002747 * Fill in the dac_nids table from the parsed pin configuration
2748 * This function only works when every pin in line_out_pins[]
2749 * contains atleast one DAC in its connection list. Some 92xx
2750 * codecs are not connected directly to a DAC, such as the 9200
2751 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002752 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002753static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002754 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002755{
2756 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002757 int i, j, conn_len = 0;
2758 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2759 unsigned int wcaps, wtype;
2760
Mattc7d4b2f2005-06-27 14:59:41 +02002761 for (i = 0; i < cfg->line_outs; i++) {
2762 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002763 conn_len = snd_hda_get_connections(codec, nid, conn,
2764 HDA_MAX_CONNECTIONS);
2765 for (j = 0; j < conn_len; j++) {
2766 wcaps = snd_hda_param_read(codec, conn[j],
2767 AC_PAR_AUDIO_WIDGET_CAP);
2768 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002769 if (wtype != AC_WID_AUD_OUT ||
2770 (wcaps & AC_WCAP_DIGITAL))
2771 continue;
2772 /* conn[j] is a DAC routed to this line-out */
2773 if (!is_in_dac_nids(spec, conn[j]))
2774 break;
2775 }
2776
2777 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002778 if (spec->multiout.num_dacs > 0) {
2779 /* we have already working output pins,
2780 * so let's drop the broken ones again
2781 */
2782 cfg->line_outs = spec->multiout.num_dacs;
2783 break;
2784 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002785 /* error out, no available DAC found */
2786 snd_printk(KERN_ERR
2787 "%s: No available DAC for pin 0x%x\n",
2788 __func__, nid);
2789 return -ENODEV;
2790 }
2791
2792 spec->multiout.dac_nids[i] = conn[j];
2793 spec->multiout.num_dacs++;
2794 if (conn_len > 1) {
2795 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002796 snd_hda_codec_write_cache(codec, nid, 0,
2797 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002798
2799 }
Mattc7d4b2f2005-06-27 14:59:41 +02002800 }
2801
Steve Longerbeam7b043892007-05-03 20:50:03 +02002802 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2803 spec->multiout.num_dacs,
2804 spec->multiout.dac_nids[0],
2805 spec->multiout.dac_nids[1],
2806 spec->multiout.dac_nids[2],
2807 spec->multiout.dac_nids[3],
2808 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002809 return 0;
2810}
2811
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002812/* create volume control/switch for the given prefx type */
2813static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2814{
2815 char name[32];
2816 int err;
2817
2818 sprintf(name, "%s Playback Volume", pfx);
2819 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2820 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2821 if (err < 0)
2822 return err;
2823 sprintf(name, "%s Playback Switch", pfx);
2824 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2825 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2826 if (err < 0)
2827 return err;
2828 return 0;
2829}
2830
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002831static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2832{
2833 if (!spec->multiout.hp_nid)
2834 spec->multiout.hp_nid = nid;
2835 else if (spec->multiout.num_dacs > 4) {
2836 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2837 return 1;
2838 } else {
2839 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2840 spec->multiout.num_dacs++;
2841 }
2842 return 0;
2843}
2844
2845static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2846{
2847 if (is_in_dac_nids(spec, nid))
2848 return 1;
2849 if (spec->multiout.hp_nid == nid)
2850 return 1;
2851 return 0;
2852}
2853
Mattc7d4b2f2005-06-27 14:59:41 +02002854/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002855static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002856 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002857{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002858 static const char *chname[4] = {
2859 "Front", "Surround", NULL /*CLFE*/, "Side"
2860 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002861 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002862 int i, err;
2863
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002864 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002865 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002866
2867
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002868 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002869 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002870 continue;
2871
2872 nid = spec->multiout.dac_nids[i];
2873
2874 if (i == 2) {
2875 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002876 err = create_controls(spec, "Center", nid, 1);
2877 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002878 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002879 err = create_controls(spec, "LFE", nid, 2);
2880 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002881 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002882
2883 wid_caps = get_wcaps(codec, nid);
2884
2885 if (wid_caps & AC_WCAP_LR_SWAP) {
2886 err = stac92xx_add_control(spec,
2887 STAC_CTL_WIDGET_CLFE_SWITCH,
2888 "Swap Center/LFE Playback Switch", nid);
2889
2890 if (err < 0)
2891 return err;
2892 }
2893
Mattc7d4b2f2005-06-27 14:59:41 +02002894 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002895 err = create_controls(spec, chname[i], nid, 3);
2896 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002897 return err;
2898 }
2899 }
2900
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002901 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2902 cfg->hp_outs && !spec->multiout.hp_nid)
2903 spec->multiout.hp_nid = nid;
2904
Takashi Iwai95026622008-11-24 07:51:11 +01002905 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002906 err = stac92xx_add_control(spec,
2907 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002908 "Headphone as Line Out Switch",
2909 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002910 if (err < 0)
2911 return err;
2912 }
2913
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002914 if (spec->line_switch) {
2915 nid = cfg->input_pins[AUTO_PIN_LINE];
2916 pincap = snd_hda_param_read(codec, nid,
2917 AC_PAR_PIN_CAP);
2918 if (pincap & AC_PINCAP_OUT) {
2919 err = stac92xx_add_control(spec,
2920 STAC_CTL_WIDGET_IO_SWITCH,
2921 "Line In as Output Switch", nid << 8);
2922 if (err < 0)
2923 return err;
2924 }
2925 }
Matt Porter403d1942005-11-29 15:00:51 +01002926
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002927 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002928 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002929 unsigned int mic_pin = AUTO_PIN_MIC;
2930again:
2931 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002932 def_conf = snd_hda_codec_read(codec, nid, 0,
2933 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002934 /* some laptops have an internal analog microphone
2935 * which can't be used as a output */
2936 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2937 pincap = snd_hda_param_read(codec, nid,
2938 AC_PAR_PIN_CAP);
2939 if (pincap & AC_PINCAP_OUT) {
2940 err = stac92xx_add_control(spec,
2941 STAC_CTL_WIDGET_IO_SWITCH,
2942 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002943 nid = snd_hda_codec_read(codec, nid, 0,
2944 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2945 if (!check_in_dac_nids(spec, nid))
2946 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002947 if (err < 0)
2948 return err;
2949 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002950 } else if (mic_pin == AUTO_PIN_MIC) {
2951 mic_pin = AUTO_PIN_FRONT_MIC;
2952 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002953 }
2954 }
Matt Porter403d1942005-11-29 15:00:51 +01002955
Mattc7d4b2f2005-06-27 14:59:41 +02002956 return 0;
2957}
2958
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002959/* add playback controls for Speaker and HP outputs */
2960static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2961 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002962{
2963 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002964 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002965 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002966
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002967 old_num_dacs = spec->multiout.num_dacs;
2968 for (i = 0; i < cfg->hp_outs; i++) {
2969 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2970 if (wid_caps & AC_WCAP_UNSOL_CAP)
2971 spec->hp_detect = 1;
2972 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2973 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2974 if (check_in_dac_nids(spec, nid))
2975 nid = 0;
2976 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002977 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002978 add_spec_dacs(spec, nid);
2979 }
2980 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002981 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002982 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2983 if (check_in_dac_nids(spec, nid))
2984 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002985 if (! nid)
2986 continue;
2987 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002988 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002989 for (i = 0; i < cfg->line_outs; i++) {
2990 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2991 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2992 if (check_in_dac_nids(spec, nid))
2993 nid = 0;
2994 if (! nid)
2995 continue;
2996 add_spec_dacs(spec, nid);
2997 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002998 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2999 static const char *pfxs[] = {
3000 "Speaker", "External Speaker", "Speaker2",
3001 };
3002 err = create_controls(spec, pfxs[i - old_num_dacs],
3003 spec->multiout.dac_nids[i], 3);
3004 if (err < 0)
3005 return err;
3006 }
3007 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01003008 err = create_controls(spec, "Headphone",
3009 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003010 if (err < 0)
3011 return err;
3012 }
Mattc7d4b2f2005-06-27 14:59:41 +02003013
3014 return 0;
3015}
3016
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003017/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003018static const char *stac92xx_mono_labels[4] = {
3019 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003020};
3021
3022/* create mono mux for mono out on capable codecs */
3023static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3024{
3025 struct sigmatel_spec *spec = codec->spec;
3026 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3027 int i, num_cons;
3028 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3029
3030 num_cons = snd_hda_get_connections(codec,
3031 spec->mono_nid,
3032 con_lst,
3033 HDA_MAX_NUM_INPUTS);
3034 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3035 return -EINVAL;
3036
3037 for (i = 0; i < num_cons; i++) {
3038 mono_mux->items[mono_mux->num_items].label =
3039 stac92xx_mono_labels[i];
3040 mono_mux->items[mono_mux->num_items].index = i;
3041 mono_mux->num_items++;
3042 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003043
3044 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3045 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003046}
3047
Matthew Ranostay89385032008-09-11 09:49:39 -04003048/* labels for amp mux outputs */
3049static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003050 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003051};
3052
3053/* create amp out controls mux on capable codecs */
3054static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3055{
3056 struct sigmatel_spec *spec = codec->spec;
3057 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3058 int i, err;
3059
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003060 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003061 amp_mux->items[amp_mux->num_items].label =
3062 stac92xx_amp_labels[i];
3063 amp_mux->items[amp_mux->num_items].index = i;
3064 amp_mux->num_items++;
3065 }
3066
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003067 if (spec->num_amps > 1) {
3068 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3069 "Amp Selector Capture Switch", 0);
3070 if (err < 0)
3071 return err;
3072 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003073 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3074 "Amp Capture Volume",
3075 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3076}
3077
3078
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003079/* create PC beep volume controls */
3080static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3081 hda_nid_t nid)
3082{
3083 struct sigmatel_spec *spec = codec->spec;
3084 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3085 int err;
3086
3087 /* check for mute support for the the amp */
3088 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3089 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3090 "PC Beep Playback Switch",
3091 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3092 if (err < 0)
3093 return err;
3094 }
3095
3096 /* check to see if there is volume support for the amp */
3097 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3098 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3099 "PC Beep Playback Volume",
3100 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3101 if (err < 0)
3102 return err;
3103 }
3104 return 0;
3105}
3106
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003107#ifdef CONFIG_SND_HDA_INPUT_BEEP
3108#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3109
3110static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3111 struct snd_ctl_elem_value *ucontrol)
3112{
3113 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3114 ucontrol->value.integer.value[0] = codec->beep->enabled;
3115 return 0;
3116}
3117
3118static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3119 struct snd_ctl_elem_value *ucontrol)
3120{
3121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3122 int enabled = !!ucontrol->value.integer.value[0];
3123 if (codec->beep->enabled != enabled) {
3124 codec->beep->enabled = enabled;
3125 return 1;
3126 }
3127 return 0;
3128}
3129
3130static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3132 .info = stac92xx_dig_beep_switch_info,
3133 .get = stac92xx_dig_beep_switch_get,
3134 .put = stac92xx_dig_beep_switch_put,
3135};
3136
3137static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3138{
3139 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3140 0, "PC Beep Playback Switch", 0);
3141}
3142#endif
3143
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003144static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3145{
3146 struct sigmatel_spec *spec = codec->spec;
3147 int wcaps, nid, i, err = 0;
3148
3149 for (i = 0; i < spec->num_muxes; i++) {
3150 nid = spec->mux_nids[i];
3151 wcaps = get_wcaps(codec, nid);
3152
3153 if (wcaps & AC_WCAP_OUT_AMP) {
3154 err = stac92xx_add_control_idx(spec,
3155 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3156 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3157 if (err < 0)
3158 return err;
3159 }
3160 }
3161 return 0;
3162};
3163
Matthew Ranostayd9737752008-09-07 12:03:41 +02003164static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003165 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003166};
3167
3168static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3169{
3170 struct sigmatel_spec *spec = codec->spec;
3171 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003172 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003173 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003174 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003175
3176 num_cons = snd_hda_get_connections(codec,
3177 spec->smux_nids[0],
3178 con_lst,
3179 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003180 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003181 return -EINVAL;
3182
Matthew Ranostay65973632008-09-16 10:39:37 -04003183 if (!labels)
3184 labels = stac92xx_spdif_labels;
3185
Matthew Ranostayd9737752008-09-07 12:03:41 +02003186 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003187 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003188 spdif_mux->items[spdif_mux->num_items].index = i;
3189 spdif_mux->num_items++;
3190 }
3191
3192 return 0;
3193}
3194
Matt Porter8b657272006-10-26 17:12:59 +02003195/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003196static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003197 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3198 "Digital Mic 3", "Digital Mic 4"
3199};
3200
3201/* create playback/capture controls for input pins on dmic capable codecs */
3202static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3203 const struct auto_pin_cfg *cfg)
3204{
3205 struct sigmatel_spec *spec = codec->spec;
3206 struct hda_input_mux *dimux = &spec->private_dimux;
3207 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003208 int err, i, j;
3209 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003210
3211 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3212 dimux->items[dimux->num_items].index = 0;
3213 dimux->num_items++;
3214
3215 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003216 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003217 int index;
3218 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003219 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003220 unsigned int def_conf;
3221
3222 def_conf = snd_hda_codec_read(codec,
3223 spec->dmic_nids[i],
3224 0,
3225 AC_VERB_GET_CONFIG_DEFAULT,
3226 0);
3227 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3228 continue;
3229
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003230 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003231 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003232 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003233 con_lst,
3234 HDA_MAX_NUM_INPUTS);
3235 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003236 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003237 index = j;
3238 goto found;
3239 }
3240 continue;
3241found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003242 wcaps = get_wcaps(codec, nid) &
3243 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003244
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003245 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003246 sprintf(name, "%s Capture Volume",
3247 stac92xx_dmic_labels[dimux->num_items]);
3248
3249 err = stac92xx_add_control(spec,
3250 STAC_CTL_WIDGET_VOL,
3251 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003252 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3253 (wcaps & AC_WCAP_OUT_AMP) ?
3254 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003255 if (err < 0)
3256 return err;
3257 }
3258
Matt Porter8b657272006-10-26 17:12:59 +02003259 dimux->items[dimux->num_items].label =
3260 stac92xx_dmic_labels[dimux->num_items];
3261 dimux->items[dimux->num_items].index = index;
3262 dimux->num_items++;
3263 }
3264
3265 return 0;
3266}
3267
Mattc7d4b2f2005-06-27 14:59:41 +02003268/* create playback/capture controls for input pins */
3269static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3270{
3271 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003272 struct hda_input_mux *imux = &spec->private_imux;
3273 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3274 int i, j, k;
3275
3276 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003277 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003278
Takashi Iwai314634b2006-09-21 11:56:18 +02003279 if (!cfg->input_pins[i])
3280 continue;
3281 index = -1;
3282 for (j = 0; j < spec->num_muxes; j++) {
3283 int num_cons;
3284 num_cons = snd_hda_get_connections(codec,
3285 spec->mux_nids[j],
3286 con_lst,
3287 HDA_MAX_NUM_INPUTS);
3288 for (k = 0; k < num_cons; k++)
3289 if (con_lst[k] == cfg->input_pins[i]) {
3290 index = k;
3291 goto found;
3292 }
Mattc7d4b2f2005-06-27 14:59:41 +02003293 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003294 continue;
3295 found:
3296 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3297 imux->items[imux->num_items].index = index;
3298 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003299 }
3300
Steve Longerbeam7b043892007-05-03 20:50:03 +02003301 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003302 /*
3303 * Set the current input for the muxes.
3304 * The STAC9221 has two input muxes with identical source
3305 * NID lists. Hopefully this won't get confused.
3306 */
3307 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003308 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3309 AC_VERB_SET_CONNECT_SEL,
3310 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003311 }
3312 }
3313
Mattc7d4b2f2005-06-27 14:59:41 +02003314 return 0;
3315}
3316
Mattc7d4b2f2005-06-27 14:59:41 +02003317static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3318{
3319 struct sigmatel_spec *spec = codec->spec;
3320 int i;
3321
3322 for (i = 0; i < spec->autocfg.line_outs; i++) {
3323 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3324 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3325 }
3326}
3327
3328static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3329{
3330 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003331 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003332
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003333 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3334 hda_nid_t pin;
3335 pin = spec->autocfg.hp_pins[i];
3336 if (pin) /* connect to front */
3337 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3338 }
3339 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3340 hda_nid_t pin;
3341 pin = spec->autocfg.speaker_pins[i];
3342 if (pin) /* connect to front */
3343 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3344 }
Mattc7d4b2f2005-06-27 14:59:41 +02003345}
3346
Matt Porter3cc08dc2006-01-23 15:27:49 +01003347static 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 +02003348{
3349 struct sigmatel_spec *spec = codec->spec;
3350 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003351 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003352
Matt Porter8b657272006-10-26 17:12:59 +02003353 if ((err = snd_hda_parse_pin_def_config(codec,
3354 &spec->autocfg,
3355 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003356 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003357 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003358 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003359
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003360 /* If we have no real line-out pin and multiple hp-outs, HPs should
3361 * be set up as multi-channel outputs.
3362 */
3363 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3364 spec->autocfg.hp_outs > 1) {
3365 /* Copy hp_outs to line_outs, backup line_outs in
3366 * speaker_outs so that the following routines can handle
3367 * HP pins as primary outputs.
3368 */
3369 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3370 sizeof(spec->autocfg.line_out_pins));
3371 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3372 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3373 sizeof(spec->autocfg.hp_pins));
3374 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3375 hp_speaker_swap = 1;
3376 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003377 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003378 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3379 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003380 u32 caps = query_amp_caps(codec,
3381 spec->autocfg.mono_out_pin, dir);
3382 hda_nid_t conn_list[1];
3383
3384 /* get the mixer node and then the mono mux if it exists */
3385 if (snd_hda_get_connections(codec,
3386 spec->autocfg.mono_out_pin, conn_list, 1) &&
3387 snd_hda_get_connections(codec, conn_list[0],
3388 conn_list, 1)) {
3389
3390 int wcaps = get_wcaps(codec, conn_list[0]);
3391 int wid_type = (wcaps & AC_WCAP_TYPE)
3392 >> AC_WCAP_TYPE_SHIFT;
3393 /* LR swap check, some stac925x have a mux that
3394 * changes the DACs output path instead of the
3395 * mono-mux path.
3396 */
3397 if (wid_type == AC_WID_AUD_SEL &&
3398 !(wcaps & AC_WCAP_LR_SWAP))
3399 spec->mono_nid = conn_list[0];
3400 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003401 if (dir) {
3402 hda_nid_t nid = spec->autocfg.mono_out_pin;
3403
3404 /* most mono outs have a least a mute/unmute switch */
3405 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3406 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3407 "Mono Playback Switch",
3408 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003409 if (err < 0)
3410 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003411 /* check for volume support for the amp */
3412 if ((caps & AC_AMPCAP_NUM_STEPS)
3413 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3414 err = stac92xx_add_control(spec,
3415 STAC_CTL_WIDGET_VOL,
3416 "Mono Playback Volume",
3417 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3418 if (err < 0)
3419 return err;
3420 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003421 }
3422
3423 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3424 AC_PINCTL_OUT_EN);
3425 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003426
Matt Porter403d1942005-11-29 15:00:51 +01003427 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3428 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003429 if (spec->multiout.num_dacs == 0)
3430 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3431 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003432
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003433 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3434
3435 if (err < 0)
3436 return err;
3437
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003438 /* setup analog beep controls */
3439 if (spec->anabeep_nid > 0) {
3440 err = stac92xx_auto_create_beep_ctls(codec,
3441 spec->anabeep_nid);
3442 if (err < 0)
3443 return err;
3444 }
3445
3446 /* setup digital beep controls and input device */
3447#ifdef CONFIG_SND_HDA_INPUT_BEEP
3448 if (spec->digbeep_nid > 0) {
3449 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003450 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003451
3452 err = stac92xx_auto_create_beep_ctls(codec, nid);
3453 if (err < 0)
3454 return err;
3455 err = snd_hda_attach_beep_device(codec, nid);
3456 if (err < 0)
3457 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003458 /* if no beep switch is available, make its own one */
3459 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3460 if (codec->beep &&
3461 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3462 err = stac92xx_beep_switch_ctl(codec);
3463 if (err < 0)
3464 return err;
3465 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003466 }
3467#endif
3468
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003469 if (hp_speaker_swap == 1) {
3470 /* Restore the hp_outs and line_outs */
3471 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3472 sizeof(spec->autocfg.line_out_pins));
3473 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3474 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3475 sizeof(spec->autocfg.speaker_pins));
3476 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3477 memset(spec->autocfg.speaker_pins, 0,
3478 sizeof(spec->autocfg.speaker_pins));
3479 spec->autocfg.speaker_outs = 0;
3480 }
3481
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003482 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3483
3484 if (err < 0)
3485 return err;
3486
3487 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3488
3489 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003490 return err;
3491
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003492 if (spec->mono_nid > 0) {
3493 err = stac92xx_auto_create_mono_output_ctls(codec);
3494 if (err < 0)
3495 return err;
3496 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003497 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003498 err = stac92xx_auto_create_amp_output_ctls(codec);
3499 if (err < 0)
3500 return err;
3501 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003502 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003503 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3504 &spec->autocfg)) < 0)
3505 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003506 if (spec->num_muxes > 0) {
3507 err = stac92xx_auto_create_mux_input_ctls(codec);
3508 if (err < 0)
3509 return err;
3510 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003511 if (spec->num_smuxes > 0) {
3512 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3513 if (err < 0)
3514 return err;
3515 }
Matt Porter8b657272006-10-26 17:12:59 +02003516
Mattc7d4b2f2005-06-27 14:59:41 +02003517 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003518 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003519 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003520
Takashi Iwai82bc9552006-03-21 11:24:42 +01003521 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003522 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003523 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003524 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003525
3526 if (spec->kctl_alloc)
3527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3528
3529 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003530 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003531 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003532 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003533 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003534 return 1;
3535}
3536
Takashi Iwai82bc9552006-03-21 11:24:42 +01003537/* add playback controls for HP output */
3538static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3539 struct auto_pin_cfg *cfg)
3540{
3541 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003542 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003543 unsigned int wid_caps;
3544
3545 if (! pin)
3546 return 0;
3547
3548 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003549 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003550 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003551
3552 return 0;
3553}
3554
Richard Fish160ea0d2006-09-06 13:58:25 +02003555/* add playback controls for LFE output */
3556static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3557 struct auto_pin_cfg *cfg)
3558{
3559 struct sigmatel_spec *spec = codec->spec;
3560 int err;
3561 hda_nid_t lfe_pin = 0x0;
3562 int i;
3563
3564 /*
3565 * search speaker outs and line outs for a mono speaker pin
3566 * with an amp. If one is found, add LFE controls
3567 * for it.
3568 */
3569 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3570 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003571 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003572 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3573 if (wcaps == AC_WCAP_OUT_AMP)
3574 /* found a mono speaker with an amp, must be lfe */
3575 lfe_pin = pin;
3576 }
3577
3578 /* if speaker_outs is 0, then speakers may be in line_outs */
3579 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3580 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3581 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003582 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003583 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003584 AC_VERB_GET_CONFIG_DEFAULT,
3585 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003586 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003587 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003588 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3589 if (wcaps == AC_WCAP_OUT_AMP)
3590 /* found a mono speaker with an amp,
3591 must be lfe */
3592 lfe_pin = pin;
3593 }
3594 }
3595 }
3596
3597 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003598 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003599 if (err < 0)
3600 return err;
3601 }
3602
3603 return 0;
3604}
3605
Mattc7d4b2f2005-06-27 14:59:41 +02003606static int stac9200_parse_auto_config(struct hda_codec *codec)
3607{
3608 struct sigmatel_spec *spec = codec->spec;
3609 int err;
3610
Kailang Yangdf694da2005-12-05 19:42:22 +01003611 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003612 return err;
3613
3614 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3615 return err;
3616
Takashi Iwai82bc9552006-03-21 11:24:42 +01003617 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3618 return err;
3619
Richard Fish160ea0d2006-09-06 13:58:25 +02003620 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3621 return err;
3622
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003623 if (spec->num_muxes > 0) {
3624 err = stac92xx_auto_create_mux_input_ctls(codec);
3625 if (err < 0)
3626 return err;
3627 }
3628
Takashi Iwai82bc9552006-03-21 11:24:42 +01003629 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003630 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003631 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003632 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003633
3634 if (spec->kctl_alloc)
3635 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3636
3637 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003638 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003639
3640 return 1;
3641}
3642
Sam Revitch62fe78e2006-05-10 15:09:17 +02003643/*
3644 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3645 * funky external mute control using GPIO pins.
3646 */
3647
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003648static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003649 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003650{
3651 unsigned int gpiostate, gpiomask, gpiodir;
3652
3653 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3654 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003655 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003656
3657 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3658 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003659 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003660
3661 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3662 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003663 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003664
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003665 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003666 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3667
3668 snd_hda_codec_write(codec, codec->afg, 0,
3669 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003670 snd_hda_codec_read(codec, codec->afg, 0,
3671 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003672
3673 msleep(1);
3674
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003675 snd_hda_codec_read(codec, codec->afg, 0,
3676 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003677}
3678
Takashi Iwai314634b2006-09-21 11:56:18 +02003679static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3680 unsigned int event)
3681{
3682 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003683 snd_hda_codec_write_cache(codec, nid, 0,
3684 AC_VERB_SET_UNSOLICITED_ENABLE,
3685 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003686}
3687
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003688static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3689{
3690 int i;
3691 for (i = 0; i < cfg->hp_outs; i++)
3692 if (cfg->hp_pins[i] == nid)
3693 return 1; /* nid is a HP-Out */
3694
3695 return 0; /* nid is not a HP-Out */
3696};
3697
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003698static void stac92xx_power_down(struct hda_codec *codec)
3699{
3700 struct sigmatel_spec *spec = codec->spec;
3701
3702 /* power down inactive DACs */
3703 hda_nid_t *dac;
3704 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003705 if (!is_in_dac_nids(spec, *dac) &&
3706 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003707 snd_hda_codec_write_cache(codec, *dac, 0,
3708 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3709}
3710
Takashi Iwaif73d3582008-11-25 08:21:51 +01003711static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3712 int enable);
3713
Mattc7d4b2f2005-06-27 14:59:41 +02003714static int stac92xx_init(struct hda_codec *codec)
3715{
3716 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003717 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003718 unsigned int gpio;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003719 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003720
Mattc7d4b2f2005-06-27 14:59:41 +02003721 snd_hda_sequence_write(codec, spec->init);
3722
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003723 /* power down adcs initially */
3724 if (spec->powerdown_adcs)
3725 for (i = 0; i < spec->num_adcs; i++)
3726 snd_hda_codec_write_cache(codec,
3727 spec->adc_nids[i], 0,
3728 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003729
3730 /* set up GPIO */
3731 gpio = spec->gpio_data;
3732 /* turn on EAPD statically when spec->eapd_switch isn't set.
3733 * otherwise, unsol event will turn it on/off dynamically
3734 */
3735 if (!spec->eapd_switch)
3736 gpio |= spec->eapd_mask;
3737 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3738
Takashi Iwai82bc9552006-03-21 11:24:42 +01003739 /* set up pins */
3740 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003741 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003742 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003743 enable_pin_detect(codec, cfg->hp_pins[i],
3744 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003745 /* force to enable the first line-out; the others are set up
3746 * in unsol_event
3747 */
3748 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3749 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003750 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003751 /* fake event to set up pins */
3752 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3753 } else {
3754 stac92xx_auto_init_multi_out(codec);
3755 stac92xx_auto_init_hp_out(codec);
3756 }
3757 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003758 hda_nid_t nid = cfg->input_pins[i];
3759 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003760 unsigned int pinctl;
3761 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3762 /* for mic pins, force to initialize */
3763 pinctl = stac92xx_get_vref(codec, nid);
3764 } else {
3765 pinctl = snd_hda_codec_read(codec, nid, 0,
3766 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3767 /* if PINCTL already set then skip */
3768 if (pinctl & AC_PINCTL_IN_EN)
3769 continue;
3770 }
3771 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003772 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3773 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003774 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003775 for (i = 0; i < spec->num_dmics; i++)
3776 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3777 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003778 if (cfg->dig_out_pin)
3779 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3780 AC_PINCTL_OUT_EN);
3781 if (cfg->dig_in_pin)
3782 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3783 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003784 for (i = 0; i < spec->num_pwrs; i++) {
3785 hda_nid_t nid = spec->pwr_nids[i];
3786 int pinctl, def_conf;
3787 int event = STAC_PWR_EVENT;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003788
Takashi Iwaif73d3582008-11-25 08:21:51 +01003789 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3790 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003791
Takashi Iwaif73d3582008-11-25 08:21:51 +01003792 pinctl = snd_hda_codec_read(codec, nid, 0,
3793 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3794 /* outputs are only ports capable of power management
3795 * any attempts on powering down a input port cause the
3796 * referenced VREF to act quirky.
3797 */
3798 if (pinctl & AC_PINCTL_IN_EN)
3799 continue;
3800 def_conf = snd_hda_codec_read(codec, nid, 0,
3801 AC_VERB_GET_CONFIG_DEFAULT, 0);
3802 def_conf = get_defcfg_connect(def_conf);
3803 /* skip any ports that don't have jacks since presence
3804 * detection is useless */
3805 if (def_conf != AC_JACK_PORT_COMPLEX) {
3806 if (def_conf != AC_JACK_PORT_NONE)
3807 stac_toggle_power_map(codec, nid, 1);
3808 continue;
3809 }
3810 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3811 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3812 }
3813 if (spec->dac_list)
3814 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02003815 return 0;
3816}
3817
Matt2f2f4252005-04-13 14:45:30 +02003818static void stac92xx_free(struct hda_codec *codec)
3819{
Mattc7d4b2f2005-06-27 14:59:41 +02003820 struct sigmatel_spec *spec = codec->spec;
3821 int i;
3822
3823 if (! spec)
3824 return;
3825
3826 if (spec->kctl_alloc) {
3827 for (i = 0; i < spec->num_kctl_used; i++)
3828 kfree(spec->kctl_alloc[i].name);
3829 kfree(spec->kctl_alloc);
3830 }
3831
Richard Fish11b44bb2006-08-23 18:31:34 +02003832 if (spec->bios_pin_configs)
3833 kfree(spec->bios_pin_configs);
3834
Mattc7d4b2f2005-06-27 14:59:41 +02003835 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003836 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003837}
3838
Matt4e550962005-07-04 17:51:39 +02003839static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3840 unsigned int flag)
3841{
3842 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3843 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003844
Takashi Iwaif9acba42007-05-29 18:01:06 +02003845 if (pin_ctl & AC_PINCTL_IN_EN) {
3846 /*
3847 * we need to check the current set-up direction of
3848 * shared input pins since they can be switched via
3849 * "xxx as Output" mixer switch
3850 */
3851 struct sigmatel_spec *spec = codec->spec;
3852 struct auto_pin_cfg *cfg = &spec->autocfg;
3853 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3854 spec->line_switch) ||
3855 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3856 spec->mic_switch))
3857 return;
3858 }
3859
Steve Longerbeam7b043892007-05-03 20:50:03 +02003860 /* if setting pin direction bits, clear the current
3861 direction bits first */
3862 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3863 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3864
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003865 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003866 AC_VERB_SET_PIN_WIDGET_CONTROL,
3867 pin_ctl | flag);
3868}
3869
3870static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3871 unsigned int flag)
3872{
3873 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3874 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003875 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003876 AC_VERB_SET_PIN_WIDGET_CONTROL,
3877 pin_ctl & ~flag);
3878}
3879
Jiang Zhe40c1d302007-11-12 13:05:16 +01003880static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003881{
3882 if (!nid)
3883 return 0;
3884 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003885 & (1 << 31)) {
3886 unsigned int pinctl;
3887 pinctl = snd_hda_codec_read(codec, nid, 0,
3888 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3889 if (pinctl & AC_PINCTL_IN_EN)
3890 return 0; /* mic- or line-input */
3891 else
3892 return 1; /* HP-output */
3893 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003894 return 0;
3895}
3896
Takashi Iwaid7a89432008-11-12 09:48:04 +01003897/* return non-zero if the hp-pin of the given array index isn't
3898 * a jack-detection target
3899 */
3900static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3901{
3902 struct auto_pin_cfg *cfg = &spec->autocfg;
3903
3904 /* ignore sensing of shared line and mic jacks */
3905 if (spec->line_switch &&
3906 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3907 return 1;
3908 if (spec->mic_switch &&
3909 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3910 return 1;
3911 /* ignore if the pin is set as line-out */
3912 if (cfg->hp_pins[i] == spec->hp_switch)
3913 return 1;
3914 return 0;
3915}
3916
Takashi Iwai314634b2006-09-21 11:56:18 +02003917static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003918{
3919 struct sigmatel_spec *spec = codec->spec;
3920 struct auto_pin_cfg *cfg = &spec->autocfg;
3921 int i, presence;
3922
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003923 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003924 if (spec->gpio_mute)
3925 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3926 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3927
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003928 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003929 if (presence)
3930 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003931 if (no_hp_sensing(spec, i))
3932 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003933 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003934 }
Matt4e550962005-07-04 17:51:39 +02003935
3936 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003937 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003938 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003939 stac92xx_reset_pinctl(codec, spec->hp_switch,
3940 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003941 for (i = 0; i < cfg->line_outs; i++)
3942 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3943 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003944 for (i = 0; i < cfg->speaker_outs; i++)
3945 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3946 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003947 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003948 stac_gpio_set(codec, spec->gpio_mask,
3949 spec->gpio_dir, spec->gpio_data &
3950 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003951 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003952 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003953 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003954 stac92xx_set_pinctl(codec, spec->hp_switch,
3955 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003956 for (i = 0; i < cfg->line_outs; i++)
3957 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3958 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003959 for (i = 0; i < cfg->speaker_outs; i++)
3960 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3961 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003962 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003963 stac_gpio_set(codec, spec->gpio_mask,
3964 spec->gpio_dir, spec->gpio_data |
3965 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003966 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01003967 /* toggle hp outs */
3968 for (i = 0; i < cfg->hp_outs; i++) {
3969 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3970 if (no_hp_sensing(spec, i))
3971 continue;
3972 if (presence)
3973 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3974 else
3975 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3976 }
Matt4e550962005-07-04 17:51:39 +02003977}
3978
Takashi Iwaif73d3582008-11-25 08:21:51 +01003979static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3980 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003981{
3982 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003983 unsigned int idx, val;
3984
3985 for (idx = 0; idx < spec->num_pwrs; idx++) {
3986 if (spec->pwr_nids[idx] == nid)
3987 break;
3988 }
3989 if (idx >= spec->num_pwrs)
3990 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003991
3992 /* several codecs have two power down bits */
3993 if (spec->pwr_mapping)
3994 idx = spec->pwr_mapping[idx];
3995 else
3996 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003997
Takashi Iwaif73d3582008-11-25 08:21:51 +01003998 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
3999 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004000 val &= ~idx;
4001 else
4002 val |= idx;
4003
4004 /* power down unused output ports */
4005 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004006}
4007
4008static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4009{
4010 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4011}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004012
Takashi Iwai314634b2006-09-21 11:56:18 +02004013static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4014{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004015 struct sigmatel_spec *spec = codec->spec;
4016 int idx = res >> 26 & 0x0f;
4017
Matthew Ranostay72474be2008-10-09 09:32:17 -04004018 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004019 case STAC_HP_EVENT:
4020 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004021 /* fallthru */
4022 case STAC_PWR_EVENT:
4023 if (spec->num_pwrs > 0)
4024 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004025 break;
4026 case STAC_VREF_EVENT: {
4027 int data = snd_hda_codec_read(codec, codec->afg, 0,
4028 AC_VERB_GET_GPIO_DATA, 0);
4029 /* toggle VREF state based on GPIOx status */
4030 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4031 !!(data & (1 << idx)));
4032 break;
4033 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004034 }
4035}
4036
Takashi Iwaicb53c622007-08-10 17:21:45 +02004037#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004038static int stac92xx_resume(struct hda_codec *codec)
4039{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004040 struct sigmatel_spec *spec = codec->spec;
4041
Richard Fish11b44bb2006-08-23 18:31:34 +02004042 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004043 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004044 stac_gpio_set(codec, spec->gpio_mask,
4045 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004046 snd_hda_codec_resume_amp(codec);
4047 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004048 /* power down inactive DACs */
4049 if (spec->dac_list)
4050 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004051 /* invoke unsolicited event to reset the HP state */
4052 if (spec->hp_detect)
4053 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02004054 return 0;
4055}
4056#endif
4057
Matt2f2f4252005-04-13 14:45:30 +02004058static struct hda_codec_ops stac92xx_patch_ops = {
4059 .build_controls = stac92xx_build_controls,
4060 .build_pcms = stac92xx_build_pcms,
4061 .init = stac92xx_init,
4062 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004063 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004064#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004065 .resume = stac92xx_resume,
4066#endif
Matt2f2f4252005-04-13 14:45:30 +02004067};
4068
4069static int patch_stac9200(struct hda_codec *codec)
4070{
4071 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004072 int err;
Matt2f2f4252005-04-13 14:45:30 +02004073
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004074 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004075 if (spec == NULL)
4076 return -ENOMEM;
4077
4078 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004079 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004080 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004081 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4082 stac9200_models,
4083 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004084 if (spec->board_config < 0) {
4085 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4086 err = stac92xx_save_bios_config_regs(codec);
4087 if (err < 0) {
4088 stac92xx_free(codec);
4089 return err;
4090 }
4091 spec->pin_configs = spec->bios_pin_configs;
4092 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004093 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4094 stac92xx_set_config_regs(codec);
4095 }
Matt2f2f4252005-04-13 14:45:30 +02004096
4097 spec->multiout.max_channels = 2;
4098 spec->multiout.num_dacs = 1;
4099 spec->multiout.dac_nids = stac9200_dac_nids;
4100 spec->adc_nids = stac9200_adc_nids;
4101 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004102 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004103 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004104 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004105 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004106
Tobin Davisbf277782008-02-03 20:31:47 +01004107 if (spec->board_config == STAC_9200_GATEWAY ||
4108 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004109 spec->init = stac9200_eapd_init;
4110 else
4111 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004112 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004113
Takashi Iwai117f2572008-03-18 09:53:23 +01004114 if (spec->board_config == STAC_9200_PANASONIC) {
4115 spec->gpio_mask = spec->gpio_dir = 0x09;
4116 spec->gpio_data = 0x00;
4117 }
4118
Mattc7d4b2f2005-06-27 14:59:41 +02004119 err = stac9200_parse_auto_config(codec);
4120 if (err < 0) {
4121 stac92xx_free(codec);
4122 return err;
4123 }
Matt2f2f4252005-04-13 14:45:30 +02004124
4125 codec->patch_ops = stac92xx_patch_ops;
4126
4127 return 0;
4128}
4129
Tobin Davis8e21c342007-01-08 11:04:17 +01004130static int patch_stac925x(struct hda_codec *codec)
4131{
4132 struct sigmatel_spec *spec;
4133 int err;
4134
4135 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4136 if (spec == NULL)
4137 return -ENOMEM;
4138
4139 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004140 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004141 spec->pin_nids = stac925x_pin_nids;
4142 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4143 stac925x_models,
4144 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004145 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004146 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004147 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4148 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004149 err = stac92xx_save_bios_config_regs(codec);
4150 if (err < 0) {
4151 stac92xx_free(codec);
4152 return err;
4153 }
4154 spec->pin_configs = spec->bios_pin_configs;
4155 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4156 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4157 stac92xx_set_config_regs(codec);
4158 }
4159
4160 spec->multiout.max_channels = 2;
4161 spec->multiout.num_dacs = 1;
4162 spec->multiout.dac_nids = stac925x_dac_nids;
4163 spec->adc_nids = stac925x_adc_nids;
4164 spec->mux_nids = stac925x_mux_nids;
4165 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004166 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004167 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004168 switch (codec->vendor_id) {
4169 case 0x83847632: /* STAC9202 */
4170 case 0x83847633: /* STAC9202D */
4171 case 0x83847636: /* STAC9251 */
4172 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004173 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004174 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004175 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4176 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004177 break;
4178 default:
4179 spec->num_dmics = 0;
4180 break;
4181 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004182
4183 spec->init = stac925x_core_init;
4184 spec->mixer = stac925x_mixer;
4185
4186 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004187 if (!err) {
4188 if (spec->board_config < 0) {
4189 printk(KERN_WARNING "hda_codec: No auto-config is "
4190 "available, default to model=ref\n");
4191 spec->board_config = STAC_925x_REF;
4192 goto again;
4193 }
4194 err = -EINVAL;
4195 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004196 if (err < 0) {
4197 stac92xx_free(codec);
4198 return err;
4199 }
4200
4201 codec->patch_ops = stac92xx_patch_ops;
4202
4203 return 0;
4204}
4205
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004206static struct hda_input_mux stac92hd73xx_dmux = {
4207 .num_items = 4,
4208 .items = {
4209 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004210 { "Digital Mic 1", 0x09 },
4211 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004212 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004213 }
4214};
4215
4216static int patch_stac92hd73xx(struct hda_codec *codec)
4217{
4218 struct sigmatel_spec *spec;
4219 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4220 int err = 0;
4221
4222 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4223 if (spec == NULL)
4224 return -ENOMEM;
4225
4226 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004227 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004228 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4229 spec->pin_nids = stac92hd73xx_pin_nids;
4230 spec->board_config = snd_hda_check_board_config(codec,
4231 STAC_92HD73XX_MODELS,
4232 stac92hd73xx_models,
4233 stac92hd73xx_cfg_tbl);
4234again:
4235 if (spec->board_config < 0) {
4236 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4237 " STAC92HD73XX, using BIOS defaults\n");
4238 err = stac92xx_save_bios_config_regs(codec);
4239 if (err < 0) {
4240 stac92xx_free(codec);
4241 return err;
4242 }
4243 spec->pin_configs = spec->bios_pin_configs;
4244 } else {
4245 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4246 stac92xx_set_config_regs(codec);
4247 }
4248
4249 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4250 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4251
4252 if (spec->multiout.num_dacs < 0) {
4253 printk(KERN_WARNING "hda_codec: Could not determine "
4254 "number of channels defaulting to DAC count\n");
4255 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4256 }
4257
4258 switch (spec->multiout.num_dacs) {
4259 case 0x3: /* 6 Channel */
4260 spec->mixer = stac92hd73xx_6ch_mixer;
4261 spec->init = stac92hd73xx_6ch_core_init;
4262 break;
4263 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004264 spec->mixer = stac92hd73xx_8ch_mixer;
4265 spec->init = stac92hd73xx_8ch_core_init;
4266 break;
4267 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004268 spec->mixer = stac92hd73xx_10ch_mixer;
4269 spec->init = stac92hd73xx_10ch_core_init;
4270 };
4271
4272 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4273 spec->aloopback_mask = 0x01;
4274 spec->aloopback_shift = 8;
4275
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004276 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004277 spec->mux_nids = stac92hd73xx_mux_nids;
4278 spec->adc_nids = stac92hd73xx_adc_nids;
4279 spec->dmic_nids = stac92hd73xx_dmic_nids;
4280 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004281 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004282 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004283 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004284
4285 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4286 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004287 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004288 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4289 sizeof(stac92hd73xx_dmux));
4290
Matthew Ranostaya7662642008-02-21 07:51:14 +01004291 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004292 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004293 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004294 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004295 case STAC_DELL_M6_AMIC:
4296 case STAC_DELL_M6_DMIC:
4297 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004298 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004299 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4300 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004301 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004302 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004303
4304 if (!spec->init)
4305 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004306 switch (spec->board_config) {
4307 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004308 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4309 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004310 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004311 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004312 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004313 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4314 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004315 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004316 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004317 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004318 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4319 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4320 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004321 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004322 break;
4323 }
4324 break;
4325 default:
4326 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004327 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004328 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004329 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004330 if (spec->board_config > STAC_92HD73XX_REF) {
4331 /* GPIO0 High = Enable EAPD */
4332 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4333 spec->gpio_data = 0x01;
4334 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004335 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004336
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004337 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4338 spec->pwr_nids = stac92hd73xx_pwr_nids;
4339
Matthew Ranostayd9737752008-09-07 12:03:41 +02004340 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004341
4342 if (!err) {
4343 if (spec->board_config < 0) {
4344 printk(KERN_WARNING "hda_codec: No auto-config is "
4345 "available, default to model=ref\n");
4346 spec->board_config = STAC_92HD73XX_REF;
4347 goto again;
4348 }
4349 err = -EINVAL;
4350 }
4351
4352 if (err < 0) {
4353 stac92xx_free(codec);
4354 return err;
4355 }
4356
4357 codec->patch_ops = stac92xx_patch_ops;
4358
4359 return 0;
4360}
4361
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004362static struct hda_input_mux stac92hd83xxx_dmux = {
4363 .num_items = 3,
4364 .items = {
4365 { "Analog Inputs", 0x03 },
4366 { "Digital Mic 1", 0x04 },
4367 { "Digital Mic 2", 0x05 },
4368 }
4369};
4370
4371static int patch_stac92hd83xxx(struct hda_codec *codec)
4372{
4373 struct sigmatel_spec *spec;
4374 int err;
4375
4376 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4377 if (spec == NULL)
4378 return -ENOMEM;
4379
4380 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004381 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004382 spec->mono_nid = 0x19;
4383 spec->digbeep_nid = 0x21;
4384 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4385 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4386 spec->adc_nids = stac92hd83xxx_adc_nids;
4387 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4388 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4389 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4390 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4391
4392 spec->init = stac92hd83xxx_core_init;
4393 switch (codec->vendor_id) {
4394 case 0x111d7605:
4395 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4396 break;
4397 default:
4398 spec->num_pwrs--;
4399 spec->init++; /* switch to config #2 */
4400 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4401 }
4402
4403 spec->mixer = stac92hd83xxx_mixer;
4404 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4405 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4406 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4407 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4408 spec->dinput_mux = &stac92hd83xxx_dmux;
4409 spec->pin_nids = stac92hd83xxx_pin_nids;
4410 spec->board_config = snd_hda_check_board_config(codec,
4411 STAC_92HD83XXX_MODELS,
4412 stac92hd83xxx_models,
4413 stac92hd83xxx_cfg_tbl);
4414again:
4415 if (spec->board_config < 0) {
4416 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4417 " STAC92HD83XXX, using BIOS defaults\n");
4418 err = stac92xx_save_bios_config_regs(codec);
4419 if (err < 0) {
4420 stac92xx_free(codec);
4421 return err;
4422 }
4423 spec->pin_configs = spec->bios_pin_configs;
4424 } else {
4425 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4426 stac92xx_set_config_regs(codec);
4427 }
4428
4429 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4430 if (!err) {
4431 if (spec->board_config < 0) {
4432 printk(KERN_WARNING "hda_codec: No auto-config is "
4433 "available, default to model=ref\n");
4434 spec->board_config = STAC_92HD83XXX_REF;
4435 goto again;
4436 }
4437 err = -EINVAL;
4438 }
4439
4440 if (err < 0) {
4441 stac92xx_free(codec);
4442 return err;
4443 }
4444
4445 codec->patch_ops = stac92xx_patch_ops;
4446
4447 return 0;
4448}
4449
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004450#ifdef SND_HDA_NEEDS_RESUME
4451static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4452{
4453 struct sigmatel_spec *spec = codec->spec;
4454 int i;
4455 snd_hda_codec_write_cache(codec, codec->afg, 0,
4456 AC_VERB_SET_POWER_STATE, pwr);
4457
4458 msleep(1);
4459 for (i = 0; i < spec->num_adcs; i++) {
4460 snd_hda_codec_write_cache(codec,
4461 spec->adc_nids[i], 0,
4462 AC_VERB_SET_POWER_STATE, pwr);
4463 }
4464};
4465
4466static int stac92hd71xx_resume(struct hda_codec *codec)
4467{
4468 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4469 return stac92xx_resume(codec);
4470}
4471
4472static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4473{
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004474 struct sigmatel_spec *spec = codec->spec;
4475
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004476 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004477 if (spec->eapd_mask)
4478 stac_gpio_set(codec, spec->gpio_mask,
4479 spec->gpio_dir, spec->gpio_data &
4480 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004481 return 0;
4482};
4483
4484#endif
4485
4486static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4487 .build_controls = stac92xx_build_controls,
4488 .build_pcms = stac92xx_build_pcms,
4489 .init = stac92xx_init,
4490 .free = stac92xx_free,
4491 .unsol_event = stac92xx_unsol_event,
4492#ifdef SND_HDA_NEEDS_RESUME
4493 .resume = stac92hd71xx_resume,
4494 .suspend = stac92hd71xx_suspend,
4495#endif
4496};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004497
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004498static struct hda_input_mux stac92hd71bxx_dmux = {
4499 .num_items = 4,
4500 .items = {
4501 { "Analog Inputs", 0x00 },
4502 { "Mixer", 0x01 },
4503 { "Digital Mic 1", 0x02 },
4504 { "Digital Mic 2", 0x03 },
4505 }
4506};
4507
Matthew Ranostaye035b842007-11-06 11:53:55 +01004508static int patch_stac92hd71bxx(struct hda_codec *codec)
4509{
4510 struct sigmatel_spec *spec;
4511 int err = 0;
4512
4513 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4514 if (spec == NULL)
4515 return -ENOMEM;
4516
4517 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004518 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004519 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004520 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004521 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004522 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4523 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004524 spec->board_config = snd_hda_check_board_config(codec,
4525 STAC_92HD71BXX_MODELS,
4526 stac92hd71bxx_models,
4527 stac92hd71bxx_cfg_tbl);
4528again:
4529 if (spec->board_config < 0) {
4530 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4531 " STAC92HD71BXX, using BIOS defaults\n");
4532 err = stac92xx_save_bios_config_regs(codec);
4533 if (err < 0) {
4534 stac92xx_free(codec);
4535 return err;
4536 }
4537 spec->pin_configs = spec->bios_pin_configs;
4538 } else {
4539 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4540 stac92xx_set_config_regs(codec);
4541 }
4542
Takashi Iwai41c3b642008-11-18 10:45:15 +01004543 if (spec->board_config > STAC_92HD71BXX_REF) {
4544 /* GPIO0 = EAPD */
4545 spec->gpio_mask = 0x01;
4546 spec->gpio_dir = 0x01;
4547 spec->gpio_data = 0x01;
4548 }
4549
Matthew Ranostay541eee82007-12-14 12:08:04 +01004550 switch (codec->vendor_id) {
4551 case 0x111d76b6: /* 4 Port without Analog Mixer */
4552 case 0x111d76b7:
4553 case 0x111d76b4: /* 6 Port without Analog Mixer */
4554 case 0x111d76b5:
4555 spec->mixer = stac92hd71bxx_mixer;
4556 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004557 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004558 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004559 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004560 switch (spec->board_config) {
4561 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004562 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004563 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004564 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4565 snd_hda_codec_write_cache(codec, codec->afg, 0,
4566 AC_VERB_SET_UNSOLICITED_ENABLE,
4567 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4568 spec->gpio_mask |= 0x02;
4569 break;
4570 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004571 if ((codec->revision_id & 0xf) == 0 ||
4572 (codec->revision_id & 0xf) == 1) {
4573#ifdef SND_HDA_NEEDS_RESUME
4574 codec->patch_ops = stac92hd71bxx_patch_ops;
4575#endif
4576 spec->stream_delay = 40; /* 40 milliseconds */
4577 }
4578
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004579 /* no output amps */
4580 spec->num_pwrs = 0;
4581 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004582 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004583
4584 /* disable VSW */
4585 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4586 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4587 break;
4588 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004589 if ((codec->revision_id & 0xf) == 1) {
4590#ifdef SND_HDA_NEEDS_RESUME
4591 codec->patch_ops = stac92hd71bxx_patch_ops;
4592#endif
4593 spec->stream_delay = 40; /* 40 milliseconds */
4594 }
4595
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004596 /* no output amps */
4597 spec->num_pwrs = 0;
4598 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004599 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004600 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004601 spec->mixer = stac92hd71bxx_analog_mixer;
4602 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004603 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004604 }
4605
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004606 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004607 spec->aloopback_shift = 0;
4608
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004609 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004610 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004611 spec->mux_nids = stac92hd71bxx_mux_nids;
4612 spec->adc_nids = stac92hd71bxx_adc_nids;
4613 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004614 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004615 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004616 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004617
4618 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4619 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004620
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004621 switch (spec->board_config) {
4622 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004623 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004624 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4625 stac92xx_auto_set_pinctl(codec, 0x0e,
4626 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004627 /* fallthru */
4628 case STAC_DELL_M4_2:
4629 spec->num_dmics = 0;
4630 spec->num_smuxes = 0;
4631 spec->num_dmuxes = 0;
4632 break;
4633 case STAC_DELL_M4_1:
4634 case STAC_DELL_M4_3:
4635 spec->num_dmics = 1;
4636 spec->num_smuxes = 0;
4637 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004638 break;
4639 default:
4640 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4641 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4642 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4643 };
4644
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004645 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004646 spec->multiout.hp_nid = 0x11;
4647 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004648 if (spec->dinput_mux)
4649 spec->private_dimux.num_items +=
4650 spec->num_dmics -
4651 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004652
4653 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4654 if (!err) {
4655 if (spec->board_config < 0) {
4656 printk(KERN_WARNING "hda_codec: No auto-config is "
4657 "available, default to model=ref\n");
4658 spec->board_config = STAC_92HD71BXX_REF;
4659 goto again;
4660 }
4661 err = -EINVAL;
4662 }
4663
4664 if (err < 0) {
4665 stac92xx_free(codec);
4666 return err;
4667 }
4668
Matthew Ranostaye035b842007-11-06 11:53:55 +01004669 return 0;
4670};
4671
Matt2f2f4252005-04-13 14:45:30 +02004672static int patch_stac922x(struct hda_codec *codec)
4673{
4674 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004675 int err;
Matt2f2f4252005-04-13 14:45:30 +02004676
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004677 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004678 if (spec == NULL)
4679 return -ENOMEM;
4680
4681 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004682 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004683 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004684 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4685 stac922x_models,
4686 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004687 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004688 spec->gpio_mask = spec->gpio_dir = 0x03;
4689 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004690 /* Intel Macs have all same PCI SSID, so we need to check
4691 * codec SSID to distinguish the exact models
4692 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004693 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004694 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004695
4696 case 0x106b0800:
4697 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004698 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004699 case 0x106b0600:
4700 case 0x106b0700:
4701 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004702 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004703 case 0x106b0e00:
4704 case 0x106b0f00:
4705 case 0x106b1600:
4706 case 0x106b1700:
4707 case 0x106b0200:
4708 case 0x106b1e00:
4709 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004710 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004711 case 0x106b1a00:
4712 case 0x00000100:
4713 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004714 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004715 case 0x106b0a00:
4716 case 0x106b2200:
4717 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004718 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004719 default:
4720 spec->board_config = STAC_INTEL_MAC_V3;
4721 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004722 }
4723 }
4724
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004725 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004726 if (spec->board_config < 0) {
4727 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4728 "using BIOS defaults\n");
4729 err = stac92xx_save_bios_config_regs(codec);
4730 if (err < 0) {
4731 stac92xx_free(codec);
4732 return err;
4733 }
4734 spec->pin_configs = spec->bios_pin_configs;
4735 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004736 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4737 stac92xx_set_config_regs(codec);
4738 }
Matt2f2f4252005-04-13 14:45:30 +02004739
Matt2f2f4252005-04-13 14:45:30 +02004740 spec->adc_nids = stac922x_adc_nids;
4741 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004742 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004743 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004744 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004745 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004746
4747 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004748 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004749
4750 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004751
Matt Porter3cc08dc2006-01-23 15:27:49 +01004752 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004753 if (!err) {
4754 if (spec->board_config < 0) {
4755 printk(KERN_WARNING "hda_codec: No auto-config is "
4756 "available, default to model=ref\n");
4757 spec->board_config = STAC_D945_REF;
4758 goto again;
4759 }
4760 err = -EINVAL;
4761 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004762 if (err < 0) {
4763 stac92xx_free(codec);
4764 return err;
4765 }
4766
4767 codec->patch_ops = stac92xx_patch_ops;
4768
Takashi Iwai807a46362007-05-29 19:01:37 +02004769 /* Fix Mux capture level; max to 2 */
4770 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4771 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4772 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4773 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4774 (0 << AC_AMPCAP_MUTE_SHIFT));
4775
Matt Porter3cc08dc2006-01-23 15:27:49 +01004776 return 0;
4777}
4778
4779static int patch_stac927x(struct hda_codec *codec)
4780{
4781 struct sigmatel_spec *spec;
4782 int err;
4783
4784 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4785 if (spec == NULL)
4786 return -ENOMEM;
4787
4788 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004789 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004790 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004791 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4792 stac927x_models,
4793 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004794 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004795 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4796 if (spec->board_config < 0)
4797 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4798 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004799 err = stac92xx_save_bios_config_regs(codec);
4800 if (err < 0) {
4801 stac92xx_free(codec);
4802 return err;
4803 }
4804 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004805 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004806 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4807 stac92xx_set_config_regs(codec);
4808 }
4809
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004810 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004811 spec->adc_nids = stac927x_adc_nids;
4812 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4813 spec->mux_nids = stac927x_mux_nids;
4814 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004815 spec->smux_nids = stac927x_smux_nids;
4816 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004817 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004818 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004819 spec->multiout.dac_nids = spec->dac_nids;
4820
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004821 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004822 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004823 case STAC_D965_5ST:
4824 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004825 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004826 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004827 spec->num_dmics = 0;
4828
Tobin Davis93ed1502006-09-01 21:03:12 +02004829 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004830 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004831 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004832 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004833 switch (codec->subsystem_id) {
4834 case 0x10280209:
4835 case 0x1028022e:
4836 /* correct the device field to SPDIF out */
4837 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4838 break;
4839 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004840 /* configure the analog microphone on some laptops */
4841 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004842 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004843 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004844 /* correct the front input jack as a mic */
4845 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4846 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004847 case STAC_DELL_3ST:
4848 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004849 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004850 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004851 spec->dmic_nids = stac927x_dmic_nids;
4852 spec->num_dmics = STAC927X_NUM_DMICS;
4853
Tobin Davis93ed1502006-09-01 21:03:12 +02004854 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004855 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004856 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004857 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004858 break;
4859 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004860 if (spec->board_config > STAC_D965_REF) {
4861 /* GPIO0 High = Enable EAPD */
4862 spec->eapd_mask = spec->gpio_mask = 0x01;
4863 spec->gpio_dir = spec->gpio_data = 0x01;
4864 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004865 spec->num_dmics = 0;
4866
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004867 spec->init = stac927x_core_init;
4868 spec->mixer = stac927x_mixer;
4869 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004870
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004871 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004872 spec->aloopback_mask = 0x40;
4873 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004874 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004875
Matt Porter3cc08dc2006-01-23 15:27:49 +01004876 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004877 if (!err) {
4878 if (spec->board_config < 0) {
4879 printk(KERN_WARNING "hda_codec: No auto-config is "
4880 "available, default to model=ref\n");
4881 spec->board_config = STAC_D965_REF;
4882 goto again;
4883 }
4884 err = -EINVAL;
4885 }
Mattc7d4b2f2005-06-27 14:59:41 +02004886 if (err < 0) {
4887 stac92xx_free(codec);
4888 return err;
4889 }
Matt2f2f4252005-04-13 14:45:30 +02004890
4891 codec->patch_ops = stac92xx_patch_ops;
4892
Takashi Iwai52987652008-01-16 16:09:47 +01004893 /*
4894 * !!FIXME!!
4895 * The STAC927x seem to require fairly long delays for certain
4896 * command sequences. With too short delays (even if the answer
4897 * is set to RIRB properly), it results in the silence output
4898 * on some hardwares like Dell.
4899 *
4900 * The below flag enables the longer delay (see get_response
4901 * in hda_intel.c).
4902 */
4903 codec->bus->needs_damn_long_delay = 1;
4904
Takashi Iwaie28d8322008-12-17 13:48:29 +01004905 /* no jack detecion for ref-no-jd model */
4906 if (spec->board_config == STAC_D965_REF_NO_JD)
4907 spec->hp_detect = 0;
4908
Matt2f2f4252005-04-13 14:45:30 +02004909 return 0;
4910}
4911
Matt Porterf3302a52006-07-31 12:49:34 +02004912static int patch_stac9205(struct hda_codec *codec)
4913{
4914 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004915 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004916
4917 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4918 if (spec == NULL)
4919 return -ENOMEM;
4920
4921 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004922 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004923 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004924 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4925 stac9205_models,
4926 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004927 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004928 if (spec->board_config < 0) {
4929 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4930 err = stac92xx_save_bios_config_regs(codec);
4931 if (err < 0) {
4932 stac92xx_free(codec);
4933 return err;
4934 }
4935 spec->pin_configs = spec->bios_pin_configs;
4936 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004937 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4938 stac92xx_set_config_regs(codec);
4939 }
4940
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004941 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004942 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004943 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004944 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004945 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004946 spec->smux_nids = stac9205_smux_nids;
4947 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004948 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004949 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004950 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004951 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004952 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004953
4954 spec->init = stac9205_core_init;
4955 spec->mixer = stac9205_mixer;
4956
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004957 spec->aloopback_mask = 0x40;
4958 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004959 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02004960 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004961
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004962 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004963 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004964 /* Enable SPDIF in/out */
4965 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4966 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004967
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004968 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004969 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004970 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4971 snd_hda_codec_write_cache(codec, codec->afg, 0,
4972 AC_VERB_SET_UNSOLICITED_ENABLE,
4973 (AC_USRSP_EN | STAC_HP_EVENT));
4974
4975 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004976 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004977 spec->gpio_mask = 0x1b;
4978 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004979 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004980 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004981 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004982 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004983 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004984 case STAC_9205_REF:
4985 /* SPDIF-In enabled */
4986 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004987 default:
4988 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004989 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004990 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004991 break;
4992 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004993
Matt Porterf3302a52006-07-31 12:49:34 +02004994 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004995 if (!err) {
4996 if (spec->board_config < 0) {
4997 printk(KERN_WARNING "hda_codec: No auto-config is "
4998 "available, default to model=ref\n");
4999 spec->board_config = STAC_9205_REF;
5000 goto again;
5001 }
5002 err = -EINVAL;
5003 }
Matt Porterf3302a52006-07-31 12:49:34 +02005004 if (err < 0) {
5005 stac92xx_free(codec);
5006 return err;
5007 }
5008
5009 codec->patch_ops = stac92xx_patch_ops;
5010
5011 return 0;
5012}
5013
Matt2f2f4252005-04-13 14:45:30 +02005014/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005015 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005016 */
5017
Guillaume Munch99ccc562006-08-16 19:35:12 +02005018/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005019static hda_nid_t vaio_dacs[] = { 0x2 };
5020#define VAIO_HP_DAC 0x5
5021static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5022static hda_nid_t vaio_mux_nids[] = { 0x15 };
5023
5024static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005025 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005026 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005027 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005028 { "Mic Jack", 0x1 },
5029 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005030 { "PCM", 0x3 },
5031 }
5032};
5033
5034static struct hda_verb vaio_init[] = {
5035 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005036 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005037 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5038 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5039 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005041 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005042 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5043 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5044 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5046 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5047 {}
5048};
5049
Guillaume Munch6d859062006-08-22 17:15:47 +02005050static struct hda_verb vaio_ar_init[] = {
5051 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5052 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5053 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5054 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5055/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005057 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005058 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5059 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5060/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5064 {}
5065};
5066
Takashi Iwaidb064e52006-03-16 16:04:58 +01005067/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005068static struct hda_bind_ctls vaio_bind_master_vol = {
5069 .ops = &snd_hda_bind_vol,
5070 .values = {
5071 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5072 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5073 0
5074 },
5075};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005076
5077/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005078static struct hda_bind_ctls vaio_bind_master_sw = {
5079 .ops = &snd_hda_bind_sw,
5080 .values = {
5081 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5082 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5083 0,
5084 },
5085};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005086
5087static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005088 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5089 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005090 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5091 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5092 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5093 {
5094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5095 .name = "Capture Source",
5096 .count = 1,
5097 .info = stac92xx_mux_enum_info,
5098 .get = stac92xx_mux_enum_get,
5099 .put = stac92xx_mux_enum_put,
5100 },
5101 {}
5102};
5103
Guillaume Munch6d859062006-08-22 17:15:47 +02005104static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005105 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5106 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02005107 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5108 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5109 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5110 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5111 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5112 {
5113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5114 .name = "Capture Source",
5115 .count = 1,
5116 .info = stac92xx_mux_enum_info,
5117 .get = stac92xx_mux_enum_get,
5118 .put = stac92xx_mux_enum_put,
5119 },
5120 {}
5121};
5122
5123static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005124 .build_controls = stac92xx_build_controls,
5125 .build_pcms = stac92xx_build_pcms,
5126 .init = stac92xx_init,
5127 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005128#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005129 .resume = stac92xx_resume,
5130#endif
5131};
5132
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005133static int stac9872_vaio_init(struct hda_codec *codec)
5134{
5135 int err;
5136
5137 err = stac92xx_init(codec);
5138 if (err < 0)
5139 return err;
5140 if (codec->patch_ops.unsol_event)
5141 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5142 return 0;
5143}
5144
5145static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5146{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005147 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005148 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5149 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5150 } else {
5151 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5152 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5153 }
5154}
5155
5156static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5157{
5158 switch (res >> 26) {
5159 case STAC_HP_EVENT:
5160 stac9872_vaio_hp_detect(codec, res);
5161 break;
5162 }
5163}
5164
5165static struct hda_codec_ops stac9872_vaio_patch_ops = {
5166 .build_controls = stac92xx_build_controls,
5167 .build_pcms = stac92xx_build_pcms,
5168 .init = stac9872_vaio_init,
5169 .free = stac92xx_free,
5170 .unsol_event = stac9872_vaio_unsol_event,
5171#ifdef CONFIG_PM
5172 .resume = stac92xx_resume,
5173#endif
5174};
5175
Guillaume Munch6d859062006-08-22 17:15:47 +02005176enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5177 CXD9872RD_VAIO,
5178 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5179 STAC9872AK_VAIO,
5180 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5181 STAC9872K_VAIO,
5182 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005183 CXD9872AKD_VAIO,
5184 STAC_9872_MODELS,
5185};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005186
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005187static const char *stac9872_models[STAC_9872_MODELS] = {
5188 [CXD9872RD_VAIO] = "vaio",
5189 [CXD9872AKD_VAIO] = "vaio-ar",
5190};
5191
5192static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5193 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5194 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5195 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005196 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005197 {}
5198};
5199
Guillaume Munch6d859062006-08-22 17:15:47 +02005200static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005201{
5202 struct sigmatel_spec *spec;
5203 int board_config;
5204
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005205 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5206 stac9872_models,
5207 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005208 if (board_config < 0)
5209 /* unknown config, let generic-parser do its job... */
5210 return snd_hda_parse_generic_codec(codec);
5211
5212 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5213 if (spec == NULL)
5214 return -ENOMEM;
5215
5216 codec->spec = spec;
5217 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005218 case CXD9872RD_VAIO:
5219 case STAC9872AK_VAIO:
5220 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005221 spec->mixer = vaio_mixer;
5222 spec->init = vaio_init;
5223 spec->multiout.max_channels = 2;
5224 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5225 spec->multiout.dac_nids = vaio_dacs;
5226 spec->multiout.hp_nid = VAIO_HP_DAC;
5227 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5228 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005229 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005230 spec->input_mux = &vaio_mux;
5231 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005232 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005233 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005234
5235 case CXD9872AKD_VAIO:
5236 spec->mixer = vaio_ar_mixer;
5237 spec->init = vaio_ar_init;
5238 spec->multiout.max_channels = 2;
5239 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5240 spec->multiout.dac_nids = vaio_dacs;
5241 spec->multiout.hp_nid = VAIO_HP_DAC;
5242 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005243 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005244 spec->adc_nids = vaio_adcs;
5245 spec->input_mux = &vaio_mux;
5246 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005247 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005248 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005249 }
5250
Takashi Iwaidb064e52006-03-16 16:04:58 +01005251 return 0;
5252}
5253
5254
5255/*
Matt2f2f4252005-04-13 14:45:30 +02005256 * patch entries
5257 */
5258struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5259 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5260 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5261 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5262 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5263 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5264 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5265 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005266 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5267 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5268 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5269 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5270 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5271 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005272 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5273 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5274 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5275 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5276 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5277 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5278 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5279 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5280 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5281 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005282 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5283 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5284 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5285 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5286 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5287 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005288 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5289 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005290 /* The following does not take into account .id=0x83847661 when subsys =
5291 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5292 * currently not fully supported.
5293 */
5294 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5295 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5296 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005297 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5298 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5299 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5300 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5301 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5302 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5303 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5304 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005305 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005306 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5307 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005308 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005309 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5310 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005311 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005312 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5313 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5314 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5315 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5316 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5317 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5318 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5319 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005320 {} /* terminator */
5321};