blob: 7cd395a175ef60cf3a066f69b76fa132a2dffb0d [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 Ranostay3a7abfd2008-11-20 21:21:43 -050086 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040087 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010088 STAC_92HD71BXX_MODELS
89};
90
91enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010092 STAC_925x_REF,
93 STAC_M2_2,
94 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020095 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010096 STAC_925x_MODELS
97};
98
99enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100100 STAC_D945_REF,
101 STAC_D945GTP3,
102 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200103 STAC_INTEL_MAC_V1,
104 STAC_INTEL_MAC_V2,
105 STAC_INTEL_MAC_V3,
106 STAC_INTEL_MAC_V4,
107 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800108 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
109 * is given, one of the above models will be
110 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200111 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100112 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100113 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100114 STAC_MACBOOK_PRO_V1,
115 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200116 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200117 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300118 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200119 STAC_922X_DELL_D81,
120 STAC_922X_DELL_D82,
121 STAC_922X_DELL_M81,
122 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100123 STAC_922X_MODELS
124};
125
126enum {
127 STAC_D965_REF,
128 STAC_D965_3ST,
129 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200130 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100131 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100132 STAC_927X_MODELS
133};
Matt Porter403d1942005-11-29 15:00:51 +0100134
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400135struct sigmatel_event {
136 hda_nid_t nid;
137 int data;
138};
139
140struct sigmatel_jack {
141 hda_nid_t nid;
142 int type;
143 struct snd_jack *jack;
144};
145
Matt2f2f4252005-04-13 14:45:30 +0200146struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100147 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200148 unsigned int num_mixers;
149
Matt Porter403d1942005-11-29 15:00:51 +0100150 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500151 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200152 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100153 unsigned int line_switch: 1;
154 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100155 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100156 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400157 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200158
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100159 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200160 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100161 unsigned int gpio_mask;
162 unsigned int gpio_dir;
163 unsigned int gpio_data;
164 unsigned int gpio_mute;
165
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200166 /* stream */
167 unsigned int stream_delay;
168
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100169 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100170 unsigned char aloopback_mask;
171 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200172
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100173 /* power management */
174 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200175 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100176 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100177 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100178
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400179 /* jack detection */
180 struct snd_array jacks;
181
182 /* events */
183 struct snd_array events;
184
Matt2f2f4252005-04-13 14:45:30 +0200185 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100186 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400187 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100188 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200189 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100190 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200191
192 /* capture */
193 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200194 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200195 hda_nid_t *mux_nids;
196 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200197 hda_nid_t *dmic_nids;
198 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100199 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100200 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200201 hda_nid_t *smux_nids;
202 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400203 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200204
Mattdabbed62005-06-14 10:19:34 +0200205 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100206 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200207 hda_nid_t anabeep_nid;
208 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200209
Matt2f2f4252005-04-13 14:45:30 +0200210 /* pin widgets */
211 hda_nid_t *pin_nids;
212 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200213 unsigned int *pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200214
215 /* codec specific stuff */
216 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100217 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200218
219 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200220 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100221 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200222 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100223 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200224 struct hda_input_mux *sinput_mux;
225 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400226 unsigned int cur_amux;
227 hda_nid_t *amp_nids;
228 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200229 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200230
Matt Porter403d1942005-11-29 15:00:51 +0100231 /* i/o switches */
232 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200233 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100234 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200235 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200236
Mattc7d4b2f2005-06-27 14:59:41 +0200237 struct hda_pcm pcm_rec[2]; /* PCM information */
238
239 /* dynamic controls and input_mux */
240 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200241 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200242 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200243 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200244 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400245 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100246 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200247};
248
249static hda_nid_t stac9200_adc_nids[1] = {
250 0x03,
251};
252
253static hda_nid_t stac9200_mux_nids[1] = {
254 0x0c,
255};
256
257static hda_nid_t stac9200_dac_nids[1] = {
258 0x02,
259};
260
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100261static hda_nid_t stac92hd73xx_pwr_nids[8] = {
262 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
263 0x0f, 0x10, 0x11
264};
265
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400266static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
267 0x26, 0,
268};
269
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100270static hda_nid_t stac92hd73xx_adc_nids[2] = {
271 0x1a, 0x1b
272};
273
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400274#define DELL_M6_AMP 2
275static hda_nid_t stac92hd73xx_amp_nids[3] = {
276 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400277};
278
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100279#define STAC92HD73XX_NUM_DMICS 2
280static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
281 0x13, 0x14, 0
282};
283
284#define STAC92HD73_DAC_COUNT 5
285static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
286 0x15, 0x16, 0x17, 0x18, 0x19,
287};
288
289static hda_nid_t stac92hd73xx_mux_nids[4] = {
290 0x28, 0x29, 0x2a, 0x2b,
291};
292
293static hda_nid_t stac92hd73xx_dmux_nids[2] = {
294 0x20, 0x21,
295};
296
Matthew Ranostayd9737752008-09-07 12:03:41 +0200297static hda_nid_t stac92hd73xx_smux_nids[2] = {
298 0x22, 0x23,
299};
300
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200301#define STAC92HD83XXX_NUM_DMICS 2
302static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
303 0x11, 0x12, 0
304};
305
306#define STAC92HD81_DAC_COUNT 2
307#define STAC92HD83_DAC_COUNT 3
308static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
309 0x13, 0x14, 0x22,
310};
311
312static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
313 0x17, 0x18,
314};
315
316static hda_nid_t stac92hd83xxx_adc_nids[2] = {
317 0x15, 0x16,
318};
319
320static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
321 0xa, 0xb, 0xd, 0xe,
322};
323
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400324static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
325 0x1e, 0,
326};
327
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200328static unsigned int stac92hd83xxx_pwr_mapping[4] = {
329 0x03, 0x0c, 0x10, 0x40,
330};
331
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100332static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
333 0x0a, 0x0d, 0x0f
334};
335
Matthew Ranostaye035b842007-11-06 11:53:55 +0100336static hda_nid_t stac92hd71bxx_adc_nids[2] = {
337 0x12, 0x13,
338};
339
340static hda_nid_t stac92hd71bxx_mux_nids[2] = {
341 0x1a, 0x1b
342};
343
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400344static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
345 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100346};
347
Matthew Ranostayd9737752008-09-07 12:03:41 +0200348static hda_nid_t stac92hd71bxx_smux_nids[2] = {
349 0x24, 0x25,
350};
351
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100352static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100353 0x10, /*0x11, */
354};
355
356#define STAC92HD71BXX_NUM_DMICS 2
357static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
358 0x18, 0x19, 0
359};
360
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400361static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
362 0x22, 0
363};
364
Tobin Davis8e21c342007-01-08 11:04:17 +0100365static hda_nid_t stac925x_adc_nids[1] = {
366 0x03,
367};
368
369static hda_nid_t stac925x_mux_nids[1] = {
370 0x0f,
371};
372
373static hda_nid_t stac925x_dac_nids[1] = {
374 0x02,
375};
376
Takashi Iwaif6e98522007-10-16 14:27:04 +0200377#define STAC925X_NUM_DMICS 1
378static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
379 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200380};
381
Takashi Iwai1697055e2007-12-18 18:05:52 +0100382static hda_nid_t stac925x_dmux_nids[1] = {
383 0x14,
384};
385
Matt2f2f4252005-04-13 14:45:30 +0200386static hda_nid_t stac922x_adc_nids[2] = {
387 0x06, 0x07,
388};
389
390static hda_nid_t stac922x_mux_nids[2] = {
391 0x12, 0x13,
392};
393
Matt Porter3cc08dc2006-01-23 15:27:49 +0100394static hda_nid_t stac927x_adc_nids[3] = {
395 0x07, 0x08, 0x09
396};
397
398static hda_nid_t stac927x_mux_nids[3] = {
399 0x15, 0x16, 0x17
400};
401
Matthew Ranostayd9737752008-09-07 12:03:41 +0200402static hda_nid_t stac927x_smux_nids[1] = {
403 0x21,
404};
405
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100406static hda_nid_t stac927x_dac_nids[6] = {
407 0x02, 0x03, 0x04, 0x05, 0x06, 0
408};
409
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100410static hda_nid_t stac927x_dmux_nids[1] = {
411 0x1b,
412};
413
Matthew Ranostay7f168592007-10-18 17:38:17 +0200414#define STAC927X_NUM_DMICS 2
415static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
416 0x13, 0x14, 0
417};
418
Matthew Ranostay65973632008-09-16 10:39:37 -0400419static const char *stac927x_spdif_labels[5] = {
420 "Digital Playback", "ADAT", "Analog Mux 1",
421 "Analog Mux 2", "Analog Mux 3"
422};
423
Matt Porterf3302a52006-07-31 12:49:34 +0200424static hda_nid_t stac9205_adc_nids[2] = {
425 0x12, 0x13
426};
427
428static hda_nid_t stac9205_mux_nids[2] = {
429 0x19, 0x1a
430};
431
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100432static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100433 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100434};
435
Matthew Ranostayd9737752008-09-07 12:03:41 +0200436static hda_nid_t stac9205_smux_nids[1] = {
437 0x21,
438};
439
Takashi Iwaif6e98522007-10-16 14:27:04 +0200440#define STAC9205_NUM_DMICS 2
441static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
442 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200443};
444
Mattc7d4b2f2005-06-27 14:59:41 +0200445static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200446 0x08, 0x09, 0x0d, 0x0e,
447 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200448};
449
Tobin Davis8e21c342007-01-08 11:04:17 +0100450static hda_nid_t stac925x_pin_nids[8] = {
451 0x07, 0x08, 0x0a, 0x0b,
452 0x0c, 0x0d, 0x10, 0x11,
453};
454
Matt2f2f4252005-04-13 14:45:30 +0200455static hda_nid_t stac922x_pin_nids[10] = {
456 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
457 0x0f, 0x10, 0x11, 0x15, 0x1b,
458};
459
Matthew Ranostaya7662642008-02-21 07:51:14 +0100460static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100461 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
462 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200463 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100464};
465
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200466static hda_nid_t stac92hd83xxx_pin_nids[14] = {
467 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
468 0x0f, 0x10, 0x11, 0x12, 0x13,
469 0x1d, 0x1e, 0x1f, 0x20
470};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400471static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100472 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
473 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400474 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100475};
476
Matt Porter3cc08dc2006-01-23 15:27:49 +0100477static hda_nid_t stac927x_pin_nids[14] = {
478 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
479 0x0f, 0x10, 0x11, 0x12, 0x13,
480 0x14, 0x21, 0x22, 0x23,
481};
482
Matt Porterf3302a52006-07-31 12:49:34 +0200483static hda_nid_t stac9205_pin_nids[12] = {
484 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
485 0x0f, 0x14, 0x16, 0x17, 0x18,
486 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200487};
488
Matthew Ranostay89385032008-09-11 09:49:39 -0400489#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
490
491static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
492 struct snd_ctl_elem_value *ucontrol)
493{
494 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
495 struct sigmatel_spec *spec = codec->spec;
496 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
497
498 kcontrol->private_value ^= get_amp_nid(kcontrol);
499 kcontrol->private_value |= nid;
500
501 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
502}
503
504static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
505 struct snd_ctl_elem_value *ucontrol)
506{
507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
508 struct sigmatel_spec *spec = codec->spec;
509 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
510
511 kcontrol->private_value ^= get_amp_nid(kcontrol);
512 kcontrol->private_value |= nid;
513
514 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
515}
516
Matt Porter8b657272006-10-26 17:12:59 +0200517static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_info *uinfo)
519{
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 struct sigmatel_spec *spec = codec->spec;
522 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
523}
524
525static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100530 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200531
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100532 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200533 return 0;
534}
535
536static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
538{
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100541 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200542
543 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100544 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200545}
546
Matthew Ranostayd9737752008-09-07 12:03:41 +0200547static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_info *uinfo)
549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct sigmatel_spec *spec = codec->spec;
552 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
553}
554
555static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
557{
558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 struct sigmatel_spec *spec = codec->spec;
560 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
561
562 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
563 return 0;
564}
565
566static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
568{
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400571 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200572 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400573 int err, val;
574 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200575
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400576 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200577 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400578 if (err < 0)
579 return err;
580
581 if (spec->spdif_mute) {
582 if (smux_idx == 0)
583 nid = spec->multiout.dig_out_nid;
584 else
585 nid = codec->slave_dig_outs[smux_idx - 1];
586 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
587 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400588 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100589 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400590 /* un/mute SPDIF out */
591 snd_hda_codec_write_cache(codec, nid, 0,
592 AC_VERB_SET_AMP_GAIN_MUTE, val);
593 }
594 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200595}
596
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100597static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200601 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200602}
603
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100604static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200605{
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
608 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
609
610 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
611 return 0;
612}
613
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100614static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200615{
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
619
Mattc7d4b2f2005-06-27 14:59:41 +0200620 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200621 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
622}
623
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100624static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_info *uinfo)
626{
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
629 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
630}
631
632static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637
638 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
639 return 0;
640}
641
642static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
644{
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
647
648 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
649 spec->mono_nid, &spec->cur_mmux);
650}
651
Matthew Ranostay89385032008-09-11 09:49:39 -0400652static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_info *uinfo)
654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
657 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
658}
659
660static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_value *ucontrol)
662{
663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
664 struct sigmatel_spec *spec = codec->spec;
665
666 ucontrol->value.enumerated.item[0] = spec->cur_amux;
667 return 0;
668}
669
670static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
672{
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
675 struct snd_kcontrol *ctl =
676 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
677 if (!ctl)
678 return -EINVAL;
679
680 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
681 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
682
683 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
684 0, &spec->cur_amux);
685}
686
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200687#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
688
689static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
691{
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100693 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200694 struct sigmatel_spec *spec = codec->spec;
695
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100696 ucontrol->value.integer.value[0] = !!(spec->aloopback &
697 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200698 return 0;
699}
700
701static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
703{
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100706 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100708 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200709
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100710 idx_val = spec->aloopback_mask << idx;
711 if (ucontrol->value.integer.value[0])
712 val = spec->aloopback | idx_val;
713 else
714 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100715 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200716 return 0;
717
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100718 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100720 /* Only return the bits defined by the shift value of the
721 * first two bytes of the mask
722 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200723 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100724 kcontrol->private_value & 0xFFFF, 0x0);
725 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200726
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100727 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200728 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100729 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200730 } else {
731 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100732 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200733 }
734
735 snd_hda_codec_write_cache(codec, codec->afg, 0,
736 kcontrol->private_value >> 16, dac_mode);
737
738 return 1;
739}
740
Mattc7d4b2f2005-06-27 14:59:41 +0200741static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200742 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200743 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200744 {}
745};
746
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200747static struct hda_verb stac9200_eapd_init[] = {
748 /* set dac0mux for dac converter */
749 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
750 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
751 {}
752};
753
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100754static struct hda_verb stac92hd73xx_6ch_core_init[] = {
755 /* set master volume and direct control */
756 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
757 /* setup audio connections */
758 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
759 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
761 /* setup adcs to point to mixer */
762 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
763 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100764 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
765 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
766 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
767 /* setup import muxs */
768 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
772 {}
773};
774
Matthew Ranostayd654a662008-03-14 08:46:51 +0100775static struct hda_verb dell_eq_core_init[] = {
776 /* set master volume to max value without distortion
777 * and direct control */
778 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
779 /* setup audio connections */
780 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400781 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100783 /* setup adcs to point to mixer */
784 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
786 /* setup import muxs */
787 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
791 {}
792};
793
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100794static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500795 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100796 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100797 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
798 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100799 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
800 /* setup adcs to point to mixer */
801 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
802 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
803 /* setup import muxs */
804 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
807 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
808 {}
809};
810
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100811static struct hda_verb stac92hd73xx_8ch_core_init[] = {
812 /* set master volume and direct control */
813 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
814 /* setup audio connections */
815 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
816 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
818 /* connect hp ports to dac3 */
819 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
820 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
821 /* setup adcs to point to mixer */
822 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
823 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100824 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 /* setup import muxs */
828 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
829 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
830 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
831 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
832 {}
833};
834
835static struct hda_verb stac92hd73xx_10ch_core_init[] = {
836 /* set master volume and direct control */
837 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
838 /* setup audio connections */
839 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
840 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
841 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
842 /* dac3 is connected to import3 mux */
843 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
844 /* connect hp ports to dac4 */
845 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
846 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
847 /* setup adcs to point to mixer */
848 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
849 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100850 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
851 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
852 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
853 /* setup import muxs */
854 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
855 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
856 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
857 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
858 {}
859};
860
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200861static struct hda_verb stac92hd83xxx_core_init[] = {
862 /* start of config #1 */
863 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
864
865 /* start of config #2 */
866 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
867 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
868 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
869
870 /* power state controls amps */
871 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
872};
873
Matthew Ranostaye035b842007-11-06 11:53:55 +0100874static struct hda_verb stac92hd71bxx_core_init[] = {
875 /* set master volume and direct control */
876 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
877 /* connect headphone jack to dac1 */
878 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100879 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
880 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
881 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
882 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100883};
884
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400885#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100886static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200887 /* start of config #1 */
888
889 /* connect port 0f to audio mixer */
890 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200891 /* unmute right and left channels for node 0x0f */
892 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
893 /* start of config #2 */
894
Matthew Ranostay541eee82007-12-14 12:08:04 +0100895 /* set master volume and direct control */
896 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
897 /* connect headphone jack to dac1 */
898 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200899 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100900 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
901 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100902 {}
903};
904
Tobin Davis8e21c342007-01-08 11:04:17 +0100905static struct hda_verb stac925x_core_init[] = {
906 /* set dac0mux for dac converter */
907 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
908 {}
909};
910
Mattc7d4b2f2005-06-27 14:59:41 +0200911static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200912 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200913 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200914 {}
915};
916
Tobin Davis93ed1502006-09-01 21:03:12 +0200917static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200918 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200920 /* unmute node 0x1b */
921 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
922 /* select node 0x03 as DAC */
923 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
924 {}
925};
926
Matt Porter3cc08dc2006-01-23 15:27:49 +0100927static struct hda_verb stac927x_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100932 {}
933};
934
Matt Porterf3302a52006-07-31 12:49:34 +0200935static struct hda_verb stac9205_core_init[] = {
936 /* set master volume and direct control */
937 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200938 /* enable analog pc beep path */
939 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200940 {}
941};
942
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100943#define STAC_MONO_MUX \
944 { \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Mono Mux", \
947 .count = 1, \
948 .info = stac92xx_mono_mux_enum_info, \
949 .get = stac92xx_mono_mux_enum_get, \
950 .put = stac92xx_mono_mux_enum_put, \
951 }
952
Matthew Ranostay89385032008-09-11 09:49:39 -0400953#define STAC_AMP_MUX \
954 { \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = "Amp Selector Capture Switch", \
957 .count = 1, \
958 .info = stac92xx_amp_mux_enum_info, \
959 .get = stac92xx_amp_mux_enum_get, \
960 .put = stac92xx_amp_mux_enum_put, \
961 }
962
963#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
964 { \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = xname, \
967 .index = 0, \
968 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
969 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
970 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
971 .info = stac92xx_amp_volume_info, \
972 .get = stac92xx_amp_volume_get, \
973 .put = stac92xx_amp_volume_put, \
974 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
975 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
976 }
977
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200978#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200979 { \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200982 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200983 .info = stac92xx_mux_enum_info, \
984 .get = stac92xx_mux_enum_get, \
985 .put = stac92xx_mux_enum_put, \
986 }
987
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100988#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200989 { \
990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
991 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100992 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200993 .info = stac92xx_aloopback_info, \
994 .get = stac92xx_aloopback_get, \
995 .put = stac92xx_aloopback_put, \
996 .private_value = verb_read | (verb_write << 16), \
997 }
998
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100999static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +02001000 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1001 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001002 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +02001003 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1004 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001005 { } /* end */
1006};
1007
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001008#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001009static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001010 /* start of config #1 */
1011 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1012 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1013
1014 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1015 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1016
1017 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1018 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1019
1020 /* start of config #2 */
1021 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1022 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1023
1024 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1025 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1026
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1028
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001029 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031
1032 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1033 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001035 { } /* end */
1036};
1037
1038static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001039 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1040
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001041 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1042 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1043
1044 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1046
1047 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1048 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1049
1050 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1051 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1052
1053 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1054 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1055
1056 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1057 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1058
1059 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1060 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1061 { } /* end */
1062};
1063
1064static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001065 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1066
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001067 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1068 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1069
1070 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1071 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1072
1073 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1074 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1075
1076 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1077 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1078
1079 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1080 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1081
1082 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1083 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1084
1085 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1086 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1087 { } /* end */
1088};
1089
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001090
1091static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1092 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1093 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1094
1095 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1096 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1097
1098 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1099 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1100
1101 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1102 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1103
1104 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1105 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1106
1107 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1108 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1109
1110 /*
1111 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1112 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1113 */
1114 { } /* end */
1115};
1116
Matthew Ranostay541eee82007-12-14 12:08:04 +01001117static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001118 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001119 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001120
Matthew Ranostay9b359472007-11-07 13:03:12 +01001121 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001123
1124 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1125 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001126 /* analog pc-beep replaced with digital beep support */
1127 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001128 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1129 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001130 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001131
Matthew Ranostay687cb982008-10-11 13:52:43 -04001132 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001134
Matthew Ranostay687cb982008-10-11 13:52:43 -04001135 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1136 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001137
1138 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1139 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1140
1141 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1142 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001143 { } /* end */
1144};
1145
Matthew Ranostay541eee82007-12-14 12:08:04 +01001146static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001147 STAC_INPUT_SOURCE(2),
1148 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1149
Matthew Ranostay541eee82007-12-14 12:08:04 +01001150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001152
1153 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1154 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001155 { } /* end */
1156};
1157
Tobin Davis8e21c342007-01-08 11:04:17 +01001158static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001159 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001160 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001161 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001162 { } /* end */
1163};
1164
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001165static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001167 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001168
1169 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001171
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001174 { } /* end */
1175};
1176
1177/* This needs to be generated dynamically based on sequence */
1178static struct snd_kcontrol_new stac922x_mixer[] = {
1179 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001180 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001182
1183 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1184 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001185 { } /* end */
1186};
1187
1188
1189static struct snd_kcontrol_new stac927x_mixer[] = {
1190 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001191 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001192
1193 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1194 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001195
1196 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1197 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001198
1199 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1200 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001201 { } /* end */
1202};
1203
Takashi Iwai1697055e2007-12-18 18:05:52 +01001204static struct snd_kcontrol_new stac_dmux_mixer = {
1205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1206 .name = "Digital Input Source",
1207 /* count set later */
1208 .info = stac92xx_dmux_enum_info,
1209 .get = stac92xx_dmux_enum_get,
1210 .put = stac92xx_dmux_enum_put,
1211};
1212
Matthew Ranostayd9737752008-09-07 12:03:41 +02001213static struct snd_kcontrol_new stac_smux_mixer = {
1214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001215 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001216 /* count set later */
1217 .info = stac92xx_smux_enum_info,
1218 .get = stac92xx_smux_enum_get,
1219 .put = stac92xx_smux_enum_put,
1220};
1221
Takashi Iwai2134ea42008-01-10 16:53:55 +01001222static const char *slave_vols[] = {
1223 "Front Playback Volume",
1224 "Surround Playback Volume",
1225 "Center Playback Volume",
1226 "LFE Playback Volume",
1227 "Side Playback Volume",
1228 "Headphone Playback Volume",
1229 "Headphone Playback Volume",
1230 "Speaker Playback Volume",
1231 "External Speaker Playback Volume",
1232 "Speaker2 Playback Volume",
1233 NULL
1234};
1235
1236static const char *slave_sws[] = {
1237 "Front Playback Switch",
1238 "Surround Playback Switch",
1239 "Center Playback Switch",
1240 "LFE Playback Switch",
1241 "Side Playback Switch",
1242 "Headphone Playback Switch",
1243 "Headphone Playback Switch",
1244 "Speaker Playback Switch",
1245 "External Speaker Playback Switch",
1246 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001247 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001248 NULL
1249};
1250
Takashi Iwai603c4012008-07-30 15:01:44 +02001251static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001252static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001253
Matt2f2f4252005-04-13 14:45:30 +02001254static int stac92xx_build_controls(struct hda_codec *codec)
1255{
1256 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001257 struct auto_pin_cfg *cfg = &spec->autocfg;
1258 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001259 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001260 int i;
Matt2f2f4252005-04-13 14:45:30 +02001261
1262 err = snd_hda_add_new_ctls(codec, spec->mixer);
1263 if (err < 0)
1264 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001265
1266 for (i = 0; i < spec->num_mixers; i++) {
1267 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1268 if (err < 0)
1269 return err;
1270 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001271 if (spec->num_dmuxes > 0) {
1272 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001273 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001274 snd_ctl_new1(&stac_dmux_mixer, codec));
1275 if (err < 0)
1276 return err;
1277 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001278 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001279 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1280 struct hda_input_mux *smux = &spec->private_smux;
1281 /* check for mute support on SPDIF out */
1282 if (wcaps & AC_WCAP_OUT_AMP) {
1283 smux->items[smux->num_items].label = "Off";
1284 smux->items[smux->num_items].index = 0;
1285 smux->num_items++;
1286 spec->spdif_mute = 1;
1287 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001288 stac_smux_mixer.count = spec->num_smuxes;
1289 err = snd_ctl_add(codec->bus->card,
1290 snd_ctl_new1(&stac_smux_mixer, codec));
1291 if (err < 0)
1292 return err;
1293 }
Mattc7d4b2f2005-06-27 14:59:41 +02001294
Mattdabbed62005-06-14 10:19:34 +02001295 if (spec->multiout.dig_out_nid) {
1296 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1297 if (err < 0)
1298 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001299 err = snd_hda_create_spdif_share_sw(codec,
1300 &spec->multiout);
1301 if (err < 0)
1302 return err;
1303 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001304 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001305 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001306 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1307 if (err < 0)
1308 return err;
1309 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001310
1311 /* if we have no master control, let's create it */
1312 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001313 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001314 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001315 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001316 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001317 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001318 if (err < 0)
1319 return err;
1320 }
1321 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1322 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1323 NULL, slave_sws);
1324 if (err < 0)
1325 return err;
1326 }
1327
Takashi Iwai603c4012008-07-30 15:01:44 +02001328 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001329
1330 /* create jack input elements */
1331 if (spec->hp_detect) {
1332 for (i = 0; i < cfg->hp_outs; i++) {
1333 int type = SND_JACK_HEADPHONE;
1334 nid = cfg->hp_pins[i];
1335 /* jack detection */
1336 if (cfg->hp_outs == i)
1337 type |= SND_JACK_LINEOUT;
1338 err = stac92xx_add_jack(codec, nid, type);
1339 if (err < 0)
1340 return err;
1341 }
1342 }
1343 for (i = 0; i < cfg->line_outs; i++) {
1344 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1345 SND_JACK_LINEOUT);
1346 if (err < 0)
1347 return err;
1348 }
1349 for (i = 0; i < AUTO_PIN_LAST; i++) {
1350 nid = cfg->input_pins[i];
1351 if (nid) {
1352 err = stac92xx_add_jack(codec, nid,
1353 SND_JACK_MICROPHONE);
1354 if (err < 0)
1355 return err;
1356 }
1357 }
1358
Mattdabbed62005-06-14 10:19:34 +02001359 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001360}
1361
Matt Porter403d1942005-11-29 15:00:51 +01001362static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001363 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001364 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1365};
1366
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001367/*
1368 STAC 9200 pin configs for
1369 102801A8
1370 102801DE
1371 102801E8
1372*/
1373static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001374 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1375 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001376};
1377
1378/*
1379 STAC 9200 pin configs for
1380 102801C0
1381 102801C1
1382*/
1383static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001384 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1385 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001386};
1387
1388/*
1389 STAC 9200 pin configs for
1390 102801C4 (Dell Dimension E310)
1391 102801C5
1392 102801C7
1393 102801D9
1394 102801DA
1395 102801E3
1396*/
1397static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001398 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1399 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001400};
1401
1402
1403/*
1404 STAC 9200-32 pin configs for
1405 102801B5 (Dell Inspiron 630m)
1406 102801D8 (Dell Inspiron 640m)
1407*/
1408static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001409 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1410 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001411};
1412
1413/*
1414 STAC 9200-32 pin configs for
1415 102801C2 (Dell Latitude D620)
1416 102801C8
1417 102801CC (Dell Latitude D820)
1418 102801D4
1419 102801D6
1420*/
1421static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001422 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1423 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001424};
1425
1426/*
1427 STAC 9200-32 pin configs for
1428 102801CE (Dell XPS M1710)
1429 102801CF (Dell Precision M90)
1430*/
1431static unsigned int dell9200_m23_pin_configs[8] = {
1432 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1433 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1434};
1435
1436/*
1437 STAC 9200-32 pin configs for
1438 102801C9
1439 102801CA
1440 102801CB (Dell Latitude 120L)
1441 102801D3
1442*/
1443static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001444 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1445 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001446};
1447
1448/*
1449 STAC 9200-32 pin configs for
1450 102801BD (Dell Inspiron E1505n)
1451 102801EE
1452 102801EF
1453*/
1454static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001455 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1456 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001457};
1458
1459/*
1460 STAC 9200-32 pin configs for
1461 102801F5 (Dell Inspiron 1501)
1462 102801F6
1463*/
1464static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001465 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1466 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001467};
1468
1469/*
1470 STAC 9200-32
1471 102801CD (Dell Inspiron E1705/9400)
1472*/
1473static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001474 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1475 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001476};
1477
Tobin Davisbf277782008-02-03 20:31:47 +01001478static unsigned int oqo9200_pin_configs[8] = {
1479 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1480 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1481};
1482
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001483
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001484static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1485 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001486 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001487 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1488 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1489 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1490 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1491 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1492 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1493 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1494 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1495 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1496 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001497 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001498};
1499
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001500static const char *stac9200_models[STAC_9200_MODELS] = {
1501 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001502 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 [STAC_9200_DELL_D21] = "dell-d21",
1504 [STAC_9200_DELL_D22] = "dell-d22",
1505 [STAC_9200_DELL_D23] = "dell-d23",
1506 [STAC_9200_DELL_M21] = "dell-m21",
1507 [STAC_9200_DELL_M22] = "dell-m22",
1508 [STAC_9200_DELL_M23] = "dell-m23",
1509 [STAC_9200_DELL_M24] = "dell-m24",
1510 [STAC_9200_DELL_M25] = "dell-m25",
1511 [STAC_9200_DELL_M26] = "dell-m26",
1512 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001513 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001514 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001515};
1516
1517static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1518 /* SigmaTel reference board */
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1520 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001521 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1523 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001525 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1527 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1529 "unknown Dell", STAC_9200_DELL_D22),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1531 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001533 "Dell Latitude D620", STAC_9200_DELL_M22),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1535 "unknown Dell", STAC_9200_DELL_D23),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1537 "unknown Dell", STAC_9200_DELL_D23),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1539 "unknown Dell", STAC_9200_DELL_M22),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1541 "unknown Dell", STAC_9200_DELL_M24),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1543 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001545 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001547 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001549 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001551 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001553 "Dell Precision M90", STAC_9200_DELL_M23),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1555 "unknown Dell", STAC_9200_DELL_M22),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1557 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001559 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001561 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1563 "unknown Dell", STAC_9200_DELL_D23),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1565 "unknown Dell", STAC_9200_DELL_D23),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1567 "unknown Dell", STAC_9200_DELL_D21),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1569 "unknown Dell", STAC_9200_DELL_D23),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1571 "unknown Dell", STAC_9200_DELL_D21),
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1573 "unknown Dell", STAC_9200_DELL_M25),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1575 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001576 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001577 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1579 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001580 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001581 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001582 /* Gateway machines needs EAPD to be set on resume */
1583 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1584 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1585 STAC_9200_GATEWAY),
1586 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1587 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001588 /* OQO Mobile */
1589 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001590 {} /* terminator */
1591};
1592
Tobin Davis8e21c342007-01-08 11:04:17 +01001593static unsigned int ref925x_pin_configs[8] = {
1594 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001595 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001596};
1597
1598static unsigned int stac925x_MA6_pin_configs[8] = {
1599 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1600 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1601};
1602
Tobin Davis2c11f952007-05-17 09:36:34 +02001603static unsigned int stac925x_PA6_pin_configs[8] = {
1604 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1605 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1606};
1607
Tobin Davis8e21c342007-01-08 11:04:17 +01001608static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001609 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1610 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001611};
1612
1613static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1614 [STAC_REF] = ref925x_pin_configs,
1615 [STAC_M2_2] = stac925xM2_2_pin_configs,
1616 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001617 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001618};
1619
1620static const char *stac925x_models[STAC_925x_MODELS] = {
1621 [STAC_REF] = "ref",
1622 [STAC_M2_2] = "m2-2",
1623 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001624 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001625};
1626
1627static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1628 /* SigmaTel reference board */
1629 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001630 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001631 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1632 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1633 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001634 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001635 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1636 {} /* terminator */
1637};
1638
Matthew Ranostaya7662642008-02-21 07:51:14 +01001639static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001640 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1641 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1642 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001643 0x01452050,
1644};
1645
1646static unsigned int dell_m6_pin_configs[13] = {
1647 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001648 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001649 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1650 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001651};
1652
1653static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001654 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1655 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001656 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001657};
1658
1659static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1660 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001661 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001662 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001663};
1664
1665static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1666 /* SigmaTel reference board */
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001668 "DFI LanParty", STAC_92HD73XX_REF),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwaid6752a52008-11-21 18:01:44 +01001670 "Dell Studio 1535", STAC_DELL_M6),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1672 "unknown Dell", STAC_DELL_M6),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1674 "unknown Dell", STAC_DELL_M6),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1676 "unknown Dell", STAC_DELL_M6),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1678 "unknown Dell", STAC_DELL_M6),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1680 "unknown Dell", STAC_DELL_M6),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1682 "unknown Dell", STAC_DELL_M6),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1684 "Dell Studio 15", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001685 {} /* terminator */
1686};
1687
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001688static unsigned int ref92hd83xxx_pin_configs[14] = {
1689 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1690 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1691 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1692 0x01451160, 0x98560170,
1693};
1694
1695static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1696 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1697};
1698
1699static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1700 [STAC_92HD83XXX_REF] = "ref",
1701};
1702
1703static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1704 /* SigmaTel reference board */
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1706 "DFI LanParty", STAC_92HD71BXX_REF),
1707};
1708
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001709static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001710 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001711 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001712 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001713};
1714
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001715static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001716 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001717 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001718 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001719};
1720
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001721static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001722 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1723 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001724 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001725};
1726
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001727static unsigned int dell_m4_3_pin_configs[11] = {
1728 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1729 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1730 0x40f000f0, 0x044413b0, 0x044413b0,
1731};
1732
Matthew Ranostaye035b842007-11-06 11:53:55 +01001733static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1734 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001735 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1736 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001737 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001738 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001739};
1740
1741static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1742 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001743 [STAC_DELL_M4_1] = "dell-m4-1",
1744 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001745 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001746 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001747};
1748
1749static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1750 /* SigmaTel reference board */
1751 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1752 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001753 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1754 "HP dv5", STAC_HP_M4),
1755 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1756 "HP dv7", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001757 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1758 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001759 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1760 "unknown Dell", STAC_DELL_M4_1),
1761 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1762 "unknown Dell", STAC_DELL_M4_1),
1763 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1764 "unknown Dell", STAC_DELL_M4_1),
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1766 "unknown Dell", STAC_DELL_M4_1),
1767 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1768 "unknown Dell", STAC_DELL_M4_1),
1769 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1770 "unknown Dell", STAC_DELL_M4_1),
1771 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1772 "unknown Dell", STAC_DELL_M4_1),
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1774 "unknown Dell", STAC_DELL_M4_2),
1775 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1776 "unknown Dell", STAC_DELL_M4_2),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1778 "unknown Dell", STAC_DELL_M4_2),
1779 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1780 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001781 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1782 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001783 {} /* terminator */
1784};
1785
Matt Porter403d1942005-11-29 15:00:51 +01001786static unsigned int ref922x_pin_configs[10] = {
1787 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1788 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001789 0x40000100, 0x40000100,
1790};
1791
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001792/*
1793 STAC 922X pin configs for
1794 102801A7
1795 102801AB
1796 102801A9
1797 102801D1
1798 102801D2
1799*/
1800static unsigned int dell_922x_d81_pin_configs[10] = {
1801 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1802 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1803 0x01813122, 0x400001f2,
1804};
1805
1806/*
1807 STAC 922X pin configs for
1808 102801AC
1809 102801D0
1810*/
1811static unsigned int dell_922x_d82_pin_configs[10] = {
1812 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1813 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1814 0x01813122, 0x400001f1,
1815};
1816
1817/*
1818 STAC 922X pin configs for
1819 102801BF
1820*/
1821static unsigned int dell_922x_m81_pin_configs[10] = {
1822 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1823 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1824 0x40C003f1, 0x405003f0,
1825};
1826
1827/*
1828 STAC 9221 A1 pin configs for
1829 102801D7 (Dell XPS M1210)
1830*/
1831static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001832 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1833 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001834 0x508003f3, 0x405003f4,
1835};
1836
Matt Porter403d1942005-11-29 15:00:51 +01001837static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001838 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001839 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1840 0x02a19120, 0x40000100,
1841};
1842
1843static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001844 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1845 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001846 0x02a19320, 0x40000100,
1847};
1848
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001849static unsigned int intel_mac_v1_pin_configs[10] = {
1850 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1851 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001852 0x400000fc, 0x400000fb,
1853};
1854
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001855static unsigned int intel_mac_v2_pin_configs[10] = {
1856 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1857 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001858 0x400000fc, 0x400000fb,
1859};
1860
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001861static unsigned int intel_mac_v3_pin_configs[10] = {
1862 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1863 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1864 0x400000fc, 0x400000fb,
1865};
1866
1867static unsigned int intel_mac_v4_pin_configs[10] = {
1868 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1869 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1870 0x400000fc, 0x400000fb,
1871};
1872
1873static unsigned int intel_mac_v5_pin_configs[10] = {
1874 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1875 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1876 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001877};
1878
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001879static unsigned int ecs202_pin_configs[10] = {
1880 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1881 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1882 0x9037012e, 0x40e000f2,
1883};
Takashi Iwai76c08822007-06-19 12:17:42 +02001884
Takashi Iwai19039bd2006-06-28 15:52:16 +02001885static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001886 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001887 [STAC_D945GTP3] = d945gtp3_pin_configs,
1888 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001889 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1890 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1891 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1892 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1893 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001894 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001895 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001896 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1897 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1898 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1899 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1900 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1901 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001902 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001903 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1904 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1905 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1906 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001907};
1908
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001909static const char *stac922x_models[STAC_922X_MODELS] = {
1910 [STAC_D945_REF] = "ref",
1911 [STAC_D945GTP5] = "5stack",
1912 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001913 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1914 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1915 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1916 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1917 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001918 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001919 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001920 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001921 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001922 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1923 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001924 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001925 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001926 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001927 [STAC_922X_DELL_D81] = "dell-d81",
1928 [STAC_922X_DELL_D82] = "dell-d82",
1929 [STAC_922X_DELL_M81] = "dell-m81",
1930 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001931};
1932
1933static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1934 /* SigmaTel reference board */
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1936 "DFI LanParty", STAC_D945_REF),
1937 /* Intel 945G based systems */
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1939 "Intel D945G", STAC_D945GTP3),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1941 "Intel D945G", STAC_D945GTP3),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1943 "Intel D945G", STAC_D945GTP3),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1945 "Intel D945G", STAC_D945GTP3),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1947 "Intel D945G", STAC_D945GTP3),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1949 "Intel D945G", STAC_D945GTP3),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1951 "Intel D945G", STAC_D945GTP3),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1953 "Intel D945G", STAC_D945GTP3),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1955 "Intel D945G", STAC_D945GTP3),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1957 "Intel D945G", STAC_D945GTP3),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1959 "Intel D945G", STAC_D945GTP3),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1961 "Intel D945G", STAC_D945GTP3),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1963 "Intel D945G", STAC_D945GTP3),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1965 "Intel D945G", STAC_D945GTP3),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1967 "Intel D945G", STAC_D945GTP3),
1968 /* Intel D945G 5-stack systems */
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1970 "Intel D945G", STAC_D945GTP5),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1972 "Intel D945G", STAC_D945GTP5),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1974 "Intel D945G", STAC_D945GTP5),
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1976 "Intel D945G", STAC_D945GTP5),
1977 /* Intel 945P based systems */
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1979 "Intel D945P", STAC_D945GTP3),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1981 "Intel D945P", STAC_D945GTP3),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1983 "Intel D945P", STAC_D945GTP3),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1985 "Intel D945P", STAC_D945GTP3),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1987 "Intel D945P", STAC_D945GTP3),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1989 "Intel D945P", STAC_D945GTP5),
1990 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001991 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001992 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001993 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001994 /* Dell systems */
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1996 "unknown Dell", STAC_922X_DELL_D81),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1998 "unknown Dell", STAC_922X_DELL_D81),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2000 "unknown Dell", STAC_922X_DELL_D81),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2002 "unknown Dell", STAC_922X_DELL_D82),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2004 "unknown Dell", STAC_922X_DELL_M81),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2006 "unknown Dell", STAC_922X_DELL_D82),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2008 "unknown Dell", STAC_922X_DELL_D81),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2010 "unknown Dell", STAC_922X_DELL_D81),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2012 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002013 /* ECS/PC Chips boards */
2014 SND_PCI_QUIRK(0x1019, 0x2144,
2015 "ECS/PC chips", STAC_ECS_202),
2016 SND_PCI_QUIRK(0x1019, 0x2608,
2017 "ECS/PC chips", STAC_ECS_202),
2018 SND_PCI_QUIRK(0x1019, 0x2633,
2019 "ECS/PC chips P17G/1333", STAC_ECS_202),
2020 SND_PCI_QUIRK(0x1019, 0x2811,
2021 "ECS/PC chips", STAC_ECS_202),
2022 SND_PCI_QUIRK(0x1019, 0x2812,
2023 "ECS/PC chips", STAC_ECS_202),
2024 SND_PCI_QUIRK(0x1019, 0x2813,
2025 "ECS/PC chips", STAC_ECS_202),
2026 SND_PCI_QUIRK(0x1019, 0x2814,
2027 "ECS/PC chips", STAC_ECS_202),
2028 SND_PCI_QUIRK(0x1019, 0x2815,
2029 "ECS/PC chips", STAC_ECS_202),
2030 SND_PCI_QUIRK(0x1019, 0x2816,
2031 "ECS/PC chips", STAC_ECS_202),
2032 SND_PCI_QUIRK(0x1019, 0x2817,
2033 "ECS/PC chips", STAC_ECS_202),
2034 SND_PCI_QUIRK(0x1019, 0x2818,
2035 "ECS/PC chips", STAC_ECS_202),
2036 SND_PCI_QUIRK(0x1019, 0x2819,
2037 "ECS/PC chips", STAC_ECS_202),
2038 SND_PCI_QUIRK(0x1019, 0x2820,
2039 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002040 {} /* terminator */
2041};
2042
Matt Porter3cc08dc2006-01-23 15:27:49 +01002043static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002044 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2045 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2046 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2047 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002048};
2049
Tobin Davis93ed1502006-09-01 21:03:12 +02002050static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002051 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2052 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2053 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2054 0x40000100, 0x40000100
2055};
2056
Tobin Davis93ed1502006-09-01 21:03:12 +02002057static unsigned int d965_5st_pin_configs[14] = {
2058 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2059 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2060 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2061 0x40000100, 0x40000100
2062};
2063
Tobin Davis4ff076e2007-08-07 11:48:12 +02002064static unsigned int dell_3st_pin_configs[14] = {
2065 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2066 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002067 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002068 0x40c003fc, 0x40000100
2069};
2070
Tobin Davis93ed1502006-09-01 21:03:12 +02002071static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002072 [STAC_D965_REF] = ref927x_pin_configs,
2073 [STAC_D965_3ST] = d965_3st_pin_configs,
2074 [STAC_D965_5ST] = d965_5st_pin_configs,
2075 [STAC_DELL_3ST] = dell_3st_pin_configs,
2076 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002077};
2078
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002079static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002080 [STAC_D965_REF] = "ref",
2081 [STAC_D965_3ST] = "3stack",
2082 [STAC_D965_5ST] = "5stack",
2083 [STAC_DELL_3ST] = "dell-3stack",
2084 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002085};
2086
2087static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2088 /* SigmaTel reference board */
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2090 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002091 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002094 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2103 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2109 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002111 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002116 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002125 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002126 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2129 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2133 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002135 {} /* terminator */
2136};
2137
Matt Porterf3302a52006-07-31 12:49:34 +02002138static unsigned int ref9205_pin_configs[12] = {
2139 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002140 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002141 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002142};
2143
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002144/*
2145 STAC 9205 pin configs for
2146 102801F1
2147 102801F2
2148 102801FC
2149 102801FD
2150 10280204
2151 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002152 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002153*/
2154static unsigned int dell_9205_m42_pin_configs[12] = {
2155 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2156 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2157 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2158};
2159
2160/*
2161 STAC 9205 pin configs for
2162 102801F9
2163 102801FA
2164 102801FE
2165 102801FF (Dell Precision M4300)
2166 10280206
2167 10280200
2168 10280201
2169*/
2170static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002171 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2172 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2173 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2174};
2175
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002176static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002177 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2178 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2179 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2180};
2181
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002182static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002183 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002184 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2185 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2186 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002187};
2188
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002189static const char *stac9205_models[STAC_9205_MODELS] = {
2190 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002191 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002192 [STAC_9205_DELL_M43] = "dell-m43",
2193 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002194};
2195
2196static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2197 /* SigmaTel reference board */
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2199 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2201 "unknown Dell", STAC_9205_DELL_M42),
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2203 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002205 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2207 "Dell Precision", STAC_9205_DELL_M43),
2208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2209 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2211 "unknown Dell", STAC_9205_DELL_M42),
2212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2213 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2215 "Dell Precision", STAC_9205_DELL_M43),
2216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002217 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2219 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2221 "Dell Precision", STAC_9205_DELL_M43),
2222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2223 "Dell Precision", STAC_9205_DELL_M43),
2224 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2225 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2227 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002228 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2229 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002230 {} /* terminator */
2231};
2232
Richard Fish11b44bb2006-08-23 18:31:34 +02002233static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2234{
2235 int i;
2236 struct sigmatel_spec *spec = codec->spec;
2237
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002238 kfree(spec->pin_configs);
2239 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2240 GFP_KERNEL);
2241 if (!spec->pin_configs)
2242 return -ENOMEM;
Richard Fish11b44bb2006-08-23 18:31:34 +02002243
2244 for (i = 0; i < spec->num_pins; i++) {
2245 hda_nid_t nid = spec->pin_nids[i];
2246 unsigned int pin_cfg;
2247
2248 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2249 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2250 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2251 nid, pin_cfg);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002252 spec->pin_configs[i] = pin_cfg;
Richard Fish11b44bb2006-08-23 18:31:34 +02002253 }
2254
2255 return 0;
2256}
2257
Matthew Ranostay87d48362007-07-17 11:52:24 +02002258static void stac92xx_set_config_reg(struct hda_codec *codec,
2259 hda_nid_t pin_nid, unsigned int pin_config)
2260{
2261 int i;
2262 snd_hda_codec_write(codec, pin_nid, 0,
2263 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2264 pin_config & 0x000000ff);
2265 snd_hda_codec_write(codec, pin_nid, 0,
2266 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2267 (pin_config & 0x0000ff00) >> 8);
2268 snd_hda_codec_write(codec, pin_nid, 0,
2269 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2270 (pin_config & 0x00ff0000) >> 16);
2271 snd_hda_codec_write(codec, pin_nid, 0,
2272 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2273 pin_config >> 24);
2274 i = snd_hda_codec_read(codec, pin_nid, 0,
2275 AC_VERB_GET_CONFIG_DEFAULT,
2276 0x00);
2277 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2278 pin_nid, i);
2279}
2280
Matt2f2f4252005-04-13 14:45:30 +02002281static void stac92xx_set_config_regs(struct hda_codec *codec)
2282{
2283 int i;
2284 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002285
Matthew Ranostay87d48362007-07-17 11:52:24 +02002286 if (!spec->pin_configs)
2287 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002288
Matthew Ranostay87d48362007-07-17 11:52:24 +02002289 for (i = 0; i < spec->num_pins; i++)
2290 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2291 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002292}
Matt2f2f4252005-04-13 14:45:30 +02002293
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002294static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2295{
2296 struct sigmatel_spec *spec = codec->spec;
2297
2298 if (!pins)
2299 return stac92xx_save_bios_config_regs(codec);
2300
2301 kfree(spec->pin_configs);
2302 spec->pin_configs = kmemdup(pins,
2303 spec->num_pins * sizeof(*pins),
2304 GFP_KERNEL);
2305 if (!spec->pin_configs)
2306 return -ENOMEM;
2307
2308 stac92xx_set_config_regs(codec);
2309 return 0;
2310}
2311
2312static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2313 unsigned int cfg)
2314{
2315 struct sigmatel_spec *spec = codec->spec;
2316 int i;
2317
2318 for (i = 0; i < spec->num_pins; i++) {
2319 if (spec->pin_nids[i] == nid) {
2320 spec->pin_configs[i] = cfg;
2321 stac92xx_set_config_reg(codec, nid, cfg);
2322 break;
2323 }
2324 }
2325}
2326
Matt2f2f4252005-04-13 14:45:30 +02002327/*
2328 * Analog playback callbacks
2329 */
2330static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2331 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002332 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002333{
2334 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002335 if (spec->stream_delay)
2336 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002337 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2338 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002339}
2340
2341static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2342 struct hda_codec *codec,
2343 unsigned int stream_tag,
2344 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002345 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002346{
2347 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002348 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002349}
2350
2351static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002353 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002354{
2355 struct sigmatel_spec *spec = codec->spec;
2356 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2357}
2358
2359/*
Mattdabbed62005-06-14 10:19:34 +02002360 * Digital playback callbacks
2361 */
2362static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2363 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002364 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002365{
2366 struct sigmatel_spec *spec = codec->spec;
2367 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2368}
2369
2370static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2371 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002372 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002373{
2374 struct sigmatel_spec *spec = codec->spec;
2375 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2376}
2377
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002378static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2379 struct hda_codec *codec,
2380 unsigned int stream_tag,
2381 unsigned int format,
2382 struct snd_pcm_substream *substream)
2383{
2384 struct sigmatel_spec *spec = codec->spec;
2385 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2386 stream_tag, format, substream);
2387}
2388
Mattdabbed62005-06-14 10:19:34 +02002389
2390/*
Matt2f2f4252005-04-13 14:45:30 +02002391 * Analog capture callbacks
2392 */
2393static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2394 struct hda_codec *codec,
2395 unsigned int stream_tag,
2396 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002397 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002398{
2399 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002400 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002401
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002402 if (spec->powerdown_adcs) {
2403 msleep(40);
2404 snd_hda_codec_write_cache(codec, nid, 0,
2405 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2406 }
2407 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002408 return 0;
2409}
2410
2411static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2412 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002413 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002414{
2415 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002416 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002417
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002418 snd_hda_codec_cleanup_stream(codec, nid);
2419 if (spec->powerdown_adcs)
2420 snd_hda_codec_write_cache(codec, nid, 0,
2421 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002422 return 0;
2423}
2424
Mattdabbed62005-06-14 10:19:34 +02002425static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2426 .substreams = 1,
2427 .channels_min = 2,
2428 .channels_max = 2,
2429 /* NID is set in stac92xx_build_pcms */
2430 .ops = {
2431 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002432 .close = stac92xx_dig_playback_pcm_close,
2433 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002434 },
2435};
2436
2437static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2438 .substreams = 1,
2439 .channels_min = 2,
2440 .channels_max = 2,
2441 /* NID is set in stac92xx_build_pcms */
2442};
2443
Matt2f2f4252005-04-13 14:45:30 +02002444static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2445 .substreams = 1,
2446 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002447 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002448 .nid = 0x02, /* NID to query formats and rates */
2449 .ops = {
2450 .open = stac92xx_playback_pcm_open,
2451 .prepare = stac92xx_playback_pcm_prepare,
2452 .cleanup = stac92xx_playback_pcm_cleanup
2453 },
2454};
2455
Matt Porter3cc08dc2006-01-23 15:27:49 +01002456static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2457 .substreams = 1,
2458 .channels_min = 2,
2459 .channels_max = 2,
2460 .nid = 0x06, /* NID to query formats and rates */
2461 .ops = {
2462 .open = stac92xx_playback_pcm_open,
2463 .prepare = stac92xx_playback_pcm_prepare,
2464 .cleanup = stac92xx_playback_pcm_cleanup
2465 },
2466};
2467
Matt2f2f4252005-04-13 14:45:30 +02002468static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002469 .channels_min = 2,
2470 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002471 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002472 .ops = {
2473 .prepare = stac92xx_capture_pcm_prepare,
2474 .cleanup = stac92xx_capture_pcm_cleanup
2475 },
2476};
2477
2478static int stac92xx_build_pcms(struct hda_codec *codec)
2479{
2480 struct sigmatel_spec *spec = codec->spec;
2481 struct hda_pcm *info = spec->pcm_rec;
2482
2483 codec->num_pcms = 1;
2484 codec->pcm_info = info;
2485
Mattc7d4b2f2005-06-27 14:59:41 +02002486 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002487 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002488 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002489 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002490 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002491
2492 if (spec->alt_switch) {
2493 codec->num_pcms++;
2494 info++;
2495 info->name = "STAC92xx Analog Alt";
2496 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2497 }
Matt2f2f4252005-04-13 14:45:30 +02002498
Mattdabbed62005-06-14 10:19:34 +02002499 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2500 codec->num_pcms++;
2501 info++;
2502 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002503 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002504 if (spec->multiout.dig_out_nid) {
2505 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2506 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2507 }
2508 if (spec->dig_in_nid) {
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2510 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2511 }
2512 }
2513
Matt2f2f4252005-04-13 14:45:30 +02002514 return 0;
2515}
2516
Takashi Iwaic960a032006-03-23 17:06:28 +01002517static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2518{
2519 unsigned int pincap = snd_hda_param_read(codec, nid,
2520 AC_PAR_PIN_CAP);
2521 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2522 if (pincap & AC_PINCAP_VREF_100)
2523 return AC_PINCTL_VREF_100;
2524 if (pincap & AC_PINCAP_VREF_80)
2525 return AC_PINCTL_VREF_80;
2526 if (pincap & AC_PINCAP_VREF_50)
2527 return AC_PINCTL_VREF_50;
2528 if (pincap & AC_PINCAP_VREF_GRD)
2529 return AC_PINCTL_VREF_GRD;
2530 return 0;
2531}
2532
Matt Porter403d1942005-11-29 15:00:51 +01002533static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2534
2535{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002536 snd_hda_codec_write_cache(codec, nid, 0,
2537 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002538}
2539
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002540#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2541
2542static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2543 struct snd_ctl_elem_value *ucontrol)
2544{
2545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2546 struct sigmatel_spec *spec = codec->spec;
2547
Takashi Iwaid7a89432008-11-12 09:48:04 +01002548 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002549 return 0;
2550}
2551
2552static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2553 struct snd_ctl_elem_value *ucontrol)
2554{
2555 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2556 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002557 int nid = kcontrol->private_value;
2558
2559 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002560
2561 /* check to be sure that the ports are upto date with
2562 * switch changes
2563 */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04002564 codec->patch_ops.unsol_event(codec, (STAC_HP_EVENT | nid) << 26);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002565
2566 return 1;
2567}
2568
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002569#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002570
2571static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2572{
2573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2574 struct sigmatel_spec *spec = codec->spec;
2575 int io_idx = kcontrol-> private_value & 0xff;
2576
2577 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2578 return 0;
2579}
2580
2581static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2582{
2583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2584 struct sigmatel_spec *spec = codec->spec;
2585 hda_nid_t nid = kcontrol->private_value >> 8;
2586 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002587 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002588
2589 spec->io_switch[io_idx] = val;
2590
2591 if (val)
2592 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002593 else {
2594 unsigned int pinctl = AC_PINCTL_IN_EN;
2595 if (io_idx) /* set VREF for mic */
2596 pinctl |= stac92xx_get_vref(codec, nid);
2597 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2598 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002599
2600 /* check the auto-mute again: we need to mute/unmute the speaker
2601 * appropriately according to the pin direction
2602 */
2603 if (spec->hp_detect)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04002604 codec->patch_ops.unsol_event(codec,
2605 (STAC_HP_EVENT | nid) << 26);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002606
Matt Porter403d1942005-11-29 15:00:51 +01002607 return 1;
2608}
2609
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002610#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2611
2612static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2613 struct snd_ctl_elem_value *ucontrol)
2614{
2615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2616 struct sigmatel_spec *spec = codec->spec;
2617
2618 ucontrol->value.integer.value[0] = spec->clfe_swap;
2619 return 0;
2620}
2621
2622static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2623 struct snd_ctl_elem_value *ucontrol)
2624{
2625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2626 struct sigmatel_spec *spec = codec->spec;
2627 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002628 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002629
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002630 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002631 return 0;
2632
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002633 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002634
2635 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2636 spec->clfe_swap ? 0x4 : 0x0);
2637
2638 return 1;
2639}
2640
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002641#define STAC_CODEC_HP_SWITCH(xname) \
2642 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2643 .name = xname, \
2644 .index = 0, \
2645 .info = stac92xx_hp_switch_info, \
2646 .get = stac92xx_hp_switch_get, \
2647 .put = stac92xx_hp_switch_put, \
2648 }
2649
Matt Porter403d1942005-11-29 15:00:51 +01002650#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2651 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2652 .name = xname, \
2653 .index = 0, \
2654 .info = stac92xx_io_switch_info, \
2655 .get = stac92xx_io_switch_get, \
2656 .put = stac92xx_io_switch_put, \
2657 .private_value = xpval, \
2658 }
2659
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002660#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2661 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2662 .name = xname, \
2663 .index = 0, \
2664 .info = stac92xx_clfe_switch_info, \
2665 .get = stac92xx_clfe_switch_get, \
2666 .put = stac92xx_clfe_switch_put, \
2667 .private_value = xpval, \
2668 }
Matt Porter403d1942005-11-29 15:00:51 +01002669
Mattc7d4b2f2005-06-27 14:59:41 +02002670enum {
2671 STAC_CTL_WIDGET_VOL,
2672 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002673 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002674 STAC_CTL_WIDGET_AMP_MUX,
2675 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002676 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002677 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002678 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002679};
2680
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002681static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002682 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2683 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002684 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002685 STAC_AMP_MUX,
2686 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002687 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002688 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002689 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002690};
2691
2692/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002693static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2694 struct snd_kcontrol_new *ktemp,
2695 int idx, const char *name,
2696 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002697{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002698 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002699
Takashi Iwai603c4012008-07-30 15:01:44 +02002700 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2701 knew = snd_array_new(&spec->kctls);
2702 if (!knew)
2703 return -ENOMEM;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002704 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002705 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002706 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002707 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002708 return -ENOMEM;
2709 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002710 return 0;
2711}
2712
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002713static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2714 int type, int idx, const char *name,
2715 unsigned long val)
2716{
2717 return stac92xx_add_control_temp(spec,
2718 &stac92xx_control_templates[type],
2719 idx, name, val);
2720}
2721
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002722
2723/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002724static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2725 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002726{
2727 return stac92xx_add_control_idx(spec, type, 0, name, val);
2728}
2729
Matt Porter403d1942005-11-29 15:00:51 +01002730/* flag inputs as additional dynamic lineouts */
2731static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2732{
2733 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002734 unsigned int wcaps, wtype;
2735 int i, num_dacs = 0;
2736
2737 /* use the wcaps cache to count all DACs available for line-outs */
2738 for (i = 0; i < codec->num_nodes; i++) {
2739 wcaps = codec->wcaps[i];
2740 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002741
Steve Longerbeam7b043892007-05-03 20:50:03 +02002742 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2743 num_dacs++;
2744 }
Matt Porter403d1942005-11-29 15:00:51 +01002745
Steve Longerbeam7b043892007-05-03 20:50:03 +02002746 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2747
Matt Porter403d1942005-11-29 15:00:51 +01002748 switch (cfg->line_outs) {
2749 case 3:
2750 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002751 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002752 cfg->line_out_pins[cfg->line_outs] =
2753 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002754 spec->line_switch = 1;
2755 cfg->line_outs++;
2756 }
2757 break;
2758 case 2:
2759 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002760 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002761 cfg->line_out_pins[cfg->line_outs] =
2762 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002763 spec->line_switch = 1;
2764 cfg->line_outs++;
2765 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002766 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002767 cfg->line_out_pins[cfg->line_outs] =
2768 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002769 spec->mic_switch = 1;
2770 cfg->line_outs++;
2771 }
2772 break;
2773 case 1:
2774 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002775 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002776 cfg->line_out_pins[cfg->line_outs] =
2777 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002778 spec->line_switch = 1;
2779 cfg->line_outs++;
2780 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002781 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002782 cfg->line_out_pins[cfg->line_outs] =
2783 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002784 spec->mic_switch = 1;
2785 cfg->line_outs++;
2786 }
2787 break;
2788 }
2789
2790 return 0;
2791}
2792
Steve Longerbeam7b043892007-05-03 20:50:03 +02002793
2794static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2795{
2796 int i;
2797
2798 for (i = 0; i < spec->multiout.num_dacs; i++) {
2799 if (spec->multiout.dac_nids[i] == nid)
2800 return 1;
2801 }
2802
2803 return 0;
2804}
2805
Matt Porter3cc08dc2006-01-23 15:27:49 +01002806/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002807 * Fill in the dac_nids table from the parsed pin configuration
2808 * This function only works when every pin in line_out_pins[]
2809 * contains atleast one DAC in its connection list. Some 92xx
2810 * codecs are not connected directly to a DAC, such as the 9200
2811 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002812 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002813static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002814 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002815{
2816 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002817 int i, j, conn_len = 0;
2818 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2819 unsigned int wcaps, wtype;
2820
Mattc7d4b2f2005-06-27 14:59:41 +02002821 for (i = 0; i < cfg->line_outs; i++) {
2822 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002823 conn_len = snd_hda_get_connections(codec, nid, conn,
2824 HDA_MAX_CONNECTIONS);
2825 for (j = 0; j < conn_len; j++) {
2826 wcaps = snd_hda_param_read(codec, conn[j],
2827 AC_PAR_AUDIO_WIDGET_CAP);
2828 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002829 if (wtype != AC_WID_AUD_OUT ||
2830 (wcaps & AC_WCAP_DIGITAL))
2831 continue;
2832 /* conn[j] is a DAC routed to this line-out */
2833 if (!is_in_dac_nids(spec, conn[j]))
2834 break;
2835 }
2836
2837 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002838 if (spec->multiout.num_dacs > 0) {
2839 /* we have already working output pins,
2840 * so let's drop the broken ones again
2841 */
2842 cfg->line_outs = spec->multiout.num_dacs;
2843 break;
2844 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002845 /* error out, no available DAC found */
2846 snd_printk(KERN_ERR
2847 "%s: No available DAC for pin 0x%x\n",
2848 __func__, nid);
2849 return -ENODEV;
2850 }
2851
2852 spec->multiout.dac_nids[i] = conn[j];
2853 spec->multiout.num_dacs++;
2854 if (conn_len > 1) {
2855 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002856 snd_hda_codec_write_cache(codec, nid, 0,
2857 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002858
2859 }
Mattc7d4b2f2005-06-27 14:59:41 +02002860 }
2861
Steve Longerbeam7b043892007-05-03 20:50:03 +02002862 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2863 spec->multiout.num_dacs,
2864 spec->multiout.dac_nids[0],
2865 spec->multiout.dac_nids[1],
2866 spec->multiout.dac_nids[2],
2867 spec->multiout.dac_nids[3],
2868 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002869 return 0;
2870}
2871
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002872/* create volume control/switch for the given prefx type */
2873static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2874{
2875 char name[32];
2876 int err;
2877
2878 sprintf(name, "%s Playback Volume", pfx);
2879 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2880 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2881 if (err < 0)
2882 return err;
2883 sprintf(name, "%s Playback Switch", pfx);
2884 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2885 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2886 if (err < 0)
2887 return err;
2888 return 0;
2889}
2890
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002891static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2892{
2893 if (!spec->multiout.hp_nid)
2894 spec->multiout.hp_nid = nid;
2895 else if (spec->multiout.num_dacs > 4) {
2896 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2897 return 1;
2898 } else {
2899 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2900 spec->multiout.num_dacs++;
2901 }
2902 return 0;
2903}
2904
2905static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2906{
2907 if (is_in_dac_nids(spec, nid))
2908 return 1;
2909 if (spec->multiout.hp_nid == nid)
2910 return 1;
2911 return 0;
2912}
2913
Mattc7d4b2f2005-06-27 14:59:41 +02002914/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002915static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002916 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002917{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002918 static const char *chname[4] = {
2919 "Front", "Surround", NULL /*CLFE*/, "Side"
2920 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002921 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002922 int i, err;
2923
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002924 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002925 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002926
2927
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002928 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002929 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002930 continue;
2931
2932 nid = spec->multiout.dac_nids[i];
2933
2934 if (i == 2) {
2935 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002936 err = create_controls(spec, "Center", nid, 1);
2937 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002938 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002939 err = create_controls(spec, "LFE", nid, 2);
2940 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002941 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002942
2943 wid_caps = get_wcaps(codec, nid);
2944
2945 if (wid_caps & AC_WCAP_LR_SWAP) {
2946 err = stac92xx_add_control(spec,
2947 STAC_CTL_WIDGET_CLFE_SWITCH,
2948 "Swap Center/LFE Playback Switch", nid);
2949
2950 if (err < 0)
2951 return err;
2952 }
2953
Mattc7d4b2f2005-06-27 14:59:41 +02002954 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002955 err = create_controls(spec, chname[i], nid, 3);
2956 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002957 return err;
2958 }
2959 }
2960
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002961 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2962 cfg->hp_outs && !spec->multiout.hp_nid)
2963 spec->multiout.hp_nid = nid;
2964
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01002965 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002966 err = stac92xx_add_control(spec,
2967 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002968 "Headphone as Line Out Switch",
2969 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002970 if (err < 0)
2971 return err;
2972 }
2973
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002974 if (spec->line_switch) {
2975 nid = cfg->input_pins[AUTO_PIN_LINE];
2976 pincap = snd_hda_param_read(codec, nid,
2977 AC_PAR_PIN_CAP);
2978 if (pincap & AC_PINCAP_OUT) {
2979 err = stac92xx_add_control(spec,
2980 STAC_CTL_WIDGET_IO_SWITCH,
2981 "Line In as Output Switch", nid << 8);
2982 if (err < 0)
2983 return err;
2984 }
2985 }
Matt Porter403d1942005-11-29 15:00:51 +01002986
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002987 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002988 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002989 unsigned int mic_pin = AUTO_PIN_MIC;
2990again:
2991 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002992 def_conf = snd_hda_codec_read(codec, nid, 0,
2993 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002994 /* some laptops have an internal analog microphone
2995 * which can't be used as a output */
2996 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2997 pincap = snd_hda_param_read(codec, nid,
2998 AC_PAR_PIN_CAP);
2999 if (pincap & AC_PINCAP_OUT) {
3000 err = stac92xx_add_control(spec,
3001 STAC_CTL_WIDGET_IO_SWITCH,
3002 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003003 nid = snd_hda_codec_read(codec, nid, 0,
3004 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
3005 if (!check_in_dac_nids(spec, nid))
3006 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01003007 if (err < 0)
3008 return err;
3009 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003010 } else if (mic_pin == AUTO_PIN_MIC) {
3011 mic_pin = AUTO_PIN_FRONT_MIC;
3012 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003013 }
3014 }
Matt Porter403d1942005-11-29 15:00:51 +01003015
Mattc7d4b2f2005-06-27 14:59:41 +02003016 return 0;
3017}
3018
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003019/* add playback controls for Speaker and HP outputs */
3020static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3021 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003022{
3023 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003024 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003025 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003026
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003027 old_num_dacs = spec->multiout.num_dacs;
3028 for (i = 0; i < cfg->hp_outs; i++) {
3029 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3030 if (wid_caps & AC_WCAP_UNSOL_CAP)
3031 spec->hp_detect = 1;
3032 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
3033 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
3034 if (check_in_dac_nids(spec, nid))
3035 nid = 0;
3036 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02003037 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003038 add_spec_dacs(spec, nid);
3039 }
3040 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02003041 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003042 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
3043 if (check_in_dac_nids(spec, nid))
3044 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003045 if (! nid)
3046 continue;
3047 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02003048 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02003049 for (i = 0; i < cfg->line_outs; i++) {
3050 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
3051 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
3052 if (check_in_dac_nids(spec, nid))
3053 nid = 0;
3054 if (! nid)
3055 continue;
3056 add_spec_dacs(spec, nid);
3057 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003058 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
3059 static const char *pfxs[] = {
3060 "Speaker", "External Speaker", "Speaker2",
3061 };
3062 err = create_controls(spec, pfxs[i - old_num_dacs],
3063 spec->multiout.dac_nids[i], 3);
3064 if (err < 0)
3065 return err;
3066 }
3067 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01003068 err = create_controls(spec, "Headphone",
3069 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003070 if (err < 0)
3071 return err;
3072 }
Mattc7d4b2f2005-06-27 14:59:41 +02003073
3074 return 0;
3075}
3076
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003077/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003078static const char *stac92xx_mono_labels[4] = {
3079 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003080};
3081
3082/* create mono mux for mono out on capable codecs */
3083static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3084{
3085 struct sigmatel_spec *spec = codec->spec;
3086 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3087 int i, num_cons;
3088 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3089
3090 num_cons = snd_hda_get_connections(codec,
3091 spec->mono_nid,
3092 con_lst,
3093 HDA_MAX_NUM_INPUTS);
3094 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3095 return -EINVAL;
3096
3097 for (i = 0; i < num_cons; i++) {
3098 mono_mux->items[mono_mux->num_items].label =
3099 stac92xx_mono_labels[i];
3100 mono_mux->items[mono_mux->num_items].index = i;
3101 mono_mux->num_items++;
3102 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003103
3104 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3105 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003106}
3107
Matthew Ranostay89385032008-09-11 09:49:39 -04003108/* labels for amp mux outputs */
3109static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003110 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003111};
3112
3113/* create amp out controls mux on capable codecs */
3114static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3115{
3116 struct sigmatel_spec *spec = codec->spec;
3117 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3118 int i, err;
3119
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003120 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003121 amp_mux->items[amp_mux->num_items].label =
3122 stac92xx_amp_labels[i];
3123 amp_mux->items[amp_mux->num_items].index = i;
3124 amp_mux->num_items++;
3125 }
3126
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003127 if (spec->num_amps > 1) {
3128 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3129 "Amp Selector Capture Switch", 0);
3130 if (err < 0)
3131 return err;
3132 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003133 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3134 "Amp Capture Volume",
3135 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3136}
3137
3138
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003139/* create PC beep volume controls */
3140static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3141 hda_nid_t nid)
3142{
3143 struct sigmatel_spec *spec = codec->spec;
3144 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3145 int err;
3146
3147 /* check for mute support for the the amp */
3148 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3149 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3150 "PC Beep Playback Switch",
3151 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3152 if (err < 0)
3153 return err;
3154 }
3155
3156 /* check to see if there is volume support for the amp */
3157 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3158 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3159 "PC Beep Playback Volume",
3160 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3161 if (err < 0)
3162 return err;
3163 }
3164 return 0;
3165}
3166
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003167#ifdef CONFIG_SND_HDA_INPUT_BEEP
3168#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3169
3170static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3171 struct snd_ctl_elem_value *ucontrol)
3172{
3173 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3174 ucontrol->value.integer.value[0] = codec->beep->enabled;
3175 return 0;
3176}
3177
3178static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3179 struct snd_ctl_elem_value *ucontrol)
3180{
3181 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3182 int enabled = !!ucontrol->value.integer.value[0];
3183 if (codec->beep->enabled != enabled) {
3184 codec->beep->enabled = enabled;
3185 return 1;
3186 }
3187 return 0;
3188}
3189
3190static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3192 .info = stac92xx_dig_beep_switch_info,
3193 .get = stac92xx_dig_beep_switch_get,
3194 .put = stac92xx_dig_beep_switch_put,
3195};
3196
3197static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3198{
3199 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3200 0, "PC Beep Playback Switch", 0);
3201}
3202#endif
3203
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003204static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3205{
3206 struct sigmatel_spec *spec = codec->spec;
3207 int wcaps, nid, i, err = 0;
3208
3209 for (i = 0; i < spec->num_muxes; i++) {
3210 nid = spec->mux_nids[i];
3211 wcaps = get_wcaps(codec, nid);
3212
3213 if (wcaps & AC_WCAP_OUT_AMP) {
3214 err = stac92xx_add_control_idx(spec,
3215 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3216 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3217 if (err < 0)
3218 return err;
3219 }
3220 }
3221 return 0;
3222};
3223
Matthew Ranostayd9737752008-09-07 12:03:41 +02003224static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003225 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003226};
3227
3228static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3229{
3230 struct sigmatel_spec *spec = codec->spec;
3231 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003232 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003233 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003234 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003235
3236 num_cons = snd_hda_get_connections(codec,
3237 spec->smux_nids[0],
3238 con_lst,
3239 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003240 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003241 return -EINVAL;
3242
Matthew Ranostay65973632008-09-16 10:39:37 -04003243 if (!labels)
3244 labels = stac92xx_spdif_labels;
3245
Matthew Ranostayd9737752008-09-07 12:03:41 +02003246 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003247 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003248 spdif_mux->items[spdif_mux->num_items].index = i;
3249 spdif_mux->num_items++;
3250 }
3251
3252 return 0;
3253}
3254
Matt Porter8b657272006-10-26 17:12:59 +02003255/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003256static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003257 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3258 "Digital Mic 3", "Digital Mic 4"
3259};
3260
3261/* create playback/capture controls for input pins on dmic capable codecs */
3262static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3263 const struct auto_pin_cfg *cfg)
3264{
3265 struct sigmatel_spec *spec = codec->spec;
3266 struct hda_input_mux *dimux = &spec->private_dimux;
3267 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003268 int err, i, j;
3269 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003270
3271 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3272 dimux->items[dimux->num_items].index = 0;
3273 dimux->num_items++;
3274
3275 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003276 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003277 int index;
3278 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003279 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003280 unsigned int def_conf;
3281
3282 def_conf = snd_hda_codec_read(codec,
3283 spec->dmic_nids[i],
3284 0,
3285 AC_VERB_GET_CONFIG_DEFAULT,
3286 0);
3287 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3288 continue;
3289
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003290 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003291 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003292 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003293 con_lst,
3294 HDA_MAX_NUM_INPUTS);
3295 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003296 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003297 index = j;
3298 goto found;
3299 }
3300 continue;
3301found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003302 wcaps = get_wcaps(codec, nid) &
3303 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003304
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003305 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003306 sprintf(name, "%s Capture Volume",
3307 stac92xx_dmic_labels[dimux->num_items]);
3308
3309 err = stac92xx_add_control(spec,
3310 STAC_CTL_WIDGET_VOL,
3311 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003312 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3313 (wcaps & AC_WCAP_OUT_AMP) ?
3314 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003315 if (err < 0)
3316 return err;
3317 }
3318
Matt Porter8b657272006-10-26 17:12:59 +02003319 dimux->items[dimux->num_items].label =
3320 stac92xx_dmic_labels[dimux->num_items];
3321 dimux->items[dimux->num_items].index = index;
3322 dimux->num_items++;
3323 }
3324
3325 return 0;
3326}
3327
Mattc7d4b2f2005-06-27 14:59:41 +02003328/* create playback/capture controls for input pins */
3329static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3330{
3331 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003332 struct hda_input_mux *imux = &spec->private_imux;
3333 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3334 int i, j, k;
3335
3336 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003337 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003338
Takashi Iwai314634b2006-09-21 11:56:18 +02003339 if (!cfg->input_pins[i])
3340 continue;
3341 index = -1;
3342 for (j = 0; j < spec->num_muxes; j++) {
3343 int num_cons;
3344 num_cons = snd_hda_get_connections(codec,
3345 spec->mux_nids[j],
3346 con_lst,
3347 HDA_MAX_NUM_INPUTS);
3348 for (k = 0; k < num_cons; k++)
3349 if (con_lst[k] == cfg->input_pins[i]) {
3350 index = k;
3351 goto found;
3352 }
Mattc7d4b2f2005-06-27 14:59:41 +02003353 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003354 continue;
3355 found:
3356 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3357 imux->items[imux->num_items].index = index;
3358 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003359 }
3360
Steve Longerbeam7b043892007-05-03 20:50:03 +02003361 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003362 /*
3363 * Set the current input for the muxes.
3364 * The STAC9221 has two input muxes with identical source
3365 * NID lists. Hopefully this won't get confused.
3366 */
3367 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003368 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3369 AC_VERB_SET_CONNECT_SEL,
3370 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003371 }
3372 }
3373
Mattc7d4b2f2005-06-27 14:59:41 +02003374 return 0;
3375}
3376
Mattc7d4b2f2005-06-27 14:59:41 +02003377static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3378{
3379 struct sigmatel_spec *spec = codec->spec;
3380 int i;
3381
3382 for (i = 0; i < spec->autocfg.line_outs; i++) {
3383 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3384 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3385 }
3386}
3387
3388static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3389{
3390 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003391 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003392
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003393 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3394 hda_nid_t pin;
3395 pin = spec->autocfg.hp_pins[i];
3396 if (pin) /* connect to front */
3397 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3398 }
3399 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3400 hda_nid_t pin;
3401 pin = spec->autocfg.speaker_pins[i];
3402 if (pin) /* connect to front */
3403 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3404 }
Mattc7d4b2f2005-06-27 14:59:41 +02003405}
3406
Matt Porter3cc08dc2006-01-23 15:27:49 +01003407static 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 +02003408{
3409 struct sigmatel_spec *spec = codec->spec;
3410 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003411 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003412
Matt Porter8b657272006-10-26 17:12:59 +02003413 if ((err = snd_hda_parse_pin_def_config(codec,
3414 &spec->autocfg,
3415 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003416 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003417 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003418 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003419
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003420 /* If we have no real line-out pin and multiple hp-outs, HPs should
3421 * be set up as multi-channel outputs.
3422 */
3423 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3424 spec->autocfg.hp_outs > 1) {
3425 /* Copy hp_outs to line_outs, backup line_outs in
3426 * speaker_outs so that the following routines can handle
3427 * HP pins as primary outputs.
3428 */
3429 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3430 sizeof(spec->autocfg.line_out_pins));
3431 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3432 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3433 sizeof(spec->autocfg.hp_pins));
3434 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3435 hp_speaker_swap = 1;
3436 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003437 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003438 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3439 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003440 u32 caps = query_amp_caps(codec,
3441 spec->autocfg.mono_out_pin, dir);
3442 hda_nid_t conn_list[1];
3443
3444 /* get the mixer node and then the mono mux if it exists */
3445 if (snd_hda_get_connections(codec,
3446 spec->autocfg.mono_out_pin, conn_list, 1) &&
3447 snd_hda_get_connections(codec, conn_list[0],
3448 conn_list, 1)) {
3449
3450 int wcaps = get_wcaps(codec, conn_list[0]);
3451 int wid_type = (wcaps & AC_WCAP_TYPE)
3452 >> AC_WCAP_TYPE_SHIFT;
3453 /* LR swap check, some stac925x have a mux that
3454 * changes the DACs output path instead of the
3455 * mono-mux path.
3456 */
3457 if (wid_type == AC_WID_AUD_SEL &&
3458 !(wcaps & AC_WCAP_LR_SWAP))
3459 spec->mono_nid = conn_list[0];
3460 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003461 if (dir) {
3462 hda_nid_t nid = spec->autocfg.mono_out_pin;
3463
3464 /* most mono outs have a least a mute/unmute switch */
3465 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3466 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3467 "Mono Playback Switch",
3468 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003469 if (err < 0)
3470 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003471 /* check for volume support for the amp */
3472 if ((caps & AC_AMPCAP_NUM_STEPS)
3473 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3474 err = stac92xx_add_control(spec,
3475 STAC_CTL_WIDGET_VOL,
3476 "Mono Playback Volume",
3477 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3478 if (err < 0)
3479 return err;
3480 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003481 }
3482
3483 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3484 AC_PINCTL_OUT_EN);
3485 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003486
Matt Porter403d1942005-11-29 15:00:51 +01003487 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3488 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003489 if (spec->multiout.num_dacs == 0)
3490 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3491 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003492
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003493 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3494
3495 if (err < 0)
3496 return err;
3497
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003498 /* setup analog beep controls */
3499 if (spec->anabeep_nid > 0) {
3500 err = stac92xx_auto_create_beep_ctls(codec,
3501 spec->anabeep_nid);
3502 if (err < 0)
3503 return err;
3504 }
3505
3506 /* setup digital beep controls and input device */
3507#ifdef CONFIG_SND_HDA_INPUT_BEEP
3508 if (spec->digbeep_nid > 0) {
3509 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003510 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003511
3512 err = stac92xx_auto_create_beep_ctls(codec, nid);
3513 if (err < 0)
3514 return err;
3515 err = snd_hda_attach_beep_device(codec, nid);
3516 if (err < 0)
3517 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003518 /* if no beep switch is available, make its own one */
3519 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3520 if (codec->beep &&
3521 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3522 err = stac92xx_beep_switch_ctl(codec);
3523 if (err < 0)
3524 return err;
3525 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003526 }
3527#endif
3528
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003529 if (hp_speaker_swap == 1) {
3530 /* Restore the hp_outs and line_outs */
3531 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3532 sizeof(spec->autocfg.line_out_pins));
3533 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3534 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3535 sizeof(spec->autocfg.speaker_pins));
3536 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3537 memset(spec->autocfg.speaker_pins, 0,
3538 sizeof(spec->autocfg.speaker_pins));
3539 spec->autocfg.speaker_outs = 0;
3540 }
3541
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003542 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3543
3544 if (err < 0)
3545 return err;
3546
3547 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3548
3549 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003550 return err;
3551
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003552 if (spec->mono_nid > 0) {
3553 err = stac92xx_auto_create_mono_output_ctls(codec);
3554 if (err < 0)
3555 return err;
3556 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003557 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003558 err = stac92xx_auto_create_amp_output_ctls(codec);
3559 if (err < 0)
3560 return err;
3561 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003562 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003563 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3564 &spec->autocfg)) < 0)
3565 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003566 if (spec->num_muxes > 0) {
3567 err = stac92xx_auto_create_mux_input_ctls(codec);
3568 if (err < 0)
3569 return err;
3570 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003571 if (spec->num_smuxes > 0) {
3572 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3573 if (err < 0)
3574 return err;
3575 }
Matt Porter8b657272006-10-26 17:12:59 +02003576
Mattc7d4b2f2005-06-27 14:59:41 +02003577 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003578 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003579 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003580
Takashi Iwai82bc9552006-03-21 11:24:42 +01003581 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003582 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003583 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003584 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003585
Takashi Iwai603c4012008-07-30 15:01:44 +02003586 if (spec->kctls.list)
3587 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003588
3589 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003590 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003591 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003592 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003593 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003594 return 1;
3595}
3596
Takashi Iwai82bc9552006-03-21 11:24:42 +01003597/* add playback controls for HP output */
3598static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3599 struct auto_pin_cfg *cfg)
3600{
3601 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003602 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003603 unsigned int wid_caps;
3604
3605 if (! pin)
3606 return 0;
3607
3608 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003609 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003610 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003611
3612 return 0;
3613}
3614
Richard Fish160ea0d2006-09-06 13:58:25 +02003615/* add playback controls for LFE output */
3616static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3617 struct auto_pin_cfg *cfg)
3618{
3619 struct sigmatel_spec *spec = codec->spec;
3620 int err;
3621 hda_nid_t lfe_pin = 0x0;
3622 int i;
3623
3624 /*
3625 * search speaker outs and line outs for a mono speaker pin
3626 * with an amp. If one is found, add LFE controls
3627 * for it.
3628 */
3629 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3630 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003631 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003632 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3633 if (wcaps == AC_WCAP_OUT_AMP)
3634 /* found a mono speaker with an amp, must be lfe */
3635 lfe_pin = pin;
3636 }
3637
3638 /* if speaker_outs is 0, then speakers may be in line_outs */
3639 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3640 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3641 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003642 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003643 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003644 AC_VERB_GET_CONFIG_DEFAULT,
3645 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003646 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003647 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003648 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3649 if (wcaps == AC_WCAP_OUT_AMP)
3650 /* found a mono speaker with an amp,
3651 must be lfe */
3652 lfe_pin = pin;
3653 }
3654 }
3655 }
3656
3657 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003658 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003659 if (err < 0)
3660 return err;
3661 }
3662
3663 return 0;
3664}
3665
Mattc7d4b2f2005-06-27 14:59:41 +02003666static int stac9200_parse_auto_config(struct hda_codec *codec)
3667{
3668 struct sigmatel_spec *spec = codec->spec;
3669 int err;
3670
Kailang Yangdf694da2005-12-05 19:42:22 +01003671 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003672 return err;
3673
3674 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3675 return err;
3676
Takashi Iwai82bc9552006-03-21 11:24:42 +01003677 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3678 return err;
3679
Richard Fish160ea0d2006-09-06 13:58:25 +02003680 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3681 return err;
3682
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003683 if (spec->num_muxes > 0) {
3684 err = stac92xx_auto_create_mux_input_ctls(codec);
3685 if (err < 0)
3686 return err;
3687 }
3688
Takashi Iwai82bc9552006-03-21 11:24:42 +01003689 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003690 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003691 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003692 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003693
Takashi Iwai603c4012008-07-30 15:01:44 +02003694 if (spec->kctls.list)
3695 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003696
3697 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003698 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003699
3700 return 1;
3701}
3702
Sam Revitch62fe78e2006-05-10 15:09:17 +02003703/*
3704 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3705 * funky external mute control using GPIO pins.
3706 */
3707
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003708static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003709 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003710{
3711 unsigned int gpiostate, gpiomask, gpiodir;
3712
3713 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3714 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003715 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003716
3717 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3718 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003719 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003720
3721 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3722 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003723 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003724
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003725 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003726 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3727
3728 snd_hda_codec_write(codec, codec->afg, 0,
3729 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003730 snd_hda_codec_read(codec, codec->afg, 0,
3731 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003732
3733 msleep(1);
3734
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003735 snd_hda_codec_read(codec, codec->afg, 0,
3736 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003737}
3738
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003739static int stac92xx_add_jack(struct hda_codec *codec,
3740 hda_nid_t nid, int type)
3741{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003742#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003743 struct sigmatel_spec *spec = codec->spec;
3744 struct sigmatel_jack *jack;
3745 int def_conf = snd_hda_codec_read(codec, nid,
3746 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3747 int connectivity = get_defcfg_connect(def_conf);
3748 char name[32];
3749
3750 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3751 return 0;
3752
3753 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3754 jack = snd_array_new(&spec->jacks);
3755 if (!jack)
3756 return -ENOMEM;
3757 jack->nid = nid;
3758 jack->type = type;
3759
3760 sprintf(name, "%s at %s %s Jack",
3761 snd_hda_get_jack_type(def_conf),
3762 snd_hda_get_jack_connectivity(def_conf),
3763 snd_hda_get_jack_location(def_conf));
3764
3765 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003766#else
3767 return 0;
3768#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003769}
3770
3771static int stac92xx_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3772 int data)
3773{
3774 struct sigmatel_event *event;
3775
3776 snd_array_init(&spec->events, sizeof(*event), 32);
3777 event = snd_array_new(&spec->events);
3778 if (!event)
3779 return -ENOMEM;
3780 event->nid = nid;
3781 event->data = data;
3782
3783 return 0;
3784}
3785
3786static int stac92xx_event_data(struct hda_codec *codec, hda_nid_t nid)
3787{
3788 struct sigmatel_spec *spec = codec->spec;
3789 struct sigmatel_event *events = spec->events.list;
3790 if (events) {
3791 int i;
3792 for (i = 0; i < spec->events.used; i++)
3793 if (events[i].nid == nid)
3794 return events[i].data;
3795 }
3796 return 0;
3797}
3798
Takashi Iwai314634b2006-09-21 11:56:18 +02003799static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3800 unsigned int event)
3801{
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003802 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003803 snd_hda_codec_write_cache(codec, nid, 0,
3804 AC_VERB_SET_UNSOLICITED_ENABLE,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003805 (AC_USRSP_EN | event | nid));
3806 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003807}
3808
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003809static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3810{
3811 int i;
3812 for (i = 0; i < cfg->hp_outs; i++)
3813 if (cfg->hp_pins[i] == nid)
3814 return 1; /* nid is a HP-Out */
3815
3816 return 0; /* nid is not a HP-Out */
3817};
3818
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003819static void stac92xx_power_down(struct hda_codec *codec)
3820{
3821 struct sigmatel_spec *spec = codec->spec;
3822
3823 /* power down inactive DACs */
3824 hda_nid_t *dac;
3825 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003826 if (!is_in_dac_nids(spec, *dac) &&
3827 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003828 snd_hda_codec_write_cache(codec, *dac, 0,
3829 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3830}
3831
Mattc7d4b2f2005-06-27 14:59:41 +02003832static int stac92xx_init(struct hda_codec *codec)
3833{
3834 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003835 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003836 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003837
Mattc7d4b2f2005-06-27 14:59:41 +02003838 snd_hda_sequence_write(codec, spec->init);
3839
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003840 /* power down adcs initially */
3841 if (spec->powerdown_adcs)
3842 for (i = 0; i < spec->num_adcs; i++)
3843 snd_hda_codec_write_cache(codec,
3844 spec->adc_nids[i], 0,
3845 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003846 /* set up pins */
3847 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003848 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003849 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003850 hda_nid_t nid = cfg->hp_pins[i];
3851 enable_pin_detect(codec, nid, STAC_HP_EVENT | nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003852 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003853 /* force to enable the first line-out; the others are set up
3854 * in unsol_event
3855 */
3856 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003857 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003858 /* fake event to set up pins */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003859 codec->patch_ops.unsol_event(codec,
3860 (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003861 } else {
3862 stac92xx_auto_init_multi_out(codec);
3863 stac92xx_auto_init_hp_out(codec);
3864 }
3865 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003866 hda_nid_t nid = cfg->input_pins[i];
3867 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003868 unsigned int pinctl;
3869 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3870 /* for mic pins, force to initialize */
3871 pinctl = stac92xx_get_vref(codec, nid);
3872 } else {
3873 pinctl = snd_hda_codec_read(codec, nid, 0,
3874 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3875 /* if PINCTL already set then skip */
3876 if (pinctl & AC_PINCTL_IN_EN)
3877 continue;
3878 }
3879 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003880 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003881 enable_pin_detect(codec, nid, STAC_INSERT_EVENT | nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003882 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003883 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003884 for (i = 0; i < spec->num_dmics; i++)
3885 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3886 AC_PINCTL_IN_EN);
3887 for (i = 0; i < spec->num_pwrs; i++) {
3888 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3889 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3890 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3891 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003892 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3893 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003894 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003895 /* outputs are only ports capable of power management
3896 * any attempts on powering down a input port cause the
3897 * referenced VREF to act quirky.
3898 */
3899 if (pinctl & AC_PINCTL_IN_EN)
3900 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003901 /* skip any ports that don't have jacks since presence
3902 * detection is useless */
3903 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003904 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003905 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3906 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3907 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003908 if (spec->dac_list)
3909 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003910 if (cfg->dig_out_pin)
3911 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3912 AC_PINCTL_OUT_EN);
3913 if (cfg->dig_in_pin)
3914 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3915 AC_PINCTL_IN_EN);
3916
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003917 stac_gpio_set(codec, spec->gpio_mask,
3918 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003919
Mattc7d4b2f2005-06-27 14:59:41 +02003920 return 0;
3921}
3922
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003923static void stac92xx_free_jacks(struct hda_codec *codec)
3924{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003925#ifdef CONFIG_SND_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01003926 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003927 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01003928 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003929 struct sigmatel_jack *jacks = spec->jacks.list;
3930 int i;
3931 for (i = 0; i < spec->jacks.used; i++)
3932 snd_device_free(codec->bus->card, &jacks[i].jack);
3933 }
3934 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003935#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003936}
3937
Takashi Iwai603c4012008-07-30 15:01:44 +02003938static void stac92xx_free_kctls(struct hda_codec *codec)
3939{
3940 struct sigmatel_spec *spec = codec->spec;
3941
3942 if (spec->kctls.list) {
3943 struct snd_kcontrol_new *kctl = spec->kctls.list;
3944 int i;
3945 for (i = 0; i < spec->kctls.used; i++)
3946 kfree(kctl[i].name);
3947 }
3948 snd_array_free(&spec->kctls);
3949}
3950
Matt2f2f4252005-04-13 14:45:30 +02003951static void stac92xx_free(struct hda_codec *codec)
3952{
Mattc7d4b2f2005-06-27 14:59:41 +02003953 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003954
3955 if (! spec)
3956 return;
3957
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01003958 kfree(spec->pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003959 stac92xx_free_jacks(codec);
3960 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02003961
Mattc7d4b2f2005-06-27 14:59:41 +02003962 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003963 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003964}
3965
Matt4e550962005-07-04 17:51:39 +02003966static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3967 unsigned int flag)
3968{
3969 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3970 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003971
Takashi Iwaif9acba42007-05-29 18:01:06 +02003972 if (pin_ctl & AC_PINCTL_IN_EN) {
3973 /*
3974 * we need to check the current set-up direction of
3975 * shared input pins since they can be switched via
3976 * "xxx as Output" mixer switch
3977 */
3978 struct sigmatel_spec *spec = codec->spec;
3979 struct auto_pin_cfg *cfg = &spec->autocfg;
3980 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3981 spec->line_switch) ||
3982 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3983 spec->mic_switch))
3984 return;
3985 }
3986
Steve Longerbeam7b043892007-05-03 20:50:03 +02003987 /* if setting pin direction bits, clear the current
3988 direction bits first */
3989 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3990 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3991
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003992 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003993 AC_VERB_SET_PIN_WIDGET_CONTROL,
3994 pin_ctl | flag);
3995}
3996
3997static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3998 unsigned int flag)
3999{
4000 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4001 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004002 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02004003 AC_VERB_SET_PIN_WIDGET_CONTROL,
4004 pin_ctl & ~flag);
4005}
4006
Jiang Zhe40c1d302007-11-12 13:05:16 +01004007static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004008{
4009 if (!nid)
4010 return 0;
4011 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01004012 & (1 << 31)) {
4013 unsigned int pinctl;
4014 pinctl = snd_hda_codec_read(codec, nid, 0,
4015 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4016 if (pinctl & AC_PINCTL_IN_EN)
4017 return 0; /* mic- or line-input */
4018 else
4019 return 1; /* HP-output */
4020 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004021 return 0;
4022}
4023
Takashi Iwaid7a89432008-11-12 09:48:04 +01004024/* return non-zero if the hp-pin of the given array index isn't
4025 * a jack-detection target
4026 */
4027static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4028{
4029 struct auto_pin_cfg *cfg = &spec->autocfg;
4030
4031 /* ignore sensing of shared line and mic jacks */
4032 if (spec->line_switch &&
4033 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
4034 return 1;
4035 if (spec->mic_switch &&
4036 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
4037 return 1;
4038 /* ignore if the pin is set as line-out */
4039 if (cfg->hp_pins[i] == spec->hp_switch)
4040 return 1;
4041 return 0;
4042}
4043
Takashi Iwai314634b2006-09-21 11:56:18 +02004044static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02004045{
4046 struct sigmatel_spec *spec = codec->spec;
4047 struct auto_pin_cfg *cfg = &spec->autocfg;
4048 int i, presence;
4049
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004050 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004051 if (spec->gpio_mute)
4052 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4053 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4054
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004055 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004056 if (presence)
4057 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004058 if (no_hp_sensing(spec, i))
4059 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004060 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004061 }
Matt4e550962005-07-04 17:51:39 +02004062
4063 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004064 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004065 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004066 stac92xx_reset_pinctl(codec, spec->hp_switch,
4067 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004068 for (i = 0; i < cfg->line_outs; i++)
4069 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4070 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004071 for (i = 0; i < cfg->speaker_outs; i++)
4072 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4073 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004074 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004075 stac_gpio_set(codec, spec->gpio_mask,
4076 spec->gpio_dir, spec->gpio_data &
4077 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004078 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004079 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004080 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004081 stac92xx_set_pinctl(codec, spec->hp_switch,
4082 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004083 for (i = 0; i < cfg->line_outs; i++)
4084 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4085 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004086 for (i = 0; i < cfg->speaker_outs; i++)
4087 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4088 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004089 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004090 stac_gpio_set(codec, spec->gpio_mask,
4091 spec->gpio_dir, spec->gpio_data |
4092 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004093 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004094 /* toggle hp outs */
4095 for (i = 0; i < cfg->hp_outs; i++) {
4096 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4097 if (no_hp_sensing(spec, i))
4098 continue;
4099 if (presence)
4100 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4101 else
4102 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4103 }
Matt4e550962005-07-04 17:51:39 +02004104}
4105
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004106static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
4107{
4108 struct sigmatel_spec *spec = codec->spec;
4109 hda_nid_t nid = spec->pwr_nids[idx];
4110 int presence, val;
4111 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
4112 & 0x000000ff;
4113 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004114
4115 /* several codecs have two power down bits */
4116 if (spec->pwr_mapping)
4117 idx = spec->pwr_mapping[idx];
4118 else
4119 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004120
4121 if (presence)
4122 val &= ~idx;
4123 else
4124 val |= idx;
4125
4126 /* power down unused output ports */
4127 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004128}
4129
4130static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4131{
4132 struct sigmatel_spec *spec = codec->spec;
4133 struct sigmatel_jack *jacks = spec->jacks.list;
4134
4135 if (jacks) {
4136 int i;
4137 for (i = 0; i < spec->jacks.used; i++) {
4138 if (jacks->nid == nid) {
4139 unsigned int pin_ctl =
4140 snd_hda_codec_read(codec, nid,
4141 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4142 0x00);
4143 int type = jacks->type;
4144 if (type == (SND_JACK_LINEOUT
4145 | SND_JACK_HEADPHONE))
4146 type = (pin_ctl & AC_PINCTL_HP_EN)
4147 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4148 snd_jack_report(jacks->jack,
4149 get_hp_pin_presence(codec, nid)
4150 ? type : 0);
4151 }
4152 jacks++;
4153 }
4154 }
4155}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004156
Takashi Iwai314634b2006-09-21 11:56:18 +02004157static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4158{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004159 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004160 int event = (res >> 26) & 0x70;
4161 int nid = res >> 26 & 0x0f;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004162
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004163 switch (event) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004164 case STAC_HP_EVENT:
4165 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004166 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004167 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004168 case STAC_PWR_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004169 if (nid) {
4170 if (spec->num_pwrs > 0)
4171 stac92xx_pin_sense(codec, nid);
4172 stac92xx_report_jack(codec, nid);
4173 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004174 break;
4175 case STAC_VREF_EVENT: {
4176 int data = snd_hda_codec_read(codec, codec->afg, 0,
4177 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004178 int idx = stac92xx_event_data(codec, nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004179 /* toggle VREF state based on GPIOx status */
4180 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4181 !!(data & (1 << idx)));
4182 break;
4183 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004184 }
4185}
4186
Takashi Iwaicb53c622007-08-10 17:21:45 +02004187#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004188static int stac92xx_resume(struct hda_codec *codec)
4189{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004190 struct sigmatel_spec *spec = codec->spec;
4191
Richard Fish11b44bb2006-08-23 18:31:34 +02004192 stac92xx_set_config_regs(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004193 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004194 snd_hda_codec_resume_amp(codec);
4195 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004196 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004197 if (spec->hp_detect)
Takashi Iwai2c885872008-11-18 09:36:55 +01004198 codec->patch_ops.unsol_event(codec,
4199 (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
Mattff6fdc32005-06-27 15:06:52 +02004200 return 0;
4201}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004202
4203static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4204{
4205 struct sigmatel_spec *spec = codec->spec;
4206 if (spec->eapd_mask)
4207 stac_gpio_set(codec, spec->gpio_mask,
4208 spec->gpio_dir, spec->gpio_data &
4209 ~spec->eapd_mask);
4210 return 0;
4211}
Mattff6fdc32005-06-27 15:06:52 +02004212#endif
4213
Matt2f2f4252005-04-13 14:45:30 +02004214static struct hda_codec_ops stac92xx_patch_ops = {
4215 .build_controls = stac92xx_build_controls,
4216 .build_pcms = stac92xx_build_pcms,
4217 .init = stac92xx_init,
4218 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004219 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004220#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004221 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004222 .resume = stac92xx_resume,
4223#endif
Matt2f2f4252005-04-13 14:45:30 +02004224};
4225
4226static int patch_stac9200(struct hda_codec *codec)
4227{
4228 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004229 int err;
Matt2f2f4252005-04-13 14:45:30 +02004230
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004231 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004232 if (spec == NULL)
4233 return -ENOMEM;
4234
4235 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004236 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004237 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004238 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4239 stac9200_models,
4240 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004241 if (spec->board_config < 0) {
4242 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4243 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004244 } else
4245 err = stac_save_pin_cfgs(codec,
4246 stac9200_brd_tbl[spec->board_config]);
4247 if (err < 0) {
4248 stac92xx_free(codec);
4249 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004250 }
Matt2f2f4252005-04-13 14:45:30 +02004251
4252 spec->multiout.max_channels = 2;
4253 spec->multiout.num_dacs = 1;
4254 spec->multiout.dac_nids = stac9200_dac_nids;
4255 spec->adc_nids = stac9200_adc_nids;
4256 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004257 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004258 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004259 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004260 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004261
Tobin Davisbf277782008-02-03 20:31:47 +01004262 if (spec->board_config == STAC_9200_GATEWAY ||
4263 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004264 spec->init = stac9200_eapd_init;
4265 else
4266 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004267 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004268
Takashi Iwai117f2572008-03-18 09:53:23 +01004269 if (spec->board_config == STAC_9200_PANASONIC) {
4270 spec->gpio_mask = spec->gpio_dir = 0x09;
4271 spec->gpio_data = 0x00;
4272 }
4273
Mattc7d4b2f2005-06-27 14:59:41 +02004274 err = stac9200_parse_auto_config(codec);
4275 if (err < 0) {
4276 stac92xx_free(codec);
4277 return err;
4278 }
Matt2f2f4252005-04-13 14:45:30 +02004279
4280 codec->patch_ops = stac92xx_patch_ops;
4281
4282 return 0;
4283}
4284
Tobin Davis8e21c342007-01-08 11:04:17 +01004285static int patch_stac925x(struct hda_codec *codec)
4286{
4287 struct sigmatel_spec *spec;
4288 int err;
4289
4290 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4291 if (spec == NULL)
4292 return -ENOMEM;
4293
4294 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004295 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004296 spec->pin_nids = stac925x_pin_nids;
4297 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4298 stac925x_models,
4299 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004300 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004301 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004302 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4303 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004304 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004305 } else
4306 err = stac_save_pin_cfgs(codec,
4307 stac925x_brd_tbl[spec->board_config]);
4308 if (err < 0) {
4309 stac92xx_free(codec);
4310 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01004311 }
4312
4313 spec->multiout.max_channels = 2;
4314 spec->multiout.num_dacs = 1;
4315 spec->multiout.dac_nids = stac925x_dac_nids;
4316 spec->adc_nids = stac925x_adc_nids;
4317 spec->mux_nids = stac925x_mux_nids;
4318 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004319 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004320 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004321 switch (codec->vendor_id) {
4322 case 0x83847632: /* STAC9202 */
4323 case 0x83847633: /* STAC9202D */
4324 case 0x83847636: /* STAC9251 */
4325 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004326 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004327 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004328 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4329 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004330 break;
4331 default:
4332 spec->num_dmics = 0;
4333 break;
4334 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004335
4336 spec->init = stac925x_core_init;
4337 spec->mixer = stac925x_mixer;
4338
4339 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004340 if (!err) {
4341 if (spec->board_config < 0) {
4342 printk(KERN_WARNING "hda_codec: No auto-config is "
4343 "available, default to model=ref\n");
4344 spec->board_config = STAC_925x_REF;
4345 goto again;
4346 }
4347 err = -EINVAL;
4348 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004349 if (err < 0) {
4350 stac92xx_free(codec);
4351 return err;
4352 }
4353
4354 codec->patch_ops = stac92xx_patch_ops;
4355
4356 return 0;
4357}
4358
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004359static struct hda_input_mux stac92hd73xx_dmux = {
4360 .num_items = 4,
4361 .items = {
4362 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004363 { "Digital Mic 1", 0x09 },
4364 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004365 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004366 }
4367};
4368
4369static int patch_stac92hd73xx(struct hda_codec *codec)
4370{
4371 struct sigmatel_spec *spec;
4372 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4373 int err = 0;
4374
4375 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4376 if (spec == NULL)
4377 return -ENOMEM;
4378
4379 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004380 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004381 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4382 spec->pin_nids = stac92hd73xx_pin_nids;
4383 spec->board_config = snd_hda_check_board_config(codec,
4384 STAC_92HD73XX_MODELS,
4385 stac92hd73xx_models,
4386 stac92hd73xx_cfg_tbl);
4387again:
4388 if (spec->board_config < 0) {
4389 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4390 " STAC92HD73XX, using BIOS defaults\n");
4391 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004392 } else
4393 err = stac_save_pin_cfgs(codec,
4394 stac92hd73xx_brd_tbl[spec->board_config]);
4395 if (err < 0) {
4396 stac92xx_free(codec);
4397 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004398 }
4399
4400 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4401 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4402
4403 if (spec->multiout.num_dacs < 0) {
4404 printk(KERN_WARNING "hda_codec: Could not determine "
4405 "number of channels defaulting to DAC count\n");
4406 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4407 }
4408
4409 switch (spec->multiout.num_dacs) {
4410 case 0x3: /* 6 Channel */
4411 spec->mixer = stac92hd73xx_6ch_mixer;
4412 spec->init = stac92hd73xx_6ch_core_init;
4413 break;
4414 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004415 spec->mixer = stac92hd73xx_8ch_mixer;
4416 spec->init = stac92hd73xx_8ch_core_init;
4417 break;
4418 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004419 spec->mixer = stac92hd73xx_10ch_mixer;
4420 spec->init = stac92hd73xx_10ch_core_init;
4421 };
4422
4423 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4424 spec->aloopback_mask = 0x01;
4425 spec->aloopback_shift = 8;
4426
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004427 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004428 spec->mux_nids = stac92hd73xx_mux_nids;
4429 spec->adc_nids = stac92hd73xx_adc_nids;
4430 spec->dmic_nids = stac92hd73xx_dmic_nids;
4431 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004432 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004433 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004434 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004435
4436 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4437 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004438 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004439 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4440 sizeof(stac92hd73xx_dmux));
4441
Matthew Ranostaya7662642008-02-21 07:51:14 +01004442 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004443 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004444 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004445 /* fallthru */
4446 case STAC_DELL_M6:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004447 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004448 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4449 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004450 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004451 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004452
4453 if (!spec->init)
4454 spec->init = dell_m6_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004455 switch (codec->subsystem_id) {
4456 case 0x1028025e: /* Analog Mics */
4457 case 0x1028025f:
4458 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4459 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004460 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004461 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004462 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004463 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004464 case 0x10280254:
4465 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004466 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4467 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004468 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004469 break;
4470 case 0x10280256: /* Both */
4471 case 0x10280057:
4472 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4473 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4474 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004475 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004476 break;
4477 }
4478 break;
4479 default:
4480 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004481 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004482 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004483 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004484 if (spec->board_config > STAC_92HD73XX_REF) {
4485 /* GPIO0 High = Enable EAPD */
4486 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4487 spec->gpio_data = 0x01;
4488 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004489 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004490
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004491 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4492 spec->pwr_nids = stac92hd73xx_pwr_nids;
4493
Matthew Ranostayd9737752008-09-07 12:03:41 +02004494 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004495
4496 if (!err) {
4497 if (spec->board_config < 0) {
4498 printk(KERN_WARNING "hda_codec: No auto-config is "
4499 "available, default to model=ref\n");
4500 spec->board_config = STAC_92HD73XX_REF;
4501 goto again;
4502 }
4503 err = -EINVAL;
4504 }
4505
4506 if (err < 0) {
4507 stac92xx_free(codec);
4508 return err;
4509 }
4510
4511 codec->patch_ops = stac92xx_patch_ops;
4512
4513 return 0;
4514}
4515
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004516static struct hda_input_mux stac92hd83xxx_dmux = {
4517 .num_items = 3,
4518 .items = {
4519 { "Analog Inputs", 0x03 },
4520 { "Digital Mic 1", 0x04 },
4521 { "Digital Mic 2", 0x05 },
4522 }
4523};
4524
4525static int patch_stac92hd83xxx(struct hda_codec *codec)
4526{
4527 struct sigmatel_spec *spec;
4528 int err;
4529
4530 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4531 if (spec == NULL)
4532 return -ENOMEM;
4533
4534 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004535 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004536 spec->mono_nid = 0x19;
4537 spec->digbeep_nid = 0x21;
4538 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4539 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4540 spec->adc_nids = stac92hd83xxx_adc_nids;
4541 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4542 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4543 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4544 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4545
4546 spec->init = stac92hd83xxx_core_init;
4547 switch (codec->vendor_id) {
4548 case 0x111d7605:
4549 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4550 break;
4551 default:
4552 spec->num_pwrs--;
4553 spec->init++; /* switch to config #2 */
4554 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4555 }
4556
4557 spec->mixer = stac92hd83xxx_mixer;
4558 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4559 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4560 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4561 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4562 spec->dinput_mux = &stac92hd83xxx_dmux;
4563 spec->pin_nids = stac92hd83xxx_pin_nids;
4564 spec->board_config = snd_hda_check_board_config(codec,
4565 STAC_92HD83XXX_MODELS,
4566 stac92hd83xxx_models,
4567 stac92hd83xxx_cfg_tbl);
4568again:
4569 if (spec->board_config < 0) {
4570 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4571 " STAC92HD83XXX, using BIOS defaults\n");
4572 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004573 } else
4574 err = stac_save_pin_cfgs(codec,
4575 stac92hd83xxx_brd_tbl[spec->board_config]);
4576 if (err < 0) {
4577 stac92xx_free(codec);
4578 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004579 }
4580
4581 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4582 if (!err) {
4583 if (spec->board_config < 0) {
4584 printk(KERN_WARNING "hda_codec: No auto-config is "
4585 "available, default to model=ref\n");
4586 spec->board_config = STAC_92HD83XXX_REF;
4587 goto again;
4588 }
4589 err = -EINVAL;
4590 }
4591
4592 if (err < 0) {
4593 stac92xx_free(codec);
4594 return err;
4595 }
4596
4597 codec->patch_ops = stac92xx_patch_ops;
4598
4599 return 0;
4600}
4601
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004602#ifdef SND_HDA_NEEDS_RESUME
4603static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4604{
4605 struct sigmatel_spec *spec = codec->spec;
4606 int i;
4607 snd_hda_codec_write_cache(codec, codec->afg, 0,
4608 AC_VERB_SET_POWER_STATE, pwr);
4609
4610 msleep(1);
4611 for (i = 0; i < spec->num_adcs; i++) {
4612 snd_hda_codec_write_cache(codec,
4613 spec->adc_nids[i], 0,
4614 AC_VERB_SET_POWER_STATE, pwr);
4615 }
4616};
4617
4618static int stac92hd71xx_resume(struct hda_codec *codec)
4619{
4620 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4621 return stac92xx_resume(codec);
4622}
4623
4624static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4625{
4626 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004627 return stac92xx_suspend(codec, state);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004628};
4629
4630#endif
4631
4632static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4633 .build_controls = stac92xx_build_controls,
4634 .build_pcms = stac92xx_build_pcms,
4635 .init = stac92xx_init,
4636 .free = stac92xx_free,
4637 .unsol_event = stac92xx_unsol_event,
4638#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004639 .suspend = stac92hd71xx_suspend,
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004640 .resume = stac92hd71xx_resume,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004641#endif
4642};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004643
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004644static struct hda_input_mux stac92hd71bxx_dmux = {
4645 .num_items = 4,
4646 .items = {
4647 { "Analog Inputs", 0x00 },
4648 { "Mixer", 0x01 },
4649 { "Digital Mic 1", 0x02 },
4650 { "Digital Mic 2", 0x03 },
4651 }
4652};
4653
Matthew Ranostaye035b842007-11-06 11:53:55 +01004654static int patch_stac92hd71bxx(struct hda_codec *codec)
4655{
4656 struct sigmatel_spec *spec;
4657 int err = 0;
4658
4659 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4660 if (spec == NULL)
4661 return -ENOMEM;
4662
4663 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004664 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004665 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004666 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004667 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004668 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4669 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004670 spec->board_config = snd_hda_check_board_config(codec,
4671 STAC_92HD71BXX_MODELS,
4672 stac92hd71bxx_models,
4673 stac92hd71bxx_cfg_tbl);
4674again:
4675 if (spec->board_config < 0) {
4676 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4677 " STAC92HD71BXX, using BIOS defaults\n");
4678 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004679 } else
4680 err = stac_save_pin_cfgs(codec,
4681 stac92hd71bxx_brd_tbl[spec->board_config]);
4682 if (err < 0) {
4683 stac92xx_free(codec);
4684 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004685 }
4686
Takashi Iwai41c3b642008-11-18 10:45:15 +01004687 if (spec->board_config > STAC_92HD71BXX_REF) {
4688 /* GPIO0 = EAPD */
4689 spec->gpio_mask = 0x01;
4690 spec->gpio_dir = 0x01;
4691 spec->gpio_data = 0x01;
4692 }
4693
Matthew Ranostay541eee82007-12-14 12:08:04 +01004694 switch (codec->vendor_id) {
4695 case 0x111d76b6: /* 4 Port without Analog Mixer */
4696 case 0x111d76b7:
4697 case 0x111d76b4: /* 6 Port without Analog Mixer */
4698 case 0x111d76b5:
4699 spec->mixer = stac92hd71bxx_mixer;
4700 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004701 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004702 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004703 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004704 switch (spec->board_config) {
4705 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004706 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004707 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004708 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4709 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004710 AC_VERB_SET_UNSOLICITED_ENABLE,
4711 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
4712 err = stac92xx_add_event(spec, codec->afg, 0x02);
4713 if (err < 0)
4714 return err;
Matthew Ranostay72474be2008-10-09 09:32:17 -04004715 spec->gpio_mask |= 0x02;
4716 break;
4717 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004718 if ((codec->revision_id & 0xf) == 0 ||
4719 (codec->revision_id & 0xf) == 1) {
4720#ifdef SND_HDA_NEEDS_RESUME
4721 codec->patch_ops = stac92hd71bxx_patch_ops;
4722#endif
4723 spec->stream_delay = 40; /* 40 milliseconds */
4724 }
4725
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004726 /* no output amps */
4727 spec->num_pwrs = 0;
4728 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004729 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004730
4731 /* disable VSW */
4732 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004733 stac_change_pin_config(codec, 0xf, 0x40f000f0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004734 break;
4735 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004736 if ((codec->revision_id & 0xf) == 1) {
4737#ifdef SND_HDA_NEEDS_RESUME
4738 codec->patch_ops = stac92hd71bxx_patch_ops;
4739#endif
4740 spec->stream_delay = 40; /* 40 milliseconds */
4741 }
4742
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004743 /* no output amps */
4744 spec->num_pwrs = 0;
4745 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004746 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004747 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004748 spec->mixer = stac92hd71bxx_analog_mixer;
4749 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004750 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004751 }
4752
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004753 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004754 spec->aloopback_shift = 0;
4755
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004756 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004757 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004758 spec->mux_nids = stac92hd71bxx_mux_nids;
4759 spec->adc_nids = stac92hd71bxx_adc_nids;
4760 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004761 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004762 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004763 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004764
4765 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4766 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004767
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004768 switch (spec->board_config) {
4769 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004770 /* enable internal microphone */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004771 stac_change_pin_config(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004772 stac92xx_auto_set_pinctl(codec, 0x0e,
4773 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004774 /* fallthru */
4775 case STAC_DELL_M4_2:
4776 spec->num_dmics = 0;
4777 spec->num_smuxes = 0;
4778 spec->num_dmuxes = 0;
4779 break;
4780 case STAC_DELL_M4_1:
4781 case STAC_DELL_M4_3:
4782 spec->num_dmics = 1;
4783 spec->num_smuxes = 0;
4784 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004785 break;
4786 default:
4787 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4788 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4789 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4790 };
4791
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004792 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004793 spec->multiout.hp_nid = 0x11;
4794 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004795 if (spec->dinput_mux)
4796 spec->private_dimux.num_items +=
4797 spec->num_dmics -
4798 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004799
4800 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4801 if (!err) {
4802 if (spec->board_config < 0) {
4803 printk(KERN_WARNING "hda_codec: No auto-config is "
4804 "available, default to model=ref\n");
4805 spec->board_config = STAC_92HD71BXX_REF;
4806 goto again;
4807 }
4808 err = -EINVAL;
4809 }
4810
4811 if (err < 0) {
4812 stac92xx_free(codec);
4813 return err;
4814 }
4815
Matthew Ranostaye035b842007-11-06 11:53:55 +01004816 return 0;
4817};
4818
Matt2f2f4252005-04-13 14:45:30 +02004819static int patch_stac922x(struct hda_codec *codec)
4820{
4821 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004822 int err;
Matt2f2f4252005-04-13 14:45:30 +02004823
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004824 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004825 if (spec == NULL)
4826 return -ENOMEM;
4827
4828 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004829 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004830 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004831 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4832 stac922x_models,
4833 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004834 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004835 spec->gpio_mask = spec->gpio_dir = 0x03;
4836 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004837 /* Intel Macs have all same PCI SSID, so we need to check
4838 * codec SSID to distinguish the exact models
4839 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004840 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004841 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004842
4843 case 0x106b0800:
4844 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004845 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004846 case 0x106b0600:
4847 case 0x106b0700:
4848 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004849 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004850 case 0x106b0e00:
4851 case 0x106b0f00:
4852 case 0x106b1600:
4853 case 0x106b1700:
4854 case 0x106b0200:
4855 case 0x106b1e00:
4856 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004857 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004858 case 0x106b1a00:
4859 case 0x00000100:
4860 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004861 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004862 case 0x106b0a00:
4863 case 0x106b2200:
4864 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004865 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004866 default:
4867 spec->board_config = STAC_INTEL_MAC_V3;
4868 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004869 }
4870 }
4871
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004872 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004873 if (spec->board_config < 0) {
4874 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4875 "using BIOS defaults\n");
4876 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004877 } else
4878 err = stac_save_pin_cfgs(codec,
4879 stac922x_brd_tbl[spec->board_config]);
4880 if (err < 0) {
4881 stac92xx_free(codec);
4882 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004883 }
Matt2f2f4252005-04-13 14:45:30 +02004884
Matt2f2f4252005-04-13 14:45:30 +02004885 spec->adc_nids = stac922x_adc_nids;
4886 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004887 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004888 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004889 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004890 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004891
4892 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004893 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004894
4895 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004896
Matt Porter3cc08dc2006-01-23 15:27:49 +01004897 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004898 if (!err) {
4899 if (spec->board_config < 0) {
4900 printk(KERN_WARNING "hda_codec: No auto-config is "
4901 "available, default to model=ref\n");
4902 spec->board_config = STAC_D945_REF;
4903 goto again;
4904 }
4905 err = -EINVAL;
4906 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004907 if (err < 0) {
4908 stac92xx_free(codec);
4909 return err;
4910 }
4911
4912 codec->patch_ops = stac92xx_patch_ops;
4913
Takashi Iwai807a46362007-05-29 19:01:37 +02004914 /* Fix Mux capture level; max to 2 */
4915 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4916 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4917 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4918 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4919 (0 << AC_AMPCAP_MUTE_SHIFT));
4920
Matt Porter3cc08dc2006-01-23 15:27:49 +01004921 return 0;
4922}
4923
4924static int patch_stac927x(struct hda_codec *codec)
4925{
4926 struct sigmatel_spec *spec;
4927 int err;
4928
4929 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4930 if (spec == NULL)
4931 return -ENOMEM;
4932
4933 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004934 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004935 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004936 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4937 stac927x_models,
4938 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004939 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004940 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4941 if (spec->board_config < 0)
4942 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4943 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004944 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004945 } else
4946 err = stac_save_pin_cfgs(codec,
4947 stac927x_brd_tbl[spec->board_config]);
4948 if (err < 0) {
4949 stac92xx_free(codec);
4950 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01004951 }
4952
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004953 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004954 spec->adc_nids = stac927x_adc_nids;
4955 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4956 spec->mux_nids = stac927x_mux_nids;
4957 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004958 spec->smux_nids = stac927x_smux_nids;
4959 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004960 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004961 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004962 spec->multiout.dac_nids = spec->dac_nids;
4963
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004964 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004965 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004966 case STAC_D965_5ST:
4967 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004968 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004969 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004970 spec->num_dmics = 0;
4971
Tobin Davis93ed1502006-09-01 21:03:12 +02004972 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004973 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004974 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004975 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004976 switch (codec->subsystem_id) {
4977 case 0x10280209:
4978 case 0x1028022e:
4979 /* correct the device field to SPDIF out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004980 stac_change_pin_config(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004981 break;
4982 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004983 /* configure the analog microphone on some laptops */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004984 stac_change_pin_config(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004985 /* correct the front output jack as a hp out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004986 stac_change_pin_config(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004987 /* correct the front input jack as a mic */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004988 stac_change_pin_config(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004989 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004990 case STAC_DELL_3ST:
4991 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004992 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004993 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004994 spec->dmic_nids = stac927x_dmic_nids;
4995 spec->num_dmics = STAC927X_NUM_DMICS;
4996
Tobin Davis93ed1502006-09-01 21:03:12 +02004997 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004998 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004999 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005000 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005001 break;
5002 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005003 if (spec->board_config > STAC_D965_REF) {
5004 /* GPIO0 High = Enable EAPD */
5005 spec->eapd_mask = spec->gpio_mask = 0x01;
5006 spec->gpio_dir = spec->gpio_data = 0x01;
5007 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005008 spec->num_dmics = 0;
5009
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005010 spec->init = stac927x_core_init;
5011 spec->mixer = stac927x_mixer;
5012 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005013
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005014 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005015 spec->aloopback_mask = 0x40;
5016 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005017 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005018
Matt Porter3cc08dc2006-01-23 15:27:49 +01005019 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005020 if (!err) {
5021 if (spec->board_config < 0) {
5022 printk(KERN_WARNING "hda_codec: No auto-config is "
5023 "available, default to model=ref\n");
5024 spec->board_config = STAC_D965_REF;
5025 goto again;
5026 }
5027 err = -EINVAL;
5028 }
Mattc7d4b2f2005-06-27 14:59:41 +02005029 if (err < 0) {
5030 stac92xx_free(codec);
5031 return err;
5032 }
Matt2f2f4252005-04-13 14:45:30 +02005033
5034 codec->patch_ops = stac92xx_patch_ops;
5035
Takashi Iwai52987652008-01-16 16:09:47 +01005036 /*
5037 * !!FIXME!!
5038 * The STAC927x seem to require fairly long delays for certain
5039 * command sequences. With too short delays (even if the answer
5040 * is set to RIRB properly), it results in the silence output
5041 * on some hardwares like Dell.
5042 *
5043 * The below flag enables the longer delay (see get_response
5044 * in hda_intel.c).
5045 */
5046 codec->bus->needs_damn_long_delay = 1;
5047
Matt2f2f4252005-04-13 14:45:30 +02005048 return 0;
5049}
5050
Matt Porterf3302a52006-07-31 12:49:34 +02005051static int patch_stac9205(struct hda_codec *codec)
5052{
5053 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005054 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005055
5056 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5057 if (spec == NULL)
5058 return -ENOMEM;
5059
5060 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005061 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005062 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005063 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5064 stac9205_models,
5065 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005066 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005067 if (spec->board_config < 0) {
5068 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5069 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005070 } else
5071 err = stac_save_pin_cfgs(codec,
5072 stac9205_brd_tbl[spec->board_config]);
5073 if (err < 0) {
5074 stac92xx_free(codec);
5075 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02005076 }
5077
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005078 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005079 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005080 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005081 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005082 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005083 spec->smux_nids = stac9205_smux_nids;
5084 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005085 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005086 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005087 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005088 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005089 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005090
5091 spec->init = stac9205_core_init;
5092 spec->mixer = stac9205_mixer;
5093
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005094 spec->aloopback_mask = 0x40;
5095 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005096 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005097 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005098
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005099 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005100 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005101 /* Enable SPDIF in/out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005102 stac_change_pin_config(codec, 0x1f, 0x01441030);
5103 stac_change_pin_config(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005104
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005105 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005106 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005107 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5108 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005109 AC_VERB_SET_UNSOLICITED_ENABLE,
5110 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
5111 err = stac92xx_add_event(spec, codec->afg, 0x01);
5112 if (err < 0)
5113 return err;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005114
5115 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005116 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005117 spec->gpio_mask = 0x1b;
5118 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005119 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005120 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005121 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005122 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005123 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005124 case STAC_9205_REF:
5125 /* SPDIF-In enabled */
5126 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005127 default:
5128 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005129 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005130 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005131 break;
5132 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005133
Matt Porterf3302a52006-07-31 12:49:34 +02005134 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005135 if (!err) {
5136 if (spec->board_config < 0) {
5137 printk(KERN_WARNING "hda_codec: No auto-config is "
5138 "available, default to model=ref\n");
5139 spec->board_config = STAC_9205_REF;
5140 goto again;
5141 }
5142 err = -EINVAL;
5143 }
Matt Porterf3302a52006-07-31 12:49:34 +02005144 if (err < 0) {
5145 stac92xx_free(codec);
5146 return err;
5147 }
5148
5149 codec->patch_ops = stac92xx_patch_ops;
5150
5151 return 0;
5152}
5153
Matt2f2f4252005-04-13 14:45:30 +02005154/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005155 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005156 */
5157
Guillaume Munch99ccc562006-08-16 19:35:12 +02005158/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005159static hda_nid_t vaio_dacs[] = { 0x2 };
5160#define VAIO_HP_DAC 0x5
5161static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5162static hda_nid_t vaio_mux_nids[] = { 0x15 };
5163
5164static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005165 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005166 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005167 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005168 { "Mic Jack", 0x1 },
5169 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005170 { "PCM", 0x3 },
5171 }
5172};
5173
5174static struct hda_verb vaio_init[] = {
5175 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005176 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005177 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5178 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5179 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005181 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005182 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5183 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5184 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5187 {}
5188};
5189
Guillaume Munch6d859062006-08-22 17:15:47 +02005190static struct hda_verb vaio_ar_init[] = {
5191 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5192 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5193 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5194 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5195/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005198 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5199 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5200/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5204 {}
5205};
5206
Takashi Iwaidb064e52006-03-16 16:04:58 +01005207static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005208 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5210 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5211 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005212 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5213 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5214 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5215 {
5216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5217 .name = "Capture Source",
5218 .count = 1,
5219 .info = stac92xx_mux_enum_info,
5220 .get = stac92xx_mux_enum_get,
5221 .put = stac92xx_mux_enum_put,
5222 },
5223 {}
5224};
5225
Guillaume Munch6d859062006-08-22 17:15:47 +02005226static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwai127e82e2008-11-14 14:03:33 +01005227 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5229 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5230 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
Guillaume Munch6d859062006-08-22 17:15:47 +02005231 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5232 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5233 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5234 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5235 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5236 {
5237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5238 .name = "Capture Source",
5239 .count = 1,
5240 .info = stac92xx_mux_enum_info,
5241 .get = stac92xx_mux_enum_get,
5242 .put = stac92xx_mux_enum_put,
5243 },
5244 {}
5245};
5246
5247static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005248 .build_controls = stac92xx_build_controls,
5249 .build_pcms = stac92xx_build_pcms,
5250 .init = stac92xx_init,
5251 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005252#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005253 .resume = stac92xx_resume,
5254#endif
5255};
5256
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005257static int stac9872_vaio_init(struct hda_codec *codec)
5258{
5259 int err;
5260
5261 err = stac92xx_init(codec);
5262 if (err < 0)
5263 return err;
5264 if (codec->patch_ops.unsol_event)
5265 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5266 return 0;
5267}
5268
5269static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5270{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005271 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005272 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5273 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5274 } else {
5275 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5276 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5277 }
5278}
5279
5280static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5281{
5282 switch (res >> 26) {
5283 case STAC_HP_EVENT:
5284 stac9872_vaio_hp_detect(codec, res);
5285 break;
5286 }
5287}
5288
5289static struct hda_codec_ops stac9872_vaio_patch_ops = {
5290 .build_controls = stac92xx_build_controls,
5291 .build_pcms = stac92xx_build_pcms,
5292 .init = stac9872_vaio_init,
5293 .free = stac92xx_free,
5294 .unsol_event = stac9872_vaio_unsol_event,
5295#ifdef CONFIG_PM
5296 .resume = stac92xx_resume,
5297#endif
5298};
5299
Guillaume Munch6d859062006-08-22 17:15:47 +02005300enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5301 CXD9872RD_VAIO,
5302 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5303 STAC9872AK_VAIO,
5304 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5305 STAC9872K_VAIO,
5306 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005307 CXD9872AKD_VAIO,
5308 STAC_9872_MODELS,
5309};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005310
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005311static const char *stac9872_models[STAC_9872_MODELS] = {
5312 [CXD9872RD_VAIO] = "vaio",
5313 [CXD9872AKD_VAIO] = "vaio-ar",
5314};
5315
5316static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5317 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5318 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5319 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005320 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005321 {}
5322};
5323
Guillaume Munch6d859062006-08-22 17:15:47 +02005324static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005325{
5326 struct sigmatel_spec *spec;
5327 int board_config;
5328
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005329 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5330 stac9872_models,
5331 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005332 if (board_config < 0)
5333 /* unknown config, let generic-parser do its job... */
5334 return snd_hda_parse_generic_codec(codec);
5335
5336 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5337 if (spec == NULL)
5338 return -ENOMEM;
5339
5340 codec->spec = spec;
5341 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005342 case CXD9872RD_VAIO:
5343 case STAC9872AK_VAIO:
5344 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005345 spec->mixer = vaio_mixer;
5346 spec->init = vaio_init;
5347 spec->multiout.max_channels = 2;
5348 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5349 spec->multiout.dac_nids = vaio_dacs;
5350 spec->multiout.hp_nid = VAIO_HP_DAC;
5351 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5352 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005353 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005354 spec->input_mux = &vaio_mux;
5355 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005356 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005357 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005358
5359 case CXD9872AKD_VAIO:
5360 spec->mixer = vaio_ar_mixer;
5361 spec->init = vaio_ar_init;
5362 spec->multiout.max_channels = 2;
5363 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5364 spec->multiout.dac_nids = vaio_dacs;
5365 spec->multiout.hp_nid = VAIO_HP_DAC;
5366 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005367 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005368 spec->adc_nids = vaio_adcs;
5369 spec->input_mux = &vaio_mux;
5370 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005371 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005372 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005373 }
5374
Takashi Iwaidb064e52006-03-16 16:04:58 +01005375 return 0;
5376}
5377
5378
5379/*
Matt2f2f4252005-04-13 14:45:30 +02005380 * patch entries
5381 */
5382struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5383 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5384 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5385 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5386 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5387 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5388 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5389 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005390 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5391 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5392 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5393 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5394 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5395 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005396 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5397 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5398 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5399 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5400 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5401 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5402 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5403 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5404 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5405 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005406 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5407 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5408 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5409 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5410 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5411 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005412 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5413 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005414 /* The following does not take into account .id=0x83847661 when subsys =
5415 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5416 * currently not fully supported.
5417 */
5418 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5419 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5420 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005421 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5422 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5423 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5424 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5425 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5426 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5427 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5428 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005429 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005430 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5431 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005432 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005433 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5434 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005435 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005436 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5437 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5438 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5439 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5440 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5441 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5442 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5443 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005444 {} /* terminator */
5445};