blob: c4f3489376c59cbc81c871c69d38aae412337503 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include "hda_codec.h"
34#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010035#include "hda_patch.h"
Matt2f2f4252005-04-13 14:45:30 +020036
Matt4e550962005-07-04 17:51:39 +020037#define NUM_CONTROL_ALLOC 32
Matthew Ranostaya64135a2008-01-10 16:55:06 +010038#define STAC_PWR_EVENT 0x20
39#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020040
Takashi Iwaif5fcc132006-11-24 17:07:44 +010041enum {
42 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010043 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020044 STAC_9200_DELL_D21,
45 STAC_9200_DELL_D22,
46 STAC_9200_DELL_D23,
47 STAC_9200_DELL_M21,
48 STAC_9200_DELL_M22,
49 STAC_9200_DELL_M23,
50 STAC_9200_DELL_M24,
51 STAC_9200_DELL_M25,
52 STAC_9200_DELL_M26,
53 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020054 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010055 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010056 STAC_9200_MODELS
57};
58
59enum {
60 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020061 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020062 STAC_9205_DELL_M43,
63 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010064 STAC_9205_MODELS
65};
66
67enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010068 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010069 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010070 STAC_92HD73XX_MODELS
71};
72
73enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010074 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010075 STAC_DELL_M4_1,
76 STAC_DELL_M4_2,
Matthew Ranostaye035b842007-11-06 11:53:55 +010077 STAC_92HD71BXX_MODELS
78};
79
80enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010081 STAC_925x_REF,
82 STAC_M2_2,
83 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020084 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010085 STAC_925x_MODELS
86};
87
88enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010089 STAC_D945_REF,
90 STAC_D945GTP3,
91 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020092 STAC_INTEL_MAC_V1,
93 STAC_INTEL_MAC_V2,
94 STAC_INTEL_MAC_V3,
95 STAC_INTEL_MAC_V4,
96 STAC_INTEL_MAC_V5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020097 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010098 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +010099 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100100 STAC_MACBOOK_PRO_V1,
101 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200102 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200103 STAC_IMAC_INTEL_20,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200104 STAC_922X_DELL_D81,
105 STAC_922X_DELL_D82,
106 STAC_922X_DELL_M81,
107 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100108 STAC_922X_MODELS
109};
110
111enum {
112 STAC_D965_REF,
113 STAC_D965_3ST,
114 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200115 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100116 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100117 STAC_927X_MODELS
118};
Matt Porter403d1942005-11-29 15:00:51 +0100119
Matt2f2f4252005-04-13 14:45:30 +0200120struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100121 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200122 unsigned int num_mixers;
123
Matt Porter403d1942005-11-29 15:00:51 +0100124 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200125 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100126 unsigned int line_switch: 1;
127 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100128 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100129 unsigned int hp_detect: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200130
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100131 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200132 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100133 unsigned int gpio_mask;
134 unsigned int gpio_dir;
135 unsigned int gpio_data;
136 unsigned int gpio_mute;
137
138 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100139 unsigned char aloopback_mask;
140 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200141
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100142 /* power management */
143 unsigned int num_pwrs;
144 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100145 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100146
Matt2f2f4252005-04-13 14:45:30 +0200147 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100148 struct hda_input_mux *mono_mux;
149 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200150 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100151 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200152
153 /* capture */
154 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200155 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200156 hda_nid_t *mux_nids;
157 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200158 hda_nid_t *dmic_nids;
159 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100160 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100161 unsigned int num_dmuxes;
Mattdabbed62005-06-14 10:19:34 +0200162 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100163 hda_nid_t mono_nid;
Matt2f2f4252005-04-13 14:45:30 +0200164
Matt2f2f4252005-04-13 14:45:30 +0200165 /* pin widgets */
166 hda_nid_t *pin_nids;
167 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200168 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200169 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200170
171 /* codec specific stuff */
172 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100173 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200174
175 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200176 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100177 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200178 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100179 unsigned int cur_mux[3];
Matt2f2f4252005-04-13 14:45:30 +0200180
Matt Porter403d1942005-11-29 15:00:51 +0100181 /* i/o switches */
182 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200183 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200184 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200185 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200186
Mattc7d4b2f2005-06-27 14:59:41 +0200187 struct hda_pcm pcm_rec[2]; /* PCM information */
188
189 /* dynamic controls and input_mux */
190 struct auto_pin_cfg autocfg;
191 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100192 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200193 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200194 struct hda_input_mux private_imux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100195 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200196};
197
198static hda_nid_t stac9200_adc_nids[1] = {
199 0x03,
200};
201
202static hda_nid_t stac9200_mux_nids[1] = {
203 0x0c,
204};
205
206static hda_nid_t stac9200_dac_nids[1] = {
207 0x02,
208};
209
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100210static hda_nid_t stac92hd73xx_pwr_nids[8] = {
211 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
212 0x0f, 0x10, 0x11
213};
214
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100215static hda_nid_t stac92hd73xx_adc_nids[2] = {
216 0x1a, 0x1b
217};
218
219#define STAC92HD73XX_NUM_DMICS 2
220static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
221 0x13, 0x14, 0
222};
223
224#define STAC92HD73_DAC_COUNT 5
225static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
226 0x15, 0x16, 0x17, 0x18, 0x19,
227};
228
229static hda_nid_t stac92hd73xx_mux_nids[4] = {
230 0x28, 0x29, 0x2a, 0x2b,
231};
232
233static hda_nid_t stac92hd73xx_dmux_nids[2] = {
234 0x20, 0x21,
235};
236
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100237static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
238 0x0a, 0x0d, 0x0f
239};
240
Matthew Ranostaye035b842007-11-06 11:53:55 +0100241static hda_nid_t stac92hd71bxx_adc_nids[2] = {
242 0x12, 0x13,
243};
244
245static hda_nid_t stac92hd71bxx_mux_nids[2] = {
246 0x1a, 0x1b
247};
248
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100249static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
250 0x1c,
251};
252
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100253static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100254 0x10, /*0x11, */
255};
256
257#define STAC92HD71BXX_NUM_DMICS 2
258static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
259 0x18, 0x19, 0
260};
261
Tobin Davis8e21c342007-01-08 11:04:17 +0100262static hda_nid_t stac925x_adc_nids[1] = {
263 0x03,
264};
265
266static hda_nid_t stac925x_mux_nids[1] = {
267 0x0f,
268};
269
270static hda_nid_t stac925x_dac_nids[1] = {
271 0x02,
272};
273
Takashi Iwaif6e98522007-10-16 14:27:04 +0200274#define STAC925X_NUM_DMICS 1
275static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
276 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200277};
278
Takashi Iwai1697055e2007-12-18 18:05:52 +0100279static hda_nid_t stac925x_dmux_nids[1] = {
280 0x14,
281};
282
Matt2f2f4252005-04-13 14:45:30 +0200283static hda_nid_t stac922x_adc_nids[2] = {
284 0x06, 0x07,
285};
286
287static hda_nid_t stac922x_mux_nids[2] = {
288 0x12, 0x13,
289};
290
Matt Porter3cc08dc2006-01-23 15:27:49 +0100291static hda_nid_t stac927x_adc_nids[3] = {
292 0x07, 0x08, 0x09
293};
294
295static hda_nid_t stac927x_mux_nids[3] = {
296 0x15, 0x16, 0x17
297};
298
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100299static hda_nid_t stac927x_dac_nids[6] = {
300 0x02, 0x03, 0x04, 0x05, 0x06, 0
301};
302
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100303static hda_nid_t stac927x_dmux_nids[1] = {
304 0x1b,
305};
306
Matthew Ranostay7f168592007-10-18 17:38:17 +0200307#define STAC927X_NUM_DMICS 2
308static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
309 0x13, 0x14, 0
310};
311
Matt Porterf3302a52006-07-31 12:49:34 +0200312static hda_nid_t stac9205_adc_nids[2] = {
313 0x12, 0x13
314};
315
316static hda_nid_t stac9205_mux_nids[2] = {
317 0x19, 0x1a
318};
319
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100320static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100321 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100322};
323
Takashi Iwaif6e98522007-10-16 14:27:04 +0200324#define STAC9205_NUM_DMICS 2
325static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
326 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200327};
328
Mattc7d4b2f2005-06-27 14:59:41 +0200329static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200330 0x08, 0x09, 0x0d, 0x0e,
331 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200332};
333
Tobin Davis8e21c342007-01-08 11:04:17 +0100334static hda_nid_t stac925x_pin_nids[8] = {
335 0x07, 0x08, 0x0a, 0x0b,
336 0x0c, 0x0d, 0x10, 0x11,
337};
338
Matt2f2f4252005-04-13 14:45:30 +0200339static hda_nid_t stac922x_pin_nids[10] = {
340 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
341 0x0f, 0x10, 0x11, 0x15, 0x1b,
342};
343
Matthew Ranostaya7662642008-02-21 07:51:14 +0100344static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
346 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100347 0x14, 0x1e, 0x22
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100348};
349
Matthew Ranostaye035b842007-11-06 11:53:55 +0100350static hda_nid_t stac92hd71bxx_pin_nids[10] = {
351 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
352 0x0f, 0x14, 0x18, 0x19, 0x1e,
353};
354
Matt Porter3cc08dc2006-01-23 15:27:49 +0100355static hda_nid_t stac927x_pin_nids[14] = {
356 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
357 0x0f, 0x10, 0x11, 0x12, 0x13,
358 0x14, 0x21, 0x22, 0x23,
359};
360
Matt Porterf3302a52006-07-31 12:49:34 +0200361static hda_nid_t stac9205_pin_nids[12] = {
362 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
363 0x0f, 0x14, 0x16, 0x17, 0x18,
364 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200365};
366
Matt Porter8b657272006-10-26 17:12:59 +0200367static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_info *uinfo)
369{
370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371 struct sigmatel_spec *spec = codec->spec;
372 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
373}
374
375static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_value *ucontrol)
377{
378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
379 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100380 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200381
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100382 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200383 return 0;
384}
385
386static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
388{
389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
390 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100391 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200392
393 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100394 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200395}
396
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100397static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200398{
399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
400 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200401 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200402}
403
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100404static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200405{
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct sigmatel_spec *spec = codec->spec;
408 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
409
410 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
411 return 0;
412}
413
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100414static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200415{
416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
417 struct sigmatel_spec *spec = codec->spec;
418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
419
Mattc7d4b2f2005-06-27 14:59:41 +0200420 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200421 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
422}
423
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100424static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo)
426{
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 struct sigmatel_spec *spec = codec->spec;
429 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
430}
431
432static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_value *ucontrol)
434{
435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
436 struct sigmatel_spec *spec = codec->spec;
437
438 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
439 return 0;
440}
441
442static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
443 struct snd_ctl_elem_value *ucontrol)
444{
445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
446 struct sigmatel_spec *spec = codec->spec;
447
448 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
449 spec->mono_nid, &spec->cur_mmux);
450}
451
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200452#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
453
454static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_value *ucontrol)
456{
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100458 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200459 struct sigmatel_spec *spec = codec->spec;
460
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100461 ucontrol->value.integer.value[0] = !!(spec->aloopback &
462 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200463 return 0;
464}
465
466static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
467 struct snd_ctl_elem_value *ucontrol)
468{
469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100471 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200472 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100473 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200474
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100475 idx_val = spec->aloopback_mask << idx;
476 if (ucontrol->value.integer.value[0])
477 val = spec->aloopback | idx_val;
478 else
479 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100480 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200481 return 0;
482
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100483 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200484
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100485 /* Only return the bits defined by the shift value of the
486 * first two bytes of the mask
487 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200488 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100489 kcontrol->private_value & 0xFFFF, 0x0);
490 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200491
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100492 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200493 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100494 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200495 } else {
496 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100497 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200498 }
499
500 snd_hda_codec_write_cache(codec, codec->afg, 0,
501 kcontrol->private_value >> 16, dac_mode);
502
503 return 1;
504}
505
Mattc7d4b2f2005-06-27 14:59:41 +0200506static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200507 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200508 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200509 {}
510};
511
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200512static struct hda_verb stac9200_eapd_init[] = {
513 /* set dac0mux for dac converter */
514 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
515 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
516 {}
517};
518
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100519static struct hda_verb stac92hd73xx_6ch_core_init[] = {
520 /* set master volume and direct control */
521 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
522 /* setup audio connections */
523 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
524 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
525 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
526 /* setup adcs to point to mixer */
527 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
528 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100529 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
530 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
531 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
532 /* setup import muxs */
533 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
534 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
535 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
536 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
537 {}
538};
539
Matthew Ranostayd654a662008-03-14 08:46:51 +0100540static struct hda_verb dell_eq_core_init[] = {
541 /* set master volume to max value without distortion
542 * and direct control */
543 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
544 /* setup audio connections */
545 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
546 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
547 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
548 /* setup adcs to point to mixer */
549 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
550 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
551 /* setup import muxs */
552 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
553 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
554 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
555 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
556 {}
557};
558
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100559static struct hda_verb dell_m6_core_init[] = {
560 /* set master volume and direct control */
561 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
562 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100563 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
564 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100565 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
566 /* setup adcs to point to mixer */
567 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
568 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
569 /* setup import muxs */
570 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
571 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
572 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
573 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
574 {}
575};
576
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100577static struct hda_verb stac92hd73xx_8ch_core_init[] = {
578 /* set master volume and direct control */
579 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
580 /* setup audio connections */
581 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
582 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
583 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
584 /* connect hp ports to dac3 */
585 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
586 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
587 /* setup adcs to point to mixer */
588 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
589 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100590 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
591 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
592 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
593 /* setup import muxs */
594 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
595 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
596 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
597 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
598 {}
599};
600
601static struct hda_verb stac92hd73xx_10ch_core_init[] = {
602 /* set master volume and direct control */
603 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
604 /* setup audio connections */
605 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
606 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
607 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
608 /* dac3 is connected to import3 mux */
609 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
610 /* connect hp ports to dac4 */
611 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
612 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
613 /* setup adcs to point to mixer */
614 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
615 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100616 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
617 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
618 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
619 /* setup import muxs */
620 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
621 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
622 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
623 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
624 {}
625};
626
Matthew Ranostaye035b842007-11-06 11:53:55 +0100627static struct hda_verb stac92hd71bxx_core_init[] = {
628 /* set master volume and direct control */
629 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
630 /* connect headphone jack to dac1 */
631 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100632 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
633 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
634 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
635 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
636 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100637};
638
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200639#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100640static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200641 /* start of config #1 */
642
643 /* connect port 0f to audio mixer */
644 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
645 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
646 /* unmute right and left channels for node 0x0f */
647 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
648 /* start of config #2 */
649
Matthew Ranostay541eee82007-12-14 12:08:04 +0100650 /* set master volume and direct control */
651 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
652 /* connect headphone jack to dac1 */
653 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200654 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100655 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100656 /* unmute dac0 input in audio mixer */
657 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200658 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100659 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
660 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100661 {}
662};
663
Tobin Davis8e21c342007-01-08 11:04:17 +0100664static struct hda_verb stac925x_core_init[] = {
665 /* set dac0mux for dac converter */
666 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
667 {}
668};
669
Mattc7d4b2f2005-06-27 14:59:41 +0200670static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200671 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200672 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200673 {}
674};
675
Tobin Davis93ed1502006-09-01 21:03:12 +0200676static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200677 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200678 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200679 /* unmute node 0x1b */
680 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
681 /* select node 0x03 as DAC */
682 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
683 {}
684};
685
Matt Porter3cc08dc2006-01-23 15:27:49 +0100686static struct hda_verb stac927x_core_init[] = {
687 /* set master volume and direct control */
688 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
689 {}
690};
691
Matt Porterf3302a52006-07-31 12:49:34 +0200692static struct hda_verb stac9205_core_init[] = {
693 /* set master volume and direct control */
694 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
695 {}
696};
697
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100698#define STAC_MONO_MUX \
699 { \
700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
701 .name = "Mono Mux", \
702 .count = 1, \
703 .info = stac92xx_mono_mux_enum_info, \
704 .get = stac92xx_mono_mux_enum_get, \
705 .put = stac92xx_mono_mux_enum_put, \
706 }
707
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200708#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200709 { \
710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
711 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200712 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200713 .info = stac92xx_mux_enum_info, \
714 .get = stac92xx_mux_enum_get, \
715 .put = stac92xx_mux_enum_put, \
716 }
717
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100718#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719 { \
720 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
721 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100722 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200723 .info = stac92xx_aloopback_info, \
724 .get = stac92xx_aloopback_get, \
725 .put = stac92xx_aloopback_put, \
726 .private_value = verb_read | (verb_write << 16), \
727 }
728
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100729static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200730 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
731 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200732 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200733 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
734 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Mattc7d4b2f2005-06-27 14:59:41 +0200735 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200736 { } /* end */
737};
738
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100739static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100740 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
741
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100742 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
743 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
744
745 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
746 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
747
748 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
749 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
750
751 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
752 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
753
754 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
755 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
756
757 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
758 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
759
760 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
761 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
762 { } /* end */
763};
764
765static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100766 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
767
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100768 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
769 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
770
771 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
772 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
773
774 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
775 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
776
777 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
778 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
779
780 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
781 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
782
783 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
784 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
785
786 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
787 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
788 { } /* end */
789};
790
791static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100792 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
793
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100794 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
795 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
796
797 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
798 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
799
800 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
801 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
802
803 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
804 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
805
806 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
807 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
808
809 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
810 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
811
812 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
813 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
814 { } /* end */
815};
816
Matthew Ranostay541eee82007-12-14 12:08:04 +0100817static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100818 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100819
Matthew Ranostay9b359472007-11-07 13:03:12 +0100820 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
821 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
822 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
823
824 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
825 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
826 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
827
828 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
829 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +0100830 { } /* end */
831};
832
Matthew Ranostay541eee82007-12-14 12:08:04 +0100833static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +0100834 STAC_INPUT_SOURCE(2),
835 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
836
Matthew Ranostay541eee82007-12-14 12:08:04 +0100837 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
838 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
839 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
840
841 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
842 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
843 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
844 { } /* end */
845};
846
Tobin Davis8e21c342007-01-08 11:04:17 +0100847static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200848 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +0100849 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +0200850 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +0100851 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
852 { } /* end */
853};
854
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100855static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200856 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100857 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200858
859 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
861 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
862
863 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
864 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
865 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
866
867 { } /* end */
868};
869
870/* This needs to be generated dynamically based on sequence */
871static struct snd_kcontrol_new stac922x_mixer[] = {
872 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200873 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
874 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
875 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
876
877 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
878 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
879 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
880 { } /* end */
881};
882
883
884static struct snd_kcontrol_new stac927x_mixer[] = {
885 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100886 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200887
888 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
889 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
890 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
891
892 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
893 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
894 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
895
896 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
897 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
898 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +0200899 { } /* end */
900};
901
Takashi Iwai1697055e2007-12-18 18:05:52 +0100902static struct snd_kcontrol_new stac_dmux_mixer = {
903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
904 .name = "Digital Input Source",
905 /* count set later */
906 .info = stac92xx_dmux_enum_info,
907 .get = stac92xx_dmux_enum_get,
908 .put = stac92xx_dmux_enum_put,
909};
910
Takashi Iwai2134ea42008-01-10 16:53:55 +0100911static const char *slave_vols[] = {
912 "Front Playback Volume",
913 "Surround Playback Volume",
914 "Center Playback Volume",
915 "LFE Playback Volume",
916 "Side Playback Volume",
917 "Headphone Playback Volume",
918 "Headphone Playback Volume",
919 "Speaker Playback Volume",
920 "External Speaker Playback Volume",
921 "Speaker2 Playback Volume",
922 NULL
923};
924
925static const char *slave_sws[] = {
926 "Front Playback Switch",
927 "Surround Playback Switch",
928 "Center Playback Switch",
929 "LFE Playback Switch",
930 "Side Playback Switch",
931 "Headphone Playback Switch",
932 "Headphone Playback Switch",
933 "Speaker Playback Switch",
934 "External Speaker Playback Switch",
935 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +0100936 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +0100937 NULL
938};
939
Matt2f2f4252005-04-13 14:45:30 +0200940static int stac92xx_build_controls(struct hda_codec *codec)
941{
942 struct sigmatel_spec *spec = codec->spec;
943 int err;
Mattc7d4b2f2005-06-27 14:59:41 +0200944 int i;
Matt2f2f4252005-04-13 14:45:30 +0200945
946 err = snd_hda_add_new_ctls(codec, spec->mixer);
947 if (err < 0)
948 return err;
Mattc7d4b2f2005-06-27 14:59:41 +0200949
950 for (i = 0; i < spec->num_mixers; i++) {
951 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
952 if (err < 0)
953 return err;
954 }
Takashi Iwai1697055e2007-12-18 18:05:52 +0100955 if (spec->num_dmuxes > 0) {
956 stac_dmux_mixer.count = spec->num_dmuxes;
957 err = snd_ctl_add(codec->bus->card,
958 snd_ctl_new1(&stac_dmux_mixer, codec));
959 if (err < 0)
960 return err;
961 }
Mattc7d4b2f2005-06-27 14:59:41 +0200962
Mattdabbed62005-06-14 10:19:34 +0200963 if (spec->multiout.dig_out_nid) {
964 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
965 if (err < 0)
966 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +0100967 err = snd_hda_create_spdif_share_sw(codec,
968 &spec->multiout);
969 if (err < 0)
970 return err;
971 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +0200972 }
973 if (spec->dig_in_nid) {
974 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
975 if (err < 0)
976 return err;
977 }
Takashi Iwai2134ea42008-01-10 16:53:55 +0100978
979 /* if we have no master control, let's create it */
980 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +0100981 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +0100982 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +0100983 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +0100984 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +0100985 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +0100986 if (err < 0)
987 return err;
988 }
989 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
990 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
991 NULL, slave_sws);
992 if (err < 0)
993 return err;
994 }
995
Mattdabbed62005-06-14 10:19:34 +0200996 return 0;
Matt2f2f4252005-04-13 14:45:30 +0200997}
998
Matt Porter403d1942005-11-29 15:00:51 +0100999static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001000 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001001 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1002};
1003
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001004/*
1005 STAC 9200 pin configs for
1006 102801A8
1007 102801DE
1008 102801E8
1009*/
1010static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001011 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1012 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001013};
1014
1015/*
1016 STAC 9200 pin configs for
1017 102801C0
1018 102801C1
1019*/
1020static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001021 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1022 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001023};
1024
1025/*
1026 STAC 9200 pin configs for
1027 102801C4 (Dell Dimension E310)
1028 102801C5
1029 102801C7
1030 102801D9
1031 102801DA
1032 102801E3
1033*/
1034static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001035 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1036 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001037};
1038
1039
1040/*
1041 STAC 9200-32 pin configs for
1042 102801B5 (Dell Inspiron 630m)
1043 102801D8 (Dell Inspiron 640m)
1044*/
1045static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001046 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1047 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001048};
1049
1050/*
1051 STAC 9200-32 pin configs for
1052 102801C2 (Dell Latitude D620)
1053 102801C8
1054 102801CC (Dell Latitude D820)
1055 102801D4
1056 102801D6
1057*/
1058static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001059 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1060 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001061};
1062
1063/*
1064 STAC 9200-32 pin configs for
1065 102801CE (Dell XPS M1710)
1066 102801CF (Dell Precision M90)
1067*/
1068static unsigned int dell9200_m23_pin_configs[8] = {
1069 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1070 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1071};
1072
1073/*
1074 STAC 9200-32 pin configs for
1075 102801C9
1076 102801CA
1077 102801CB (Dell Latitude 120L)
1078 102801D3
1079*/
1080static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001081 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1082 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001083};
1084
1085/*
1086 STAC 9200-32 pin configs for
1087 102801BD (Dell Inspiron E1505n)
1088 102801EE
1089 102801EF
1090*/
1091static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001092 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1093 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001094};
1095
1096/*
1097 STAC 9200-32 pin configs for
1098 102801F5 (Dell Inspiron 1501)
1099 102801F6
1100*/
1101static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001102 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1103 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001104};
1105
1106/*
1107 STAC 9200-32
1108 102801CD (Dell Inspiron E1705/9400)
1109*/
1110static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001111 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1112 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001113};
1114
Tobin Davisbf277782008-02-03 20:31:47 +01001115static unsigned int oqo9200_pin_configs[8] = {
1116 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1117 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1118};
1119
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001120
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001121static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1122 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001123 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001124 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1125 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1126 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1127 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1128 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1129 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1130 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1131 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1132 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1133 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001134 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001135};
1136
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001137static const char *stac9200_models[STAC_9200_MODELS] = {
1138 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001139 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001140 [STAC_9200_DELL_D21] = "dell-d21",
1141 [STAC_9200_DELL_D22] = "dell-d22",
1142 [STAC_9200_DELL_D23] = "dell-d23",
1143 [STAC_9200_DELL_M21] = "dell-m21",
1144 [STAC_9200_DELL_M22] = "dell-m22",
1145 [STAC_9200_DELL_M23] = "dell-m23",
1146 [STAC_9200_DELL_M24] = "dell-m24",
1147 [STAC_9200_DELL_M25] = "dell-m25",
1148 [STAC_9200_DELL_M26] = "dell-m26",
1149 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001150 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001151 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001152};
1153
1154static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1155 /* SigmaTel reference board */
1156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1157 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001158 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1160 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001162 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1164 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1166 "unknown Dell", STAC_9200_DELL_D22),
1167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1168 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001170 "Dell Latitude D620", STAC_9200_DELL_M22),
1171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1172 "unknown Dell", STAC_9200_DELL_D23),
1173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1174 "unknown Dell", STAC_9200_DELL_D23),
1175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1176 "unknown Dell", STAC_9200_DELL_M22),
1177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1178 "unknown Dell", STAC_9200_DELL_M24),
1179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1180 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001182 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001184 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001186 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001187 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001188 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001190 "Dell Precision M90", STAC_9200_DELL_M23),
1191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1192 "unknown Dell", STAC_9200_DELL_M22),
1193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1194 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001196 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001197 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001198 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1199 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1200 "unknown Dell", STAC_9200_DELL_D23),
1201 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1202 "unknown Dell", STAC_9200_DELL_D23),
1203 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1204 "unknown Dell", STAC_9200_DELL_D21),
1205 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1206 "unknown Dell", STAC_9200_DELL_D23),
1207 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1208 "unknown Dell", STAC_9200_DELL_D21),
1209 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1210 "unknown Dell", STAC_9200_DELL_M25),
1211 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1212 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001213 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001214 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1215 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1216 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001217 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001218 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001219 /* Gateway machines needs EAPD to be set on resume */
1220 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1221 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1222 STAC_9200_GATEWAY),
1223 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1224 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001225 /* OQO Mobile */
1226 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001227 {} /* terminator */
1228};
1229
Tobin Davis8e21c342007-01-08 11:04:17 +01001230static unsigned int ref925x_pin_configs[8] = {
1231 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001232 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001233};
1234
1235static unsigned int stac925x_MA6_pin_configs[8] = {
1236 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1237 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1238};
1239
Tobin Davis2c11f952007-05-17 09:36:34 +02001240static unsigned int stac925x_PA6_pin_configs[8] = {
1241 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1242 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1243};
1244
Tobin Davis8e21c342007-01-08 11:04:17 +01001245static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001246 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1247 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001248};
1249
1250static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1251 [STAC_REF] = ref925x_pin_configs,
1252 [STAC_M2_2] = stac925xM2_2_pin_configs,
1253 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001254 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001255};
1256
1257static const char *stac925x_models[STAC_925x_MODELS] = {
1258 [STAC_REF] = "ref",
1259 [STAC_M2_2] = "m2-2",
1260 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001261 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001262};
1263
1264static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1265 /* SigmaTel reference board */
1266 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001267 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001268 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1269 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1270 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001271 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001272 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1273 {} /* terminator */
1274};
1275
Matthew Ranostaya7662642008-02-21 07:51:14 +01001276static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001277 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1278 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1279 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001280 0x01452050,
1281};
1282
1283static unsigned int dell_m6_pin_configs[13] = {
1284 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001285 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001286 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1287 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001288};
1289
1290static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001291 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1292 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001293};
1294
1295static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1296 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001297 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001298};
1299
1300static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1301 /* SigmaTel reference board */
1302 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001303 "DFI LanParty", STAC_92HD73XX_REF),
1304 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1305 "unknown Dell", STAC_DELL_M6),
1306 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1307 "unknown Dell", STAC_DELL_M6),
1308 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1309 "unknown Dell", STAC_DELL_M6),
1310 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1311 "unknown Dell", STAC_DELL_M6),
1312 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1313 "unknown Dell", STAC_DELL_M6),
1314 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1315 "unknown Dell", STAC_DELL_M6),
1316 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1317 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001318 {} /* terminator */
1319};
1320
Matthew Ranostaye035b842007-11-06 11:53:55 +01001321static unsigned int ref92hd71bxx_pin_configs[10] = {
1322 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001323 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001324 0x90a000f0, 0x01452050,
1325};
1326
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001327static unsigned int dell_m4_1_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001328 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001329 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001330 0x40f000f0, 0x4f0000f0,
1331};
1332
Matthew Ranostayaafc4412008-06-13 18:04:33 +02001333static unsigned int dell_m4_2_pin_configs[10] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001334 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1335 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1336 0x40f000f0, 0x044413b0,
1337};
1338
Matthew Ranostaye035b842007-11-06 11:53:55 +01001339static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1340 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001341 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1342 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001343};
1344
1345static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1346 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001347 [STAC_DELL_M4_1] = "dell-m4-1",
1348 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001349};
1350
1351static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1352 /* SigmaTel reference board */
1353 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1354 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001355 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1356 "unknown Dell", STAC_DELL_M4_1),
1357 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1358 "unknown Dell", STAC_DELL_M4_1),
1359 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1360 "unknown Dell", STAC_DELL_M4_1),
1361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1362 "unknown Dell", STAC_DELL_M4_1),
1363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1364 "unknown Dell", STAC_DELL_M4_1),
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1366 "unknown Dell", STAC_DELL_M4_1),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1368 "unknown Dell", STAC_DELL_M4_1),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1370 "unknown Dell", STAC_DELL_M4_2),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1372 "unknown Dell", STAC_DELL_M4_2),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1374 "unknown Dell", STAC_DELL_M4_2),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1376 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001377 {} /* terminator */
1378};
1379
Matt Porter403d1942005-11-29 15:00:51 +01001380static unsigned int ref922x_pin_configs[10] = {
1381 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1382 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001383 0x40000100, 0x40000100,
1384};
1385
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001386/*
1387 STAC 922X pin configs for
1388 102801A7
1389 102801AB
1390 102801A9
1391 102801D1
1392 102801D2
1393*/
1394static unsigned int dell_922x_d81_pin_configs[10] = {
1395 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1396 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1397 0x01813122, 0x400001f2,
1398};
1399
1400/*
1401 STAC 922X pin configs for
1402 102801AC
1403 102801D0
1404*/
1405static unsigned int dell_922x_d82_pin_configs[10] = {
1406 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1407 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1408 0x01813122, 0x400001f1,
1409};
1410
1411/*
1412 STAC 922X pin configs for
1413 102801BF
1414*/
1415static unsigned int dell_922x_m81_pin_configs[10] = {
1416 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1417 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1418 0x40C003f1, 0x405003f0,
1419};
1420
1421/*
1422 STAC 9221 A1 pin configs for
1423 102801D7 (Dell XPS M1210)
1424*/
1425static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001426 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1427 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001428 0x508003f3, 0x405003f4,
1429};
1430
Matt Porter403d1942005-11-29 15:00:51 +01001431static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001432 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001433 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1434 0x02a19120, 0x40000100,
1435};
1436
1437static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001438 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1439 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001440 0x02a19320, 0x40000100,
1441};
1442
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001443static unsigned int intel_mac_v1_pin_configs[10] = {
1444 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1445 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001446 0x400000fc, 0x400000fb,
1447};
1448
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001449static unsigned int intel_mac_v2_pin_configs[10] = {
1450 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1451 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001452 0x400000fc, 0x400000fb,
1453};
1454
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001455static unsigned int intel_mac_v3_pin_configs[10] = {
1456 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1457 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1458 0x400000fc, 0x400000fb,
1459};
1460
1461static unsigned int intel_mac_v4_pin_configs[10] = {
1462 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1463 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1464 0x400000fc, 0x400000fb,
1465};
1466
1467static unsigned int intel_mac_v5_pin_configs[10] = {
1468 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1469 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1470 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001471};
1472
Takashi Iwai76c08822007-06-19 12:17:42 +02001473
Takashi Iwai19039bd2006-06-28 15:52:16 +02001474static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001475 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001476 [STAC_D945GTP3] = d945gtp3_pin_configs,
1477 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001478 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1479 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1480 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1481 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1482 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001483 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001484 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1485 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1486 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1487 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1488 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1489 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001490 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1491 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1492 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1493 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001494};
1495
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001496static const char *stac922x_models[STAC_922X_MODELS] = {
1497 [STAC_D945_REF] = "ref",
1498 [STAC_D945GTP5] = "5stack",
1499 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001500 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1501 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1502 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1503 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1504 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001505 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001506 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001507 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001508 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1509 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001510 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001511 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001512 [STAC_922X_DELL_D81] = "dell-d81",
1513 [STAC_922X_DELL_D82] = "dell-d82",
1514 [STAC_922X_DELL_M81] = "dell-m81",
1515 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001516};
1517
1518static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1519 /* SigmaTel reference board */
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1521 "DFI LanParty", STAC_D945_REF),
1522 /* Intel 945G based systems */
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1524 "Intel D945G", STAC_D945GTP3),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1526 "Intel D945G", STAC_D945GTP3),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1528 "Intel D945G", STAC_D945GTP3),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1530 "Intel D945G", STAC_D945GTP3),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1532 "Intel D945G", STAC_D945GTP3),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1534 "Intel D945G", STAC_D945GTP3),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1536 "Intel D945G", STAC_D945GTP3),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1538 "Intel D945G", STAC_D945GTP3),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1540 "Intel D945G", STAC_D945GTP3),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1542 "Intel D945G", STAC_D945GTP3),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1544 "Intel D945G", STAC_D945GTP3),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1546 "Intel D945G", STAC_D945GTP3),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1548 "Intel D945G", STAC_D945GTP3),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1550 "Intel D945G", STAC_D945GTP3),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1552 "Intel D945G", STAC_D945GTP3),
1553 /* Intel D945G 5-stack systems */
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1555 "Intel D945G", STAC_D945GTP5),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1557 "Intel D945G", STAC_D945GTP5),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1559 "Intel D945G", STAC_D945GTP5),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1561 "Intel D945G", STAC_D945GTP5),
1562 /* Intel 945P based systems */
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1564 "Intel D945P", STAC_D945GTP3),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1566 "Intel D945P", STAC_D945GTP3),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1568 "Intel D945P", STAC_D945GTP3),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1570 "Intel D945P", STAC_D945GTP3),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1572 "Intel D945P", STAC_D945GTP3),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1574 "Intel D945P", STAC_D945GTP5),
1575 /* other systems */
1576 /* Apple Mac Mini (early 2006) */
1577 SND_PCI_QUIRK(0x8384, 0x7680,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001578 "Mac Mini", STAC_INTEL_MAC_V3),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001579 /* Dell systems */
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1581 "unknown Dell", STAC_922X_DELL_D81),
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1583 "unknown Dell", STAC_922X_DELL_D81),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1585 "unknown Dell", STAC_922X_DELL_D81),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1587 "unknown Dell", STAC_922X_DELL_D82),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1589 "unknown Dell", STAC_922X_DELL_M81),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1591 "unknown Dell", STAC_922X_DELL_D82),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1593 "unknown Dell", STAC_922X_DELL_D81),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1595 "unknown Dell", STAC_922X_DELL_D81),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1597 "Dell XPS M1210", STAC_922X_DELL_M82),
Matt Porter403d1942005-11-29 15:00:51 +01001598 {} /* terminator */
1599};
1600
Matt Porter3cc08dc2006-01-23 15:27:49 +01001601static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001602 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1603 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1604 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1605 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001606};
1607
Tobin Davis93ed1502006-09-01 21:03:12 +02001608static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001609 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1610 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1611 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1612 0x40000100, 0x40000100
1613};
1614
Tobin Davis93ed1502006-09-01 21:03:12 +02001615static unsigned int d965_5st_pin_configs[14] = {
1616 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1617 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1618 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1619 0x40000100, 0x40000100
1620};
1621
Tobin Davis4ff076e2007-08-07 11:48:12 +02001622static unsigned int dell_3st_pin_configs[14] = {
1623 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1624 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001625 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001626 0x40c003fc, 0x40000100
1627};
1628
Tobin Davis93ed1502006-09-01 21:03:12 +02001629static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001630 [STAC_D965_REF] = ref927x_pin_configs,
1631 [STAC_D965_3ST] = d965_3st_pin_configs,
1632 [STAC_D965_5ST] = d965_5st_pin_configs,
1633 [STAC_DELL_3ST] = dell_3st_pin_configs,
1634 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001635};
1636
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001637static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001638 [STAC_D965_REF] = "ref",
1639 [STAC_D965_3ST] = "3stack",
1640 [STAC_D965_5ST] = "5stack",
1641 [STAC_DELL_3ST] = "dell-3stack",
1642 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001643};
1644
1645static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1646 /* SigmaTel reference board */
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1648 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001649 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001652 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001653 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1660 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001669 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001670 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001672 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001674 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01001675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001677 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell ", STAC_DELL_BIOS),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02001683 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01001693 {} /* terminator */
1694};
1695
Matt Porterf3302a52006-07-31 12:49:34 +02001696static unsigned int ref9205_pin_configs[12] = {
1697 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001698 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02001699 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02001700};
1701
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001702/*
1703 STAC 9205 pin configs for
1704 102801F1
1705 102801F2
1706 102801FC
1707 102801FD
1708 10280204
1709 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001710 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001711*/
1712static unsigned int dell_9205_m42_pin_configs[12] = {
1713 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1714 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1715 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1716};
1717
1718/*
1719 STAC 9205 pin configs for
1720 102801F9
1721 102801FA
1722 102801FE
1723 102801FF (Dell Precision M4300)
1724 10280206
1725 10280200
1726 10280201
1727*/
1728static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001729 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1730 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1731 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1732};
1733
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001734static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001735 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1736 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1737 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1738};
1739
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001740static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001741 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001742 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1743 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1744 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02001745};
1746
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001747static const char *stac9205_models[STAC_9205_MODELS] = {
1748 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001749 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001750 [STAC_9205_DELL_M43] = "dell-m43",
1751 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001752};
1753
1754static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1755 /* SigmaTel reference board */
1756 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1757 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001758 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1759 "unknown Dell", STAC_9205_DELL_M42),
1760 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1761 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001762 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02001763 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001764 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1765 "Dell Precision", STAC_9205_DELL_M43),
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1767 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001768 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1769 "unknown Dell", STAC_9205_DELL_M42),
1770 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1771 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001772 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1773 "Dell Precision", STAC_9205_DELL_M43),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001775 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001776 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1777 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02001778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1779 "Dell Precision", STAC_9205_DELL_M43),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1781 "Dell Precision", STAC_9205_DELL_M43),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1783 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02001784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1785 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01001786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1787 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02001788 {} /* terminator */
1789};
1790
Richard Fish11b44bb2006-08-23 18:31:34 +02001791static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1792{
1793 int i;
1794 struct sigmatel_spec *spec = codec->spec;
1795
1796 if (! spec->bios_pin_configs) {
1797 spec->bios_pin_configs = kcalloc(spec->num_pins,
1798 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1799 if (! spec->bios_pin_configs)
1800 return -ENOMEM;
1801 }
1802
1803 for (i = 0; i < spec->num_pins; i++) {
1804 hda_nid_t nid = spec->pin_nids[i];
1805 unsigned int pin_cfg;
1806
1807 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1808 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1809 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1810 nid, pin_cfg);
1811 spec->bios_pin_configs[i] = pin_cfg;
1812 }
1813
1814 return 0;
1815}
1816
Matthew Ranostay87d48362007-07-17 11:52:24 +02001817static void stac92xx_set_config_reg(struct hda_codec *codec,
1818 hda_nid_t pin_nid, unsigned int pin_config)
1819{
1820 int i;
1821 snd_hda_codec_write(codec, pin_nid, 0,
1822 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1823 pin_config & 0x000000ff);
1824 snd_hda_codec_write(codec, pin_nid, 0,
1825 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1826 (pin_config & 0x0000ff00) >> 8);
1827 snd_hda_codec_write(codec, pin_nid, 0,
1828 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1829 (pin_config & 0x00ff0000) >> 16);
1830 snd_hda_codec_write(codec, pin_nid, 0,
1831 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1832 pin_config >> 24);
1833 i = snd_hda_codec_read(codec, pin_nid, 0,
1834 AC_VERB_GET_CONFIG_DEFAULT,
1835 0x00);
1836 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1837 pin_nid, i);
1838}
1839
Matt2f2f4252005-04-13 14:45:30 +02001840static void stac92xx_set_config_regs(struct hda_codec *codec)
1841{
1842 int i;
1843 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02001844
Matthew Ranostay87d48362007-07-17 11:52:24 +02001845 if (!spec->pin_configs)
1846 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02001847
Matthew Ranostay87d48362007-07-17 11:52:24 +02001848 for (i = 0; i < spec->num_pins; i++)
1849 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1850 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02001851}
Matt2f2f4252005-04-13 14:45:30 +02001852
Matt2f2f4252005-04-13 14:45:30 +02001853/*
1854 * Analog playback callbacks
1855 */
1856static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1857 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001858 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001859{
1860 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01001861 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1862 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02001863}
1864
1865static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1866 struct hda_codec *codec,
1867 unsigned int stream_tag,
1868 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001869 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001870{
1871 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01001872 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02001873}
1874
1875static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1876 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001877 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001878{
1879 struct sigmatel_spec *spec = codec->spec;
1880 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1881}
1882
1883/*
Mattdabbed62005-06-14 10:19:34 +02001884 * Digital playback callbacks
1885 */
1886static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1887 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001888 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02001889{
1890 struct sigmatel_spec *spec = codec->spec;
1891 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1892}
1893
1894static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1895 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001896 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02001897{
1898 struct sigmatel_spec *spec = codec->spec;
1899 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1900}
1901
Takashi Iwai6b97eb42007-04-05 14:51:48 +02001902static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1903 struct hda_codec *codec,
1904 unsigned int stream_tag,
1905 unsigned int format,
1906 struct snd_pcm_substream *substream)
1907{
1908 struct sigmatel_spec *spec = codec->spec;
1909 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1910 stream_tag, format, substream);
1911}
1912
Mattdabbed62005-06-14 10:19:34 +02001913
1914/*
Matt2f2f4252005-04-13 14:45:30 +02001915 * Analog capture callbacks
1916 */
1917static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1918 struct hda_codec *codec,
1919 unsigned int stream_tag,
1920 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001921 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001922{
1923 struct sigmatel_spec *spec = codec->spec;
1924
1925 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1926 stream_tag, 0, format);
1927 return 0;
1928}
1929
1930static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1931 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001932 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02001933{
1934 struct sigmatel_spec *spec = codec->spec;
1935
Takashi Iwai888afa12008-03-18 09:57:50 +01001936 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
Matt2f2f4252005-04-13 14:45:30 +02001937 return 0;
1938}
1939
Mattdabbed62005-06-14 10:19:34 +02001940static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1941 .substreams = 1,
1942 .channels_min = 2,
1943 .channels_max = 2,
1944 /* NID is set in stac92xx_build_pcms */
1945 .ops = {
1946 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02001947 .close = stac92xx_dig_playback_pcm_close,
1948 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02001949 },
1950};
1951
1952static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1953 .substreams = 1,
1954 .channels_min = 2,
1955 .channels_max = 2,
1956 /* NID is set in stac92xx_build_pcms */
1957};
1958
Matt2f2f4252005-04-13 14:45:30 +02001959static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1960 .substreams = 1,
1961 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02001962 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02001963 .nid = 0x02, /* NID to query formats and rates */
1964 .ops = {
1965 .open = stac92xx_playback_pcm_open,
1966 .prepare = stac92xx_playback_pcm_prepare,
1967 .cleanup = stac92xx_playback_pcm_cleanup
1968 },
1969};
1970
Matt Porter3cc08dc2006-01-23 15:27:49 +01001971static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1972 .substreams = 1,
1973 .channels_min = 2,
1974 .channels_max = 2,
1975 .nid = 0x06, /* NID to query formats and rates */
1976 .ops = {
1977 .open = stac92xx_playback_pcm_open,
1978 .prepare = stac92xx_playback_pcm_prepare,
1979 .cleanup = stac92xx_playback_pcm_cleanup
1980 },
1981};
1982
Matt2f2f4252005-04-13 14:45:30 +02001983static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02001984 .channels_min = 2,
1985 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001986 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02001987 .ops = {
1988 .prepare = stac92xx_capture_pcm_prepare,
1989 .cleanup = stac92xx_capture_pcm_cleanup
1990 },
1991};
1992
1993static int stac92xx_build_pcms(struct hda_codec *codec)
1994{
1995 struct sigmatel_spec *spec = codec->spec;
1996 struct hda_pcm *info = spec->pcm_rec;
1997
1998 codec->num_pcms = 1;
1999 codec->pcm_info = info;
2000
Mattc7d4b2f2005-06-27 14:59:41 +02002001 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002002 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002003 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002004 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002005 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002006
2007 if (spec->alt_switch) {
2008 codec->num_pcms++;
2009 info++;
2010 info->name = "STAC92xx Analog Alt";
2011 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2012 }
Matt2f2f4252005-04-13 14:45:30 +02002013
Mattdabbed62005-06-14 10:19:34 +02002014 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2015 codec->num_pcms++;
2016 info++;
2017 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002018 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002019 if (spec->multiout.dig_out_nid) {
2020 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2021 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2022 }
2023 if (spec->dig_in_nid) {
2024 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2025 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2026 }
2027 }
2028
Matt2f2f4252005-04-13 14:45:30 +02002029 return 0;
2030}
2031
Takashi Iwaic960a032006-03-23 17:06:28 +01002032static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2033{
2034 unsigned int pincap = snd_hda_param_read(codec, nid,
2035 AC_PAR_PIN_CAP);
2036 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2037 if (pincap & AC_PINCAP_VREF_100)
2038 return AC_PINCTL_VREF_100;
2039 if (pincap & AC_PINCAP_VREF_80)
2040 return AC_PINCTL_VREF_80;
2041 if (pincap & AC_PINCAP_VREF_50)
2042 return AC_PINCTL_VREF_50;
2043 if (pincap & AC_PINCAP_VREF_GRD)
2044 return AC_PINCTL_VREF_GRD;
2045 return 0;
2046}
2047
Matt Porter403d1942005-11-29 15:00:51 +01002048static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2049
2050{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002051 snd_hda_codec_write_cache(codec, nid, 0,
2052 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002053}
2054
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002055#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2056
2057static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2058 struct snd_ctl_elem_value *ucontrol)
2059{
2060 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2061 struct sigmatel_spec *spec = codec->spec;
2062
2063 ucontrol->value.integer.value[0] = spec->hp_switch;
2064 return 0;
2065}
2066
2067static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2068 struct snd_ctl_elem_value *ucontrol)
2069{
2070 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2071 struct sigmatel_spec *spec = codec->spec;
2072
2073 spec->hp_switch = ucontrol->value.integer.value[0];
2074
2075 /* check to be sure that the ports are upto date with
2076 * switch changes
2077 */
2078 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2079
2080 return 1;
2081}
2082
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002083#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002084
2085static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2086{
2087 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2088 struct sigmatel_spec *spec = codec->spec;
2089 int io_idx = kcontrol-> private_value & 0xff;
2090
2091 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2092 return 0;
2093}
2094
2095static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2096{
2097 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2098 struct sigmatel_spec *spec = codec->spec;
2099 hda_nid_t nid = kcontrol->private_value >> 8;
2100 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002101 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002102
2103 spec->io_switch[io_idx] = val;
2104
2105 if (val)
2106 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002107 else {
2108 unsigned int pinctl = AC_PINCTL_IN_EN;
2109 if (io_idx) /* set VREF for mic */
2110 pinctl |= stac92xx_get_vref(codec, nid);
2111 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2112 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002113
2114 /* check the auto-mute again: we need to mute/unmute the speaker
2115 * appropriately according to the pin direction
2116 */
2117 if (spec->hp_detect)
2118 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2119
Matt Porter403d1942005-11-29 15:00:51 +01002120 return 1;
2121}
2122
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002123#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2124
2125static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2126 struct snd_ctl_elem_value *ucontrol)
2127{
2128 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2129 struct sigmatel_spec *spec = codec->spec;
2130
2131 ucontrol->value.integer.value[0] = spec->clfe_swap;
2132 return 0;
2133}
2134
2135static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2136 struct snd_ctl_elem_value *ucontrol)
2137{
2138 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2139 struct sigmatel_spec *spec = codec->spec;
2140 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002141 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002142
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002143 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002144 return 0;
2145
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002146 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002147
2148 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2149 spec->clfe_swap ? 0x4 : 0x0);
2150
2151 return 1;
2152}
2153
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002154#define STAC_CODEC_HP_SWITCH(xname) \
2155 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2156 .name = xname, \
2157 .index = 0, \
2158 .info = stac92xx_hp_switch_info, \
2159 .get = stac92xx_hp_switch_get, \
2160 .put = stac92xx_hp_switch_put, \
2161 }
2162
Matt Porter403d1942005-11-29 15:00:51 +01002163#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2164 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2165 .name = xname, \
2166 .index = 0, \
2167 .info = stac92xx_io_switch_info, \
2168 .get = stac92xx_io_switch_get, \
2169 .put = stac92xx_io_switch_put, \
2170 .private_value = xpval, \
2171 }
2172
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002173#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2174 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2175 .name = xname, \
2176 .index = 0, \
2177 .info = stac92xx_clfe_switch_info, \
2178 .get = stac92xx_clfe_switch_get, \
2179 .put = stac92xx_clfe_switch_put, \
2180 .private_value = xpval, \
2181 }
Matt Porter403d1942005-11-29 15:00:51 +01002182
Mattc7d4b2f2005-06-27 14:59:41 +02002183enum {
2184 STAC_CTL_WIDGET_VOL,
2185 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002186 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002187 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002188 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002189 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002190};
2191
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002192static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002193 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2194 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002195 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002196 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002197 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002198 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002199};
2200
2201/* add dynamic controls */
2202static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2203{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002204 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002205
2206 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2207 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2208
2209 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2210 if (! knew)
2211 return -ENOMEM;
2212 if (spec->kctl_alloc) {
2213 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2214 kfree(spec->kctl_alloc);
2215 }
2216 spec->kctl_alloc = knew;
2217 spec->num_kctl_alloc = num;
2218 }
2219
2220 knew = &spec->kctl_alloc[spec->num_kctl_used];
2221 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002222 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002223 if (! knew->name)
2224 return -ENOMEM;
2225 knew->private_value = val;
2226 spec->num_kctl_used++;
2227 return 0;
2228}
2229
Matt Porter403d1942005-11-29 15:00:51 +01002230/* flag inputs as additional dynamic lineouts */
2231static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2232{
2233 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002234 unsigned int wcaps, wtype;
2235 int i, num_dacs = 0;
2236
2237 /* use the wcaps cache to count all DACs available for line-outs */
2238 for (i = 0; i < codec->num_nodes; i++) {
2239 wcaps = codec->wcaps[i];
2240 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002241
Steve Longerbeam7b043892007-05-03 20:50:03 +02002242 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2243 num_dacs++;
2244 }
Matt Porter403d1942005-11-29 15:00:51 +01002245
Steve Longerbeam7b043892007-05-03 20:50:03 +02002246 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2247
Matt Porter403d1942005-11-29 15:00:51 +01002248 switch (cfg->line_outs) {
2249 case 3:
2250 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002251 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002252 cfg->line_out_pins[cfg->line_outs] =
2253 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002254 spec->line_switch = 1;
2255 cfg->line_outs++;
2256 }
2257 break;
2258 case 2:
2259 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002260 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002261 cfg->line_out_pins[cfg->line_outs] =
2262 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002263 spec->line_switch = 1;
2264 cfg->line_outs++;
2265 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002266 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002267 cfg->line_out_pins[cfg->line_outs] =
2268 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002269 spec->mic_switch = 1;
2270 cfg->line_outs++;
2271 }
2272 break;
2273 case 1:
2274 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002275 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002276 cfg->line_out_pins[cfg->line_outs] =
2277 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002278 spec->line_switch = 1;
2279 cfg->line_outs++;
2280 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002281 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002282 cfg->line_out_pins[cfg->line_outs] =
2283 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002284 spec->mic_switch = 1;
2285 cfg->line_outs++;
2286 }
2287 break;
2288 }
2289
2290 return 0;
2291}
2292
Steve Longerbeam7b043892007-05-03 20:50:03 +02002293
2294static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2295{
2296 int i;
2297
2298 for (i = 0; i < spec->multiout.num_dacs; i++) {
2299 if (spec->multiout.dac_nids[i] == nid)
2300 return 1;
2301 }
2302
2303 return 0;
2304}
2305
Matt Porter3cc08dc2006-01-23 15:27:49 +01002306/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002307 * Fill in the dac_nids table from the parsed pin configuration
2308 * This function only works when every pin in line_out_pins[]
2309 * contains atleast one DAC in its connection list. Some 92xx
2310 * codecs are not connected directly to a DAC, such as the 9200
2311 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002312 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002313static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002314 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002315{
2316 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002317 int i, j, conn_len = 0;
2318 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2319 unsigned int wcaps, wtype;
2320
Mattc7d4b2f2005-06-27 14:59:41 +02002321 for (i = 0; i < cfg->line_outs; i++) {
2322 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002323 conn_len = snd_hda_get_connections(codec, nid, conn,
2324 HDA_MAX_CONNECTIONS);
2325 for (j = 0; j < conn_len; j++) {
2326 wcaps = snd_hda_param_read(codec, conn[j],
2327 AC_PAR_AUDIO_WIDGET_CAP);
2328 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002329 if (wtype != AC_WID_AUD_OUT ||
2330 (wcaps & AC_WCAP_DIGITAL))
2331 continue;
2332 /* conn[j] is a DAC routed to this line-out */
2333 if (!is_in_dac_nids(spec, conn[j]))
2334 break;
2335 }
2336
2337 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002338 if (spec->multiout.num_dacs > 0) {
2339 /* we have already working output pins,
2340 * so let's drop the broken ones again
2341 */
2342 cfg->line_outs = spec->multiout.num_dacs;
2343 break;
2344 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002345 /* error out, no available DAC found */
2346 snd_printk(KERN_ERR
2347 "%s: No available DAC for pin 0x%x\n",
2348 __func__, nid);
2349 return -ENODEV;
2350 }
2351
2352 spec->multiout.dac_nids[i] = conn[j];
2353 spec->multiout.num_dacs++;
2354 if (conn_len > 1) {
2355 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002356 snd_hda_codec_write_cache(codec, nid, 0,
2357 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002358
2359 }
Mattc7d4b2f2005-06-27 14:59:41 +02002360 }
2361
Steve Longerbeam7b043892007-05-03 20:50:03 +02002362 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2363 spec->multiout.num_dacs,
2364 spec->multiout.dac_nids[0],
2365 spec->multiout.dac_nids[1],
2366 spec->multiout.dac_nids[2],
2367 spec->multiout.dac_nids[3],
2368 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002369 return 0;
2370}
2371
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002372/* create volume control/switch for the given prefx type */
2373static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2374{
2375 char name[32];
2376 int err;
2377
2378 sprintf(name, "%s Playback Volume", pfx);
2379 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2380 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2381 if (err < 0)
2382 return err;
2383 sprintf(name, "%s Playback Switch", pfx);
2384 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2385 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2386 if (err < 0)
2387 return err;
2388 return 0;
2389}
2390
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002391static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2392{
2393 if (!spec->multiout.hp_nid)
2394 spec->multiout.hp_nid = nid;
2395 else if (spec->multiout.num_dacs > 4) {
2396 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2397 return 1;
2398 } else {
2399 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2400 spec->multiout.num_dacs++;
2401 }
2402 return 0;
2403}
2404
2405static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2406{
2407 if (is_in_dac_nids(spec, nid))
2408 return 1;
2409 if (spec->multiout.hp_nid == nid)
2410 return 1;
2411 return 0;
2412}
2413
Mattc7d4b2f2005-06-27 14:59:41 +02002414/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002415static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002416 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002417{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002418 static const char *chname[4] = {
2419 "Front", "Surround", NULL /*CLFE*/, "Side"
2420 };
Mattc7d4b2f2005-06-27 14:59:41 +02002421 hda_nid_t nid;
2422 int i, err;
2423
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002424 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002425 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002426
2427
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002428 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002429 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002430 continue;
2431
2432 nid = spec->multiout.dac_nids[i];
2433
2434 if (i == 2) {
2435 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002436 err = create_controls(spec, "Center", nid, 1);
2437 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002438 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002439 err = create_controls(spec, "LFE", nid, 2);
2440 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002441 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002442
2443 wid_caps = get_wcaps(codec, nid);
2444
2445 if (wid_caps & AC_WCAP_LR_SWAP) {
2446 err = stac92xx_add_control(spec,
2447 STAC_CTL_WIDGET_CLFE_SWITCH,
2448 "Swap Center/LFE Playback Switch", nid);
2449
2450 if (err < 0)
2451 return err;
2452 }
2453
Mattc7d4b2f2005-06-27 14:59:41 +02002454 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002455 err = create_controls(spec, chname[i], nid, 3);
2456 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002457 return err;
2458 }
2459 }
2460
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002461 if (cfg->hp_outs > 1) {
2462 err = stac92xx_add_control(spec,
2463 STAC_CTL_WIDGET_HP_SWITCH,
2464 "Headphone as Line Out Switch", 0);
2465 if (err < 0)
2466 return err;
2467 }
2468
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002469 if (spec->line_switch) {
2470 nid = cfg->input_pins[AUTO_PIN_LINE];
2471 pincap = snd_hda_param_read(codec, nid,
2472 AC_PAR_PIN_CAP);
2473 if (pincap & AC_PINCAP_OUT) {
2474 err = stac92xx_add_control(spec,
2475 STAC_CTL_WIDGET_IO_SWITCH,
2476 "Line In as Output Switch", nid << 8);
2477 if (err < 0)
2478 return err;
2479 }
2480 }
Matt Porter403d1942005-11-29 15:00:51 +01002481
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002482 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002483 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002484 unsigned int mic_pin = AUTO_PIN_MIC;
2485again:
2486 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002487 def_conf = snd_hda_codec_read(codec, nid, 0,
2488 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002489 /* some laptops have an internal analog microphone
2490 * which can't be used as a output */
2491 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2492 pincap = snd_hda_param_read(codec, nid,
2493 AC_PAR_PIN_CAP);
2494 if (pincap & AC_PINCAP_OUT) {
2495 err = stac92xx_add_control(spec,
2496 STAC_CTL_WIDGET_IO_SWITCH,
2497 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002498 nid = snd_hda_codec_read(codec, nid, 0,
2499 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2500 if (!check_in_dac_nids(spec, nid))
2501 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002502 if (err < 0)
2503 return err;
2504 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002505 } else if (mic_pin == AUTO_PIN_MIC) {
2506 mic_pin = AUTO_PIN_FRONT_MIC;
2507 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002508 }
2509 }
Matt Porter403d1942005-11-29 15:00:51 +01002510
Mattc7d4b2f2005-06-27 14:59:41 +02002511 return 0;
2512}
2513
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002514/* add playback controls for Speaker and HP outputs */
2515static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2516 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002517{
2518 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002519 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002520 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002521
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002522 old_num_dacs = spec->multiout.num_dacs;
2523 for (i = 0; i < cfg->hp_outs; i++) {
2524 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2525 if (wid_caps & AC_WCAP_UNSOL_CAP)
2526 spec->hp_detect = 1;
2527 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2528 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2529 if (check_in_dac_nids(spec, nid))
2530 nid = 0;
2531 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002532 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002533 add_spec_dacs(spec, nid);
2534 }
2535 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002536 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002537 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2538 if (check_in_dac_nids(spec, nid))
2539 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002540 if (! nid)
2541 continue;
2542 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002543 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002544 for (i = 0; i < cfg->line_outs; i++) {
2545 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2546 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2547 if (check_in_dac_nids(spec, nid))
2548 nid = 0;
2549 if (! nid)
2550 continue;
2551 add_spec_dacs(spec, nid);
2552 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002553 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2554 static const char *pfxs[] = {
2555 "Speaker", "External Speaker", "Speaker2",
2556 };
2557 err = create_controls(spec, pfxs[i - old_num_dacs],
2558 spec->multiout.dac_nids[i], 3);
2559 if (err < 0)
2560 return err;
2561 }
2562 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002563 err = create_controls(spec, "Headphone",
2564 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002565 if (err < 0)
2566 return err;
2567 }
Mattc7d4b2f2005-06-27 14:59:41 +02002568
2569 return 0;
2570}
2571
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002572/* labels for mono mux outputs */
2573static const char *stac92xx_mono_labels[3] = {
2574 "DAC0", "DAC1", "Mixer"
2575};
2576
2577/* create mono mux for mono out on capable codecs */
2578static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2579{
2580 struct sigmatel_spec *spec = codec->spec;
2581 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2582 int i, num_cons;
2583 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2584
2585 num_cons = snd_hda_get_connections(codec,
2586 spec->mono_nid,
2587 con_lst,
2588 HDA_MAX_NUM_INPUTS);
2589 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2590 return -EINVAL;
2591
2592 for (i = 0; i < num_cons; i++) {
2593 mono_mux->items[mono_mux->num_items].label =
2594 stac92xx_mono_labels[i];
2595 mono_mux->items[mono_mux->num_items].index = i;
2596 mono_mux->num_items++;
2597 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002598
2599 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2600 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002601}
2602
Matt Porter8b657272006-10-26 17:12:59 +02002603/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01002604static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02002605 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2606 "Digital Mic 3", "Digital Mic 4"
2607};
2608
2609/* create playback/capture controls for input pins on dmic capable codecs */
2610static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2611 const struct auto_pin_cfg *cfg)
2612{
2613 struct sigmatel_spec *spec = codec->spec;
2614 struct hda_input_mux *dimux = &spec->private_dimux;
2615 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002616 int err, i, j;
2617 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02002618
2619 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2620 dimux->items[dimux->num_items].index = 0;
2621 dimux->num_items++;
2622
2623 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002624 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02002625 int index;
2626 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002627 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02002628 unsigned int def_conf;
2629
2630 def_conf = snd_hda_codec_read(codec,
2631 spec->dmic_nids[i],
2632 0,
2633 AC_VERB_GET_CONFIG_DEFAULT,
2634 0);
2635 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2636 continue;
2637
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002638 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02002639 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002640 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02002641 con_lst,
2642 HDA_MAX_NUM_INPUTS);
2643 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002644 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02002645 index = j;
2646 goto found;
2647 }
2648 continue;
2649found:
Matthew Ranostay0678acc2008-01-08 12:10:50 +01002650 wcaps = get_wcaps(codec, nid);
2651
2652 if (wcaps & AC_WCAP_OUT_AMP) {
2653 sprintf(name, "%s Capture Volume",
2654 stac92xx_dmic_labels[dimux->num_items]);
2655
2656 err = stac92xx_add_control(spec,
2657 STAC_CTL_WIDGET_VOL,
2658 name,
2659 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2660 if (err < 0)
2661 return err;
2662 }
2663
Matt Porter8b657272006-10-26 17:12:59 +02002664 dimux->items[dimux->num_items].label =
2665 stac92xx_dmic_labels[dimux->num_items];
2666 dimux->items[dimux->num_items].index = index;
2667 dimux->num_items++;
2668 }
2669
2670 return 0;
2671}
2672
Mattc7d4b2f2005-06-27 14:59:41 +02002673/* create playback/capture controls for input pins */
2674static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2675{
2676 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002677 struct hda_input_mux *imux = &spec->private_imux;
2678 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2679 int i, j, k;
2680
2681 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02002682 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02002683
Takashi Iwai314634b2006-09-21 11:56:18 +02002684 if (!cfg->input_pins[i])
2685 continue;
2686 index = -1;
2687 for (j = 0; j < spec->num_muxes; j++) {
2688 int num_cons;
2689 num_cons = snd_hda_get_connections(codec,
2690 spec->mux_nids[j],
2691 con_lst,
2692 HDA_MAX_NUM_INPUTS);
2693 for (k = 0; k < num_cons; k++)
2694 if (con_lst[k] == cfg->input_pins[i]) {
2695 index = k;
2696 goto found;
2697 }
Mattc7d4b2f2005-06-27 14:59:41 +02002698 }
Takashi Iwai314634b2006-09-21 11:56:18 +02002699 continue;
2700 found:
2701 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2702 imux->items[imux->num_items].index = index;
2703 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02002704 }
2705
Steve Longerbeam7b043892007-05-03 20:50:03 +02002706 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02002707 /*
2708 * Set the current input for the muxes.
2709 * The STAC9221 has two input muxes with identical source
2710 * NID lists. Hopefully this won't get confused.
2711 */
2712 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002713 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2714 AC_VERB_SET_CONNECT_SEL,
2715 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02002716 }
2717 }
2718
Mattc7d4b2f2005-06-27 14:59:41 +02002719 return 0;
2720}
2721
Mattc7d4b2f2005-06-27 14:59:41 +02002722static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2723{
2724 struct sigmatel_spec *spec = codec->spec;
2725 int i;
2726
2727 for (i = 0; i < spec->autocfg.line_outs; i++) {
2728 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2729 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2730 }
2731}
2732
2733static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2734{
2735 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002736 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02002737
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002738 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2739 hda_nid_t pin;
2740 pin = spec->autocfg.hp_pins[i];
2741 if (pin) /* connect to front */
2742 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2743 }
2744 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2745 hda_nid_t pin;
2746 pin = spec->autocfg.speaker_pins[i];
2747 if (pin) /* connect to front */
2748 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2749 }
Mattc7d4b2f2005-06-27 14:59:41 +02002750}
2751
Matt Porter3cc08dc2006-01-23 15:27:49 +01002752static 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 +02002753{
2754 struct sigmatel_spec *spec = codec->spec;
2755 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002756 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002757
Matt Porter8b657272006-10-26 17:12:59 +02002758 if ((err = snd_hda_parse_pin_def_config(codec,
2759 &spec->autocfg,
2760 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002761 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002762 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01002763 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002764
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002765 /* If we have no real line-out pin and multiple hp-outs, HPs should
2766 * be set up as multi-channel outputs.
2767 */
2768 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2769 spec->autocfg.hp_outs > 1) {
2770 /* Copy hp_outs to line_outs, backup line_outs in
2771 * speaker_outs so that the following routines can handle
2772 * HP pins as primary outputs.
2773 */
2774 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2775 sizeof(spec->autocfg.line_out_pins));
2776 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2777 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2778 sizeof(spec->autocfg.hp_pins));
2779 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2780 hp_speaker_swap = 1;
2781 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002782 if (spec->autocfg.mono_out_pin) {
2783 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2784 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2785 u32 caps = query_amp_caps(codec,
2786 spec->autocfg.mono_out_pin, dir);
2787 hda_nid_t conn_list[1];
2788
2789 /* get the mixer node and then the mono mux if it exists */
2790 if (snd_hda_get_connections(codec,
2791 spec->autocfg.mono_out_pin, conn_list, 1) &&
2792 snd_hda_get_connections(codec, conn_list[0],
2793 conn_list, 1)) {
2794
2795 int wcaps = get_wcaps(codec, conn_list[0]);
2796 int wid_type = (wcaps & AC_WCAP_TYPE)
2797 >> AC_WCAP_TYPE_SHIFT;
2798 /* LR swap check, some stac925x have a mux that
2799 * changes the DACs output path instead of the
2800 * mono-mux path.
2801 */
2802 if (wid_type == AC_WID_AUD_SEL &&
2803 !(wcaps & AC_WCAP_LR_SWAP))
2804 spec->mono_nid = conn_list[0];
2805 }
2806 /* all mono outs have a least a mute/unmute switch */
2807 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2808 "Mono Playback Switch",
2809 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2810 1, 0, dir));
2811 if (err < 0)
2812 return err;
2813 /* check to see if there is volume support for the amp */
2814 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2815 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2816 "Mono Playback Volume",
2817 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2818 1, 0, dir));
2819 if (err < 0)
2820 return err;
2821 }
2822
2823 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2824 AC_PINCTL_OUT_EN);
2825 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002826
Matt Porter403d1942005-11-29 15:00:51 +01002827 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2828 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02002829 if (spec->multiout.num_dacs == 0)
2830 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2831 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02002832
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002833 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2834
2835 if (err < 0)
2836 return err;
2837
Jiang Zhebcecd9b2007-11-12 12:57:03 +01002838 if (hp_speaker_swap == 1) {
2839 /* Restore the hp_outs and line_outs */
2840 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2841 sizeof(spec->autocfg.line_out_pins));
2842 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2843 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2844 sizeof(spec->autocfg.speaker_pins));
2845 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2846 memset(spec->autocfg.speaker_pins, 0,
2847 sizeof(spec->autocfg.speaker_pins));
2848 spec->autocfg.speaker_outs = 0;
2849 }
2850
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002851 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2852
2853 if (err < 0)
2854 return err;
2855
2856 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2857
2858 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002859 return err;
2860
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002861 if (spec->mono_nid > 0) {
2862 err = stac92xx_auto_create_mono_output_ctls(codec);
2863 if (err < 0)
2864 return err;
2865 }
2866
Matt Porter8b657272006-10-26 17:12:59 +02002867 if (spec->num_dmics > 0)
2868 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2869 &spec->autocfg)) < 0)
2870 return err;
2871
Mattc7d4b2f2005-06-27 14:59:41 +02002872 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01002873 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02002874 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02002875
Takashi Iwai82bc9552006-03-21 11:24:42 +01002876 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01002877 spec->multiout.dig_out_nid = dig_out;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002878 if (spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01002879 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02002880
2881 if (spec->kctl_alloc)
2882 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2883
2884 spec->input_mux = &spec->private_imux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01002885 if (!spec->dinput_mux)
2886 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002887 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02002888
2889 return 1;
2890}
2891
Takashi Iwai82bc9552006-03-21 11:24:42 +01002892/* add playback controls for HP output */
2893static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2894 struct auto_pin_cfg *cfg)
2895{
2896 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002897 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01002898 unsigned int wid_caps;
2899
2900 if (! pin)
2901 return 0;
2902
2903 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02002904 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01002905 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002906
2907 return 0;
2908}
2909
Richard Fish160ea0d2006-09-06 13:58:25 +02002910/* add playback controls for LFE output */
2911static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2912 struct auto_pin_cfg *cfg)
2913{
2914 struct sigmatel_spec *spec = codec->spec;
2915 int err;
2916 hda_nid_t lfe_pin = 0x0;
2917 int i;
2918
2919 /*
2920 * search speaker outs and line outs for a mono speaker pin
2921 * with an amp. If one is found, add LFE controls
2922 * for it.
2923 */
2924 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2925 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01002926 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02002927 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2928 if (wcaps == AC_WCAP_OUT_AMP)
2929 /* found a mono speaker with an amp, must be lfe */
2930 lfe_pin = pin;
2931 }
2932
2933 /* if speaker_outs is 0, then speakers may be in line_outs */
2934 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2935 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2936 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01002937 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01002938 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02002939 AC_VERB_GET_CONFIG_DEFAULT,
2940 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01002941 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01002942 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02002943 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2944 if (wcaps == AC_WCAP_OUT_AMP)
2945 /* found a mono speaker with an amp,
2946 must be lfe */
2947 lfe_pin = pin;
2948 }
2949 }
2950 }
2951
2952 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002953 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02002954 if (err < 0)
2955 return err;
2956 }
2957
2958 return 0;
2959}
2960
Mattc7d4b2f2005-06-27 14:59:41 +02002961static int stac9200_parse_auto_config(struct hda_codec *codec)
2962{
2963 struct sigmatel_spec *spec = codec->spec;
2964 int err;
2965
Kailang Yangdf694da2005-12-05 19:42:22 +01002966 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002967 return err;
2968
2969 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2970 return err;
2971
Takashi Iwai82bc9552006-03-21 11:24:42 +01002972 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2973 return err;
2974
Richard Fish160ea0d2006-09-06 13:58:25 +02002975 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2976 return err;
2977
Takashi Iwai82bc9552006-03-21 11:24:42 +01002978 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02002979 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002980 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02002981 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02002982
2983 if (spec->kctl_alloc)
2984 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2985
2986 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02002987 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02002988
2989 return 1;
2990}
2991
Sam Revitch62fe78e2006-05-10 15:09:17 +02002992/*
2993 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2994 * funky external mute control using GPIO pins.
2995 */
2996
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01002997static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01002998 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02002999{
3000 unsigned int gpiostate, gpiomask, gpiodir;
3001
3002 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3003 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003004 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003005
3006 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3007 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003008 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003009
3010 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3011 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003012 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003013
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003014 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003015 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3016
3017 snd_hda_codec_write(codec, codec->afg, 0,
3018 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003019 snd_hda_codec_read(codec, codec->afg, 0,
3020 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003021
3022 msleep(1);
3023
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003024 snd_hda_codec_read(codec, codec->afg, 0,
3025 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003026}
3027
Takashi Iwai314634b2006-09-21 11:56:18 +02003028static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3029 unsigned int event)
3030{
3031 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003032 snd_hda_codec_write_cache(codec, nid, 0,
3033 AC_VERB_SET_UNSOLICITED_ENABLE,
3034 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003035}
3036
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003037static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3038{
3039 int i;
3040 for (i = 0; i < cfg->hp_outs; i++)
3041 if (cfg->hp_pins[i] == nid)
3042 return 1; /* nid is a HP-Out */
3043
3044 return 0; /* nid is not a HP-Out */
3045};
3046
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003047static void stac92xx_power_down(struct hda_codec *codec)
3048{
3049 struct sigmatel_spec *spec = codec->spec;
3050
3051 /* power down inactive DACs */
3052 hda_nid_t *dac;
3053 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003054 if (!is_in_dac_nids(spec, *dac) &&
3055 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003056 snd_hda_codec_write_cache(codec, *dac, 0,
3057 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3058}
3059
Mattc7d4b2f2005-06-27 14:59:41 +02003060static int stac92xx_init(struct hda_codec *codec)
3061{
3062 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003063 struct auto_pin_cfg *cfg = &spec->autocfg;
3064 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003065
Mattc7d4b2f2005-06-27 14:59:41 +02003066 snd_hda_sequence_write(codec, spec->init);
3067
Takashi Iwai82bc9552006-03-21 11:24:42 +01003068 /* set up pins */
3069 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003070 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003071 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003072 enable_pin_detect(codec, cfg->hp_pins[i],
3073 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003074 /* force to enable the first line-out; the others are set up
3075 * in unsol_event
3076 */
3077 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3078 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003079 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003080 /* fake event to set up pins */
3081 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3082 } else {
3083 stac92xx_auto_init_multi_out(codec);
3084 stac92xx_auto_init_hp_out(codec);
3085 }
3086 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003087 hda_nid_t nid = cfg->input_pins[i];
3088 if (nid) {
3089 unsigned int pinctl = AC_PINCTL_IN_EN;
3090 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3091 pinctl |= stac92xx_get_vref(codec, nid);
3092 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3093 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003094 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003095 for (i = 0; i < spec->num_dmics; i++)
3096 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3097 AC_PINCTL_IN_EN);
3098 for (i = 0; i < spec->num_pwrs; i++) {
3099 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3100 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3101 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3102 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003103 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3104 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003105 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003106 /* outputs are only ports capable of power management
3107 * any attempts on powering down a input port cause the
3108 * referenced VREF to act quirky.
3109 */
3110 if (pinctl & AC_PINCTL_IN_EN)
3111 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003112 /* skip any ports that don't have jacks since presence
3113 * detection is useless */
3114 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003115 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003116 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3117 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3118 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003119 if (spec->dac_list)
3120 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003121 if (cfg->dig_out_pin)
3122 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3123 AC_PINCTL_OUT_EN);
3124 if (cfg->dig_in_pin)
3125 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3126 AC_PINCTL_IN_EN);
3127
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003128 stac_gpio_set(codec, spec->gpio_mask,
3129 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003130
Mattc7d4b2f2005-06-27 14:59:41 +02003131 return 0;
3132}
3133
Matt2f2f4252005-04-13 14:45:30 +02003134static void stac92xx_free(struct hda_codec *codec)
3135{
Mattc7d4b2f2005-06-27 14:59:41 +02003136 struct sigmatel_spec *spec = codec->spec;
3137 int i;
3138
3139 if (! spec)
3140 return;
3141
3142 if (spec->kctl_alloc) {
3143 for (i = 0; i < spec->num_kctl_used; i++)
3144 kfree(spec->kctl_alloc[i].name);
3145 kfree(spec->kctl_alloc);
3146 }
3147
Richard Fish11b44bb2006-08-23 18:31:34 +02003148 if (spec->bios_pin_configs)
3149 kfree(spec->bios_pin_configs);
3150
Mattc7d4b2f2005-06-27 14:59:41 +02003151 kfree(spec);
Matt2f2f4252005-04-13 14:45:30 +02003152}
3153
Matt4e550962005-07-04 17:51:39 +02003154static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3155 unsigned int flag)
3156{
3157 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3158 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003159
Takashi Iwaif9acba42007-05-29 18:01:06 +02003160 if (pin_ctl & AC_PINCTL_IN_EN) {
3161 /*
3162 * we need to check the current set-up direction of
3163 * shared input pins since they can be switched via
3164 * "xxx as Output" mixer switch
3165 */
3166 struct sigmatel_spec *spec = codec->spec;
3167 struct auto_pin_cfg *cfg = &spec->autocfg;
3168 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3169 spec->line_switch) ||
3170 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3171 spec->mic_switch))
3172 return;
3173 }
3174
Steve Longerbeam7b043892007-05-03 20:50:03 +02003175 /* if setting pin direction bits, clear the current
3176 direction bits first */
3177 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3178 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3179
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003180 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003181 AC_VERB_SET_PIN_WIDGET_CONTROL,
3182 pin_ctl | flag);
3183}
3184
3185static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3186 unsigned int flag)
3187{
3188 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3189 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003190 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003191 AC_VERB_SET_PIN_WIDGET_CONTROL,
3192 pin_ctl & ~flag);
3193}
3194
Jiang Zhe40c1d302007-11-12 13:05:16 +01003195static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003196{
3197 if (!nid)
3198 return 0;
3199 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003200 & (1 << 31)) {
3201 unsigned int pinctl;
3202 pinctl = snd_hda_codec_read(codec, nid, 0,
3203 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3204 if (pinctl & AC_PINCTL_IN_EN)
3205 return 0; /* mic- or line-input */
3206 else
3207 return 1; /* HP-output */
3208 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003209 return 0;
3210}
3211
3212static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003213{
3214 struct sigmatel_spec *spec = codec->spec;
3215 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003216 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003217 int i, presence;
3218
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003219 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003220 if (spec->gpio_mute)
3221 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3222 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3223
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003224 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003225 if (presence)
3226 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003227 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3228 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003229 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003230 }
Matt4e550962005-07-04 17:51:39 +02003231
3232 if (presence) {
3233 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003234 if (spec->hp_switch)
3235 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003236 for (i = 0; i < cfg->line_outs; i++)
3237 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3238 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003239 for (i = 0; i < cfg->speaker_outs; i++)
3240 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3241 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003242 if (spec->eapd_mask)
3243 stac_gpio_set(codec, spec->gpio_mask,
3244 spec->gpio_dir, spec->gpio_data &
3245 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003246 } else {
3247 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003248 if (spec->hp_switch)
3249 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003250 for (i = 0; i < cfg->line_outs; i++)
3251 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3252 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003253 for (i = 0; i < cfg->speaker_outs; i++)
3254 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3255 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003256 if (spec->eapd_mask)
3257 stac_gpio_set(codec, spec->gpio_mask,
3258 spec->gpio_dir, spec->gpio_data |
3259 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003260 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003261 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3262 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003263}
3264
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003265static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3266{
3267 struct sigmatel_spec *spec = codec->spec;
3268 hda_nid_t nid = spec->pwr_nids[idx];
3269 int presence, val;
3270 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3271 & 0x000000ff;
3272 presence = get_hp_pin_presence(codec, nid);
3273 idx = 1 << idx;
3274
3275 if (presence)
3276 val &= ~idx;
3277 else
3278 val |= idx;
3279
3280 /* power down unused output ports */
3281 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3282};
3283
Takashi Iwai314634b2006-09-21 11:56:18 +02003284static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3285{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003286 struct sigmatel_spec *spec = codec->spec;
3287 int idx = res >> 26 & 0x0f;
3288
3289 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003290 case STAC_HP_EVENT:
3291 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003292 /* fallthru */
3293 case STAC_PWR_EVENT:
3294 if (spec->num_pwrs > 0)
3295 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003296 }
3297}
3298
Takashi Iwaicb53c622007-08-10 17:21:45 +02003299#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003300static int stac92xx_resume(struct hda_codec *codec)
3301{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003302 struct sigmatel_spec *spec = codec->spec;
3303
Richard Fish11b44bb2006-08-23 18:31:34 +02003304 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003305 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003306 stac_gpio_set(codec, spec->gpio_mask,
3307 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003308 snd_hda_codec_resume_amp(codec);
3309 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003310 /* power down inactive DACs */
3311 if (spec->dac_list)
3312 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003313 /* invoke unsolicited event to reset the HP state */
3314 if (spec->hp_detect)
3315 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003316 return 0;
3317}
3318#endif
3319
Matt2f2f4252005-04-13 14:45:30 +02003320static struct hda_codec_ops stac92xx_patch_ops = {
3321 .build_controls = stac92xx_build_controls,
3322 .build_pcms = stac92xx_build_pcms,
3323 .init = stac92xx_init,
3324 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003325 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003326#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003327 .resume = stac92xx_resume,
3328#endif
Matt2f2f4252005-04-13 14:45:30 +02003329};
3330
3331static int patch_stac9200(struct hda_codec *codec)
3332{
3333 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003334 int err;
Matt2f2f4252005-04-13 14:45:30 +02003335
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003336 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003337 if (spec == NULL)
3338 return -ENOMEM;
3339
3340 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003341 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003342 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003343 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3344 stac9200_models,
3345 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003346 if (spec->board_config < 0) {
3347 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3348 err = stac92xx_save_bios_config_regs(codec);
3349 if (err < 0) {
3350 stac92xx_free(codec);
3351 return err;
3352 }
3353 spec->pin_configs = spec->bios_pin_configs;
3354 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003355 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3356 stac92xx_set_config_regs(codec);
3357 }
Matt2f2f4252005-04-13 14:45:30 +02003358
3359 spec->multiout.max_channels = 2;
3360 spec->multiout.num_dacs = 1;
3361 spec->multiout.dac_nids = stac9200_dac_nids;
3362 spec->adc_nids = stac9200_adc_nids;
3363 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003364 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003365 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003366 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003367 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003368
Tobin Davisbf277782008-02-03 20:31:47 +01003369 if (spec->board_config == STAC_9200_GATEWAY ||
3370 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003371 spec->init = stac9200_eapd_init;
3372 else
3373 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003374 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003375
Takashi Iwai117f2572008-03-18 09:53:23 +01003376 if (spec->board_config == STAC_9200_PANASONIC) {
3377 spec->gpio_mask = spec->gpio_dir = 0x09;
3378 spec->gpio_data = 0x00;
3379 }
3380
Mattc7d4b2f2005-06-27 14:59:41 +02003381 err = stac9200_parse_auto_config(codec);
3382 if (err < 0) {
3383 stac92xx_free(codec);
3384 return err;
3385 }
Matt2f2f4252005-04-13 14:45:30 +02003386
3387 codec->patch_ops = stac92xx_patch_ops;
3388
3389 return 0;
3390}
3391
Tobin Davis8e21c342007-01-08 11:04:17 +01003392static int patch_stac925x(struct hda_codec *codec)
3393{
3394 struct sigmatel_spec *spec;
3395 int err;
3396
3397 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3398 if (spec == NULL)
3399 return -ENOMEM;
3400
3401 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003402 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003403 spec->pin_nids = stac925x_pin_nids;
3404 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3405 stac925x_models,
3406 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003407 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003408 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003409 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3410 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003411 err = stac92xx_save_bios_config_regs(codec);
3412 if (err < 0) {
3413 stac92xx_free(codec);
3414 return err;
3415 }
3416 spec->pin_configs = spec->bios_pin_configs;
3417 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3418 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3419 stac92xx_set_config_regs(codec);
3420 }
3421
3422 spec->multiout.max_channels = 2;
3423 spec->multiout.num_dacs = 1;
3424 spec->multiout.dac_nids = stac925x_dac_nids;
3425 spec->adc_nids = stac925x_adc_nids;
3426 spec->mux_nids = stac925x_mux_nids;
3427 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003428 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003429 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003430 switch (codec->vendor_id) {
3431 case 0x83847632: /* STAC9202 */
3432 case 0x83847633: /* STAC9202D */
3433 case 0x83847636: /* STAC9251 */
3434 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003435 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003436 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003437 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3438 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003439 break;
3440 default:
3441 spec->num_dmics = 0;
3442 break;
3443 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003444
3445 spec->init = stac925x_core_init;
3446 spec->mixer = stac925x_mixer;
3447
3448 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003449 if (!err) {
3450 if (spec->board_config < 0) {
3451 printk(KERN_WARNING "hda_codec: No auto-config is "
3452 "available, default to model=ref\n");
3453 spec->board_config = STAC_925x_REF;
3454 goto again;
3455 }
3456 err = -EINVAL;
3457 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003458 if (err < 0) {
3459 stac92xx_free(codec);
3460 return err;
3461 }
3462
3463 codec->patch_ops = stac92xx_patch_ops;
3464
3465 return 0;
3466}
3467
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003468static struct hda_input_mux stac92hd73xx_dmux = {
3469 .num_items = 4,
3470 .items = {
3471 { "Analog Inputs", 0x0b },
3472 { "CD", 0x08 },
3473 { "Digital Mic 1", 0x09 },
3474 { "Digital Mic 2", 0x0a },
3475 }
3476};
3477
3478static int patch_stac92hd73xx(struct hda_codec *codec)
3479{
3480 struct sigmatel_spec *spec;
3481 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3482 int err = 0;
3483
3484 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3485 if (spec == NULL)
3486 return -ENOMEM;
3487
3488 codec->spec = spec;
3489 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3490 spec->pin_nids = stac92hd73xx_pin_nids;
3491 spec->board_config = snd_hda_check_board_config(codec,
3492 STAC_92HD73XX_MODELS,
3493 stac92hd73xx_models,
3494 stac92hd73xx_cfg_tbl);
3495again:
3496 if (spec->board_config < 0) {
3497 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3498 " STAC92HD73XX, using BIOS defaults\n");
3499 err = stac92xx_save_bios_config_regs(codec);
3500 if (err < 0) {
3501 stac92xx_free(codec);
3502 return err;
3503 }
3504 spec->pin_configs = spec->bios_pin_configs;
3505 } else {
3506 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3507 stac92xx_set_config_regs(codec);
3508 }
3509
3510 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3511 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3512
3513 if (spec->multiout.num_dacs < 0) {
3514 printk(KERN_WARNING "hda_codec: Could not determine "
3515 "number of channels defaulting to DAC count\n");
3516 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3517 }
3518
3519 switch (spec->multiout.num_dacs) {
3520 case 0x3: /* 6 Channel */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003521 spec->multiout.hp_nid = 0x17;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003522 spec->mixer = stac92hd73xx_6ch_mixer;
3523 spec->init = stac92hd73xx_6ch_core_init;
3524 break;
3525 case 0x4: /* 8 Channel */
3526 spec->multiout.hp_nid = 0x18;
3527 spec->mixer = stac92hd73xx_8ch_mixer;
3528 spec->init = stac92hd73xx_8ch_core_init;
3529 break;
3530 case 0x5: /* 10 Channel */
3531 spec->multiout.hp_nid = 0x19;
3532 spec->mixer = stac92hd73xx_10ch_mixer;
3533 spec->init = stac92hd73xx_10ch_core_init;
3534 };
3535
3536 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3537 spec->aloopback_mask = 0x01;
3538 spec->aloopback_shift = 8;
3539
3540 spec->mux_nids = stac92hd73xx_mux_nids;
3541 spec->adc_nids = stac92hd73xx_adc_nids;
3542 spec->dmic_nids = stac92hd73xx_dmic_nids;
3543 spec->dmux_nids = stac92hd73xx_dmux_nids;
3544
3545 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3546 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01003547 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003548 spec->dinput_mux = &stac92hd73xx_dmux;
3549 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003550 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003551 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003552
Matthew Ranostaya7662642008-02-21 07:51:14 +01003553 switch (spec->board_config) {
3554 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003555 spec->init = dell_eq_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01003556 switch (codec->subsystem_id) {
3557 case 0x1028025e: /* Analog Mics */
3558 case 0x1028025f:
3559 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3560 spec->num_dmics = 0;
3561 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01003562 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01003563 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01003564 spec->init = dell_m6_core_init;
3565 /* fall-through */
3566 case 0x10280254:
3567 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01003568 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3569 spec->num_dmics = 1;
3570 break;
3571 case 0x10280256: /* Both */
3572 case 0x10280057:
3573 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3574 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3575 spec->num_dmics = 1;
3576 break;
3577 }
3578 break;
3579 default:
3580 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3581 }
3582
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003583 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3584 spec->pwr_nids = stac92hd73xx_pwr_nids;
3585
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003586 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3587
3588 if (!err) {
3589 if (spec->board_config < 0) {
3590 printk(KERN_WARNING "hda_codec: No auto-config is "
3591 "available, default to model=ref\n");
3592 spec->board_config = STAC_92HD73XX_REF;
3593 goto again;
3594 }
3595 err = -EINVAL;
3596 }
3597
3598 if (err < 0) {
3599 stac92xx_free(codec);
3600 return err;
3601 }
3602
3603 codec->patch_ops = stac92xx_patch_ops;
3604
3605 return 0;
3606}
3607
Matthew Ranostaye035b842007-11-06 11:53:55 +01003608static int patch_stac92hd71bxx(struct hda_codec *codec)
3609{
3610 struct sigmatel_spec *spec;
3611 int err = 0;
3612
3613 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3614 if (spec == NULL)
3615 return -ENOMEM;
3616
3617 codec->spec = spec;
3618 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003619 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003620 spec->pin_nids = stac92hd71bxx_pin_nids;
3621 spec->board_config = snd_hda_check_board_config(codec,
3622 STAC_92HD71BXX_MODELS,
3623 stac92hd71bxx_models,
3624 stac92hd71bxx_cfg_tbl);
3625again:
3626 if (spec->board_config < 0) {
3627 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3628 " STAC92HD71BXX, using BIOS defaults\n");
3629 err = stac92xx_save_bios_config_regs(codec);
3630 if (err < 0) {
3631 stac92xx_free(codec);
3632 return err;
3633 }
3634 spec->pin_configs = spec->bios_pin_configs;
3635 } else {
3636 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3637 stac92xx_set_config_regs(codec);
3638 }
3639
Matthew Ranostay541eee82007-12-14 12:08:04 +01003640 switch (codec->vendor_id) {
3641 case 0x111d76b6: /* 4 Port without Analog Mixer */
3642 case 0x111d76b7:
3643 case 0x111d76b4: /* 6 Port without Analog Mixer */
3644 case 0x111d76b5:
3645 spec->mixer = stac92hd71bxx_mixer;
3646 spec->init = stac92hd71bxx_core_init;
3647 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003648 case 0x111d7608: /* 5 Port with Analog Mixer */
3649 /* no output amps */
3650 spec->num_pwrs = 0;
3651 spec->mixer = stac92hd71bxx_analog_mixer;
3652
3653 /* disable VSW */
3654 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3655 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3656 break;
3657 case 0x111d7603: /* 6 Port with Analog Mixer */
3658 /* no output amps */
3659 spec->num_pwrs = 0;
3660 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01003661 default:
3662 spec->mixer = stac92hd71bxx_analog_mixer;
3663 spec->init = stac92hd71bxx_analog_core_init;
3664 }
3665
3666 spec->aloopback_mask = 0x20;
3667 spec->aloopback_shift = 0;
3668
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003669 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003670 spec->gpio_mask = 0x01;
3671 spec->gpio_dir = 0x01;
3672 spec->gpio_mask = 0x01;
3673 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003674
Matthew Ranostaye035b842007-11-06 11:53:55 +01003675 spec->mux_nids = stac92hd71bxx_mux_nids;
3676 spec->adc_nids = stac92hd71bxx_adc_nids;
3677 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003678 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003679 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003680
3681 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3682 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3683 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003684 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003685
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01003686 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003687 spec->multiout.hp_nid = 0x11;
3688 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3689
3690 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3691 if (!err) {
3692 if (spec->board_config < 0) {
3693 printk(KERN_WARNING "hda_codec: No auto-config is "
3694 "available, default to model=ref\n");
3695 spec->board_config = STAC_92HD71BXX_REF;
3696 goto again;
3697 }
3698 err = -EINVAL;
3699 }
3700
3701 if (err < 0) {
3702 stac92xx_free(codec);
3703 return err;
3704 }
3705
3706 codec->patch_ops = stac92xx_patch_ops;
3707
3708 return 0;
3709};
3710
Matt2f2f4252005-04-13 14:45:30 +02003711static int patch_stac922x(struct hda_codec *codec)
3712{
3713 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003714 int err;
Matt2f2f4252005-04-13 14:45:30 +02003715
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003716 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003717 if (spec == NULL)
3718 return -ENOMEM;
3719
3720 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003721 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003722 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003723 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3724 stac922x_models,
3725 stac922x_cfg_tbl);
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003726 if (spec->board_config == STAC_INTEL_MAC_V3) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003727 spec->gpio_mask = spec->gpio_dir = 0x03;
3728 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003729 /* Intel Macs have all same PCI SSID, so we need to check
3730 * codec SSID to distinguish the exact models
3731 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01003732 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003733 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003734
3735 case 0x106b0800:
3736 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02003737 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003738 case 0x106b0600:
3739 case 0x106b0700:
3740 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01003741 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003742 case 0x106b0e00:
3743 case 0x106b0f00:
3744 case 0x106b1600:
3745 case 0x106b1700:
3746 case 0x106b0200:
3747 case 0x106b1e00:
3748 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003749 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003750 case 0x106b1a00:
3751 case 0x00000100:
3752 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02003753 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003754 case 0x106b0a00:
3755 case 0x106b2200:
3756 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02003757 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01003758 }
3759 }
3760
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003761 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02003762 if (spec->board_config < 0) {
3763 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3764 "using BIOS defaults\n");
3765 err = stac92xx_save_bios_config_regs(codec);
3766 if (err < 0) {
3767 stac92xx_free(codec);
3768 return err;
3769 }
3770 spec->pin_configs = spec->bios_pin_configs;
3771 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01003772 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3773 stac92xx_set_config_regs(codec);
3774 }
Matt2f2f4252005-04-13 14:45:30 +02003775
Matt2f2f4252005-04-13 14:45:30 +02003776 spec->adc_nids = stac922x_adc_nids;
3777 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01003778 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003779 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02003780 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003781 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003782
3783 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003784 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003785
3786 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003787
Matt Porter3cc08dc2006-01-23 15:27:49 +01003788 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003789 if (!err) {
3790 if (spec->board_config < 0) {
3791 printk(KERN_WARNING "hda_codec: No auto-config is "
3792 "available, default to model=ref\n");
3793 spec->board_config = STAC_D945_REF;
3794 goto again;
3795 }
3796 err = -EINVAL;
3797 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01003798 if (err < 0) {
3799 stac92xx_free(codec);
3800 return err;
3801 }
3802
3803 codec->patch_ops = stac92xx_patch_ops;
3804
Takashi Iwai807a46362007-05-29 19:01:37 +02003805 /* Fix Mux capture level; max to 2 */
3806 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3807 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3808 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3809 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3810 (0 << AC_AMPCAP_MUTE_SHIFT));
3811
Matt Porter3cc08dc2006-01-23 15:27:49 +01003812 return 0;
3813}
3814
3815static int patch_stac927x(struct hda_codec *codec)
3816{
3817 struct sigmatel_spec *spec;
3818 int err;
3819
3820 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3821 if (spec == NULL)
3822 return -ENOMEM;
3823
3824 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003825 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003826 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003827 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3828 stac927x_models,
3829 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003830 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003831 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3832 if (spec->board_config < 0)
3833 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3834 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02003835 err = stac92xx_save_bios_config_regs(codec);
3836 if (err < 0) {
3837 stac92xx_free(codec);
3838 return err;
3839 }
3840 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003841 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003842 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3843 stac92xx_set_config_regs(codec);
3844 }
3845
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003846 spec->adc_nids = stac927x_adc_nids;
3847 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3848 spec->mux_nids = stac927x_mux_nids;
3849 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003850 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003851 spec->multiout.dac_nids = spec->dac_nids;
3852
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003853 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02003854 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003855 case STAC_D965_5ST:
3856 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003857 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003858 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003859 spec->num_dmics = 0;
3860
Tobin Davis93ed1502006-09-01 21:03:12 +02003861 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003862 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003863 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003864 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02003865 switch (codec->subsystem_id) {
3866 case 0x10280209:
3867 case 0x1028022e:
3868 /* correct the device field to SPDIF out */
3869 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3870 break;
3871 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01003872 /* configure the analog microphone on some laptops */
3873 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003874 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01003875 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01003876 /* correct the front input jack as a mic */
3877 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3878 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003879 case STAC_DELL_3ST:
3880 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003881 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003882 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003883 spec->dmic_nids = stac927x_dmic_nids;
3884 spec->num_dmics = STAC927X_NUM_DMICS;
3885
Tobin Davis93ed1502006-09-01 21:03:12 +02003886 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003887 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003888 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003889 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003890 break;
3891 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003892 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003893 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003894 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003895 spec->num_dmics = 0;
3896
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003897 spec->init = stac927x_core_init;
3898 spec->mixer = stac927x_mixer;
3899 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01003900
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003901 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003902 spec->aloopback_mask = 0x40;
3903 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003904
Matt Porter3cc08dc2006-01-23 15:27:49 +01003905 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003906 if (!err) {
3907 if (spec->board_config < 0) {
3908 printk(KERN_WARNING "hda_codec: No auto-config is "
3909 "available, default to model=ref\n");
3910 spec->board_config = STAC_D965_REF;
3911 goto again;
3912 }
3913 err = -EINVAL;
3914 }
Mattc7d4b2f2005-06-27 14:59:41 +02003915 if (err < 0) {
3916 stac92xx_free(codec);
3917 return err;
3918 }
Matt2f2f4252005-04-13 14:45:30 +02003919
3920 codec->patch_ops = stac92xx_patch_ops;
3921
Takashi Iwai52987652008-01-16 16:09:47 +01003922 /*
3923 * !!FIXME!!
3924 * The STAC927x seem to require fairly long delays for certain
3925 * command sequences. With too short delays (even if the answer
3926 * is set to RIRB properly), it results in the silence output
3927 * on some hardwares like Dell.
3928 *
3929 * The below flag enables the longer delay (see get_response
3930 * in hda_intel.c).
3931 */
3932 codec->bus->needs_damn_long_delay = 1;
3933
Matt2f2f4252005-04-13 14:45:30 +02003934 return 0;
3935}
3936
Matt Porterf3302a52006-07-31 12:49:34 +02003937static int patch_stac9205(struct hda_codec *codec)
3938{
3939 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02003940 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02003941
3942 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3943 if (spec == NULL)
3944 return -ENOMEM;
3945
3946 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003947 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003948 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003949 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
3950 stac9205_models,
3951 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003952 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02003953 if (spec->board_config < 0) {
3954 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
3955 err = stac92xx_save_bios_config_regs(codec);
3956 if (err < 0) {
3957 stac92xx_free(codec);
3958 return err;
3959 }
3960 spec->pin_configs = spec->bios_pin_configs;
3961 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02003962 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
3963 stac92xx_set_config_regs(codec);
3964 }
3965
3966 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003967 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02003968 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01003969 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02003970 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02003971 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003972 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01003973 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003974 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02003975
3976 spec->init = stac9205_core_init;
3977 spec->mixer = stac9205_mixer;
3978
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003979 spec->aloopback_mask = 0x40;
3980 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02003981 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02003982
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003983 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003984 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02003985 /* Enable SPDIF in/out */
3986 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3987 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01003988
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003989 /* Enable unsol response for GPIO4/Dock HP connection */
3990 snd_hda_codec_write(codec, codec->afg, 0,
3991 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3992 snd_hda_codec_write_cache(codec, codec->afg, 0,
3993 AC_VERB_SET_UNSOLICITED_ENABLE,
3994 (AC_USRSP_EN | STAC_HP_EVENT));
3995
3996 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003997 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003998 spec->gpio_mask = 0x1b;
3999 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004000 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004001 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004002 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004003 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004004 break;
4005 default:
4006 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004007 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004008 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004009 break;
4010 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004011
Matt Porterf3302a52006-07-31 12:49:34 +02004012 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004013 if (!err) {
4014 if (spec->board_config < 0) {
4015 printk(KERN_WARNING "hda_codec: No auto-config is "
4016 "available, default to model=ref\n");
4017 spec->board_config = STAC_9205_REF;
4018 goto again;
4019 }
4020 err = -EINVAL;
4021 }
Matt Porterf3302a52006-07-31 12:49:34 +02004022 if (err < 0) {
4023 stac92xx_free(codec);
4024 return err;
4025 }
4026
4027 codec->patch_ops = stac92xx_patch_ops;
4028
4029 return 0;
4030}
4031
Matt2f2f4252005-04-13 14:45:30 +02004032/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004033 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004034 */
4035
Guillaume Munch99ccc562006-08-16 19:35:12 +02004036/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004037static hda_nid_t vaio_dacs[] = { 0x2 };
4038#define VAIO_HP_DAC 0x5
4039static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4040static hda_nid_t vaio_mux_nids[] = { 0x15 };
4041
4042static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004043 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004044 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004045 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004046 { "Mic Jack", 0x1 },
4047 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004048 { "PCM", 0x3 },
4049 }
4050};
4051
4052static struct hda_verb vaio_init[] = {
4053 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004054 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004055 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4056 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4057 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004059 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004060 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4061 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4063 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4065 {}
4066};
4067
Guillaume Munch6d859062006-08-22 17:15:47 +02004068static struct hda_verb vaio_ar_init[] = {
4069 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4070 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4071 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4072 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4073/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4074 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004075 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004076 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4077 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4078/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4080 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4082 {}
4083};
4084
Takashi Iwaidb064e52006-03-16 16:04:58 +01004085/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004086static struct hda_bind_ctls vaio_bind_master_vol = {
4087 .ops = &snd_hda_bind_vol,
4088 .values = {
4089 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4090 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4091 0
4092 },
4093};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004094
4095/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004096static struct hda_bind_ctls vaio_bind_master_sw = {
4097 .ops = &snd_hda_bind_sw,
4098 .values = {
4099 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4100 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4101 0,
4102 },
4103};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004104
4105static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004106 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4107 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004108 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4109 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4110 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4111 {
4112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4113 .name = "Capture Source",
4114 .count = 1,
4115 .info = stac92xx_mux_enum_info,
4116 .get = stac92xx_mux_enum_get,
4117 .put = stac92xx_mux_enum_put,
4118 },
4119 {}
4120};
4121
Guillaume Munch6d859062006-08-22 17:15:47 +02004122static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004123 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4124 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004125 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4126 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4127 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4128 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4129 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4130 {
4131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4132 .name = "Capture Source",
4133 .count = 1,
4134 .info = stac92xx_mux_enum_info,
4135 .get = stac92xx_mux_enum_get,
4136 .put = stac92xx_mux_enum_put,
4137 },
4138 {}
4139};
4140
4141static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004142 .build_controls = stac92xx_build_controls,
4143 .build_pcms = stac92xx_build_pcms,
4144 .init = stac92xx_init,
4145 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004146#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004147 .resume = stac92xx_resume,
4148#endif
4149};
4150
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004151static int stac9872_vaio_init(struct hda_codec *codec)
4152{
4153 int err;
4154
4155 err = stac92xx_init(codec);
4156 if (err < 0)
4157 return err;
4158 if (codec->patch_ops.unsol_event)
4159 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4160 return 0;
4161}
4162
4163static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4164{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004165 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004166 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4167 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4168 } else {
4169 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4170 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4171 }
4172}
4173
4174static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4175{
4176 switch (res >> 26) {
4177 case STAC_HP_EVENT:
4178 stac9872_vaio_hp_detect(codec, res);
4179 break;
4180 }
4181}
4182
4183static struct hda_codec_ops stac9872_vaio_patch_ops = {
4184 .build_controls = stac92xx_build_controls,
4185 .build_pcms = stac92xx_build_pcms,
4186 .init = stac9872_vaio_init,
4187 .free = stac92xx_free,
4188 .unsol_event = stac9872_vaio_unsol_event,
4189#ifdef CONFIG_PM
4190 .resume = stac92xx_resume,
4191#endif
4192};
4193
Guillaume Munch6d859062006-08-22 17:15:47 +02004194enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4195 CXD9872RD_VAIO,
4196 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4197 STAC9872AK_VAIO,
4198 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4199 STAC9872K_VAIO,
4200 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004201 CXD9872AKD_VAIO,
4202 STAC_9872_MODELS,
4203};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004204
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004205static const char *stac9872_models[STAC_9872_MODELS] = {
4206 [CXD9872RD_VAIO] = "vaio",
4207 [CXD9872AKD_VAIO] = "vaio-ar",
4208};
4209
4210static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4211 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4212 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4213 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004214 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004215 {}
4216};
4217
Guillaume Munch6d859062006-08-22 17:15:47 +02004218static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004219{
4220 struct sigmatel_spec *spec;
4221 int board_config;
4222
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004223 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4224 stac9872_models,
4225 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004226 if (board_config < 0)
4227 /* unknown config, let generic-parser do its job... */
4228 return snd_hda_parse_generic_codec(codec);
4229
4230 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4231 if (spec == NULL)
4232 return -ENOMEM;
4233
4234 codec->spec = spec;
4235 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004236 case CXD9872RD_VAIO:
4237 case STAC9872AK_VAIO:
4238 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004239 spec->mixer = vaio_mixer;
4240 spec->init = vaio_init;
4241 spec->multiout.max_channels = 2;
4242 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4243 spec->multiout.dac_nids = vaio_dacs;
4244 spec->multiout.hp_nid = VAIO_HP_DAC;
4245 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4246 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004247 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004248 spec->input_mux = &vaio_mux;
4249 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004250 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004251 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004252
4253 case CXD9872AKD_VAIO:
4254 spec->mixer = vaio_ar_mixer;
4255 spec->init = vaio_ar_init;
4256 spec->multiout.max_channels = 2;
4257 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4258 spec->multiout.dac_nids = vaio_dacs;
4259 spec->multiout.hp_nid = VAIO_HP_DAC;
4260 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004261 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004262 spec->adc_nids = vaio_adcs;
4263 spec->input_mux = &vaio_mux;
4264 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004265 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004266 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004267 }
4268
Takashi Iwaidb064e52006-03-16 16:04:58 +01004269 return 0;
4270}
4271
4272
4273/*
Matt2f2f4252005-04-13 14:45:30 +02004274 * patch entries
4275 */
4276struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4277 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4278 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4279 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4280 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4281 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4282 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4283 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004284 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4285 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4286 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4287 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4288 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4289 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004290 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4291 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4292 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4293 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4294 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4295 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4296 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4297 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4298 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4299 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004300 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4301 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4302 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4303 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4304 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4305 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004306 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4307 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004308 /* The following does not take into account .id=0x83847661 when subsys =
4309 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4310 * currently not fully supported.
4311 */
4312 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4313 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4314 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02004315 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4316 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4317 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4318 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4319 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4320 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4321 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4322 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004323 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4324 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01004325 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4326 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004327 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01004328 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4329 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4330 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4331 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4332 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4333 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4334 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4335 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02004336 {} /* terminator */
4337};