blob: 3029f5b1419ac9d0d7459442dab359a2dfe6537d [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>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040033#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010036#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020037#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020038
Matthew Ranostayc39555d2008-11-14 17:46:22 -050039#define STAC_VREF_EVENT 0x00
Matthew Ranostay74aeaab2008-10-25 01:06:04 -040040#define STAC_INSERT_EVENT 0x10
Matthew Ranostaya64135a2008-01-10 16:55:06 +010041#define STAC_PWR_EVENT 0x20
42#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020043
Takashi Iwaif5fcc132006-11-24 17:07:44 +010044enum {
45 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010046 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020047 STAC_9200_DELL_D21,
48 STAC_9200_DELL_D22,
49 STAC_9200_DELL_D23,
50 STAC_9200_DELL_M21,
51 STAC_9200_DELL_M22,
52 STAC_9200_DELL_M23,
53 STAC_9200_DELL_M24,
54 STAC_9200_DELL_M25,
55 STAC_9200_DELL_M26,
56 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020057 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010058 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010059 STAC_9200_MODELS
60};
61
62enum {
63 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020064 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020065 STAC_9205_DELL_M43,
66 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010067 STAC_9205_MODELS
68};
69
70enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010071 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010072 STAC_DELL_M6,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050073 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010074 STAC_92HD73XX_MODELS
75};
76
77enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020078 STAC_92HD83XXX_REF,
79 STAC_92HD83XXX_MODELS
80};
81
82enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010083 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010084 STAC_DELL_M4_1,
85 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040086 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010087 STAC_92HD71BXX_MODELS
88};
89
90enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010091 STAC_925x_REF,
92 STAC_M2_2,
93 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020094 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010095 STAC_925x_MODELS
96};
97
98enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010099 STAC_D945_REF,
100 STAC_D945GTP3,
101 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200102 STAC_INTEL_MAC_V1,
103 STAC_INTEL_MAC_V2,
104 STAC_INTEL_MAC_V3,
105 STAC_INTEL_MAC_V4,
106 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800107 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
108 * is given, one of the above models will be
109 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200110 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100111 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100112 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100113 STAC_MACBOOK_PRO_V1,
114 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200115 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200116 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300117 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200118 STAC_922X_DELL_D81,
119 STAC_922X_DELL_D82,
120 STAC_922X_DELL_M81,
121 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100122 STAC_922X_MODELS
123};
124
125enum {
126 STAC_D965_REF,
127 STAC_D965_3ST,
128 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200129 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100130 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100131 STAC_927X_MODELS
132};
Matt Porter403d1942005-11-29 15:00:51 +0100133
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400134struct sigmatel_event {
135 hda_nid_t nid;
136 int data;
137};
138
139struct sigmatel_jack {
140 hda_nid_t nid;
141 int type;
142 struct snd_jack *jack;
143};
144
Matt2f2f4252005-04-13 14:45:30 +0200145struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100146 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200147 unsigned int num_mixers;
148
Matt Porter403d1942005-11-29 15:00:51 +0100149 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500150 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200151 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100152 unsigned int line_switch: 1;
153 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100154 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100155 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400156 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200157
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100158 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200159 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100160 unsigned int gpio_mask;
161 unsigned int gpio_dir;
162 unsigned int gpio_data;
163 unsigned int gpio_mute;
164
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200165 /* stream */
166 unsigned int stream_delay;
167
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100168 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100169 unsigned char aloopback_mask;
170 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200171
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100172 /* power management */
173 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200174 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100175 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100176 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100177
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400178 /* jack detection */
179 struct snd_array jacks;
180
181 /* events */
182 struct snd_array events;
183
Matt2f2f4252005-04-13 14:45:30 +0200184 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100185 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400186 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100187 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200188 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100189 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200190
191 /* capture */
192 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200193 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200194 hda_nid_t *mux_nids;
195 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200196 hda_nid_t *dmic_nids;
197 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100198 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100199 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200200 hda_nid_t *smux_nids;
201 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400202 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200203
Mattdabbed62005-06-14 10:19:34 +0200204 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100205 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200206 hda_nid_t anabeep_nid;
207 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200208
Matt2f2f4252005-04-13 14:45:30 +0200209 /* pin widgets */
210 hda_nid_t *pin_nids;
211 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200212 unsigned int *pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200213
214 /* codec specific stuff */
215 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100216 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200217
218 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200219 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100220 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200221 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100222 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200223 struct hda_input_mux *sinput_mux;
224 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400225 unsigned int cur_amux;
226 hda_nid_t *amp_nids;
227 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200228 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200229
Matt Porter403d1942005-11-29 15:00:51 +0100230 /* i/o switches */
231 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200232 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100233 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200234 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200235
Mattc7d4b2f2005-06-27 14:59:41 +0200236 struct hda_pcm pcm_rec[2]; /* PCM information */
237
238 /* dynamic controls and input_mux */
239 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200240 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200241 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200242 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200243 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400244 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100245 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200246};
247
248static hda_nid_t stac9200_adc_nids[1] = {
249 0x03,
250};
251
252static hda_nid_t stac9200_mux_nids[1] = {
253 0x0c,
254};
255
256static hda_nid_t stac9200_dac_nids[1] = {
257 0x02,
258};
259
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100260static hda_nid_t stac92hd73xx_pwr_nids[8] = {
261 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
262 0x0f, 0x10, 0x11
263};
264
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400265static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
266 0x26, 0,
267};
268
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100269static hda_nid_t stac92hd73xx_adc_nids[2] = {
270 0x1a, 0x1b
271};
272
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400273#define DELL_M6_AMP 2
274static hda_nid_t stac92hd73xx_amp_nids[3] = {
275 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400276};
277
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100278#define STAC92HD73XX_NUM_DMICS 2
279static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
280 0x13, 0x14, 0
281};
282
283#define STAC92HD73_DAC_COUNT 5
284static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
285 0x15, 0x16, 0x17, 0x18, 0x19,
286};
287
288static hda_nid_t stac92hd73xx_mux_nids[4] = {
289 0x28, 0x29, 0x2a, 0x2b,
290};
291
292static hda_nid_t stac92hd73xx_dmux_nids[2] = {
293 0x20, 0x21,
294};
295
Matthew Ranostayd9737752008-09-07 12:03:41 +0200296static hda_nid_t stac92hd73xx_smux_nids[2] = {
297 0x22, 0x23,
298};
299
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200300#define STAC92HD83XXX_NUM_DMICS 2
301static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
302 0x11, 0x12, 0
303};
304
305#define STAC92HD81_DAC_COUNT 2
306#define STAC92HD83_DAC_COUNT 3
307static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
308 0x13, 0x14, 0x22,
309};
310
311static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
312 0x17, 0x18,
313};
314
315static hda_nid_t stac92hd83xxx_adc_nids[2] = {
316 0x15, 0x16,
317};
318
319static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
320 0xa, 0xb, 0xd, 0xe,
321};
322
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400323static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
324 0x1e, 0,
325};
326
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200327static unsigned int stac92hd83xxx_pwr_mapping[4] = {
328 0x03, 0x0c, 0x10, 0x40,
329};
330
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100331static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
332 0x0a, 0x0d, 0x0f
333};
334
Matthew Ranostaye035b842007-11-06 11:53:55 +0100335static hda_nid_t stac92hd71bxx_adc_nids[2] = {
336 0x12, 0x13,
337};
338
339static hda_nid_t stac92hd71bxx_mux_nids[2] = {
340 0x1a, 0x1b
341};
342
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400343static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
344 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345};
346
Matthew Ranostayd9737752008-09-07 12:03:41 +0200347static hda_nid_t stac92hd71bxx_smux_nids[2] = {
348 0x24, 0x25,
349};
350
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100351static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100352 0x10, /*0x11, */
353};
354
355#define STAC92HD71BXX_NUM_DMICS 2
356static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
357 0x18, 0x19, 0
358};
359
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400360static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
361 0x22, 0
362};
363
Tobin Davis8e21c342007-01-08 11:04:17 +0100364static hda_nid_t stac925x_adc_nids[1] = {
365 0x03,
366};
367
368static hda_nid_t stac925x_mux_nids[1] = {
369 0x0f,
370};
371
372static hda_nid_t stac925x_dac_nids[1] = {
373 0x02,
374};
375
Takashi Iwaif6e98522007-10-16 14:27:04 +0200376#define STAC925X_NUM_DMICS 1
377static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
378 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200379};
380
Takashi Iwai1697055e2007-12-18 18:05:52 +0100381static hda_nid_t stac925x_dmux_nids[1] = {
382 0x14,
383};
384
Matt2f2f4252005-04-13 14:45:30 +0200385static hda_nid_t stac922x_adc_nids[2] = {
386 0x06, 0x07,
387};
388
389static hda_nid_t stac922x_mux_nids[2] = {
390 0x12, 0x13,
391};
392
Matt Porter3cc08dc2006-01-23 15:27:49 +0100393static hda_nid_t stac927x_adc_nids[3] = {
394 0x07, 0x08, 0x09
395};
396
397static hda_nid_t stac927x_mux_nids[3] = {
398 0x15, 0x16, 0x17
399};
400
Matthew Ranostayd9737752008-09-07 12:03:41 +0200401static hda_nid_t stac927x_smux_nids[1] = {
402 0x21,
403};
404
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100405static hda_nid_t stac927x_dac_nids[6] = {
406 0x02, 0x03, 0x04, 0x05, 0x06, 0
407};
408
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100409static hda_nid_t stac927x_dmux_nids[1] = {
410 0x1b,
411};
412
Matthew Ranostay7f168592007-10-18 17:38:17 +0200413#define STAC927X_NUM_DMICS 2
414static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
415 0x13, 0x14, 0
416};
417
Matthew Ranostay65973632008-09-16 10:39:37 -0400418static const char *stac927x_spdif_labels[5] = {
419 "Digital Playback", "ADAT", "Analog Mux 1",
420 "Analog Mux 2", "Analog Mux 3"
421};
422
Matt Porterf3302a52006-07-31 12:49:34 +0200423static hda_nid_t stac9205_adc_nids[2] = {
424 0x12, 0x13
425};
426
427static hda_nid_t stac9205_mux_nids[2] = {
428 0x19, 0x1a
429};
430
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100431static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100432 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100433};
434
Matthew Ranostayd9737752008-09-07 12:03:41 +0200435static hda_nid_t stac9205_smux_nids[1] = {
436 0x21,
437};
438
Takashi Iwaif6e98522007-10-16 14:27:04 +0200439#define STAC9205_NUM_DMICS 2
440static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
441 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200442};
443
Mattc7d4b2f2005-06-27 14:59:41 +0200444static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200445 0x08, 0x09, 0x0d, 0x0e,
446 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200447};
448
Tobin Davis8e21c342007-01-08 11:04:17 +0100449static hda_nid_t stac925x_pin_nids[8] = {
450 0x07, 0x08, 0x0a, 0x0b,
451 0x0c, 0x0d, 0x10, 0x11,
452};
453
Matt2f2f4252005-04-13 14:45:30 +0200454static hda_nid_t stac922x_pin_nids[10] = {
455 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
456 0x0f, 0x10, 0x11, 0x15, 0x1b,
457};
458
Matthew Ranostaya7662642008-02-21 07:51:14 +0100459static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100460 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
461 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200462 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100463};
464
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200465static hda_nid_t stac92hd83xxx_pin_nids[14] = {
466 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
467 0x0f, 0x10, 0x11, 0x12, 0x13,
468 0x1d, 0x1e, 0x1f, 0x20
469};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400470static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100471 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
472 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400473 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100474};
475
Matt Porter3cc08dc2006-01-23 15:27:49 +0100476static hda_nid_t stac927x_pin_nids[14] = {
477 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
478 0x0f, 0x10, 0x11, 0x12, 0x13,
479 0x14, 0x21, 0x22, 0x23,
480};
481
Matt Porterf3302a52006-07-31 12:49:34 +0200482static hda_nid_t stac9205_pin_nids[12] = {
483 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
484 0x0f, 0x14, 0x16, 0x17, 0x18,
485 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200486};
487
Matthew Ranostay89385032008-09-11 09:49:39 -0400488#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
489
490static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_value *ucontrol)
492{
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct sigmatel_spec *spec = codec->spec;
495 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
496
497 kcontrol->private_value ^= get_amp_nid(kcontrol);
498 kcontrol->private_value |= nid;
499
500 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
501}
502
503static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_value *ucontrol)
505{
506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
507 struct sigmatel_spec *spec = codec->spec;
508 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
509
510 kcontrol->private_value ^= get_amp_nid(kcontrol);
511 kcontrol->private_value |= nid;
512
513 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
514}
515
Matt Porter8b657272006-10-26 17:12:59 +0200516static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
518{
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct sigmatel_spec *spec = codec->spec;
521 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
522}
523
524static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100529 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200530
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100531 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200532 return 0;
533}
534
535static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100540 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200541
542 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100543 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200544}
545
Matthew Ranostayd9737752008-09-07 12:03:41 +0200546static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_info *uinfo)
548{
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct sigmatel_spec *spec = codec->spec;
551 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
552}
553
554static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
555 struct snd_ctl_elem_value *ucontrol)
556{
557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
558 struct sigmatel_spec *spec = codec->spec;
559 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
560
561 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
562 return 0;
563}
564
565static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
566 struct snd_ctl_elem_value *ucontrol)
567{
568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
569 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400570 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200571 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400572 int err, val;
573 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200574
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400575 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200576 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400577 if (err < 0)
578 return err;
579
580 if (spec->spdif_mute) {
581 if (smux_idx == 0)
582 nid = spec->multiout.dig_out_nid;
583 else
584 nid = codec->slave_dig_outs[smux_idx - 1];
585 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
586 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400587 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100588 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400589 /* un/mute SPDIF out */
590 snd_hda_codec_write_cache(codec, nid, 0,
591 AC_VERB_SET_AMP_GAIN_MUTE, val);
592 }
593 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200594}
595
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100596static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200597{
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200600 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200601}
602
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100603static int stac92xx_mux_enum_get(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
609 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
610 return 0;
611}
612
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100613static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200614{
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 struct sigmatel_spec *spec = codec->spec;
617 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
618
Mattc7d4b2f2005-06-27 14:59:41 +0200619 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200620 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
621}
622
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100623static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_info *uinfo)
625{
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
629}
630
631static int stac92xx_mono_mux_enum_get(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 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
638 return 0;
639}
640
641static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
646
647 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
648 spec->mono_nid, &spec->cur_mmux);
649}
650
Matthew Ranostay89385032008-09-11 09:49:39 -0400651static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_info *uinfo)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
657}
658
659static int stac92xx_amp_mux_enum_get(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
665 ucontrol->value.enumerated.item[0] = spec->cur_amux;
666 return 0;
667}
668
669static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
670 struct snd_ctl_elem_value *ucontrol)
671{
672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
673 struct sigmatel_spec *spec = codec->spec;
674 struct snd_kcontrol *ctl =
675 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
676 if (!ctl)
677 return -EINVAL;
678
679 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
680 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
681
682 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
683 0, &spec->cur_amux);
684}
685
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200686#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
687
688static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
689 struct snd_ctl_elem_value *ucontrol)
690{
691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100692 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200693 struct sigmatel_spec *spec = codec->spec;
694
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100695 ucontrol->value.integer.value[0] = !!(spec->aloopback &
696 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200697 return 0;
698}
699
700static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
702{
703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
704 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100705 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200706 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100707 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200708
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100709 idx_val = spec->aloopback_mask << idx;
710 if (ucontrol->value.integer.value[0])
711 val = spec->aloopback | idx_val;
712 else
713 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100714 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200715 return 0;
716
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100717 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200718
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100719 /* Only return the bits defined by the shift value of the
720 * first two bytes of the mask
721 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200722 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100723 kcontrol->private_value & 0xFFFF, 0x0);
724 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200725
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100726 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200727 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100728 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200729 } else {
730 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100731 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200732 }
733
734 snd_hda_codec_write_cache(codec, codec->afg, 0,
735 kcontrol->private_value >> 16, dac_mode);
736
737 return 1;
738}
739
Mattc7d4b2f2005-06-27 14:59:41 +0200740static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200741 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200742 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200743 {}
744};
745
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200746static struct hda_verb stac9200_eapd_init[] = {
747 /* set dac0mux for dac converter */
748 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
749 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
750 {}
751};
752
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100753static struct hda_verb stac92hd73xx_6ch_core_init[] = {
754 /* set master volume and direct control */
755 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
756 /* setup audio connections */
757 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
758 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
760 /* setup adcs to point to mixer */
761 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
762 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100763 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
764 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
765 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
766 /* setup import muxs */
767 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
768 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
771 {}
772};
773
Matthew Ranostayd654a662008-03-14 08:46:51 +0100774static struct hda_verb dell_eq_core_init[] = {
775 /* set master volume to max value without distortion
776 * and direct control */
777 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
778 /* setup audio connections */
779 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400780 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
781 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100782 /* setup adcs to point to mixer */
783 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
784 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 /* setup import muxs */
786 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
787 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
790 {}
791};
792
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100793static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500794 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100795 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100796 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
797 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100798 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
799 /* setup adcs to point to mixer */
800 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
801 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
802 /* setup import muxs */
803 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
804 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
807 {}
808};
809
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100810static struct hda_verb stac92hd73xx_8ch_core_init[] = {
811 /* set master volume and direct control */
812 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
813 /* setup audio connections */
814 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
815 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
817 /* connect hp ports to dac3 */
818 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
819 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
820 /* setup adcs to point to mixer */
821 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
822 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100823 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
824 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 /* setup import muxs */
827 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
828 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
829 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
830 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
831 {}
832};
833
834static struct hda_verb stac92hd73xx_10ch_core_init[] = {
835 /* set master volume and direct control */
836 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
837 /* setup audio connections */
838 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
839 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
840 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
841 /* dac3 is connected to import3 mux */
842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
843 /* connect hp ports to dac4 */
844 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
845 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
846 /* setup adcs to point to mixer */
847 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
848 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100849 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
850 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
851 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
852 /* setup import muxs */
853 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
854 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
855 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
856 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
857 {}
858};
859
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200860static struct hda_verb stac92hd83xxx_core_init[] = {
861 /* start of config #1 */
862 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
863
864 /* start of config #2 */
865 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
866 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
867 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
868
869 /* power state controls amps */
870 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
871};
872
Matthew Ranostaye035b842007-11-06 11:53:55 +0100873static struct hda_verb stac92hd71bxx_core_init[] = {
874 /* set master volume and direct control */
875 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
876 /* connect headphone jack to dac1 */
877 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100878 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
879 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
880 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
881 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100882};
883
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400884#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100885static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200886 /* start of config #1 */
887
888 /* connect port 0f to audio mixer */
889 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200890 /* unmute right and left channels for node 0x0f */
891 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
892 /* start of config #2 */
893
Matthew Ranostay541eee82007-12-14 12:08:04 +0100894 /* set master volume and direct control */
895 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
896 /* connect headphone jack to dac1 */
897 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200898 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100899 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
900 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100901 {}
902};
903
Tobin Davis8e21c342007-01-08 11:04:17 +0100904static struct hda_verb stac925x_core_init[] = {
905 /* set dac0mux for dac converter */
906 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
907 {}
908};
909
Mattc7d4b2f2005-06-27 14:59:41 +0200910static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200911 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200912 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200913 {}
914};
915
Tobin Davis93ed1502006-09-01 21:03:12 +0200916static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200917 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200918 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200919 /* unmute node 0x1b */
920 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
921 /* select node 0x03 as DAC */
922 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
923 {}
924};
925
Matt Porter3cc08dc2006-01-23 15:27:49 +0100926static struct hda_verb stac927x_core_init[] = {
927 /* set master volume and direct control */
928 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200929 /* enable analog pc beep path */
930 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100931 {}
932};
933
Matt Porterf3302a52006-07-31 12:49:34 +0200934static struct hda_verb stac9205_core_init[] = {
935 /* set master volume and direct control */
936 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200937 /* enable analog pc beep path */
938 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200939 {}
940};
941
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100942#define STAC_MONO_MUX \
943 { \
944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
945 .name = "Mono Mux", \
946 .count = 1, \
947 .info = stac92xx_mono_mux_enum_info, \
948 .get = stac92xx_mono_mux_enum_get, \
949 .put = stac92xx_mono_mux_enum_put, \
950 }
951
Matthew Ranostay89385032008-09-11 09:49:39 -0400952#define STAC_AMP_MUX \
953 { \
954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
955 .name = "Amp Selector Capture Switch", \
956 .count = 1, \
957 .info = stac92xx_amp_mux_enum_info, \
958 .get = stac92xx_amp_mux_enum_get, \
959 .put = stac92xx_amp_mux_enum_put, \
960 }
961
962#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
963 { \
964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
965 .name = xname, \
966 .index = 0, \
967 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
968 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
969 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
970 .info = stac92xx_amp_volume_info, \
971 .get = stac92xx_amp_volume_get, \
972 .put = stac92xx_amp_volume_put, \
973 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
974 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
975 }
976
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200977#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200978 { \
979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
980 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200981 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200982 .info = stac92xx_mux_enum_info, \
983 .get = stac92xx_mux_enum_get, \
984 .put = stac92xx_mux_enum_put, \
985 }
986
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100987#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200988 { \
989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
990 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100991 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200992 .info = stac92xx_aloopback_info, \
993 .get = stac92xx_aloopback_get, \
994 .put = stac92xx_aloopback_put, \
995 .private_value = verb_read | (verb_write << 16), \
996 }
997
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100998static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200999 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1000 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001001 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +02001002 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1003 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001004 { } /* end */
1005};
1006
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001007#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001008static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001009 /* start of config #1 */
1010 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1011 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1012
1013 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1014 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1015
1016 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1017 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1018
1019 /* start of config #2 */
1020 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1021 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1022
1023 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1024 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1025
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001026 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1027
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001028 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1029 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1030
1031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1033
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001034 { } /* end */
1035};
1036
1037static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001038 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1039
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001040 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1041 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1042
1043 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1044 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1045
1046 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1047 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1048
1049 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1050 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1051
1052 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1053 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1054
1055 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1056 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1057
1058 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1059 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1060 { } /* end */
1061};
1062
1063static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001064 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1065
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001066 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1067 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1068
1069 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1070 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1071
1072 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1073 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1074
1075 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1076 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1077
1078 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1079 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1080
1081 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1082 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1083
1084 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1085 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1086 { } /* end */
1087};
1088
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001089
1090static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1091 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1092 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1093
1094 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1095 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1096
1097 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1098 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1099
1100 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1101 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1102
1103 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1104 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1105
1106 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1107 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1108
1109 /*
1110 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1111 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1112 */
1113 { } /* end */
1114};
1115
Matthew Ranostay541eee82007-12-14 12:08:04 +01001116static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001117 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001118 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001119
Matthew Ranostay9b359472007-11-07 13:03:12 +01001120 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001122
1123 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001125 /* analog pc-beep replaced with digital beep support */
1126 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001127 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1128 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001129 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001130
Matthew Ranostay687cb982008-10-11 13:52:43 -04001131 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1132 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001133
Matthew Ranostay687cb982008-10-11 13:52:43 -04001134 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001136
1137 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1138 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1139
1140 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1141 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001142 { } /* end */
1143};
1144
Matthew Ranostay541eee82007-12-14 12:08:04 +01001145static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001146 STAC_INPUT_SOURCE(2),
1147 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1148
Matthew Ranostay541eee82007-12-14 12:08:04 +01001149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001151
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001154 { } /* end */
1155};
1156
Tobin Davis8e21c342007-01-08 11:04:17 +01001157static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001158 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001159 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001160 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001161 { } /* end */
1162};
1163
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001164static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001165 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001166 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001167
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001170
1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001173 { } /* end */
1174};
1175
1176/* This needs to be generated dynamically based on sequence */
1177static struct snd_kcontrol_new stac922x_mixer[] = {
1178 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001181
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001184 { } /* end */
1185};
1186
1187
1188static struct snd_kcontrol_new stac927x_mixer[] = {
1189 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001190 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001191
1192 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1193 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001194
1195 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1196 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001197
1198 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1199 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001200 { } /* end */
1201};
1202
Takashi Iwai1697055e2007-12-18 18:05:52 +01001203static struct snd_kcontrol_new stac_dmux_mixer = {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1205 .name = "Digital Input Source",
1206 /* count set later */
1207 .info = stac92xx_dmux_enum_info,
1208 .get = stac92xx_dmux_enum_get,
1209 .put = stac92xx_dmux_enum_put,
1210};
1211
Matthew Ranostayd9737752008-09-07 12:03:41 +02001212static struct snd_kcontrol_new stac_smux_mixer = {
1213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001214 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001215 /* count set later */
1216 .info = stac92xx_smux_enum_info,
1217 .get = stac92xx_smux_enum_get,
1218 .put = stac92xx_smux_enum_put,
1219};
1220
Takashi Iwai2134ea42008-01-10 16:53:55 +01001221static const char *slave_vols[] = {
1222 "Front Playback Volume",
1223 "Surround Playback Volume",
1224 "Center Playback Volume",
1225 "LFE Playback Volume",
1226 "Side Playback Volume",
1227 "Headphone Playback Volume",
1228 "Headphone Playback Volume",
1229 "Speaker Playback Volume",
1230 "External Speaker Playback Volume",
1231 "Speaker2 Playback Volume",
1232 NULL
1233};
1234
1235static const char *slave_sws[] = {
1236 "Front Playback Switch",
1237 "Surround Playback Switch",
1238 "Center Playback Switch",
1239 "LFE Playback Switch",
1240 "Side Playback Switch",
1241 "Headphone Playback Switch",
1242 "Headphone Playback Switch",
1243 "Speaker Playback Switch",
1244 "External Speaker Playback Switch",
1245 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001246 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001247 NULL
1248};
1249
Takashi Iwai603c4012008-07-30 15:01:44 +02001250static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001251static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001252
Matt2f2f4252005-04-13 14:45:30 +02001253static int stac92xx_build_controls(struct hda_codec *codec)
1254{
1255 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001256 struct auto_pin_cfg *cfg = &spec->autocfg;
1257 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001258 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001259 int i;
Matt2f2f4252005-04-13 14:45:30 +02001260
1261 err = snd_hda_add_new_ctls(codec, spec->mixer);
1262 if (err < 0)
1263 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001264
1265 for (i = 0; i < spec->num_mixers; i++) {
1266 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1267 if (err < 0)
1268 return err;
1269 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001270 if (spec->num_dmuxes > 0) {
1271 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001272 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001273 snd_ctl_new1(&stac_dmux_mixer, codec));
1274 if (err < 0)
1275 return err;
1276 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001277 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001278 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1279 struct hda_input_mux *smux = &spec->private_smux;
1280 /* check for mute support on SPDIF out */
1281 if (wcaps & AC_WCAP_OUT_AMP) {
1282 smux->items[smux->num_items].label = "Off";
1283 smux->items[smux->num_items].index = 0;
1284 smux->num_items++;
1285 spec->spdif_mute = 1;
1286 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001287 stac_smux_mixer.count = spec->num_smuxes;
1288 err = snd_ctl_add(codec->bus->card,
1289 snd_ctl_new1(&stac_smux_mixer, codec));
1290 if (err < 0)
1291 return err;
1292 }
Mattc7d4b2f2005-06-27 14:59:41 +02001293
Mattdabbed62005-06-14 10:19:34 +02001294 if (spec->multiout.dig_out_nid) {
1295 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1296 if (err < 0)
1297 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001298 err = snd_hda_create_spdif_share_sw(codec,
1299 &spec->multiout);
1300 if (err < 0)
1301 return err;
1302 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001303 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001304 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001305 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1306 if (err < 0)
1307 return err;
1308 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001309
1310 /* if we have no master control, let's create it */
1311 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001312 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001313 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001314 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001315 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001316 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001317 if (err < 0)
1318 return err;
1319 }
1320 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1321 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1322 NULL, slave_sws);
1323 if (err < 0)
1324 return err;
1325 }
1326
Takashi Iwai603c4012008-07-30 15:01:44 +02001327 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001328
1329 /* create jack input elements */
1330 if (spec->hp_detect) {
1331 for (i = 0; i < cfg->hp_outs; i++) {
1332 int type = SND_JACK_HEADPHONE;
1333 nid = cfg->hp_pins[i];
1334 /* jack detection */
1335 if (cfg->hp_outs == i)
1336 type |= SND_JACK_LINEOUT;
1337 err = stac92xx_add_jack(codec, nid, type);
1338 if (err < 0)
1339 return err;
1340 }
1341 }
1342 for (i = 0; i < cfg->line_outs; i++) {
1343 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1344 SND_JACK_LINEOUT);
1345 if (err < 0)
1346 return err;
1347 }
1348 for (i = 0; i < AUTO_PIN_LAST; i++) {
1349 nid = cfg->input_pins[i];
1350 if (nid) {
1351 err = stac92xx_add_jack(codec, nid,
1352 SND_JACK_MICROPHONE);
1353 if (err < 0)
1354 return err;
1355 }
1356 }
1357
Mattdabbed62005-06-14 10:19:34 +02001358 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001359}
1360
Matt Porter403d1942005-11-29 15:00:51 +01001361static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001362 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001363 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1364};
1365
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001366/*
1367 STAC 9200 pin configs for
1368 102801A8
1369 102801DE
1370 102801E8
1371*/
1372static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001373 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1374 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001375};
1376
1377/*
1378 STAC 9200 pin configs for
1379 102801C0
1380 102801C1
1381*/
1382static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001383 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1384 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001385};
1386
1387/*
1388 STAC 9200 pin configs for
1389 102801C4 (Dell Dimension E310)
1390 102801C5
1391 102801C7
1392 102801D9
1393 102801DA
1394 102801E3
1395*/
1396static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001397 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1398 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399};
1400
1401
1402/*
1403 STAC 9200-32 pin configs for
1404 102801B5 (Dell Inspiron 630m)
1405 102801D8 (Dell Inspiron 640m)
1406*/
1407static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001408 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1409 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001410};
1411
1412/*
1413 STAC 9200-32 pin configs for
1414 102801C2 (Dell Latitude D620)
1415 102801C8
1416 102801CC (Dell Latitude D820)
1417 102801D4
1418 102801D6
1419*/
1420static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001421 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1422 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001423};
1424
1425/*
1426 STAC 9200-32 pin configs for
1427 102801CE (Dell XPS M1710)
1428 102801CF (Dell Precision M90)
1429*/
1430static unsigned int dell9200_m23_pin_configs[8] = {
1431 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1432 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1433};
1434
1435/*
1436 STAC 9200-32 pin configs for
1437 102801C9
1438 102801CA
1439 102801CB (Dell Latitude 120L)
1440 102801D3
1441*/
1442static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001443 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1444 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001445};
1446
1447/*
1448 STAC 9200-32 pin configs for
1449 102801BD (Dell Inspiron E1505n)
1450 102801EE
1451 102801EF
1452*/
1453static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001454 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1455 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001456};
1457
1458/*
1459 STAC 9200-32 pin configs for
1460 102801F5 (Dell Inspiron 1501)
1461 102801F6
1462*/
1463static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001464 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1465 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001466};
1467
1468/*
1469 STAC 9200-32
1470 102801CD (Dell Inspiron E1705/9400)
1471*/
1472static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001473 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1474 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001475};
1476
Tobin Davisbf277782008-02-03 20:31:47 +01001477static unsigned int oqo9200_pin_configs[8] = {
1478 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1479 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1480};
1481
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001482
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001483static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1484 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001485 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001486 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1487 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1488 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1489 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1490 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1491 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1492 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1493 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1494 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1495 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001496 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001497};
1498
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001499static const char *stac9200_models[STAC_9200_MODELS] = {
1500 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001501 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001502 [STAC_9200_DELL_D21] = "dell-d21",
1503 [STAC_9200_DELL_D22] = "dell-d22",
1504 [STAC_9200_DELL_D23] = "dell-d23",
1505 [STAC_9200_DELL_M21] = "dell-m21",
1506 [STAC_9200_DELL_M22] = "dell-m22",
1507 [STAC_9200_DELL_M23] = "dell-m23",
1508 [STAC_9200_DELL_M24] = "dell-m24",
1509 [STAC_9200_DELL_M25] = "dell-m25",
1510 [STAC_9200_DELL_M26] = "dell-m26",
1511 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001512 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001513 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001514};
1515
1516static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1517 /* SigmaTel reference board */
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1519 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001520 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1522 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001524 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1526 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1528 "unknown Dell", STAC_9200_DELL_D22),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1530 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001532 "Dell Latitude D620", STAC_9200_DELL_M22),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1534 "unknown Dell", STAC_9200_DELL_D23),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1536 "unknown Dell", STAC_9200_DELL_D23),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1538 "unknown Dell", STAC_9200_DELL_M22),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1540 "unknown Dell", STAC_9200_DELL_M24),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1542 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001546 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001548 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001550 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001552 "Dell Precision M90", STAC_9200_DELL_M23),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1554 "unknown Dell", STAC_9200_DELL_M22),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1556 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001558 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001560 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1562 "unknown Dell", STAC_9200_DELL_D23),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1564 "unknown Dell", STAC_9200_DELL_D23),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1566 "unknown Dell", STAC_9200_DELL_D21),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1568 "unknown Dell", STAC_9200_DELL_D23),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1570 "unknown Dell", STAC_9200_DELL_D21),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1572 "unknown Dell", STAC_9200_DELL_M25),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1574 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001576 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1578 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001579 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001580 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001581 /* Gateway machines needs EAPD to be set on resume */
1582 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1583 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1584 STAC_9200_GATEWAY),
1585 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1586 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001587 /* OQO Mobile */
1588 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001589 {} /* terminator */
1590};
1591
Tobin Davis8e21c342007-01-08 11:04:17 +01001592static unsigned int ref925x_pin_configs[8] = {
1593 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001594 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001595};
1596
1597static unsigned int stac925x_MA6_pin_configs[8] = {
1598 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1599 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1600};
1601
Tobin Davis2c11f952007-05-17 09:36:34 +02001602static unsigned int stac925x_PA6_pin_configs[8] = {
1603 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1604 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1605};
1606
Tobin Davis8e21c342007-01-08 11:04:17 +01001607static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001608 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1609 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001610};
1611
1612static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1613 [STAC_REF] = ref925x_pin_configs,
1614 [STAC_M2_2] = stac925xM2_2_pin_configs,
1615 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001616 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001617};
1618
1619static const char *stac925x_models[STAC_925x_MODELS] = {
1620 [STAC_REF] = "ref",
1621 [STAC_M2_2] = "m2-2",
1622 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001623 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001624};
1625
1626static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1627 /* SigmaTel reference board */
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001629 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001630 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1631 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1632 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001633 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001634 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1635 {} /* terminator */
1636};
1637
Matthew Ranostaya7662642008-02-21 07:51:14 +01001638static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001639 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1640 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1641 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001642 0x01452050,
1643};
1644
1645static unsigned int dell_m6_pin_configs[13] = {
1646 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001647 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001648 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1649 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001650};
1651
1652static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001653 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1654 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001655 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001656};
1657
1658static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1659 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001660 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001661 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001662};
1663
1664static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1665 /* SigmaTel reference board */
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001667 "DFI LanParty", STAC_92HD73XX_REF),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1669 "unknown Dell", STAC_DELL_M6),
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1671 "unknown Dell", STAC_DELL_M6),
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1673 "unknown Dell", STAC_DELL_M6),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1675 "unknown Dell", STAC_DELL_M6),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1677 "unknown Dell", STAC_DELL_M6),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1679 "unknown Dell", STAC_DELL_M6),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1681 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001682 {} /* terminator */
1683};
1684
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001685static unsigned int ref92hd83xxx_pin_configs[14] = {
1686 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1687 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1688 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1689 0x01451160, 0x98560170,
1690};
1691
1692static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1693 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1694};
1695
1696static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1697 [STAC_92HD83XXX_REF] = "ref",
1698};
1699
1700static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1701 /* SigmaTel reference board */
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1703 "DFI LanParty", STAC_92HD71BXX_REF),
1704};
1705
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001706static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001707 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001708 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001709 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001710};
1711
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001712static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001713 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001714 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001715 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001716};
1717
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001718static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001719 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1720 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001721 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001722};
1723
Matthew Ranostaye035b842007-11-06 11:53:55 +01001724static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1725 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001726 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1727 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001728 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001729};
1730
1731static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1732 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001733 [STAC_DELL_M4_1] = "dell-m4-1",
1734 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001735 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001736};
1737
1738static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1739 /* SigmaTel reference board */
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1741 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001742 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1743 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001744 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1745 "unknown Dell", STAC_DELL_M4_1),
1746 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1747 "unknown Dell", STAC_DELL_M4_1),
1748 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1749 "unknown Dell", STAC_DELL_M4_1),
1750 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1751 "unknown Dell", STAC_DELL_M4_1),
1752 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1753 "unknown Dell", STAC_DELL_M4_1),
1754 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1755 "unknown Dell", STAC_DELL_M4_1),
1756 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1757 "unknown Dell", STAC_DELL_M4_1),
1758 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1759 "unknown Dell", STAC_DELL_M4_2),
1760 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1761 "unknown Dell", STAC_DELL_M4_2),
1762 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1763 "unknown Dell", STAC_DELL_M4_2),
1764 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1765 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001766 {} /* terminator */
1767};
1768
Matt Porter403d1942005-11-29 15:00:51 +01001769static unsigned int ref922x_pin_configs[10] = {
1770 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1771 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001772 0x40000100, 0x40000100,
1773};
1774
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001775/*
1776 STAC 922X pin configs for
1777 102801A7
1778 102801AB
1779 102801A9
1780 102801D1
1781 102801D2
1782*/
1783static unsigned int dell_922x_d81_pin_configs[10] = {
1784 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1785 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1786 0x01813122, 0x400001f2,
1787};
1788
1789/*
1790 STAC 922X pin configs for
1791 102801AC
1792 102801D0
1793*/
1794static unsigned int dell_922x_d82_pin_configs[10] = {
1795 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1796 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1797 0x01813122, 0x400001f1,
1798};
1799
1800/*
1801 STAC 922X pin configs for
1802 102801BF
1803*/
1804static unsigned int dell_922x_m81_pin_configs[10] = {
1805 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1806 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1807 0x40C003f1, 0x405003f0,
1808};
1809
1810/*
1811 STAC 9221 A1 pin configs for
1812 102801D7 (Dell XPS M1210)
1813*/
1814static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001815 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1816 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001817 0x508003f3, 0x405003f4,
1818};
1819
Matt Porter403d1942005-11-29 15:00:51 +01001820static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001821 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001822 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1823 0x02a19120, 0x40000100,
1824};
1825
1826static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001827 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1828 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001829 0x02a19320, 0x40000100,
1830};
1831
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001832static unsigned int intel_mac_v1_pin_configs[10] = {
1833 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1834 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001835 0x400000fc, 0x400000fb,
1836};
1837
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001838static unsigned int intel_mac_v2_pin_configs[10] = {
1839 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1840 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001841 0x400000fc, 0x400000fb,
1842};
1843
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001844static unsigned int intel_mac_v3_pin_configs[10] = {
1845 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1846 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1847 0x400000fc, 0x400000fb,
1848};
1849
1850static unsigned int intel_mac_v4_pin_configs[10] = {
1851 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1852 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1853 0x400000fc, 0x400000fb,
1854};
1855
1856static unsigned int intel_mac_v5_pin_configs[10] = {
1857 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1858 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1859 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001860};
1861
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001862static unsigned int ecs202_pin_configs[10] = {
1863 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1864 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1865 0x9037012e, 0x40e000f2,
1866};
Takashi Iwai76c08822007-06-19 12:17:42 +02001867
Takashi Iwai19039bd2006-06-28 15:52:16 +02001868static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001869 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001870 [STAC_D945GTP3] = d945gtp3_pin_configs,
1871 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001872 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1873 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1874 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1875 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1876 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001877 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001878 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001879 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1880 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1881 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1882 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1883 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1884 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001885 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001886 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1887 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1888 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1889 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001890};
1891
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001892static const char *stac922x_models[STAC_922X_MODELS] = {
1893 [STAC_D945_REF] = "ref",
1894 [STAC_D945GTP5] = "5stack",
1895 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001896 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1897 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1898 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1899 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1900 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001901 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001902 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001903 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001904 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001905 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1906 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001907 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001908 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001909 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001910 [STAC_922X_DELL_D81] = "dell-d81",
1911 [STAC_922X_DELL_D82] = "dell-d82",
1912 [STAC_922X_DELL_M81] = "dell-m81",
1913 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001914};
1915
1916static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1917 /* SigmaTel reference board */
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1919 "DFI LanParty", STAC_D945_REF),
1920 /* Intel 945G based systems */
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1922 "Intel D945G", STAC_D945GTP3),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1924 "Intel D945G", STAC_D945GTP3),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1926 "Intel D945G", STAC_D945GTP3),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1928 "Intel D945G", STAC_D945GTP3),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1930 "Intel D945G", STAC_D945GTP3),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1932 "Intel D945G", STAC_D945GTP3),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1934 "Intel D945G", STAC_D945GTP3),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1936 "Intel D945G", STAC_D945GTP3),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1938 "Intel D945G", STAC_D945GTP3),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1940 "Intel D945G", STAC_D945GTP3),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1942 "Intel D945G", STAC_D945GTP3),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1944 "Intel D945G", STAC_D945GTP3),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1946 "Intel D945G", STAC_D945GTP3),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1948 "Intel D945G", STAC_D945GTP3),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1950 "Intel D945G", STAC_D945GTP3),
1951 /* Intel D945G 5-stack systems */
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1953 "Intel D945G", STAC_D945GTP5),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1955 "Intel D945G", STAC_D945GTP5),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1957 "Intel D945G", STAC_D945GTP5),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1959 "Intel D945G", STAC_D945GTP5),
1960 /* Intel 945P based systems */
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1962 "Intel D945P", STAC_D945GTP3),
1963 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1964 "Intel D945P", STAC_D945GTP3),
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1966 "Intel D945P", STAC_D945GTP3),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1968 "Intel D945P", STAC_D945GTP3),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1970 "Intel D945P", STAC_D945GTP3),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1972 "Intel D945P", STAC_D945GTP5),
1973 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001974 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001975 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001976 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001977 /* Dell systems */
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1979 "unknown Dell", STAC_922X_DELL_D81),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1981 "unknown Dell", STAC_922X_DELL_D81),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1983 "unknown Dell", STAC_922X_DELL_D81),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1985 "unknown Dell", STAC_922X_DELL_D82),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1987 "unknown Dell", STAC_922X_DELL_M81),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1989 "unknown Dell", STAC_922X_DELL_D82),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1991 "unknown Dell", STAC_922X_DELL_D81),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1993 "unknown Dell", STAC_922X_DELL_D81),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1995 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001996 /* ECS/PC Chips boards */
1997 SND_PCI_QUIRK(0x1019, 0x2144,
1998 "ECS/PC chips", STAC_ECS_202),
1999 SND_PCI_QUIRK(0x1019, 0x2608,
2000 "ECS/PC chips", STAC_ECS_202),
2001 SND_PCI_QUIRK(0x1019, 0x2633,
2002 "ECS/PC chips P17G/1333", STAC_ECS_202),
2003 SND_PCI_QUIRK(0x1019, 0x2811,
2004 "ECS/PC chips", STAC_ECS_202),
2005 SND_PCI_QUIRK(0x1019, 0x2812,
2006 "ECS/PC chips", STAC_ECS_202),
2007 SND_PCI_QUIRK(0x1019, 0x2813,
2008 "ECS/PC chips", STAC_ECS_202),
2009 SND_PCI_QUIRK(0x1019, 0x2814,
2010 "ECS/PC chips", STAC_ECS_202),
2011 SND_PCI_QUIRK(0x1019, 0x2815,
2012 "ECS/PC chips", STAC_ECS_202),
2013 SND_PCI_QUIRK(0x1019, 0x2816,
2014 "ECS/PC chips", STAC_ECS_202),
2015 SND_PCI_QUIRK(0x1019, 0x2817,
2016 "ECS/PC chips", STAC_ECS_202),
2017 SND_PCI_QUIRK(0x1019, 0x2818,
2018 "ECS/PC chips", STAC_ECS_202),
2019 SND_PCI_QUIRK(0x1019, 0x2819,
2020 "ECS/PC chips", STAC_ECS_202),
2021 SND_PCI_QUIRK(0x1019, 0x2820,
2022 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002023 {} /* terminator */
2024};
2025
Matt Porter3cc08dc2006-01-23 15:27:49 +01002026static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002027 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2028 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2029 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2030 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002031};
2032
Tobin Davis93ed1502006-09-01 21:03:12 +02002033static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002034 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2035 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2036 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2037 0x40000100, 0x40000100
2038};
2039
Tobin Davis93ed1502006-09-01 21:03:12 +02002040static unsigned int d965_5st_pin_configs[14] = {
2041 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2042 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2043 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2044 0x40000100, 0x40000100
2045};
2046
Tobin Davis4ff076e2007-08-07 11:48:12 +02002047static unsigned int dell_3st_pin_configs[14] = {
2048 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2049 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002050 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002051 0x40c003fc, 0x40000100
2052};
2053
Tobin Davis93ed1502006-09-01 21:03:12 +02002054static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002055 [STAC_D965_REF] = ref927x_pin_configs,
2056 [STAC_D965_3ST] = d965_3st_pin_configs,
2057 [STAC_D965_5ST] = d965_5st_pin_configs,
2058 [STAC_DELL_3ST] = dell_3st_pin_configs,
2059 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002060};
2061
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002062static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002063 [STAC_D965_REF] = "ref",
2064 [STAC_D965_3ST] = "3stack",
2065 [STAC_D965_5ST] = "5stack",
2066 [STAC_DELL_3ST] = "dell-3stack",
2067 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002068};
2069
2070static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2071 /* SigmaTel reference board */
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2073 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002074 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002077 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002094 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002095 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002097 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002099 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002100 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002102 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002103 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002104 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002108 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002109 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2111 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002118 {} /* terminator */
2119};
2120
Matt Porterf3302a52006-07-31 12:49:34 +02002121static unsigned int ref9205_pin_configs[12] = {
2122 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002123 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002124 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002125};
2126
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002127/*
2128 STAC 9205 pin configs for
2129 102801F1
2130 102801F2
2131 102801FC
2132 102801FD
2133 10280204
2134 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002135 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002136*/
2137static unsigned int dell_9205_m42_pin_configs[12] = {
2138 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2139 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2140 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2141};
2142
2143/*
2144 STAC 9205 pin configs for
2145 102801F9
2146 102801FA
2147 102801FE
2148 102801FF (Dell Precision M4300)
2149 10280206
2150 10280200
2151 10280201
2152*/
2153static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002154 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2155 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2156 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2157};
2158
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002159static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002160 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2161 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2162 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2163};
2164
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002165static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002166 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002167 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2168 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2169 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002170};
2171
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002172static const char *stac9205_models[STAC_9205_MODELS] = {
2173 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002174 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002175 [STAC_9205_DELL_M43] = "dell-m43",
2176 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002177};
2178
2179static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2180 /* SigmaTel reference board */
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2182 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2184 "unknown Dell", STAC_9205_DELL_M42),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2186 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002187 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002188 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2190 "Dell Precision", STAC_9205_DELL_M43),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2192 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2194 "unknown Dell", STAC_9205_DELL_M42),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2196 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002197 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2198 "Dell Precision", STAC_9205_DELL_M43),
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002200 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002201 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2202 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002203 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2204 "Dell Precision", STAC_9205_DELL_M43),
2205 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2206 "Dell Precision", STAC_9205_DELL_M43),
2207 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2208 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002209 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2210 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002211 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2212 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002213 {} /* terminator */
2214};
2215
Richard Fish11b44bb2006-08-23 18:31:34 +02002216static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2217{
2218 int i;
2219 struct sigmatel_spec *spec = codec->spec;
2220
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002221 kfree(spec->pin_configs);
2222 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2223 GFP_KERNEL);
2224 if (!spec->pin_configs)
2225 return -ENOMEM;
Richard Fish11b44bb2006-08-23 18:31:34 +02002226
2227 for (i = 0; i < spec->num_pins; i++) {
2228 hda_nid_t nid = spec->pin_nids[i];
2229 unsigned int pin_cfg;
2230
2231 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2232 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2233 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2234 nid, pin_cfg);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002235 spec->pin_configs[i] = pin_cfg;
Richard Fish11b44bb2006-08-23 18:31:34 +02002236 }
2237
2238 return 0;
2239}
2240
Matthew Ranostay87d48362007-07-17 11:52:24 +02002241static void stac92xx_set_config_reg(struct hda_codec *codec,
2242 hda_nid_t pin_nid, unsigned int pin_config)
2243{
2244 int i;
2245 snd_hda_codec_write(codec, pin_nid, 0,
2246 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2247 pin_config & 0x000000ff);
2248 snd_hda_codec_write(codec, pin_nid, 0,
2249 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2250 (pin_config & 0x0000ff00) >> 8);
2251 snd_hda_codec_write(codec, pin_nid, 0,
2252 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2253 (pin_config & 0x00ff0000) >> 16);
2254 snd_hda_codec_write(codec, pin_nid, 0,
2255 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2256 pin_config >> 24);
2257 i = snd_hda_codec_read(codec, pin_nid, 0,
2258 AC_VERB_GET_CONFIG_DEFAULT,
2259 0x00);
2260 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2261 pin_nid, i);
2262}
2263
Matt2f2f4252005-04-13 14:45:30 +02002264static void stac92xx_set_config_regs(struct hda_codec *codec)
2265{
2266 int i;
2267 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002268
Matthew Ranostay87d48362007-07-17 11:52:24 +02002269 if (!spec->pin_configs)
2270 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002271
Matthew Ranostay87d48362007-07-17 11:52:24 +02002272 for (i = 0; i < spec->num_pins; i++)
2273 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2274 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002275}
Matt2f2f4252005-04-13 14:45:30 +02002276
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002277static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2278{
2279 struct sigmatel_spec *spec = codec->spec;
2280
2281 if (!pins)
2282 return stac92xx_save_bios_config_regs(codec);
2283
2284 kfree(spec->pin_configs);
2285 spec->pin_configs = kmemdup(pins,
2286 spec->num_pins * sizeof(*pins),
2287 GFP_KERNEL);
2288 if (!spec->pin_configs)
2289 return -ENOMEM;
2290
2291 stac92xx_set_config_regs(codec);
2292 return 0;
2293}
2294
2295static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2296 unsigned int cfg)
2297{
2298 struct sigmatel_spec *spec = codec->spec;
2299 int i;
2300
2301 for (i = 0; i < spec->num_pins; i++) {
2302 if (spec->pin_nids[i] == nid) {
2303 spec->pin_configs[i] = cfg;
2304 stac92xx_set_config_reg(codec, nid, cfg);
2305 break;
2306 }
2307 }
2308}
2309
Matt2f2f4252005-04-13 14:45:30 +02002310/*
2311 * Analog playback callbacks
2312 */
2313static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2314 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002315 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002316{
2317 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002318 if (spec->stream_delay)
2319 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002320 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2321 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002322}
2323
2324static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 unsigned int stream_tag,
2327 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002328 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002329{
2330 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002331 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002332}
2333
2334static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2335 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002336 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002337{
2338 struct sigmatel_spec *spec = codec->spec;
2339 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2340}
2341
2342/*
Mattdabbed62005-06-14 10:19:34 +02002343 * Digital playback callbacks
2344 */
2345static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2346 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002347 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002348{
2349 struct sigmatel_spec *spec = codec->spec;
2350 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2351}
2352
2353static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2354 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002355 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002356{
2357 struct sigmatel_spec *spec = codec->spec;
2358 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2359}
2360
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002361static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2362 struct hda_codec *codec,
2363 unsigned int stream_tag,
2364 unsigned int format,
2365 struct snd_pcm_substream *substream)
2366{
2367 struct sigmatel_spec *spec = codec->spec;
2368 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2369 stream_tag, format, substream);
2370}
2371
Mattdabbed62005-06-14 10:19:34 +02002372
2373/*
Matt2f2f4252005-04-13 14:45:30 +02002374 * Analog capture callbacks
2375 */
2376static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2377 struct hda_codec *codec,
2378 unsigned int stream_tag,
2379 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002380 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002381{
2382 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002383 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002384
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002385 if (spec->powerdown_adcs) {
2386 msleep(40);
2387 snd_hda_codec_write_cache(codec, nid, 0,
2388 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2389 }
2390 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002391 return 0;
2392}
2393
2394static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2395 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002396 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002397{
2398 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002399 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002400
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002401 snd_hda_codec_cleanup_stream(codec, nid);
2402 if (spec->powerdown_adcs)
2403 snd_hda_codec_write_cache(codec, nid, 0,
2404 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002405 return 0;
2406}
2407
Mattdabbed62005-06-14 10:19:34 +02002408static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2409 .substreams = 1,
2410 .channels_min = 2,
2411 .channels_max = 2,
2412 /* NID is set in stac92xx_build_pcms */
2413 .ops = {
2414 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002415 .close = stac92xx_dig_playback_pcm_close,
2416 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002417 },
2418};
2419
2420static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2421 .substreams = 1,
2422 .channels_min = 2,
2423 .channels_max = 2,
2424 /* NID is set in stac92xx_build_pcms */
2425};
2426
Matt2f2f4252005-04-13 14:45:30 +02002427static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2428 .substreams = 1,
2429 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002430 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002431 .nid = 0x02, /* NID to query formats and rates */
2432 .ops = {
2433 .open = stac92xx_playback_pcm_open,
2434 .prepare = stac92xx_playback_pcm_prepare,
2435 .cleanup = stac92xx_playback_pcm_cleanup
2436 },
2437};
2438
Matt Porter3cc08dc2006-01-23 15:27:49 +01002439static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2440 .substreams = 1,
2441 .channels_min = 2,
2442 .channels_max = 2,
2443 .nid = 0x06, /* NID to query formats and rates */
2444 .ops = {
2445 .open = stac92xx_playback_pcm_open,
2446 .prepare = stac92xx_playback_pcm_prepare,
2447 .cleanup = stac92xx_playback_pcm_cleanup
2448 },
2449};
2450
Matt2f2f4252005-04-13 14:45:30 +02002451static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002452 .channels_min = 2,
2453 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002454 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002455 .ops = {
2456 .prepare = stac92xx_capture_pcm_prepare,
2457 .cleanup = stac92xx_capture_pcm_cleanup
2458 },
2459};
2460
2461static int stac92xx_build_pcms(struct hda_codec *codec)
2462{
2463 struct sigmatel_spec *spec = codec->spec;
2464 struct hda_pcm *info = spec->pcm_rec;
2465
2466 codec->num_pcms = 1;
2467 codec->pcm_info = info;
2468
Mattc7d4b2f2005-06-27 14:59:41 +02002469 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002470 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002471 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002472 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002473 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002474
2475 if (spec->alt_switch) {
2476 codec->num_pcms++;
2477 info++;
2478 info->name = "STAC92xx Analog Alt";
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2480 }
Matt2f2f4252005-04-13 14:45:30 +02002481
Mattdabbed62005-06-14 10:19:34 +02002482 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2483 codec->num_pcms++;
2484 info++;
2485 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002486 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002487 if (spec->multiout.dig_out_nid) {
2488 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2489 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2490 }
2491 if (spec->dig_in_nid) {
2492 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2493 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2494 }
2495 }
2496
Matt2f2f4252005-04-13 14:45:30 +02002497 return 0;
2498}
2499
Takashi Iwaic960a032006-03-23 17:06:28 +01002500static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2501{
2502 unsigned int pincap = snd_hda_param_read(codec, nid,
2503 AC_PAR_PIN_CAP);
2504 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2505 if (pincap & AC_PINCAP_VREF_100)
2506 return AC_PINCTL_VREF_100;
2507 if (pincap & AC_PINCAP_VREF_80)
2508 return AC_PINCTL_VREF_80;
2509 if (pincap & AC_PINCAP_VREF_50)
2510 return AC_PINCTL_VREF_50;
2511 if (pincap & AC_PINCAP_VREF_GRD)
2512 return AC_PINCTL_VREF_GRD;
2513 return 0;
2514}
2515
Matt Porter403d1942005-11-29 15:00:51 +01002516static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2517
2518{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002519 snd_hda_codec_write_cache(codec, nid, 0,
2520 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002521}
2522
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002523#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2524
2525static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2526 struct snd_ctl_elem_value *ucontrol)
2527{
2528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2529 struct sigmatel_spec *spec = codec->spec;
2530
Takashi Iwaid7a89432008-11-12 09:48:04 +01002531 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002532 return 0;
2533}
2534
2535static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2536 struct snd_ctl_elem_value *ucontrol)
2537{
2538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2539 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002540 int nid = kcontrol->private_value;
2541
2542 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002543
2544 /* check to be sure that the ports are upto date with
2545 * switch changes
2546 */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04002547 codec->patch_ops.unsol_event(codec, (STAC_HP_EVENT | nid) << 26);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002548
2549 return 1;
2550}
2551
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002552#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002553
2554static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2555{
2556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2557 struct sigmatel_spec *spec = codec->spec;
2558 int io_idx = kcontrol-> private_value & 0xff;
2559
2560 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2561 return 0;
2562}
2563
2564static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2565{
2566 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2567 struct sigmatel_spec *spec = codec->spec;
2568 hda_nid_t nid = kcontrol->private_value >> 8;
2569 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002570 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002571
2572 spec->io_switch[io_idx] = val;
2573
2574 if (val)
2575 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002576 else {
2577 unsigned int pinctl = AC_PINCTL_IN_EN;
2578 if (io_idx) /* set VREF for mic */
2579 pinctl |= stac92xx_get_vref(codec, nid);
2580 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2581 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002582
2583 /* check the auto-mute again: we need to mute/unmute the speaker
2584 * appropriately according to the pin direction
2585 */
2586 if (spec->hp_detect)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04002587 codec->patch_ops.unsol_event(codec,
2588 (STAC_HP_EVENT | nid) << 26);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002589
Matt Porter403d1942005-11-29 15:00:51 +01002590 return 1;
2591}
2592
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002593#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2594
2595static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2596 struct snd_ctl_elem_value *ucontrol)
2597{
2598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2599 struct sigmatel_spec *spec = codec->spec;
2600
2601 ucontrol->value.integer.value[0] = spec->clfe_swap;
2602 return 0;
2603}
2604
2605static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2606 struct snd_ctl_elem_value *ucontrol)
2607{
2608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2609 struct sigmatel_spec *spec = codec->spec;
2610 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002611 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002612
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002613 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002614 return 0;
2615
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002616 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002617
2618 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2619 spec->clfe_swap ? 0x4 : 0x0);
2620
2621 return 1;
2622}
2623
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002624#define STAC_CODEC_HP_SWITCH(xname) \
2625 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2626 .name = xname, \
2627 .index = 0, \
2628 .info = stac92xx_hp_switch_info, \
2629 .get = stac92xx_hp_switch_get, \
2630 .put = stac92xx_hp_switch_put, \
2631 }
2632
Matt Porter403d1942005-11-29 15:00:51 +01002633#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2634 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2635 .name = xname, \
2636 .index = 0, \
2637 .info = stac92xx_io_switch_info, \
2638 .get = stac92xx_io_switch_get, \
2639 .put = stac92xx_io_switch_put, \
2640 .private_value = xpval, \
2641 }
2642
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002643#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2644 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2645 .name = xname, \
2646 .index = 0, \
2647 .info = stac92xx_clfe_switch_info, \
2648 .get = stac92xx_clfe_switch_get, \
2649 .put = stac92xx_clfe_switch_put, \
2650 .private_value = xpval, \
2651 }
Matt Porter403d1942005-11-29 15:00:51 +01002652
Mattc7d4b2f2005-06-27 14:59:41 +02002653enum {
2654 STAC_CTL_WIDGET_VOL,
2655 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002656 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002657 STAC_CTL_WIDGET_AMP_MUX,
2658 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002659 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002660 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002661 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002662};
2663
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002664static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002665 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2666 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002667 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002668 STAC_AMP_MUX,
2669 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002670 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002671 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002672 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002673};
2674
2675/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002676static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2677 struct snd_kcontrol_new *ktemp,
2678 int idx, const char *name,
2679 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002680{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002681 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002682
Takashi Iwai603c4012008-07-30 15:01:44 +02002683 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2684 knew = snd_array_new(&spec->kctls);
2685 if (!knew)
2686 return -ENOMEM;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002687 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002688 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002689 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002690 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002691 return -ENOMEM;
2692 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002693 return 0;
2694}
2695
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002696static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2697 int type, int idx, const char *name,
2698 unsigned long val)
2699{
2700 return stac92xx_add_control_temp(spec,
2701 &stac92xx_control_templates[type],
2702 idx, name, val);
2703}
2704
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002705
2706/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002707static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2708 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002709{
2710 return stac92xx_add_control_idx(spec, type, 0, name, val);
2711}
2712
Matt Porter403d1942005-11-29 15:00:51 +01002713/* flag inputs as additional dynamic lineouts */
2714static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2715{
2716 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002717 unsigned int wcaps, wtype;
2718 int i, num_dacs = 0;
2719
2720 /* use the wcaps cache to count all DACs available for line-outs */
2721 for (i = 0; i < codec->num_nodes; i++) {
2722 wcaps = codec->wcaps[i];
2723 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002724
Steve Longerbeam7b043892007-05-03 20:50:03 +02002725 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2726 num_dacs++;
2727 }
Matt Porter403d1942005-11-29 15:00:51 +01002728
Steve Longerbeam7b043892007-05-03 20:50:03 +02002729 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2730
Matt Porter403d1942005-11-29 15:00:51 +01002731 switch (cfg->line_outs) {
2732 case 3:
2733 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002734 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002735 cfg->line_out_pins[cfg->line_outs] =
2736 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002737 spec->line_switch = 1;
2738 cfg->line_outs++;
2739 }
2740 break;
2741 case 2:
2742 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002743 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002744 cfg->line_out_pins[cfg->line_outs] =
2745 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002746 spec->line_switch = 1;
2747 cfg->line_outs++;
2748 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002749 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002750 cfg->line_out_pins[cfg->line_outs] =
2751 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002752 spec->mic_switch = 1;
2753 cfg->line_outs++;
2754 }
2755 break;
2756 case 1:
2757 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002758 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002759 cfg->line_out_pins[cfg->line_outs] =
2760 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002761 spec->line_switch = 1;
2762 cfg->line_outs++;
2763 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002764 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002765 cfg->line_out_pins[cfg->line_outs] =
2766 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002767 spec->mic_switch = 1;
2768 cfg->line_outs++;
2769 }
2770 break;
2771 }
2772
2773 return 0;
2774}
2775
Steve Longerbeam7b043892007-05-03 20:50:03 +02002776
2777static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2778{
2779 int i;
2780
2781 for (i = 0; i < spec->multiout.num_dacs; i++) {
2782 if (spec->multiout.dac_nids[i] == nid)
2783 return 1;
2784 }
2785
2786 return 0;
2787}
2788
Matt Porter3cc08dc2006-01-23 15:27:49 +01002789/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002790 * Fill in the dac_nids table from the parsed pin configuration
2791 * This function only works when every pin in line_out_pins[]
2792 * contains atleast one DAC in its connection list. Some 92xx
2793 * codecs are not connected directly to a DAC, such as the 9200
2794 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002795 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002796static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002797 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002798{
2799 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002800 int i, j, conn_len = 0;
2801 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2802 unsigned int wcaps, wtype;
2803
Mattc7d4b2f2005-06-27 14:59:41 +02002804 for (i = 0; i < cfg->line_outs; i++) {
2805 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002806 conn_len = snd_hda_get_connections(codec, nid, conn,
2807 HDA_MAX_CONNECTIONS);
2808 for (j = 0; j < conn_len; j++) {
2809 wcaps = snd_hda_param_read(codec, conn[j],
2810 AC_PAR_AUDIO_WIDGET_CAP);
2811 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002812 if (wtype != AC_WID_AUD_OUT ||
2813 (wcaps & AC_WCAP_DIGITAL))
2814 continue;
2815 /* conn[j] is a DAC routed to this line-out */
2816 if (!is_in_dac_nids(spec, conn[j]))
2817 break;
2818 }
2819
2820 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002821 if (spec->multiout.num_dacs > 0) {
2822 /* we have already working output pins,
2823 * so let's drop the broken ones again
2824 */
2825 cfg->line_outs = spec->multiout.num_dacs;
2826 break;
2827 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002828 /* error out, no available DAC found */
2829 snd_printk(KERN_ERR
2830 "%s: No available DAC for pin 0x%x\n",
2831 __func__, nid);
2832 return -ENODEV;
2833 }
2834
2835 spec->multiout.dac_nids[i] = conn[j];
2836 spec->multiout.num_dacs++;
2837 if (conn_len > 1) {
2838 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002839 snd_hda_codec_write_cache(codec, nid, 0,
2840 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002841
2842 }
Mattc7d4b2f2005-06-27 14:59:41 +02002843 }
2844
Steve Longerbeam7b043892007-05-03 20:50:03 +02002845 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2846 spec->multiout.num_dacs,
2847 spec->multiout.dac_nids[0],
2848 spec->multiout.dac_nids[1],
2849 spec->multiout.dac_nids[2],
2850 spec->multiout.dac_nids[3],
2851 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002852 return 0;
2853}
2854
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002855/* create volume control/switch for the given prefx type */
2856static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2857{
2858 char name[32];
2859 int err;
2860
2861 sprintf(name, "%s Playback Volume", pfx);
2862 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2863 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2864 if (err < 0)
2865 return err;
2866 sprintf(name, "%s Playback Switch", pfx);
2867 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2868 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2869 if (err < 0)
2870 return err;
2871 return 0;
2872}
2873
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002874static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2875{
2876 if (!spec->multiout.hp_nid)
2877 spec->multiout.hp_nid = nid;
2878 else if (spec->multiout.num_dacs > 4) {
2879 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2880 return 1;
2881 } else {
2882 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2883 spec->multiout.num_dacs++;
2884 }
2885 return 0;
2886}
2887
2888static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2889{
2890 if (is_in_dac_nids(spec, nid))
2891 return 1;
2892 if (spec->multiout.hp_nid == nid)
2893 return 1;
2894 return 0;
2895}
2896
Mattc7d4b2f2005-06-27 14:59:41 +02002897/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002898static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002899 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002900{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002901 static const char *chname[4] = {
2902 "Front", "Surround", NULL /*CLFE*/, "Side"
2903 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002904 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002905 int i, err;
2906
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002907 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002908 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002909
2910
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002911 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002912 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002913 continue;
2914
2915 nid = spec->multiout.dac_nids[i];
2916
2917 if (i == 2) {
2918 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002919 err = create_controls(spec, "Center", nid, 1);
2920 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002921 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002922 err = create_controls(spec, "LFE", nid, 2);
2923 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002924 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002925
2926 wid_caps = get_wcaps(codec, nid);
2927
2928 if (wid_caps & AC_WCAP_LR_SWAP) {
2929 err = stac92xx_add_control(spec,
2930 STAC_CTL_WIDGET_CLFE_SWITCH,
2931 "Swap Center/LFE Playback Switch", nid);
2932
2933 if (err < 0)
2934 return err;
2935 }
2936
Mattc7d4b2f2005-06-27 14:59:41 +02002937 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002938 err = create_controls(spec, chname[i], nid, 3);
2939 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002940 return err;
2941 }
2942 }
2943
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002944 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2945 cfg->hp_outs && !spec->multiout.hp_nid)
2946 spec->multiout.hp_nid = nid;
2947
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002948 if (cfg->hp_outs > 1) {
2949 err = stac92xx_add_control(spec,
2950 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002951 "Headphone as Line Out Switch",
2952 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002953 if (err < 0)
2954 return err;
2955 }
2956
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002957 if (spec->line_switch) {
2958 nid = cfg->input_pins[AUTO_PIN_LINE];
2959 pincap = snd_hda_param_read(codec, nid,
2960 AC_PAR_PIN_CAP);
2961 if (pincap & AC_PINCAP_OUT) {
2962 err = stac92xx_add_control(spec,
2963 STAC_CTL_WIDGET_IO_SWITCH,
2964 "Line In as Output Switch", nid << 8);
2965 if (err < 0)
2966 return err;
2967 }
2968 }
Matt Porter403d1942005-11-29 15:00:51 +01002969
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002970 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002971 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002972 unsigned int mic_pin = AUTO_PIN_MIC;
2973again:
2974 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002975 def_conf = snd_hda_codec_read(codec, nid, 0,
2976 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002977 /* some laptops have an internal analog microphone
2978 * which can't be used as a output */
2979 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2980 pincap = snd_hda_param_read(codec, nid,
2981 AC_PAR_PIN_CAP);
2982 if (pincap & AC_PINCAP_OUT) {
2983 err = stac92xx_add_control(spec,
2984 STAC_CTL_WIDGET_IO_SWITCH,
2985 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002986 nid = snd_hda_codec_read(codec, nid, 0,
2987 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2988 if (!check_in_dac_nids(spec, nid))
2989 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002990 if (err < 0)
2991 return err;
2992 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002993 } else if (mic_pin == AUTO_PIN_MIC) {
2994 mic_pin = AUTO_PIN_FRONT_MIC;
2995 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002996 }
2997 }
Matt Porter403d1942005-11-29 15:00:51 +01002998
Mattc7d4b2f2005-06-27 14:59:41 +02002999 return 0;
3000}
3001
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003002/* add playback controls for Speaker and HP outputs */
3003static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3004 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003005{
3006 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003007 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003008 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003009
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003010 old_num_dacs = spec->multiout.num_dacs;
3011 for (i = 0; i < cfg->hp_outs; i++) {
3012 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3013 if (wid_caps & AC_WCAP_UNSOL_CAP)
3014 spec->hp_detect = 1;
3015 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
3016 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
3017 if (check_in_dac_nids(spec, nid))
3018 nid = 0;
3019 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02003020 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003021 add_spec_dacs(spec, nid);
3022 }
3023 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02003024 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003025 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
3026 if (check_in_dac_nids(spec, nid))
3027 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003028 if (! nid)
3029 continue;
3030 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02003031 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02003032 for (i = 0; i < cfg->line_outs; i++) {
3033 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
3034 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
3035 if (check_in_dac_nids(spec, nid))
3036 nid = 0;
3037 if (! nid)
3038 continue;
3039 add_spec_dacs(spec, nid);
3040 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003041 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
3042 static const char *pfxs[] = {
3043 "Speaker", "External Speaker", "Speaker2",
3044 };
3045 err = create_controls(spec, pfxs[i - old_num_dacs],
3046 spec->multiout.dac_nids[i], 3);
3047 if (err < 0)
3048 return err;
3049 }
3050 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01003051 err = create_controls(spec, "Headphone",
3052 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003053 if (err < 0)
3054 return err;
3055 }
Mattc7d4b2f2005-06-27 14:59:41 +02003056
3057 return 0;
3058}
3059
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003060/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003061static const char *stac92xx_mono_labels[4] = {
3062 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003063};
3064
3065/* create mono mux for mono out on capable codecs */
3066static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3067{
3068 struct sigmatel_spec *spec = codec->spec;
3069 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3070 int i, num_cons;
3071 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3072
3073 num_cons = snd_hda_get_connections(codec,
3074 spec->mono_nid,
3075 con_lst,
3076 HDA_MAX_NUM_INPUTS);
3077 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3078 return -EINVAL;
3079
3080 for (i = 0; i < num_cons; i++) {
3081 mono_mux->items[mono_mux->num_items].label =
3082 stac92xx_mono_labels[i];
3083 mono_mux->items[mono_mux->num_items].index = i;
3084 mono_mux->num_items++;
3085 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003086
3087 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3088 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003089}
3090
Matthew Ranostay89385032008-09-11 09:49:39 -04003091/* labels for amp mux outputs */
3092static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003093 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003094};
3095
3096/* create amp out controls mux on capable codecs */
3097static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3098{
3099 struct sigmatel_spec *spec = codec->spec;
3100 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3101 int i, err;
3102
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003103 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003104 amp_mux->items[amp_mux->num_items].label =
3105 stac92xx_amp_labels[i];
3106 amp_mux->items[amp_mux->num_items].index = i;
3107 amp_mux->num_items++;
3108 }
3109
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003110 if (spec->num_amps > 1) {
3111 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3112 "Amp Selector Capture Switch", 0);
3113 if (err < 0)
3114 return err;
3115 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003116 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3117 "Amp Capture Volume",
3118 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3119}
3120
3121
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003122/* create PC beep volume controls */
3123static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3124 hda_nid_t nid)
3125{
3126 struct sigmatel_spec *spec = codec->spec;
3127 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3128 int err;
3129
3130 /* check for mute support for the the amp */
3131 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3132 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3133 "PC Beep Playback Switch",
3134 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3135 if (err < 0)
3136 return err;
3137 }
3138
3139 /* check to see if there is volume support for the amp */
3140 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3141 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3142 "PC Beep Playback Volume",
3143 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3144 if (err < 0)
3145 return err;
3146 }
3147 return 0;
3148}
3149
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003150#ifdef CONFIG_SND_HDA_INPUT_BEEP
3151#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3152
3153static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3154 struct snd_ctl_elem_value *ucontrol)
3155{
3156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3157 ucontrol->value.integer.value[0] = codec->beep->enabled;
3158 return 0;
3159}
3160
3161static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3162 struct snd_ctl_elem_value *ucontrol)
3163{
3164 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3165 int enabled = !!ucontrol->value.integer.value[0];
3166 if (codec->beep->enabled != enabled) {
3167 codec->beep->enabled = enabled;
3168 return 1;
3169 }
3170 return 0;
3171}
3172
3173static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3174 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3175 .info = stac92xx_dig_beep_switch_info,
3176 .get = stac92xx_dig_beep_switch_get,
3177 .put = stac92xx_dig_beep_switch_put,
3178};
3179
3180static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3181{
3182 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3183 0, "PC Beep Playback Switch", 0);
3184}
3185#endif
3186
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003187static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3188{
3189 struct sigmatel_spec *spec = codec->spec;
3190 int wcaps, nid, i, err = 0;
3191
3192 for (i = 0; i < spec->num_muxes; i++) {
3193 nid = spec->mux_nids[i];
3194 wcaps = get_wcaps(codec, nid);
3195
3196 if (wcaps & AC_WCAP_OUT_AMP) {
3197 err = stac92xx_add_control_idx(spec,
3198 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3199 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3200 if (err < 0)
3201 return err;
3202 }
3203 }
3204 return 0;
3205};
3206
Matthew Ranostayd9737752008-09-07 12:03:41 +02003207static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003208 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003209};
3210
3211static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3212{
3213 struct sigmatel_spec *spec = codec->spec;
3214 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003215 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003216 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003217 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003218
3219 num_cons = snd_hda_get_connections(codec,
3220 spec->smux_nids[0],
3221 con_lst,
3222 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003223 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003224 return -EINVAL;
3225
Matthew Ranostay65973632008-09-16 10:39:37 -04003226 if (!labels)
3227 labels = stac92xx_spdif_labels;
3228
Matthew Ranostayd9737752008-09-07 12:03:41 +02003229 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003230 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003231 spdif_mux->items[spdif_mux->num_items].index = i;
3232 spdif_mux->num_items++;
3233 }
3234
3235 return 0;
3236}
3237
Matt Porter8b657272006-10-26 17:12:59 +02003238/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003239static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003240 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3241 "Digital Mic 3", "Digital Mic 4"
3242};
3243
3244/* create playback/capture controls for input pins on dmic capable codecs */
3245static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3246 const struct auto_pin_cfg *cfg)
3247{
3248 struct sigmatel_spec *spec = codec->spec;
3249 struct hda_input_mux *dimux = &spec->private_dimux;
3250 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003251 int err, i, j;
3252 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003253
3254 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3255 dimux->items[dimux->num_items].index = 0;
3256 dimux->num_items++;
3257
3258 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003259 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003260 int index;
3261 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003262 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003263 unsigned int def_conf;
3264
3265 def_conf = snd_hda_codec_read(codec,
3266 spec->dmic_nids[i],
3267 0,
3268 AC_VERB_GET_CONFIG_DEFAULT,
3269 0);
3270 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3271 continue;
3272
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003273 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003274 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003275 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003276 con_lst,
3277 HDA_MAX_NUM_INPUTS);
3278 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003279 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003280 index = j;
3281 goto found;
3282 }
3283 continue;
3284found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003285 wcaps = get_wcaps(codec, nid) &
3286 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003287
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003288 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003289 sprintf(name, "%s Capture Volume",
3290 stac92xx_dmic_labels[dimux->num_items]);
3291
3292 err = stac92xx_add_control(spec,
3293 STAC_CTL_WIDGET_VOL,
3294 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003295 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3296 (wcaps & AC_WCAP_OUT_AMP) ?
3297 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003298 if (err < 0)
3299 return err;
3300 }
3301
Matt Porter8b657272006-10-26 17:12:59 +02003302 dimux->items[dimux->num_items].label =
3303 stac92xx_dmic_labels[dimux->num_items];
3304 dimux->items[dimux->num_items].index = index;
3305 dimux->num_items++;
3306 }
3307
3308 return 0;
3309}
3310
Mattc7d4b2f2005-06-27 14:59:41 +02003311/* create playback/capture controls for input pins */
3312static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3313{
3314 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003315 struct hda_input_mux *imux = &spec->private_imux;
3316 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3317 int i, j, k;
3318
3319 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003320 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003321
Takashi Iwai314634b2006-09-21 11:56:18 +02003322 if (!cfg->input_pins[i])
3323 continue;
3324 index = -1;
3325 for (j = 0; j < spec->num_muxes; j++) {
3326 int num_cons;
3327 num_cons = snd_hda_get_connections(codec,
3328 spec->mux_nids[j],
3329 con_lst,
3330 HDA_MAX_NUM_INPUTS);
3331 for (k = 0; k < num_cons; k++)
3332 if (con_lst[k] == cfg->input_pins[i]) {
3333 index = k;
3334 goto found;
3335 }
Mattc7d4b2f2005-06-27 14:59:41 +02003336 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003337 continue;
3338 found:
3339 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3340 imux->items[imux->num_items].index = index;
3341 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003342 }
3343
Steve Longerbeam7b043892007-05-03 20:50:03 +02003344 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003345 /*
3346 * Set the current input for the muxes.
3347 * The STAC9221 has two input muxes with identical source
3348 * NID lists. Hopefully this won't get confused.
3349 */
3350 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003351 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3352 AC_VERB_SET_CONNECT_SEL,
3353 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003354 }
3355 }
3356
Mattc7d4b2f2005-06-27 14:59:41 +02003357 return 0;
3358}
3359
Mattc7d4b2f2005-06-27 14:59:41 +02003360static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3361{
3362 struct sigmatel_spec *spec = codec->spec;
3363 int i;
3364
3365 for (i = 0; i < spec->autocfg.line_outs; i++) {
3366 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3367 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3368 }
3369}
3370
3371static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3372{
3373 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003374 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003375
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003376 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3377 hda_nid_t pin;
3378 pin = spec->autocfg.hp_pins[i];
3379 if (pin) /* connect to front */
3380 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3381 }
3382 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3383 hda_nid_t pin;
3384 pin = spec->autocfg.speaker_pins[i];
3385 if (pin) /* connect to front */
3386 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3387 }
Mattc7d4b2f2005-06-27 14:59:41 +02003388}
3389
Matt Porter3cc08dc2006-01-23 15:27:49 +01003390static 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 +02003391{
3392 struct sigmatel_spec *spec = codec->spec;
3393 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003394 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003395
Matt Porter8b657272006-10-26 17:12:59 +02003396 if ((err = snd_hda_parse_pin_def_config(codec,
3397 &spec->autocfg,
3398 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003399 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003400 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003401 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003402
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003403 /* If we have no real line-out pin and multiple hp-outs, HPs should
3404 * be set up as multi-channel outputs.
3405 */
3406 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3407 spec->autocfg.hp_outs > 1) {
3408 /* Copy hp_outs to line_outs, backup line_outs in
3409 * speaker_outs so that the following routines can handle
3410 * HP pins as primary outputs.
3411 */
3412 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3413 sizeof(spec->autocfg.line_out_pins));
3414 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3415 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3416 sizeof(spec->autocfg.hp_pins));
3417 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3418 hp_speaker_swap = 1;
3419 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003420 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003421 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3422 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003423 u32 caps = query_amp_caps(codec,
3424 spec->autocfg.mono_out_pin, dir);
3425 hda_nid_t conn_list[1];
3426
3427 /* get the mixer node and then the mono mux if it exists */
3428 if (snd_hda_get_connections(codec,
3429 spec->autocfg.mono_out_pin, conn_list, 1) &&
3430 snd_hda_get_connections(codec, conn_list[0],
3431 conn_list, 1)) {
3432
3433 int wcaps = get_wcaps(codec, conn_list[0]);
3434 int wid_type = (wcaps & AC_WCAP_TYPE)
3435 >> AC_WCAP_TYPE_SHIFT;
3436 /* LR swap check, some stac925x have a mux that
3437 * changes the DACs output path instead of the
3438 * mono-mux path.
3439 */
3440 if (wid_type == AC_WID_AUD_SEL &&
3441 !(wcaps & AC_WCAP_LR_SWAP))
3442 spec->mono_nid = conn_list[0];
3443 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003444 if (dir) {
3445 hda_nid_t nid = spec->autocfg.mono_out_pin;
3446
3447 /* most mono outs have a least a mute/unmute switch */
3448 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3449 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3450 "Mono Playback Switch",
3451 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003452 if (err < 0)
3453 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003454 /* check for volume support for the amp */
3455 if ((caps & AC_AMPCAP_NUM_STEPS)
3456 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3457 err = stac92xx_add_control(spec,
3458 STAC_CTL_WIDGET_VOL,
3459 "Mono Playback Volume",
3460 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3461 if (err < 0)
3462 return err;
3463 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003464 }
3465
3466 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3467 AC_PINCTL_OUT_EN);
3468 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003469
Matt Porter403d1942005-11-29 15:00:51 +01003470 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3471 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003472 if (spec->multiout.num_dacs == 0)
3473 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3474 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003475
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003476 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3477
3478 if (err < 0)
3479 return err;
3480
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003481 /* setup analog beep controls */
3482 if (spec->anabeep_nid > 0) {
3483 err = stac92xx_auto_create_beep_ctls(codec,
3484 spec->anabeep_nid);
3485 if (err < 0)
3486 return err;
3487 }
3488
3489 /* setup digital beep controls and input device */
3490#ifdef CONFIG_SND_HDA_INPUT_BEEP
3491 if (spec->digbeep_nid > 0) {
3492 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003493 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003494
3495 err = stac92xx_auto_create_beep_ctls(codec, nid);
3496 if (err < 0)
3497 return err;
3498 err = snd_hda_attach_beep_device(codec, nid);
3499 if (err < 0)
3500 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003501 /* if no beep switch is available, make its own one */
3502 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3503 if (codec->beep &&
3504 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3505 err = stac92xx_beep_switch_ctl(codec);
3506 if (err < 0)
3507 return err;
3508 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003509 }
3510#endif
3511
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003512 if (hp_speaker_swap == 1) {
3513 /* Restore the hp_outs and line_outs */
3514 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3515 sizeof(spec->autocfg.line_out_pins));
3516 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3517 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3518 sizeof(spec->autocfg.speaker_pins));
3519 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3520 memset(spec->autocfg.speaker_pins, 0,
3521 sizeof(spec->autocfg.speaker_pins));
3522 spec->autocfg.speaker_outs = 0;
3523 }
3524
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003525 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3526
3527 if (err < 0)
3528 return err;
3529
3530 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3531
3532 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003533 return err;
3534
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003535 if (spec->mono_nid > 0) {
3536 err = stac92xx_auto_create_mono_output_ctls(codec);
3537 if (err < 0)
3538 return err;
3539 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003540 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003541 err = stac92xx_auto_create_amp_output_ctls(codec);
3542 if (err < 0)
3543 return err;
3544 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003545 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003546 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3547 &spec->autocfg)) < 0)
3548 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003549 if (spec->num_muxes > 0) {
3550 err = stac92xx_auto_create_mux_input_ctls(codec);
3551 if (err < 0)
3552 return err;
3553 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003554 if (spec->num_smuxes > 0) {
3555 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3556 if (err < 0)
3557 return err;
3558 }
Matt Porter8b657272006-10-26 17:12:59 +02003559
Mattc7d4b2f2005-06-27 14:59:41 +02003560 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003561 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003562 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003563
Takashi Iwai82bc9552006-03-21 11:24:42 +01003564 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003565 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003566 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003567 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003568
Takashi Iwai603c4012008-07-30 15:01:44 +02003569 if (spec->kctls.list)
3570 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003571
3572 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003573 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003574 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003575 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003576 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003577 return 1;
3578}
3579
Takashi Iwai82bc9552006-03-21 11:24:42 +01003580/* add playback controls for HP output */
3581static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3582 struct auto_pin_cfg *cfg)
3583{
3584 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003585 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003586 unsigned int wid_caps;
3587
3588 if (! pin)
3589 return 0;
3590
3591 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003592 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003593 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003594
3595 return 0;
3596}
3597
Richard Fish160ea0d2006-09-06 13:58:25 +02003598/* add playback controls for LFE output */
3599static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3600 struct auto_pin_cfg *cfg)
3601{
3602 struct sigmatel_spec *spec = codec->spec;
3603 int err;
3604 hda_nid_t lfe_pin = 0x0;
3605 int i;
3606
3607 /*
3608 * search speaker outs and line outs for a mono speaker pin
3609 * with an amp. If one is found, add LFE controls
3610 * for it.
3611 */
3612 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3613 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003614 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003615 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3616 if (wcaps == AC_WCAP_OUT_AMP)
3617 /* found a mono speaker with an amp, must be lfe */
3618 lfe_pin = pin;
3619 }
3620
3621 /* if speaker_outs is 0, then speakers may be in line_outs */
3622 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3623 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3624 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003625 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003626 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003627 AC_VERB_GET_CONFIG_DEFAULT,
3628 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003629 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003630 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003631 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3632 if (wcaps == AC_WCAP_OUT_AMP)
3633 /* found a mono speaker with an amp,
3634 must be lfe */
3635 lfe_pin = pin;
3636 }
3637 }
3638 }
3639
3640 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003641 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003642 if (err < 0)
3643 return err;
3644 }
3645
3646 return 0;
3647}
3648
Mattc7d4b2f2005-06-27 14:59:41 +02003649static int stac9200_parse_auto_config(struct hda_codec *codec)
3650{
3651 struct sigmatel_spec *spec = codec->spec;
3652 int err;
3653
Kailang Yangdf694da2005-12-05 19:42:22 +01003654 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003655 return err;
3656
3657 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3658 return err;
3659
Takashi Iwai82bc9552006-03-21 11:24:42 +01003660 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3661 return err;
3662
Richard Fish160ea0d2006-09-06 13:58:25 +02003663 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3664 return err;
3665
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003666 if (spec->num_muxes > 0) {
3667 err = stac92xx_auto_create_mux_input_ctls(codec);
3668 if (err < 0)
3669 return err;
3670 }
3671
Takashi Iwai82bc9552006-03-21 11:24:42 +01003672 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003673 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003674 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003675 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003676
Takashi Iwai603c4012008-07-30 15:01:44 +02003677 if (spec->kctls.list)
3678 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003679
3680 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003681 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003682
3683 return 1;
3684}
3685
Sam Revitch62fe78e2006-05-10 15:09:17 +02003686/*
3687 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3688 * funky external mute control using GPIO pins.
3689 */
3690
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003691static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003692 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003693{
3694 unsigned int gpiostate, gpiomask, gpiodir;
3695
3696 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3697 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003698 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003699
3700 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3701 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003702 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003703
3704 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3705 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003706 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003707
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003708 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003709 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3710
3711 snd_hda_codec_write(codec, codec->afg, 0,
3712 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003713 snd_hda_codec_read(codec, codec->afg, 0,
3714 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003715
3716 msleep(1);
3717
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003718 snd_hda_codec_read(codec, codec->afg, 0,
3719 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003720}
3721
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003722static int stac92xx_add_jack(struct hda_codec *codec,
3723 hda_nid_t nid, int type)
3724{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003725#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003726 struct sigmatel_spec *spec = codec->spec;
3727 struct sigmatel_jack *jack;
3728 int def_conf = snd_hda_codec_read(codec, nid,
3729 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3730 int connectivity = get_defcfg_connect(def_conf);
3731 char name[32];
3732
3733 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3734 return 0;
3735
3736 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3737 jack = snd_array_new(&spec->jacks);
3738 if (!jack)
3739 return -ENOMEM;
3740 jack->nid = nid;
3741 jack->type = type;
3742
3743 sprintf(name, "%s at %s %s Jack",
3744 snd_hda_get_jack_type(def_conf),
3745 snd_hda_get_jack_connectivity(def_conf),
3746 snd_hda_get_jack_location(def_conf));
3747
3748 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003749#else
3750 return 0;
3751#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003752}
3753
3754static int stac92xx_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3755 int data)
3756{
3757 struct sigmatel_event *event;
3758
3759 snd_array_init(&spec->events, sizeof(*event), 32);
3760 event = snd_array_new(&spec->events);
3761 if (!event)
3762 return -ENOMEM;
3763 event->nid = nid;
3764 event->data = data;
3765
3766 return 0;
3767}
3768
3769static int stac92xx_event_data(struct hda_codec *codec, hda_nid_t nid)
3770{
3771 struct sigmatel_spec *spec = codec->spec;
3772 struct sigmatel_event *events = spec->events.list;
3773 if (events) {
3774 int i;
3775 for (i = 0; i < spec->events.used; i++)
3776 if (events[i].nid == nid)
3777 return events[i].data;
3778 }
3779 return 0;
3780}
3781
Takashi Iwai314634b2006-09-21 11:56:18 +02003782static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3783 unsigned int event)
3784{
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003785 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003786 snd_hda_codec_write_cache(codec, nid, 0,
3787 AC_VERB_SET_UNSOLICITED_ENABLE,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003788 (AC_USRSP_EN | event | nid));
3789 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003790}
3791
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003792static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3793{
3794 int i;
3795 for (i = 0; i < cfg->hp_outs; i++)
3796 if (cfg->hp_pins[i] == nid)
3797 return 1; /* nid is a HP-Out */
3798
3799 return 0; /* nid is not a HP-Out */
3800};
3801
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003802static void stac92xx_power_down(struct hda_codec *codec)
3803{
3804 struct sigmatel_spec *spec = codec->spec;
3805
3806 /* power down inactive DACs */
3807 hda_nid_t *dac;
3808 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003809 if (!is_in_dac_nids(spec, *dac) &&
3810 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003811 snd_hda_codec_write_cache(codec, *dac, 0,
3812 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3813}
3814
Mattc7d4b2f2005-06-27 14:59:41 +02003815static int stac92xx_init(struct hda_codec *codec)
3816{
3817 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003818 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003819 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003820
Mattc7d4b2f2005-06-27 14:59:41 +02003821 snd_hda_sequence_write(codec, spec->init);
3822
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003823 /* power down adcs initially */
3824 if (spec->powerdown_adcs)
3825 for (i = 0; i < spec->num_adcs; i++)
3826 snd_hda_codec_write_cache(codec,
3827 spec->adc_nids[i], 0,
3828 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003829 /* set up pins */
3830 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003831 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003832 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003833 hda_nid_t nid = cfg->hp_pins[i];
3834 enable_pin_detect(codec, nid, STAC_HP_EVENT | nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003835 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003836 /* force to enable the first line-out; the others are set up
3837 * in unsol_event
3838 */
3839 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003840 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003841 /* fake event to set up pins */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003842 codec->patch_ops.unsol_event(codec,
3843 (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003844 } else {
3845 stac92xx_auto_init_multi_out(codec);
3846 stac92xx_auto_init_hp_out(codec);
3847 }
3848 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003849 hda_nid_t nid = cfg->input_pins[i];
3850 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003851 unsigned int pinctl;
3852 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3853 /* for mic pins, force to initialize */
3854 pinctl = stac92xx_get_vref(codec, nid);
3855 } else {
3856 pinctl = snd_hda_codec_read(codec, nid, 0,
3857 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3858 /* if PINCTL already set then skip */
3859 if (pinctl & AC_PINCTL_IN_EN)
3860 continue;
3861 }
3862 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003863 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003864 enable_pin_detect(codec, nid, STAC_INSERT_EVENT | nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003865 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003866 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003867 for (i = 0; i < spec->num_dmics; i++)
3868 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3869 AC_PINCTL_IN_EN);
3870 for (i = 0; i < spec->num_pwrs; i++) {
3871 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3872 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3873 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3874 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003875 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3876 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003877 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003878 /* outputs are only ports capable of power management
3879 * any attempts on powering down a input port cause the
3880 * referenced VREF to act quirky.
3881 */
3882 if (pinctl & AC_PINCTL_IN_EN)
3883 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003884 /* skip any ports that don't have jacks since presence
3885 * detection is useless */
3886 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003887 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003888 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3889 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3890 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003891 if (spec->dac_list)
3892 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003893 if (cfg->dig_out_pin)
3894 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3895 AC_PINCTL_OUT_EN);
3896 if (cfg->dig_in_pin)
3897 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3898 AC_PINCTL_IN_EN);
3899
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003900 stac_gpio_set(codec, spec->gpio_mask,
3901 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003902
Mattc7d4b2f2005-06-27 14:59:41 +02003903 return 0;
3904}
3905
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003906static void stac92xx_free_jacks(struct hda_codec *codec)
3907{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003908#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003909 struct sigmatel_spec *spec = codec->spec;
3910 if (spec->jacks.list) {
3911 struct sigmatel_jack *jacks = spec->jacks.list;
3912 int i;
3913 for (i = 0; i < spec->jacks.used; i++)
3914 snd_device_free(codec->bus->card, &jacks[i].jack);
3915 }
3916 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003917#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003918}
3919
Takashi Iwai603c4012008-07-30 15:01:44 +02003920static void stac92xx_free_kctls(struct hda_codec *codec)
3921{
3922 struct sigmatel_spec *spec = codec->spec;
3923
3924 if (spec->kctls.list) {
3925 struct snd_kcontrol_new *kctl = spec->kctls.list;
3926 int i;
3927 for (i = 0; i < spec->kctls.used; i++)
3928 kfree(kctl[i].name);
3929 }
3930 snd_array_free(&spec->kctls);
3931}
3932
Matt2f2f4252005-04-13 14:45:30 +02003933static void stac92xx_free(struct hda_codec *codec)
3934{
Mattc7d4b2f2005-06-27 14:59:41 +02003935 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003936
3937 if (! spec)
3938 return;
3939
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01003940 kfree(spec->pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003941 stac92xx_free_jacks(codec);
3942 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02003943
Mattc7d4b2f2005-06-27 14:59:41 +02003944 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003945 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003946}
3947
Matt4e550962005-07-04 17:51:39 +02003948static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3949 unsigned int flag)
3950{
3951 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3952 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003953
Takashi Iwaif9acba42007-05-29 18:01:06 +02003954 if (pin_ctl & AC_PINCTL_IN_EN) {
3955 /*
3956 * we need to check the current set-up direction of
3957 * shared input pins since they can be switched via
3958 * "xxx as Output" mixer switch
3959 */
3960 struct sigmatel_spec *spec = codec->spec;
3961 struct auto_pin_cfg *cfg = &spec->autocfg;
3962 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3963 spec->line_switch) ||
3964 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3965 spec->mic_switch))
3966 return;
3967 }
3968
Steve Longerbeam7b043892007-05-03 20:50:03 +02003969 /* if setting pin direction bits, clear the current
3970 direction bits first */
3971 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3972 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3973
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003974 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003975 AC_VERB_SET_PIN_WIDGET_CONTROL,
3976 pin_ctl | flag);
3977}
3978
3979static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3980 unsigned int flag)
3981{
3982 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3983 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003984 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003985 AC_VERB_SET_PIN_WIDGET_CONTROL,
3986 pin_ctl & ~flag);
3987}
3988
Jiang Zhe40c1d302007-11-12 13:05:16 +01003989static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003990{
3991 if (!nid)
3992 return 0;
3993 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003994 & (1 << 31)) {
3995 unsigned int pinctl;
3996 pinctl = snd_hda_codec_read(codec, nid, 0,
3997 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3998 if (pinctl & AC_PINCTL_IN_EN)
3999 return 0; /* mic- or line-input */
4000 else
4001 return 1; /* HP-output */
4002 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004003 return 0;
4004}
4005
Takashi Iwaid7a89432008-11-12 09:48:04 +01004006/* return non-zero if the hp-pin of the given array index isn't
4007 * a jack-detection target
4008 */
4009static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4010{
4011 struct auto_pin_cfg *cfg = &spec->autocfg;
4012
4013 /* ignore sensing of shared line and mic jacks */
4014 if (spec->line_switch &&
4015 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
4016 return 1;
4017 if (spec->mic_switch &&
4018 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
4019 return 1;
4020 /* ignore if the pin is set as line-out */
4021 if (cfg->hp_pins[i] == spec->hp_switch)
4022 return 1;
4023 return 0;
4024}
4025
Takashi Iwai314634b2006-09-21 11:56:18 +02004026static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02004027{
4028 struct sigmatel_spec *spec = codec->spec;
4029 struct auto_pin_cfg *cfg = &spec->autocfg;
4030 int i, presence;
4031
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004032 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004033 if (spec->gpio_mute)
4034 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4035 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4036
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004037 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004038 if (presence)
4039 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004040 if (no_hp_sensing(spec, i))
4041 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004042 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004043 }
Matt4e550962005-07-04 17:51:39 +02004044
4045 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004046 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004047 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004048 stac92xx_reset_pinctl(codec, spec->hp_switch,
4049 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004050 for (i = 0; i < cfg->line_outs; i++)
4051 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4052 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004053 for (i = 0; i < cfg->speaker_outs; i++)
4054 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4055 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004056 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004057 stac_gpio_set(codec, spec->gpio_mask,
4058 spec->gpio_dir, spec->gpio_data &
4059 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004060 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004061 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004062 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004063 stac92xx_set_pinctl(codec, spec->hp_switch,
4064 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004065 for (i = 0; i < cfg->line_outs; i++)
4066 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4067 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004068 for (i = 0; i < cfg->speaker_outs; i++)
4069 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4070 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004071 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004072 stac_gpio_set(codec, spec->gpio_mask,
4073 spec->gpio_dir, spec->gpio_data |
4074 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004075 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004076 /* toggle hp outs */
4077 for (i = 0; i < cfg->hp_outs; i++) {
4078 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4079 if (no_hp_sensing(spec, i))
4080 continue;
4081 if (presence)
4082 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4083 else
4084 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4085 }
Matt4e550962005-07-04 17:51:39 +02004086}
4087
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004088static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
4089{
4090 struct sigmatel_spec *spec = codec->spec;
4091 hda_nid_t nid = spec->pwr_nids[idx];
4092 int presence, val;
4093 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
4094 & 0x000000ff;
4095 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004096
4097 /* several codecs have two power down bits */
4098 if (spec->pwr_mapping)
4099 idx = spec->pwr_mapping[idx];
4100 else
4101 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004102
4103 if (presence)
4104 val &= ~idx;
4105 else
4106 val |= idx;
4107
4108 /* power down unused output ports */
4109 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004110}
4111
4112static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4113{
4114 struct sigmatel_spec *spec = codec->spec;
4115 struct sigmatel_jack *jacks = spec->jacks.list;
4116
4117 if (jacks) {
4118 int i;
4119 for (i = 0; i < spec->jacks.used; i++) {
4120 if (jacks->nid == nid) {
4121 unsigned int pin_ctl =
4122 snd_hda_codec_read(codec, nid,
4123 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4124 0x00);
4125 int type = jacks->type;
4126 if (type == (SND_JACK_LINEOUT
4127 | SND_JACK_HEADPHONE))
4128 type = (pin_ctl & AC_PINCTL_HP_EN)
4129 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4130 snd_jack_report(jacks->jack,
4131 get_hp_pin_presence(codec, nid)
4132 ? type : 0);
4133 }
4134 jacks++;
4135 }
4136 }
4137}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004138
Takashi Iwai314634b2006-09-21 11:56:18 +02004139static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4140{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004141 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004142 int event = (res >> 26) & 0x70;
4143 int nid = res >> 26 & 0x0f;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004144
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004145 switch (event) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004146 case STAC_HP_EVENT:
4147 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004148 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004149 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004150 case STAC_PWR_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004151 if (nid) {
4152 if (spec->num_pwrs > 0)
4153 stac92xx_pin_sense(codec, nid);
4154 stac92xx_report_jack(codec, nid);
4155 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004156 break;
4157 case STAC_VREF_EVENT: {
4158 int data = snd_hda_codec_read(codec, codec->afg, 0,
4159 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004160 int idx = stac92xx_event_data(codec, nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004161 /* toggle VREF state based on GPIOx status */
4162 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4163 !!(data & (1 << idx)));
4164 break;
4165 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004166 }
4167}
4168
Takashi Iwaicb53c622007-08-10 17:21:45 +02004169#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004170static int stac92xx_resume(struct hda_codec *codec)
4171{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004172 struct sigmatel_spec *spec = codec->spec;
4173
Richard Fish11b44bb2006-08-23 18:31:34 +02004174 stac92xx_set_config_regs(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004175 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004176 snd_hda_codec_resume_amp(codec);
4177 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004178 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004179 if (spec->hp_detect)
Takashi Iwai2c885872008-11-18 09:36:55 +01004180 codec->patch_ops.unsol_event(codec,
4181 (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
Mattff6fdc32005-06-27 15:06:52 +02004182 return 0;
4183}
4184#endif
4185
Matt2f2f4252005-04-13 14:45:30 +02004186static struct hda_codec_ops stac92xx_patch_ops = {
4187 .build_controls = stac92xx_build_controls,
4188 .build_pcms = stac92xx_build_pcms,
4189 .init = stac92xx_init,
4190 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004191 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004192#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004193 .resume = stac92xx_resume,
4194#endif
Matt2f2f4252005-04-13 14:45:30 +02004195};
4196
4197static int patch_stac9200(struct hda_codec *codec)
4198{
4199 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004200 int err;
Matt2f2f4252005-04-13 14:45:30 +02004201
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004202 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004203 if (spec == NULL)
4204 return -ENOMEM;
4205
4206 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004207 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004208 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004209 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4210 stac9200_models,
4211 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004212 if (spec->board_config < 0) {
4213 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4214 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004215 } else
4216 err = stac_save_pin_cfgs(codec,
4217 stac9200_brd_tbl[spec->board_config]);
4218 if (err < 0) {
4219 stac92xx_free(codec);
4220 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004221 }
Matt2f2f4252005-04-13 14:45:30 +02004222
4223 spec->multiout.max_channels = 2;
4224 spec->multiout.num_dacs = 1;
4225 spec->multiout.dac_nids = stac9200_dac_nids;
4226 spec->adc_nids = stac9200_adc_nids;
4227 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004228 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004229 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004230 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004231 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004232
Tobin Davisbf277782008-02-03 20:31:47 +01004233 if (spec->board_config == STAC_9200_GATEWAY ||
4234 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004235 spec->init = stac9200_eapd_init;
4236 else
4237 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004238 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004239
Takashi Iwai117f2572008-03-18 09:53:23 +01004240 if (spec->board_config == STAC_9200_PANASONIC) {
4241 spec->gpio_mask = spec->gpio_dir = 0x09;
4242 spec->gpio_data = 0x00;
4243 }
4244
Mattc7d4b2f2005-06-27 14:59:41 +02004245 err = stac9200_parse_auto_config(codec);
4246 if (err < 0) {
4247 stac92xx_free(codec);
4248 return err;
4249 }
Matt2f2f4252005-04-13 14:45:30 +02004250
4251 codec->patch_ops = stac92xx_patch_ops;
4252
4253 return 0;
4254}
4255
Tobin Davis8e21c342007-01-08 11:04:17 +01004256static int patch_stac925x(struct hda_codec *codec)
4257{
4258 struct sigmatel_spec *spec;
4259 int err;
4260
4261 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4262 if (spec == NULL)
4263 return -ENOMEM;
4264
4265 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004266 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004267 spec->pin_nids = stac925x_pin_nids;
4268 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4269 stac925x_models,
4270 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004271 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004272 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004273 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4274 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004275 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004276 } else
4277 err = stac_save_pin_cfgs(codec,
4278 stac925x_brd_tbl[spec->board_config]);
4279 if (err < 0) {
4280 stac92xx_free(codec);
4281 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01004282 }
4283
4284 spec->multiout.max_channels = 2;
4285 spec->multiout.num_dacs = 1;
4286 spec->multiout.dac_nids = stac925x_dac_nids;
4287 spec->adc_nids = stac925x_adc_nids;
4288 spec->mux_nids = stac925x_mux_nids;
4289 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004290 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004291 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004292 switch (codec->vendor_id) {
4293 case 0x83847632: /* STAC9202 */
4294 case 0x83847633: /* STAC9202D */
4295 case 0x83847636: /* STAC9251 */
4296 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004297 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004298 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004299 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4300 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004301 break;
4302 default:
4303 spec->num_dmics = 0;
4304 break;
4305 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004306
4307 spec->init = stac925x_core_init;
4308 spec->mixer = stac925x_mixer;
4309
4310 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004311 if (!err) {
4312 if (spec->board_config < 0) {
4313 printk(KERN_WARNING "hda_codec: No auto-config is "
4314 "available, default to model=ref\n");
4315 spec->board_config = STAC_925x_REF;
4316 goto again;
4317 }
4318 err = -EINVAL;
4319 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004320 if (err < 0) {
4321 stac92xx_free(codec);
4322 return err;
4323 }
4324
4325 codec->patch_ops = stac92xx_patch_ops;
4326
4327 return 0;
4328}
4329
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004330static struct hda_input_mux stac92hd73xx_dmux = {
4331 .num_items = 4,
4332 .items = {
4333 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004334 { "Digital Mic 1", 0x09 },
4335 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004336 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004337 }
4338};
4339
4340static int patch_stac92hd73xx(struct hda_codec *codec)
4341{
4342 struct sigmatel_spec *spec;
4343 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4344 int err = 0;
4345
4346 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4347 if (spec == NULL)
4348 return -ENOMEM;
4349
4350 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004351 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004352 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4353 spec->pin_nids = stac92hd73xx_pin_nids;
4354 spec->board_config = snd_hda_check_board_config(codec,
4355 STAC_92HD73XX_MODELS,
4356 stac92hd73xx_models,
4357 stac92hd73xx_cfg_tbl);
4358again:
4359 if (spec->board_config < 0) {
4360 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4361 " STAC92HD73XX, using BIOS defaults\n");
4362 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004363 } else
4364 err = stac_save_pin_cfgs(codec,
4365 stac92hd73xx_brd_tbl[spec->board_config]);
4366 if (err < 0) {
4367 stac92xx_free(codec);
4368 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004369 }
4370
4371 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4372 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4373
4374 if (spec->multiout.num_dacs < 0) {
4375 printk(KERN_WARNING "hda_codec: Could not determine "
4376 "number of channels defaulting to DAC count\n");
4377 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4378 }
4379
4380 switch (spec->multiout.num_dacs) {
4381 case 0x3: /* 6 Channel */
4382 spec->mixer = stac92hd73xx_6ch_mixer;
4383 spec->init = stac92hd73xx_6ch_core_init;
4384 break;
4385 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004386 spec->mixer = stac92hd73xx_8ch_mixer;
4387 spec->init = stac92hd73xx_8ch_core_init;
4388 break;
4389 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004390 spec->mixer = stac92hd73xx_10ch_mixer;
4391 spec->init = stac92hd73xx_10ch_core_init;
4392 };
4393
4394 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4395 spec->aloopback_mask = 0x01;
4396 spec->aloopback_shift = 8;
4397
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004398 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004399 spec->mux_nids = stac92hd73xx_mux_nids;
4400 spec->adc_nids = stac92hd73xx_adc_nids;
4401 spec->dmic_nids = stac92hd73xx_dmic_nids;
4402 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004403 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004404 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004405 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004406
4407 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4408 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004409 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004410 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4411 sizeof(stac92hd73xx_dmux));
4412
Matthew Ranostaya7662642008-02-21 07:51:14 +01004413 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004414 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004415 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004416 /* fallthru */
4417 case STAC_DELL_M6:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004418 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004419 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4420 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004421 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004422 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004423
4424 if (!spec->init)
4425 spec->init = dell_m6_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004426 switch (codec->subsystem_id) {
4427 case 0x1028025e: /* Analog Mics */
4428 case 0x1028025f:
4429 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4430 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004431 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004432 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004433 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004434 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004435 case 0x10280254:
4436 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004437 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4438 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004439 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004440 break;
4441 case 0x10280256: /* Both */
4442 case 0x10280057:
4443 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4444 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4445 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004446 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004447 break;
4448 }
4449 break;
4450 default:
4451 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004452 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004453 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004454 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004455 if (spec->board_config > STAC_92HD73XX_REF) {
4456 /* GPIO0 High = Enable EAPD */
4457 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4458 spec->gpio_data = 0x01;
4459 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004460 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004461
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004462 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4463 spec->pwr_nids = stac92hd73xx_pwr_nids;
4464
Matthew Ranostayd9737752008-09-07 12:03:41 +02004465 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004466
4467 if (!err) {
4468 if (spec->board_config < 0) {
4469 printk(KERN_WARNING "hda_codec: No auto-config is "
4470 "available, default to model=ref\n");
4471 spec->board_config = STAC_92HD73XX_REF;
4472 goto again;
4473 }
4474 err = -EINVAL;
4475 }
4476
4477 if (err < 0) {
4478 stac92xx_free(codec);
4479 return err;
4480 }
4481
4482 codec->patch_ops = stac92xx_patch_ops;
4483
4484 return 0;
4485}
4486
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004487static struct hda_input_mux stac92hd83xxx_dmux = {
4488 .num_items = 3,
4489 .items = {
4490 { "Analog Inputs", 0x03 },
4491 { "Digital Mic 1", 0x04 },
4492 { "Digital Mic 2", 0x05 },
4493 }
4494};
4495
4496static int patch_stac92hd83xxx(struct hda_codec *codec)
4497{
4498 struct sigmatel_spec *spec;
4499 int err;
4500
4501 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4502 if (spec == NULL)
4503 return -ENOMEM;
4504
4505 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004506 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004507 spec->mono_nid = 0x19;
4508 spec->digbeep_nid = 0x21;
4509 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4510 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4511 spec->adc_nids = stac92hd83xxx_adc_nids;
4512 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4513 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4514 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4515 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4516
4517 spec->init = stac92hd83xxx_core_init;
4518 switch (codec->vendor_id) {
4519 case 0x111d7605:
4520 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4521 break;
4522 default:
4523 spec->num_pwrs--;
4524 spec->init++; /* switch to config #2 */
4525 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4526 }
4527
4528 spec->mixer = stac92hd83xxx_mixer;
4529 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4530 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4531 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4532 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4533 spec->dinput_mux = &stac92hd83xxx_dmux;
4534 spec->pin_nids = stac92hd83xxx_pin_nids;
4535 spec->board_config = snd_hda_check_board_config(codec,
4536 STAC_92HD83XXX_MODELS,
4537 stac92hd83xxx_models,
4538 stac92hd83xxx_cfg_tbl);
4539again:
4540 if (spec->board_config < 0) {
4541 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4542 " STAC92HD83XXX, using BIOS defaults\n");
4543 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004544 } else
4545 err = stac_save_pin_cfgs(codec,
4546 stac92hd83xxx_brd_tbl[spec->board_config]);
4547 if (err < 0) {
4548 stac92xx_free(codec);
4549 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004550 }
4551
4552 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4553 if (!err) {
4554 if (spec->board_config < 0) {
4555 printk(KERN_WARNING "hda_codec: No auto-config is "
4556 "available, default to model=ref\n");
4557 spec->board_config = STAC_92HD83XXX_REF;
4558 goto again;
4559 }
4560 err = -EINVAL;
4561 }
4562
4563 if (err < 0) {
4564 stac92xx_free(codec);
4565 return err;
4566 }
4567
4568 codec->patch_ops = stac92xx_patch_ops;
4569
4570 return 0;
4571}
4572
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004573#ifdef SND_HDA_NEEDS_RESUME
4574static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4575{
4576 struct sigmatel_spec *spec = codec->spec;
4577 int i;
4578 snd_hda_codec_write_cache(codec, codec->afg, 0,
4579 AC_VERB_SET_POWER_STATE, pwr);
4580
4581 msleep(1);
4582 for (i = 0; i < spec->num_adcs; i++) {
4583 snd_hda_codec_write_cache(codec,
4584 spec->adc_nids[i], 0,
4585 AC_VERB_SET_POWER_STATE, pwr);
4586 }
4587};
4588
4589static int stac92hd71xx_resume(struct hda_codec *codec)
4590{
4591 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4592 return stac92xx_resume(codec);
4593}
4594
4595static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4596{
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004597 struct sigmatel_spec *spec = codec->spec;
4598
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004599 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004600 if (spec->eapd_mask)
4601 stac_gpio_set(codec, spec->gpio_mask,
4602 spec->gpio_dir, spec->gpio_data &
4603 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004604 return 0;
4605};
4606
4607#endif
4608
4609static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4610 .build_controls = stac92xx_build_controls,
4611 .build_pcms = stac92xx_build_pcms,
4612 .init = stac92xx_init,
4613 .free = stac92xx_free,
4614 .unsol_event = stac92xx_unsol_event,
4615#ifdef SND_HDA_NEEDS_RESUME
4616 .resume = stac92hd71xx_resume,
4617 .suspend = stac92hd71xx_suspend,
4618#endif
4619};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004620
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004621static struct hda_input_mux stac92hd71bxx_dmux = {
4622 .num_items = 4,
4623 .items = {
4624 { "Analog Inputs", 0x00 },
4625 { "Mixer", 0x01 },
4626 { "Digital Mic 1", 0x02 },
4627 { "Digital Mic 2", 0x03 },
4628 }
4629};
4630
Matthew Ranostaye035b842007-11-06 11:53:55 +01004631static int patch_stac92hd71bxx(struct hda_codec *codec)
4632{
4633 struct sigmatel_spec *spec;
4634 int err = 0;
4635
4636 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4637 if (spec == NULL)
4638 return -ENOMEM;
4639
4640 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004641 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004642 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004643 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004644 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004645 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4646 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004647 spec->board_config = snd_hda_check_board_config(codec,
4648 STAC_92HD71BXX_MODELS,
4649 stac92hd71bxx_models,
4650 stac92hd71bxx_cfg_tbl);
4651again:
4652 if (spec->board_config < 0) {
4653 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4654 " STAC92HD71BXX, using BIOS defaults\n");
4655 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004656 } else
4657 err = stac_save_pin_cfgs(codec,
4658 stac92hd71bxx_brd_tbl[spec->board_config]);
4659 if (err < 0) {
4660 stac92xx_free(codec);
4661 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004662 }
4663
Matthew Ranostay541eee82007-12-14 12:08:04 +01004664 switch (codec->vendor_id) {
4665 case 0x111d76b6: /* 4 Port without Analog Mixer */
4666 case 0x111d76b7:
4667 case 0x111d76b4: /* 6 Port without Analog Mixer */
4668 case 0x111d76b5:
4669 spec->mixer = stac92hd71bxx_mixer;
4670 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004671 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004672 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004673 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay72474be2008-10-09 09:32:17 -04004674 switch (codec->subsystem_id) {
4675 case 0x103c361a:
4676 /* Enable VREF power saving on GPIO1 detect */
4677 snd_hda_codec_write(codec, codec->afg, 0,
4678 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4679 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004680 AC_VERB_SET_UNSOLICITED_ENABLE,
4681 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
4682 err = stac92xx_add_event(spec, codec->afg, 0x02);
4683 if (err < 0)
4684 return err;
Matthew Ranostay72474be2008-10-09 09:32:17 -04004685 spec->gpio_mask |= 0x02;
4686 break;
4687 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004688 if ((codec->revision_id & 0xf) == 0 ||
4689 (codec->revision_id & 0xf) == 1) {
4690#ifdef SND_HDA_NEEDS_RESUME
4691 codec->patch_ops = stac92hd71bxx_patch_ops;
4692#endif
4693 spec->stream_delay = 40; /* 40 milliseconds */
4694 }
4695
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004696 /* no output amps */
4697 spec->num_pwrs = 0;
4698 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004699 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004700
4701 /* disable VSW */
4702 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004703 stac_change_pin_config(codec, 0xf, 0x40f000f0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004704 break;
4705 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004706 if ((codec->revision_id & 0xf) == 1) {
4707#ifdef SND_HDA_NEEDS_RESUME
4708 codec->patch_ops = stac92hd71bxx_patch_ops;
4709#endif
4710 spec->stream_delay = 40; /* 40 milliseconds */
4711 }
4712
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004713 /* no output amps */
4714 spec->num_pwrs = 0;
4715 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004716 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004717 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004718 spec->mixer = stac92hd71bxx_analog_mixer;
4719 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004720 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004721 }
4722
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004723 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004724 spec->aloopback_shift = 0;
4725
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004726 if (spec->board_config > STAC_92HD71BXX_REF) {
4727 /* GPIO0 = EAPD */
4728 spec->gpio_mask = 0x01;
4729 spec->gpio_dir = 0x01;
4730 spec->gpio_data = 0x01;
4731 }
Matthew Ranostaye035b842007-11-06 11:53:55 +01004732
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004733 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004734 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004735 spec->mux_nids = stac92hd71bxx_mux_nids;
4736 spec->adc_nids = stac92hd71bxx_adc_nids;
4737 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004738 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004739 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004740 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004741
4742 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4743 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004744
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004745 switch (spec->board_config) {
4746 case STAC_HP_M4:
4747 spec->num_dmics = 0;
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004748 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004749 spec->num_dmuxes = 0;
4750
4751 /* enable internal microphone */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004752 stac_change_pin_config(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004753 stac92xx_auto_set_pinctl(codec, 0x0e,
4754 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004755 break;
4756 default:
4757 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4758 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4759 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4760 };
4761
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004762 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004763 spec->multiout.hp_nid = 0x11;
4764 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004765 if (spec->dinput_mux)
4766 spec->private_dimux.num_items +=
4767 spec->num_dmics -
4768 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004769
4770 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4771 if (!err) {
4772 if (spec->board_config < 0) {
4773 printk(KERN_WARNING "hda_codec: No auto-config is "
4774 "available, default to model=ref\n");
4775 spec->board_config = STAC_92HD71BXX_REF;
4776 goto again;
4777 }
4778 err = -EINVAL;
4779 }
4780
4781 if (err < 0) {
4782 stac92xx_free(codec);
4783 return err;
4784 }
4785
Matthew Ranostaye035b842007-11-06 11:53:55 +01004786 return 0;
4787};
4788
Matt2f2f4252005-04-13 14:45:30 +02004789static int patch_stac922x(struct hda_codec *codec)
4790{
4791 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004792 int err;
Matt2f2f4252005-04-13 14:45:30 +02004793
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004794 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004795 if (spec == NULL)
4796 return -ENOMEM;
4797
4798 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004799 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004800 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004801 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4802 stac922x_models,
4803 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004804 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004805 spec->gpio_mask = spec->gpio_dir = 0x03;
4806 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004807 /* Intel Macs have all same PCI SSID, so we need to check
4808 * codec SSID to distinguish the exact models
4809 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004810 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004811 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004812
4813 case 0x106b0800:
4814 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004815 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004816 case 0x106b0600:
4817 case 0x106b0700:
4818 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004819 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004820 case 0x106b0e00:
4821 case 0x106b0f00:
4822 case 0x106b1600:
4823 case 0x106b1700:
4824 case 0x106b0200:
4825 case 0x106b1e00:
4826 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004827 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004828 case 0x106b1a00:
4829 case 0x00000100:
4830 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004831 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004832 case 0x106b0a00:
4833 case 0x106b2200:
4834 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004835 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004836 default:
4837 spec->board_config = STAC_INTEL_MAC_V3;
4838 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004839 }
4840 }
4841
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004842 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004843 if (spec->board_config < 0) {
4844 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4845 "using BIOS defaults\n");
4846 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004847 } else
4848 err = stac_save_pin_cfgs(codec,
4849 stac922x_brd_tbl[spec->board_config]);
4850 if (err < 0) {
4851 stac92xx_free(codec);
4852 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004853 }
Matt2f2f4252005-04-13 14:45:30 +02004854
Matt2f2f4252005-04-13 14:45:30 +02004855 spec->adc_nids = stac922x_adc_nids;
4856 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004857 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004858 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004859 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004860 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004861
4862 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004863 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004864
4865 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004866
Matt Porter3cc08dc2006-01-23 15:27:49 +01004867 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004868 if (!err) {
4869 if (spec->board_config < 0) {
4870 printk(KERN_WARNING "hda_codec: No auto-config is "
4871 "available, default to model=ref\n");
4872 spec->board_config = STAC_D945_REF;
4873 goto again;
4874 }
4875 err = -EINVAL;
4876 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004877 if (err < 0) {
4878 stac92xx_free(codec);
4879 return err;
4880 }
4881
4882 codec->patch_ops = stac92xx_patch_ops;
4883
Takashi Iwai807a46362007-05-29 19:01:37 +02004884 /* Fix Mux capture level; max to 2 */
4885 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4886 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4887 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4888 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4889 (0 << AC_AMPCAP_MUTE_SHIFT));
4890
Matt Porter3cc08dc2006-01-23 15:27:49 +01004891 return 0;
4892}
4893
4894static int patch_stac927x(struct hda_codec *codec)
4895{
4896 struct sigmatel_spec *spec;
4897 int err;
4898
4899 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4900 if (spec == NULL)
4901 return -ENOMEM;
4902
4903 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004904 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004905 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004906 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4907 stac927x_models,
4908 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004909 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004910 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4911 if (spec->board_config < 0)
4912 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4913 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004914 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004915 } else
4916 err = stac_save_pin_cfgs(codec,
4917 stac927x_brd_tbl[spec->board_config]);
4918 if (err < 0) {
4919 stac92xx_free(codec);
4920 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01004921 }
4922
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004923 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004924 spec->adc_nids = stac927x_adc_nids;
4925 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4926 spec->mux_nids = stac927x_mux_nids;
4927 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004928 spec->smux_nids = stac927x_smux_nids;
4929 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004930 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004931 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004932 spec->multiout.dac_nids = spec->dac_nids;
4933
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004934 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004935 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004936 case STAC_D965_5ST:
4937 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004938 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004939 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004940 spec->num_dmics = 0;
4941
Tobin Davis93ed1502006-09-01 21:03:12 +02004942 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004943 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004944 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004945 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004946 switch (codec->subsystem_id) {
4947 case 0x10280209:
4948 case 0x1028022e:
4949 /* correct the device field to SPDIF out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004950 stac_change_pin_config(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004951 break;
4952 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004953 /* configure the analog microphone on some laptops */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004954 stac_change_pin_config(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004955 /* correct the front output jack as a hp out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004956 stac_change_pin_config(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004957 /* correct the front input jack as a mic */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004958 stac_change_pin_config(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004959 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004960 case STAC_DELL_3ST:
4961 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004962 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004963 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004964 spec->dmic_nids = stac927x_dmic_nids;
4965 spec->num_dmics = STAC927X_NUM_DMICS;
4966
Tobin Davis93ed1502006-09-01 21:03:12 +02004967 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004968 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004969 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004970 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004971 break;
4972 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004973 if (spec->board_config > STAC_D965_REF) {
4974 /* GPIO0 High = Enable EAPD */
4975 spec->eapd_mask = spec->gpio_mask = 0x01;
4976 spec->gpio_dir = spec->gpio_data = 0x01;
4977 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004978 spec->num_dmics = 0;
4979
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004980 spec->init = stac927x_core_init;
4981 spec->mixer = stac927x_mixer;
4982 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004983
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004984 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004985 spec->aloopback_mask = 0x40;
4986 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004987 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004988
Matt Porter3cc08dc2006-01-23 15:27:49 +01004989 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004990 if (!err) {
4991 if (spec->board_config < 0) {
4992 printk(KERN_WARNING "hda_codec: No auto-config is "
4993 "available, default to model=ref\n");
4994 spec->board_config = STAC_D965_REF;
4995 goto again;
4996 }
4997 err = -EINVAL;
4998 }
Mattc7d4b2f2005-06-27 14:59:41 +02004999 if (err < 0) {
5000 stac92xx_free(codec);
5001 return err;
5002 }
Matt2f2f4252005-04-13 14:45:30 +02005003
5004 codec->patch_ops = stac92xx_patch_ops;
5005
Takashi Iwai52987652008-01-16 16:09:47 +01005006 /*
5007 * !!FIXME!!
5008 * The STAC927x seem to require fairly long delays for certain
5009 * command sequences. With too short delays (even if the answer
5010 * is set to RIRB properly), it results in the silence output
5011 * on some hardwares like Dell.
5012 *
5013 * The below flag enables the longer delay (see get_response
5014 * in hda_intel.c).
5015 */
5016 codec->bus->needs_damn_long_delay = 1;
5017
Matt2f2f4252005-04-13 14:45:30 +02005018 return 0;
5019}
5020
Matt Porterf3302a52006-07-31 12:49:34 +02005021static int patch_stac9205(struct hda_codec *codec)
5022{
5023 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005024 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005025
5026 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5027 if (spec == NULL)
5028 return -ENOMEM;
5029
5030 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005031 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005032 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005033 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5034 stac9205_models,
5035 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005036 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005037 if (spec->board_config < 0) {
5038 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5039 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005040 } else
5041 err = stac_save_pin_cfgs(codec,
5042 stac9205_brd_tbl[spec->board_config]);
5043 if (err < 0) {
5044 stac92xx_free(codec);
5045 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02005046 }
5047
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005048 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005049 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005050 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005051 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005052 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005053 spec->smux_nids = stac9205_smux_nids;
5054 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005055 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005056 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005057 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005058 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005059 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005060
5061 spec->init = stac9205_core_init;
5062 spec->mixer = stac9205_mixer;
5063
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005064 spec->aloopback_mask = 0x40;
5065 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005066 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005067 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005068
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005069 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005070 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005071 /* Enable SPDIF in/out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005072 stac_change_pin_config(codec, 0x1f, 0x01441030);
5073 stac_change_pin_config(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005074
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005075 /* Enable unsol response for GPIO4/Dock HP connection */
5076 snd_hda_codec_write(codec, codec->afg, 0,
5077 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5078 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005079 AC_VERB_SET_UNSOLICITED_ENABLE,
5080 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
5081 err = stac92xx_add_event(spec, codec->afg, 0x01);
5082 if (err < 0)
5083 return err;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005084
5085 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005086 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005087 spec->gpio_mask = 0x1b;
5088 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005089 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005090 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005091 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005092 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005093 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005094 case STAC_9205_REF:
5095 /* SPDIF-In enabled */
5096 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005097 default:
5098 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005099 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005100 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005101 break;
5102 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005103
Matt Porterf3302a52006-07-31 12:49:34 +02005104 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005105 if (!err) {
5106 if (spec->board_config < 0) {
5107 printk(KERN_WARNING "hda_codec: No auto-config is "
5108 "available, default to model=ref\n");
5109 spec->board_config = STAC_9205_REF;
5110 goto again;
5111 }
5112 err = -EINVAL;
5113 }
Matt Porterf3302a52006-07-31 12:49:34 +02005114 if (err < 0) {
5115 stac92xx_free(codec);
5116 return err;
5117 }
5118
5119 codec->patch_ops = stac92xx_patch_ops;
5120
5121 return 0;
5122}
5123
Matt2f2f4252005-04-13 14:45:30 +02005124/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005125 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005126 */
5127
Guillaume Munch99ccc562006-08-16 19:35:12 +02005128/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005129static hda_nid_t vaio_dacs[] = { 0x2 };
5130#define VAIO_HP_DAC 0x5
5131static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5132static hda_nid_t vaio_mux_nids[] = { 0x15 };
5133
5134static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005135 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005136 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005137 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005138 { "Mic Jack", 0x1 },
5139 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005140 { "PCM", 0x3 },
5141 }
5142};
5143
5144static struct hda_verb vaio_init[] = {
5145 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005146 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005147 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5148 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5149 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005152 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5153 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5154 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5157 {}
5158};
5159
Guillaume Munch6d859062006-08-22 17:15:47 +02005160static struct hda_verb vaio_ar_init[] = {
5161 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5162 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5163 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5164 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5165/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5166 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005167 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005168 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5169 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5170/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5171 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5173 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5174 {}
5175};
5176
Takashi Iwaidb064e52006-03-16 16:04:58 +01005177static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5179 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5180 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5181 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005182 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5183 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5184 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5185 {
5186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5187 .name = "Capture Source",
5188 .count = 1,
5189 .info = stac92xx_mux_enum_info,
5190 .get = stac92xx_mux_enum_get,
5191 .put = stac92xx_mux_enum_put,
5192 },
5193 {}
5194};
5195
Guillaume Munch6d859062006-08-22 17:15:47 +02005196static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005197 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5198 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5199 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5200 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Guillaume Munch6d859062006-08-22 17:15:47 +02005201 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5202 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5203 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5204 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5205 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5206 {
5207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5208 .name = "Capture Source",
5209 .count = 1,
5210 .info = stac92xx_mux_enum_info,
5211 .get = stac92xx_mux_enum_get,
5212 .put = stac92xx_mux_enum_put,
5213 },
5214 {}
5215};
5216
5217static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005218 .build_controls = stac92xx_build_controls,
5219 .build_pcms = stac92xx_build_pcms,
5220 .init = stac92xx_init,
5221 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005222#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005223 .resume = stac92xx_resume,
5224#endif
5225};
5226
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005227static int stac9872_vaio_init(struct hda_codec *codec)
5228{
5229 int err;
5230
5231 err = stac92xx_init(codec);
5232 if (err < 0)
5233 return err;
5234 if (codec->patch_ops.unsol_event)
5235 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5236 return 0;
5237}
5238
5239static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5240{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005241 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005242 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5243 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5244 } else {
5245 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5246 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5247 }
5248}
5249
5250static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5251{
5252 switch (res >> 26) {
5253 case STAC_HP_EVENT:
5254 stac9872_vaio_hp_detect(codec, res);
5255 break;
5256 }
5257}
5258
5259static struct hda_codec_ops stac9872_vaio_patch_ops = {
5260 .build_controls = stac92xx_build_controls,
5261 .build_pcms = stac92xx_build_pcms,
5262 .init = stac9872_vaio_init,
5263 .free = stac92xx_free,
5264 .unsol_event = stac9872_vaio_unsol_event,
5265#ifdef CONFIG_PM
5266 .resume = stac92xx_resume,
5267#endif
5268};
5269
Guillaume Munch6d859062006-08-22 17:15:47 +02005270enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5271 CXD9872RD_VAIO,
5272 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5273 STAC9872AK_VAIO,
5274 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5275 STAC9872K_VAIO,
5276 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005277 CXD9872AKD_VAIO,
5278 STAC_9872_MODELS,
5279};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005280
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005281static const char *stac9872_models[STAC_9872_MODELS] = {
5282 [CXD9872RD_VAIO] = "vaio",
5283 [CXD9872AKD_VAIO] = "vaio-ar",
5284};
5285
5286static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5287 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5288 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5289 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005290 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005291 {}
5292};
5293
Guillaume Munch6d859062006-08-22 17:15:47 +02005294static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005295{
5296 struct sigmatel_spec *spec;
5297 int board_config;
5298
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005299 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5300 stac9872_models,
5301 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005302 if (board_config < 0)
5303 /* unknown config, let generic-parser do its job... */
5304 return snd_hda_parse_generic_codec(codec);
5305
5306 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5307 if (spec == NULL)
5308 return -ENOMEM;
5309
5310 codec->spec = spec;
5311 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005312 case CXD9872RD_VAIO:
5313 case STAC9872AK_VAIO:
5314 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005315 spec->mixer = vaio_mixer;
5316 spec->init = vaio_init;
5317 spec->multiout.max_channels = 2;
5318 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5319 spec->multiout.dac_nids = vaio_dacs;
5320 spec->multiout.hp_nid = VAIO_HP_DAC;
5321 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5322 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005323 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005324 spec->input_mux = &vaio_mux;
5325 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005326 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005327 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005328
5329 case CXD9872AKD_VAIO:
5330 spec->mixer = vaio_ar_mixer;
5331 spec->init = vaio_ar_init;
5332 spec->multiout.max_channels = 2;
5333 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5334 spec->multiout.dac_nids = vaio_dacs;
5335 spec->multiout.hp_nid = VAIO_HP_DAC;
5336 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005337 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005338 spec->adc_nids = vaio_adcs;
5339 spec->input_mux = &vaio_mux;
5340 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005341 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005342 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005343 }
5344
Takashi Iwaidb064e52006-03-16 16:04:58 +01005345 return 0;
5346}
5347
5348
5349/*
Matt2f2f4252005-04-13 14:45:30 +02005350 * patch entries
5351 */
5352struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5353 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5354 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5355 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5356 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5357 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5358 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5359 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005360 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5361 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5362 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5363 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5364 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5365 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005366 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5367 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5368 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5369 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5370 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5371 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5372 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5373 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5374 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5375 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005376 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5377 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5378 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5379 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5380 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5381 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005382 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5383 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005384 /* The following does not take into account .id=0x83847661 when subsys =
5385 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5386 * currently not fully supported.
5387 */
5388 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5389 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5390 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005391 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5392 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5393 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5394 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5395 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5396 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5397 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5398 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005399 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005400 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5401 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005402 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005403 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5404 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005405 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005406 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5407 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5408 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5409 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5410 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5411 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5412 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5413 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005414 {} /* terminator */
5415};