blob: 58c9ff9d27f5f5420dae0f4de6f5257e6b13b7c8 [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 Ranostayd0513fc2008-07-27 10:30:30 +020086 STAC_92HD83XXX_MODELS
87};
88
89enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010090 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010091 STAC_DELL_M4_1,
92 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050093 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040094 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +010095 STAC_HP_DV5,
Matthew Ranostaye035b842007-11-06 11:53:55 +010096 STAC_92HD71BXX_MODELS
97};
98
99enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100100 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200101 STAC_M1,
102 STAC_M1_2,
103 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100104 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200105 STAC_M3,
106 STAC_M5,
107 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100108 STAC_925x_MODELS
109};
110
111enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100112 STAC_D945_REF,
113 STAC_D945GTP3,
114 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200115 STAC_INTEL_MAC_V1,
116 STAC_INTEL_MAC_V2,
117 STAC_INTEL_MAC_V3,
118 STAC_INTEL_MAC_V4,
119 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800120 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
121 * is given, one of the above models will be
122 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200123 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100124 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100125 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100126 STAC_MACBOOK_PRO_V1,
127 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200128 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200129 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300130 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200131 STAC_922X_DELL_D81,
132 STAC_922X_DELL_D82,
133 STAC_922X_DELL_M81,
134 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100135 STAC_922X_MODELS
136};
137
138enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100139 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100140 STAC_D965_REF,
141 STAC_D965_3ST,
142 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200143 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100144 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100145 STAC_927X_MODELS
146};
Matt Porter403d1942005-11-29 15:00:51 +0100147
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400148struct sigmatel_event {
149 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100150 unsigned char type;
151 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400152 int data;
153};
154
155struct sigmatel_jack {
156 hda_nid_t nid;
157 int type;
158 struct snd_jack *jack;
159};
160
Matt2f2f4252005-04-13 14:45:30 +0200161struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100162 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200163 unsigned int num_mixers;
164
Matt Porter403d1942005-11-29 15:00:51 +0100165 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500166 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200167 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100168 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100169 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400170 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100171 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200172
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100173 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200174 unsigned int eapd_mask;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100175 unsigned int gpio_mask;
176 unsigned int gpio_dir;
177 unsigned int gpio_data;
178 unsigned int gpio_mute;
179
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200180 /* stream */
181 unsigned int stream_delay;
182
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100183 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100184 unsigned char aloopback_mask;
185 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200186
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100187 /* power management */
188 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200189 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100190 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100191 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100192
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400193 /* jack detection */
194 struct snd_array jacks;
195
196 /* events */
197 struct snd_array events;
198
Matt2f2f4252005-04-13 14:45:30 +0200199 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100200 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400201 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100202 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200203 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100204 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100205 hda_nid_t hp_dacs[5];
206 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200207
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100208 int volume_offset;
209
Matt2f2f4252005-04-13 14:45:30 +0200210 /* capture */
211 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200212 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200213 hda_nid_t *mux_nids;
214 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200215 hda_nid_t *dmic_nids;
216 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100217 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100218 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200219 hda_nid_t *smux_nids;
220 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400221 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200222
Mattdabbed62005-06-14 10:19:34 +0200223 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100224 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200225 hda_nid_t anabeep_nid;
226 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200227
Matt2f2f4252005-04-13 14:45:30 +0200228 /* pin widgets */
229 hda_nid_t *pin_nids;
230 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200231 unsigned int *pin_configs;
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
Matt Porter3cc08dc2006-01-23 15:27:49 +0100407static hda_nid_t stac927x_adc_nids[3] = {
408 0x07, 0x08, 0x09
409};
410
411static hda_nid_t stac927x_mux_nids[3] = {
412 0x15, 0x16, 0x17
413};
414
Matthew Ranostayd9737752008-09-07 12:03:41 +0200415static hda_nid_t stac927x_smux_nids[1] = {
416 0x21,
417};
418
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100419static hda_nid_t stac927x_dac_nids[6] = {
420 0x02, 0x03, 0x04, 0x05, 0x06, 0
421};
422
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100423static hda_nid_t stac927x_dmux_nids[1] = {
424 0x1b,
425};
426
Matthew Ranostay7f168592007-10-18 17:38:17 +0200427#define STAC927X_NUM_DMICS 2
428static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
429 0x13, 0x14, 0
430};
431
Matthew Ranostay65973632008-09-16 10:39:37 -0400432static const char *stac927x_spdif_labels[5] = {
433 "Digital Playback", "ADAT", "Analog Mux 1",
434 "Analog Mux 2", "Analog Mux 3"
435};
436
Matt Porterf3302a52006-07-31 12:49:34 +0200437static hda_nid_t stac9205_adc_nids[2] = {
438 0x12, 0x13
439};
440
441static hda_nid_t stac9205_mux_nids[2] = {
442 0x19, 0x1a
443};
444
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100445static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100446 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100447};
448
Matthew Ranostayd9737752008-09-07 12:03:41 +0200449static hda_nid_t stac9205_smux_nids[1] = {
450 0x21,
451};
452
Takashi Iwaif6e98522007-10-16 14:27:04 +0200453#define STAC9205_NUM_DMICS 2
454static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
455 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200456};
457
Mattc7d4b2f2005-06-27 14:59:41 +0200458static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200459 0x08, 0x09, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200461};
462
Tobin Davis8e21c342007-01-08 11:04:17 +0100463static hda_nid_t stac925x_pin_nids[8] = {
464 0x07, 0x08, 0x0a, 0x0b,
465 0x0c, 0x0d, 0x10, 0x11,
466};
467
Matt2f2f4252005-04-13 14:45:30 +0200468static hda_nid_t stac922x_pin_nids[10] = {
469 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
470 0x0f, 0x10, 0x11, 0x15, 0x1b,
471};
472
Matthew Ranostaya7662642008-02-21 07:51:14 +0100473static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100474 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
475 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200476 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100477};
478
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200479static hda_nid_t stac92hd83xxx_pin_nids[14] = {
480 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
481 0x0f, 0x10, 0x11, 0x12, 0x13,
482 0x1d, 0x1e, 0x1f, 0x20
483};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500484
485#define STAC92HD71BXX_NUM_PINS 13
486static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
487 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
488 0x00, 0x14, 0x18, 0x19, 0x1e,
489 0x1f, 0x20, 0x27
490};
491static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100492 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
493 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500494 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100495};
496
Matt Porter3cc08dc2006-01-23 15:27:49 +0100497static hda_nid_t stac927x_pin_nids[14] = {
498 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
499 0x0f, 0x10, 0x11, 0x12, 0x13,
500 0x14, 0x21, 0x22, 0x23,
501};
502
Matt Porterf3302a52006-07-31 12:49:34 +0200503static hda_nid_t stac9205_pin_nids[12] = {
504 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
505 0x0f, 0x14, 0x16, 0x17, 0x18,
506 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200507};
508
Matthew Ranostay89385032008-09-11 09:49:39 -0400509#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
510
511static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
512 struct snd_ctl_elem_value *ucontrol)
513{
514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
515 struct sigmatel_spec *spec = codec->spec;
516 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
517
518 kcontrol->private_value ^= get_amp_nid(kcontrol);
519 kcontrol->private_value |= nid;
520
521 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
522}
523
524static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct sigmatel_spec *spec = codec->spec;
529 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
530
531 kcontrol->private_value ^= get_amp_nid(kcontrol);
532 kcontrol->private_value |= nid;
533
534 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
535}
536
Matt Porter8b657272006-10-26 17:12:59 +0200537static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_info *uinfo)
539{
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 struct sigmatel_spec *spec = codec->spec;
542 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
543}
544
545static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
547{
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100550 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200551
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100552 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200553 return 0;
554}
555
556static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
558{
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100561 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200562
563 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100564 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200565}
566
Matthew Ranostayd9737752008-09-07 12:03:41 +0200567static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_info *uinfo)
569{
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 struct sigmatel_spec *spec = codec->spec;
572 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
573}
574
575static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_value *ucontrol)
577{
578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
579 struct sigmatel_spec *spec = codec->spec;
580 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
581
582 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
583 return 0;
584}
585
586static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
587 struct snd_ctl_elem_value *ucontrol)
588{
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400591 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200592 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400593 int err, val;
594 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200595
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400596 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200597 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400598 if (err < 0)
599 return err;
600
601 if (spec->spdif_mute) {
602 if (smux_idx == 0)
603 nid = spec->multiout.dig_out_nid;
604 else
605 nid = codec->slave_dig_outs[smux_idx - 1];
606 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100607 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400608 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100609 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400610 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100611 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
612 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400613 }
614 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200615}
616
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100617static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200618{
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200621 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200622}
623
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100624static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200625{
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
629
630 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
631 return 0;
632}
633
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100634static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200635{
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
639
Mattc7d4b2f2005-06-27 14:59:41 +0200640 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200641 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
642}
643
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100644static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_info *uinfo)
646{
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
649 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
650}
651
652static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
657
658 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
659 return 0;
660}
661
662static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
663 struct snd_ctl_elem_value *ucontrol)
664{
665 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
666 struct sigmatel_spec *spec = codec->spec;
667
668 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
669 spec->mono_nid, &spec->cur_mmux);
670}
671
Matthew Ranostay89385032008-09-11 09:49:39 -0400672static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_info *uinfo)
674{
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 struct sigmatel_spec *spec = codec->spec;
677 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
678}
679
680static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
681 struct snd_ctl_elem_value *ucontrol)
682{
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 struct sigmatel_spec *spec = codec->spec;
685
686 ucontrol->value.enumerated.item[0] = spec->cur_amux;
687 return 0;
688}
689
690static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
691 struct snd_ctl_elem_value *ucontrol)
692{
693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
694 struct sigmatel_spec *spec = codec->spec;
695 struct snd_kcontrol *ctl =
696 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
697 if (!ctl)
698 return -EINVAL;
699
700 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
701 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
702
703 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
704 0, &spec->cur_amux);
705}
706
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
708
709static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
711{
712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200714 struct sigmatel_spec *spec = codec->spec;
715
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100716 ucontrol->value.integer.value[0] = !!(spec->aloopback &
717 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200718 return 0;
719}
720
721static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
722 struct snd_ctl_elem_value *ucontrol)
723{
724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
725 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100726 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200727 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100728 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200729
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100730 idx_val = spec->aloopback_mask << idx;
731 if (ucontrol->value.integer.value[0])
732 val = spec->aloopback | idx_val;
733 else
734 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100735 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200736 return 0;
737
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100738 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200739
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100740 /* Only return the bits defined by the shift value of the
741 * first two bytes of the mask
742 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200743 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100744 kcontrol->private_value & 0xFFFF, 0x0);
745 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200746
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100747 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200748 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100749 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200750 } else {
751 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100752 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200753 }
754
755 snd_hda_codec_write_cache(codec, codec->afg, 0,
756 kcontrol->private_value >> 16, dac_mode);
757
758 return 1;
759}
760
Mattc7d4b2f2005-06-27 14:59:41 +0200761static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200762 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200763 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200764 {}
765};
766
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200767static struct hda_verb stac9200_eapd_init[] = {
768 /* set dac0mux for dac converter */
769 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
770 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
771 {}
772};
773
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100774static struct hda_verb stac92hd73xx_6ch_core_init[] = {
775 /* set master volume and direct control */
776 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100777 /* setup adcs to point to mixer */
778 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
779 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100780 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
781 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
782 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
783 /* setup import muxs */
784 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
785 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
786 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
787 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
788 {}
789};
790
Matthew Ranostayd654a662008-03-14 08:46:51 +0100791static struct hda_verb dell_eq_core_init[] = {
792 /* set master volume to max value without distortion
793 * and direct control */
794 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100795 /* setup adcs to point to mixer */
796 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
797 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
798 /* setup import muxs */
799 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
800 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
801 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
802 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
803 {}
804};
805
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100806static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500807 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100808 /* setup adcs to point to mixer */
809 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
810 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
811 /* setup import muxs */
812 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
816 {}
817};
818
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100819static struct hda_verb stac92hd73xx_8ch_core_init[] = {
820 /* set master volume and direct control */
821 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100822 /* setup adcs to point to mixer */
823 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
824 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100825 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
828 /* setup import muxs */
829 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
830 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
831 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
832 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
833 {}
834};
835
836static struct hda_verb stac92hd73xx_10ch_core_init[] = {
837 /* set master volume and direct control */
838 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100839 /* dac3 is connected to import3 mux */
840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100841 /* setup adcs to point to mixer */
842 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
843 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100844 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
845 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
846 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
847 /* setup import muxs */
848 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
849 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
850 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
851 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
852 {}
853};
854
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200855static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200856 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
857 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
858 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
859
860 /* power state controls amps */
861 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200862 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200863};
864
Matthew Ranostaye035b842007-11-06 11:53:55 +0100865static struct hda_verb stac92hd71bxx_core_init[] = {
866 /* set master volume and direct control */
867 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200868 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100869};
870
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500871#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100872static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200873 /* start of config #1 */
874
875 /* connect port 0f to audio mixer */
876 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200877 /* start of config #2 */
878
Matthew Ranostay541eee82007-12-14 12:08:04 +0100879 /* set master volume and direct control */
880 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500881 {}
882};
883
884static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
885 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
886 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100887 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
888 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100889 {}
890};
891
Tobin Davis8e21c342007-01-08 11:04:17 +0100892static struct hda_verb stac925x_core_init[] = {
893 /* set dac0mux for dac converter */
894 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100895 /* mute the master volume */
896 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100897 {}
898};
899
Mattc7d4b2f2005-06-27 14:59:41 +0200900static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200901 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200902 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200903 {}
904};
905
Tobin Davis93ed1502006-09-01 21:03:12 +0200906static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200907 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200908 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200909 /* unmute node 0x1b */
910 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
911 /* select node 0x03 as DAC */
912 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
913 {}
914};
915
Matt Porter3cc08dc2006-01-23 15:27:49 +0100916static struct hda_verb stac927x_core_init[] = {
917 /* set master volume and direct control */
918 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200919 /* enable analog pc beep path */
920 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100921 {}
922};
923
Matt Porterf3302a52006-07-31 12:49:34 +0200924static struct hda_verb stac9205_core_init[] = {
925 /* set master volume and direct control */
926 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200927 /* enable analog pc beep path */
928 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200929 {}
930};
931
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100932#define STAC_MONO_MUX \
933 { \
934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
935 .name = "Mono Mux", \
936 .count = 1, \
937 .info = stac92xx_mono_mux_enum_info, \
938 .get = stac92xx_mono_mux_enum_get, \
939 .put = stac92xx_mono_mux_enum_put, \
940 }
941
Matthew Ranostay89385032008-09-11 09:49:39 -0400942#define STAC_AMP_MUX \
943 { \
944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
945 .name = "Amp Selector Capture Switch", \
946 .count = 1, \
947 .info = stac92xx_amp_mux_enum_info, \
948 .get = stac92xx_amp_mux_enum_get, \
949 .put = stac92xx_amp_mux_enum_put, \
950 }
951
952#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
953 { \
954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
955 .name = xname, \
956 .index = 0, \
957 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
958 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
960 .info = stac92xx_amp_volume_info, \
961 .get = stac92xx_amp_volume_get, \
962 .put = stac92xx_amp_volume_put, \
963 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
964 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
965 }
966
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100967#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200968 { \
969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
970 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100971 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200972 .info = stac92xx_aloopback_info, \
973 .get = stac92xx_aloopback_get, \
974 .put = stac92xx_aloopback_put, \
975 .private_value = verb_read | (verb_write << 16), \
976 }
977
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100978static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200979 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
980 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200981 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
982 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200983 { } /* end */
984};
985
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400986#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100987static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400988 /* start of config #1 */
989 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
990 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
991
992 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
993 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
994
995 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
996 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
997
998 /* start of config #2 */
999 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1000 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1001
1002 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1003 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1004
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001005 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1006
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001007 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1009
1010 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1012
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001013 { } /* end */
1014};
1015
1016static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1018
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1021
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1024
1025 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1026 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1027
1028 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1029 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1030
1031 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1032 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1033
1034 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1035 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1036
1037 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1038 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1039 { } /* end */
1040};
1041
1042static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001043 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1044
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001045 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1047
1048 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1050
1051 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1052 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1053
1054 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1055 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1056
1057 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1058 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1059
1060 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1061 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1062
1063 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1064 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1065 { } /* end */
1066};
1067
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001068
1069static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1070 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1071 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1072
1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1074 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1075
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001076 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1077 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001078
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001079 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1080 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001081
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001082 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1083 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001084
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001085 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1086 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001087
1088 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001089 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1090 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001091 */
1092 { } /* end */
1093};
1094
Matthew Ranostay541eee82007-12-14 12:08:04 +01001095static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001096 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001097
Matthew Ranostay9b359472007-11-07 13:03:12 +01001098 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1099 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001100
1101 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001103 /* analog pc-beep replaced with digital beep support */
1104 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001105 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1106 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001107 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001108
Matthew Ranostay687cb982008-10-11 13:52:43 -04001109 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1110 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001111
Matthew Ranostay687cb982008-10-11 13:52:43 -04001112 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1113 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001114
1115 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1116 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1117
1118 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1119 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001120 { } /* end */
1121};
1122
Matthew Ranostay541eee82007-12-14 12:08:04 +01001123static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001124 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1125
Matthew Ranostay541eee82007-12-14 12:08:04 +01001126 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001128
1129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001131 { } /* end */
1132};
1133
Tobin Davis8e21c342007-01-08 11:04:17 +01001134static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001135 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001137 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001138 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001139 { } /* end */
1140};
1141
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001142static struct snd_kcontrol_new stac9205_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001143 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001144
1145 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1146 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001147
1148 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001150 { } /* end */
1151};
1152
1153/* This needs to be generated dynamically based on sequence */
1154static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001157
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160 { } /* end */
1161};
1162
1163
1164static struct snd_kcontrol_new stac927x_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001165 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166
1167 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001169
1170 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001172
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001175 { } /* end */
1176};
1177
Takashi Iwai1697055e2007-12-18 18:05:52 +01001178static struct snd_kcontrol_new stac_dmux_mixer = {
1179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1180 .name = "Digital Input Source",
1181 /* count set later */
1182 .info = stac92xx_dmux_enum_info,
1183 .get = stac92xx_dmux_enum_get,
1184 .put = stac92xx_dmux_enum_put,
1185};
1186
Matthew Ranostayd9737752008-09-07 12:03:41 +02001187static struct snd_kcontrol_new stac_smux_mixer = {
1188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001189 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001190 /* count set later */
1191 .info = stac92xx_smux_enum_info,
1192 .get = stac92xx_smux_enum_get,
1193 .put = stac92xx_smux_enum_put,
1194};
1195
Takashi Iwai2134ea42008-01-10 16:53:55 +01001196static const char *slave_vols[] = {
1197 "Front Playback Volume",
1198 "Surround Playback Volume",
1199 "Center Playback Volume",
1200 "LFE Playback Volume",
1201 "Side Playback Volume",
1202 "Headphone Playback Volume",
1203 "Headphone Playback Volume",
1204 "Speaker Playback Volume",
1205 "External Speaker Playback Volume",
1206 "Speaker2 Playback Volume",
1207 NULL
1208};
1209
1210static const char *slave_sws[] = {
1211 "Front Playback Switch",
1212 "Surround Playback Switch",
1213 "Center Playback Switch",
1214 "LFE Playback Switch",
1215 "Side Playback Switch",
1216 "Headphone Playback Switch",
1217 "Headphone Playback Switch",
1218 "Speaker Playback Switch",
1219 "External Speaker Playback Switch",
1220 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001221 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001222 NULL
1223};
1224
Takashi Iwai603c4012008-07-30 15:01:44 +02001225static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001226static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001227
Matt2f2f4252005-04-13 14:45:30 +02001228static int stac92xx_build_controls(struct hda_codec *codec)
1229{
1230 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001231 struct auto_pin_cfg *cfg = &spec->autocfg;
1232 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001233 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001234 int i;
Matt2f2f4252005-04-13 14:45:30 +02001235
1236 err = snd_hda_add_new_ctls(codec, spec->mixer);
1237 if (err < 0)
1238 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001239
1240 for (i = 0; i < spec->num_mixers; i++) {
1241 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1242 if (err < 0)
1243 return err;
1244 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001245 if (spec->num_dmuxes > 0) {
1246 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001247 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001248 snd_ctl_new1(&stac_dmux_mixer, codec));
1249 if (err < 0)
1250 return err;
1251 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001252 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001253 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1254 struct hda_input_mux *smux = &spec->private_smux;
1255 /* check for mute support on SPDIF out */
1256 if (wcaps & AC_WCAP_OUT_AMP) {
1257 smux->items[smux->num_items].label = "Off";
1258 smux->items[smux->num_items].index = 0;
1259 smux->num_items++;
1260 spec->spdif_mute = 1;
1261 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001262 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001263 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001264 snd_ctl_new1(&stac_smux_mixer, codec));
1265 if (err < 0)
1266 return err;
1267 }
Mattc7d4b2f2005-06-27 14:59:41 +02001268
Mattdabbed62005-06-14 10:19:34 +02001269 if (spec->multiout.dig_out_nid) {
1270 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1271 if (err < 0)
1272 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001273 err = snd_hda_create_spdif_share_sw(codec,
1274 &spec->multiout);
1275 if (err < 0)
1276 return err;
1277 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001278 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001279 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001280 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1281 if (err < 0)
1282 return err;
1283 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001284
1285 /* if we have no master control, let's create it */
1286 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001287 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001288 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001289 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001290 /* correct volume offset */
1291 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001292 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001293 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001294 if (err < 0)
1295 return err;
1296 }
1297 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1298 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1299 NULL, slave_sws);
1300 if (err < 0)
1301 return err;
1302 }
1303
Takashi Iwai603c4012008-07-30 15:01:44 +02001304 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001305
1306 /* create jack input elements */
1307 if (spec->hp_detect) {
1308 for (i = 0; i < cfg->hp_outs; i++) {
1309 int type = SND_JACK_HEADPHONE;
1310 nid = cfg->hp_pins[i];
1311 /* jack detection */
1312 if (cfg->hp_outs == i)
1313 type |= SND_JACK_LINEOUT;
1314 err = stac92xx_add_jack(codec, nid, type);
1315 if (err < 0)
1316 return err;
1317 }
1318 }
1319 for (i = 0; i < cfg->line_outs; i++) {
1320 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1321 SND_JACK_LINEOUT);
1322 if (err < 0)
1323 return err;
1324 }
1325 for (i = 0; i < AUTO_PIN_LAST; i++) {
1326 nid = cfg->input_pins[i];
1327 if (nid) {
1328 err = stac92xx_add_jack(codec, nid,
1329 SND_JACK_MICROPHONE);
1330 if (err < 0)
1331 return err;
1332 }
1333 }
1334
Mattdabbed62005-06-14 10:19:34 +02001335 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001336}
1337
Matt Porter403d1942005-11-29 15:00:51 +01001338static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001339 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001340 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1341};
1342
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001343static unsigned int gateway9200_m4_pin_configs[8] = {
1344 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1345 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1346};
1347static unsigned int gateway9200_m4_2_pin_configs[8] = {
1348 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1349 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1350};
1351
1352/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001353 STAC 9200 pin configs for
1354 102801A8
1355 102801DE
1356 102801E8
1357*/
1358static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001359 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1360 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001361};
1362
1363/*
1364 STAC 9200 pin configs for
1365 102801C0
1366 102801C1
1367*/
1368static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001369 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1370 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001371};
1372
1373/*
1374 STAC 9200 pin configs for
1375 102801C4 (Dell Dimension E310)
1376 102801C5
1377 102801C7
1378 102801D9
1379 102801DA
1380 102801E3
1381*/
1382static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001383 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1384 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001385};
1386
1387
1388/*
1389 STAC 9200-32 pin configs for
1390 102801B5 (Dell Inspiron 630m)
1391 102801D8 (Dell Inspiron 640m)
1392*/
1393static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001394 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1395 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001396};
1397
1398/*
1399 STAC 9200-32 pin configs for
1400 102801C2 (Dell Latitude D620)
1401 102801C8
1402 102801CC (Dell Latitude D820)
1403 102801D4
1404 102801D6
1405*/
1406static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001407 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1408 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001409};
1410
1411/*
1412 STAC 9200-32 pin configs for
1413 102801CE (Dell XPS M1710)
1414 102801CF (Dell Precision M90)
1415*/
1416static unsigned int dell9200_m23_pin_configs[8] = {
1417 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1418 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1419};
1420
1421/*
1422 STAC 9200-32 pin configs for
1423 102801C9
1424 102801CA
1425 102801CB (Dell Latitude 120L)
1426 102801D3
1427*/
1428static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001429 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1430 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001431};
1432
1433/*
1434 STAC 9200-32 pin configs for
1435 102801BD (Dell Inspiron E1505n)
1436 102801EE
1437 102801EF
1438*/
1439static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001440 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1441 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001442};
1443
1444/*
1445 STAC 9200-32 pin configs for
1446 102801F5 (Dell Inspiron 1501)
1447 102801F6
1448*/
1449static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001450 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1451 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001452};
1453
1454/*
1455 STAC 9200-32
1456 102801CD (Dell Inspiron E1705/9400)
1457*/
1458static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001459 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1460 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001461};
1462
Tobin Davisbf277782008-02-03 20:31:47 +01001463static unsigned int oqo9200_pin_configs[8] = {
1464 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1465 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1466};
1467
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001468
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001469static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1470 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001471 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001472 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1473 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1474 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1475 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1476 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1477 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1478 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1479 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1480 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1481 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001482 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1483 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001484 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001485};
1486
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001487static const char *stac9200_models[STAC_9200_MODELS] = {
1488 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001489 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001490 [STAC_9200_DELL_D21] = "dell-d21",
1491 [STAC_9200_DELL_D22] = "dell-d22",
1492 [STAC_9200_DELL_D23] = "dell-d23",
1493 [STAC_9200_DELL_M21] = "dell-m21",
1494 [STAC_9200_DELL_M22] = "dell-m22",
1495 [STAC_9200_DELL_M23] = "dell-m23",
1496 [STAC_9200_DELL_M24] = "dell-m24",
1497 [STAC_9200_DELL_M25] = "dell-m25",
1498 [STAC_9200_DELL_M26] = "dell-m26",
1499 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001500 [STAC_9200_M4] = "gateway-m4",
1501 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001502 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001503};
1504
1505static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1506 /* SigmaTel reference board */
1507 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1508 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001509 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1510 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001511 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1513 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001515 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1517 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1519 "unknown Dell", STAC_9200_DELL_D22),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1521 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001523 "Dell Latitude D620", STAC_9200_DELL_M22),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1525 "unknown Dell", STAC_9200_DELL_D23),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1527 "unknown Dell", STAC_9200_DELL_D23),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1529 "unknown Dell", STAC_9200_DELL_M22),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1531 "unknown Dell", STAC_9200_DELL_M24),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1533 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001535 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001537 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001539 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001541 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001543 "Dell Precision M90", STAC_9200_DELL_M23),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1545 "unknown Dell", STAC_9200_DELL_M22),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1547 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001549 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001551 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1553 "unknown Dell", STAC_9200_DELL_D23),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1555 "unknown Dell", STAC_9200_DELL_D23),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1557 "unknown Dell", STAC_9200_DELL_D21),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1559 "unknown Dell", STAC_9200_DELL_D23),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1561 "unknown Dell", STAC_9200_DELL_D21),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1563 "unknown Dell", STAC_9200_DELL_M25),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1565 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001567 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1569 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001570 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001571 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001572 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001573 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1574 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1575 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001576 /* OQO Mobile */
1577 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001578 {} /* terminator */
1579};
1580
Tobin Davis8e21c342007-01-08 11:04:17 +01001581static unsigned int ref925x_pin_configs[8] = {
1582 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001583 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001584};
1585
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001586static unsigned int stac925xM1_pin_configs[8] = {
1587 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1588 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001589};
1590
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001591static unsigned int stac925xM1_2_pin_configs[8] = {
1592 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1593 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1594};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001595
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001596static unsigned int stac925xM2_pin_configs[8] = {
1597 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1598 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001599};
1600
Tobin Davis8e21c342007-01-08 11:04:17 +01001601static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001602 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1603 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1604};
1605
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001606static unsigned int stac925xM3_pin_configs[8] = {
1607 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1608 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1609};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001610
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001611static unsigned int stac925xM5_pin_configs[8] = {
1612 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1613 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1614};
1615
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001616static unsigned int stac925xM6_pin_configs[8] = {
1617 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1618 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001619};
1620
1621static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1622 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001623 [STAC_M1] = stac925xM1_pin_configs,
1624 [STAC_M1_2] = stac925xM1_2_pin_configs,
1625 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001626 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001627 [STAC_M3] = stac925xM3_pin_configs,
1628 [STAC_M5] = stac925xM5_pin_configs,
1629 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001630};
1631
1632static const char *stac925x_models[STAC_925x_MODELS] = {
1633 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001634 [STAC_M1] = "m1",
1635 [STAC_M1_2] = "m1-2",
1636 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001637 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001638 [STAC_M3] = "m3",
1639 [STAC_M5] = "m5",
1640 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001641};
1642
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001643static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001644 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1645 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1646 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1647 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001648 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001649 /* Not sure about the brand name for those */
1650 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1651 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1652 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1653 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001654 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001655};
1656
1657static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1658 /* SigmaTel reference board */
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001660 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001661 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001662
1663 /* Default table for unknown ID */
1664 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1665
Tobin Davis8e21c342007-01-08 11:04:17 +01001666 {} /* terminator */
1667};
1668
Matthew Ranostaya7662642008-02-21 07:51:14 +01001669static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001670 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1671 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1672 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001673 0x01452050,
1674};
1675
1676static unsigned int dell_m6_pin_configs[13] = {
1677 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001678 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001679 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1680 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001681};
1682
1683static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001684 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001685 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1686 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1687 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001688 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001689};
1690
1691static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001692 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001693 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001694 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1695 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1696 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001697 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001698};
1699
1700static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1701 /* SigmaTel reference board */
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001703 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001704 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1705 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001707 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001709 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001711 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001713 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001715 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001717 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001719 "unknown Dell", STAC_DELL_M6_DMIC),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1721 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001723 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1725 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001726 {} /* terminator */
1727};
1728
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001729static unsigned int ref92hd83xxx_pin_configs[14] = {
1730 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1731 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1732 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1733 0x01451160, 0x98560170,
1734};
1735
1736static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1737 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001738 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001739};
1740
1741static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1742 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001743 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001744};
1745
1746static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1747 /* SigmaTel reference board */
1748 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001749 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001750 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1751 "DFI LanParty", STAC_92HD83XXX_REF),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001752 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001753};
1754
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001755static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001756 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001757 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001758 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1759 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001760};
1761
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001762static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001763 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001764 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001765 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1766 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001767};
1768
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001769static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001770 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1771 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001772 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1773 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001774};
1775
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001776static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001777 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1778 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001779 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1780 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001781};
1782
Matthew Ranostaye035b842007-11-06 11:53:55 +01001783static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1784 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001785 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1786 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001787 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001788 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001789 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001790};
1791
1792static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1793 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001794 [STAC_DELL_M4_1] = "dell-m4-1",
1795 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001796 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001797 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001798 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001799};
1800
1801static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1802 /* SigmaTel reference board */
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1804 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001805 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1806 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1808 "HP dv5", STAC_HP_M4),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1810 "HP dv7", STAC_HP_M4),
Takashi Iwaie0c0e942009-01-22 12:58:11 +01001811 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7,
1812 "HP dv4", STAC_HP_DV5),
Takashi Iwai69dfaef2008-12-20 16:57:50 +01001813 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1814 "HP dv7", STAC_HP_M4),
Takashi Iwai42de55c2009-01-30 15:49:58 +01001815 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3600,
1816 "HP dv5", STAC_HP_DV5),
Giuseppe Bilottadafb70c2009-01-13 08:58:49 -05001817 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001818 "HP dv5", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001819 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1820 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1822 "unknown Dell", STAC_DELL_M4_1),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1824 "unknown Dell", STAC_DELL_M4_1),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1830 "unknown Dell", STAC_DELL_M4_1),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1832 "unknown Dell", STAC_DELL_M4_1),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1834 "unknown Dell", STAC_DELL_M4_1),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1836 "unknown Dell", STAC_DELL_M4_2),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1838 "unknown Dell", STAC_DELL_M4_2),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1840 "unknown Dell", STAC_DELL_M4_2),
1841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1842 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001843 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1844 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001845 {} /* terminator */
1846};
1847
Matt Porter403d1942005-11-29 15:00:51 +01001848static unsigned int ref922x_pin_configs[10] = {
1849 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1850 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001851 0x40000100, 0x40000100,
1852};
1853
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001854/*
1855 STAC 922X pin configs for
1856 102801A7
1857 102801AB
1858 102801A9
1859 102801D1
1860 102801D2
1861*/
1862static unsigned int dell_922x_d81_pin_configs[10] = {
1863 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1864 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1865 0x01813122, 0x400001f2,
1866};
1867
1868/*
1869 STAC 922X pin configs for
1870 102801AC
1871 102801D0
1872*/
1873static unsigned int dell_922x_d82_pin_configs[10] = {
1874 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1875 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1876 0x01813122, 0x400001f1,
1877};
1878
1879/*
1880 STAC 922X pin configs for
1881 102801BF
1882*/
1883static unsigned int dell_922x_m81_pin_configs[10] = {
1884 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1885 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1886 0x40C003f1, 0x405003f0,
1887};
1888
1889/*
1890 STAC 9221 A1 pin configs for
1891 102801D7 (Dell XPS M1210)
1892*/
1893static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001894 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1895 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001896 0x508003f3, 0x405003f4,
1897};
1898
Matt Porter403d1942005-11-29 15:00:51 +01001899static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001900 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001901 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1902 0x02a19120, 0x40000100,
1903};
1904
1905static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001906 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1907 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001908 0x02a19320, 0x40000100,
1909};
1910
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001911static unsigned int intel_mac_v1_pin_configs[10] = {
1912 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1913 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001914 0x400000fc, 0x400000fb,
1915};
1916
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001917static unsigned int intel_mac_v2_pin_configs[10] = {
1918 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1919 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001920 0x400000fc, 0x400000fb,
1921};
1922
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001923static unsigned int intel_mac_v3_pin_configs[10] = {
1924 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1925 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1926 0x400000fc, 0x400000fb,
1927};
1928
1929static unsigned int intel_mac_v4_pin_configs[10] = {
1930 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1931 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1932 0x400000fc, 0x400000fb,
1933};
1934
1935static unsigned int intel_mac_v5_pin_configs[10] = {
1936 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1937 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1938 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001939};
1940
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001941static unsigned int ecs202_pin_configs[10] = {
1942 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1943 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1944 0x9037012e, 0x40e000f2,
1945};
Takashi Iwai76c08822007-06-19 12:17:42 +02001946
Takashi Iwai19039bd2006-06-28 15:52:16 +02001947static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001948 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001949 [STAC_D945GTP3] = d945gtp3_pin_configs,
1950 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001951 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1952 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1953 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1954 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1955 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001956 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001957 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001958 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1959 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1960 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1961 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1962 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1963 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001964 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001965 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1966 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1967 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1968 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001969};
1970
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001971static const char *stac922x_models[STAC_922X_MODELS] = {
1972 [STAC_D945_REF] = "ref",
1973 [STAC_D945GTP5] = "5stack",
1974 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001975 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1976 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1977 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1978 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1979 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001980 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001981 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001982 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001983 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001984 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1985 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001986 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001987 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001988 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001989 [STAC_922X_DELL_D81] = "dell-d81",
1990 [STAC_922X_DELL_D82] = "dell-d82",
1991 [STAC_922X_DELL_M81] = "dell-m81",
1992 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001993};
1994
1995static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1996 /* SigmaTel reference board */
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1998 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001999 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2000 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002001 /* Intel 945G based systems */
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2003 "Intel D945G", STAC_D945GTP3),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2031 "Intel D945G", STAC_D945GTP3),
2032 /* Intel D945G 5-stack systems */
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2034 "Intel D945G", STAC_D945GTP5),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2036 "Intel D945G", STAC_D945GTP5),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2038 "Intel D945G", STAC_D945GTP5),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2040 "Intel D945G", STAC_D945GTP5),
2041 /* Intel 945P based systems */
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2043 "Intel D945P", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2045 "Intel D945P", STAC_D945GTP3),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2047 "Intel D945P", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2049 "Intel D945P", STAC_D945GTP3),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2051 "Intel D945P", STAC_D945GTP3),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2053 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002054 /* other intel */
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2056 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002057 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002058 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002059 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002060 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002061 /* Dell systems */
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2063 "unknown Dell", STAC_922X_DELL_D81),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2065 "unknown Dell", STAC_922X_DELL_D81),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2067 "unknown Dell", STAC_922X_DELL_D81),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2069 "unknown Dell", STAC_922X_DELL_D82),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2071 "unknown Dell", STAC_922X_DELL_M81),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2073 "unknown Dell", STAC_922X_DELL_D82),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2075 "unknown Dell", STAC_922X_DELL_D81),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2077 "unknown Dell", STAC_922X_DELL_D81),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2079 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002080 /* ECS/PC Chips boards */
2081 SND_PCI_QUIRK(0x1019, 0x2144,
2082 "ECS/PC chips", STAC_ECS_202),
2083 SND_PCI_QUIRK(0x1019, 0x2608,
2084 "ECS/PC chips", STAC_ECS_202),
2085 SND_PCI_QUIRK(0x1019, 0x2633,
2086 "ECS/PC chips P17G/1333", STAC_ECS_202),
2087 SND_PCI_QUIRK(0x1019, 0x2811,
2088 "ECS/PC chips", STAC_ECS_202),
2089 SND_PCI_QUIRK(0x1019, 0x2812,
2090 "ECS/PC chips", STAC_ECS_202),
2091 SND_PCI_QUIRK(0x1019, 0x2813,
2092 "ECS/PC chips", STAC_ECS_202),
2093 SND_PCI_QUIRK(0x1019, 0x2814,
2094 "ECS/PC chips", STAC_ECS_202),
2095 SND_PCI_QUIRK(0x1019, 0x2815,
2096 "ECS/PC chips", STAC_ECS_202),
2097 SND_PCI_QUIRK(0x1019, 0x2816,
2098 "ECS/PC chips", STAC_ECS_202),
2099 SND_PCI_QUIRK(0x1019, 0x2817,
2100 "ECS/PC chips", STAC_ECS_202),
2101 SND_PCI_QUIRK(0x1019, 0x2818,
2102 "ECS/PC chips", STAC_ECS_202),
2103 SND_PCI_QUIRK(0x1019, 0x2819,
2104 "ECS/PC chips", STAC_ECS_202),
2105 SND_PCI_QUIRK(0x1019, 0x2820,
2106 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002107 {} /* terminator */
2108};
2109
Matt Porter3cc08dc2006-01-23 15:27:49 +01002110static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002111 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2112 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2113 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2114 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002115};
2116
Tobin Davis93ed1502006-09-01 21:03:12 +02002117static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002118 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2119 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2120 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2121 0x40000100, 0x40000100
2122};
2123
Tobin Davis93ed1502006-09-01 21:03:12 +02002124static unsigned int d965_5st_pin_configs[14] = {
2125 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2126 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2127 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2128 0x40000100, 0x40000100
2129};
2130
Tobin Davis4ff076e2007-08-07 11:48:12 +02002131static unsigned int dell_3st_pin_configs[14] = {
2132 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2133 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002134 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002135 0x40c003fc, 0x40000100
2136};
2137
Tobin Davis93ed1502006-09-01 21:03:12 +02002138static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002139 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002140 [STAC_D965_REF] = ref927x_pin_configs,
2141 [STAC_D965_3ST] = d965_3st_pin_configs,
2142 [STAC_D965_5ST] = d965_5st_pin_configs,
2143 [STAC_DELL_3ST] = dell_3st_pin_configs,
2144 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002145};
2146
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002147static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002148 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002149 [STAC_D965_REF] = "ref",
2150 [STAC_D965_3ST] = "3stack",
2151 [STAC_D965_5ST] = "5stack",
2152 [STAC_DELL_3ST] = "dell-3stack",
2153 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002154};
2155
2156static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2157 /* SigmaTel reference board */
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2159 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002160 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2161 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002162 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002165 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002182 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002187 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002196 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002197 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2201 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2203 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2204 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2205 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002206 {} /* terminator */
2207};
2208
Matt Porterf3302a52006-07-31 12:49:34 +02002209static unsigned int ref9205_pin_configs[12] = {
2210 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002211 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002212 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002213};
2214
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002215/*
2216 STAC 9205 pin configs for
2217 102801F1
2218 102801F2
2219 102801FC
2220 102801FD
2221 10280204
2222 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002223 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002224*/
2225static unsigned int dell_9205_m42_pin_configs[12] = {
2226 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2227 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2228 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2229};
2230
2231/*
2232 STAC 9205 pin configs for
2233 102801F9
2234 102801FA
2235 102801FE
2236 102801FF (Dell Precision M4300)
2237 10280206
2238 10280200
2239 10280201
2240*/
2241static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002242 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2243 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2244 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2245};
2246
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002247static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002248 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2249 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2250 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2251};
2252
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002253static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002254 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002255 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2256 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2257 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002258 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002259};
2260
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002261static const char *stac9205_models[STAC_9205_MODELS] = {
2262 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002263 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002264 [STAC_9205_DELL_M43] = "dell-m43",
2265 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002266 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002267};
2268
2269static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2270 /* SigmaTel reference board */
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2272 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002273 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2274 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002275 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2277 "unknown Dell", STAC_9205_DELL_M42),
2278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2279 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002281 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2283 "Dell Precision", STAC_9205_DELL_M43),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2285 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2287 "unknown Dell", STAC_9205_DELL_M42),
2288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2289 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2291 "Dell Precision", STAC_9205_DELL_M43),
2292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002293 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2295 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2297 "Dell Precision", STAC_9205_DELL_M43),
2298 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2299 "Dell Precision", STAC_9205_DELL_M43),
2300 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2301 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002302 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2303 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002304 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2305 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002306 /* Gateway */
2307 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002308 {} /* terminator */
2309};
2310
Richard Fish11b44bb2006-08-23 18:31:34 +02002311static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2312{
2313 int i;
2314 struct sigmatel_spec *spec = codec->spec;
2315
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01002316 kfree(spec->pin_configs);
2317 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2318 GFP_KERNEL);
2319 if (!spec->pin_configs)
2320 return -ENOMEM;
Richard Fish11b44bb2006-08-23 18:31:34 +02002321
2322 for (i = 0; i < spec->num_pins; i++) {
2323 hda_nid_t nid = spec->pin_nids[i];
2324 unsigned int pin_cfg;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05002325
2326 if (!nid)
2327 continue;
Richard Fish11b44bb2006-08-23 18:31:34 +02002328 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2329 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2330 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2331 nid, pin_cfg);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01002332 spec->pin_configs[i] = pin_cfg;
Richard Fish11b44bb2006-08-23 18:31:34 +02002333 }
2334
2335 return 0;
2336}
2337
Matthew Ranostay87d48362007-07-17 11:52:24 +02002338static void stac92xx_set_config_reg(struct hda_codec *codec,
2339 hda_nid_t pin_nid, unsigned int pin_config)
2340{
2341 int i;
2342 snd_hda_codec_write(codec, pin_nid, 0,
2343 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2344 pin_config & 0x000000ff);
2345 snd_hda_codec_write(codec, pin_nid, 0,
2346 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2347 (pin_config & 0x0000ff00) >> 8);
2348 snd_hda_codec_write(codec, pin_nid, 0,
2349 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2350 (pin_config & 0x00ff0000) >> 16);
2351 snd_hda_codec_write(codec, pin_nid, 0,
2352 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2353 pin_config >> 24);
2354 i = snd_hda_codec_read(codec, pin_nid, 0,
2355 AC_VERB_GET_CONFIG_DEFAULT,
2356 0x00);
2357 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2358 pin_nid, i);
2359}
2360
Matt2f2f4252005-04-13 14:45:30 +02002361static void stac92xx_set_config_regs(struct hda_codec *codec)
2362{
2363 int i;
2364 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002365
Matthew Ranostay87d48362007-07-17 11:52:24 +02002366 if (!spec->pin_configs)
2367 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002368
Matthew Ranostay87d48362007-07-17 11:52:24 +02002369 for (i = 0; i < spec->num_pins; i++)
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05002370 if (spec->pin_nids[i] && spec->pin_configs[i])
2371 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2372 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002373}
Matt2f2f4252005-04-13 14:45:30 +02002374
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01002375static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2376{
2377 struct sigmatel_spec *spec = codec->spec;
2378
2379 if (!pins)
2380 return stac92xx_save_bios_config_regs(codec);
2381
2382 kfree(spec->pin_configs);
2383 spec->pin_configs = kmemdup(pins,
2384 spec->num_pins * sizeof(*pins),
2385 GFP_KERNEL);
2386 if (!spec->pin_configs)
2387 return -ENOMEM;
2388
2389 stac92xx_set_config_regs(codec);
2390 return 0;
2391}
2392
2393static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2394 unsigned int cfg)
2395{
2396 struct sigmatel_spec *spec = codec->spec;
2397 int i;
2398
2399 for (i = 0; i < spec->num_pins; i++) {
2400 if (spec->pin_nids[i] == nid) {
2401 spec->pin_configs[i] = cfg;
2402 stac92xx_set_config_reg(codec, nid, cfg);
2403 break;
2404 }
2405 }
2406}
2407
Matt2f2f4252005-04-13 14:45:30 +02002408/*
2409 * Analog playback callbacks
2410 */
2411static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2412 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002413 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002414{
2415 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002416 if (spec->stream_delay)
2417 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002418 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2419 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002420}
2421
2422static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2423 struct hda_codec *codec,
2424 unsigned int stream_tag,
2425 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002426 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002427{
2428 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002429 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002430}
2431
2432static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2433 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002434 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002435{
2436 struct sigmatel_spec *spec = codec->spec;
2437 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2438}
2439
2440/*
Mattdabbed62005-06-14 10:19:34 +02002441 * Digital playback callbacks
2442 */
2443static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2444 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002445 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002446{
2447 struct sigmatel_spec *spec = codec->spec;
2448 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2449}
2450
2451static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2452 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002453 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002454{
2455 struct sigmatel_spec *spec = codec->spec;
2456 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2457}
2458
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002459static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2460 struct hda_codec *codec,
2461 unsigned int stream_tag,
2462 unsigned int format,
2463 struct snd_pcm_substream *substream)
2464{
2465 struct sigmatel_spec *spec = codec->spec;
2466 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2467 stream_tag, format, substream);
2468}
2469
Mattdabbed62005-06-14 10:19:34 +02002470
2471/*
Matt2f2f4252005-04-13 14:45:30 +02002472 * Analog capture callbacks
2473 */
2474static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2475 struct hda_codec *codec,
2476 unsigned int stream_tag,
2477 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002478 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002479{
2480 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002481 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002482
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002483 if (spec->powerdown_adcs) {
2484 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002485 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002486 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2487 }
2488 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002489 return 0;
2490}
2491
2492static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2493 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002494 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002495{
2496 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002497 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002498
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002499 snd_hda_codec_cleanup_stream(codec, nid);
2500 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002501 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002502 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002503 return 0;
2504}
2505
Mattdabbed62005-06-14 10:19:34 +02002506static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2507 .substreams = 1,
2508 .channels_min = 2,
2509 .channels_max = 2,
2510 /* NID is set in stac92xx_build_pcms */
2511 .ops = {
2512 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002513 .close = stac92xx_dig_playback_pcm_close,
2514 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002515 },
2516};
2517
2518static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2519 .substreams = 1,
2520 .channels_min = 2,
2521 .channels_max = 2,
2522 /* NID is set in stac92xx_build_pcms */
2523};
2524
Matt2f2f4252005-04-13 14:45:30 +02002525static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2526 .substreams = 1,
2527 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002528 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002529 .nid = 0x02, /* NID to query formats and rates */
2530 .ops = {
2531 .open = stac92xx_playback_pcm_open,
2532 .prepare = stac92xx_playback_pcm_prepare,
2533 .cleanup = stac92xx_playback_pcm_cleanup
2534 },
2535};
2536
Matt Porter3cc08dc2006-01-23 15:27:49 +01002537static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2538 .substreams = 1,
2539 .channels_min = 2,
2540 .channels_max = 2,
2541 .nid = 0x06, /* NID to query formats and rates */
2542 .ops = {
2543 .open = stac92xx_playback_pcm_open,
2544 .prepare = stac92xx_playback_pcm_prepare,
2545 .cleanup = stac92xx_playback_pcm_cleanup
2546 },
2547};
2548
Matt2f2f4252005-04-13 14:45:30 +02002549static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002550 .channels_min = 2,
2551 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002552 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002553 .ops = {
2554 .prepare = stac92xx_capture_pcm_prepare,
2555 .cleanup = stac92xx_capture_pcm_cleanup
2556 },
2557};
2558
2559static int stac92xx_build_pcms(struct hda_codec *codec)
2560{
2561 struct sigmatel_spec *spec = codec->spec;
2562 struct hda_pcm *info = spec->pcm_rec;
2563
2564 codec->num_pcms = 1;
2565 codec->pcm_info = info;
2566
Mattc7d4b2f2005-06-27 14:59:41 +02002567 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002568 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002569 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2570 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002571 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002572 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002573 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002574
2575 if (spec->alt_switch) {
2576 codec->num_pcms++;
2577 info++;
2578 info->name = "STAC92xx Analog Alt";
2579 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2580 }
Matt2f2f4252005-04-13 14:45:30 +02002581
Mattdabbed62005-06-14 10:19:34 +02002582 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2583 codec->num_pcms++;
2584 info++;
2585 info->name = "STAC92xx Digital";
Takashi Iwai8c441982009-01-20 18:30:20 +01002586 info->pcm_type = spec->autocfg.dig_out_type;
Mattdabbed62005-06-14 10:19:34 +02002587 if (spec->multiout.dig_out_nid) {
2588 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2589 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2590 }
2591 if (spec->dig_in_nid) {
2592 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2593 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2594 }
2595 }
2596
Matt2f2f4252005-04-13 14:45:30 +02002597 return 0;
2598}
2599
Takashi Iwaic960a032006-03-23 17:06:28 +01002600static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2601{
2602 unsigned int pincap = snd_hda_param_read(codec, nid,
2603 AC_PAR_PIN_CAP);
2604 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2605 if (pincap & AC_PINCAP_VREF_100)
2606 return AC_PINCTL_VREF_100;
2607 if (pincap & AC_PINCAP_VREF_80)
2608 return AC_PINCTL_VREF_80;
2609 if (pincap & AC_PINCAP_VREF_50)
2610 return AC_PINCTL_VREF_50;
2611 if (pincap & AC_PINCAP_VREF_GRD)
2612 return AC_PINCTL_VREF_GRD;
2613 return 0;
2614}
2615
Matt Porter403d1942005-11-29 15:00:51 +01002616static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2617
2618{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002619 snd_hda_codec_write_cache(codec, nid, 0,
2620 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002621}
2622
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002623#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2624
2625static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2626 struct snd_ctl_elem_value *ucontrol)
2627{
2628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2629 struct sigmatel_spec *spec = codec->spec;
2630
Takashi Iwaid7a89432008-11-12 09:48:04 +01002631 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002632 return 0;
2633}
2634
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002635static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2636 unsigned char type);
2637
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002638static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2639 struct snd_ctl_elem_value *ucontrol)
2640{
2641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2642 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002643 int nid = kcontrol->private_value;
2644
2645 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002646
2647 /* check to be sure that the ports are upto date with
2648 * switch changes
2649 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002650 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002651
2652 return 1;
2653}
2654
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002655#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002656
2657static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2658{
2659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2660 struct sigmatel_spec *spec = codec->spec;
2661 int io_idx = kcontrol-> private_value & 0xff;
2662
2663 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2664 return 0;
2665}
2666
2667static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2668{
2669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2670 struct sigmatel_spec *spec = codec->spec;
2671 hda_nid_t nid = kcontrol->private_value >> 8;
2672 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002673 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002674
2675 spec->io_switch[io_idx] = val;
2676
2677 if (val)
2678 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002679 else {
2680 unsigned int pinctl = AC_PINCTL_IN_EN;
2681 if (io_idx) /* set VREF for mic */
2682 pinctl |= stac92xx_get_vref(codec, nid);
2683 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2684 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002685
2686 /* check the auto-mute again: we need to mute/unmute the speaker
2687 * appropriately according to the pin direction
2688 */
2689 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002690 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002691
Matt Porter403d1942005-11-29 15:00:51 +01002692 return 1;
2693}
2694
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002695#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2696
2697static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2698 struct snd_ctl_elem_value *ucontrol)
2699{
2700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2701 struct sigmatel_spec *spec = codec->spec;
2702
2703 ucontrol->value.integer.value[0] = spec->clfe_swap;
2704 return 0;
2705}
2706
2707static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2708 struct snd_ctl_elem_value *ucontrol)
2709{
2710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2711 struct sigmatel_spec *spec = codec->spec;
2712 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002713 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002714
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002715 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002716 return 0;
2717
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002718 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002719
2720 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2721 spec->clfe_swap ? 0x4 : 0x0);
2722
2723 return 1;
2724}
2725
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002726#define STAC_CODEC_HP_SWITCH(xname) \
2727 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2728 .name = xname, \
2729 .index = 0, \
2730 .info = stac92xx_hp_switch_info, \
2731 .get = stac92xx_hp_switch_get, \
2732 .put = stac92xx_hp_switch_put, \
2733 }
2734
Matt Porter403d1942005-11-29 15:00:51 +01002735#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2737 .name = xname, \
2738 .index = 0, \
2739 .info = stac92xx_io_switch_info, \
2740 .get = stac92xx_io_switch_get, \
2741 .put = stac92xx_io_switch_put, \
2742 .private_value = xpval, \
2743 }
2744
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002745#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2746 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2747 .name = xname, \
2748 .index = 0, \
2749 .info = stac92xx_clfe_switch_info, \
2750 .get = stac92xx_clfe_switch_get, \
2751 .put = stac92xx_clfe_switch_put, \
2752 .private_value = xpval, \
2753 }
Matt Porter403d1942005-11-29 15:00:51 +01002754
Mattc7d4b2f2005-06-27 14:59:41 +02002755enum {
2756 STAC_CTL_WIDGET_VOL,
2757 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002758 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002759 STAC_CTL_WIDGET_AMP_MUX,
2760 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002761 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002762 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002763 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002764};
2765
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002766static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002767 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2768 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002769 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002770 STAC_AMP_MUX,
2771 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002772 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002773 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002774 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002775};
2776
2777/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002778static struct snd_kcontrol_new *
2779stac_control_new(struct sigmatel_spec *spec,
2780 struct snd_kcontrol_new *ktemp,
2781 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002782{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002783 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002784
Takashi Iwai603c4012008-07-30 15:01:44 +02002785 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2786 knew = snd_array_new(&spec->kctls);
2787 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002788 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002789 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002790 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002791 if (!knew->name) {
2792 /* roolback */
2793 memset(knew, 0, sizeof(*knew));
2794 spec->kctls.alloced--;
2795 return NULL;
2796 }
2797 return knew;
2798}
2799
2800static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2801 struct snd_kcontrol_new *ktemp,
2802 int idx, const char *name,
2803 unsigned long val)
2804{
2805 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2806 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002807 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002808 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002809 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002810 return 0;
2811}
2812
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002813static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2814 int type, int idx, const char *name,
2815 unsigned long val)
2816{
2817 return stac92xx_add_control_temp(spec,
2818 &stac92xx_control_templates[type],
2819 idx, name, val);
2820}
2821
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002822
2823/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002824static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2825 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002826{
2827 return stac92xx_add_control_idx(spec, type, 0, name, val);
2828}
2829
Takashi Iwaie3c75962009-01-23 11:57:22 +01002830static struct snd_kcontrol_new stac_input_src_temp = {
2831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2832 .name = "Input Source",
2833 .info = stac92xx_mux_enum_info,
2834 .get = stac92xx_mux_enum_get,
2835 .put = stac92xx_mux_enum_put,
2836};
2837
2838static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2839{
2840 struct snd_kcontrol_new *knew;
2841 struct hda_input_mux *imux = &spec->private_imux;
2842
2843 if (!spec->num_adcs || imux->num_items <= 1)
2844 return 0; /* no need for input source control */
2845 knew = stac_control_new(spec, &stac_input_src_temp,
2846 stac_input_src_temp.name);
2847 if (!knew)
2848 return -ENOMEM;
2849 knew->count = spec->num_adcs;
2850 return 0;
2851}
2852
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002853/* check whether the line-input can be used as line-out */
2854static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002855{
2856 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002857 struct auto_pin_cfg *cfg = &spec->autocfg;
2858 hda_nid_t nid;
2859 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002860
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002861 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2862 return 0;
2863 nid = cfg->input_pins[AUTO_PIN_LINE];
2864 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2865 if (pincap & AC_PINCAP_OUT)
2866 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002867 return 0;
2868}
2869
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002870/* check whether the mic-input can be used as line-out */
2871static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2872{
2873 struct sigmatel_spec *spec = codec->spec;
2874 struct auto_pin_cfg *cfg = &spec->autocfg;
2875 unsigned int def_conf, pincap;
2876 unsigned int mic_pin;
2877
2878 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2879 return 0;
2880 mic_pin = AUTO_PIN_MIC;
2881 for (;;) {
2882 hda_nid_t nid = cfg->input_pins[mic_pin];
2883 def_conf = snd_hda_codec_read(codec, nid, 0,
2884 AC_VERB_GET_CONFIG_DEFAULT, 0);
2885 /* some laptops have an internal analog microphone
2886 * which can't be used as a output */
2887 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2888 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2889 if (pincap & AC_PINCAP_OUT)
2890 return nid;
2891 }
2892 if (mic_pin == AUTO_PIN_MIC)
2893 mic_pin = AUTO_PIN_FRONT_MIC;
2894 else
2895 break;
2896 }
2897 return 0;
2898}
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002899
2900static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2901{
2902 int i;
2903
2904 for (i = 0; i < spec->multiout.num_dacs; i++) {
2905 if (spec->multiout.dac_nids[i] == nid)
2906 return 1;
2907 }
2908
2909 return 0;
2910}
2911
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002912static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2913{
2914 int i;
2915 if (is_in_dac_nids(spec, nid))
2916 return 1;
2917 for (i = 0; i < spec->autocfg.hp_outs; i++)
2918 if (spec->hp_dacs[i] == nid)
2919 return 1;
2920 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2921 if (spec->speaker_dacs[i] == nid)
2922 return 1;
2923 return 0;
2924}
2925
2926static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2927{
2928 struct sigmatel_spec *spec = codec->spec;
2929 int j, conn_len;
2930 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2931 unsigned int wcaps, wtype;
2932
2933 conn_len = snd_hda_get_connections(codec, nid, conn,
2934 HDA_MAX_CONNECTIONS);
2935 for (j = 0; j < conn_len; j++) {
2936 wcaps = snd_hda_param_read(codec, conn[j],
2937 AC_PAR_AUDIO_WIDGET_CAP);
2938 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2939 /* we check only analog outputs */
2940 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2941 continue;
2942 /* if this route has a free DAC, assign it */
2943 if (!check_all_dac_nids(spec, conn[j])) {
2944 if (conn_len > 1) {
2945 /* select this DAC in the pin's input mux */
2946 snd_hda_codec_write_cache(codec, nid, 0,
2947 AC_VERB_SET_CONNECT_SEL, j);
2948 }
2949 return conn[j];
2950 }
2951 }
2952 return 0;
2953}
2954
2955static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2956static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2957
Matt Porter3cc08dc2006-01-23 15:27:49 +01002958/*
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002959 * Fill in the dac_nids table from the parsed pin configuration
2960 * This function only works when every pin in line_out_pins[]
2961 * contains atleast one DAC in its connection list. Some 92xx
2962 * codecs are not connected directly to a DAC, such as the 9200
2963 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002964 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002965static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002966{
2967 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002968 struct auto_pin_cfg *cfg = &spec->autocfg;
2969 int i;
2970 hda_nid_t nid, dac;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002971
Mattc7d4b2f2005-06-27 14:59:41 +02002972 for (i = 0; i < cfg->line_outs; i++) {
2973 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002974 dac = get_unassigned_dac(codec, nid);
2975 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002976 if (spec->multiout.num_dacs > 0) {
2977 /* we have already working output pins,
2978 * so let's drop the broken ones again
2979 */
2980 cfg->line_outs = spec->multiout.num_dacs;
2981 break;
2982 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002983 /* error out, no available DAC found */
2984 snd_printk(KERN_ERR
2985 "%s: No available DAC for pin 0x%x\n",
2986 __func__, nid);
2987 return -ENODEV;
2988 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002989 add_spec_dacs(spec, dac);
2990 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002991
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002992 /* add line-in as output */
2993 nid = check_line_out_switch(codec);
2994 if (nid) {
2995 dac = get_unassigned_dac(codec, nid);
2996 if (dac) {
2997 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2998 nid, cfg->line_outs);
2999 cfg->line_out_pins[cfg->line_outs] = nid;
3000 cfg->line_outs++;
3001 spec->line_switch = nid;
3002 add_spec_dacs(spec, dac);
3003 }
3004 }
3005 /* add mic as output */
3006 nid = check_mic_out_switch(codec);
3007 if (nid) {
3008 dac = get_unassigned_dac(codec, nid);
3009 if (dac) {
3010 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3011 nid, cfg->line_outs);
3012 cfg->line_out_pins[cfg->line_outs] = nid;
3013 cfg->line_outs++;
3014 spec->mic_switch = nid;
3015 add_spec_dacs(spec, dac);
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003016 }
Mattc7d4b2f2005-06-27 14:59:41 +02003017 }
3018
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003019 for (i = 0; i < cfg->hp_outs; i++) {
3020 nid = cfg->hp_pins[i];
3021 dac = get_unassigned_dac(codec, nid);
3022 if (dac) {
3023 if (!spec->multiout.hp_nid)
3024 spec->multiout.hp_nid = dac;
3025 else
3026 add_spec_extra_dacs(spec, dac);
3027 }
3028 spec->hp_dacs[i] = dac;
3029 }
3030
3031 for (i = 0; i < cfg->speaker_outs; i++) {
3032 nid = cfg->speaker_pins[i];
3033 dac = get_unassigned_dac(codec, nid);
3034 if (dac)
3035 add_spec_extra_dacs(spec, dac);
3036 spec->speaker_dacs[i] = dac;
3037 }
3038
3039 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003040 spec->multiout.num_dacs,
3041 spec->multiout.dac_nids[0],
3042 spec->multiout.dac_nids[1],
3043 spec->multiout.dac_nids[2],
3044 spec->multiout.dac_nids[3],
3045 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003046
Mattc7d4b2f2005-06-27 14:59:41 +02003047 return 0;
3048}
3049
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003050/* create volume control/switch for the given prefx type */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003051static int create_controls(struct hda_codec *codec, const char *pfx,
3052 hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003053{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003054 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003055 char name[32];
3056 int err;
3057
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003058 if (!spec->check_volume_offset) {
3059 unsigned int caps, step, nums, db_scale;
3060 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3061 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3062 AC_AMPCAP_STEP_SIZE_SHIFT;
3063 step = (step + 1) * 25; /* in .01dB unit */
3064 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3065 AC_AMPCAP_NUM_STEPS_SHIFT;
3066 db_scale = nums * step;
3067 /* if dB scale is over -64dB, and finer enough,
3068 * let's reduce it to half
3069 */
3070 if (db_scale > 6400 && nums >= 0x1f)
3071 spec->volume_offset = nums / 2;
3072 spec->check_volume_offset = 1;
3073 }
3074
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003075 sprintf(name, "%s Playback Volume", pfx);
3076 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003077 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3078 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003079 if (err < 0)
3080 return err;
3081 sprintf(name, "%s Playback Switch", pfx);
3082 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
3083 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3084 if (err < 0)
3085 return err;
3086 return 0;
3087}
3088
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003089static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3090{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003091 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003092 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3093 return 1;
3094 } else {
3095 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3096 spec->multiout.num_dacs++;
3097 }
3098 return 0;
3099}
3100
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003101static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003102{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003103 int i;
3104 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3105 if (!spec->multiout.extra_out_nid[i]) {
3106 spec->multiout.extra_out_nid[i] = nid;
3107 return 0;
3108 }
3109 }
3110 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3111 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003112}
3113
Takashi Iwai76624532008-12-19 10:09:47 +01003114static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3115{
3116 int i;
3117
3118 if (spec->autocfg.line_outs != 1)
3119 return 0;
3120 if (spec->multiout.hp_nid == nid)
3121 return 0;
3122 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3123 if (spec->multiout.extra_out_nid[i] == nid)
3124 return 0;
3125 return 1;
3126}
3127
Mattc7d4b2f2005-06-27 14:59:41 +02003128/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003129static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003130 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003131{
Takashi Iwai76624532008-12-19 10:09:47 +01003132 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003133 static const char *chname[4] = {
3134 "Front", "Surround", NULL /*CLFE*/, "Side"
3135 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003136 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003137 int i, err;
3138 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003139
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003140 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003141 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003142 if (i == 2) {
3143 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003144 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003145 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003146 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003147 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003148 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003149 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003150
3151 wid_caps = get_wcaps(codec, nid);
3152
3153 if (wid_caps & AC_WCAP_LR_SWAP) {
3154 err = stac92xx_add_control(spec,
3155 STAC_CTL_WIDGET_CLFE_SWITCH,
3156 "Swap Center/LFE Playback Switch", nid);
3157
3158 if (err < 0)
3159 return err;
3160 }
3161
Mattc7d4b2f2005-06-27 14:59:41 +02003162 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003163 const char *name = chname[i];
3164 /* if it's a single DAC, assign a better name */
3165 if (!i && is_unique_dac(spec, nid)) {
3166 switch (cfg->line_out_type) {
3167 case AUTO_PIN_HP_OUT:
3168 name = "Headphone";
3169 break;
3170 case AUTO_PIN_SPEAKER_OUT:
3171 name = "Speaker";
3172 break;
3173 }
3174 }
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003175 err = create_controls(codec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003176 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003177 return err;
3178 }
3179 }
3180
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003181 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003182 err = stac92xx_add_control(spec,
3183 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003184 "Headphone as Line Out Switch",
3185 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003186 if (err < 0)
3187 return err;
3188 }
3189
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003190 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003191 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3192 "Line In as Output Switch",
3193 spec->line_switch << 8);
3194 if (err < 0)
3195 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003196 }
Matt Porter403d1942005-11-29 15:00:51 +01003197
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003198 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003199 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3200 "Mic as Output Switch",
3201 (spec->mic_switch << 8) | 1);
3202 if (err < 0)
3203 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003204 }
Matt Porter403d1942005-11-29 15:00:51 +01003205
Mattc7d4b2f2005-06-27 14:59:41 +02003206 return 0;
3207}
3208
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003209/* add playback controls for Speaker and HP outputs */
3210static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3211 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003212{
3213 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003214 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003215 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003216
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003217 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003218 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003219 static const char *pfxs[] = {
3220 "Headphone", "Headphone2", "Headphone3",
3221 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003222 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3223 if (wid_caps & AC_WCAP_UNSOL_CAP)
3224 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003225 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003226 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003227 nid = spec->hp_dacs[i];
3228 if (!nid)
3229 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003230 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003231 if (err < 0)
3232 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003233 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003234 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003235 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003236 static const char *pfxs[] = {
3237 "Speaker", "External Speaker", "Speaker2",
3238 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003239 if (nums >= ARRAY_SIZE(pfxs))
3240 continue;
3241 nid = spec->speaker_dacs[i];
3242 if (!nid)
3243 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003244 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003245 if (err < 0)
3246 return err;
3247 }
Mattc7d4b2f2005-06-27 14:59:41 +02003248 return 0;
3249}
3250
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003251/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003252static const char *stac92xx_mono_labels[4] = {
3253 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003254};
3255
3256/* create mono mux for mono out on capable codecs */
3257static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3258{
3259 struct sigmatel_spec *spec = codec->spec;
3260 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3261 int i, num_cons;
3262 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3263
3264 num_cons = snd_hda_get_connections(codec,
3265 spec->mono_nid,
3266 con_lst,
3267 HDA_MAX_NUM_INPUTS);
3268 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3269 return -EINVAL;
3270
3271 for (i = 0; i < num_cons; i++) {
3272 mono_mux->items[mono_mux->num_items].label =
3273 stac92xx_mono_labels[i];
3274 mono_mux->items[mono_mux->num_items].index = i;
3275 mono_mux->num_items++;
3276 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003277
3278 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3279 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003280}
3281
Matthew Ranostay89385032008-09-11 09:49:39 -04003282/* labels for amp mux outputs */
3283static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003284 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003285};
3286
3287/* create amp out controls mux on capable codecs */
3288static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3289{
3290 struct sigmatel_spec *spec = codec->spec;
3291 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3292 int i, err;
3293
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003294 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003295 amp_mux->items[amp_mux->num_items].label =
3296 stac92xx_amp_labels[i];
3297 amp_mux->items[amp_mux->num_items].index = i;
3298 amp_mux->num_items++;
3299 }
3300
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003301 if (spec->num_amps > 1) {
3302 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3303 "Amp Selector Capture Switch", 0);
3304 if (err < 0)
3305 return err;
3306 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003307 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3308 "Amp Capture Volume",
3309 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3310}
3311
3312
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003313/* create PC beep volume controls */
3314static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3315 hda_nid_t nid)
3316{
3317 struct sigmatel_spec *spec = codec->spec;
3318 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3319 int err;
3320
3321 /* check for mute support for the the amp */
3322 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3323 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3324 "PC Beep Playback Switch",
3325 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3326 if (err < 0)
3327 return err;
3328 }
3329
3330 /* check to see if there is volume support for the amp */
3331 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3332 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3333 "PC Beep Playback Volume",
3334 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3335 if (err < 0)
3336 return err;
3337 }
3338 return 0;
3339}
3340
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003341#ifdef CONFIG_SND_HDA_INPUT_BEEP
3342#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3343
3344static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3345 struct snd_ctl_elem_value *ucontrol)
3346{
3347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3348 ucontrol->value.integer.value[0] = codec->beep->enabled;
3349 return 0;
3350}
3351
3352static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3353 struct snd_ctl_elem_value *ucontrol)
3354{
3355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3356 int enabled = !!ucontrol->value.integer.value[0];
3357 if (codec->beep->enabled != enabled) {
3358 codec->beep->enabled = enabled;
3359 return 1;
3360 }
3361 return 0;
3362}
3363
3364static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3366 .info = stac92xx_dig_beep_switch_info,
3367 .get = stac92xx_dig_beep_switch_get,
3368 .put = stac92xx_dig_beep_switch_put,
3369};
3370
3371static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3372{
3373 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3374 0, "PC Beep Playback Switch", 0);
3375}
3376#endif
3377
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003378static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3379{
3380 struct sigmatel_spec *spec = codec->spec;
3381 int wcaps, nid, i, err = 0;
3382
3383 for (i = 0; i < spec->num_muxes; i++) {
3384 nid = spec->mux_nids[i];
3385 wcaps = get_wcaps(codec, nid);
3386
3387 if (wcaps & AC_WCAP_OUT_AMP) {
3388 err = stac92xx_add_control_idx(spec,
3389 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3390 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3391 if (err < 0)
3392 return err;
3393 }
3394 }
3395 return 0;
3396};
3397
Matthew Ranostayd9737752008-09-07 12:03:41 +02003398static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003399 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003400};
3401
3402static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3403{
3404 struct sigmatel_spec *spec = codec->spec;
3405 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003406 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003407 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003408 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003409
3410 num_cons = snd_hda_get_connections(codec,
3411 spec->smux_nids[0],
3412 con_lst,
3413 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003414 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003415 return -EINVAL;
3416
Matthew Ranostay65973632008-09-16 10:39:37 -04003417 if (!labels)
3418 labels = stac92xx_spdif_labels;
3419
Matthew Ranostayd9737752008-09-07 12:03:41 +02003420 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003421 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003422 spdif_mux->items[spdif_mux->num_items].index = i;
3423 spdif_mux->num_items++;
3424 }
3425
3426 return 0;
3427}
3428
Matt Porter8b657272006-10-26 17:12:59 +02003429/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003430static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003431 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3432 "Digital Mic 3", "Digital Mic 4"
3433};
3434
3435/* create playback/capture controls for input pins on dmic capable codecs */
3436static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3437 const struct auto_pin_cfg *cfg)
3438{
3439 struct sigmatel_spec *spec = codec->spec;
3440 struct hda_input_mux *dimux = &spec->private_dimux;
3441 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003442 int err, i, j;
3443 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003444
3445 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3446 dimux->items[dimux->num_items].index = 0;
3447 dimux->num_items++;
3448
3449 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003450 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003451 int index;
3452 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003453 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003454 unsigned int def_conf;
3455
3456 def_conf = snd_hda_codec_read(codec,
3457 spec->dmic_nids[i],
3458 0,
3459 AC_VERB_GET_CONFIG_DEFAULT,
3460 0);
3461 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3462 continue;
3463
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003464 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003465 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003466 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003467 con_lst,
3468 HDA_MAX_NUM_INPUTS);
3469 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003470 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003471 index = j;
3472 goto found;
3473 }
3474 continue;
3475found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003476 wcaps = get_wcaps(codec, nid) &
3477 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003478
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003479 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003480 sprintf(name, "%s Capture Volume",
3481 stac92xx_dmic_labels[dimux->num_items]);
3482
3483 err = stac92xx_add_control(spec,
3484 STAC_CTL_WIDGET_VOL,
3485 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003486 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3487 (wcaps & AC_WCAP_OUT_AMP) ?
3488 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003489 if (err < 0)
3490 return err;
3491 }
3492
Matt Porter8b657272006-10-26 17:12:59 +02003493 dimux->items[dimux->num_items].label =
3494 stac92xx_dmic_labels[dimux->num_items];
3495 dimux->items[dimux->num_items].index = index;
3496 dimux->num_items++;
3497 }
3498
3499 return 0;
3500}
3501
Mattc7d4b2f2005-06-27 14:59:41 +02003502/* create playback/capture controls for input pins */
3503static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3504{
3505 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003506 struct hda_input_mux *imux = &spec->private_imux;
3507 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3508 int i, j, k;
3509
3510 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003511 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003512
Takashi Iwai314634b2006-09-21 11:56:18 +02003513 if (!cfg->input_pins[i])
3514 continue;
3515 index = -1;
3516 for (j = 0; j < spec->num_muxes; j++) {
3517 int num_cons;
3518 num_cons = snd_hda_get_connections(codec,
3519 spec->mux_nids[j],
3520 con_lst,
3521 HDA_MAX_NUM_INPUTS);
3522 for (k = 0; k < num_cons; k++)
3523 if (con_lst[k] == cfg->input_pins[i]) {
3524 index = k;
3525 goto found;
3526 }
Mattc7d4b2f2005-06-27 14:59:41 +02003527 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003528 continue;
3529 found:
3530 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3531 imux->items[imux->num_items].index = index;
3532 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003533 }
3534
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003535 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003536 /*
3537 * Set the current input for the muxes.
3538 * The STAC9221 has two input muxes with identical source
3539 * NID lists. Hopefully this won't get confused.
3540 */
3541 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003542 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3543 AC_VERB_SET_CONNECT_SEL,
3544 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003545 }
3546 }
3547
Mattc7d4b2f2005-06-27 14:59:41 +02003548 return 0;
3549}
3550
Mattc7d4b2f2005-06-27 14:59:41 +02003551static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3552{
3553 struct sigmatel_spec *spec = codec->spec;
3554 int i;
3555
3556 for (i = 0; i < spec->autocfg.line_outs; i++) {
3557 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3558 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3559 }
3560}
3561
3562static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3563{
3564 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003565 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003566
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003567 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3568 hda_nid_t pin;
3569 pin = spec->autocfg.hp_pins[i];
3570 if (pin) /* connect to front */
3571 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3572 }
3573 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3574 hda_nid_t pin;
3575 pin = spec->autocfg.speaker_pins[i];
3576 if (pin) /* connect to front */
3577 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3578 }
Mattc7d4b2f2005-06-27 14:59:41 +02003579}
3580
Matt Porter3cc08dc2006-01-23 15:27:49 +01003581static 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 +02003582{
3583 struct sigmatel_spec *spec = codec->spec;
3584 int err;
3585
Matt Porter8b657272006-10-26 17:12:59 +02003586 if ((err = snd_hda_parse_pin_def_config(codec,
3587 &spec->autocfg,
3588 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003589 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003590 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003591 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003592
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003593 /* If we have no real line-out pin and multiple hp-outs, HPs should
3594 * be set up as multi-channel outputs.
3595 */
3596 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3597 spec->autocfg.hp_outs > 1) {
3598 /* Copy hp_outs to line_outs, backup line_outs in
3599 * speaker_outs so that the following routines can handle
3600 * HP pins as primary outputs.
3601 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003602 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003603 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3604 sizeof(spec->autocfg.line_out_pins));
3605 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3606 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3607 sizeof(spec->autocfg.hp_pins));
3608 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003609 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3610 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003611 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003612 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003613 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3614 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003615 u32 caps = query_amp_caps(codec,
3616 spec->autocfg.mono_out_pin, dir);
3617 hda_nid_t conn_list[1];
3618
3619 /* get the mixer node and then the mono mux if it exists */
3620 if (snd_hda_get_connections(codec,
3621 spec->autocfg.mono_out_pin, conn_list, 1) &&
3622 snd_hda_get_connections(codec, conn_list[0],
3623 conn_list, 1)) {
3624
3625 int wcaps = get_wcaps(codec, conn_list[0]);
3626 int wid_type = (wcaps & AC_WCAP_TYPE)
3627 >> AC_WCAP_TYPE_SHIFT;
3628 /* LR swap check, some stac925x have a mux that
3629 * changes the DACs output path instead of the
3630 * mono-mux path.
3631 */
3632 if (wid_type == AC_WID_AUD_SEL &&
3633 !(wcaps & AC_WCAP_LR_SWAP))
3634 spec->mono_nid = conn_list[0];
3635 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003636 if (dir) {
3637 hda_nid_t nid = spec->autocfg.mono_out_pin;
3638
3639 /* most mono outs have a least a mute/unmute switch */
3640 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3641 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3642 "Mono Playback Switch",
3643 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003644 if (err < 0)
3645 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003646 /* check for volume support for the amp */
3647 if ((caps & AC_AMPCAP_NUM_STEPS)
3648 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3649 err = stac92xx_add_control(spec,
3650 STAC_CTL_WIDGET_VOL,
3651 "Mono Playback Volume",
3652 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3653 if (err < 0)
3654 return err;
3655 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003656 }
3657
3658 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3659 AC_PINCTL_OUT_EN);
3660 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003661
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003662 if (!spec->multiout.num_dacs) {
3663 err = stac92xx_auto_fill_dac_nids(codec);
3664 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003665 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003666 err = stac92xx_auto_create_multi_out_ctls(codec,
3667 &spec->autocfg);
3668 if (err < 0)
3669 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003670 }
Mattc7d4b2f2005-06-27 14:59:41 +02003671
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003672 /* setup analog beep controls */
3673 if (spec->anabeep_nid > 0) {
3674 err = stac92xx_auto_create_beep_ctls(codec,
3675 spec->anabeep_nid);
3676 if (err < 0)
3677 return err;
3678 }
3679
3680 /* setup digital beep controls and input device */
3681#ifdef CONFIG_SND_HDA_INPUT_BEEP
3682 if (spec->digbeep_nid > 0) {
3683 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003684 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003685
3686 err = stac92xx_auto_create_beep_ctls(codec, nid);
3687 if (err < 0)
3688 return err;
3689 err = snd_hda_attach_beep_device(codec, nid);
3690 if (err < 0)
3691 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003692 /* if no beep switch is available, make its own one */
3693 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3694 if (codec->beep &&
3695 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3696 err = stac92xx_beep_switch_ctl(codec);
3697 if (err < 0)
3698 return err;
3699 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003700 }
3701#endif
3702
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003703 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3704
3705 if (err < 0)
3706 return err;
3707
3708 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3709
3710 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003711 return err;
3712
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003713 if (spec->mono_nid > 0) {
3714 err = stac92xx_auto_create_mono_output_ctls(codec);
3715 if (err < 0)
3716 return err;
3717 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003718 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003719 err = stac92xx_auto_create_amp_output_ctls(codec);
3720 if (err < 0)
3721 return err;
3722 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003723 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003724 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3725 &spec->autocfg)) < 0)
3726 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003727 if (spec->num_muxes > 0) {
3728 err = stac92xx_auto_create_mux_input_ctls(codec);
3729 if (err < 0)
3730 return err;
3731 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003732 if (spec->num_smuxes > 0) {
3733 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3734 if (err < 0)
3735 return err;
3736 }
Matt Porter8b657272006-10-26 17:12:59 +02003737
Takashi Iwaie3c75962009-01-23 11:57:22 +01003738 err = stac92xx_add_input_source(spec);
3739 if (err < 0)
3740 return err;
3741
Mattc7d4b2f2005-06-27 14:59:41 +02003742 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003743 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003744 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003745
Takashi Iwai82bc9552006-03-21 11:24:42 +01003746 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003747 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003748 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003749 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003750
Takashi Iwai603c4012008-07-30 15:01:44 +02003751 if (spec->kctls.list)
3752 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003753
3754 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003755 if (!spec->dinput_mux)
3756 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003757 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003758 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003759 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003760 return 1;
3761}
3762
Takashi Iwai82bc9552006-03-21 11:24:42 +01003763/* add playback controls for HP output */
3764static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3765 struct auto_pin_cfg *cfg)
3766{
3767 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003768 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003769 unsigned int wid_caps;
3770
3771 if (! pin)
3772 return 0;
3773
3774 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003775 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003776 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003777
3778 return 0;
3779}
3780
Richard Fish160ea0d2006-09-06 13:58:25 +02003781/* add playback controls for LFE output */
3782static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3783 struct auto_pin_cfg *cfg)
3784{
3785 struct sigmatel_spec *spec = codec->spec;
3786 int err;
3787 hda_nid_t lfe_pin = 0x0;
3788 int i;
3789
3790 /*
3791 * search speaker outs and line outs for a mono speaker pin
3792 * with an amp. If one is found, add LFE controls
3793 * for it.
3794 */
3795 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3796 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003797 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003798 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3799 if (wcaps == AC_WCAP_OUT_AMP)
3800 /* found a mono speaker with an amp, must be lfe */
3801 lfe_pin = pin;
3802 }
3803
3804 /* if speaker_outs is 0, then speakers may be in line_outs */
3805 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3806 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3807 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003808 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003809 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003810 AC_VERB_GET_CONFIG_DEFAULT,
3811 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003812 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003813 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003814 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3815 if (wcaps == AC_WCAP_OUT_AMP)
3816 /* found a mono speaker with an amp,
3817 must be lfe */
3818 lfe_pin = pin;
3819 }
3820 }
3821 }
3822
3823 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003824 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003825 if (err < 0)
3826 return err;
3827 }
3828
3829 return 0;
3830}
3831
Mattc7d4b2f2005-06-27 14:59:41 +02003832static int stac9200_parse_auto_config(struct hda_codec *codec)
3833{
3834 struct sigmatel_spec *spec = codec->spec;
3835 int err;
3836
Kailang Yangdf694da2005-12-05 19:42:22 +01003837 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003838 return err;
3839
3840 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3841 return err;
3842
Takashi Iwai82bc9552006-03-21 11:24:42 +01003843 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3844 return err;
3845
Richard Fish160ea0d2006-09-06 13:58:25 +02003846 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3847 return err;
3848
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003849 if (spec->num_muxes > 0) {
3850 err = stac92xx_auto_create_mux_input_ctls(codec);
3851 if (err < 0)
3852 return err;
3853 }
3854
Takashi Iwaie3c75962009-01-23 11:57:22 +01003855 err = stac92xx_add_input_source(spec);
3856 if (err < 0)
3857 return err;
3858
Takashi Iwai82bc9552006-03-21 11:24:42 +01003859 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003860 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003861 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003862 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003863
Takashi Iwai603c4012008-07-30 15:01:44 +02003864 if (spec->kctls.list)
3865 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003866
3867 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003868 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003869
3870 return 1;
3871}
3872
Sam Revitch62fe78e2006-05-10 15:09:17 +02003873/*
3874 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3875 * funky external mute control using GPIO pins.
3876 */
3877
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003878static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003879 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003880{
3881 unsigned int gpiostate, gpiomask, gpiodir;
3882
3883 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3884 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003885 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003886
3887 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3888 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003889 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003890
3891 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3892 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01003893 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003894
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003895 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003896 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3897
3898 snd_hda_codec_write(codec, codec->afg, 0,
3899 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003900 snd_hda_codec_read(codec, codec->afg, 0,
3901 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003902
3903 msleep(1);
3904
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003905 snd_hda_codec_read(codec, codec->afg, 0,
3906 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003907}
3908
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003909static int stac92xx_add_jack(struct hda_codec *codec,
3910 hda_nid_t nid, int type)
3911{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003912#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003913 struct sigmatel_spec *spec = codec->spec;
3914 struct sigmatel_jack *jack;
3915 int def_conf = snd_hda_codec_read(codec, nid,
3916 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3917 int connectivity = get_defcfg_connect(def_conf);
3918 char name[32];
3919
3920 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3921 return 0;
3922
3923 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3924 jack = snd_array_new(&spec->jacks);
3925 if (!jack)
3926 return -ENOMEM;
3927 jack->nid = nid;
3928 jack->type = type;
3929
3930 sprintf(name, "%s at %s %s Jack",
3931 snd_hda_get_jack_type(def_conf),
3932 snd_hda_get_jack_connectivity(def_conf),
3933 snd_hda_get_jack_location(def_conf));
3934
3935 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003936#else
3937 return 0;
3938#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003939}
3940
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003941static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3942 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003943{
3944 struct sigmatel_event *event;
3945
3946 snd_array_init(&spec->events, sizeof(*event), 32);
3947 event = snd_array_new(&spec->events);
3948 if (!event)
3949 return -ENOMEM;
3950 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003951 event->type = type;
3952 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003953 event->data = data;
3954
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003955 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003956}
3957
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003958static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3959 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003960{
3961 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003962 struct sigmatel_event *event = spec->events.list;
3963 int i;
3964
3965 for (i = 0; i < spec->events.used; i++, event++) {
3966 if (event->nid == nid && event->type == type)
3967 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003968 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003969 return NULL;
3970}
3971
3972static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3973 unsigned char tag)
3974{
3975 struct sigmatel_spec *spec = codec->spec;
3976 struct sigmatel_event *event = spec->events.list;
3977 int i;
3978
3979 for (i = 0; i < spec->events.used; i++, event++) {
3980 if (event->tag == tag)
3981 return event;
3982 }
3983 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003984}
3985
Takashi Iwai314634b2006-09-21 11:56:18 +02003986static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003987 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003988{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003989 struct sigmatel_event *event;
3990 int tag;
3991
3992 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3993 return;
3994 event = stac_get_event(codec, nid, type);
3995 if (event)
3996 tag = event->tag;
3997 else
3998 tag = stac_add_event(codec->spec, nid, type, 0);
3999 if (tag < 0)
4000 return;
4001 snd_hda_codec_write_cache(codec, nid, 0,
4002 AC_VERB_SET_UNSOLICITED_ENABLE,
4003 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02004004}
4005
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004006static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4007{
4008 int i;
4009 for (i = 0; i < cfg->hp_outs; i++)
4010 if (cfg->hp_pins[i] == nid)
4011 return 1; /* nid is a HP-Out */
4012
4013 return 0; /* nid is not a HP-Out */
4014};
4015
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004016static void stac92xx_power_down(struct hda_codec *codec)
4017{
4018 struct sigmatel_spec *spec = codec->spec;
4019
4020 /* power down inactive DACs */
4021 hda_nid_t *dac;
4022 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004023 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004024 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004025 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4026}
4027
Takashi Iwaif73d3582008-11-25 08:21:51 +01004028static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4029 int enable);
4030
Mattc7d4b2f2005-06-27 14:59:41 +02004031static int stac92xx_init(struct hda_codec *codec)
4032{
4033 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004034 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004035 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004036 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004037
Mattc7d4b2f2005-06-27 14:59:41 +02004038 snd_hda_sequence_write(codec, spec->init);
4039
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004040 /* power down adcs initially */
4041 if (spec->powerdown_adcs)
4042 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004043 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004044 spec->adc_nids[i], 0,
4045 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004046
4047 /* set up GPIO */
4048 gpio = spec->gpio_data;
4049 /* turn on EAPD statically when spec->eapd_switch isn't set.
4050 * otherwise, unsol event will turn it on/off dynamically
4051 */
4052 if (!spec->eapd_switch)
4053 gpio |= spec->eapd_mask;
4054 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4055
Takashi Iwai82bc9552006-03-21 11:24:42 +01004056 /* set up pins */
4057 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004058 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004059 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004060 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004061 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004062 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004063 /* force to enable the first line-out; the others are set up
4064 * in unsol_event
4065 */
4066 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004067 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004068 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004069 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4070 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004071 } else {
4072 stac92xx_auto_init_multi_out(codec);
4073 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004074 for (i = 0; i < cfg->hp_outs; i++)
4075 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004076 }
4077 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004078 hda_nid_t nid = cfg->input_pins[i];
4079 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004080 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004081 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4082 /* for mic pins, force to initialize */
4083 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004084 pinctl |= AC_PINCTL_IN_EN;
4085 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004086 } else {
4087 pinctl = snd_hda_codec_read(codec, nid, 0,
4088 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4089 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004090 if (!(pinctl & AC_PINCTL_IN_EN)) {
4091 pinctl |= AC_PINCTL_IN_EN;
4092 stac92xx_auto_set_pinctl(codec, nid,
4093 pinctl);
4094 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004095 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004096 conf = snd_hda_codec_read(codec, nid, 0,
4097 AC_VERB_GET_CONFIG_DEFAULT, 0);
4098 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4099 enable_pin_detect(codec, nid,
4100 STAC_INSERT_EVENT);
4101 stac_issue_unsol_event(codec, nid,
4102 STAC_INSERT_EVENT);
4103 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004104 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004105 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004106 for (i = 0; i < spec->num_dmics; i++)
4107 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4108 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004109 if (cfg->dig_out_pin)
4110 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
4111 AC_PINCTL_OUT_EN);
4112 if (cfg->dig_in_pin)
4113 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4114 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004115 for (i = 0; i < spec->num_pwrs; i++) {
4116 hda_nid_t nid = spec->pwr_nids[i];
4117 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004118
Takashi Iwaieb632122008-12-19 16:39:48 +01004119 /* power on when no jack detection is available */
4120 if (!spec->hp_detect) {
4121 stac_toggle_power_map(codec, nid, 1);
4122 continue;
4123 }
4124
4125 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004126 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004127
Takashi Iwaif73d3582008-11-25 08:21:51 +01004128 pinctl = snd_hda_codec_read(codec, nid, 0,
4129 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4130 /* outputs are only ports capable of power management
4131 * any attempts on powering down a input port cause the
4132 * referenced VREF to act quirky.
4133 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004134 if (pinctl & AC_PINCTL_IN_EN) {
4135 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004136 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004137 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004138 def_conf = snd_hda_codec_read(codec, nid, 0,
4139 AC_VERB_GET_CONFIG_DEFAULT, 0);
4140 def_conf = get_defcfg_connect(def_conf);
4141 /* skip any ports that don't have jacks since presence
4142 * detection is useless */
4143 if (def_conf != AC_JACK_PORT_COMPLEX) {
4144 if (def_conf != AC_JACK_PORT_NONE)
4145 stac_toggle_power_map(codec, nid, 1);
4146 continue;
4147 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004148 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4149 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4150 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4151 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004152 }
4153 if (spec->dac_list)
4154 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004155 return 0;
4156}
4157
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004158static void stac92xx_free_jacks(struct hda_codec *codec)
4159{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004160#ifdef CONFIG_SND_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004161 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004162 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004163 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004164 struct sigmatel_jack *jacks = spec->jacks.list;
4165 int i;
4166 for (i = 0; i < spec->jacks.used; i++)
4167 snd_device_free(codec->bus->card, &jacks[i].jack);
4168 }
4169 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004170#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004171}
4172
Takashi Iwai603c4012008-07-30 15:01:44 +02004173static void stac92xx_free_kctls(struct hda_codec *codec)
4174{
4175 struct sigmatel_spec *spec = codec->spec;
4176
4177 if (spec->kctls.list) {
4178 struct snd_kcontrol_new *kctl = spec->kctls.list;
4179 int i;
4180 for (i = 0; i < spec->kctls.used; i++)
4181 kfree(kctl[i].name);
4182 }
4183 snd_array_free(&spec->kctls);
4184}
4185
Matt2f2f4252005-04-13 14:45:30 +02004186static void stac92xx_free(struct hda_codec *codec)
4187{
Mattc7d4b2f2005-06-27 14:59:41 +02004188 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004189
4190 if (! spec)
4191 return;
4192
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01004193 kfree(spec->pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004194 stac92xx_free_jacks(codec);
4195 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004196
Mattc7d4b2f2005-06-27 14:59:41 +02004197 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004198 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004199}
4200
Matt4e550962005-07-04 17:51:39 +02004201static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4202 unsigned int flag)
4203{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004204 unsigned int old_ctl, pin_ctl;
4205
4206 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004207 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b0438992007-05-03 20:50:03 +02004208
Takashi Iwaif9acba42007-05-29 18:01:06 +02004209 if (pin_ctl & AC_PINCTL_IN_EN) {
4210 /*
4211 * we need to check the current set-up direction of
4212 * shared input pins since they can be switched via
4213 * "xxx as Output" mixer switch
4214 */
4215 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004216 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004217 return;
4218 }
4219
Takashi Iwai8ce84192009-01-22 16:59:20 +01004220 old_ctl = pin_ctl;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02004221 /* if setting pin direction bits, clear the current
4222 direction bits first */
4223 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4224 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4225
Takashi Iwai8ce84192009-01-22 16:59:20 +01004226 pin_ctl |= flag;
4227 if (old_ctl != pin_ctl)
4228 snd_hda_codec_write_cache(codec, nid, 0,
4229 AC_VERB_SET_PIN_WIDGET_CONTROL,
4230 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004231}
4232
4233static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4234 unsigned int flag)
4235{
4236 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4237 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004238 if (pin_ctl & flag)
4239 snd_hda_codec_write_cache(codec, nid, 0,
4240 AC_VERB_SET_PIN_WIDGET_CONTROL,
4241 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004242}
4243
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004244static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004245{
4246 if (!nid)
4247 return 0;
4248 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004249 & (1 << 31))
4250 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004251 return 0;
4252}
4253
Takashi Iwaid7a89432008-11-12 09:48:04 +01004254/* return non-zero if the hp-pin of the given array index isn't
4255 * a jack-detection target
4256 */
4257static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4258{
4259 struct auto_pin_cfg *cfg = &spec->autocfg;
4260
4261 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004262 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004263 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004264 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004265 return 1;
4266 /* ignore if the pin is set as line-out */
4267 if (cfg->hp_pins[i] == spec->hp_switch)
4268 return 1;
4269 return 0;
4270}
4271
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004272static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004273{
4274 struct sigmatel_spec *spec = codec->spec;
4275 struct auto_pin_cfg *cfg = &spec->autocfg;
4276 int i, presence;
4277
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004278 presence = 0;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004279 if (spec->gpio_mute)
4280 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4281 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4282
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004283 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004284 if (presence)
4285 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004286 if (no_hp_sensing(spec, i))
4287 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004288 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4289 if (presence) {
4290 unsigned int pinctl;
4291 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4292 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4293 if (pinctl & AC_PINCTL_IN_EN)
4294 presence = 0; /* mic- or line-input */
4295 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004296 }
Matt4e550962005-07-04 17:51:39 +02004297
4298 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004299 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004300 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004301 stac92xx_reset_pinctl(codec, spec->hp_switch,
4302 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004303 for (i = 0; i < cfg->line_outs; i++)
4304 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4305 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004306 for (i = 0; i < cfg->speaker_outs; i++)
4307 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4308 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004309 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004310 stac_gpio_set(codec, spec->gpio_mask,
4311 spec->gpio_dir, spec->gpio_data &
4312 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004313 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004314 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004315 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004316 stac92xx_set_pinctl(codec, spec->hp_switch,
4317 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004318 for (i = 0; i < cfg->line_outs; i++)
4319 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4320 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004321 for (i = 0; i < cfg->speaker_outs; i++)
4322 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4323 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004324 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004325 stac_gpio_set(codec, spec->gpio_mask,
4326 spec->gpio_dir, spec->gpio_data |
4327 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004328 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004329 /* toggle hp outs */
4330 for (i = 0; i < cfg->hp_outs; i++) {
4331 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4332 if (no_hp_sensing(spec, i))
4333 continue;
4334 if (presence)
4335 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004336#if 0 /* FIXME */
4337/* Resetting the pinctl like below may lead to (a sort of) regressions
4338 * on some devices since they use the HP pin actually for line/speaker
4339 * outs although the default pin config shows a different pin (that is
4340 * wrong and useless).
4341 *
4342 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4343 * But, disabling the code below just works around it, and I'm too tired of
4344 * bug reports with such devices...
4345 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004346 else
4347 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004348#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004349 }
Matt4e550962005-07-04 17:51:39 +02004350}
4351
Takashi Iwaif73d3582008-11-25 08:21:51 +01004352static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4353 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004354{
4355 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004356 unsigned int idx, val;
4357
4358 for (idx = 0; idx < spec->num_pwrs; idx++) {
4359 if (spec->pwr_nids[idx] == nid)
4360 break;
4361 }
4362 if (idx >= spec->num_pwrs)
4363 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004364
4365 /* several codecs have two power down bits */
4366 if (spec->pwr_mapping)
4367 idx = spec->pwr_mapping[idx];
4368 else
4369 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004370
Takashi Iwaif73d3582008-11-25 08:21:51 +01004371 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4372 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004373 val &= ~idx;
4374 else
4375 val |= idx;
4376
4377 /* power down unused output ports */
4378 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004379}
4380
Takashi Iwaif73d3582008-11-25 08:21:51 +01004381static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4382{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004383 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004384}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004385
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004386static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4387{
4388 struct sigmatel_spec *spec = codec->spec;
4389 struct sigmatel_jack *jacks = spec->jacks.list;
4390
4391 if (jacks) {
4392 int i;
4393 for (i = 0; i < spec->jacks.used; i++) {
4394 if (jacks->nid == nid) {
4395 unsigned int pin_ctl =
4396 snd_hda_codec_read(codec, nid,
4397 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4398 0x00);
4399 int type = jacks->type;
4400 if (type == (SND_JACK_LINEOUT
4401 | SND_JACK_HEADPHONE))
4402 type = (pin_ctl & AC_PINCTL_HP_EN)
4403 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4404 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004405 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004406 ? type : 0);
4407 }
4408 jacks++;
4409 }
4410 }
4411}
Matt2f2f4252005-04-13 14:45:30 +02004412
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004413static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4414 unsigned char type)
4415{
4416 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4417 if (!event)
4418 return;
4419 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4420}
4421
Takashi Iwai314634b2006-09-21 11:56:18 +02004422static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4423{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004424 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004425 struct sigmatel_event *event;
4426 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004427
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004428 tag = (res >> 26) & 0x7f;
4429 event = stac_get_event_from_tag(codec, tag);
4430 if (!event)
4431 return;
4432
4433 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004434 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004435 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004436 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004437 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004438 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004439 if (spec->num_pwrs > 0)
4440 stac92xx_pin_sense(codec, event->nid);
4441 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004442 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004443 case STAC_VREF_EVENT:
4444 data = snd_hda_codec_read(codec, codec->afg, 0,
4445 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004446 /* toggle VREF state based on GPIOx status */
4447 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004448 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004449 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004450 }
4451}
4452
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004453#ifdef CONFIG_PROC_FS
4454static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4455 struct hda_codec *codec, hda_nid_t nid)
4456{
4457 if (nid == codec->afg)
4458 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4459 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4460}
4461
4462static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4463 struct hda_codec *codec,
4464 unsigned int verb)
4465{
4466 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4467 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4468}
4469
4470/* stac92hd71bxx, stac92hd73xx */
4471static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4472 struct hda_codec *codec, hda_nid_t nid)
4473{
4474 stac92hd_proc_hook(buffer, codec, nid);
4475 if (nid == codec->afg)
4476 analog_loop_proc_hook(buffer, codec, 0xfa0);
4477}
4478
4479static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4480 struct hda_codec *codec, hda_nid_t nid)
4481{
4482 if (nid == codec->afg)
4483 analog_loop_proc_hook(buffer, codec, 0xfe0);
4484}
4485
4486static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4487 struct hda_codec *codec, hda_nid_t nid)
4488{
4489 if (nid == codec->afg)
4490 analog_loop_proc_hook(buffer, codec, 0xfeb);
4491}
4492#else
4493#define stac92hd_proc_hook NULL
4494#define stac92hd7x_proc_hook NULL
4495#define stac9205_proc_hook NULL
4496#define stac927x_proc_hook NULL
4497#endif
4498
Takashi Iwaicb53c622007-08-10 17:21:45 +02004499#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004500static int stac92xx_resume(struct hda_codec *codec)
4501{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004502 struct sigmatel_spec *spec = codec->spec;
4503
Richard Fish11b44bb2006-08-23 18:31:34 +02004504 stac92xx_set_config_regs(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004505 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004506 snd_hda_codec_resume_amp(codec);
4507 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004508 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004509 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004510 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4511 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004512 return 0;
4513}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004514
4515static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4516{
4517 struct sigmatel_spec *spec = codec->spec;
4518 if (spec->eapd_mask)
4519 stac_gpio_set(codec, spec->gpio_mask,
4520 spec->gpio_dir, spec->gpio_data &
4521 ~spec->eapd_mask);
4522 return 0;
4523}
Mattff6fdc32005-06-27 15:06:52 +02004524#endif
4525
Matt2f2f4252005-04-13 14:45:30 +02004526static struct hda_codec_ops stac92xx_patch_ops = {
4527 .build_controls = stac92xx_build_controls,
4528 .build_pcms = stac92xx_build_pcms,
4529 .init = stac92xx_init,
4530 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004531 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004532#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004533 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004534 .resume = stac92xx_resume,
4535#endif
Matt2f2f4252005-04-13 14:45:30 +02004536};
4537
4538static int patch_stac9200(struct hda_codec *codec)
4539{
4540 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004541 int err;
Matt2f2f4252005-04-13 14:45:30 +02004542
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004543 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004544 if (spec == NULL)
4545 return -ENOMEM;
4546
4547 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004548 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004549 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004550 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4551 stac9200_models,
4552 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004553 if (spec->board_config < 0) {
4554 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4555 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01004556 } else
4557 err = stac_save_pin_cfgs(codec,
4558 stac9200_brd_tbl[spec->board_config]);
4559 if (err < 0) {
4560 stac92xx_free(codec);
4561 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004562 }
Matt2f2f4252005-04-13 14:45:30 +02004563
4564 spec->multiout.max_channels = 2;
4565 spec->multiout.num_dacs = 1;
4566 spec->multiout.dac_nids = stac9200_dac_nids;
4567 spec->adc_nids = stac9200_adc_nids;
4568 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004569 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004570 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004571 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004572 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004573
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004574 if (spec->board_config == STAC_9200_M4 ||
4575 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004576 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004577 spec->init = stac9200_eapd_init;
4578 else
4579 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004580 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004581
Takashi Iwai117f2572008-03-18 09:53:23 +01004582 if (spec->board_config == STAC_9200_PANASONIC) {
4583 spec->gpio_mask = spec->gpio_dir = 0x09;
4584 spec->gpio_data = 0x00;
4585 }
4586
Mattc7d4b2f2005-06-27 14:59:41 +02004587 err = stac9200_parse_auto_config(codec);
4588 if (err < 0) {
4589 stac92xx_free(codec);
4590 return err;
4591 }
Matt2f2f4252005-04-13 14:45:30 +02004592
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004593 /* CF-74 has no headphone detection, and the driver should *NOT*
4594 * do detection and HP/speaker toggle because the hardware does it.
4595 */
4596 if (spec->board_config == STAC_9200_PANASONIC)
4597 spec->hp_detect = 0;
4598
Matt2f2f4252005-04-13 14:45:30 +02004599 codec->patch_ops = stac92xx_patch_ops;
4600
4601 return 0;
4602}
4603
Tobin Davis8e21c342007-01-08 11:04:17 +01004604static int patch_stac925x(struct hda_codec *codec)
4605{
4606 struct sigmatel_spec *spec;
4607 int err;
4608
4609 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4610 if (spec == NULL)
4611 return -ENOMEM;
4612
4613 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004614 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004615 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004616
4617 /* Check first for codec ID */
4618 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4619 STAC_925x_MODELS,
4620 stac925x_models,
4621 stac925x_codec_id_cfg_tbl);
4622
4623 /* Now checks for PCI ID, if codec ID is not found */
4624 if (spec->board_config < 0)
4625 spec->board_config = snd_hda_check_board_config(codec,
4626 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004627 stac925x_models,
4628 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004629 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004630 if (spec->board_config < 0) {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004631 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004632 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004633 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01004634 } else
4635 err = stac_save_pin_cfgs(codec,
4636 stac925x_brd_tbl[spec->board_config]);
4637 if (err < 0) {
4638 stac92xx_free(codec);
4639 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01004640 }
4641
4642 spec->multiout.max_channels = 2;
4643 spec->multiout.num_dacs = 1;
4644 spec->multiout.dac_nids = stac925x_dac_nids;
4645 spec->adc_nids = stac925x_adc_nids;
4646 spec->mux_nids = stac925x_mux_nids;
4647 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004648 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004649 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004650 switch (codec->vendor_id) {
4651 case 0x83847632: /* STAC9202 */
4652 case 0x83847633: /* STAC9202D */
4653 case 0x83847636: /* STAC9251 */
4654 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004655 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004656 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004657 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4658 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004659 break;
4660 default:
4661 spec->num_dmics = 0;
4662 break;
4663 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004664
4665 spec->init = stac925x_core_init;
4666 spec->mixer = stac925x_mixer;
4667
4668 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004669 if (!err) {
4670 if (spec->board_config < 0) {
4671 printk(KERN_WARNING "hda_codec: No auto-config is "
4672 "available, default to model=ref\n");
4673 spec->board_config = STAC_925x_REF;
4674 goto again;
4675 }
4676 err = -EINVAL;
4677 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004678 if (err < 0) {
4679 stac92xx_free(codec);
4680 return err;
4681 }
4682
4683 codec->patch_ops = stac92xx_patch_ops;
4684
4685 return 0;
4686}
4687
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004688static struct hda_input_mux stac92hd73xx_dmux = {
4689 .num_items = 4,
4690 .items = {
4691 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004692 { "Digital Mic 1", 0x09 },
4693 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004694 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004695 }
4696};
4697
4698static int patch_stac92hd73xx(struct hda_codec *codec)
4699{
4700 struct sigmatel_spec *spec;
4701 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4702 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004703 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004704
4705 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4706 if (spec == NULL)
4707 return -ENOMEM;
4708
4709 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004710 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004711 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4712 spec->pin_nids = stac92hd73xx_pin_nids;
4713 spec->board_config = snd_hda_check_board_config(codec,
4714 STAC_92HD73XX_MODELS,
4715 stac92hd73xx_models,
4716 stac92hd73xx_cfg_tbl);
4717again:
4718 if (spec->board_config < 0) {
4719 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4720 " STAC92HD73XX, using BIOS defaults\n");
4721 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01004722 } else
4723 err = stac_save_pin_cfgs(codec,
4724 stac92hd73xx_brd_tbl[spec->board_config]);
4725 if (err < 0) {
4726 stac92xx_free(codec);
4727 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004728 }
4729
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004730 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004731 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4732
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004733 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004734 printk(KERN_WARNING "hda_codec: Could not determine "
4735 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004736 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004737 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004738 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004739 case 0x3: /* 6 Channel */
4740 spec->mixer = stac92hd73xx_6ch_mixer;
4741 spec->init = stac92hd73xx_6ch_core_init;
4742 break;
4743 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004744 spec->mixer = stac92hd73xx_8ch_mixer;
4745 spec->init = stac92hd73xx_8ch_core_init;
4746 break;
4747 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004748 spec->mixer = stac92hd73xx_10ch_mixer;
4749 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004750 }
4751 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004752
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004753 spec->aloopback_mask = 0x01;
4754 spec->aloopback_shift = 8;
4755
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004756 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004757 spec->mux_nids = stac92hd73xx_mux_nids;
4758 spec->adc_nids = stac92hd73xx_adc_nids;
4759 spec->dmic_nids = stac92hd73xx_dmic_nids;
4760 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004761 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004762 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004763 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004764
4765 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4766 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004767 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004768 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4769 sizeof(stac92hd73xx_dmux));
4770
Matthew Ranostaya7662642008-02-21 07:51:14 +01004771 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004772 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004773 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004774 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004775 case STAC_DELL_M6_AMIC:
4776 case STAC_DELL_M6_DMIC:
4777 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004778 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004779 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4780 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004781 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004782 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004783
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004784 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004785 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004786 switch (spec->board_config) {
4787 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004788 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4789 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004790 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004791 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004792 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004793 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4794 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004795 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004796 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004797 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004798 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4799 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4800 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004801 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004802 break;
4803 }
4804 break;
4805 default:
4806 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004807 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004808 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004809 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004810 if (spec->board_config > STAC_92HD73XX_REF) {
4811 /* GPIO0 High = Enable EAPD */
4812 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4813 spec->gpio_data = 0x01;
4814 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004815 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004816
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004817 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4818 spec->pwr_nids = stac92hd73xx_pwr_nids;
4819
Matthew Ranostayd9737752008-09-07 12:03:41 +02004820 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004821
4822 if (!err) {
4823 if (spec->board_config < 0) {
4824 printk(KERN_WARNING "hda_codec: No auto-config is "
4825 "available, default to model=ref\n");
4826 spec->board_config = STAC_92HD73XX_REF;
4827 goto again;
4828 }
4829 err = -EINVAL;
4830 }
4831
4832 if (err < 0) {
4833 stac92xx_free(codec);
4834 return err;
4835 }
4836
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004837 if (spec->board_config == STAC_92HD73XX_NO_JD)
4838 spec->hp_detect = 0;
4839
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004840 codec->patch_ops = stac92xx_patch_ops;
4841
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004842 codec->proc_widget_hook = stac92hd7x_proc_hook;
4843
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004844 return 0;
4845}
4846
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004847static struct hda_input_mux stac92hd83xxx_dmux = {
4848 .num_items = 3,
4849 .items = {
4850 { "Analog Inputs", 0x03 },
4851 { "Digital Mic 1", 0x04 },
4852 { "Digital Mic 2", 0x05 },
4853 }
4854};
4855
4856static int patch_stac92hd83xxx(struct hda_codec *codec)
4857{
4858 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004859 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004860 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004861 int num_dacs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004862
4863 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4864 if (spec == NULL)
4865 return -ENOMEM;
4866
4867 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004868 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004869 spec->mono_nid = 0x19;
4870 spec->digbeep_nid = 0x21;
4871 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4872 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4873 spec->adc_nids = stac92hd83xxx_adc_nids;
4874 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004875 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004876 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4877 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004878 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004879
Matthew Ranostay65557f32009-01-20 16:50:25 -05004880
4881 /* set port 0xe to select the last DAC
4882 */
4883 num_dacs = snd_hda_get_connections(codec, 0x0e,
4884 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4885
4886 snd_hda_codec_write_cache(codec, 0xe, 0,
4887 AC_VERB_SET_CONNECT_SEL, num_dacs);
4888
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004889 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004890 spec->mixer = stac92hd83xxx_mixer;
4891 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4892 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4893 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004894 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004895 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4896 spec->dinput_mux = &stac92hd83xxx_dmux;
4897 spec->pin_nids = stac92hd83xxx_pin_nids;
4898 spec->board_config = snd_hda_check_board_config(codec,
4899 STAC_92HD83XXX_MODELS,
4900 stac92hd83xxx_models,
4901 stac92hd83xxx_cfg_tbl);
4902again:
4903 if (spec->board_config < 0) {
4904 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4905 " STAC92HD83XXX, using BIOS defaults\n");
4906 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01004907 } else
4908 err = stac_save_pin_cfgs(codec,
4909 stac92hd83xxx_brd_tbl[spec->board_config]);
4910 if (err < 0) {
4911 stac92xx_free(codec);
4912 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004913 }
4914
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05004915 switch (codec->vendor_id) {
4916 case 0x111d7604:
4917 case 0x111d7605:
4918 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4919 break;
4920 spec->num_pwrs = 0;
4921 break;
4922 }
4923
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004924 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4925 if (!err) {
4926 if (spec->board_config < 0) {
4927 printk(KERN_WARNING "hda_codec: No auto-config is "
4928 "available, default to model=ref\n");
4929 spec->board_config = STAC_92HD83XXX_REF;
4930 goto again;
4931 }
4932 err = -EINVAL;
4933 }
4934
4935 if (err < 0) {
4936 stac92xx_free(codec);
4937 return err;
4938 }
4939
4940 codec->patch_ops = stac92xx_patch_ops;
4941
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004942 codec->proc_widget_hook = stac92hd_proc_hook;
4943
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004944 return 0;
4945}
4946
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004947static struct hda_input_mux stac92hd71bxx_dmux = {
4948 .num_items = 4,
4949 .items = {
4950 { "Analog Inputs", 0x00 },
4951 { "Mixer", 0x01 },
4952 { "Digital Mic 1", 0x02 },
4953 { "Digital Mic 2", 0x03 },
4954 }
4955};
4956
Matthew Ranostaye035b842007-11-06 11:53:55 +01004957static int patch_stac92hd71bxx(struct hda_codec *codec)
4958{
4959 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05004960 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004961 int err = 0;
4962
4963 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4964 if (spec == NULL)
4965 return -ENOMEM;
4966
4967 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004968 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05004969 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4970 switch (codec->vendor_id) {
4971 case 0x111d76b6:
4972 case 0x111d76b7:
4973 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4974 break;
4975 case 0x111d7603:
4976 case 0x111d7608:
4977 /* On 92HD75Bx 0x27 isn't a pin nid */
4978 spec->num_pins--;
4979 /* fallthrough */
4980 default:
4981 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
4982 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004983 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004984 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4985 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004986 spec->board_config = snd_hda_check_board_config(codec,
4987 STAC_92HD71BXX_MODELS,
4988 stac92hd71bxx_models,
4989 stac92hd71bxx_cfg_tbl);
4990again:
4991 if (spec->board_config < 0) {
4992 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4993 " STAC92HD71BXX, using BIOS defaults\n");
4994 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01004995 } else
4996 err = stac_save_pin_cfgs(codec,
4997 stac92hd71bxx_brd_tbl[spec->board_config]);
4998 if (err < 0) {
4999 stac92xx_free(codec);
5000 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005001 }
5002
Takashi Iwai41c3b642008-11-18 10:45:15 +01005003 if (spec->board_config > STAC_92HD71BXX_REF) {
5004 /* GPIO0 = EAPD */
5005 spec->gpio_mask = 0x01;
5006 spec->gpio_dir = 0x01;
5007 spec->gpio_data = 0x01;
5008 }
5009
Matthew Ranostay541eee82007-12-14 12:08:04 +01005010 switch (codec->vendor_id) {
5011 case 0x111d76b6: /* 4 Port without Analog Mixer */
5012 case 0x111d76b7:
5013 case 0x111d76b4: /* 6 Port without Analog Mixer */
5014 case 0x111d76b5:
5015 spec->mixer = stac92hd71bxx_mixer;
5016 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005017 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005018 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005019 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005020 switch (spec->board_config) {
5021 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005022 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005023 err = stac_add_event(spec, codec->afg,
5024 STAC_VREF_EVENT, 0x02);
5025 if (err < 0)
5026 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005027 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005028 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5029 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005030 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005031 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005032 spec->gpio_mask |= 0x02;
5033 break;
5034 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005035 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005036 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005037 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005038
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005039 /* no output amps */
5040 spec->num_pwrs = 0;
5041 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005042 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005043
5044 /* disable VSW */
5045 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005046 unmute_init++;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005047 stac_change_pin_config(codec, 0x0f, 0x40f000f0);
5048 stac_change_pin_config(codec, 0x19, 0x40f000f3);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005049 break;
5050 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005051 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005052 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005053
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005054 /* no output amps */
5055 spec->num_pwrs = 0;
5056 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005057 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005058 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005059 spec->mixer = stac92hd71bxx_analog_mixer;
5060 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005061 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005062 }
5063
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005064 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5065 snd_hda_sequence_write_cache(codec, unmute_init);
5066
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005067 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005068 spec->aloopback_shift = 0;
5069
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005070 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005071 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005072 spec->mux_nids = stac92hd71bxx_mux_nids;
5073 spec->adc_nids = stac92hd71bxx_adc_nids;
5074 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005075 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005076 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005077 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005078
5079 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5080 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005081
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005082 switch (spec->board_config) {
5083 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005084 /* enable internal microphone */
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005085 stac_change_pin_config(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea7152008-10-09 08:37:28 -04005086 stac92xx_auto_set_pinctl(codec, 0x0e,
5087 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005088 /* fallthru */
5089 case STAC_DELL_M4_2:
5090 spec->num_dmics = 0;
5091 spec->num_smuxes = 0;
5092 spec->num_dmuxes = 0;
5093 break;
5094 case STAC_DELL_M4_1:
5095 case STAC_DELL_M4_3:
5096 spec->num_dmics = 1;
5097 spec->num_smuxes = 0;
5098 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005099 break;
5100 default:
5101 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
5102 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
5103 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5104 };
5105
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005106 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005107 if (spec->dinput_mux)
5108 spec->private_dimux.num_items +=
5109 spec->num_dmics -
5110 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005111
5112 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
5113 if (!err) {
5114 if (spec->board_config < 0) {
5115 printk(KERN_WARNING "hda_codec: No auto-config is "
5116 "available, default to model=ref\n");
5117 spec->board_config = STAC_92HD71BXX_REF;
5118 goto again;
5119 }
5120 err = -EINVAL;
5121 }
5122
5123 if (err < 0) {
5124 stac92xx_free(codec);
5125 return err;
5126 }
5127
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005128 codec->proc_widget_hook = stac92hd7x_proc_hook;
5129
Matthew Ranostaye035b842007-11-06 11:53:55 +01005130 return 0;
5131};
5132
Matt2f2f4252005-04-13 14:45:30 +02005133static int patch_stac922x(struct hda_codec *codec)
5134{
5135 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005136 int err;
Matt2f2f4252005-04-13 14:45:30 +02005137
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005138 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005139 if (spec == NULL)
5140 return -ENOMEM;
5141
5142 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005143 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005144 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005145 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5146 stac922x_models,
5147 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005148 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005149 spec->gpio_mask = spec->gpio_dir = 0x03;
5150 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005151 /* Intel Macs have all same PCI SSID, so we need to check
5152 * codec SSID to distinguish the exact models
5153 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005154 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005155 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005156
5157 case 0x106b0800:
5158 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005159 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005160 case 0x106b0600:
5161 case 0x106b0700:
5162 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005163 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005164 case 0x106b0e00:
5165 case 0x106b0f00:
5166 case 0x106b1600:
5167 case 0x106b1700:
5168 case 0x106b0200:
5169 case 0x106b1e00:
5170 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005171 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005172 case 0x106b1a00:
5173 case 0x00000100:
5174 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005175 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005176 case 0x106b0a00:
5177 case 0x106b2200:
5178 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005179 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005180 default:
5181 spec->board_config = STAC_INTEL_MAC_V3;
5182 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005183 }
5184 }
5185
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005186 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005187 if (spec->board_config < 0) {
5188 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5189 "using BIOS defaults\n");
5190 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005191 } else
5192 err = stac_save_pin_cfgs(codec,
5193 stac922x_brd_tbl[spec->board_config]);
5194 if (err < 0) {
5195 stac92xx_free(codec);
5196 return err;
Matt Porter403d1942005-11-29 15:00:51 +01005197 }
Matt2f2f4252005-04-13 14:45:30 +02005198
Matt2f2f4252005-04-13 14:45:30 +02005199 spec->adc_nids = stac922x_adc_nids;
5200 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005201 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005202 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005203 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005204 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005205
5206 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005207 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005208
5209 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005210
Matt Porter3cc08dc2006-01-23 15:27:49 +01005211 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005212 if (!err) {
5213 if (spec->board_config < 0) {
5214 printk(KERN_WARNING "hda_codec: No auto-config is "
5215 "available, default to model=ref\n");
5216 spec->board_config = STAC_D945_REF;
5217 goto again;
5218 }
5219 err = -EINVAL;
5220 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005221 if (err < 0) {
5222 stac92xx_free(codec);
5223 return err;
5224 }
5225
5226 codec->patch_ops = stac92xx_patch_ops;
5227
Takashi Iwai807a46362007-05-29 19:01:37 +02005228 /* Fix Mux capture level; max to 2 */
5229 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5230 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5231 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5232 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5233 (0 << AC_AMPCAP_MUTE_SHIFT));
5234
Matt Porter3cc08dc2006-01-23 15:27:49 +01005235 return 0;
5236}
5237
5238static int patch_stac927x(struct hda_codec *codec)
5239{
5240 struct sigmatel_spec *spec;
5241 int err;
5242
5243 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5244 if (spec == NULL)
5245 return -ENOMEM;
5246
5247 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005248 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005249 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005250 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5251 stac927x_models,
5252 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005253 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005254 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
5255 if (spec->board_config < 0)
5256 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5257 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02005258 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005259 } else
5260 err = stac_save_pin_cfgs(codec,
5261 stac927x_brd_tbl[spec->board_config]);
5262 if (err < 0) {
5263 stac92xx_free(codec);
5264 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01005265 }
5266
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005267 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005268 spec->adc_nids = stac927x_adc_nids;
5269 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5270 spec->mux_nids = stac927x_mux_nids;
5271 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005272 spec->smux_nids = stac927x_smux_nids;
5273 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005274 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005275 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005276 spec->multiout.dac_nids = spec->dac_nids;
5277
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005278 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005279 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005280 case STAC_D965_5ST:
5281 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005282 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005283 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005284 spec->num_dmics = 0;
5285
Tobin Davis93ed1502006-09-01 21:03:12 +02005286 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005287 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005288 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005289 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005290 switch (codec->subsystem_id) {
5291 case 0x10280209:
5292 case 0x1028022e:
5293 /* correct the device field to SPDIF out */
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005294 stac_change_pin_config(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005295 break;
5296 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005297 /* configure the analog microphone on some laptops */
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005298 stac_change_pin_config(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005299 /* correct the front output jack as a hp out */
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005300 stac_change_pin_config(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005301 /* correct the front input jack as a mic */
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005302 stac_change_pin_config(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005303 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005304 case STAC_DELL_3ST:
5305 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005306 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005307 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005308 spec->dmic_nids = stac927x_dmic_nids;
5309 spec->num_dmics = STAC927X_NUM_DMICS;
5310
Tobin Davis93ed1502006-09-01 21:03:12 +02005311 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005312 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005313 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005314 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005315 break;
5316 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005317 if (spec->board_config > STAC_D965_REF) {
5318 /* GPIO0 High = Enable EAPD */
5319 spec->eapd_mask = spec->gpio_mask = 0x01;
5320 spec->gpio_dir = spec->gpio_data = 0x01;
5321 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005322 spec->num_dmics = 0;
5323
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005324 spec->init = stac927x_core_init;
5325 spec->mixer = stac927x_mixer;
5326 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005327
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005328 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005329 spec->aloopback_mask = 0x40;
5330 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005331 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005332
Matt Porter3cc08dc2006-01-23 15:27:49 +01005333 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005334 if (!err) {
5335 if (spec->board_config < 0) {
5336 printk(KERN_WARNING "hda_codec: No auto-config is "
5337 "available, default to model=ref\n");
5338 spec->board_config = STAC_D965_REF;
5339 goto again;
5340 }
5341 err = -EINVAL;
5342 }
Mattc7d4b2f2005-06-27 14:59:41 +02005343 if (err < 0) {
5344 stac92xx_free(codec);
5345 return err;
5346 }
Matt2f2f4252005-04-13 14:45:30 +02005347
5348 codec->patch_ops = stac92xx_patch_ops;
5349
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005350 codec->proc_widget_hook = stac927x_proc_hook;
5351
Takashi Iwai52987652008-01-16 16:09:47 +01005352 /*
5353 * !!FIXME!!
5354 * The STAC927x seem to require fairly long delays for certain
5355 * command sequences. With too short delays (even if the answer
5356 * is set to RIRB properly), it results in the silence output
5357 * on some hardwares like Dell.
5358 *
5359 * The below flag enables the longer delay (see get_response
5360 * in hda_intel.c).
5361 */
5362 codec->bus->needs_damn_long_delay = 1;
5363
Takashi Iwaie28d8322008-12-17 13:48:29 +01005364 /* no jack detecion for ref-no-jd model */
5365 if (spec->board_config == STAC_D965_REF_NO_JD)
5366 spec->hp_detect = 0;
5367
Matt2f2f4252005-04-13 14:45:30 +02005368 return 0;
5369}
5370
Matt Porterf3302a52006-07-31 12:49:34 +02005371static int patch_stac9205(struct hda_codec *codec)
5372{
5373 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005374 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005375
5376 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5377 if (spec == NULL)
5378 return -ENOMEM;
5379
5380 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005381 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005382 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005383 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5384 stac9205_models,
5385 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005386 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005387 if (spec->board_config < 0) {
5388 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5389 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005390 } else
5391 err = stac_save_pin_cfgs(codec,
5392 stac9205_brd_tbl[spec->board_config]);
5393 if (err < 0) {
5394 stac92xx_free(codec);
5395 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02005396 }
5397
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005398 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005399 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005400 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005401 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005402 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005403 spec->smux_nids = stac9205_smux_nids;
5404 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005405 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005406 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005407 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005408 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005409 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005410
5411 spec->init = stac9205_core_init;
5412 spec->mixer = stac9205_mixer;
5413
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005414 spec->aloopback_mask = 0x40;
5415 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005416 /* Turn on/off EAPD per HP plugging */
5417 if (spec->board_config != STAC_9205_EAPD)
5418 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005419 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005420
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005421 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005422 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005423 /* Enable SPDIF in/out */
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005424 stac_change_pin_config(codec, 0x1f, 0x01441030);
5425 stac_change_pin_config(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005426
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005427 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005428 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5429 if (err < 0)
5430 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005431 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005432 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5433 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005434 AC_VERB_SET_UNSOLICITED_ENABLE,
5435 AC_USRSP_EN | err);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005436
5437 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005438 spec->eapd_mask = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005439 spec->gpio_mask = 0x1b;
5440 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005441 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005442 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005443 */
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005444 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005445 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005446 case STAC_9205_REF:
5447 /* SPDIF-In enabled */
5448 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005449 default:
5450 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005451 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005452 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005453 break;
5454 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005455
Matt Porterf3302a52006-07-31 12:49:34 +02005456 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005457 if (!err) {
5458 if (spec->board_config < 0) {
5459 printk(KERN_WARNING "hda_codec: No auto-config is "
5460 "available, default to model=ref\n");
5461 spec->board_config = STAC_9205_REF;
5462 goto again;
5463 }
5464 err = -EINVAL;
5465 }
Matt Porterf3302a52006-07-31 12:49:34 +02005466 if (err < 0) {
5467 stac92xx_free(codec);
5468 return err;
5469 }
5470
5471 codec->patch_ops = stac92xx_patch_ops;
5472
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005473 codec->proc_widget_hook = stac9205_proc_hook;
5474
Matt Porterf3302a52006-07-31 12:49:34 +02005475 return 0;
5476}
5477
Matt2f2f4252005-04-13 14:45:30 +02005478/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005479 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005480 */
5481
Takashi Iwai1e137f92009-01-21 07:41:22 +01005482static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005483 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5485 {}
5486};
5487
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005488static struct snd_kcontrol_new stac9872_mixer[] = {
5489 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5490 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005491 { } /* end */
5492};
5493
5494static hda_nid_t stac9872_pin_nids[] = {
5495 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5496 0x11, 0x13, 0x14,
5497};
5498
5499static hda_nid_t stac9872_adc_nids[] = {
5500 0x8 /*,0x6*/
5501};
5502
5503static hda_nid_t stac9872_mux_nids[] = {
5504 0x15
5505};
5506
Guillaume Munch6d859062006-08-22 17:15:47 +02005507static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005508{
5509 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005510 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005511
Takashi Iwaidb064e52006-03-16 16:04:58 +01005512 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5513 if (spec == NULL)
5514 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005515 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005516
Takashi Iwai1e137f92009-01-21 07:41:22 +01005517#if 0 /* no model right now */
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005518 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5519 stac9872_models,
5520 stac9872_cfg_tbl);
Takashi Iwai1e137f92009-01-21 07:41:22 +01005521#endif
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005522
Takashi Iwai1e137f92009-01-21 07:41:22 +01005523 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5524 spec->pin_nids = stac9872_pin_nids;
5525 spec->multiout.dac_nids = spec->dac_nids;
5526 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5527 spec->adc_nids = stac9872_adc_nids;
5528 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5529 spec->mux_nids = stac9872_mux_nids;
5530 spec->mixer = stac9872_mixer;
5531 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005532
Takashi Iwai1e137f92009-01-21 07:41:22 +01005533 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5534 if (err < 0) {
5535 stac92xx_free(codec);
5536 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005537 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005538 spec->input_mux = &spec->private_imux;
5539 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005540 return 0;
5541}
5542
5543
5544/*
Matt2f2f4252005-04-13 14:45:30 +02005545 * patch entries
5546 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005547static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005548 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5549 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5550 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5551 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5552 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5553 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5554 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005555 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5556 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5557 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5558 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5559 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5560 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005561 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5562 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5563 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5564 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5565 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5566 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5567 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5568 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5569 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5570 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005571 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5572 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5573 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5574 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5575 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5576 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005577 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5578 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005579 /* The following does not take into account .id=0x83847661 when subsys =
5580 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5581 * currently not fully supported.
5582 */
5583 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5584 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5585 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005586 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5587 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5588 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5589 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5590 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5591 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5592 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5593 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005594 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005595 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5596 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005597 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005598 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5599 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005600 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005601 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5602 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5603 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5604 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5605 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5606 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5607 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5608 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005609 {} /* terminator */
5610};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005611
5612MODULE_ALIAS("snd-hda-codec-id:8384*");
5613MODULE_ALIAS("snd-hda-codec-id:111d*");
5614
5615MODULE_LICENSE("GPL");
5616MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5617
5618static struct hda_codec_preset_list sigmatel_list = {
5619 .preset = snd_hda_preset_sigmatel,
5620 .owner = THIS_MODULE,
5621};
5622
5623static int __init patch_sigmatel_init(void)
5624{
5625 return snd_hda_add_codec_preset(&sigmatel_list);
5626}
5627
5628static void __exit patch_sigmatel_exit(void)
5629{
5630 snd_hda_delete_codec_preset(&sigmatel_list);
5631}
5632
5633module_init(patch_sigmatel_init)
5634module_exit(patch_sigmatel_exit)