blob: da48d8c0b295082ad10686adcddc99585c9a644f [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040033#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Takashi Iwaic6e4c662008-11-25 11:58:19 +010038enum {
39 STAC_VREF_EVENT = 1,
40 STAC_INSERT_EVENT,
41 STAC_PWR_EVENT,
42 STAC_HP_EVENT,
43};
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
46 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010047 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020048 STAC_9200_DELL_D21,
49 STAC_9200_DELL_D22,
50 STAC_9200_DELL_D23,
51 STAC_9200_DELL_M21,
52 STAC_9200_DELL_M22,
53 STAC_9200_DELL_M23,
54 STAC_9200_DELL_M24,
55 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020058 STAC_9200_M4,
59 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010060 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010061 STAC_9200_MODELS
62};
63
64enum {
65 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020066 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020067 STAC_9205_DELL_M43,
68 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010069 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010070 STAC_9205_MODELS
71};
72
73enum {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010074 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010075 STAC_92HD73XX_REF,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010076 STAC_DELL_M6_AMIC,
77 STAC_DELL_M6_DMIC,
78 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050079 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010080 STAC_92HD73XX_MODELS
81};
82
83enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020084 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050085 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050086 STAC_DELL_S14,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020087 STAC_92HD83XXX_MODELS
88};
89
90enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010091 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010092 STAC_DELL_M4_1,
93 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050094 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040095 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +010096 STAC_HP_DV5,
Matthew Ranostaye035b842007-11-06 11:53:55 +010097 STAC_92HD71BXX_MODELS
98};
99
100enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100101 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200102 STAC_M1,
103 STAC_M1_2,
104 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100105 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200106 STAC_M3,
107 STAC_M5,
108 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100109 STAC_925x_MODELS
110};
111
112enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100113 STAC_D945_REF,
114 STAC_D945GTP3,
115 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200116 STAC_INTEL_MAC_V1,
117 STAC_INTEL_MAC_V2,
118 STAC_INTEL_MAC_V3,
119 STAC_INTEL_MAC_V4,
120 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800121 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
122 * is given, one of the above models will be
123 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200124 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100125 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100126 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100127 STAC_MACBOOK_PRO_V1,
128 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200129 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200130 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300131 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200132 STAC_922X_DELL_D81,
133 STAC_922X_DELL_D82,
134 STAC_922X_DELL_M81,
135 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100136 STAC_922X_MODELS
137};
138
139enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100140 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100141 STAC_D965_REF,
142 STAC_D965_3ST,
143 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200144 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100145 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100146 STAC_927X_MODELS
147};
Matt Porter403d1942005-11-29 15:00:51 +0100148
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400149struct sigmatel_event {
150 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100151 unsigned char type;
152 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400153 int data;
154};
155
156struct sigmatel_jack {
157 hda_nid_t nid;
158 int type;
159 struct snd_jack *jack;
160};
161
Matt2f2f4252005-04-13 14:45:30 +0200162struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100163 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200164 unsigned int num_mixers;
165
Matt Porter403d1942005-11-29 15:00:51 +0100166 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500167 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200168 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100169 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100170 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400171 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100172 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200173
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100174 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200175 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100176 unsigned int gpio_mask;
177 unsigned int gpio_dir;
178 unsigned int gpio_data;
179 unsigned int gpio_mute;
180
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200181 /* stream */
182 unsigned int stream_delay;
183
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100184 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100185 unsigned char aloopback_mask;
186 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200187
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100188 /* power management */
189 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200190 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100191 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100192 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100193
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400194 /* jack detection */
195 struct snd_array jacks;
196
197 /* events */
198 struct snd_array events;
199
Matt2f2f4252005-04-13 14:45:30 +0200200 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100201 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400202 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100203 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200204 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100205 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100206 hda_nid_t hp_dacs[5];
207 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200208
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100209 int volume_offset;
210
Matt2f2f4252005-04-13 14:45:30 +0200211 /* capture */
212 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200213 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200214 hda_nid_t *mux_nids;
215 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200216 hda_nid_t *dmic_nids;
217 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100218 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100219 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200220 hda_nid_t *smux_nids;
221 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400222 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200223
Mattdabbed62005-06-14 10:19:34 +0200224 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100225 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200226 hda_nid_t anabeep_nid;
227 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200228
Matt2f2f4252005-04-13 14:45:30 +0200229 /* pin widgets */
230 hda_nid_t *pin_nids;
231 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200232
233 /* codec specific stuff */
234 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100235 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200236
237 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200238 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100239 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200240 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100241 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200242 struct hda_input_mux *sinput_mux;
243 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400244 unsigned int cur_amux;
245 hda_nid_t *amp_nids;
246 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200247 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200248
Matt Porter403d1942005-11-29 15:00:51 +0100249 /* i/o switches */
250 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200251 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100252 hda_nid_t line_switch; /* shared line-in for input and output */
253 hda_nid_t mic_switch; /* shared mic-in for input and output */
254 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200255 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200256
Mattc7d4b2f2005-06-27 14:59:41 +0200257 struct hda_pcm pcm_rec[2]; /* PCM information */
258
259 /* dynamic controls and input_mux */
260 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200261 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200262 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200263 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200264 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400265 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100266 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200267};
268
269static hda_nid_t stac9200_adc_nids[1] = {
270 0x03,
271};
272
273static hda_nid_t stac9200_mux_nids[1] = {
274 0x0c,
275};
276
277static hda_nid_t stac9200_dac_nids[1] = {
278 0x02,
279};
280
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100281static hda_nid_t stac92hd73xx_pwr_nids[8] = {
282 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
283 0x0f, 0x10, 0x11
284};
285
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400286static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
287 0x26, 0,
288};
289
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100290static hda_nid_t stac92hd73xx_adc_nids[2] = {
291 0x1a, 0x1b
292};
293
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400294#define DELL_M6_AMP 2
295static hda_nid_t stac92hd73xx_amp_nids[3] = {
296 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400297};
298
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100299#define STAC92HD73XX_NUM_DMICS 2
300static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
301 0x13, 0x14, 0
302};
303
304#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100305
306static hda_nid_t stac92hd73xx_mux_nids[4] = {
307 0x28, 0x29, 0x2a, 0x2b,
308};
309
310static hda_nid_t stac92hd73xx_dmux_nids[2] = {
311 0x20, 0x21,
312};
313
Matthew Ranostayd9737752008-09-07 12:03:41 +0200314static hda_nid_t stac92hd73xx_smux_nids[2] = {
315 0x22, 0x23,
316};
317
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200318#define STAC92HD83XXX_NUM_DMICS 2
319static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
320 0x11, 0x12, 0
321};
322
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200323#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200324
325static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
326 0x17, 0x18,
327};
328
329static hda_nid_t stac92hd83xxx_adc_nids[2] = {
330 0x15, 0x16,
331};
332
333static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
334 0xa, 0xb, 0xd, 0xe,
335};
336
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400337static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
338 0x1e, 0,
339};
340
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200341static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500342 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200343};
344
Takashi Iwai9248f262009-01-14 09:40:25 +0100345static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500346 0xc,
347};
348
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100349static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
350 0x0a, 0x0d, 0x0f
351};
352
Matthew Ranostaye035b842007-11-06 11:53:55 +0100353static hda_nid_t stac92hd71bxx_adc_nids[2] = {
354 0x12, 0x13,
355};
356
357static hda_nid_t stac92hd71bxx_mux_nids[2] = {
358 0x1a, 0x1b
359};
360
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400361static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
362 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100363};
364
Matthew Ranostayd9737752008-09-07 12:03:41 +0200365static hda_nid_t stac92hd71bxx_smux_nids[2] = {
366 0x24, 0x25,
367};
368
Matthew Ranostaye035b842007-11-06 11:53:55 +0100369#define STAC92HD71BXX_NUM_DMICS 2
370static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
371 0x18, 0x19, 0
372};
373
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400374static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
375 0x22, 0
376};
377
Tobin Davis8e21c342007-01-08 11:04:17 +0100378static hda_nid_t stac925x_adc_nids[1] = {
379 0x03,
380};
381
382static hda_nid_t stac925x_mux_nids[1] = {
383 0x0f,
384};
385
386static hda_nid_t stac925x_dac_nids[1] = {
387 0x02,
388};
389
Takashi Iwaif6e98522007-10-16 14:27:04 +0200390#define STAC925X_NUM_DMICS 1
391static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
392 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200393};
394
Takashi Iwai1697055e2007-12-18 18:05:52 +0100395static hda_nid_t stac925x_dmux_nids[1] = {
396 0x14,
397};
398
Matt2f2f4252005-04-13 14:45:30 +0200399static hda_nid_t stac922x_adc_nids[2] = {
400 0x06, 0x07,
401};
402
403static hda_nid_t stac922x_mux_nids[2] = {
404 0x12, 0x13,
405};
406
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500407static hda_nid_t stac927x_slave_dig_outs[2] = {
408 0x1f, 0,
409};
410
Matt Porter3cc08dc2006-01-23 15:27:49 +0100411static hda_nid_t stac927x_adc_nids[3] = {
412 0x07, 0x08, 0x09
413};
414
415static hda_nid_t stac927x_mux_nids[3] = {
416 0x15, 0x16, 0x17
417};
418
Matthew Ranostayd9737752008-09-07 12:03:41 +0200419static hda_nid_t stac927x_smux_nids[1] = {
420 0x21,
421};
422
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100423static hda_nid_t stac927x_dac_nids[6] = {
424 0x02, 0x03, 0x04, 0x05, 0x06, 0
425};
426
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100427static hda_nid_t stac927x_dmux_nids[1] = {
428 0x1b,
429};
430
Matthew Ranostay7f168592007-10-18 17:38:17 +0200431#define STAC927X_NUM_DMICS 2
432static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
433 0x13, 0x14, 0
434};
435
Matthew Ranostay65973632008-09-16 10:39:37 -0400436static const char *stac927x_spdif_labels[5] = {
437 "Digital Playback", "ADAT", "Analog Mux 1",
438 "Analog Mux 2", "Analog Mux 3"
439};
440
Matt Porterf3302a52006-07-31 12:49:34 +0200441static hda_nid_t stac9205_adc_nids[2] = {
442 0x12, 0x13
443};
444
445static hda_nid_t stac9205_mux_nids[2] = {
446 0x19, 0x1a
447};
448
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100449static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100450 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100451};
452
Matthew Ranostayd9737752008-09-07 12:03:41 +0200453static hda_nid_t stac9205_smux_nids[1] = {
454 0x21,
455};
456
Takashi Iwaif6e98522007-10-16 14:27:04 +0200457#define STAC9205_NUM_DMICS 2
458static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
459 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200460};
461
Mattc7d4b2f2005-06-27 14:59:41 +0200462static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200463 0x08, 0x09, 0x0d, 0x0e,
464 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200465};
466
Tobin Davis8e21c342007-01-08 11:04:17 +0100467static hda_nid_t stac925x_pin_nids[8] = {
468 0x07, 0x08, 0x0a, 0x0b,
469 0x0c, 0x0d, 0x10, 0x11,
470};
471
Matt2f2f4252005-04-13 14:45:30 +0200472static hda_nid_t stac922x_pin_nids[10] = {
473 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
474 0x0f, 0x10, 0x11, 0x15, 0x1b,
475};
476
Matthew Ranostaya7662642008-02-21 07:51:14 +0100477static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100478 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
479 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200480 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100481};
482
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500483static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200484 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500485 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200486};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500487
488#define STAC92HD71BXX_NUM_PINS 13
489static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
490 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
491 0x00, 0x14, 0x18, 0x19, 0x1e,
492 0x1f, 0x20, 0x27
493};
494static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100495 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
496 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500497 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100498};
499
Matt Porter3cc08dc2006-01-23 15:27:49 +0100500static hda_nid_t stac927x_pin_nids[14] = {
501 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
502 0x0f, 0x10, 0x11, 0x12, 0x13,
503 0x14, 0x21, 0x22, 0x23,
504};
505
Matt Porterf3302a52006-07-31 12:49:34 +0200506static hda_nid_t stac9205_pin_nids[12] = {
507 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
508 0x0f, 0x14, 0x16, 0x17, 0x18,
509 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200510};
511
Matthew Ranostay89385032008-09-11 09:49:39 -0400512#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
513
514static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
516{
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct sigmatel_spec *spec = codec->spec;
519 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
520
521 kcontrol->private_value ^= get_amp_nid(kcontrol);
522 kcontrol->private_value |= nid;
523
524 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
525}
526
527static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
528 struct snd_ctl_elem_value *ucontrol)
529{
530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
531 struct sigmatel_spec *spec = codec->spec;
532 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
533
534 kcontrol->private_value ^= get_amp_nid(kcontrol);
535 kcontrol->private_value |= nid;
536
537 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
538}
539
Matt Porter8b657272006-10-26 17:12:59 +0200540static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
541 struct snd_ctl_elem_info *uinfo)
542{
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 struct sigmatel_spec *spec = codec->spec;
545 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
546}
547
548static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
550{
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100553 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200554
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100555 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200556 return 0;
557}
558
559static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_value *ucontrol)
561{
562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100564 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200565
566 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100567 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200568}
569
Matthew Ranostayd9737752008-09-07 12:03:41 +0200570static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
571 struct snd_ctl_elem_info *uinfo)
572{
573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
574 struct sigmatel_spec *spec = codec->spec;
575 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
576}
577
578static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
579 struct snd_ctl_elem_value *ucontrol)
580{
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 struct sigmatel_spec *spec = codec->spec;
583 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
584
585 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
586 return 0;
587}
588
589static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_value *ucontrol)
591{
592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400594 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200595 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400596 int err, val;
597 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200598
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400599 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200600 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400601 if (err < 0)
602 return err;
603
604 if (spec->spdif_mute) {
605 if (smux_idx == 0)
606 nid = spec->multiout.dig_out_nid;
607 else
608 nid = codec->slave_dig_outs[smux_idx - 1];
609 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100610 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400611 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100612 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400613 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100614 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
615 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400616 }
617 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200618}
619
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100620static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200621{
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200624 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200625}
626
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100627static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
632
633 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
634 return 0;
635}
636
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100637static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200638{
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 struct sigmatel_spec *spec = codec->spec;
641 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
642
Mattc7d4b2f2005-06-27 14:59:41 +0200643 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200644 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
645}
646
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100647static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
648 struct snd_ctl_elem_info *uinfo)
649{
650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
651 struct sigmatel_spec *spec = codec->spec;
652 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
653}
654
655static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
657{
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
660
661 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
662 return 0;
663}
664
665static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
666 struct snd_ctl_elem_value *ucontrol)
667{
668 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
669 struct sigmatel_spec *spec = codec->spec;
670
671 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
672 spec->mono_nid, &spec->cur_mmux);
673}
674
Matthew Ranostay89385032008-09-11 09:49:39 -0400675static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
676 struct snd_ctl_elem_info *uinfo)
677{
678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
679 struct sigmatel_spec *spec = codec->spec;
680 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
681}
682
683static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *ucontrol)
685{
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
688
689 ucontrol->value.enumerated.item[0] = spec->cur_amux;
690 return 0;
691}
692
693static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
695{
696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
697 struct sigmatel_spec *spec = codec->spec;
698 struct snd_kcontrol *ctl =
699 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
700 if (!ctl)
701 return -EINVAL;
702
703 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
704 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
705
706 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
707 0, &spec->cur_amux);
708}
709
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200710#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
711
712static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
713 struct snd_ctl_elem_value *ucontrol)
714{
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100716 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200717 struct sigmatel_spec *spec = codec->spec;
718
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100719 ucontrol->value.integer.value[0] = !!(spec->aloopback &
720 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200721 return 0;
722}
723
724static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
725 struct snd_ctl_elem_value *ucontrol)
726{
727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
728 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100729 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200730 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100731 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200732
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100733 idx_val = spec->aloopback_mask << idx;
734 if (ucontrol->value.integer.value[0])
735 val = spec->aloopback | idx_val;
736 else
737 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100738 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200739 return 0;
740
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100741 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200742
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100743 /* Only return the bits defined by the shift value of the
744 * first two bytes of the mask
745 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200746 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100747 kcontrol->private_value & 0xFFFF, 0x0);
748 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200749
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100750 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200751 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100752 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200753 } else {
754 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100755 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200756 }
757
758 snd_hda_codec_write_cache(codec, codec->afg, 0,
759 kcontrol->private_value >> 16, dac_mode);
760
761 return 1;
762}
763
Mattc7d4b2f2005-06-27 14:59:41 +0200764static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200765 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200766 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200767 {}
768};
769
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200770static struct hda_verb stac9200_eapd_init[] = {
771 /* set dac0mux for dac converter */
772 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
773 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
774 {}
775};
776
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100777static struct hda_verb stac92hd73xx_6ch_core_init[] = {
778 /* set master volume and direct control */
779 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100780 /* setup adcs to point to mixer */
781 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
782 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100783 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
784 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
785 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
786 /* setup import muxs */
787 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
791 {}
792};
793
Matthew Ranostayd654a662008-03-14 08:46:51 +0100794static struct hda_verb dell_eq_core_init[] = {
795 /* set master volume to max value without distortion
796 * and direct control */
797 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100798 /* setup adcs to point to mixer */
799 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
800 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
801 /* setup import muxs */
802 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
803 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
804 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
806 {}
807};
808
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100809static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500810 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100811 /* setup adcs to point to mixer */
812 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
813 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
814 /* setup import muxs */
815 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
818 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
819 {}
820};
821
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100822static struct hda_verb stac92hd73xx_8ch_core_init[] = {
823 /* set master volume and direct control */
824 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100825 /* setup adcs to point to mixer */
826 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
827 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100828 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
829 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
830 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
831 /* setup import muxs */
832 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
833 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
834 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
835 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
836 {}
837};
838
839static struct hda_verb stac92hd73xx_10ch_core_init[] = {
840 /* set master volume and direct control */
841 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100842 /* dac3 is connected to import3 mux */
843 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100844 /* setup adcs to point to mixer */
845 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
846 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100847 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
848 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
849 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
850 /* setup import muxs */
851 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
852 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
853 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
854 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
855 {}
856};
857
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200858static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500859 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
860 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
861 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200862
863 /* power state controls amps */
864 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200865 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200866};
867
Matthew Ranostaye035b842007-11-06 11:53:55 +0100868static struct hda_verb stac92hd71bxx_core_init[] = {
869 /* set master volume and direct control */
870 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200871 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100872};
873
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500874#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100875static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200876 /* start of config #1 */
877
878 /* connect port 0f to audio mixer */
879 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200880 /* start of config #2 */
881
Matthew Ranostay541eee82007-12-14 12:08:04 +0100882 /* set master volume and direct control */
883 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500884 {}
885};
886
887static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
888 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
889 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100890 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
891 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100892 {}
893};
894
Tobin Davis8e21c342007-01-08 11:04:17 +0100895static struct hda_verb stac925x_core_init[] = {
896 /* set dac0mux for dac converter */
897 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100898 /* mute the master volume */
899 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100900 {}
901};
902
Mattc7d4b2f2005-06-27 14:59:41 +0200903static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200904 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200905 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200906 {}
907};
908
Tobin Davis93ed1502006-09-01 21:03:12 +0200909static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200910 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200911 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200912 /* unmute node 0x1b */
913 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
914 /* select node 0x03 as DAC */
915 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
916 {}
917};
918
Matt Porter3cc08dc2006-01-23 15:27:49 +0100919static struct hda_verb stac927x_core_init[] = {
920 /* set master volume and direct control */
921 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200922 /* enable analog pc beep path */
923 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100924 {}
925};
926
Matt Porterf3302a52006-07-31 12:49:34 +0200927static struct hda_verb stac9205_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200932 {}
933};
934
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100935#define STAC_MONO_MUX \
936 { \
937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
938 .name = "Mono Mux", \
939 .count = 1, \
940 .info = stac92xx_mono_mux_enum_info, \
941 .get = stac92xx_mono_mux_enum_get, \
942 .put = stac92xx_mono_mux_enum_put, \
943 }
944
Matthew Ranostay89385032008-09-11 09:49:39 -0400945#define STAC_AMP_MUX \
946 { \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Amp Selector Capture Switch", \
949 .count = 1, \
950 .info = stac92xx_amp_mux_enum_info, \
951 .get = stac92xx_amp_mux_enum_get, \
952 .put = stac92xx_amp_mux_enum_put, \
953 }
954
955#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
956 { \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .name = xname, \
959 .index = 0, \
960 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
961 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
962 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
963 .info = stac92xx_amp_volume_info, \
964 .get = stac92xx_amp_volume_get, \
965 .put = stac92xx_amp_volume_put, \
966 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
967 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
968 }
969
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100970#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200971 { \
972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
973 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100974 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200975 .info = stac92xx_aloopback_info, \
976 .get = stac92xx_aloopback_get, \
977 .put = stac92xx_aloopback_put, \
978 .private_value = verb_read | (verb_write << 16), \
979 }
980
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100981static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200982 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
983 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200984 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
985 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200986 { } /* end */
987};
988
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400989#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100990static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400991 /* start of config #1 */
992 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
993 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
994
995 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
996 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
997
998 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
999 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1000
1001 /* start of config #2 */
1002 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1003 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1004
1005 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1006 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1007
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001008 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1009
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001010 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1012
1013 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1014 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1015
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001016 { } /* end */
1017};
1018
1019static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001020 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1021
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1024
1025 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1026 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1027
1028 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1029 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1030
1031 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1032 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1033
1034 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1035 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1036
1037 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1038 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1039
1040 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1041 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1042 { } /* end */
1043};
1044
1045static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001046 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1047
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001048 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1050
1051 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1053
1054 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1055 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1056
1057 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1058 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1059
1060 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1061 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1062
1063 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1064 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1065
1066 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1067 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1068 { } /* end */
1069};
1070
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001071
1072static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1074 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1075
1076 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1077 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1078
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001079 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1080 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001081
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001082 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1083 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001084
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001085 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1086 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001087
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001088 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1089 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001090
1091 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001092 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1093 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001094 */
1095 { } /* end */
1096};
1097
Matthew Ranostay541eee82007-12-14 12:08:04 +01001098static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001099 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001100
Matthew Ranostay9b359472007-11-07 13:03:12 +01001101 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001103
1104 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001106 /* analog pc-beep replaced with digital beep support */
1107 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001108 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1109 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001110 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001111
Matthew Ranostay687cb982008-10-11 13:52:43 -04001112 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1113 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001114
Matthew Ranostay687cb982008-10-11 13:52:43 -04001115 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1116 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001117
1118 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1119 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1120
1121 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1122 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001123 { } /* end */
1124};
1125
Matthew Ranostay541eee82007-12-14 12:08:04 +01001126static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001127 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1128
Matthew Ranostay541eee82007-12-14 12:08:04 +01001129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001131
1132 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001134 { } /* end */
1135};
1136
Tobin Davis8e21c342007-01-08 11:04:17 +01001137static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001138 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001140 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001141 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001142 { } /* end */
1143};
1144
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001145static struct snd_kcontrol_new stac9205_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001146 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001147
1148 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001150
1151 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001153 { } /* end */
1154};
1155
1156/* This needs to be generated dynamically based on sequence */
1157static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001163 { } /* end */
1164};
1165
1166
1167static struct snd_kcontrol_new stac927x_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001168 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001169
1170 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001172
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001175
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001178 { } /* end */
1179};
1180
Takashi Iwai1697055e2007-12-18 18:05:52 +01001181static struct snd_kcontrol_new stac_dmux_mixer = {
1182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1183 .name = "Digital Input Source",
1184 /* count set later */
1185 .info = stac92xx_dmux_enum_info,
1186 .get = stac92xx_dmux_enum_get,
1187 .put = stac92xx_dmux_enum_put,
1188};
1189
Matthew Ranostayd9737752008-09-07 12:03:41 +02001190static struct snd_kcontrol_new stac_smux_mixer = {
1191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001192 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001193 /* count set later */
1194 .info = stac92xx_smux_enum_info,
1195 .get = stac92xx_smux_enum_get,
1196 .put = stac92xx_smux_enum_put,
1197};
1198
Takashi Iwai2134ea42008-01-10 16:53:55 +01001199static const char *slave_vols[] = {
1200 "Front Playback Volume",
1201 "Surround Playback Volume",
1202 "Center Playback Volume",
1203 "LFE Playback Volume",
1204 "Side Playback Volume",
1205 "Headphone Playback Volume",
1206 "Headphone Playback Volume",
1207 "Speaker Playback Volume",
1208 "External Speaker Playback Volume",
1209 "Speaker2 Playback Volume",
1210 NULL
1211};
1212
1213static const char *slave_sws[] = {
1214 "Front Playback Switch",
1215 "Surround Playback Switch",
1216 "Center Playback Switch",
1217 "LFE Playback Switch",
1218 "Side Playback Switch",
1219 "Headphone Playback Switch",
1220 "Headphone Playback Switch",
1221 "Speaker Playback Switch",
1222 "External Speaker Playback Switch",
1223 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001224 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001225 NULL
1226};
1227
Takashi Iwai603c4012008-07-30 15:01:44 +02001228static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001229static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001230
Matt2f2f4252005-04-13 14:45:30 +02001231static int stac92xx_build_controls(struct hda_codec *codec)
1232{
1233 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001234 struct auto_pin_cfg *cfg = &spec->autocfg;
1235 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001236 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001237 int i;
Matt2f2f4252005-04-13 14:45:30 +02001238
1239 err = snd_hda_add_new_ctls(codec, spec->mixer);
1240 if (err < 0)
1241 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001242
1243 for (i = 0; i < spec->num_mixers; i++) {
1244 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1245 if (err < 0)
1246 return err;
1247 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001248 if (spec->num_dmuxes > 0) {
1249 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001250 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001251 snd_ctl_new1(&stac_dmux_mixer, codec));
1252 if (err < 0)
1253 return err;
1254 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001255 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001256 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1257 struct hda_input_mux *smux = &spec->private_smux;
1258 /* check for mute support on SPDIF out */
1259 if (wcaps & AC_WCAP_OUT_AMP) {
1260 smux->items[smux->num_items].label = "Off";
1261 smux->items[smux->num_items].index = 0;
1262 smux->num_items++;
1263 spec->spdif_mute = 1;
1264 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001265 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001266 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001267 snd_ctl_new1(&stac_smux_mixer, codec));
1268 if (err < 0)
1269 return err;
1270 }
Mattc7d4b2f2005-06-27 14:59:41 +02001271
Mattdabbed62005-06-14 10:19:34 +02001272 if (spec->multiout.dig_out_nid) {
1273 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1274 if (err < 0)
1275 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001276 err = snd_hda_create_spdif_share_sw(codec,
1277 &spec->multiout);
1278 if (err < 0)
1279 return err;
1280 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001281 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001282 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001283 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1284 if (err < 0)
1285 return err;
1286 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001287
1288 /* if we have no master control, let's create it */
1289 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001290 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001291 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001292 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001293 /* correct volume offset */
1294 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001295 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001296 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001297 if (err < 0)
1298 return err;
1299 }
1300 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1301 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1302 NULL, slave_sws);
1303 if (err < 0)
1304 return err;
1305 }
1306
Takashi Iwai603c4012008-07-30 15:01:44 +02001307 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001308
1309 /* create jack input elements */
1310 if (spec->hp_detect) {
1311 for (i = 0; i < cfg->hp_outs; i++) {
1312 int type = SND_JACK_HEADPHONE;
1313 nid = cfg->hp_pins[i];
1314 /* jack detection */
1315 if (cfg->hp_outs == i)
1316 type |= SND_JACK_LINEOUT;
1317 err = stac92xx_add_jack(codec, nid, type);
1318 if (err < 0)
1319 return err;
1320 }
1321 }
1322 for (i = 0; i < cfg->line_outs; i++) {
1323 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1324 SND_JACK_LINEOUT);
1325 if (err < 0)
1326 return err;
1327 }
1328 for (i = 0; i < AUTO_PIN_LAST; i++) {
1329 nid = cfg->input_pins[i];
1330 if (nid) {
1331 err = stac92xx_add_jack(codec, nid,
1332 SND_JACK_MICROPHONE);
1333 if (err < 0)
1334 return err;
1335 }
1336 }
1337
Mattdabbed62005-06-14 10:19:34 +02001338 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001339}
1340
Matt Porter403d1942005-11-29 15:00:51 +01001341static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001342 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001343 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1344};
1345
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001346static unsigned int gateway9200_m4_pin_configs[8] = {
1347 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1348 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1349};
1350static unsigned int gateway9200_m4_2_pin_configs[8] = {
1351 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1352 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1353};
1354
1355/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001356 STAC 9200 pin configs for
1357 102801A8
1358 102801DE
1359 102801E8
1360*/
1361static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001362 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1363 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364};
1365
1366/*
1367 STAC 9200 pin configs for
1368 102801C0
1369 102801C1
1370*/
1371static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001372 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1373 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001374};
1375
1376/*
1377 STAC 9200 pin configs for
1378 102801C4 (Dell Dimension E310)
1379 102801C5
1380 102801C7
1381 102801D9
1382 102801DA
1383 102801E3
1384*/
1385static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001386 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1387 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001388};
1389
1390
1391/*
1392 STAC 9200-32 pin configs for
1393 102801B5 (Dell Inspiron 630m)
1394 102801D8 (Dell Inspiron 640m)
1395*/
1396static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001397 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1398 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399};
1400
1401/*
1402 STAC 9200-32 pin configs for
1403 102801C2 (Dell Latitude D620)
1404 102801C8
1405 102801CC (Dell Latitude D820)
1406 102801D4
1407 102801D6
1408*/
1409static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001410 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1411 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001412};
1413
1414/*
1415 STAC 9200-32 pin configs for
1416 102801CE (Dell XPS M1710)
1417 102801CF (Dell Precision M90)
1418*/
1419static unsigned int dell9200_m23_pin_configs[8] = {
1420 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1421 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1422};
1423
1424/*
1425 STAC 9200-32 pin configs for
1426 102801C9
1427 102801CA
1428 102801CB (Dell Latitude 120L)
1429 102801D3
1430*/
1431static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001432 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1433 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001434};
1435
1436/*
1437 STAC 9200-32 pin configs for
1438 102801BD (Dell Inspiron E1505n)
1439 102801EE
1440 102801EF
1441*/
1442static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001443 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1444 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001445};
1446
1447/*
1448 STAC 9200-32 pin configs for
1449 102801F5 (Dell Inspiron 1501)
1450 102801F6
1451*/
1452static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001453 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1454 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001455};
1456
1457/*
1458 STAC 9200-32
1459 102801CD (Dell Inspiron E1705/9400)
1460*/
1461static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001462 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1463 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001464};
1465
Tobin Davisbf277782008-02-03 20:31:47 +01001466static unsigned int oqo9200_pin_configs[8] = {
1467 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1468 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1469};
1470
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001471
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001472static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1473 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001474 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001475 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1476 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1477 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1478 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1479 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1480 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1481 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1482 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1483 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1484 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001485 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1486 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001487 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001488};
1489
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001490static const char *stac9200_models[STAC_9200_MODELS] = {
1491 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001492 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001493 [STAC_9200_DELL_D21] = "dell-d21",
1494 [STAC_9200_DELL_D22] = "dell-d22",
1495 [STAC_9200_DELL_D23] = "dell-d23",
1496 [STAC_9200_DELL_M21] = "dell-m21",
1497 [STAC_9200_DELL_M22] = "dell-m22",
1498 [STAC_9200_DELL_M23] = "dell-m23",
1499 [STAC_9200_DELL_M24] = "dell-m24",
1500 [STAC_9200_DELL_M25] = "dell-m25",
1501 [STAC_9200_DELL_M26] = "dell-m26",
1502 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001503 [STAC_9200_M4] = "gateway-m4",
1504 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001505 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001506};
1507
1508static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1509 /* SigmaTel reference board */
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1511 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001512 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1513 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001514 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1516 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001518 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1520 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1522 "unknown Dell", STAC_9200_DELL_D22),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1524 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001526 "Dell Latitude D620", STAC_9200_DELL_M22),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1528 "unknown Dell", STAC_9200_DELL_D23),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1530 "unknown Dell", STAC_9200_DELL_D23),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1532 "unknown Dell", STAC_9200_DELL_M22),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1534 "unknown Dell", STAC_9200_DELL_M24),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1536 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001538 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001540 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001542 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001546 "Dell Precision M90", STAC_9200_DELL_M23),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1548 "unknown Dell", STAC_9200_DELL_M22),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1550 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001552 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001554 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1556 "unknown Dell", STAC_9200_DELL_D23),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1558 "unknown Dell", STAC_9200_DELL_D23),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1560 "unknown Dell", STAC_9200_DELL_D21),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1562 "unknown Dell", STAC_9200_DELL_D23),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1564 "unknown Dell", STAC_9200_DELL_D21),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1566 "unknown Dell", STAC_9200_DELL_M25),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1568 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001570 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1572 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001573 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001574 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001575 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001576 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1577 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1578 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001579 /* OQO Mobile */
1580 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001581 {} /* terminator */
1582};
1583
Tobin Davis8e21c342007-01-08 11:04:17 +01001584static unsigned int ref925x_pin_configs[8] = {
1585 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001586 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001587};
1588
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001589static unsigned int stac925xM1_pin_configs[8] = {
1590 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1591 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001592};
1593
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001594static unsigned int stac925xM1_2_pin_configs[8] = {
1595 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1596 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1597};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001598
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001599static unsigned int stac925xM2_pin_configs[8] = {
1600 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1601 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001602};
1603
Tobin Davis8e21c342007-01-08 11:04:17 +01001604static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001605 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1606 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1607};
1608
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001609static unsigned int stac925xM3_pin_configs[8] = {
1610 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1611 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1612};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001613
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001614static unsigned int stac925xM5_pin_configs[8] = {
1615 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1616 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1617};
1618
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001619static unsigned int stac925xM6_pin_configs[8] = {
1620 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1621 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001622};
1623
1624static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1625 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001626 [STAC_M1] = stac925xM1_pin_configs,
1627 [STAC_M1_2] = stac925xM1_2_pin_configs,
1628 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001629 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001630 [STAC_M3] = stac925xM3_pin_configs,
1631 [STAC_M5] = stac925xM5_pin_configs,
1632 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001633};
1634
1635static const char *stac925x_models[STAC_925x_MODELS] = {
1636 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001637 [STAC_M1] = "m1",
1638 [STAC_M1_2] = "m1-2",
1639 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001640 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001641 [STAC_M3] = "m3",
1642 [STAC_M5] = "m5",
1643 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001644};
1645
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001646static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001647 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1648 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1649 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1650 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001651 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001652 /* Not sure about the brand name for those */
1653 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1654 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1655 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1656 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001657 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001658};
1659
1660static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1661 /* SigmaTel reference board */
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001663 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001664 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001665
1666 /* Default table for unknown ID */
1667 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1668
Tobin Davis8e21c342007-01-08 11:04:17 +01001669 {} /* terminator */
1670};
1671
Matthew Ranostaya7662642008-02-21 07:51:14 +01001672static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001673 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1674 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1675 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001676 0x01452050,
1677};
1678
1679static unsigned int dell_m6_pin_configs[13] = {
1680 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001681 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001682 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1683 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001684};
1685
1686static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001687 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001688 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1689 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1690 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001691 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001692};
1693
1694static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001695 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001696 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001697 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1698 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1699 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001700 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001701};
1702
1703static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1704 /* SigmaTel reference board */
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001706 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001707 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1708 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001710 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001712 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001714 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001716 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001718 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001720 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001722 "unknown Dell", STAC_DELL_M6_DMIC),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1724 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001726 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1728 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001729 {} /* terminator */
1730};
1731
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001732static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001733 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1734 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001735 0x01451160, 0x98560170,
1736};
1737
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001738static unsigned int dell_s14_pin_configs[10] = {
1739 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1740 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1741 0x40f000f0, 0x40f000f0,
1742};
1743
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001744static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1745 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001746 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001747 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001748};
1749
1750static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1751 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001752 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001753 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001754};
1755
1756static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1757 /* SigmaTel reference board */
1758 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001759 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001760 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1761 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001762 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1763 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001764 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001765};
1766
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001767static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001768 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001769 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001770 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1771 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001772};
1773
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001774static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001775 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001776 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001777 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1778 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001779};
1780
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001781static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001782 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1783 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001784 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1785 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001786};
1787
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001788static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001789 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1790 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001791 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1792 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001793};
1794
Matthew Ranostaye035b842007-11-06 11:53:55 +01001795static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1796 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001797 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1798 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001799 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001800 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001801 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001802};
1803
1804static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1805 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001806 [STAC_DELL_M4_1] = "dell-m4-1",
1807 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001808 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001809 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001810 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001811};
1812
1813static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1814 /* SigmaTel reference board */
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1816 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001817 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1818 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001819 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1820 "HP dv4-7", STAC_HP_DV5),
1821 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1822 "HP dv4-7", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001823 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001824 "HP mini 1000", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1830 "unknown Dell", STAC_DELL_M4_1),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1832 "unknown Dell", STAC_DELL_M4_1),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1834 "unknown Dell", STAC_DELL_M4_1),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1836 "unknown Dell", STAC_DELL_M4_1),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1838 "unknown Dell", STAC_DELL_M4_1),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1840 "unknown Dell", STAC_DELL_M4_2),
1841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1842 "unknown Dell", STAC_DELL_M4_2),
1843 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1844 "unknown Dell", STAC_DELL_M4_2),
1845 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1846 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001847 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1848 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001849 {} /* terminator */
1850};
1851
Matt Porter403d1942005-11-29 15:00:51 +01001852static unsigned int ref922x_pin_configs[10] = {
1853 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1854 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001855 0x40000100, 0x40000100,
1856};
1857
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001858/*
1859 STAC 922X pin configs for
1860 102801A7
1861 102801AB
1862 102801A9
1863 102801D1
1864 102801D2
1865*/
1866static unsigned int dell_922x_d81_pin_configs[10] = {
1867 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1868 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1869 0x01813122, 0x400001f2,
1870};
1871
1872/*
1873 STAC 922X pin configs for
1874 102801AC
1875 102801D0
1876*/
1877static unsigned int dell_922x_d82_pin_configs[10] = {
1878 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1879 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1880 0x01813122, 0x400001f1,
1881};
1882
1883/*
1884 STAC 922X pin configs for
1885 102801BF
1886*/
1887static unsigned int dell_922x_m81_pin_configs[10] = {
1888 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1889 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1890 0x40C003f1, 0x405003f0,
1891};
1892
1893/*
1894 STAC 9221 A1 pin configs for
1895 102801D7 (Dell XPS M1210)
1896*/
1897static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001898 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1899 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001900 0x508003f3, 0x405003f4,
1901};
1902
Matt Porter403d1942005-11-29 15:00:51 +01001903static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001904 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001905 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1906 0x02a19120, 0x40000100,
1907};
1908
1909static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001910 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1911 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001912 0x02a19320, 0x40000100,
1913};
1914
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001915static unsigned int intel_mac_v1_pin_configs[10] = {
1916 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1917 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001918 0x400000fc, 0x400000fb,
1919};
1920
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001921static unsigned int intel_mac_v2_pin_configs[10] = {
1922 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1923 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001924 0x400000fc, 0x400000fb,
1925};
1926
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001927static unsigned int intel_mac_v3_pin_configs[10] = {
1928 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1929 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1930 0x400000fc, 0x400000fb,
1931};
1932
1933static unsigned int intel_mac_v4_pin_configs[10] = {
1934 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1935 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1936 0x400000fc, 0x400000fb,
1937};
1938
1939static unsigned int intel_mac_v5_pin_configs[10] = {
1940 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1941 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1942 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001943};
1944
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001945static unsigned int ecs202_pin_configs[10] = {
1946 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1947 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1948 0x9037012e, 0x40e000f2,
1949};
Takashi Iwai76c08822007-06-19 12:17:42 +02001950
Takashi Iwai19039bd2006-06-28 15:52:16 +02001951static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001952 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001953 [STAC_D945GTP3] = d945gtp3_pin_configs,
1954 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001955 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1956 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1957 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1958 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1959 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001960 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001961 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001962 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1963 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1964 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1965 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1966 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1967 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001968 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001969 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1970 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1971 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1972 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001973};
1974
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001975static const char *stac922x_models[STAC_922X_MODELS] = {
1976 [STAC_D945_REF] = "ref",
1977 [STAC_D945GTP5] = "5stack",
1978 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001979 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1980 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1981 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1982 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1983 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001984 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001985 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001986 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001987 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001988 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1989 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001990 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001991 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001992 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001993 [STAC_922X_DELL_D81] = "dell-d81",
1994 [STAC_922X_DELL_D82] = "dell-d82",
1995 [STAC_922X_DELL_M81] = "dell-m81",
1996 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001997};
1998
1999static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2000 /* SigmaTel reference board */
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2002 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002003 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2004 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002005 /* Intel 945G based systems */
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2033 "Intel D945G", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2035 "Intel D945G", STAC_D945GTP3),
2036 /* Intel D945G 5-stack systems */
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2038 "Intel D945G", STAC_D945GTP5),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2040 "Intel D945G", STAC_D945GTP5),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2042 "Intel D945G", STAC_D945GTP5),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2044 "Intel D945G", STAC_D945GTP5),
2045 /* Intel 945P based systems */
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2047 "Intel D945P", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2049 "Intel D945P", STAC_D945GTP3),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2051 "Intel D945P", STAC_D945GTP3),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2053 "Intel D945P", STAC_D945GTP3),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2055 "Intel D945P", STAC_D945GTP3),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2057 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002058 /* other intel */
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2060 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002061 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002062 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002063 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002064 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002065 /* Dell systems */
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2067 "unknown Dell", STAC_922X_DELL_D81),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2069 "unknown Dell", STAC_922X_DELL_D81),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2071 "unknown Dell", STAC_922X_DELL_D81),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2073 "unknown Dell", STAC_922X_DELL_D82),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2075 "unknown Dell", STAC_922X_DELL_M81),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2077 "unknown Dell", STAC_922X_DELL_D82),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2079 "unknown Dell", STAC_922X_DELL_D81),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2081 "unknown Dell", STAC_922X_DELL_D81),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2083 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002084 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002085 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002086 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002087 {} /* terminator */
2088};
2089
Matt Porter3cc08dc2006-01-23 15:27:49 +01002090static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002091 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2092 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2093 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2094 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002095};
2096
Tobin Davis93ed1502006-09-01 21:03:12 +02002097static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002098 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2099 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2100 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2101 0x40000100, 0x40000100
2102};
2103
Tobin Davis93ed1502006-09-01 21:03:12 +02002104static unsigned int d965_5st_pin_configs[14] = {
2105 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2106 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2107 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2108 0x40000100, 0x40000100
2109};
2110
Tobin Davis4ff076e2007-08-07 11:48:12 +02002111static unsigned int dell_3st_pin_configs[14] = {
2112 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2113 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002114 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002115 0x40c003fc, 0x40000100
2116};
2117
Tobin Davis93ed1502006-09-01 21:03:12 +02002118static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002119 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002120 [STAC_D965_REF] = ref927x_pin_configs,
2121 [STAC_D965_3ST] = d965_3st_pin_configs,
2122 [STAC_D965_5ST] = d965_5st_pin_configs,
2123 [STAC_DELL_3ST] = dell_3st_pin_configs,
2124 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002125};
2126
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002127static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002128 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002129 [STAC_D965_REF] = "ref",
2130 [STAC_D965_3ST] = "3stack",
2131 [STAC_D965_5ST] = "5stack",
2132 [STAC_DELL_3ST] = "dell-3stack",
2133 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002134};
2135
2136static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2137 /* SigmaTel reference board */
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2139 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002140 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2141 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002142 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002145 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002146 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2147 "Intel D965", STAC_D965_3ST),
2148 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2149 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002150 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002155 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002164 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002165 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2166 "Intel D965", STAC_D965_5ST),
2167 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2168 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002169 {} /* terminator */
2170};
2171
Matt Porterf3302a52006-07-31 12:49:34 +02002172static unsigned int ref9205_pin_configs[12] = {
2173 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002174 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002175 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002176};
2177
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002178/*
2179 STAC 9205 pin configs for
2180 102801F1
2181 102801F2
2182 102801FC
2183 102801FD
2184 10280204
2185 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002186 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002187*/
2188static unsigned int dell_9205_m42_pin_configs[12] = {
2189 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2190 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2191 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2192};
2193
2194/*
2195 STAC 9205 pin configs for
2196 102801F9
2197 102801FA
2198 102801FE
2199 102801FF (Dell Precision M4300)
2200 10280206
2201 10280200
2202 10280201
2203*/
2204static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002205 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2206 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2207 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2208};
2209
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002210static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002211 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2212 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2213 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2214};
2215
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002216static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002217 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002218 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2219 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2220 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002221 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002222};
2223
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002224static const char *stac9205_models[STAC_9205_MODELS] = {
2225 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002226 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002227 [STAC_9205_DELL_M43] = "dell-m43",
2228 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002229 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002230};
2231
2232static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2233 /* SigmaTel reference board */
2234 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2235 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002236 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2237 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002238 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002239 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2240 "unknown Dell", STAC_9205_DELL_M42),
2241 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2242 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002243 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002244 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002245 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2246 "Dell Precision", STAC_9205_DELL_M43),
2247 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2248 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002249 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2250 "unknown Dell", STAC_9205_DELL_M42),
2251 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2252 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2254 "Dell Precision", STAC_9205_DELL_M43),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002256 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2258 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2260 "Dell Precision", STAC_9205_DELL_M43),
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2262 "Dell Precision", STAC_9205_DELL_M43),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2264 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2266 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2268 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002269 /* Gateway */
2270 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002271 {} /* terminator */
2272};
2273
Takashi Iwai330ee992009-02-20 14:33:36 +01002274static void stac92xx_set_config_regs(struct hda_codec *codec,
2275 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002276{
2277 int i;
2278 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002279
Takashi Iwai330ee992009-02-20 14:33:36 +01002280 if (!pincfgs)
2281 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002282
Matthew Ranostay87d48362007-07-17 11:52:24 +02002283 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002284 if (spec->pin_nids[i] && pincfgs[i])
2285 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2286 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002287}
2288
Matt2f2f4252005-04-13 14:45:30 +02002289/*
2290 * Analog playback callbacks
2291 */
2292static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2293 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002294 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002295{
2296 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002297 if (spec->stream_delay)
2298 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002299 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2300 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002301}
2302
2303static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2304 struct hda_codec *codec,
2305 unsigned int stream_tag,
2306 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002307 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002308{
2309 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002310 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002311}
2312
2313static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2314 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002315 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002316{
2317 struct sigmatel_spec *spec = codec->spec;
2318 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2319}
2320
2321/*
Mattdabbed62005-06-14 10:19:34 +02002322 * Digital playback callbacks
2323 */
2324static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002326 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002327{
2328 struct sigmatel_spec *spec = codec->spec;
2329 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2330}
2331
2332static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2333 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002334 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002335{
2336 struct sigmatel_spec *spec = codec->spec;
2337 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2338}
2339
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002340static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
2342 unsigned int stream_tag,
2343 unsigned int format,
2344 struct snd_pcm_substream *substream)
2345{
2346 struct sigmatel_spec *spec = codec->spec;
2347 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2348 stream_tag, format, substream);
2349}
2350
Takashi Iwai9411e212009-02-13 11:32:28 +01002351static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
2353 struct snd_pcm_substream *substream)
2354{
2355 struct sigmatel_spec *spec = codec->spec;
2356 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2357}
2358
Mattdabbed62005-06-14 10:19:34 +02002359
2360/*
Matt2f2f4252005-04-13 14:45:30 +02002361 * Analog capture callbacks
2362 */
2363static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2364 struct hda_codec *codec,
2365 unsigned int stream_tag,
2366 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002367 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002368{
2369 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002370 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002371
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002372 if (spec->powerdown_adcs) {
2373 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002374 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002375 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2376 }
2377 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002378 return 0;
2379}
2380
2381static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2382 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002383 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002384{
2385 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002386 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002387
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002388 snd_hda_codec_cleanup_stream(codec, nid);
2389 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002390 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002391 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002392 return 0;
2393}
2394
Mattdabbed62005-06-14 10:19:34 +02002395static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2396 .substreams = 1,
2397 .channels_min = 2,
2398 .channels_max = 2,
2399 /* NID is set in stac92xx_build_pcms */
2400 .ops = {
2401 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002402 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002403 .prepare = stac92xx_dig_playback_pcm_prepare,
2404 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002405 },
2406};
2407
2408static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2409 .substreams = 1,
2410 .channels_min = 2,
2411 .channels_max = 2,
2412 /* NID is set in stac92xx_build_pcms */
2413};
2414
Matt2f2f4252005-04-13 14:45:30 +02002415static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2416 .substreams = 1,
2417 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002418 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002419 .nid = 0x02, /* NID to query formats and rates */
2420 .ops = {
2421 .open = stac92xx_playback_pcm_open,
2422 .prepare = stac92xx_playback_pcm_prepare,
2423 .cleanup = stac92xx_playback_pcm_cleanup
2424 },
2425};
2426
Matt Porter3cc08dc2006-01-23 15:27:49 +01002427static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2428 .substreams = 1,
2429 .channels_min = 2,
2430 .channels_max = 2,
2431 .nid = 0x06, /* NID to query formats and rates */
2432 .ops = {
2433 .open = stac92xx_playback_pcm_open,
2434 .prepare = stac92xx_playback_pcm_prepare,
2435 .cleanup = stac92xx_playback_pcm_cleanup
2436 },
2437};
2438
Matt2f2f4252005-04-13 14:45:30 +02002439static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002440 .channels_min = 2,
2441 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002442 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002443 .ops = {
2444 .prepare = stac92xx_capture_pcm_prepare,
2445 .cleanup = stac92xx_capture_pcm_cleanup
2446 },
2447};
2448
2449static int stac92xx_build_pcms(struct hda_codec *codec)
2450{
2451 struct sigmatel_spec *spec = codec->spec;
2452 struct hda_pcm *info = spec->pcm_rec;
2453
2454 codec->num_pcms = 1;
2455 codec->pcm_info = info;
2456
Mattc7d4b2f2005-06-27 14:59:41 +02002457 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002458 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002459 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2460 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002461 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002462 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002463 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002464
2465 if (spec->alt_switch) {
2466 codec->num_pcms++;
2467 info++;
2468 info->name = "STAC92xx Analog Alt";
2469 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2470 }
Matt2f2f4252005-04-13 14:45:30 +02002471
Mattdabbed62005-06-14 10:19:34 +02002472 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2473 codec->num_pcms++;
2474 info++;
2475 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002476 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002477 if (spec->multiout.dig_out_nid) {
2478 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2480 }
2481 if (spec->dig_in_nid) {
2482 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2483 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2484 }
2485 }
2486
Matt2f2f4252005-04-13 14:45:30 +02002487 return 0;
2488}
2489
Takashi Iwaic960a032006-03-23 17:06:28 +01002490static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2491{
2492 unsigned int pincap = snd_hda_param_read(codec, nid,
2493 AC_PAR_PIN_CAP);
2494 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2495 if (pincap & AC_PINCAP_VREF_100)
2496 return AC_PINCTL_VREF_100;
2497 if (pincap & AC_PINCAP_VREF_80)
2498 return AC_PINCTL_VREF_80;
2499 if (pincap & AC_PINCAP_VREF_50)
2500 return AC_PINCTL_VREF_50;
2501 if (pincap & AC_PINCAP_VREF_GRD)
2502 return AC_PINCTL_VREF_GRD;
2503 return 0;
2504}
2505
Matt Porter403d1942005-11-29 15:00:51 +01002506static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2507
2508{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002509 snd_hda_codec_write_cache(codec, nid, 0,
2510 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002511}
2512
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002513#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2514
2515static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2516 struct snd_ctl_elem_value *ucontrol)
2517{
2518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2519 struct sigmatel_spec *spec = codec->spec;
2520
Takashi Iwaid7a89432008-11-12 09:48:04 +01002521 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002522 return 0;
2523}
2524
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002525static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2526 unsigned char type);
2527
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002528static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2529 struct snd_ctl_elem_value *ucontrol)
2530{
2531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2532 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002533 int nid = kcontrol->private_value;
2534
2535 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002536
2537 /* check to be sure that the ports are upto date with
2538 * switch changes
2539 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002540 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002541
2542 return 1;
2543}
2544
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002545#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002546
2547static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2548{
2549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2550 struct sigmatel_spec *spec = codec->spec;
2551 int io_idx = kcontrol-> private_value & 0xff;
2552
2553 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2554 return 0;
2555}
2556
2557static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2558{
2559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2560 struct sigmatel_spec *spec = codec->spec;
2561 hda_nid_t nid = kcontrol->private_value >> 8;
2562 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002563 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002564
2565 spec->io_switch[io_idx] = val;
2566
2567 if (val)
2568 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002569 else {
2570 unsigned int pinctl = AC_PINCTL_IN_EN;
2571 if (io_idx) /* set VREF for mic */
2572 pinctl |= stac92xx_get_vref(codec, nid);
2573 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2574 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002575
2576 /* check the auto-mute again: we need to mute/unmute the speaker
2577 * appropriately according to the pin direction
2578 */
2579 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002580 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002581
Matt Porter403d1942005-11-29 15:00:51 +01002582 return 1;
2583}
2584
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002585#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2586
2587static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2588 struct snd_ctl_elem_value *ucontrol)
2589{
2590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2591 struct sigmatel_spec *spec = codec->spec;
2592
2593 ucontrol->value.integer.value[0] = spec->clfe_swap;
2594 return 0;
2595}
2596
2597static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2598 struct snd_ctl_elem_value *ucontrol)
2599{
2600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2601 struct sigmatel_spec *spec = codec->spec;
2602 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002603 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002604
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002605 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002606 return 0;
2607
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002608 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002609
2610 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2611 spec->clfe_swap ? 0x4 : 0x0);
2612
2613 return 1;
2614}
2615
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002616#define STAC_CODEC_HP_SWITCH(xname) \
2617 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2618 .name = xname, \
2619 .index = 0, \
2620 .info = stac92xx_hp_switch_info, \
2621 .get = stac92xx_hp_switch_get, \
2622 .put = stac92xx_hp_switch_put, \
2623 }
2624
Matt Porter403d1942005-11-29 15:00:51 +01002625#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2626 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2627 .name = xname, \
2628 .index = 0, \
2629 .info = stac92xx_io_switch_info, \
2630 .get = stac92xx_io_switch_get, \
2631 .put = stac92xx_io_switch_put, \
2632 .private_value = xpval, \
2633 }
2634
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002635#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2636 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2637 .name = xname, \
2638 .index = 0, \
2639 .info = stac92xx_clfe_switch_info, \
2640 .get = stac92xx_clfe_switch_get, \
2641 .put = stac92xx_clfe_switch_put, \
2642 .private_value = xpval, \
2643 }
Matt Porter403d1942005-11-29 15:00:51 +01002644
Mattc7d4b2f2005-06-27 14:59:41 +02002645enum {
2646 STAC_CTL_WIDGET_VOL,
2647 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002648 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002649 STAC_CTL_WIDGET_AMP_MUX,
2650 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002651 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002652 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002653 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002654};
2655
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002656static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002657 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2658 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002659 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002660 STAC_AMP_MUX,
2661 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002662 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002663 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002664 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002665};
2666
2667/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002668static struct snd_kcontrol_new *
2669stac_control_new(struct sigmatel_spec *spec,
2670 struct snd_kcontrol_new *ktemp,
2671 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002672{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002673 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002674
Takashi Iwai603c4012008-07-30 15:01:44 +02002675 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2676 knew = snd_array_new(&spec->kctls);
2677 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002678 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002679 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002680 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002681 if (!knew->name) {
2682 /* roolback */
2683 memset(knew, 0, sizeof(*knew));
2684 spec->kctls.alloced--;
2685 return NULL;
2686 }
2687 return knew;
2688}
2689
2690static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2691 struct snd_kcontrol_new *ktemp,
2692 int idx, const char *name,
2693 unsigned long val)
2694{
2695 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2696 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002697 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002698 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002699 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002700 return 0;
2701}
2702
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002703static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2704 int type, int idx, const char *name,
2705 unsigned long val)
2706{
2707 return stac92xx_add_control_temp(spec,
2708 &stac92xx_control_templates[type],
2709 idx, name, val);
2710}
2711
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002712
2713/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002714static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2715 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002716{
2717 return stac92xx_add_control_idx(spec, type, 0, name, val);
2718}
2719
Takashi Iwaie3c75962009-01-23 11:57:22 +01002720static struct snd_kcontrol_new stac_input_src_temp = {
2721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2722 .name = "Input Source",
2723 .info = stac92xx_mux_enum_info,
2724 .get = stac92xx_mux_enum_get,
2725 .put = stac92xx_mux_enum_put,
2726};
2727
2728static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2729{
2730 struct snd_kcontrol_new *knew;
2731 struct hda_input_mux *imux = &spec->private_imux;
2732
2733 if (!spec->num_adcs || imux->num_items <= 1)
2734 return 0; /* no need for input source control */
2735 knew = stac_control_new(spec, &stac_input_src_temp,
2736 stac_input_src_temp.name);
2737 if (!knew)
2738 return -ENOMEM;
2739 knew->count = spec->num_adcs;
2740 return 0;
2741}
2742
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002743/* check whether the line-input can be used as line-out */
2744static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002745{
2746 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002747 struct auto_pin_cfg *cfg = &spec->autocfg;
2748 hda_nid_t nid;
2749 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002750
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002751 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2752 return 0;
2753 nid = cfg->input_pins[AUTO_PIN_LINE];
2754 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2755 if (pincap & AC_PINCAP_OUT)
2756 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002757 return 0;
2758}
2759
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002760/* check whether the mic-input can be used as line-out */
2761static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2762{
2763 struct sigmatel_spec *spec = codec->spec;
2764 struct auto_pin_cfg *cfg = &spec->autocfg;
2765 unsigned int def_conf, pincap;
2766 unsigned int mic_pin;
2767
2768 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2769 return 0;
2770 mic_pin = AUTO_PIN_MIC;
2771 for (;;) {
2772 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002773 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002774 /* some laptops have an internal analog microphone
2775 * which can't be used as a output */
2776 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2777 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2778 if (pincap & AC_PINCAP_OUT)
2779 return nid;
2780 }
2781 if (mic_pin == AUTO_PIN_MIC)
2782 mic_pin = AUTO_PIN_FRONT_MIC;
2783 else
2784 break;
2785 }
2786 return 0;
2787}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002788
2789static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2790{
2791 int i;
2792
2793 for (i = 0; i < spec->multiout.num_dacs; i++) {
2794 if (spec->multiout.dac_nids[i] == nid)
2795 return 1;
2796 }
2797
2798 return 0;
2799}
2800
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002801static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2802{
2803 int i;
2804 if (is_in_dac_nids(spec, nid))
2805 return 1;
2806 for (i = 0; i < spec->autocfg.hp_outs; i++)
2807 if (spec->hp_dacs[i] == nid)
2808 return 1;
2809 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2810 if (spec->speaker_dacs[i] == nid)
2811 return 1;
2812 return 0;
2813}
2814
2815static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2816{
2817 struct sigmatel_spec *spec = codec->spec;
2818 int j, conn_len;
2819 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2820 unsigned int wcaps, wtype;
2821
2822 conn_len = snd_hda_get_connections(codec, nid, conn,
2823 HDA_MAX_CONNECTIONS);
2824 for (j = 0; j < conn_len; j++) {
2825 wcaps = snd_hda_param_read(codec, conn[j],
2826 AC_PAR_AUDIO_WIDGET_CAP);
2827 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2828 /* we check only analog outputs */
2829 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2830 continue;
2831 /* if this route has a free DAC, assign it */
2832 if (!check_all_dac_nids(spec, conn[j])) {
2833 if (conn_len > 1) {
2834 /* select this DAC in the pin's input mux */
2835 snd_hda_codec_write_cache(codec, nid, 0,
2836 AC_VERB_SET_CONNECT_SEL, j);
2837 }
2838 return conn[j];
2839 }
2840 }
2841 return 0;
2842}
2843
2844static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2845static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2846
Matt Porter3cc08dc2006-01-23 15:27:49 +01002847/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002848 * Fill in the dac_nids table from the parsed pin configuration
2849 * This function only works when every pin in line_out_pins[]
2850 * contains atleast one DAC in its connection list. Some 92xx
2851 * codecs are not connected directly to a DAC, such as the 9200
2852 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002853 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002854static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002855{
2856 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002857 struct auto_pin_cfg *cfg = &spec->autocfg;
2858 int i;
2859 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002860
Mattc7d4b2f2005-06-27 14:59:41 +02002861 for (i = 0; i < cfg->line_outs; i++) {
2862 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002863 dac = get_unassigned_dac(codec, nid);
2864 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002865 if (spec->multiout.num_dacs > 0) {
2866 /* we have already working output pins,
2867 * so let's drop the broken ones again
2868 */
2869 cfg->line_outs = spec->multiout.num_dacs;
2870 break;
2871 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002872 /* error out, no available DAC found */
2873 snd_printk(KERN_ERR
2874 "%s: No available DAC for pin 0x%x\n",
2875 __func__, nid);
2876 return -ENODEV;
2877 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002878 add_spec_dacs(spec, dac);
2879 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002880
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002881 /* add line-in as output */
2882 nid = check_line_out_switch(codec);
2883 if (nid) {
2884 dac = get_unassigned_dac(codec, nid);
2885 if (dac) {
2886 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2887 nid, cfg->line_outs);
2888 cfg->line_out_pins[cfg->line_outs] = nid;
2889 cfg->line_outs++;
2890 spec->line_switch = nid;
2891 add_spec_dacs(spec, dac);
2892 }
2893 }
2894 /* add mic as output */
2895 nid = check_mic_out_switch(codec);
2896 if (nid) {
2897 dac = get_unassigned_dac(codec, nid);
2898 if (dac) {
2899 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2900 nid, cfg->line_outs);
2901 cfg->line_out_pins[cfg->line_outs] = nid;
2902 cfg->line_outs++;
2903 spec->mic_switch = nid;
2904 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002905 }
Mattc7d4b2f2005-06-27 14:59:41 +02002906 }
2907
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002908 for (i = 0; i < cfg->hp_outs; i++) {
2909 nid = cfg->hp_pins[i];
2910 dac = get_unassigned_dac(codec, nid);
2911 if (dac) {
2912 if (!spec->multiout.hp_nid)
2913 spec->multiout.hp_nid = dac;
2914 else
2915 add_spec_extra_dacs(spec, dac);
2916 }
2917 spec->hp_dacs[i] = dac;
2918 }
2919
2920 for (i = 0; i < cfg->speaker_outs; i++) {
2921 nid = cfg->speaker_pins[i];
2922 dac = get_unassigned_dac(codec, nid);
2923 if (dac)
2924 add_spec_extra_dacs(spec, dac);
2925 spec->speaker_dacs[i] = dac;
2926 }
2927
2928 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02002929 spec->multiout.num_dacs,
2930 spec->multiout.dac_nids[0],
2931 spec->multiout.dac_nids[1],
2932 spec->multiout.dac_nids[2],
2933 spec->multiout.dac_nids[3],
2934 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002935
Mattc7d4b2f2005-06-27 14:59:41 +02002936 return 0;
2937}
2938
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002939/* create volume control/switch for the given prefx type */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002940static int create_controls(struct hda_codec *codec, const char *pfx,
2941 hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002942{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002943 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002944 char name[32];
2945 int err;
2946
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002947 if (!spec->check_volume_offset) {
2948 unsigned int caps, step, nums, db_scale;
2949 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2950 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2951 AC_AMPCAP_STEP_SIZE_SHIFT;
2952 step = (step + 1) * 25; /* in .01dB unit */
2953 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2954 AC_AMPCAP_NUM_STEPS_SHIFT;
2955 db_scale = nums * step;
2956 /* if dB scale is over -64dB, and finer enough,
2957 * let's reduce it to half
2958 */
2959 if (db_scale > 6400 && nums >= 0x1f)
2960 spec->volume_offset = nums / 2;
2961 spec->check_volume_offset = 1;
2962 }
2963
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002964 sprintf(name, "%s Playback Volume", pfx);
2965 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01002966 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2967 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002968 if (err < 0)
2969 return err;
2970 sprintf(name, "%s Playback Switch", pfx);
2971 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2972 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2973 if (err < 0)
2974 return err;
2975 return 0;
2976}
2977
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002978static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2979{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002980 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002981 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2982 return 1;
2983 } else {
2984 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2985 spec->multiout.num_dacs++;
2986 }
2987 return 0;
2988}
2989
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002990static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002991{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002992 int i;
2993 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
2994 if (!spec->multiout.extra_out_nid[i]) {
2995 spec->multiout.extra_out_nid[i] = nid;
2996 return 0;
2997 }
2998 }
2999 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3000 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003001}
3002
Takashi Iwai76624532008-12-19 10:09:47 +01003003static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3004{
3005 int i;
3006
3007 if (spec->autocfg.line_outs != 1)
3008 return 0;
3009 if (spec->multiout.hp_nid == nid)
3010 return 0;
3011 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3012 if (spec->multiout.extra_out_nid[i] == nid)
3013 return 0;
3014 return 1;
3015}
3016
Mattc7d4b2f2005-06-27 14:59:41 +02003017/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003018static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003019 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003020{
Takashi Iwai76624532008-12-19 10:09:47 +01003021 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003022 static const char *chname[4] = {
3023 "Front", "Surround", NULL /*CLFE*/, "Side"
3024 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003025 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003026 int i, err;
3027 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003028
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003029 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003030 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003031 if (i == 2) {
3032 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003033 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003034 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003035 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003036 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003037 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003038 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003039
3040 wid_caps = get_wcaps(codec, nid);
3041
3042 if (wid_caps & AC_WCAP_LR_SWAP) {
3043 err = stac92xx_add_control(spec,
3044 STAC_CTL_WIDGET_CLFE_SWITCH,
3045 "Swap Center/LFE Playback Switch", nid);
3046
3047 if (err < 0)
3048 return err;
3049 }
3050
Mattc7d4b2f2005-06-27 14:59:41 +02003051 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003052 const char *name = chname[i];
3053 /* if it's a single DAC, assign a better name */
3054 if (!i && is_unique_dac(spec, nid)) {
3055 switch (cfg->line_out_type) {
3056 case AUTO_PIN_HP_OUT:
3057 name = "Headphone";
3058 break;
3059 case AUTO_PIN_SPEAKER_OUT:
3060 name = "Speaker";
3061 break;
3062 }
3063 }
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003064 err = create_controls(codec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003065 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003066 return err;
3067 }
3068 }
3069
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003070 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003071 err = stac92xx_add_control(spec,
3072 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003073 "Headphone as Line Out Switch",
3074 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003075 if (err < 0)
3076 return err;
3077 }
3078
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003079 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003080 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3081 "Line In as Output Switch",
3082 spec->line_switch << 8);
3083 if (err < 0)
3084 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003085 }
Matt Porter403d1942005-11-29 15:00:51 +01003086
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003087 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003088 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3089 "Mic as Output Switch",
3090 (spec->mic_switch << 8) | 1);
3091 if (err < 0)
3092 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003093 }
Matt Porter403d1942005-11-29 15:00:51 +01003094
Mattc7d4b2f2005-06-27 14:59:41 +02003095 return 0;
3096}
3097
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003098/* add playback controls for Speaker and HP outputs */
3099static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3100 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003101{
3102 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003103 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003104 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003105
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003106 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003107 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003108 static const char *pfxs[] = {
3109 "Headphone", "Headphone2", "Headphone3",
3110 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003111 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3112 if (wid_caps & AC_WCAP_UNSOL_CAP)
3113 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003114 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003115 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003116 nid = spec->hp_dacs[i];
3117 if (!nid)
3118 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003119 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003120 if (err < 0)
3121 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003122 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003123 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003124 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003125 static const char *pfxs[] = {
3126 "Speaker", "External Speaker", "Speaker2",
3127 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003128 if (nums >= ARRAY_SIZE(pfxs))
3129 continue;
3130 nid = spec->speaker_dacs[i];
3131 if (!nid)
3132 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003133 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003134 if (err < 0)
3135 return err;
3136 }
Mattc7d4b2f2005-06-27 14:59:41 +02003137 return 0;
3138}
3139
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003140/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003141static const char *stac92xx_mono_labels[4] = {
3142 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003143};
3144
3145/* create mono mux for mono out on capable codecs */
3146static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3147{
3148 struct sigmatel_spec *spec = codec->spec;
3149 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3150 int i, num_cons;
3151 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3152
3153 num_cons = snd_hda_get_connections(codec,
3154 spec->mono_nid,
3155 con_lst,
3156 HDA_MAX_NUM_INPUTS);
3157 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3158 return -EINVAL;
3159
3160 for (i = 0; i < num_cons; i++) {
3161 mono_mux->items[mono_mux->num_items].label =
3162 stac92xx_mono_labels[i];
3163 mono_mux->items[mono_mux->num_items].index = i;
3164 mono_mux->num_items++;
3165 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003166
3167 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3168 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003169}
3170
Matthew Ranostay89385032008-09-11 09:49:39 -04003171/* labels for amp mux outputs */
3172static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003173 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003174};
3175
3176/* create amp out controls mux on capable codecs */
3177static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3178{
3179 struct sigmatel_spec *spec = codec->spec;
3180 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3181 int i, err;
3182
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003183 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003184 amp_mux->items[amp_mux->num_items].label =
3185 stac92xx_amp_labels[i];
3186 amp_mux->items[amp_mux->num_items].index = i;
3187 amp_mux->num_items++;
3188 }
3189
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003190 if (spec->num_amps > 1) {
3191 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3192 "Amp Selector Capture Switch", 0);
3193 if (err < 0)
3194 return err;
3195 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003196 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3197 "Amp Capture Volume",
3198 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3199}
3200
3201
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003202/* create PC beep volume controls */
3203static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3204 hda_nid_t nid)
3205{
3206 struct sigmatel_spec *spec = codec->spec;
3207 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3208 int err;
3209
3210 /* check for mute support for the the amp */
3211 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3212 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3213 "PC Beep Playback Switch",
3214 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3215 if (err < 0)
3216 return err;
3217 }
3218
3219 /* check to see if there is volume support for the amp */
3220 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3221 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3222 "PC Beep Playback Volume",
3223 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3224 if (err < 0)
3225 return err;
3226 }
3227 return 0;
3228}
3229
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003230#ifdef CONFIG_SND_HDA_INPUT_BEEP
3231#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3232
3233static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3234 struct snd_ctl_elem_value *ucontrol)
3235{
3236 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3237 ucontrol->value.integer.value[0] = codec->beep->enabled;
3238 return 0;
3239}
3240
3241static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3242 struct snd_ctl_elem_value *ucontrol)
3243{
3244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3245 int enabled = !!ucontrol->value.integer.value[0];
3246 if (codec->beep->enabled != enabled) {
3247 codec->beep->enabled = enabled;
3248 return 1;
3249 }
3250 return 0;
3251}
3252
3253static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3255 .info = stac92xx_dig_beep_switch_info,
3256 .get = stac92xx_dig_beep_switch_get,
3257 .put = stac92xx_dig_beep_switch_put,
3258};
3259
3260static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3261{
3262 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3263 0, "PC Beep Playback Switch", 0);
3264}
3265#endif
3266
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003267static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3268{
3269 struct sigmatel_spec *spec = codec->spec;
3270 int wcaps, nid, i, err = 0;
3271
3272 for (i = 0; i < spec->num_muxes; i++) {
3273 nid = spec->mux_nids[i];
3274 wcaps = get_wcaps(codec, nid);
3275
3276 if (wcaps & AC_WCAP_OUT_AMP) {
3277 err = stac92xx_add_control_idx(spec,
3278 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3279 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3280 if (err < 0)
3281 return err;
3282 }
3283 }
3284 return 0;
3285};
3286
Matthew Ranostayd9737752008-09-07 12:03:41 +02003287static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003288 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003289};
3290
3291static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3292{
3293 struct sigmatel_spec *spec = codec->spec;
3294 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003295 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003296 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003297 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003298
3299 num_cons = snd_hda_get_connections(codec,
3300 spec->smux_nids[0],
3301 con_lst,
3302 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003303 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003304 return -EINVAL;
3305
Matthew Ranostay65973632008-09-16 10:39:37 -04003306 if (!labels)
3307 labels = stac92xx_spdif_labels;
3308
Matthew Ranostayd9737752008-09-07 12:03:41 +02003309 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003310 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003311 spdif_mux->items[spdif_mux->num_items].index = i;
3312 spdif_mux->num_items++;
3313 }
3314
3315 return 0;
3316}
3317
Matt Porter8b657272006-10-26 17:12:59 +02003318/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003319static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003320 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3321 "Digital Mic 3", "Digital Mic 4"
3322};
3323
3324/* create playback/capture controls for input pins on dmic capable codecs */
3325static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3326 const struct auto_pin_cfg *cfg)
3327{
3328 struct sigmatel_spec *spec = codec->spec;
3329 struct hda_input_mux *dimux = &spec->private_dimux;
3330 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003331 int err, i, j;
3332 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003333
3334 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3335 dimux->items[dimux->num_items].index = 0;
3336 dimux->num_items++;
3337
3338 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003339 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003340 int index;
3341 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003342 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003343 unsigned int def_conf;
3344
Takashi Iwai330ee992009-02-20 14:33:36 +01003345 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003346 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3347 continue;
3348
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003349 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003350 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003351 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003352 con_lst,
3353 HDA_MAX_NUM_INPUTS);
3354 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003355 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003356 index = j;
3357 goto found;
3358 }
3359 continue;
3360found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003361 wcaps = get_wcaps(codec, nid) &
3362 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003363
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003364 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003365 sprintf(name, "%s Capture Volume",
3366 stac92xx_dmic_labels[dimux->num_items]);
3367
3368 err = stac92xx_add_control(spec,
3369 STAC_CTL_WIDGET_VOL,
3370 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003371 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3372 (wcaps & AC_WCAP_OUT_AMP) ?
3373 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003374 if (err < 0)
3375 return err;
3376 }
3377
Matt Porter8b657272006-10-26 17:12:59 +02003378 dimux->items[dimux->num_items].label =
3379 stac92xx_dmic_labels[dimux->num_items];
3380 dimux->items[dimux->num_items].index = index;
3381 dimux->num_items++;
3382 }
3383
3384 return 0;
3385}
3386
Mattc7d4b2f2005-06-27 14:59:41 +02003387/* create playback/capture controls for input pins */
3388static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3389{
3390 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003391 struct hda_input_mux *imux = &spec->private_imux;
3392 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3393 int i, j, k;
3394
3395 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003396 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003397
Takashi Iwai314634b2006-09-21 11:56:18 +02003398 if (!cfg->input_pins[i])
3399 continue;
3400 index = -1;
3401 for (j = 0; j < spec->num_muxes; j++) {
3402 int num_cons;
3403 num_cons = snd_hda_get_connections(codec,
3404 spec->mux_nids[j],
3405 con_lst,
3406 HDA_MAX_NUM_INPUTS);
3407 for (k = 0; k < num_cons; k++)
3408 if (con_lst[k] == cfg->input_pins[i]) {
3409 index = k;
3410 goto found;
3411 }
Mattc7d4b2f2005-06-27 14:59:41 +02003412 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003413 continue;
3414 found:
3415 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3416 imux->items[imux->num_items].index = index;
3417 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003418 }
3419
Steve Longerbeam7b043892007-05-03 20:50:03 +02003420 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003421 /*
3422 * Set the current input for the muxes.
3423 * The STAC9221 has two input muxes with identical source
3424 * NID lists. Hopefully this won't get confused.
3425 */
3426 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003427 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3428 AC_VERB_SET_CONNECT_SEL,
3429 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003430 }
3431 }
3432
Mattc7d4b2f2005-06-27 14:59:41 +02003433 return 0;
3434}
3435
Mattc7d4b2f2005-06-27 14:59:41 +02003436static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3437{
3438 struct sigmatel_spec *spec = codec->spec;
3439 int i;
3440
3441 for (i = 0; i < spec->autocfg.line_outs; i++) {
3442 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3443 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3444 }
3445}
3446
3447static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3448{
3449 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003450 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003451
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003452 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3453 hda_nid_t pin;
3454 pin = spec->autocfg.hp_pins[i];
3455 if (pin) /* connect to front */
3456 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3457 }
3458 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3459 hda_nid_t pin;
3460 pin = spec->autocfg.speaker_pins[i];
3461 if (pin) /* connect to front */
3462 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3463 }
Mattc7d4b2f2005-06-27 14:59:41 +02003464}
3465
Matt Porter3cc08dc2006-01-23 15:27:49 +01003466static 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 +02003467{
3468 struct sigmatel_spec *spec = codec->spec;
3469 int err;
3470
Matt Porter8b657272006-10-26 17:12:59 +02003471 if ((err = snd_hda_parse_pin_def_config(codec,
3472 &spec->autocfg,
3473 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003474 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003475 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003476 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003477
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003478 /* If we have no real line-out pin and multiple hp-outs, HPs should
3479 * be set up as multi-channel outputs.
3480 */
3481 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3482 spec->autocfg.hp_outs > 1) {
3483 /* Copy hp_outs to line_outs, backup line_outs in
3484 * speaker_outs so that the following routines can handle
3485 * HP pins as primary outputs.
3486 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003487 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003488 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3489 sizeof(spec->autocfg.line_out_pins));
3490 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3491 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3492 sizeof(spec->autocfg.hp_pins));
3493 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003494 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3495 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003496 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003497 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003498 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3499 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003500 u32 caps = query_amp_caps(codec,
3501 spec->autocfg.mono_out_pin, dir);
3502 hda_nid_t conn_list[1];
3503
3504 /* get the mixer node and then the mono mux if it exists */
3505 if (snd_hda_get_connections(codec,
3506 spec->autocfg.mono_out_pin, conn_list, 1) &&
3507 snd_hda_get_connections(codec, conn_list[0],
3508 conn_list, 1)) {
3509
3510 int wcaps = get_wcaps(codec, conn_list[0]);
3511 int wid_type = (wcaps & AC_WCAP_TYPE)
3512 >> AC_WCAP_TYPE_SHIFT;
3513 /* LR swap check, some stac925x have a mux that
3514 * changes the DACs output path instead of the
3515 * mono-mux path.
3516 */
3517 if (wid_type == AC_WID_AUD_SEL &&
3518 !(wcaps & AC_WCAP_LR_SWAP))
3519 spec->mono_nid = conn_list[0];
3520 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003521 if (dir) {
3522 hda_nid_t nid = spec->autocfg.mono_out_pin;
3523
3524 /* most mono outs have a least a mute/unmute switch */
3525 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3526 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3527 "Mono Playback Switch",
3528 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003529 if (err < 0)
3530 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003531 /* check for volume support for the amp */
3532 if ((caps & AC_AMPCAP_NUM_STEPS)
3533 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3534 err = stac92xx_add_control(spec,
3535 STAC_CTL_WIDGET_VOL,
3536 "Mono Playback Volume",
3537 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3538 if (err < 0)
3539 return err;
3540 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003541 }
3542
3543 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3544 AC_PINCTL_OUT_EN);
3545 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003546
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003547 if (!spec->multiout.num_dacs) {
3548 err = stac92xx_auto_fill_dac_nids(codec);
3549 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003550 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003551 err = stac92xx_auto_create_multi_out_ctls(codec,
3552 &spec->autocfg);
3553 if (err < 0)
3554 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003555 }
Mattc7d4b2f2005-06-27 14:59:41 +02003556
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003557 /* setup analog beep controls */
3558 if (spec->anabeep_nid > 0) {
3559 err = stac92xx_auto_create_beep_ctls(codec,
3560 spec->anabeep_nid);
3561 if (err < 0)
3562 return err;
3563 }
3564
3565 /* setup digital beep controls and input device */
3566#ifdef CONFIG_SND_HDA_INPUT_BEEP
3567 if (spec->digbeep_nid > 0) {
3568 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003569 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003570
3571 err = stac92xx_auto_create_beep_ctls(codec, nid);
3572 if (err < 0)
3573 return err;
3574 err = snd_hda_attach_beep_device(codec, nid);
3575 if (err < 0)
3576 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003577 /* if no beep switch is available, make its own one */
3578 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3579 if (codec->beep &&
3580 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3581 err = stac92xx_beep_switch_ctl(codec);
3582 if (err < 0)
3583 return err;
3584 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003585 }
3586#endif
3587
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003588 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3589
3590 if (err < 0)
3591 return err;
3592
3593 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3594
3595 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003596 return err;
3597
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003598 if (spec->mono_nid > 0) {
3599 err = stac92xx_auto_create_mono_output_ctls(codec);
3600 if (err < 0)
3601 return err;
3602 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003603 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003604 err = stac92xx_auto_create_amp_output_ctls(codec);
3605 if (err < 0)
3606 return err;
3607 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003608 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003609 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3610 &spec->autocfg)) < 0)
3611 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003612 if (spec->num_muxes > 0) {
3613 err = stac92xx_auto_create_mux_input_ctls(codec);
3614 if (err < 0)
3615 return err;
3616 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003617 if (spec->num_smuxes > 0) {
3618 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3619 if (err < 0)
3620 return err;
3621 }
Matt Porter8b657272006-10-26 17:12:59 +02003622
Takashi Iwaie3c75962009-01-23 11:57:22 +01003623 err = stac92xx_add_input_source(spec);
3624 if (err < 0)
3625 return err;
3626
Mattc7d4b2f2005-06-27 14:59:41 +02003627 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003628 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003629 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003630
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003631 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003632 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003633 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003634 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003635
Takashi Iwai603c4012008-07-30 15:01:44 +02003636 if (spec->kctls.list)
3637 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003638
3639 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003640 if (!spec->dinput_mux)
3641 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003642 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003643 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003644 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003645 return 1;
3646}
3647
Takashi Iwai82bc9552006-03-21 11:24:42 +01003648/* add playback controls for HP output */
3649static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3650 struct auto_pin_cfg *cfg)
3651{
3652 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003653 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003654 unsigned int wid_caps;
3655
3656 if (! pin)
3657 return 0;
3658
3659 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003660 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003661 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003662
3663 return 0;
3664}
3665
Richard Fish160ea0d2006-09-06 13:58:25 +02003666/* add playback controls for LFE output */
3667static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3668 struct auto_pin_cfg *cfg)
3669{
3670 struct sigmatel_spec *spec = codec->spec;
3671 int err;
3672 hda_nid_t lfe_pin = 0x0;
3673 int i;
3674
3675 /*
3676 * search speaker outs and line outs for a mono speaker pin
3677 * with an amp. If one is found, add LFE controls
3678 * for it.
3679 */
3680 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3681 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003682 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003683 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3684 if (wcaps == AC_WCAP_OUT_AMP)
3685 /* found a mono speaker with an amp, must be lfe */
3686 lfe_pin = pin;
3687 }
3688
3689 /* if speaker_outs is 0, then speakers may be in line_outs */
3690 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3691 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3692 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003693 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003694 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003695 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003696 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003697 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3698 if (wcaps == AC_WCAP_OUT_AMP)
3699 /* found a mono speaker with an amp,
3700 must be lfe */
3701 lfe_pin = pin;
3702 }
3703 }
3704 }
3705
3706 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003707 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003708 if (err < 0)
3709 return err;
3710 }
3711
3712 return 0;
3713}
3714
Mattc7d4b2f2005-06-27 14:59:41 +02003715static int stac9200_parse_auto_config(struct hda_codec *codec)
3716{
3717 struct sigmatel_spec *spec = codec->spec;
3718 int err;
3719
Kailang Yangdf694da2005-12-05 19:42:22 +01003720 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003721 return err;
3722
3723 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3724 return err;
3725
Takashi Iwai82bc9552006-03-21 11:24:42 +01003726 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3727 return err;
3728
Richard Fish160ea0d2006-09-06 13:58:25 +02003729 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3730 return err;
3731
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003732 if (spec->num_muxes > 0) {
3733 err = stac92xx_auto_create_mux_input_ctls(codec);
3734 if (err < 0)
3735 return err;
3736 }
3737
Takashi Iwaie3c75962009-01-23 11:57:22 +01003738 err = stac92xx_add_input_source(spec);
3739 if (err < 0)
3740 return err;
3741
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003742 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003743 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003744 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003745 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003746
Takashi Iwai603c4012008-07-30 15:01:44 +02003747 if (spec->kctls.list)
3748 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003749
3750 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003751 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003752
3753 return 1;
3754}
3755
Sam Revitch62fe78e2006-05-10 15:09:17 +02003756/*
3757 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3758 * funky external mute control using GPIO pins.
3759 */
3760
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003761static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003762 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003763{
3764 unsigned int gpiostate, gpiomask, gpiodir;
3765
3766 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3767 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003768 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003769
3770 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3771 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003772 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003773
3774 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3775 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003776 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003777
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003778 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003779 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3780
3781 snd_hda_codec_write(codec, codec->afg, 0,
3782 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003783 snd_hda_codec_read(codec, codec->afg, 0,
3784 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003785
3786 msleep(1);
3787
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003788 snd_hda_codec_read(codec, codec->afg, 0,
3789 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003790}
3791
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003792static int stac92xx_add_jack(struct hda_codec *codec,
3793 hda_nid_t nid, int type)
3794{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003795#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003796 struct sigmatel_spec *spec = codec->spec;
3797 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01003798 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003799 int connectivity = get_defcfg_connect(def_conf);
3800 char name[32];
3801
3802 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3803 return 0;
3804
3805 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3806 jack = snd_array_new(&spec->jacks);
3807 if (!jack)
3808 return -ENOMEM;
3809 jack->nid = nid;
3810 jack->type = type;
3811
3812 sprintf(name, "%s at %s %s Jack",
3813 snd_hda_get_jack_type(def_conf),
3814 snd_hda_get_jack_connectivity(def_conf),
3815 snd_hda_get_jack_location(def_conf));
3816
3817 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003818#else
3819 return 0;
3820#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003821}
3822
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003823static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3824 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003825{
3826 struct sigmatel_event *event;
3827
3828 snd_array_init(&spec->events, sizeof(*event), 32);
3829 event = snd_array_new(&spec->events);
3830 if (!event)
3831 return -ENOMEM;
3832 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003833 event->type = type;
3834 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003835 event->data = data;
3836
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003837 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003838}
3839
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003840static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3841 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003842{
3843 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003844 struct sigmatel_event *event = spec->events.list;
3845 int i;
3846
3847 for (i = 0; i < spec->events.used; i++, event++) {
3848 if (event->nid == nid && event->type == type)
3849 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003850 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003851 return NULL;
3852}
3853
3854static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3855 unsigned char tag)
3856{
3857 struct sigmatel_spec *spec = codec->spec;
3858 struct sigmatel_event *event = spec->events.list;
3859 int i;
3860
3861 for (i = 0; i < spec->events.used; i++, event++) {
3862 if (event->tag == tag)
3863 return event;
3864 }
3865 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003866}
3867
Takashi Iwai314634b2006-09-21 11:56:18 +02003868static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003869 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003870{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003871 struct sigmatel_event *event;
3872 int tag;
3873
3874 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3875 return;
3876 event = stac_get_event(codec, nid, type);
3877 if (event)
3878 tag = event->tag;
3879 else
3880 tag = stac_add_event(codec->spec, nid, type, 0);
3881 if (tag < 0)
3882 return;
3883 snd_hda_codec_write_cache(codec, nid, 0,
3884 AC_VERB_SET_UNSOLICITED_ENABLE,
3885 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003886}
3887
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003888static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3889{
3890 int i;
3891 for (i = 0; i < cfg->hp_outs; i++)
3892 if (cfg->hp_pins[i] == nid)
3893 return 1; /* nid is a HP-Out */
3894
3895 return 0; /* nid is not a HP-Out */
3896};
3897
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003898static void stac92xx_power_down(struct hda_codec *codec)
3899{
3900 struct sigmatel_spec *spec = codec->spec;
3901
3902 /* power down inactive DACs */
3903 hda_nid_t *dac;
3904 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003905 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003906 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003907 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3908}
3909
Takashi Iwaif73d3582008-11-25 08:21:51 +01003910static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3911 int enable);
3912
Mattc7d4b2f2005-06-27 14:59:41 +02003913static int stac92xx_init(struct hda_codec *codec)
3914{
3915 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003916 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003917 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003918 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003919
Mattc7d4b2f2005-06-27 14:59:41 +02003920 snd_hda_sequence_write(codec, spec->init);
3921
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003922 /* power down adcs initially */
3923 if (spec->powerdown_adcs)
3924 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003925 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003926 spec->adc_nids[i], 0,
3927 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003928
3929 /* set up GPIO */
3930 gpio = spec->gpio_data;
3931 /* turn on EAPD statically when spec->eapd_switch isn't set.
3932 * otherwise, unsol event will turn it on/off dynamically
3933 */
3934 if (!spec->eapd_switch)
3935 gpio |= spec->eapd_mask;
3936 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3937
Takashi Iwai82bc9552006-03-21 11:24:42 +01003938 /* set up pins */
3939 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003940 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003941 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003942 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003943 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003944 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003945 /* force to enable the first line-out; the others are set up
3946 * in unsol_event
3947 */
3948 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003949 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003950 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003951 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3952 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003953 } else {
3954 stac92xx_auto_init_multi_out(codec);
3955 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003956 for (i = 0; i < cfg->hp_outs; i++)
3957 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003958 }
3959 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003960 hda_nid_t nid = cfg->input_pins[i];
3961 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003962 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003963 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3964 /* for mic pins, force to initialize */
3965 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003966 pinctl |= AC_PINCTL_IN_EN;
3967 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003968 } else {
3969 pinctl = snd_hda_codec_read(codec, nid, 0,
3970 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3971 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003972 if (!(pinctl & AC_PINCTL_IN_EN)) {
3973 pinctl |= AC_PINCTL_IN_EN;
3974 stac92xx_auto_set_pinctl(codec, nid,
3975 pinctl);
3976 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003977 }
Takashi Iwai330ee992009-02-20 14:33:36 +01003978 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01003979 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
3980 enable_pin_detect(codec, nid,
3981 STAC_INSERT_EVENT);
3982 stac_issue_unsol_event(codec, nid,
3983 STAC_INSERT_EVENT);
3984 }
Takashi Iwaic960a032006-03-23 17:06:28 +01003985 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003986 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003987 for (i = 0; i < spec->num_dmics; i++)
3988 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3989 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003990 if (cfg->dig_out_pins[0])
3991 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01003992 AC_PINCTL_OUT_EN);
3993 if (cfg->dig_in_pin)
3994 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3995 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003996 for (i = 0; i < spec->num_pwrs; i++) {
3997 hda_nid_t nid = spec->pwr_nids[i];
3998 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003999
Takashi Iwaieb632122008-12-19 16:39:48 +01004000 /* power on when no jack detection is available */
4001 if (!spec->hp_detect) {
4002 stac_toggle_power_map(codec, nid, 1);
4003 continue;
4004 }
4005
4006 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004007 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004008
Takashi Iwaif73d3582008-11-25 08:21:51 +01004009 pinctl = snd_hda_codec_read(codec, nid, 0,
4010 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4011 /* outputs are only ports capable of power management
4012 * any attempts on powering down a input port cause the
4013 * referenced VREF to act quirky.
4014 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004015 if (pinctl & AC_PINCTL_IN_EN) {
4016 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004017 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004018 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004019 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004020 def_conf = get_defcfg_connect(def_conf);
4021 /* skip any ports that don't have jacks since presence
4022 * detection is useless */
4023 if (def_conf != AC_JACK_PORT_COMPLEX) {
4024 if (def_conf != AC_JACK_PORT_NONE)
4025 stac_toggle_power_map(codec, nid, 1);
4026 continue;
4027 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004028 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4029 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4030 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4031 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004032 }
4033 if (spec->dac_list)
4034 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004035 return 0;
4036}
4037
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004038static void stac92xx_free_jacks(struct hda_codec *codec)
4039{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004040#ifdef CONFIG_SND_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004041 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004042 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004043 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004044 struct sigmatel_jack *jacks = spec->jacks.list;
4045 int i;
4046 for (i = 0; i < spec->jacks.used; i++)
4047 snd_device_free(codec->bus->card, &jacks[i].jack);
4048 }
4049 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004050#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004051}
4052
Takashi Iwai603c4012008-07-30 15:01:44 +02004053static void stac92xx_free_kctls(struct hda_codec *codec)
4054{
4055 struct sigmatel_spec *spec = codec->spec;
4056
4057 if (spec->kctls.list) {
4058 struct snd_kcontrol_new *kctl = spec->kctls.list;
4059 int i;
4060 for (i = 0; i < spec->kctls.used; i++)
4061 kfree(kctl[i].name);
4062 }
4063 snd_array_free(&spec->kctls);
4064}
4065
Matt2f2f4252005-04-13 14:45:30 +02004066static void stac92xx_free(struct hda_codec *codec)
4067{
Mattc7d4b2f2005-06-27 14:59:41 +02004068 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004069
4070 if (! spec)
4071 return;
4072
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004073 stac92xx_free_jacks(codec);
4074 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004075
Mattc7d4b2f2005-06-27 14:59:41 +02004076 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004077 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004078}
4079
Matt4e550962005-07-04 17:51:39 +02004080static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4081 unsigned int flag)
4082{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004083 unsigned int old_ctl, pin_ctl;
4084
4085 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004086 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004087
Takashi Iwaif9acba42007-05-29 18:01:06 +02004088 if (pin_ctl & AC_PINCTL_IN_EN) {
4089 /*
4090 * we need to check the current set-up direction of
4091 * shared input pins since they can be switched via
4092 * "xxx as Output" mixer switch
4093 */
4094 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004095 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004096 return;
4097 }
4098
Takashi Iwai8ce84192009-01-22 16:59:20 +01004099 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004100 /* if setting pin direction bits, clear the current
4101 direction bits first */
4102 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4103 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4104
Takashi Iwai8ce84192009-01-22 16:59:20 +01004105 pin_ctl |= flag;
4106 if (old_ctl != pin_ctl)
4107 snd_hda_codec_write_cache(codec, nid, 0,
4108 AC_VERB_SET_PIN_WIDGET_CONTROL,
4109 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004110}
4111
4112static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4113 unsigned int flag)
4114{
4115 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4116 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004117 if (pin_ctl & flag)
4118 snd_hda_codec_write_cache(codec, nid, 0,
4119 AC_VERB_SET_PIN_WIDGET_CONTROL,
4120 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004121}
4122
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004123static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004124{
4125 if (!nid)
4126 return 0;
4127 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004128 & (1 << 31))
4129 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004130 return 0;
4131}
4132
Takashi Iwaid7a89432008-11-12 09:48:04 +01004133/* return non-zero if the hp-pin of the given array index isn't
4134 * a jack-detection target
4135 */
4136static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4137{
4138 struct auto_pin_cfg *cfg = &spec->autocfg;
4139
4140 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004141 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004142 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004143 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004144 return 1;
4145 /* ignore if the pin is set as line-out */
4146 if (cfg->hp_pins[i] == spec->hp_switch)
4147 return 1;
4148 return 0;
4149}
4150
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004151static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004152{
4153 struct sigmatel_spec *spec = codec->spec;
4154 struct auto_pin_cfg *cfg = &spec->autocfg;
4155 int i, presence;
4156
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004157 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004158 if (spec->gpio_mute)
4159 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4160 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4161
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004162 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004163 if (presence)
4164 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004165 if (no_hp_sensing(spec, i))
4166 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004167 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4168 if (presence) {
4169 unsigned int pinctl;
4170 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4171 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4172 if (pinctl & AC_PINCTL_IN_EN)
4173 presence = 0; /* mic- or line-input */
4174 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004175 }
Matt4e550962005-07-04 17:51:39 +02004176
4177 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004178 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004179 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004180 stac92xx_reset_pinctl(codec, spec->hp_switch,
4181 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004182 for (i = 0; i < cfg->line_outs; i++)
4183 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4184 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004185 for (i = 0; i < cfg->speaker_outs; i++)
4186 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4187 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004188 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004189 stac_gpio_set(codec, spec->gpio_mask,
4190 spec->gpio_dir, spec->gpio_data &
4191 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004192 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004193 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004194 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004195 stac92xx_set_pinctl(codec, spec->hp_switch,
4196 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004197 for (i = 0; i < cfg->line_outs; i++)
4198 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4199 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004200 for (i = 0; i < cfg->speaker_outs; i++)
4201 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4202 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004203 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004204 stac_gpio_set(codec, spec->gpio_mask,
4205 spec->gpio_dir, spec->gpio_data |
4206 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004207 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004208 /* toggle hp outs */
4209 for (i = 0; i < cfg->hp_outs; i++) {
4210 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4211 if (no_hp_sensing(spec, i))
4212 continue;
4213 if (presence)
4214 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004215#if 0 /* FIXME */
4216/* Resetting the pinctl like below may lead to (a sort of) regressions
4217 * on some devices since they use the HP pin actually for line/speaker
4218 * outs although the default pin config shows a different pin (that is
4219 * wrong and useless).
4220 *
4221 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4222 * But, disabling the code below just works around it, and I'm too tired of
4223 * bug reports with such devices...
4224 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004225 else
4226 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004227#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004228 }
Matt4e550962005-07-04 17:51:39 +02004229}
4230
Takashi Iwaif73d3582008-11-25 08:21:51 +01004231static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4232 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004233{
4234 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004235 unsigned int idx, val;
4236
4237 for (idx = 0; idx < spec->num_pwrs; idx++) {
4238 if (spec->pwr_nids[idx] == nid)
4239 break;
4240 }
4241 if (idx >= spec->num_pwrs)
4242 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004243
4244 /* several codecs have two power down bits */
4245 if (spec->pwr_mapping)
4246 idx = spec->pwr_mapping[idx];
4247 else
4248 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004249
Takashi Iwaif73d3582008-11-25 08:21:51 +01004250 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4251 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004252 val &= ~idx;
4253 else
4254 val |= idx;
4255
4256 /* power down unused output ports */
4257 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004258}
4259
Takashi Iwaif73d3582008-11-25 08:21:51 +01004260static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4261{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004262 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004263}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004264
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004265static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4266{
4267 struct sigmatel_spec *spec = codec->spec;
4268 struct sigmatel_jack *jacks = spec->jacks.list;
4269
4270 if (jacks) {
4271 int i;
4272 for (i = 0; i < spec->jacks.used; i++) {
4273 if (jacks->nid == nid) {
4274 unsigned int pin_ctl =
4275 snd_hda_codec_read(codec, nid,
4276 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4277 0x00);
4278 int type = jacks->type;
4279 if (type == (SND_JACK_LINEOUT
4280 | SND_JACK_HEADPHONE))
4281 type = (pin_ctl & AC_PINCTL_HP_EN)
4282 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4283 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004284 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004285 ? type : 0);
4286 }
4287 jacks++;
4288 }
4289 }
4290}
Matt2f2f4252005-04-13 14:45:30 +02004291
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004292static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4293 unsigned char type)
4294{
4295 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4296 if (!event)
4297 return;
4298 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4299}
4300
Takashi Iwai314634b2006-09-21 11:56:18 +02004301static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4302{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004303 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004304 struct sigmatel_event *event;
4305 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004306
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004307 tag = (res >> 26) & 0x7f;
4308 event = stac_get_event_from_tag(codec, tag);
4309 if (!event)
4310 return;
4311
4312 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004313 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004314 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004315 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004316 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004317 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004318 if (spec->num_pwrs > 0)
4319 stac92xx_pin_sense(codec, event->nid);
4320 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004321 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004322 case STAC_VREF_EVENT:
4323 data = snd_hda_codec_read(codec, codec->afg, 0,
4324 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004325 /* toggle VREF state based on GPIOx status */
4326 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004327 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004328 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004329 }
4330}
4331
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004332#ifdef CONFIG_PROC_FS
4333static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4334 struct hda_codec *codec, hda_nid_t nid)
4335{
4336 if (nid == codec->afg)
4337 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4338 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4339}
4340
4341static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4342 struct hda_codec *codec,
4343 unsigned int verb)
4344{
4345 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4346 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4347}
4348
4349/* stac92hd71bxx, stac92hd73xx */
4350static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4351 struct hda_codec *codec, hda_nid_t nid)
4352{
4353 stac92hd_proc_hook(buffer, codec, nid);
4354 if (nid == codec->afg)
4355 analog_loop_proc_hook(buffer, codec, 0xfa0);
4356}
4357
4358static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4359 struct hda_codec *codec, hda_nid_t nid)
4360{
4361 if (nid == codec->afg)
4362 analog_loop_proc_hook(buffer, codec, 0xfe0);
4363}
4364
4365static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4366 struct hda_codec *codec, hda_nid_t nid)
4367{
4368 if (nid == codec->afg)
4369 analog_loop_proc_hook(buffer, codec, 0xfeb);
4370}
4371#else
4372#define stac92hd_proc_hook NULL
4373#define stac92hd7x_proc_hook NULL
4374#define stac9205_proc_hook NULL
4375#define stac927x_proc_hook NULL
4376#endif
4377
Takashi Iwaicb53c622007-08-10 17:21:45 +02004378#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004379static int stac92xx_resume(struct hda_codec *codec)
4380{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004381 struct sigmatel_spec *spec = codec->spec;
4382
Takashi Iwai2c885872008-11-18 09:36:55 +01004383 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004384 snd_hda_codec_resume_amp(codec);
4385 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004386 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004387 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004388 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4389 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004390 return 0;
4391}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004392
4393static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4394{
4395 struct sigmatel_spec *spec = codec->spec;
4396 if (spec->eapd_mask)
4397 stac_gpio_set(codec, spec->gpio_mask,
4398 spec->gpio_dir, spec->gpio_data &
4399 ~spec->eapd_mask);
4400 return 0;
4401}
Mattff6fdc32005-06-27 15:06:52 +02004402#endif
4403
Matt2f2f4252005-04-13 14:45:30 +02004404static struct hda_codec_ops stac92xx_patch_ops = {
4405 .build_controls = stac92xx_build_controls,
4406 .build_pcms = stac92xx_build_pcms,
4407 .init = stac92xx_init,
4408 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004409 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004410#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004411 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004412 .resume = stac92xx_resume,
4413#endif
Matt2f2f4252005-04-13 14:45:30 +02004414};
4415
4416static int patch_stac9200(struct hda_codec *codec)
4417{
4418 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004419 int err;
Matt2f2f4252005-04-13 14:45:30 +02004420
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004421 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004422 if (spec == NULL)
4423 return -ENOMEM;
4424
4425 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004426 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004427 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004428 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4429 stac9200_models,
4430 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004431 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02004432 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004433 else
4434 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004435 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004436
4437 spec->multiout.max_channels = 2;
4438 spec->multiout.num_dacs = 1;
4439 spec->multiout.dac_nids = stac9200_dac_nids;
4440 spec->adc_nids = stac9200_adc_nids;
4441 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004442 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004443 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004444 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004445 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004446
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004447 if (spec->board_config == STAC_9200_M4 ||
4448 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004449 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004450 spec->init = stac9200_eapd_init;
4451 else
4452 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004453 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004454
Takashi Iwai117f2572008-03-18 09:53:23 +01004455 if (spec->board_config == STAC_9200_PANASONIC) {
4456 spec->gpio_mask = spec->gpio_dir = 0x09;
4457 spec->gpio_data = 0x00;
4458 }
4459
Mattc7d4b2f2005-06-27 14:59:41 +02004460 err = stac9200_parse_auto_config(codec);
4461 if (err < 0) {
4462 stac92xx_free(codec);
4463 return err;
4464 }
Matt2f2f4252005-04-13 14:45:30 +02004465
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004466 /* CF-74 has no headphone detection, and the driver should *NOT*
4467 * do detection and HP/speaker toggle because the hardware does it.
4468 */
4469 if (spec->board_config == STAC_9200_PANASONIC)
4470 spec->hp_detect = 0;
4471
Matt2f2f4252005-04-13 14:45:30 +02004472 codec->patch_ops = stac92xx_patch_ops;
4473
4474 return 0;
4475}
4476
Tobin Davis8e21c342007-01-08 11:04:17 +01004477static int patch_stac925x(struct hda_codec *codec)
4478{
4479 struct sigmatel_spec *spec;
4480 int err;
4481
4482 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4483 if (spec == NULL)
4484 return -ENOMEM;
4485
4486 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004487 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004488 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004489
4490 /* Check first for codec ID */
4491 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4492 STAC_925x_MODELS,
4493 stac925x_models,
4494 stac925x_codec_id_cfg_tbl);
4495
4496 /* Now checks for PCI ID, if codec ID is not found */
4497 if (spec->board_config < 0)
4498 spec->board_config = snd_hda_check_board_config(codec,
4499 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004500 stac925x_models,
4501 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004502 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004503 if (spec->board_config < 0)
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004504 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004505 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004506 else
4507 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004508 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004509
4510 spec->multiout.max_channels = 2;
4511 spec->multiout.num_dacs = 1;
4512 spec->multiout.dac_nids = stac925x_dac_nids;
4513 spec->adc_nids = stac925x_adc_nids;
4514 spec->mux_nids = stac925x_mux_nids;
4515 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004516 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004517 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004518 switch (codec->vendor_id) {
4519 case 0x83847632: /* STAC9202 */
4520 case 0x83847633: /* STAC9202D */
4521 case 0x83847636: /* STAC9251 */
4522 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004523 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004524 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004525 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4526 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004527 break;
4528 default:
4529 spec->num_dmics = 0;
4530 break;
4531 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004532
4533 spec->init = stac925x_core_init;
4534 spec->mixer = stac925x_mixer;
4535
4536 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004537 if (!err) {
4538 if (spec->board_config < 0) {
4539 printk(KERN_WARNING "hda_codec: No auto-config is "
4540 "available, default to model=ref\n");
4541 spec->board_config = STAC_925x_REF;
4542 goto again;
4543 }
4544 err = -EINVAL;
4545 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004546 if (err < 0) {
4547 stac92xx_free(codec);
4548 return err;
4549 }
4550
4551 codec->patch_ops = stac92xx_patch_ops;
4552
4553 return 0;
4554}
4555
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004556static struct hda_input_mux stac92hd73xx_dmux = {
4557 .num_items = 4,
4558 .items = {
4559 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004560 { "Digital Mic 1", 0x09 },
4561 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004562 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004563 }
4564};
4565
4566static int patch_stac92hd73xx(struct hda_codec *codec)
4567{
4568 struct sigmatel_spec *spec;
4569 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4570 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004571 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004572
4573 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4574 if (spec == NULL)
4575 return -ENOMEM;
4576
4577 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004578 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004579 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4580 spec->pin_nids = stac92hd73xx_pin_nids;
4581 spec->board_config = snd_hda_check_board_config(codec,
4582 STAC_92HD73XX_MODELS,
4583 stac92hd73xx_models,
4584 stac92hd73xx_cfg_tbl);
4585again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004586 if (spec->board_config < 0)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004587 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4588 " STAC92HD73XX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004589 else
4590 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004591 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004592
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004593 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004594 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4595
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004596 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004597 printk(KERN_WARNING "hda_codec: Could not determine "
4598 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004599 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004600 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004601 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004602 case 0x3: /* 6 Channel */
4603 spec->mixer = stac92hd73xx_6ch_mixer;
4604 spec->init = stac92hd73xx_6ch_core_init;
4605 break;
4606 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004607 spec->mixer = stac92hd73xx_8ch_mixer;
4608 spec->init = stac92hd73xx_8ch_core_init;
4609 break;
4610 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004611 spec->mixer = stac92hd73xx_10ch_mixer;
4612 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004613 }
4614 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004615
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004616 spec->aloopback_mask = 0x01;
4617 spec->aloopback_shift = 8;
4618
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004619 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004620 spec->mux_nids = stac92hd73xx_mux_nids;
4621 spec->adc_nids = stac92hd73xx_adc_nids;
4622 spec->dmic_nids = stac92hd73xx_dmic_nids;
4623 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004624 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004625 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004626 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004627
4628 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4629 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004630 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004631 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4632 sizeof(stac92hd73xx_dmux));
4633
Matthew Ranostaya7662642008-02-21 07:51:14 +01004634 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004635 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004636 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004637 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004638 case STAC_DELL_M6_AMIC:
4639 case STAC_DELL_M6_DMIC:
4640 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004641 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004642 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4643 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004644 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004645 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004646
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004647 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004648 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004649 switch (spec->board_config) {
4650 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004651 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004652 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004653 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004654 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004655 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01004656 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004657 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004658 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004659 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004660 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01004661 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4662 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004663 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004664 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004665 break;
4666 }
4667 break;
4668 default:
4669 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004670 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004671 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004672 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004673 if (spec->board_config > STAC_92HD73XX_REF) {
4674 /* GPIO0 High = Enable EAPD */
4675 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4676 spec->gpio_data = 0x01;
4677 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004678 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004679
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004680 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4681 spec->pwr_nids = stac92hd73xx_pwr_nids;
4682
Matthew Ranostayd9737752008-09-07 12:03:41 +02004683 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004684
4685 if (!err) {
4686 if (spec->board_config < 0) {
4687 printk(KERN_WARNING "hda_codec: No auto-config is "
4688 "available, default to model=ref\n");
4689 spec->board_config = STAC_92HD73XX_REF;
4690 goto again;
4691 }
4692 err = -EINVAL;
4693 }
4694
4695 if (err < 0) {
4696 stac92xx_free(codec);
4697 return err;
4698 }
4699
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004700 if (spec->board_config == STAC_92HD73XX_NO_JD)
4701 spec->hp_detect = 0;
4702
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004703 codec->patch_ops = stac92xx_patch_ops;
4704
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004705 codec->proc_widget_hook = stac92hd7x_proc_hook;
4706
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004707 return 0;
4708}
4709
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004710static struct hda_input_mux stac92hd83xxx_dmux = {
4711 .num_items = 3,
4712 .items = {
4713 { "Analog Inputs", 0x03 },
4714 { "Digital Mic 1", 0x04 },
4715 { "Digital Mic 2", 0x05 },
4716 }
4717};
4718
4719static int patch_stac92hd83xxx(struct hda_codec *codec)
4720{
4721 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004722 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004723 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004724 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004725 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004726
4727 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4728 if (spec == NULL)
4729 return -ENOMEM;
4730
4731 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004732 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004733 spec->mono_nid = 0x19;
4734 spec->digbeep_nid = 0x21;
4735 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4736 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4737 spec->adc_nids = stac92hd83xxx_adc_nids;
4738 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004739 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004740 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4741 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004742 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004743
4744 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004745 spec->mixer = stac92hd83xxx_mixer;
4746 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4747 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4748 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004749 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004750 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4751 spec->dinput_mux = &stac92hd83xxx_dmux;
4752 spec->pin_nids = stac92hd83xxx_pin_nids;
4753 spec->board_config = snd_hda_check_board_config(codec,
4754 STAC_92HD83XXX_MODELS,
4755 stac92hd83xxx_models,
4756 stac92hd83xxx_cfg_tbl);
4757again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004758 if (spec->board_config < 0)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004759 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4760 " STAC92HD83XXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004761 else
4762 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004763 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004764
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05004765 switch (codec->vendor_id) {
4766 case 0x111d7604:
4767 case 0x111d7605:
4768 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4769 break;
4770 spec->num_pwrs = 0;
4771 break;
4772 }
4773
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004774 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4775 if (!err) {
4776 if (spec->board_config < 0) {
4777 printk(KERN_WARNING "hda_codec: No auto-config is "
4778 "available, default to model=ref\n");
4779 spec->board_config = STAC_92HD83XXX_REF;
4780 goto again;
4781 }
4782 err = -EINVAL;
4783 }
4784
4785 if (err < 0) {
4786 stac92xx_free(codec);
4787 return err;
4788 }
4789
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05004790 switch (spec->board_config) {
4791 case STAC_DELL_S14:
4792 nid = 0xf;
4793 break;
4794 default:
4795 nid = 0xe;
4796 break;
4797 }
4798
4799 num_dacs = snd_hda_get_connections(codec, nid,
4800 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4801
4802 /* set port X to select the last DAC
4803 */
4804 snd_hda_codec_write_cache(codec, nid, 0,
4805 AC_VERB_SET_CONNECT_SEL, num_dacs);
4806
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004807 codec->patch_ops = stac92xx_patch_ops;
4808
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004809 codec->proc_widget_hook = stac92hd_proc_hook;
4810
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004811 return 0;
4812}
4813
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004814static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4815 .num_items = 3,
4816 .items = {
4817 { "Analog Inputs", 0x00 },
4818 { "Digital Mic 1", 0x02 },
4819 { "Digital Mic 2", 0x03 },
4820 }
4821};
4822
4823static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004824 .num_items = 4,
4825 .items = {
4826 { "Analog Inputs", 0x00 },
4827 { "Mixer", 0x01 },
4828 { "Digital Mic 1", 0x02 },
4829 { "Digital Mic 2", 0x03 },
4830 }
4831};
4832
Takashi Iwai330ee992009-02-20 14:33:36 +01004833/* get the pin connection (fixed, none, etc) */
4834static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4835{
4836 struct sigmatel_spec *spec = codec->spec;
4837 unsigned int cfg;
4838
4839 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4840 return get_defcfg_connect(cfg);
4841}
4842
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004843static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
4844 hda_nid_t *nids, int num_nids)
4845{
4846 struct sigmatel_spec *spec = codec->spec;
4847 int idx, num;
4848 unsigned int def_conf;
4849
4850 for (num = 0; num < num_nids; num++) {
4851 for (idx = 0; idx < spec->num_pins; idx++)
4852 if (spec->pin_nids[idx] == nids[num])
4853 break;
4854 if (idx >= spec->num_pins)
4855 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01004856 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004857 if (def_conf == AC_JACK_PORT_NONE)
4858 break;
4859 }
4860 return num;
4861}
4862
4863static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
4864 hda_nid_t dig0pin)
4865{
4866 struct sigmatel_spec *spec = codec->spec;
4867 int idx;
4868
4869 for (idx = 0; idx < spec->num_pins; idx++)
4870 if (spec->pin_nids[idx] == dig0pin)
4871 break;
4872 if ((idx + 2) >= spec->num_pins)
4873 return 0;
4874
4875 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004876 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004877 return 2;
4878
4879 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01004880 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004881 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01004882 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004883 return 1;
4884 else
4885 return 0;
4886}
4887
Matthew Ranostaye035b842007-11-06 11:53:55 +01004888static int patch_stac92hd71bxx(struct hda_codec *codec)
4889{
4890 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05004891 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004892 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004893 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004894
4895 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4896 if (spec == NULL)
4897 return -ENOMEM;
4898
4899 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004900 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05004901 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4902 switch (codec->vendor_id) {
4903 case 0x111d76b6:
4904 case 0x111d76b7:
4905 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4906 break;
4907 case 0x111d7603:
4908 case 0x111d7608:
4909 /* On 92HD75Bx 0x27 isn't a pin nid */
4910 spec->num_pins--;
4911 /* fallthrough */
4912 default:
4913 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
4914 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004915 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004916 spec->board_config = snd_hda_check_board_config(codec,
4917 STAC_92HD71BXX_MODELS,
4918 stac92hd71bxx_models,
4919 stac92hd71bxx_cfg_tbl);
4920again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004921 if (spec->board_config < 0)
Matthew Ranostaye035b842007-11-06 11:53:55 +01004922 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4923 " STAC92HD71BXX, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01004924 else
4925 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004926 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004927
Takashi Iwai41c3b642008-11-18 10:45:15 +01004928 if (spec->board_config > STAC_92HD71BXX_REF) {
4929 /* GPIO0 = EAPD */
4930 spec->gpio_mask = 0x01;
4931 spec->gpio_dir = 0x01;
4932 spec->gpio_data = 0x01;
4933 }
4934
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004935 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4936 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4937
Matthew Ranostay541eee82007-12-14 12:08:04 +01004938 switch (codec->vendor_id) {
4939 case 0x111d76b6: /* 4 Port without Analog Mixer */
4940 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02004941 unmute_init++;
4942 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004943 case 0x111d76b4: /* 6 Port without Analog Mixer */
4944 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004945 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
4946 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01004947 spec->mixer = stac92hd71bxx_mixer;
4948 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004949 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004950 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
4951 stac92hd71bxx_dmic_nids,
4952 STAC92HD71BXX_NUM_DMICS);
4953 if (spec->num_dmics) {
4954 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4955 spec->dinput_mux = &spec->private_dimux;
4956 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
4957 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01004958 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004959 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004960 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
4961 sizeof(stac92hd71bxx_dmux_amixer));
4962 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004963 switch (spec->board_config) {
4964 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004965 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004966 err = stac_add_event(spec, codec->afg,
4967 STAC_VREF_EVENT, 0x02);
4968 if (err < 0)
4969 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004970 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004971 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4972 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004973 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004974 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004975 spec->gpio_mask |= 0x02;
4976 break;
4977 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004978 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004979 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004980 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004981
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004982 /* no output amps */
4983 spec->num_pwrs = 0;
4984 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004985 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004986
4987 /* disable VSW */
4988 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05004989 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01004990 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
4991 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05004992 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
4993 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
4994 stac92hd71bxx_dmic_nids,
4995 STAC92HD71BXX_NUM_DMICS - 1);
4996 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4997 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004998 break;
4999 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005000 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005001 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005002
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005003 /* no output amps */
5004 spec->num_pwrs = 0;
5005 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005006 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005007 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5008 sizeof(stac92hd71bxx_dmux_amixer));
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005009 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005010 spec->mixer = stac92hd71bxx_analog_mixer;
5011 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005012 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005013 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5014 stac92hd71bxx_dmic_nids,
5015 STAC92HD71BXX_NUM_DMICS);
5016 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5017 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005018 }
5019
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005020 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5021 snd_hda_sequence_write_cache(codec, unmute_init);
5022
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005023 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005024 spec->aloopback_shift = 0;
5025
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005026 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005027 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005028 spec->mux_nids = stac92hd71bxx_mux_nids;
5029 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005030 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005031 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005032
5033 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5034 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005035 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005036
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005037 switch (spec->board_config) {
5038 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005039 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005040 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005041 stac92xx_auto_set_pinctl(codec, 0x0e,
5042 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005043 /* fallthru */
5044 case STAC_DELL_M4_2:
5045 spec->num_dmics = 0;
5046 spec->num_smuxes = 0;
5047 spec->num_dmuxes = 0;
5048 break;
5049 case STAC_DELL_M4_1:
5050 case STAC_DELL_M4_3:
5051 spec->num_dmics = 1;
5052 spec->num_smuxes = 0;
5053 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005054 break;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005055 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005056 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005057 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5058 break;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005059 };
5060
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005061 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005062 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005063 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005064
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005065 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005066 if (!err) {
5067 if (spec->board_config < 0) {
5068 printk(KERN_WARNING "hda_codec: No auto-config is "
5069 "available, default to model=ref\n");
5070 spec->board_config = STAC_92HD71BXX_REF;
5071 goto again;
5072 }
5073 err = -EINVAL;
5074 }
5075
5076 if (err < 0) {
5077 stac92xx_free(codec);
5078 return err;
5079 }
5080
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005081 codec->proc_widget_hook = stac92hd7x_proc_hook;
5082
Matthew Ranostaye035b842007-11-06 11:53:55 +01005083 return 0;
5084};
5085
Matt2f2f4252005-04-13 14:45:30 +02005086static int patch_stac922x(struct hda_codec *codec)
5087{
5088 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005089 int err;
Matt2f2f4252005-04-13 14:45:30 +02005090
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005091 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005092 if (spec == NULL)
5093 return -ENOMEM;
5094
5095 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005096 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005097 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005098 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5099 stac922x_models,
5100 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005101 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005102 spec->gpio_mask = spec->gpio_dir = 0x03;
5103 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005104 /* Intel Macs have all same PCI SSID, so we need to check
5105 * codec SSID to distinguish the exact models
5106 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005107 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005108 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005109
5110 case 0x106b0800:
5111 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005112 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005113 case 0x106b0600:
5114 case 0x106b0700:
5115 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005116 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005117 case 0x106b0e00:
5118 case 0x106b0f00:
5119 case 0x106b1600:
5120 case 0x106b1700:
5121 case 0x106b0200:
5122 case 0x106b1e00:
5123 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005124 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005125 case 0x106b1a00:
5126 case 0x00000100:
5127 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005128 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005129 case 0x106b0a00:
5130 case 0x106b2200:
5131 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005132 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005133 default:
5134 spec->board_config = STAC_INTEL_MAC_V3;
5135 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005136 }
5137 }
5138
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005139 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005140 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005141 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5142 "using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005143 else
5144 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005145 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005146
Matt2f2f4252005-04-13 14:45:30 +02005147 spec->adc_nids = stac922x_adc_nids;
5148 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005149 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005150 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005151 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005152 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005153
5154 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005155 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005156
5157 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005158
Matt Porter3cc08dc2006-01-23 15:27:49 +01005159 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005160 if (!err) {
5161 if (spec->board_config < 0) {
5162 printk(KERN_WARNING "hda_codec: No auto-config is "
5163 "available, default to model=ref\n");
5164 spec->board_config = STAC_D945_REF;
5165 goto again;
5166 }
5167 err = -EINVAL;
5168 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005169 if (err < 0) {
5170 stac92xx_free(codec);
5171 return err;
5172 }
5173
5174 codec->patch_ops = stac92xx_patch_ops;
5175
Takashi Iwai807a46362007-05-29 19:01:37 +02005176 /* Fix Mux capture level; max to 2 */
5177 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5178 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5179 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5180 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5181 (0 << AC_AMPCAP_MUTE_SHIFT));
5182
Matt Porter3cc08dc2006-01-23 15:27:49 +01005183 return 0;
5184}
5185
5186static int patch_stac927x(struct hda_codec *codec)
5187{
5188 struct sigmatel_spec *spec;
5189 int err;
5190
5191 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5192 if (spec == NULL)
5193 return -ENOMEM;
5194
5195 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005196 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005197 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005198 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005199 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5200 stac927x_models,
5201 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005202 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005203 if (spec->board_config < 0)
Herton Ronaldo Krzesinskic98041f2009-02-11 20:33:15 -02005204 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5205 "STAC927x, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005206 else
5207 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005208 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005209
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005210 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005211 spec->adc_nids = stac927x_adc_nids;
5212 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5213 spec->mux_nids = stac927x_mux_nids;
5214 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005215 spec->smux_nids = stac927x_smux_nids;
5216 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005217 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005218 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005219 spec->multiout.dac_nids = spec->dac_nids;
5220
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005221 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005222 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005223 case STAC_D965_5ST:
5224 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005225 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005226 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005227 spec->num_dmics = 0;
5228
Tobin Davis93ed1502006-09-01 21:03:12 +02005229 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005230 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005231 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005232 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005233 switch (codec->subsystem_id) {
5234 case 0x10280209:
5235 case 0x1028022e:
5236 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005237 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005238 break;
5239 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005240 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005241 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005242 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005243 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005244 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005245 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005246 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005247 case STAC_DELL_3ST:
5248 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005249 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005250 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005251 spec->dmic_nids = stac927x_dmic_nids;
5252 spec->num_dmics = STAC927X_NUM_DMICS;
5253
Tobin Davis93ed1502006-09-01 21:03:12 +02005254 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005255 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005256 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005257 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005258 break;
5259 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005260 if (spec->board_config > STAC_D965_REF) {
5261 /* GPIO0 High = Enable EAPD */
5262 spec->eapd_mask = spec->gpio_mask = 0x01;
5263 spec->gpio_dir = spec->gpio_data = 0x01;
5264 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005265 spec->num_dmics = 0;
5266
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005267 spec->init = stac927x_core_init;
5268 spec->mixer = stac927x_mixer;
5269 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005270
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005271 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005272 spec->aloopback_mask = 0x40;
5273 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005274 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005275
Matt Porter3cc08dc2006-01-23 15:27:49 +01005276 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005277 if (!err) {
5278 if (spec->board_config < 0) {
5279 printk(KERN_WARNING "hda_codec: No auto-config is "
5280 "available, default to model=ref\n");
5281 spec->board_config = STAC_D965_REF;
5282 goto again;
5283 }
5284 err = -EINVAL;
5285 }
Mattc7d4b2f2005-06-27 14:59:41 +02005286 if (err < 0) {
5287 stac92xx_free(codec);
5288 return err;
5289 }
Matt2f2f4252005-04-13 14:45:30 +02005290
5291 codec->patch_ops = stac92xx_patch_ops;
5292
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005293 codec->proc_widget_hook = stac927x_proc_hook;
5294
Takashi Iwai52987652008-01-16 16:09:47 +01005295 /*
5296 * !!FIXME!!
5297 * The STAC927x seem to require fairly long delays for certain
5298 * command sequences. With too short delays (even if the answer
5299 * is set to RIRB properly), it results in the silence output
5300 * on some hardwares like Dell.
5301 *
5302 * The below flag enables the longer delay (see get_response
5303 * in hda_intel.c).
5304 */
5305 codec->bus->needs_damn_long_delay = 1;
5306
Takashi Iwaie28d8322008-12-17 13:48:29 +01005307 /* no jack detecion for ref-no-jd model */
5308 if (spec->board_config == STAC_D965_REF_NO_JD)
5309 spec->hp_detect = 0;
5310
Matt2f2f4252005-04-13 14:45:30 +02005311 return 0;
5312}
5313
Matt Porterf3302a52006-07-31 12:49:34 +02005314static int patch_stac9205(struct hda_codec *codec)
5315{
5316 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005317 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005318
5319 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5320 if (spec == NULL)
5321 return -ENOMEM;
5322
5323 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005324 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005325 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005326 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5327 stac9205_models,
5328 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005329 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005330 if (spec->board_config < 0)
Richard Fish11b44bb2006-08-23 18:31:34 +02005331 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
Takashi Iwai330ee992009-02-20 14:33:36 +01005332 else
5333 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005334 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005335
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005336 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005337 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005338 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005339 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005340 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005341 spec->smux_nids = stac9205_smux_nids;
5342 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005343 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005344 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005345 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005346 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005347 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005348
5349 spec->init = stac9205_core_init;
5350 spec->mixer = stac9205_mixer;
5351
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005352 spec->aloopback_mask = 0x40;
5353 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005354 /* Turn on/off EAPD per HP plugging */
5355 if (spec->board_config != STAC_9205_EAPD)
5356 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005357 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005358
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005359 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005360 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005361 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005362 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5363 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005364
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005365 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005366 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5367 if (err < 0)
5368 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005369 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005370 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5371 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005372 AC_VERB_SET_UNSOLICITED_ENABLE,
5373 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005374
5375 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005376 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005377 spec->gpio_mask = 0x1b;
5378 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005379 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005380 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005381 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005382 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005383 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005384 case STAC_9205_REF:
5385 /* SPDIF-In enabled */
5386 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005387 default:
5388 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005389 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005390 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005391 break;
5392 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005393
Matt Porterf3302a52006-07-31 12:49:34 +02005394 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005395 if (!err) {
5396 if (spec->board_config < 0) {
5397 printk(KERN_WARNING "hda_codec: No auto-config is "
5398 "available, default to model=ref\n");
5399 spec->board_config = STAC_9205_REF;
5400 goto again;
5401 }
5402 err = -EINVAL;
5403 }
Matt Porterf3302a52006-07-31 12:49:34 +02005404 if (err < 0) {
5405 stac92xx_free(codec);
5406 return err;
5407 }
5408
5409 codec->patch_ops = stac92xx_patch_ops;
5410
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005411 codec->proc_widget_hook = stac9205_proc_hook;
5412
Matt Porterf3302a52006-07-31 12:49:34 +02005413 return 0;
5414}
5415
Matt2f2f4252005-04-13 14:45:30 +02005416/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005417 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005418 */
5419
Takashi Iwai1e137f92009-01-21 07:41:22 +01005420static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5423 {}
5424};
5425
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005426static struct snd_kcontrol_new stac9872_mixer[] = {
5427 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5428 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005429 { } /* end */
5430};
5431
5432static hda_nid_t stac9872_pin_nids[] = {
5433 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5434 0x11, 0x13, 0x14,
5435};
5436
5437static hda_nid_t stac9872_adc_nids[] = {
5438 0x8 /*,0x6*/
5439};
5440
5441static hda_nid_t stac9872_mux_nids[] = {
5442 0x15
5443};
5444
Guillaume Munch6d859062006-08-22 17:15:47 +02005445static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005446{
5447 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005448 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005449
Takashi Iwaidb064e52006-03-16 16:04:58 +01005450 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5451 if (spec == NULL)
5452 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005453 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005454
Takashi Iwai1e137f92009-01-21 07:41:22 +01005455#if 0 /* no model right now */
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005456 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5457 stac9872_models,
5458 stac9872_cfg_tbl);
Takashi Iwai1e137f92009-01-21 07:41:22 +01005459#endif
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005460
Takashi Iwai1e137f92009-01-21 07:41:22 +01005461 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5462 spec->pin_nids = stac9872_pin_nids;
5463 spec->multiout.dac_nids = spec->dac_nids;
5464 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5465 spec->adc_nids = stac9872_adc_nids;
5466 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5467 spec->mux_nids = stac9872_mux_nids;
5468 spec->mixer = stac9872_mixer;
5469 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005470
Takashi Iwai1e137f92009-01-21 07:41:22 +01005471 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5472 if (err < 0) {
5473 stac92xx_free(codec);
5474 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005475 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005476 spec->input_mux = &spec->private_imux;
5477 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005478 return 0;
5479}
5480
5481
5482/*
Matt2f2f4252005-04-13 14:45:30 +02005483 * patch entries
5484 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005485static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005486 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5487 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5488 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5489 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5490 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5491 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5492 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005493 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5494 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5495 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5496 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5497 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5498 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005499 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5500 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5501 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5502 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5503 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5504 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5505 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5506 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5507 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5508 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005509 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5510 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5511 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5512 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5513 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5514 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005515 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5516 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005517 /* The following does not take into account .id=0x83847661 when subsys =
5518 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5519 * currently not fully supported.
5520 */
5521 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5522 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5523 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005524 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5525 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5526 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5527 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5528 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5529 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5530 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5531 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005532 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005533 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5534 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005535 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005536 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5537 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005538 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005539 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5540 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5541 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5542 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5543 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5544 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5545 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5546 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005547 {} /* terminator */
5548};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005549
5550MODULE_ALIAS("snd-hda-codec-id:8384*");
5551MODULE_ALIAS("snd-hda-codec-id:111d*");
5552
5553MODULE_LICENSE("GPL");
5554MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5555
5556static struct hda_codec_preset_list sigmatel_list = {
5557 .preset = snd_hda_preset_sigmatel,
5558 .owner = THIS_MODULE,
5559};
5560
5561static int __init patch_sigmatel_init(void)
5562{
5563 return snd_hda_add_codec_preset(&sigmatel_list);
5564}
5565
5566static void __exit patch_sigmatel_exit(void)
5567{
5568 snd_hda_delete_codec_preset(&sigmatel_list);
5569}
5570
5571module_init(patch_sigmatel_init)
5572module_exit(patch_sigmatel_exit)