blob: a7df81efed235e3d77e1235d442fb681af057fb7 [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 Iwaic8b6bf9b2005-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 Ranostay4fe51952008-01-29 15:28:44 +0100173 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200174 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-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 Ranostay4fe51952008-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 Iwai16970552007-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 Iwaic8b6bf9b2005-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 Iwai16970552007-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 Porterf3302a592006-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 Iwai16970552007-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};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400484static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100485 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
486 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400487 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100488};
489
Matt Porter3cc08dc2006-01-23 15:27:49 +0100490static hda_nid_t stac927x_pin_nids[14] = {
491 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
492 0x0f, 0x10, 0x11, 0x12, 0x13,
493 0x14, 0x21, 0x22, 0x23,
494};
495
Matt Porterf3302a592006-07-31 12:49:34 +0200496static hda_nid_t stac9205_pin_nids[12] = {
497 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
498 0x0f, 0x14, 0x16, 0x17, 0x18,
499 0x21, 0x22,
Matt Porterf3302a592006-07-31 12:49:34 +0200500};
501
Matthew Ranostay89385032008-09-11 09:49:39 -0400502#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
503
504static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
505 struct snd_ctl_elem_value *ucontrol)
506{
507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
508 struct sigmatel_spec *spec = codec->spec;
509 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
510
511 kcontrol->private_value ^= get_amp_nid(kcontrol);
512 kcontrol->private_value |= nid;
513
514 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
515}
516
517static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_value *ucontrol)
519{
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 struct sigmatel_spec *spec = codec->spec;
522 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
523
524 kcontrol->private_value ^= get_amp_nid(kcontrol);
525 kcontrol->private_value |= nid;
526
527 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
528}
529
Matt Porter8b657272006-10-26 17:12:59 +0200530static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_info *uinfo)
532{
533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
534 struct sigmatel_spec *spec = codec->spec;
535 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
536}
537
538static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
540{
541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
542 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100543 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200544
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100545 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200546 return 0;
547}
548
549static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
550 struct snd_ctl_elem_value *ucontrol)
551{
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100554 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200555
556 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100557 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200558}
559
Matthew Ranostayd9737752008-09-07 12:03:41 +0200560static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_info *uinfo)
562{
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 struct sigmatel_spec *spec = codec->spec;
565 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
566}
567
568static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
570{
571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 struct sigmatel_spec *spec = codec->spec;
573 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
574
575 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
576 return 0;
577}
578
579static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
581{
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400584 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200585 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400586 int err, val;
587 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200588
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400589 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200590 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400591 if (err < 0)
592 return err;
593
594 if (spec->spdif_mute) {
595 if (smux_idx == 0)
596 nid = spec->multiout.dig_out_nid;
597 else
598 nid = codec->slave_dig_outs[smux_idx - 1];
599 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100600 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400601 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100602 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400603 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100604 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
605 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400606 }
607 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200608}
609
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100610static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200611{
612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
613 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200614 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200615}
616
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100617static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200618{
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 struct sigmatel_spec *spec = codec->spec;
621 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
622
623 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
624 return 0;
625}
626
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100627static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
632
Mattc7d4b2f2005-06-27 14:59:41 +0200633 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200634 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
635}
636
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100637static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_info *uinfo)
639{
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 struct sigmatel_spec *spec = codec->spec;
642 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
643}
644
645static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
647{
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 struct sigmatel_spec *spec = codec->spec;
650
651 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
652 return 0;
653}
654
655static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
657{
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
660
661 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
662 spec->mono_nid, &spec->cur_mmux);
663}
664
Matthew Ranostay89385032008-09-11 09:49:39 -0400665static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
666 struct snd_ctl_elem_info *uinfo)
667{
668 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
669 struct sigmatel_spec *spec = codec->spec;
670 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
671}
672
673static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
674 struct snd_ctl_elem_value *ucontrol)
675{
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 struct sigmatel_spec *spec = codec->spec;
678
679 ucontrol->value.enumerated.item[0] = spec->cur_amux;
680 return 0;
681}
682
683static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *ucontrol)
685{
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
688 struct snd_kcontrol *ctl =
689 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
690 if (!ctl)
691 return -EINVAL;
692
693 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
694 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
695
696 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
697 0, &spec->cur_amux);
698}
699
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200700#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
701
702static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
703 struct snd_ctl_elem_value *ucontrol)
704{
705 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100706 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707 struct sigmatel_spec *spec = codec->spec;
708
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100709 ucontrol->value.integer.value[0] = !!(spec->aloopback &
710 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200711 return 0;
712}
713
714static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
715 struct snd_ctl_elem_value *ucontrol)
716{
717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
718 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100719 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200720 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100721 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200722
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100723 idx_val = spec->aloopback_mask << idx;
724 if (ucontrol->value.integer.value[0])
725 val = spec->aloopback | idx_val;
726 else
727 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100728 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200729 return 0;
730
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100731 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200732
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100733 /* Only return the bits defined by the shift value of the
734 * first two bytes of the mask
735 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200736 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100737 kcontrol->private_value & 0xFFFF, 0x0);
738 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200739
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100740 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200741 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100742 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200743 } else {
744 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100745 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200746 }
747
748 snd_hda_codec_write_cache(codec, codec->afg, 0,
749 kcontrol->private_value >> 16, dac_mode);
750
751 return 1;
752}
753
Mattc7d4b2f2005-06-27 14:59:41 +0200754static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200755 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200756 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200757 {}
758};
759
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200760static struct hda_verb stac9200_eapd_init[] = {
761 /* set dac0mux for dac converter */
762 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
763 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
764 {}
765};
766
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100767static struct hda_verb stac92hd73xx_6ch_core_init[] = {
768 /* set master volume and direct control */
769 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100770 /* setup adcs to point to mixer */
771 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
772 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100773 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
774 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
775 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
776 /* setup import muxs */
777 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
779 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
780 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
781 {}
782};
783
Matthew Ranostayd654a662008-03-14 08:46:51 +0100784static struct hda_verb dell_eq_core_init[] = {
785 /* set master volume to max value without distortion
786 * and direct control */
787 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100788 /* setup adcs to point to mixer */
789 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
790 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 /* setup import muxs */
792 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
793 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
794 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
796 {}
797};
798
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100799static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500800 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100801 /* setup adcs to point to mixer */
802 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
803 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
804 /* setup import muxs */
805 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
807 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
808 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
809 {}
810};
811
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100812static struct hda_verb stac92hd73xx_8ch_core_init[] = {
813 /* set master volume and direct control */
814 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100815 /* setup adcs to point to mixer */
816 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
817 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100818 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
819 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
820 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
821 /* setup import muxs */
822 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
823 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
824 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
825 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
826 {}
827};
828
829static struct hda_verb stac92hd73xx_10ch_core_init[] = {
830 /* set master volume and direct control */
831 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100832 /* dac3 is connected to import3 mux */
833 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 /* setup adcs to point to mixer */
835 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
836 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 /* setup import muxs */
841 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
845 {}
846};
847
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200848static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200849 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
850 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
851 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
852
853 /* power state controls amps */
854 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200855 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200856};
857
Matthew Ranostaye035b842007-11-06 11:53:55 +0100858static struct hda_verb stac92hd71bxx_core_init[] = {
859 /* set master volume and direct control */
860 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200861 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100862};
863
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500864#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100865static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200866 /* start of config #1 */
867
868 /* connect port 0f to audio mixer */
869 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200870 /* start of config #2 */
871
Matthew Ranostay541eee82007-12-14 12:08:04 +0100872 /* set master volume and direct control */
873 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500874 {}
875};
876
877static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
878 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
879 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100880 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
881 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100882 {}
883};
884
Tobin Davis8e21c342007-01-08 11:04:17 +0100885static struct hda_verb stac925x_core_init[] = {
886 /* set dac0mux for dac converter */
887 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100888 /* mute the master volume */
889 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100890 {}
891};
892
Mattc7d4b2f2005-06-27 14:59:41 +0200893static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200894 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200895 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200896 {}
897};
898
Tobin Davis93ed1502006-09-01 21:03:12 +0200899static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200900 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200901 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200902 /* unmute node 0x1b */
903 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
904 /* select node 0x03 as DAC */
905 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
906 {}
907};
908
Matt Porter3cc08dc2006-01-23 15:27:49 +0100909static struct hda_verb stac927x_core_init[] = {
910 /* set master volume and direct control */
911 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200912 /* enable analog pc beep path */
913 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100914 {}
915};
916
Matt Porterf3302a592006-07-31 12:49:34 +0200917static struct hda_verb stac9205_core_init[] = {
918 /* set master volume and direct control */
919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200920 /* enable analog pc beep path */
921 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a592006-07-31 12:49:34 +0200922 {}
923};
924
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100925#define STAC_MONO_MUX \
926 { \
927 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
928 .name = "Mono Mux", \
929 .count = 1, \
930 .info = stac92xx_mono_mux_enum_info, \
931 .get = stac92xx_mono_mux_enum_get, \
932 .put = stac92xx_mono_mux_enum_put, \
933 }
934
Matthew Ranostay89385032008-09-11 09:49:39 -0400935#define STAC_AMP_MUX \
936 { \
937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
938 .name = "Amp Selector Capture Switch", \
939 .count = 1, \
940 .info = stac92xx_amp_mux_enum_info, \
941 .get = stac92xx_amp_mux_enum_get, \
942 .put = stac92xx_amp_mux_enum_put, \
943 }
944
945#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
946 { \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = xname, \
949 .index = 0, \
950 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
951 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
952 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
953 .info = stac92xx_amp_volume_info, \
954 .get = stac92xx_amp_volume_get, \
955 .put = stac92xx_amp_volume_put, \
956 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
957 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
958 }
959
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100960#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200961 { \
962 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
963 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100964 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200965 .info = stac92xx_aloopback_info, \
966 .get = stac92xx_aloopback_get, \
967 .put = stac92xx_aloopback_put, \
968 .private_value = verb_read | (verb_write << 16), \
969 }
970
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100971static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200972 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
973 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200974 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
975 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200976 { } /* end */
977};
978
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400979#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100980static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400981 /* start of config #1 */
982 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
983 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
984
985 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
986 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
987
988 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
989 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
990
991 /* start of config #2 */
992 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
993 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
994
995 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
996 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
997
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100998 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
999
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001000 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1001 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1002
1003 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1004 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1005
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001006 { } /* end */
1007};
1008
1009static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001010 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1011
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001012 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1014
1015 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1016 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1017
1018 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1019 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1020
1021 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1022 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1023
1024 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1025 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1026
1027 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1028 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1029
1030 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1031 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1032 { } /* end */
1033};
1034
1035static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001036 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1037
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001038 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1039 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1040
1041 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1042 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1043
1044 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1045 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1046
1047 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1048 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1049
1050 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1051 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1052
1053 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1054 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1055
1056 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1057 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1058 { } /* end */
1059};
1060
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001061
1062static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1063 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1064 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1065
1066 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1067 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1068
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001069 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1070 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001071
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001072 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1073 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001074
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001075 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1076 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001077
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001078 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1079 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001080
1081 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001082 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1083 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001084 */
1085 { } /* end */
1086};
1087
Matthew Ranostay541eee82007-12-14 12:08:04 +01001088static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001089 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001090
Matthew Ranostay9b359472007-11-07 13:03:12 +01001091 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1092 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001093
1094 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1095 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001096 /* analog pc-beep replaced with digital beep support */
1097 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001098 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1099 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001100 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001101
Matthew Ranostay687cb982008-10-11 13:52:43 -04001102 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1103 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001104
Matthew Ranostay687cb982008-10-11 13:52:43 -04001105 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1106 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001107
1108 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1109 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1110
1111 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1112 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001113 { } /* end */
1114};
1115
Matthew Ranostay541eee82007-12-14 12:08:04 +01001116static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001117 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1118
Matthew Ranostay541eee82007-12-14 12:08:04 +01001119 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1120 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001121
1122 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1123 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001124 { } /* end */
1125};
1126
Tobin Davis8e21c342007-01-08 11:04:17 +01001127static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001128 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1129 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001130 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001131 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001132 { } /* end */
1133};
1134
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001135static struct snd_kcontrol_new stac9205_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001136 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001137
1138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001140
1141 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1142 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001143 { } /* end */
1144};
1145
1146/* This needs to be generated dynamically based on sequence */
1147static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001148 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001150
1151 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001153 { } /* end */
1154};
1155
1156
1157static struct snd_kcontrol_new stac927x_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001158 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001159
1160 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1161 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001162
1163 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001165
1166 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a592006-07-31 12:49:34 +02001168 { } /* end */
1169};
1170
Takashi Iwai16970552007-12-18 18:05:52 +01001171static struct snd_kcontrol_new stac_dmux_mixer = {
1172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1173 .name = "Digital Input Source",
1174 /* count set later */
1175 .info = stac92xx_dmux_enum_info,
1176 .get = stac92xx_dmux_enum_get,
1177 .put = stac92xx_dmux_enum_put,
1178};
1179
Matthew Ranostayd9737752008-09-07 12:03:41 +02001180static struct snd_kcontrol_new stac_smux_mixer = {
1181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001182 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001183 /* count set later */
1184 .info = stac92xx_smux_enum_info,
1185 .get = stac92xx_smux_enum_get,
1186 .put = stac92xx_smux_enum_put,
1187};
1188
Takashi Iwai2134ea42008-01-10 16:53:55 +01001189static const char *slave_vols[] = {
1190 "Front Playback Volume",
1191 "Surround Playback Volume",
1192 "Center Playback Volume",
1193 "LFE Playback Volume",
1194 "Side Playback Volume",
1195 "Headphone Playback Volume",
1196 "Headphone Playback Volume",
1197 "Speaker Playback Volume",
1198 "External Speaker Playback Volume",
1199 "Speaker2 Playback Volume",
1200 NULL
1201};
1202
1203static const char *slave_sws[] = {
1204 "Front Playback Switch",
1205 "Surround Playback Switch",
1206 "Center Playback Switch",
1207 "LFE Playback Switch",
1208 "Side Playback Switch",
1209 "Headphone Playback Switch",
1210 "Headphone Playback Switch",
1211 "Speaker Playback Switch",
1212 "External Speaker Playback Switch",
1213 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001214 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001215 NULL
1216};
1217
Takashi Iwai603c4012008-07-30 15:01:44 +02001218static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001219static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001220
Matt2f2f4252005-04-13 14:45:30 +02001221static int stac92xx_build_controls(struct hda_codec *codec)
1222{
1223 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001224 struct auto_pin_cfg *cfg = &spec->autocfg;
1225 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001226 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001227 int i;
Matt2f2f4252005-04-13 14:45:30 +02001228
1229 err = snd_hda_add_new_ctls(codec, spec->mixer);
1230 if (err < 0)
1231 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001232
1233 for (i = 0; i < spec->num_mixers; i++) {
1234 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1235 if (err < 0)
1236 return err;
1237 }
Takashi Iwai16970552007-12-18 18:05:52 +01001238 if (spec->num_dmuxes > 0) {
1239 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001240 err = snd_hda_ctl_add(codec,
Takashi Iwai16970552007-12-18 18:05:52 +01001241 snd_ctl_new1(&stac_dmux_mixer, codec));
1242 if (err < 0)
1243 return err;
1244 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001245 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001246 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1247 struct hda_input_mux *smux = &spec->private_smux;
1248 /* check for mute support on SPDIF out */
1249 if (wcaps & AC_WCAP_OUT_AMP) {
1250 smux->items[smux->num_items].label = "Off";
1251 smux->items[smux->num_items].index = 0;
1252 smux->num_items++;
1253 spec->spdif_mute = 1;
1254 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001255 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001256 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001257 snd_ctl_new1(&stac_smux_mixer, codec));
1258 if (err < 0)
1259 return err;
1260 }
Mattc7d4b2f2005-06-27 14:59:41 +02001261
Mattdabbed62005-06-14 10:19:34 +02001262 if (spec->multiout.dig_out_nid) {
1263 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1264 if (err < 0)
1265 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001266 err = snd_hda_create_spdif_share_sw(codec,
1267 &spec->multiout);
1268 if (err < 0)
1269 return err;
1270 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001271 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001272 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001273 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1274 if (err < 0)
1275 return err;
1276 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001277
1278 /* if we have no master control, let's create it */
1279 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001280 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001281 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001282 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001283 /* correct volume offset */
1284 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001285 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001286 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001287 if (err < 0)
1288 return err;
1289 }
1290 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1291 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1292 NULL, slave_sws);
1293 if (err < 0)
1294 return err;
1295 }
1296
Takashi Iwai603c4012008-07-30 15:01:44 +02001297 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001298
1299 /* create jack input elements */
1300 if (spec->hp_detect) {
1301 for (i = 0; i < cfg->hp_outs; i++) {
1302 int type = SND_JACK_HEADPHONE;
1303 nid = cfg->hp_pins[i];
1304 /* jack detection */
1305 if (cfg->hp_outs == i)
1306 type |= SND_JACK_LINEOUT;
1307 err = stac92xx_add_jack(codec, nid, type);
1308 if (err < 0)
1309 return err;
1310 }
1311 }
1312 for (i = 0; i < cfg->line_outs; i++) {
1313 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1314 SND_JACK_LINEOUT);
1315 if (err < 0)
1316 return err;
1317 }
1318 for (i = 0; i < AUTO_PIN_LAST; i++) {
1319 nid = cfg->input_pins[i];
1320 if (nid) {
1321 err = stac92xx_add_jack(codec, nid,
1322 SND_JACK_MICROPHONE);
1323 if (err < 0)
1324 return err;
1325 }
1326 }
1327
Mattdabbed62005-06-14 10:19:34 +02001328 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001329}
1330
Matt Porter403d1942005-11-29 15:00:51 +01001331static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001332 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001333 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1334};
1335
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001336static unsigned int gateway9200_m4_pin_configs[8] = {
1337 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1338 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1339};
1340static unsigned int gateway9200_m4_2_pin_configs[8] = {
1341 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1342 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1343};
1344
1345/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001346 STAC 9200 pin configs for
1347 102801A8
1348 102801DE
1349 102801E8
1350*/
1351static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001352 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1353 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001354};
1355
1356/*
1357 STAC 9200 pin configs for
1358 102801C0
1359 102801C1
1360*/
1361static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001362 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1363 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364};
1365
1366/*
1367 STAC 9200 pin configs for
1368 102801C4 (Dell Dimension E310)
1369 102801C5
1370 102801C7
1371 102801D9
1372 102801DA
1373 102801E3
1374*/
1375static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001376 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1377 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001378};
1379
1380
1381/*
1382 STAC 9200-32 pin configs for
1383 102801B5 (Dell Inspiron 630m)
1384 102801D8 (Dell Inspiron 640m)
1385*/
1386static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001387 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1388 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001389};
1390
1391/*
1392 STAC 9200-32 pin configs for
1393 102801C2 (Dell Latitude D620)
1394 102801C8
1395 102801CC (Dell Latitude D820)
1396 102801D4
1397 102801D6
1398*/
1399static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001400 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1401 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001402};
1403
1404/*
1405 STAC 9200-32 pin configs for
1406 102801CE (Dell XPS M1710)
1407 102801CF (Dell Precision M90)
1408*/
1409static unsigned int dell9200_m23_pin_configs[8] = {
1410 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1411 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1412};
1413
1414/*
1415 STAC 9200-32 pin configs for
1416 102801C9
1417 102801CA
1418 102801CB (Dell Latitude 120L)
1419 102801D3
1420*/
1421static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001422 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1423 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001424};
1425
1426/*
1427 STAC 9200-32 pin configs for
1428 102801BD (Dell Inspiron E1505n)
1429 102801EE
1430 102801EF
1431*/
1432static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001433 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1434 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001435};
1436
1437/*
1438 STAC 9200-32 pin configs for
1439 102801F5 (Dell Inspiron 1501)
1440 102801F6
1441*/
1442static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001443 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1444 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001445};
1446
1447/*
1448 STAC 9200-32
1449 102801CD (Dell Inspiron E1705/9400)
1450*/
1451static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001452 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1453 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001454};
1455
Tobin Davisbf277782008-02-03 20:31:47 +01001456static unsigned int oqo9200_pin_configs[8] = {
1457 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1458 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1459};
1460
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001461
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001462static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1463 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001464 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001465 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1466 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1467 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1468 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1469 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1470 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1471 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1472 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1473 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1474 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001475 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1476 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001477 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001478};
1479
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001480static const char *stac9200_models[STAC_9200_MODELS] = {
1481 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001482 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001483 [STAC_9200_DELL_D21] = "dell-d21",
1484 [STAC_9200_DELL_D22] = "dell-d22",
1485 [STAC_9200_DELL_D23] = "dell-d23",
1486 [STAC_9200_DELL_M21] = "dell-m21",
1487 [STAC_9200_DELL_M22] = "dell-m22",
1488 [STAC_9200_DELL_M23] = "dell-m23",
1489 [STAC_9200_DELL_M24] = "dell-m24",
1490 [STAC_9200_DELL_M25] = "dell-m25",
1491 [STAC_9200_DELL_M26] = "dell-m26",
1492 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001493 [STAC_9200_M4] = "gateway-m4",
1494 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001495 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001496};
1497
1498static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1499 /* SigmaTel reference board */
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1501 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001502 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1503 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001504 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1506 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001508 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1510 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1512 "unknown Dell", STAC_9200_DELL_D22),
1513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1514 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001516 "Dell Latitude D620", STAC_9200_DELL_M22),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1518 "unknown Dell", STAC_9200_DELL_D23),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1520 "unknown Dell", STAC_9200_DELL_D23),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1522 "unknown Dell", STAC_9200_DELL_M22),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1524 "unknown Dell", STAC_9200_DELL_M24),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1526 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001528 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001530 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001532 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001534 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001536 "Dell Precision M90", STAC_9200_DELL_M23),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1538 "unknown Dell", STAC_9200_DELL_M22),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1540 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001542 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1546 "unknown Dell", STAC_9200_DELL_D23),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1548 "unknown Dell", STAC_9200_DELL_D23),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1550 "unknown Dell", STAC_9200_DELL_D21),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1552 "unknown Dell", STAC_9200_DELL_D23),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1554 "unknown Dell", STAC_9200_DELL_D21),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1556 "unknown Dell", STAC_9200_DELL_M25),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1558 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001560 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1562 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001563 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001564 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001565 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001566 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1567 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1568 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001569 /* OQO Mobile */
1570 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001571 {} /* terminator */
1572};
1573
Tobin Davis8e21c342007-01-08 11:04:17 +01001574static unsigned int ref925x_pin_configs[8] = {
1575 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001576 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001577};
1578
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001579static unsigned int stac925xM1_pin_configs[8] = {
1580 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1581 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001582};
1583
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001584static unsigned int stac925xM1_2_pin_configs[8] = {
1585 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1586 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1587};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001588
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001589static unsigned int stac925xM2_pin_configs[8] = {
1590 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1591 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001592};
1593
Tobin Davis8e21c342007-01-08 11:04:17 +01001594static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001595 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1596 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1597};
1598
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001599static unsigned int stac925xM3_pin_configs[8] = {
1600 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1601 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1602};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001603
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001604static unsigned int stac925xM5_pin_configs[8] = {
1605 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1606 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1607};
1608
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001609static unsigned int stac925xM6_pin_configs[8] = {
1610 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1611 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001612};
1613
1614static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1615 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001616 [STAC_M1] = stac925xM1_pin_configs,
1617 [STAC_M1_2] = stac925xM1_2_pin_configs,
1618 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001619 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001620 [STAC_M3] = stac925xM3_pin_configs,
1621 [STAC_M5] = stac925xM5_pin_configs,
1622 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001623};
1624
1625static const char *stac925x_models[STAC_925x_MODELS] = {
1626 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001627 [STAC_M1] = "m1",
1628 [STAC_M1_2] = "m1-2",
1629 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001630 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001631 [STAC_M3] = "m3",
1632 [STAC_M5] = "m5",
1633 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001634};
1635
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001636static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001637 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1638 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1639 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1640 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001641 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001642 /* Not sure about the brand name for those */
1643 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1644 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1645 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1646 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001647 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001648};
1649
1650static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1651 /* SigmaTel reference board */
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001653 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001654 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001655
1656 /* Default table for unknown ID */
1657 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1658
Tobin Davis8e21c342007-01-08 11:04:17 +01001659 {} /* terminator */
1660};
1661
Matthew Ranostaya7662642008-02-21 07:51:14 +01001662static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001663 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1664 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1665 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001666 0x01452050,
1667};
1668
1669static unsigned int dell_m6_pin_configs[13] = {
1670 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001671 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001672 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1673 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001674};
1675
1676static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001677 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001678 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1679 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1680 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001681 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001682};
1683
1684static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001685 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001686 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001687 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1688 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1689 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001690 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001691};
1692
1693static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1694 /* SigmaTel reference board */
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001696 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001697 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1698 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001700 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001702 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001704 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001706 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001708 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001710 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001712 "unknown Dell", STAC_DELL_M6_DMIC),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1714 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001716 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1718 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001719 {} /* terminator */
1720};
1721
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001722static unsigned int ref92hd83xxx_pin_configs[14] = {
1723 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1724 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1725 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1726 0x01451160, 0x98560170,
1727};
1728
1729static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1730 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001731 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001732};
1733
1734static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1735 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001736 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001737};
1738
1739static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1740 /* SigmaTel reference board */
1741 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001742 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001743 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1744 "DFI LanParty", STAC_92HD83XXX_REF),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001745 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001746};
1747
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001748static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001749 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001750 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001751 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001752};
1753
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001754static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001755 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001756 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001757 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001758};
1759
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001760static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001761 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1762 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001763 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001764};
1765
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001766static unsigned int dell_m4_3_pin_configs[11] = {
1767 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1768 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1769 0x40f000f0, 0x044413b0, 0x044413b0,
1770};
1771
Matthew Ranostaye035b842007-11-06 11:53:55 +01001772static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1773 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001774 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1775 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001776 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001777 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001778 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001779};
1780
1781static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1782 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001783 [STAC_DELL_M4_1] = "dell-m4-1",
1784 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001785 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001786 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001787 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001788};
1789
1790static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1791 /* SigmaTel reference board */
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1793 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001794 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1795 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001796 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1797 "HP dv5", STAC_HP_M4),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1799 "HP dv7", STAC_HP_M4),
Takashi Iwaie0c0e942009-01-22 12:58:11 +01001800 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7,
1801 "HP dv4", STAC_HP_DV5),
Takashi Iwai69dfaef2008-12-20 16:57:50 +01001802 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1803 "HP dv7", STAC_HP_M4),
Takashi Iwai42de55c2009-01-30 15:49:58 +01001804 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3600,
1805 "HP dv5", STAC_HP_DV5),
Giuseppe Bilottadafb70c2009-01-13 08:58:49 -05001806 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001807 "HP dv5", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001808 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1809 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1811 "unknown Dell", STAC_DELL_M4_1),
1812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1813 "unknown Dell", STAC_DELL_M4_1),
1814 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1815 "unknown Dell", STAC_DELL_M4_1),
1816 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1817 "unknown Dell", STAC_DELL_M4_1),
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1819 "unknown Dell", STAC_DELL_M4_1),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1821 "unknown Dell", STAC_DELL_M4_1),
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1823 "unknown Dell", STAC_DELL_M4_1),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1825 "unknown Dell", STAC_DELL_M4_2),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1827 "unknown Dell", STAC_DELL_M4_2),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1829 "unknown Dell", STAC_DELL_M4_2),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1831 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1833 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001834 {} /* terminator */
1835};
1836
Matt Porter403d1942005-11-29 15:00:51 +01001837static unsigned int ref922x_pin_configs[10] = {
1838 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1839 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001840 0x40000100, 0x40000100,
1841};
1842
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001843/*
1844 STAC 922X pin configs for
1845 102801A7
1846 102801AB
1847 102801A9
1848 102801D1
1849 102801D2
1850*/
1851static unsigned int dell_922x_d81_pin_configs[10] = {
1852 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1853 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1854 0x01813122, 0x400001f2,
1855};
1856
1857/*
1858 STAC 922X pin configs for
1859 102801AC
1860 102801D0
1861*/
1862static unsigned int dell_922x_d82_pin_configs[10] = {
1863 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1864 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1865 0x01813122, 0x400001f1,
1866};
1867
1868/*
1869 STAC 922X pin configs for
1870 102801BF
1871*/
1872static unsigned int dell_922x_m81_pin_configs[10] = {
1873 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1874 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1875 0x40C003f1, 0x405003f0,
1876};
1877
1878/*
1879 STAC 9221 A1 pin configs for
1880 102801D7 (Dell XPS M1210)
1881*/
1882static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001883 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1884 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001885 0x508003f3, 0x405003f4,
1886};
1887
Matt Porter403d1942005-11-29 15:00:51 +01001888static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001889 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001890 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1891 0x02a19120, 0x40000100,
1892};
1893
1894static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001895 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1896 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001897 0x02a19320, 0x40000100,
1898};
1899
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001900static unsigned int intel_mac_v1_pin_configs[10] = {
1901 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1902 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001903 0x400000fc, 0x400000fb,
1904};
1905
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001906static unsigned int intel_mac_v2_pin_configs[10] = {
1907 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1908 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001909 0x400000fc, 0x400000fb,
1910};
1911
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001912static unsigned int intel_mac_v3_pin_configs[10] = {
1913 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1914 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1915 0x400000fc, 0x400000fb,
1916};
1917
1918static unsigned int intel_mac_v4_pin_configs[10] = {
1919 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1920 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1921 0x400000fc, 0x400000fb,
1922};
1923
1924static unsigned int intel_mac_v5_pin_configs[10] = {
1925 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1926 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1927 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001928};
1929
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001930static unsigned int ecs202_pin_configs[10] = {
1931 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1932 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1933 0x9037012e, 0x40e000f2,
1934};
Takashi Iwai76c08822007-06-19 12:17:42 +02001935
Takashi Iwai19039bd2006-06-28 15:52:16 +02001936static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001937 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001938 [STAC_D945GTP3] = d945gtp3_pin_configs,
1939 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001940 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1941 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1942 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1943 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1944 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001945 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001946 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001947 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1948 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1949 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1950 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1951 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1952 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001953 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001954 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1955 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1956 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1957 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001958};
1959
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001960static const char *stac922x_models[STAC_922X_MODELS] = {
1961 [STAC_D945_REF] = "ref",
1962 [STAC_D945GTP5] = "5stack",
1963 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001964 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1965 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1966 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1967 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1968 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001969 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001970 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001971 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001972 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001973 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1974 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001975 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001976 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001977 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001978 [STAC_922X_DELL_D81] = "dell-d81",
1979 [STAC_922X_DELL_D82] = "dell-d82",
1980 [STAC_922X_DELL_M81] = "dell-m81",
1981 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001982};
1983
1984static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1985 /* SigmaTel reference board */
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1987 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001988 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1989 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001990 /* Intel 945G based systems */
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1992 "Intel D945G", STAC_D945GTP3),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1994 "Intel D945G", STAC_D945GTP3),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1996 "Intel D945G", STAC_D945GTP3),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1998 "Intel D945G", STAC_D945GTP3),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2000 "Intel D945G", STAC_D945GTP3),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2002 "Intel D945G", STAC_D945GTP3),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2004 "Intel D945G", STAC_D945GTP3),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2006 "Intel D945G", STAC_D945GTP3),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2008 "Intel D945G", STAC_D945GTP3),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2010 "Intel D945G", STAC_D945GTP3),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2012 "Intel D945G", STAC_D945GTP3),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2014 "Intel D945G", STAC_D945GTP3),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2016 "Intel D945G", STAC_D945GTP3),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2018 "Intel D945G", STAC_D945GTP3),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2020 "Intel D945G", STAC_D945GTP3),
2021 /* Intel D945G 5-stack systems */
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2023 "Intel D945G", STAC_D945GTP5),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2025 "Intel D945G", STAC_D945GTP5),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2027 "Intel D945G", STAC_D945GTP5),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2029 "Intel D945G", STAC_D945GTP5),
2030 /* Intel 945P based systems */
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2032 "Intel D945P", STAC_D945GTP3),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2034 "Intel D945P", STAC_D945GTP3),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2036 "Intel D945P", STAC_D945GTP3),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2038 "Intel D945P", STAC_D945GTP3),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2040 "Intel D945P", STAC_D945GTP3),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2042 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002043 /* other intel */
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2045 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002046 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002047 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002048 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002049 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002050 /* Dell systems */
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2052 "unknown Dell", STAC_922X_DELL_D81),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2054 "unknown Dell", STAC_922X_DELL_D81),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2056 "unknown Dell", STAC_922X_DELL_D81),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2058 "unknown Dell", STAC_922X_DELL_D82),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2060 "unknown Dell", STAC_922X_DELL_M81),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2062 "unknown Dell", STAC_922X_DELL_D82),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2064 "unknown Dell", STAC_922X_DELL_D81),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2066 "unknown Dell", STAC_922X_DELL_D81),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2068 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002069 /* ECS/PC Chips boards */
2070 SND_PCI_QUIRK(0x1019, 0x2144,
2071 "ECS/PC chips", STAC_ECS_202),
2072 SND_PCI_QUIRK(0x1019, 0x2608,
2073 "ECS/PC chips", STAC_ECS_202),
2074 SND_PCI_QUIRK(0x1019, 0x2633,
2075 "ECS/PC chips P17G/1333", STAC_ECS_202),
2076 SND_PCI_QUIRK(0x1019, 0x2811,
2077 "ECS/PC chips", STAC_ECS_202),
2078 SND_PCI_QUIRK(0x1019, 0x2812,
2079 "ECS/PC chips", STAC_ECS_202),
2080 SND_PCI_QUIRK(0x1019, 0x2813,
2081 "ECS/PC chips", STAC_ECS_202),
2082 SND_PCI_QUIRK(0x1019, 0x2814,
2083 "ECS/PC chips", STAC_ECS_202),
2084 SND_PCI_QUIRK(0x1019, 0x2815,
2085 "ECS/PC chips", STAC_ECS_202),
2086 SND_PCI_QUIRK(0x1019, 0x2816,
2087 "ECS/PC chips", STAC_ECS_202),
2088 SND_PCI_QUIRK(0x1019, 0x2817,
2089 "ECS/PC chips", STAC_ECS_202),
2090 SND_PCI_QUIRK(0x1019, 0x2818,
2091 "ECS/PC chips", STAC_ECS_202),
2092 SND_PCI_QUIRK(0x1019, 0x2819,
2093 "ECS/PC chips", STAC_ECS_202),
2094 SND_PCI_QUIRK(0x1019, 0x2820,
2095 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002096 {} /* terminator */
2097};
2098
Matt Porter3cc08dc2006-01-23 15:27:49 +01002099static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002100 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2101 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2102 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2103 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002104};
2105
Tobin Davis93ed1502006-09-01 21:03:12 +02002106static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002107 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2108 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2109 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2110 0x40000100, 0x40000100
2111};
2112
Tobin Davis93ed1502006-09-01 21:03:12 +02002113static unsigned int d965_5st_pin_configs[14] = {
2114 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2115 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2116 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2117 0x40000100, 0x40000100
2118};
2119
Tobin Davis4ff076e2007-08-07 11:48:12 +02002120static unsigned int dell_3st_pin_configs[14] = {
2121 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2122 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002123 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002124 0x40c003fc, 0x40000100
2125};
2126
Tobin Davis93ed1502006-09-01 21:03:12 +02002127static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002128 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002129 [STAC_D965_REF] = ref927x_pin_configs,
2130 [STAC_D965_3ST] = d965_3st_pin_configs,
2131 [STAC_D965_5ST] = d965_5st_pin_configs,
2132 [STAC_DELL_3ST] = dell_3st_pin_configs,
2133 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002134};
2135
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002136static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002137 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002138 [STAC_D965_REF] = "ref",
2139 [STAC_D965_3ST] = "3stack",
2140 [STAC_D965_5ST] = "5stack",
2141 [STAC_DELL_3ST] = "dell-3stack",
2142 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002143};
2144
2145static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2146 /* SigmaTel reference board */
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2148 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002149 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2150 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002151 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002154 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002155 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002171 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002176 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002185 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002186 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002195 {} /* terminator */
2196};
2197
Matt Porterf3302a592006-07-31 12:49:34 +02002198static unsigned int ref9205_pin_configs[12] = {
2199 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002200 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002201 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a592006-07-31 12:49:34 +02002202};
2203
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002204/*
2205 STAC 9205 pin configs for
2206 102801F1
2207 102801F2
2208 102801FC
2209 102801FD
2210 10280204
2211 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002212 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002213*/
2214static unsigned int dell_9205_m42_pin_configs[12] = {
2215 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2216 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2217 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2218};
2219
2220/*
2221 STAC 9205 pin configs for
2222 102801F9
2223 102801FA
2224 102801FE
2225 102801FF (Dell Precision M4300)
2226 10280206
2227 10280200
2228 10280201
2229*/
2230static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002231 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2232 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2233 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2234};
2235
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002236static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002237 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2238 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2239 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2240};
2241
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002242static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002243 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002244 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2245 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2246 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002247 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a592006-07-31 12:49:34 +02002248};
2249
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002250static const char *stac9205_models[STAC_9205_MODELS] = {
2251 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002252 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002253 [STAC_9205_DELL_M43] = "dell-m43",
2254 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002255 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002256};
2257
2258static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2259 /* SigmaTel reference board */
2260 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2261 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002262 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2263 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002264 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2266 "unknown Dell", STAC_9205_DELL_M42),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2268 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002270 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2272 "Dell Precision", STAC_9205_DELL_M43),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2274 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2276 "unknown Dell", STAC_9205_DELL_M42),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2278 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2280 "Dell Precision", STAC_9205_DELL_M43),
2281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002282 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2284 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2286 "Dell Precision", STAC_9205_DELL_M43),
2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2288 "Dell Precision", STAC_9205_DELL_M43),
2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2290 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2292 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2294 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002295 /* Gateway */
2296 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a592006-07-31 12:49:34 +02002297 {} /* terminator */
2298};
2299
Richard Fish11b44bb2006-08-23 18:31:34 +02002300static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2301{
2302 int i;
2303 struct sigmatel_spec *spec = codec->spec;
2304
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002305 kfree(spec->pin_configs);
2306 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2307 GFP_KERNEL);
2308 if (!spec->pin_configs)
2309 return -ENOMEM;
Richard Fish11b44bb2006-08-23 18:31:34 +02002310
2311 for (i = 0; i < spec->num_pins; i++) {
2312 hda_nid_t nid = spec->pin_nids[i];
2313 unsigned int pin_cfg;
2314
2315 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2316 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2317 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2318 nid, pin_cfg);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002319 spec->pin_configs[i] = pin_cfg;
Richard Fish11b44bb2006-08-23 18:31:34 +02002320 }
2321
2322 return 0;
2323}
2324
Matthew Ranostay87d48362007-07-17 11:52:24 +02002325static void stac92xx_set_config_reg(struct hda_codec *codec,
2326 hda_nid_t pin_nid, unsigned int pin_config)
2327{
2328 int i;
2329 snd_hda_codec_write(codec, pin_nid, 0,
2330 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2331 pin_config & 0x000000ff);
2332 snd_hda_codec_write(codec, pin_nid, 0,
2333 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2334 (pin_config & 0x0000ff00) >> 8);
2335 snd_hda_codec_write(codec, pin_nid, 0,
2336 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2337 (pin_config & 0x00ff0000) >> 16);
2338 snd_hda_codec_write(codec, pin_nid, 0,
2339 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2340 pin_config >> 24);
2341 i = snd_hda_codec_read(codec, pin_nid, 0,
2342 AC_VERB_GET_CONFIG_DEFAULT,
2343 0x00);
2344 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2345 pin_nid, i);
2346}
2347
Matt2f2f4252005-04-13 14:45:30 +02002348static void stac92xx_set_config_regs(struct hda_codec *codec)
2349{
2350 int i;
2351 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002352
Matthew Ranostay87d48362007-07-17 11:52:24 +02002353 if (!spec->pin_configs)
2354 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002355
Matthew Ranostay87d48362007-07-17 11:52:24 +02002356 for (i = 0; i < spec->num_pins; i++)
2357 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2358 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002359}
Matt2f2f4252005-04-13 14:45:30 +02002360
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002361static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2362{
2363 struct sigmatel_spec *spec = codec->spec;
2364
2365 if (!pins)
2366 return stac92xx_save_bios_config_regs(codec);
2367
2368 kfree(spec->pin_configs);
2369 spec->pin_configs = kmemdup(pins,
2370 spec->num_pins * sizeof(*pins),
2371 GFP_KERNEL);
2372 if (!spec->pin_configs)
2373 return -ENOMEM;
2374
2375 stac92xx_set_config_regs(codec);
2376 return 0;
2377}
2378
2379static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2380 unsigned int cfg)
2381{
2382 struct sigmatel_spec *spec = codec->spec;
2383 int i;
2384
2385 for (i = 0; i < spec->num_pins; i++) {
2386 if (spec->pin_nids[i] == nid) {
2387 spec->pin_configs[i] = cfg;
2388 stac92xx_set_config_reg(codec, nid, cfg);
2389 break;
2390 }
2391 }
2392}
2393
Matt2f2f4252005-04-13 14:45:30 +02002394/*
2395 * Analog playback callbacks
2396 */
2397static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2398 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002399 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002400{
2401 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002402 if (spec->stream_delay)
2403 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002404 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2405 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002406}
2407
2408static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2409 struct hda_codec *codec,
2410 unsigned int stream_tag,
2411 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002412 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002413{
2414 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002415 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002416}
2417
2418static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2419 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002420 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002421{
2422 struct sigmatel_spec *spec = codec->spec;
2423 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2424}
2425
2426/*
Mattdabbed62005-06-14 10:19:34 +02002427 * Digital playback callbacks
2428 */
2429static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2430 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002431 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002432{
2433 struct sigmatel_spec *spec = codec->spec;
2434 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2435}
2436
2437static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2438 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002439 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002440{
2441 struct sigmatel_spec *spec = codec->spec;
2442 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2443}
2444
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002445static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2446 struct hda_codec *codec,
2447 unsigned int stream_tag,
2448 unsigned int format,
2449 struct snd_pcm_substream *substream)
2450{
2451 struct sigmatel_spec *spec = codec->spec;
2452 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2453 stream_tag, format, substream);
2454}
2455
Mattdabbed62005-06-14 10:19:34 +02002456
2457/*
Matt2f2f4252005-04-13 14:45:30 +02002458 * Analog capture callbacks
2459 */
2460static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2461 struct hda_codec *codec,
2462 unsigned int stream_tag,
2463 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002464 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002465{
2466 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002467 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002468
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002469 if (spec->powerdown_adcs) {
2470 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002471 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002472 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2473 }
2474 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002475 return 0;
2476}
2477
2478static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2479 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002480 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002481{
2482 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002483 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002484
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002485 snd_hda_codec_cleanup_stream(codec, nid);
2486 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002487 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002488 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002489 return 0;
2490}
2491
Mattdabbed62005-06-14 10:19:34 +02002492static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2493 .substreams = 1,
2494 .channels_min = 2,
2495 .channels_max = 2,
2496 /* NID is set in stac92xx_build_pcms */
2497 .ops = {
2498 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002499 .close = stac92xx_dig_playback_pcm_close,
2500 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002501 },
2502};
2503
2504static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2505 .substreams = 1,
2506 .channels_min = 2,
2507 .channels_max = 2,
2508 /* NID is set in stac92xx_build_pcms */
2509};
2510
Matt2f2f4252005-04-13 14:45:30 +02002511static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2512 .substreams = 1,
2513 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002514 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002515 .nid = 0x02, /* NID to query formats and rates */
2516 .ops = {
2517 .open = stac92xx_playback_pcm_open,
2518 .prepare = stac92xx_playback_pcm_prepare,
2519 .cleanup = stac92xx_playback_pcm_cleanup
2520 },
2521};
2522
Matt Porter3cc08dc2006-01-23 15:27:49 +01002523static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2524 .substreams = 1,
2525 .channels_min = 2,
2526 .channels_max = 2,
2527 .nid = 0x06, /* NID to query formats and rates */
2528 .ops = {
2529 .open = stac92xx_playback_pcm_open,
2530 .prepare = stac92xx_playback_pcm_prepare,
2531 .cleanup = stac92xx_playback_pcm_cleanup
2532 },
2533};
2534
Matt2f2f4252005-04-13 14:45:30 +02002535static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002536 .channels_min = 2,
2537 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002538 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002539 .ops = {
2540 .prepare = stac92xx_capture_pcm_prepare,
2541 .cleanup = stac92xx_capture_pcm_cleanup
2542 },
2543};
2544
2545static int stac92xx_build_pcms(struct hda_codec *codec)
2546{
2547 struct sigmatel_spec *spec = codec->spec;
2548 struct hda_pcm *info = spec->pcm_rec;
2549
2550 codec->num_pcms = 1;
2551 codec->pcm_info = info;
2552
Mattc7d4b2f2005-06-27 14:59:41 +02002553 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002554 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002555 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2556 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002557 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002558 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002559 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002560
2561 if (spec->alt_switch) {
2562 codec->num_pcms++;
2563 info++;
2564 info->name = "STAC92xx Analog Alt";
2565 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2566 }
Matt2f2f4252005-04-13 14:45:30 +02002567
Mattdabbed62005-06-14 10:19:34 +02002568 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2569 codec->num_pcms++;
2570 info++;
2571 info->name = "STAC92xx Digital";
Takashi Iwai8c441982009-01-20 18:30:20 +01002572 info->pcm_type = spec->autocfg.dig_out_type;
Mattdabbed62005-06-14 10:19:34 +02002573 if (spec->multiout.dig_out_nid) {
2574 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2575 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2576 }
2577 if (spec->dig_in_nid) {
2578 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2579 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2580 }
2581 }
2582
Matt2f2f4252005-04-13 14:45:30 +02002583 return 0;
2584}
2585
Takashi Iwaic960a032006-03-23 17:06:28 +01002586static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2587{
2588 unsigned int pincap = snd_hda_param_read(codec, nid,
2589 AC_PAR_PIN_CAP);
2590 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2591 if (pincap & AC_PINCAP_VREF_100)
2592 return AC_PINCTL_VREF_100;
2593 if (pincap & AC_PINCAP_VREF_80)
2594 return AC_PINCTL_VREF_80;
2595 if (pincap & AC_PINCAP_VREF_50)
2596 return AC_PINCTL_VREF_50;
2597 if (pincap & AC_PINCAP_VREF_GRD)
2598 return AC_PINCTL_VREF_GRD;
2599 return 0;
2600}
2601
Matt Porter403d1942005-11-29 15:00:51 +01002602static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2603
2604{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002605 snd_hda_codec_write_cache(codec, nid, 0,
2606 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002607}
2608
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002609#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2610
2611static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2612 struct snd_ctl_elem_value *ucontrol)
2613{
2614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2615 struct sigmatel_spec *spec = codec->spec;
2616
Takashi Iwaid7a89432008-11-12 09:48:04 +01002617 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002618 return 0;
2619}
2620
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002621static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2622 unsigned char type);
2623
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002624static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2625 struct snd_ctl_elem_value *ucontrol)
2626{
2627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2628 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002629 int nid = kcontrol->private_value;
2630
2631 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002632
2633 /* check to be sure that the ports are upto date with
2634 * switch changes
2635 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002636 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002637
2638 return 1;
2639}
2640
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002641#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002642
2643static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2644{
2645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2646 struct sigmatel_spec *spec = codec->spec;
2647 int io_idx = kcontrol-> private_value & 0xff;
2648
2649 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2650 return 0;
2651}
2652
2653static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2654{
2655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2656 struct sigmatel_spec *spec = codec->spec;
2657 hda_nid_t nid = kcontrol->private_value >> 8;
2658 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002659 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002660
2661 spec->io_switch[io_idx] = val;
2662
2663 if (val)
2664 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002665 else {
2666 unsigned int pinctl = AC_PINCTL_IN_EN;
2667 if (io_idx) /* set VREF for mic */
2668 pinctl |= stac92xx_get_vref(codec, nid);
2669 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2670 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002671
2672 /* check the auto-mute again: we need to mute/unmute the speaker
2673 * appropriately according to the pin direction
2674 */
2675 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002676 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002677
Matt Porter403d1942005-11-29 15:00:51 +01002678 return 1;
2679}
2680
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002681#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2682
2683static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2684 struct snd_ctl_elem_value *ucontrol)
2685{
2686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2687 struct sigmatel_spec *spec = codec->spec;
2688
2689 ucontrol->value.integer.value[0] = spec->clfe_swap;
2690 return 0;
2691}
2692
2693static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2694 struct snd_ctl_elem_value *ucontrol)
2695{
2696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2697 struct sigmatel_spec *spec = codec->spec;
2698 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002699 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002700
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002701 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002702 return 0;
2703
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002704 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002705
2706 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2707 spec->clfe_swap ? 0x4 : 0x0);
2708
2709 return 1;
2710}
2711
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002712#define STAC_CODEC_HP_SWITCH(xname) \
2713 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2714 .name = xname, \
2715 .index = 0, \
2716 .info = stac92xx_hp_switch_info, \
2717 .get = stac92xx_hp_switch_get, \
2718 .put = stac92xx_hp_switch_put, \
2719 }
2720
Matt Porter403d1942005-11-29 15:00:51 +01002721#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2722 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2723 .name = xname, \
2724 .index = 0, \
2725 .info = stac92xx_io_switch_info, \
2726 .get = stac92xx_io_switch_get, \
2727 .put = stac92xx_io_switch_put, \
2728 .private_value = xpval, \
2729 }
2730
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002731#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2732 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2733 .name = xname, \
2734 .index = 0, \
2735 .info = stac92xx_clfe_switch_info, \
2736 .get = stac92xx_clfe_switch_get, \
2737 .put = stac92xx_clfe_switch_put, \
2738 .private_value = xpval, \
2739 }
Matt Porter403d1942005-11-29 15:00:51 +01002740
Mattc7d4b2f2005-06-27 14:59:41 +02002741enum {
2742 STAC_CTL_WIDGET_VOL,
2743 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002744 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002745 STAC_CTL_WIDGET_AMP_MUX,
2746 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002747 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002748 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002749 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002750};
2751
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002752static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002753 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2754 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002755 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002756 STAC_AMP_MUX,
2757 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002758 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002759 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002760 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002761};
2762
2763/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002764static struct snd_kcontrol_new *
2765stac_control_new(struct sigmatel_spec *spec,
2766 struct snd_kcontrol_new *ktemp,
2767 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002768{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002769 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002770
Takashi Iwai603c4012008-07-30 15:01:44 +02002771 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2772 knew = snd_array_new(&spec->kctls);
2773 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002774 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002775 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002776 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002777 if (!knew->name) {
2778 /* roolback */
2779 memset(knew, 0, sizeof(*knew));
2780 spec->kctls.alloced--;
2781 return NULL;
2782 }
2783 return knew;
2784}
2785
2786static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2787 struct snd_kcontrol_new *ktemp,
2788 int idx, const char *name,
2789 unsigned long val)
2790{
2791 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2792 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002793 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002794 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002795 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002796 return 0;
2797}
2798
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002799static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2800 int type, int idx, const char *name,
2801 unsigned long val)
2802{
2803 return stac92xx_add_control_temp(spec,
2804 &stac92xx_control_templates[type],
2805 idx, name, val);
2806}
2807
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002808
2809/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002810static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2811 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002812{
2813 return stac92xx_add_control_idx(spec, type, 0, name, val);
2814}
2815
Takashi Iwaie3c75962009-01-23 11:57:22 +01002816static struct snd_kcontrol_new stac_input_src_temp = {
2817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2818 .name = "Input Source",
2819 .info = stac92xx_mux_enum_info,
2820 .get = stac92xx_mux_enum_get,
2821 .put = stac92xx_mux_enum_put,
2822};
2823
2824static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2825{
2826 struct snd_kcontrol_new *knew;
2827 struct hda_input_mux *imux = &spec->private_imux;
2828
2829 if (!spec->num_adcs || imux->num_items <= 1)
2830 return 0; /* no need for input source control */
2831 knew = stac_control_new(spec, &stac_input_src_temp,
2832 stac_input_src_temp.name);
2833 if (!knew)
2834 return -ENOMEM;
2835 knew->count = spec->num_adcs;
2836 return 0;
2837}
2838
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002839/* check whether the line-input can be used as line-out */
2840static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002841{
2842 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002843 struct auto_pin_cfg *cfg = &spec->autocfg;
2844 hda_nid_t nid;
2845 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002846
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002847 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2848 return 0;
2849 nid = cfg->input_pins[AUTO_PIN_LINE];
2850 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2851 if (pincap & AC_PINCAP_OUT)
2852 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002853 return 0;
2854}
2855
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002856/* check whether the mic-input can be used as line-out */
2857static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2858{
2859 struct sigmatel_spec *spec = codec->spec;
2860 struct auto_pin_cfg *cfg = &spec->autocfg;
2861 unsigned int def_conf, pincap;
2862 unsigned int mic_pin;
2863
2864 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2865 return 0;
2866 mic_pin = AUTO_PIN_MIC;
2867 for (;;) {
2868 hda_nid_t nid = cfg->input_pins[mic_pin];
2869 def_conf = snd_hda_codec_read(codec, nid, 0,
2870 AC_VERB_GET_CONFIG_DEFAULT, 0);
2871 /* some laptops have an internal analog microphone
2872 * which can't be used as a output */
2873 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2874 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2875 if (pincap & AC_PINCAP_OUT)
2876 return nid;
2877 }
2878 if (mic_pin == AUTO_PIN_MIC)
2879 mic_pin = AUTO_PIN_FRONT_MIC;
2880 else
2881 break;
2882 }
2883 return 0;
2884}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002885
2886static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2887{
2888 int i;
2889
2890 for (i = 0; i < spec->multiout.num_dacs; i++) {
2891 if (spec->multiout.dac_nids[i] == nid)
2892 return 1;
2893 }
2894
2895 return 0;
2896}
2897
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002898static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2899{
2900 int i;
2901 if (is_in_dac_nids(spec, nid))
2902 return 1;
2903 for (i = 0; i < spec->autocfg.hp_outs; i++)
2904 if (spec->hp_dacs[i] == nid)
2905 return 1;
2906 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2907 if (spec->speaker_dacs[i] == nid)
2908 return 1;
2909 return 0;
2910}
2911
2912static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2913{
2914 struct sigmatel_spec *spec = codec->spec;
2915 int j, conn_len;
2916 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2917 unsigned int wcaps, wtype;
2918
2919 conn_len = snd_hda_get_connections(codec, nid, conn,
2920 HDA_MAX_CONNECTIONS);
2921 for (j = 0; j < conn_len; j++) {
2922 wcaps = snd_hda_param_read(codec, conn[j],
2923 AC_PAR_AUDIO_WIDGET_CAP);
2924 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2925 /* we check only analog outputs */
2926 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2927 continue;
2928 /* if this route has a free DAC, assign it */
2929 if (!check_all_dac_nids(spec, conn[j])) {
2930 if (conn_len > 1) {
2931 /* select this DAC in the pin's input mux */
2932 snd_hda_codec_write_cache(codec, nid, 0,
2933 AC_VERB_SET_CONNECT_SEL, j);
2934 }
2935 return conn[j];
2936 }
2937 }
2938 return 0;
2939}
2940
2941static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2942static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2943
Matt Porter3cc08dc2006-01-23 15:27:49 +01002944/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002945 * Fill in the dac_nids table from the parsed pin configuration
2946 * This function only works when every pin in line_out_pins[]
2947 * contains atleast one DAC in its connection list. Some 92xx
2948 * codecs are not connected directly to a DAC, such as the 9200
2949 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002950 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002951static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002952{
2953 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002954 struct auto_pin_cfg *cfg = &spec->autocfg;
2955 int i;
2956 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002957
Mattc7d4b2f2005-06-27 14:59:41 +02002958 for (i = 0; i < cfg->line_outs; i++) {
2959 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002960 dac = get_unassigned_dac(codec, nid);
2961 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002962 if (spec->multiout.num_dacs > 0) {
2963 /* we have already working output pins,
2964 * so let's drop the broken ones again
2965 */
2966 cfg->line_outs = spec->multiout.num_dacs;
2967 break;
2968 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002969 /* error out, no available DAC found */
2970 snd_printk(KERN_ERR
2971 "%s: No available DAC for pin 0x%x\n",
2972 __func__, nid);
2973 return -ENODEV;
2974 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002975 add_spec_dacs(spec, dac);
2976 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002977
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002978 /* add line-in as output */
2979 nid = check_line_out_switch(codec);
2980 if (nid) {
2981 dac = get_unassigned_dac(codec, nid);
2982 if (dac) {
2983 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2984 nid, cfg->line_outs);
2985 cfg->line_out_pins[cfg->line_outs] = nid;
2986 cfg->line_outs++;
2987 spec->line_switch = nid;
2988 add_spec_dacs(spec, dac);
2989 }
2990 }
2991 /* add mic as output */
2992 nid = check_mic_out_switch(codec);
2993 if (nid) {
2994 dac = get_unassigned_dac(codec, nid);
2995 if (dac) {
2996 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2997 nid, cfg->line_outs);
2998 cfg->line_out_pins[cfg->line_outs] = nid;
2999 cfg->line_outs++;
3000 spec->mic_switch = nid;
3001 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003002 }
Mattc7d4b2f2005-06-27 14:59:41 +02003003 }
3004
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003005 for (i = 0; i < cfg->hp_outs; i++) {
3006 nid = cfg->hp_pins[i];
3007 dac = get_unassigned_dac(codec, nid);
3008 if (dac) {
3009 if (!spec->multiout.hp_nid)
3010 spec->multiout.hp_nid = dac;
3011 else
3012 add_spec_extra_dacs(spec, dac);
3013 }
3014 spec->hp_dacs[i] = dac;
3015 }
3016
3017 for (i = 0; i < cfg->speaker_outs; i++) {
3018 nid = cfg->speaker_pins[i];
3019 dac = get_unassigned_dac(codec, nid);
3020 if (dac)
3021 add_spec_extra_dacs(spec, dac);
3022 spec->speaker_dacs[i] = dac;
3023 }
3024
3025 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003026 spec->multiout.num_dacs,
3027 spec->multiout.dac_nids[0],
3028 spec->multiout.dac_nids[1],
3029 spec->multiout.dac_nids[2],
3030 spec->multiout.dac_nids[3],
3031 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003032
Mattc7d4b2f2005-06-27 14:59:41 +02003033 return 0;
3034}
3035
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003036/* create volume control/switch for the given prefx type */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003037static int create_controls(struct hda_codec *codec, const char *pfx,
3038 hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003039{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003040 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003041 char name[32];
3042 int err;
3043
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003044 if (!spec->check_volume_offset) {
3045 unsigned int caps, step, nums, db_scale;
3046 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3047 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3048 AC_AMPCAP_STEP_SIZE_SHIFT;
3049 step = (step + 1) * 25; /* in .01dB unit */
3050 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3051 AC_AMPCAP_NUM_STEPS_SHIFT;
3052 db_scale = nums * step;
3053 /* if dB scale is over -64dB, and finer enough,
3054 * let's reduce it to half
3055 */
3056 if (db_scale > 6400 && nums >= 0x1f)
3057 spec->volume_offset = nums / 2;
3058 spec->check_volume_offset = 1;
3059 }
3060
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003061 sprintf(name, "%s Playback Volume", pfx);
3062 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003063 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3064 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003065 if (err < 0)
3066 return err;
3067 sprintf(name, "%s Playback Switch", pfx);
3068 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
3069 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3070 if (err < 0)
3071 return err;
3072 return 0;
3073}
3074
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003075static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3076{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003077 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003078 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3079 return 1;
3080 } else {
3081 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3082 spec->multiout.num_dacs++;
3083 }
3084 return 0;
3085}
3086
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003087static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003088{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003089 int i;
3090 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3091 if (!spec->multiout.extra_out_nid[i]) {
3092 spec->multiout.extra_out_nid[i] = nid;
3093 return 0;
3094 }
3095 }
3096 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3097 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003098}
3099
Takashi Iwai76624532008-12-19 10:09:47 +01003100static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3101{
3102 int i;
3103
3104 if (spec->autocfg.line_outs != 1)
3105 return 0;
3106 if (spec->multiout.hp_nid == nid)
3107 return 0;
3108 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3109 if (spec->multiout.extra_out_nid[i] == nid)
3110 return 0;
3111 return 1;
3112}
3113
Mattc7d4b2f2005-06-27 14:59:41 +02003114/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003115static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003116 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003117{
Takashi Iwai76624532008-12-19 10:09:47 +01003118 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003119 static const char *chname[4] = {
3120 "Front", "Surround", NULL /*CLFE*/, "Side"
3121 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003122 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003123 int i, err;
3124 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003125
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003126 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003127 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003128 if (i == 2) {
3129 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003130 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003131 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003132 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003133 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003134 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003135 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003136
3137 wid_caps = get_wcaps(codec, nid);
3138
3139 if (wid_caps & AC_WCAP_LR_SWAP) {
3140 err = stac92xx_add_control(spec,
3141 STAC_CTL_WIDGET_CLFE_SWITCH,
3142 "Swap Center/LFE Playback Switch", nid);
3143
3144 if (err < 0)
3145 return err;
3146 }
3147
Mattc7d4b2f2005-06-27 14:59:41 +02003148 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003149 const char *name = chname[i];
3150 /* if it's a single DAC, assign a better name */
3151 if (!i && is_unique_dac(spec, nid)) {
3152 switch (cfg->line_out_type) {
3153 case AUTO_PIN_HP_OUT:
3154 name = "Headphone";
3155 break;
3156 case AUTO_PIN_SPEAKER_OUT:
3157 name = "Speaker";
3158 break;
3159 }
3160 }
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003161 err = create_controls(codec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003162 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003163 return err;
3164 }
3165 }
3166
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003167 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003168 err = stac92xx_add_control(spec,
3169 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003170 "Headphone as Line Out Switch",
3171 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003172 if (err < 0)
3173 return err;
3174 }
3175
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003176 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003177 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3178 "Line In as Output Switch",
3179 spec->line_switch << 8);
3180 if (err < 0)
3181 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003182 }
Matt Porter403d1942005-11-29 15:00:51 +01003183
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003184 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003185 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3186 "Mic as Output Switch",
3187 (spec->mic_switch << 8) | 1);
3188 if (err < 0)
3189 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003190 }
Matt Porter403d1942005-11-29 15:00:51 +01003191
Mattc7d4b2f2005-06-27 14:59:41 +02003192 return 0;
3193}
3194
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003195/* add playback controls for Speaker and HP outputs */
3196static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3197 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003198{
3199 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003200 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003201 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003202
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003203 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003204 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003205 static const char *pfxs[] = {
3206 "Headphone", "Headphone2", "Headphone3",
3207 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003208 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3209 if (wid_caps & AC_WCAP_UNSOL_CAP)
3210 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003211 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003212 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003213 nid = spec->hp_dacs[i];
3214 if (!nid)
3215 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003216 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003217 if (err < 0)
3218 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003219 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003220 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003221 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003222 static const char *pfxs[] = {
3223 "Speaker", "External Speaker", "Speaker2",
3224 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003225 if (nums >= ARRAY_SIZE(pfxs))
3226 continue;
3227 nid = spec->speaker_dacs[i];
3228 if (!nid)
3229 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003230 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003231 if (err < 0)
3232 return err;
3233 }
Mattc7d4b2f2005-06-27 14:59:41 +02003234 return 0;
3235}
3236
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003237/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003238static const char *stac92xx_mono_labels[4] = {
3239 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003240};
3241
3242/* create mono mux for mono out on capable codecs */
3243static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3244{
3245 struct sigmatel_spec *spec = codec->spec;
3246 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3247 int i, num_cons;
3248 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3249
3250 num_cons = snd_hda_get_connections(codec,
3251 spec->mono_nid,
3252 con_lst,
3253 HDA_MAX_NUM_INPUTS);
3254 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3255 return -EINVAL;
3256
3257 for (i = 0; i < num_cons; i++) {
3258 mono_mux->items[mono_mux->num_items].label =
3259 stac92xx_mono_labels[i];
3260 mono_mux->items[mono_mux->num_items].index = i;
3261 mono_mux->num_items++;
3262 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003263
3264 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3265 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003266}
3267
Matthew Ranostay89385032008-09-11 09:49:39 -04003268/* labels for amp mux outputs */
3269static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003270 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003271};
3272
3273/* create amp out controls mux on capable codecs */
3274static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3275{
3276 struct sigmatel_spec *spec = codec->spec;
3277 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3278 int i, err;
3279
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003280 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003281 amp_mux->items[amp_mux->num_items].label =
3282 stac92xx_amp_labels[i];
3283 amp_mux->items[amp_mux->num_items].index = i;
3284 amp_mux->num_items++;
3285 }
3286
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003287 if (spec->num_amps > 1) {
3288 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3289 "Amp Selector Capture Switch", 0);
3290 if (err < 0)
3291 return err;
3292 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003293 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3294 "Amp Capture Volume",
3295 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3296}
3297
3298
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003299/* create PC beep volume controls */
3300static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3301 hda_nid_t nid)
3302{
3303 struct sigmatel_spec *spec = codec->spec;
3304 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3305 int err;
3306
3307 /* check for mute support for the the amp */
3308 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3309 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3310 "PC Beep Playback Switch",
3311 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3312 if (err < 0)
3313 return err;
3314 }
3315
3316 /* check to see if there is volume support for the amp */
3317 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3318 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3319 "PC Beep Playback Volume",
3320 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3321 if (err < 0)
3322 return err;
3323 }
3324 return 0;
3325}
3326
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003327#ifdef CONFIG_SND_HDA_INPUT_BEEP
3328#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3329
3330static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3331 struct snd_ctl_elem_value *ucontrol)
3332{
3333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3334 ucontrol->value.integer.value[0] = codec->beep->enabled;
3335 return 0;
3336}
3337
3338static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3339 struct snd_ctl_elem_value *ucontrol)
3340{
3341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3342 int enabled = !!ucontrol->value.integer.value[0];
3343 if (codec->beep->enabled != enabled) {
3344 codec->beep->enabled = enabled;
3345 return 1;
3346 }
3347 return 0;
3348}
3349
3350static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3352 .info = stac92xx_dig_beep_switch_info,
3353 .get = stac92xx_dig_beep_switch_get,
3354 .put = stac92xx_dig_beep_switch_put,
3355};
3356
3357static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3358{
3359 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3360 0, "PC Beep Playback Switch", 0);
3361}
3362#endif
3363
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003364static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3365{
3366 struct sigmatel_spec *spec = codec->spec;
3367 int wcaps, nid, i, err = 0;
3368
3369 for (i = 0; i < spec->num_muxes; i++) {
3370 nid = spec->mux_nids[i];
3371 wcaps = get_wcaps(codec, nid);
3372
3373 if (wcaps & AC_WCAP_OUT_AMP) {
3374 err = stac92xx_add_control_idx(spec,
3375 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3376 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3377 if (err < 0)
3378 return err;
3379 }
3380 }
3381 return 0;
3382};
3383
Matthew Ranostayd9737752008-09-07 12:03:41 +02003384static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003385 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003386};
3387
3388static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3389{
3390 struct sigmatel_spec *spec = codec->spec;
3391 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003392 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003393 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003394 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003395
3396 num_cons = snd_hda_get_connections(codec,
3397 spec->smux_nids[0],
3398 con_lst,
3399 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003400 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003401 return -EINVAL;
3402
Matthew Ranostay65973632008-09-16 10:39:37 -04003403 if (!labels)
3404 labels = stac92xx_spdif_labels;
3405
Matthew Ranostayd9737752008-09-07 12:03:41 +02003406 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003407 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003408 spdif_mux->items[spdif_mux->num_items].index = i;
3409 spdif_mux->num_items++;
3410 }
3411
3412 return 0;
3413}
3414
Matt Porter8b657272006-10-26 17:12:59 +02003415/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003416static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003417 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3418 "Digital Mic 3", "Digital Mic 4"
3419};
3420
3421/* create playback/capture controls for input pins on dmic capable codecs */
3422static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3423 const struct auto_pin_cfg *cfg)
3424{
3425 struct sigmatel_spec *spec = codec->spec;
3426 struct hda_input_mux *dimux = &spec->private_dimux;
3427 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003428 int err, i, j;
3429 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003430
3431 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3432 dimux->items[dimux->num_items].index = 0;
3433 dimux->num_items++;
3434
3435 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003436 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003437 int index;
3438 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003439 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003440 unsigned int def_conf;
3441
3442 def_conf = snd_hda_codec_read(codec,
3443 spec->dmic_nids[i],
3444 0,
3445 AC_VERB_GET_CONFIG_DEFAULT,
3446 0);
3447 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3448 continue;
3449
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003450 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003451 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003452 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003453 con_lst,
3454 HDA_MAX_NUM_INPUTS);
3455 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003456 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003457 index = j;
3458 goto found;
3459 }
3460 continue;
3461found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003462 wcaps = get_wcaps(codec, nid) &
3463 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003464
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003465 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003466 sprintf(name, "%s Capture Volume",
3467 stac92xx_dmic_labels[dimux->num_items]);
3468
3469 err = stac92xx_add_control(spec,
3470 STAC_CTL_WIDGET_VOL,
3471 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003472 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3473 (wcaps & AC_WCAP_OUT_AMP) ?
3474 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003475 if (err < 0)
3476 return err;
3477 }
3478
Matt Porter8b657272006-10-26 17:12:59 +02003479 dimux->items[dimux->num_items].label =
3480 stac92xx_dmic_labels[dimux->num_items];
3481 dimux->items[dimux->num_items].index = index;
3482 dimux->num_items++;
3483 }
3484
3485 return 0;
3486}
3487
Mattc7d4b2f2005-06-27 14:59:41 +02003488/* create playback/capture controls for input pins */
3489static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3490{
3491 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003492 struct hda_input_mux *imux = &spec->private_imux;
3493 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3494 int i, j, k;
3495
3496 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003497 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003498
Takashi Iwai314634b2006-09-21 11:56:18 +02003499 if (!cfg->input_pins[i])
3500 continue;
3501 index = -1;
3502 for (j = 0; j < spec->num_muxes; j++) {
3503 int num_cons;
3504 num_cons = snd_hda_get_connections(codec,
3505 spec->mux_nids[j],
3506 con_lst,
3507 HDA_MAX_NUM_INPUTS);
3508 for (k = 0; k < num_cons; k++)
3509 if (con_lst[k] == cfg->input_pins[i]) {
3510 index = k;
3511 goto found;
3512 }
Mattc7d4b2f2005-06-27 14:59:41 +02003513 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003514 continue;
3515 found:
3516 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3517 imux->items[imux->num_items].index = index;
3518 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003519 }
3520
Steve Longerbeam7b043892007-05-03 20:50:03 +02003521 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003522 /*
3523 * Set the current input for the muxes.
3524 * The STAC9221 has two input muxes with identical source
3525 * NID lists. Hopefully this won't get confused.
3526 */
3527 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003528 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3529 AC_VERB_SET_CONNECT_SEL,
3530 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003531 }
3532 }
3533
Mattc7d4b2f2005-06-27 14:59:41 +02003534 return 0;
3535}
3536
Mattc7d4b2f2005-06-27 14:59:41 +02003537static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3538{
3539 struct sigmatel_spec *spec = codec->spec;
3540 int i;
3541
3542 for (i = 0; i < spec->autocfg.line_outs; i++) {
3543 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3544 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3545 }
3546}
3547
3548static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3549{
3550 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003551 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003552
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003553 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3554 hda_nid_t pin;
3555 pin = spec->autocfg.hp_pins[i];
3556 if (pin) /* connect to front */
3557 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3558 }
3559 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3560 hda_nid_t pin;
3561 pin = spec->autocfg.speaker_pins[i];
3562 if (pin) /* connect to front */
3563 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3564 }
Mattc7d4b2f2005-06-27 14:59:41 +02003565}
3566
Matt Porter3cc08dc2006-01-23 15:27:49 +01003567static 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 +02003568{
3569 struct sigmatel_spec *spec = codec->spec;
3570 int err;
3571
Matt Porter8b657272006-10-26 17:12:59 +02003572 if ((err = snd_hda_parse_pin_def_config(codec,
3573 &spec->autocfg,
3574 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003575 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003576 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003577 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003578
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003579 /* If we have no real line-out pin and multiple hp-outs, HPs should
3580 * be set up as multi-channel outputs.
3581 */
3582 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3583 spec->autocfg.hp_outs > 1) {
3584 /* Copy hp_outs to line_outs, backup line_outs in
3585 * speaker_outs so that the following routines can handle
3586 * HP pins as primary outputs.
3587 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003588 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003589 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3590 sizeof(spec->autocfg.line_out_pins));
3591 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3592 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3593 sizeof(spec->autocfg.hp_pins));
3594 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003595 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3596 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003597 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003598 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003599 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3600 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003601 u32 caps = query_amp_caps(codec,
3602 spec->autocfg.mono_out_pin, dir);
3603 hda_nid_t conn_list[1];
3604
3605 /* get the mixer node and then the mono mux if it exists */
3606 if (snd_hda_get_connections(codec,
3607 spec->autocfg.mono_out_pin, conn_list, 1) &&
3608 snd_hda_get_connections(codec, conn_list[0],
3609 conn_list, 1)) {
3610
3611 int wcaps = get_wcaps(codec, conn_list[0]);
3612 int wid_type = (wcaps & AC_WCAP_TYPE)
3613 >> AC_WCAP_TYPE_SHIFT;
3614 /* LR swap check, some stac925x have a mux that
3615 * changes the DACs output path instead of the
3616 * mono-mux path.
3617 */
3618 if (wid_type == AC_WID_AUD_SEL &&
3619 !(wcaps & AC_WCAP_LR_SWAP))
3620 spec->mono_nid = conn_list[0];
3621 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003622 if (dir) {
3623 hda_nid_t nid = spec->autocfg.mono_out_pin;
3624
3625 /* most mono outs have a least a mute/unmute switch */
3626 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3627 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3628 "Mono Playback Switch",
3629 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003630 if (err < 0)
3631 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003632 /* check for volume support for the amp */
3633 if ((caps & AC_AMPCAP_NUM_STEPS)
3634 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3635 err = stac92xx_add_control(spec,
3636 STAC_CTL_WIDGET_VOL,
3637 "Mono Playback Volume",
3638 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3639 if (err < 0)
3640 return err;
3641 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003642 }
3643
3644 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3645 AC_PINCTL_OUT_EN);
3646 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003647
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003648 if (!spec->multiout.num_dacs) {
3649 err = stac92xx_auto_fill_dac_nids(codec);
3650 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003651 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003652 err = stac92xx_auto_create_multi_out_ctls(codec,
3653 &spec->autocfg);
3654 if (err < 0)
3655 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003656 }
Mattc7d4b2f2005-06-27 14:59:41 +02003657
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003658 /* setup analog beep controls */
3659 if (spec->anabeep_nid > 0) {
3660 err = stac92xx_auto_create_beep_ctls(codec,
3661 spec->anabeep_nid);
3662 if (err < 0)
3663 return err;
3664 }
3665
3666 /* setup digital beep controls and input device */
3667#ifdef CONFIG_SND_HDA_INPUT_BEEP
3668 if (spec->digbeep_nid > 0) {
3669 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003670 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003671
3672 err = stac92xx_auto_create_beep_ctls(codec, nid);
3673 if (err < 0)
3674 return err;
3675 err = snd_hda_attach_beep_device(codec, nid);
3676 if (err < 0)
3677 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003678 /* if no beep switch is available, make its own one */
3679 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3680 if (codec->beep &&
3681 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3682 err = stac92xx_beep_switch_ctl(codec);
3683 if (err < 0)
3684 return err;
3685 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003686 }
3687#endif
3688
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003689 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3690
3691 if (err < 0)
3692 return err;
3693
3694 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3695
3696 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003697 return err;
3698
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003699 if (spec->mono_nid > 0) {
3700 err = stac92xx_auto_create_mono_output_ctls(codec);
3701 if (err < 0)
3702 return err;
3703 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003704 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003705 err = stac92xx_auto_create_amp_output_ctls(codec);
3706 if (err < 0)
3707 return err;
3708 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003709 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003710 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3711 &spec->autocfg)) < 0)
3712 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003713 if (spec->num_muxes > 0) {
3714 err = stac92xx_auto_create_mux_input_ctls(codec);
3715 if (err < 0)
3716 return err;
3717 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003718 if (spec->num_smuxes > 0) {
3719 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3720 if (err < 0)
3721 return err;
3722 }
Matt Porter8b657272006-10-26 17:12:59 +02003723
Takashi Iwaie3c75962009-01-23 11:57:22 +01003724 err = stac92xx_add_input_source(spec);
3725 if (err < 0)
3726 return err;
3727
Mattc7d4b2f2005-06-27 14:59:41 +02003728 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003729 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003730 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003731
Takashi Iwai82bc9552006-03-21 11:24:42 +01003732 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003733 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003734 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003735 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003736
Takashi Iwai603c4012008-07-30 15:01:44 +02003737 if (spec->kctls.list)
3738 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003739
3740 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003741 if (!spec->dinput_mux)
3742 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003743 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003744 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003745 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003746 return 1;
3747}
3748
Takashi Iwai82bc9552006-03-21 11:24:42 +01003749/* add playback controls for HP output */
3750static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3751 struct auto_pin_cfg *cfg)
3752{
3753 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003754 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003755 unsigned int wid_caps;
3756
3757 if (! pin)
3758 return 0;
3759
3760 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003761 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003762 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003763
3764 return 0;
3765}
3766
Richard Fish160ea0d2006-09-06 13:58:25 +02003767/* add playback controls for LFE output */
3768static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3769 struct auto_pin_cfg *cfg)
3770{
3771 struct sigmatel_spec *spec = codec->spec;
3772 int err;
3773 hda_nid_t lfe_pin = 0x0;
3774 int i;
3775
3776 /*
3777 * search speaker outs and line outs for a mono speaker pin
3778 * with an amp. If one is found, add LFE controls
3779 * for it.
3780 */
3781 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3782 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003783 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003784 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3785 if (wcaps == AC_WCAP_OUT_AMP)
3786 /* found a mono speaker with an amp, must be lfe */
3787 lfe_pin = pin;
3788 }
3789
3790 /* if speaker_outs is 0, then speakers may be in line_outs */
3791 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3792 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3793 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003794 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003795 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003796 AC_VERB_GET_CONFIG_DEFAULT,
3797 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003798 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003799 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003800 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3801 if (wcaps == AC_WCAP_OUT_AMP)
3802 /* found a mono speaker with an amp,
3803 must be lfe */
3804 lfe_pin = pin;
3805 }
3806 }
3807 }
3808
3809 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003810 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003811 if (err < 0)
3812 return err;
3813 }
3814
3815 return 0;
3816}
3817
Mattc7d4b2f2005-06-27 14:59:41 +02003818static int stac9200_parse_auto_config(struct hda_codec *codec)
3819{
3820 struct sigmatel_spec *spec = codec->spec;
3821 int err;
3822
Kailang Yangdf694da2005-12-05 19:42:22 +01003823 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003824 return err;
3825
3826 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3827 return err;
3828
Takashi Iwai82bc9552006-03-21 11:24:42 +01003829 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3830 return err;
3831
Richard Fish160ea0d2006-09-06 13:58:25 +02003832 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3833 return err;
3834
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003835 if (spec->num_muxes > 0) {
3836 err = stac92xx_auto_create_mux_input_ctls(codec);
3837 if (err < 0)
3838 return err;
3839 }
3840
Takashi Iwaie3c75962009-01-23 11:57:22 +01003841 err = stac92xx_add_input_source(spec);
3842 if (err < 0)
3843 return err;
3844
Takashi Iwai82bc9552006-03-21 11:24:42 +01003845 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003846 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003847 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003848 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003849
Takashi Iwai603c4012008-07-30 15:01:44 +02003850 if (spec->kctls.list)
3851 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003852
3853 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003854 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003855
3856 return 1;
3857}
3858
Sam Revitch62fe78e2006-05-10 15:09:17 +02003859/*
3860 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3861 * funky external mute control using GPIO pins.
3862 */
3863
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003864static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003865 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003866{
3867 unsigned int gpiostate, gpiomask, gpiodir;
3868
3869 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3870 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003871 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003872
3873 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3874 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003875 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003876
3877 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3878 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003879 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003880
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003881 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003882 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3883
3884 snd_hda_codec_write(codec, codec->afg, 0,
3885 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003886 snd_hda_codec_read(codec, codec->afg, 0,
3887 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003888
3889 msleep(1);
3890
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003891 snd_hda_codec_read(codec, codec->afg, 0,
3892 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003893}
3894
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003895static int stac92xx_add_jack(struct hda_codec *codec,
3896 hda_nid_t nid, int type)
3897{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003898#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003899 struct sigmatel_spec *spec = codec->spec;
3900 struct sigmatel_jack *jack;
3901 int def_conf = snd_hda_codec_read(codec, nid,
3902 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3903 int connectivity = get_defcfg_connect(def_conf);
3904 char name[32];
3905
3906 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3907 return 0;
3908
3909 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3910 jack = snd_array_new(&spec->jacks);
3911 if (!jack)
3912 return -ENOMEM;
3913 jack->nid = nid;
3914 jack->type = type;
3915
3916 sprintf(name, "%s at %s %s Jack",
3917 snd_hda_get_jack_type(def_conf),
3918 snd_hda_get_jack_connectivity(def_conf),
3919 snd_hda_get_jack_location(def_conf));
3920
3921 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003922#else
3923 return 0;
3924#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003925}
3926
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003927static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3928 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003929{
3930 struct sigmatel_event *event;
3931
3932 snd_array_init(&spec->events, sizeof(*event), 32);
3933 event = snd_array_new(&spec->events);
3934 if (!event)
3935 return -ENOMEM;
3936 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003937 event->type = type;
3938 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003939 event->data = data;
3940
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003941 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003942}
3943
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003944static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3945 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003946{
3947 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003948 struct sigmatel_event *event = spec->events.list;
3949 int i;
3950
3951 for (i = 0; i < spec->events.used; i++, event++) {
3952 if (event->nid == nid && event->type == type)
3953 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003954 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003955 return NULL;
3956}
3957
3958static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3959 unsigned char tag)
3960{
3961 struct sigmatel_spec *spec = codec->spec;
3962 struct sigmatel_event *event = spec->events.list;
3963 int i;
3964
3965 for (i = 0; i < spec->events.used; i++, event++) {
3966 if (event->tag == tag)
3967 return event;
3968 }
3969 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003970}
3971
Takashi Iwai314634b2006-09-21 11:56:18 +02003972static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003973 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003974{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003975 struct sigmatel_event *event;
3976 int tag;
3977
3978 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3979 return;
3980 event = stac_get_event(codec, nid, type);
3981 if (event)
3982 tag = event->tag;
3983 else
3984 tag = stac_add_event(codec->spec, nid, type, 0);
3985 if (tag < 0)
3986 return;
3987 snd_hda_codec_write_cache(codec, nid, 0,
3988 AC_VERB_SET_UNSOLICITED_ENABLE,
3989 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003990}
3991
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003992static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3993{
3994 int i;
3995 for (i = 0; i < cfg->hp_outs; i++)
3996 if (cfg->hp_pins[i] == nid)
3997 return 1; /* nid is a HP-Out */
3998
3999 return 0; /* nid is not a HP-Out */
4000};
4001
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004002static void stac92xx_power_down(struct hda_codec *codec)
4003{
4004 struct sigmatel_spec *spec = codec->spec;
4005
4006 /* power down inactive DACs */
4007 hda_nid_t *dac;
4008 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004009 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004010 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004011 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4012}
4013
Takashi Iwaif73d3582008-11-25 08:21:51 +01004014static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4015 int enable);
4016
Mattc7d4b2f2005-06-27 14:59:41 +02004017static int stac92xx_init(struct hda_codec *codec)
4018{
4019 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004020 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004021 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004022 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004023
Mattc7d4b2f2005-06-27 14:59:41 +02004024 snd_hda_sequence_write(codec, spec->init);
4025
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004026 /* power down adcs initially */
4027 if (spec->powerdown_adcs)
4028 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004029 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004030 spec->adc_nids[i], 0,
4031 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004032
4033 /* set up GPIO */
4034 gpio = spec->gpio_data;
4035 /* turn on EAPD statically when spec->eapd_switch isn't set.
4036 * otherwise, unsol event will turn it on/off dynamically
4037 */
4038 if (!spec->eapd_switch)
4039 gpio |= spec->eapd_mask;
4040 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4041
Takashi Iwai82bc9552006-03-21 11:24:42 +01004042 /* set up pins */
4043 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004044 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004045 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004046 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004047 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004048 }
Takashi Iwai0a07aca2007-03-13 10:40:23 +01004049 /* force to enable the first line-out; the others are set up
4050 * in unsol_event
4051 */
4052 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004053 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004054 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004055 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4056 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004057 } else {
4058 stac92xx_auto_init_multi_out(codec);
4059 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004060 for (i = 0; i < cfg->hp_outs; i++)
4061 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004062 }
4063 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004064 hda_nid_t nid = cfg->input_pins[i];
4065 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004066 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004067 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4068 /* for mic pins, force to initialize */
4069 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004070 pinctl |= AC_PINCTL_IN_EN;
4071 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004072 } else {
4073 pinctl = snd_hda_codec_read(codec, nid, 0,
4074 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4075 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004076 if (!(pinctl & AC_PINCTL_IN_EN)) {
4077 pinctl |= AC_PINCTL_IN_EN;
4078 stac92xx_auto_set_pinctl(codec, nid,
4079 pinctl);
4080 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004081 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004082 conf = snd_hda_codec_read(codec, nid, 0,
4083 AC_VERB_GET_CONFIG_DEFAULT, 0);
4084 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4085 enable_pin_detect(codec, nid,
4086 STAC_INSERT_EVENT);
4087 stac_issue_unsol_event(codec, nid,
4088 STAC_INSERT_EVENT);
4089 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004090 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004091 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004092 for (i = 0; i < spec->num_dmics; i++)
4093 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4094 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004095 if (cfg->dig_out_pin)
4096 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
4097 AC_PINCTL_OUT_EN);
4098 if (cfg->dig_in_pin)
4099 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4100 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004101 for (i = 0; i < spec->num_pwrs; i++) {
4102 hda_nid_t nid = spec->pwr_nids[i];
4103 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004104
Takashi Iwaieb632122008-12-19 16:39:48 +01004105 /* power on when no jack detection is available */
4106 if (!spec->hp_detect) {
4107 stac_toggle_power_map(codec, nid, 1);
4108 continue;
4109 }
4110
4111 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004112 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004113
Takashi Iwaif73d3582008-11-25 08:21:51 +01004114 pinctl = snd_hda_codec_read(codec, nid, 0,
4115 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4116 /* outputs are only ports capable of power management
4117 * any attempts on powering down a input port cause the
4118 * referenced VREF to act quirky.
4119 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004120 if (pinctl & AC_PINCTL_IN_EN) {
4121 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004122 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004123 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004124 def_conf = snd_hda_codec_read(codec, nid, 0,
4125 AC_VERB_GET_CONFIG_DEFAULT, 0);
4126 def_conf = get_defcfg_connect(def_conf);
4127 /* skip any ports that don't have jacks since presence
4128 * detection is useless */
4129 if (def_conf != AC_JACK_PORT_COMPLEX) {
4130 if (def_conf != AC_JACK_PORT_NONE)
4131 stac_toggle_power_map(codec, nid, 1);
4132 continue;
4133 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004134 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4135 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4136 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4137 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004138 }
4139 if (spec->dac_list)
4140 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004141 return 0;
4142}
4143
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004144static void stac92xx_free_jacks(struct hda_codec *codec)
4145{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004146#ifdef CONFIG_SND_JACK
Takashi Iwaib94d3532008-11-21 09:08:06 +01004147 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004148 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d3532008-11-21 09:08:06 +01004149 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004150 struct sigmatel_jack *jacks = spec->jacks.list;
4151 int i;
4152 for (i = 0; i < spec->jacks.used; i++)
4153 snd_device_free(codec->bus->card, &jacks[i].jack);
4154 }
4155 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004156#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004157}
4158
Takashi Iwai603c4012008-07-30 15:01:44 +02004159static void stac92xx_free_kctls(struct hda_codec *codec)
4160{
4161 struct sigmatel_spec *spec = codec->spec;
4162
4163 if (spec->kctls.list) {
4164 struct snd_kcontrol_new *kctl = spec->kctls.list;
4165 int i;
4166 for (i = 0; i < spec->kctls.used; i++)
4167 kfree(kctl[i].name);
4168 }
4169 snd_array_free(&spec->kctls);
4170}
4171
Matt2f2f4252005-04-13 14:45:30 +02004172static void stac92xx_free(struct hda_codec *codec)
4173{
Mattc7d4b2f2005-06-27 14:59:41 +02004174 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004175
4176 if (! spec)
4177 return;
4178
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004179 kfree(spec->pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004180 stac92xx_free_jacks(codec);
4181 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004182
Mattc7d4b2f2005-06-27 14:59:41 +02004183 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004184 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004185}
4186
Matt4e550962005-07-04 17:51:39 +02004187static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4188 unsigned int flag)
4189{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004190 unsigned int old_ctl, pin_ctl;
4191
4192 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004193 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004194
Takashi Iwaif9acba42007-05-29 18:01:06 +02004195 if (pin_ctl & AC_PINCTL_IN_EN) {
4196 /*
4197 * we need to check the current set-up direction of
4198 * shared input pins since they can be switched via
4199 * "xxx as Output" mixer switch
4200 */
4201 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004202 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004203 return;
4204 }
4205
Takashi Iwai8ce84192009-01-22 16:59:20 +01004206 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004207 /* if setting pin direction bits, clear the current
4208 direction bits first */
4209 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4210 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4211
Takashi Iwai8ce84192009-01-22 16:59:20 +01004212 pin_ctl |= flag;
4213 if (old_ctl != pin_ctl)
4214 snd_hda_codec_write_cache(codec, nid, 0,
4215 AC_VERB_SET_PIN_WIDGET_CONTROL,
4216 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004217}
4218
4219static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4220 unsigned int flag)
4221{
4222 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4223 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004224 if (pin_ctl & flag)
4225 snd_hda_codec_write_cache(codec, nid, 0,
4226 AC_VERB_SET_PIN_WIDGET_CONTROL,
4227 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004228}
4229
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004230static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004231{
4232 if (!nid)
4233 return 0;
4234 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004235 & (1 << 31))
4236 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004237 return 0;
4238}
4239
Takashi Iwaid7a89432008-11-12 09:48:04 +01004240/* return non-zero if the hp-pin of the given array index isn't
4241 * a jack-detection target
4242 */
4243static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4244{
4245 struct auto_pin_cfg *cfg = &spec->autocfg;
4246
4247 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004248 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004249 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004250 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004251 return 1;
4252 /* ignore if the pin is set as line-out */
4253 if (cfg->hp_pins[i] == spec->hp_switch)
4254 return 1;
4255 return 0;
4256}
4257
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004258static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004259{
4260 struct sigmatel_spec *spec = codec->spec;
4261 struct auto_pin_cfg *cfg = &spec->autocfg;
4262 int i, presence;
4263
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004264 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004265 if (spec->gpio_mute)
4266 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4267 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4268
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004269 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004270 if (presence)
4271 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004272 if (no_hp_sensing(spec, i))
4273 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004274 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4275 if (presence) {
4276 unsigned int pinctl;
4277 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4278 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4279 if (pinctl & AC_PINCTL_IN_EN)
4280 presence = 0; /* mic- or line-input */
4281 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004282 }
Matt4e550962005-07-04 17:51:39 +02004283
4284 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004285 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004286 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004287 stac92xx_reset_pinctl(codec, spec->hp_switch,
4288 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004289 for (i = 0; i < cfg->line_outs; i++)
4290 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4291 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004292 for (i = 0; i < cfg->speaker_outs; i++)
4293 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4294 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004295 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004296 stac_gpio_set(codec, spec->gpio_mask,
4297 spec->gpio_dir, spec->gpio_data &
4298 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004299 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004300 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004301 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004302 stac92xx_set_pinctl(codec, spec->hp_switch,
4303 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004304 for (i = 0; i < cfg->line_outs; i++)
4305 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4306 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004307 for (i = 0; i < cfg->speaker_outs; i++)
4308 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4309 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004310 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004311 stac_gpio_set(codec, spec->gpio_mask,
4312 spec->gpio_dir, spec->gpio_data |
4313 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004314 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004315 /* toggle hp outs */
4316 for (i = 0; i < cfg->hp_outs; i++) {
4317 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4318 if (no_hp_sensing(spec, i))
4319 continue;
4320 if (presence)
4321 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004322#if 0 /* FIXME */
4323/* Resetting the pinctl like below may lead to (a sort of) regressions
4324 * on some devices since they use the HP pin actually for line/speaker
4325 * outs although the default pin config shows a different pin (that is
4326 * wrong and useless).
4327 *
4328 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4329 * But, disabling the code below just works around it, and I'm too tired of
4330 * bug reports with such devices...
4331 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004332 else
4333 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004334#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004335 }
Matt4e550962005-07-04 17:51:39 +02004336}
4337
Takashi Iwaif73d3582008-11-25 08:21:51 +01004338static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4339 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004340{
4341 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004342 unsigned int idx, val;
4343
4344 for (idx = 0; idx < spec->num_pwrs; idx++) {
4345 if (spec->pwr_nids[idx] == nid)
4346 break;
4347 }
4348 if (idx >= spec->num_pwrs)
4349 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004350
4351 /* several codecs have two power down bits */
4352 if (spec->pwr_mapping)
4353 idx = spec->pwr_mapping[idx];
4354 else
4355 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004356
Takashi Iwaif73d3582008-11-25 08:21:51 +01004357 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4358 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004359 val &= ~idx;
4360 else
4361 val |= idx;
4362
4363 /* power down unused output ports */
4364 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004365}
4366
Takashi Iwaif73d3582008-11-25 08:21:51 +01004367static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4368{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004369 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004370}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004371
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004372static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4373{
4374 struct sigmatel_spec *spec = codec->spec;
4375 struct sigmatel_jack *jacks = spec->jacks.list;
4376
4377 if (jacks) {
4378 int i;
4379 for (i = 0; i < spec->jacks.used; i++) {
4380 if (jacks->nid == nid) {
4381 unsigned int pin_ctl =
4382 snd_hda_codec_read(codec, nid,
4383 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4384 0x00);
4385 int type = jacks->type;
4386 if (type == (SND_JACK_LINEOUT
4387 | SND_JACK_HEADPHONE))
4388 type = (pin_ctl & AC_PINCTL_HP_EN)
4389 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4390 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004391 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004392 ? type : 0);
4393 }
4394 jacks++;
4395 }
4396 }
4397}
Matt2f2f4252005-04-13 14:45:30 +02004398
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004399static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4400 unsigned char type)
4401{
4402 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4403 if (!event)
4404 return;
4405 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4406}
4407
Takashi Iwai314634b2006-09-21 11:56:18 +02004408static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4409{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004410 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004411 struct sigmatel_event *event;
4412 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004413
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004414 tag = (res >> 26) & 0x7f;
4415 event = stac_get_event_from_tag(codec, tag);
4416 if (!event)
4417 return;
4418
4419 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004420 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004421 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004422 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004423 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004424 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004425 if (spec->num_pwrs > 0)
4426 stac92xx_pin_sense(codec, event->nid);
4427 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004428 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004429 case STAC_VREF_EVENT:
4430 data = snd_hda_codec_read(codec, codec->afg, 0,
4431 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004432 /* toggle VREF state based on GPIOx status */
4433 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004434 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004435 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004436 }
4437}
4438
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004439#ifdef CONFIG_PROC_FS
4440static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4441 struct hda_codec *codec, hda_nid_t nid)
4442{
4443 if (nid == codec->afg)
4444 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4445 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4446}
4447
4448static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4449 struct hda_codec *codec,
4450 unsigned int verb)
4451{
4452 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4453 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4454}
4455
4456/* stac92hd71bxx, stac92hd73xx */
4457static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4458 struct hda_codec *codec, hda_nid_t nid)
4459{
4460 stac92hd_proc_hook(buffer, codec, nid);
4461 if (nid == codec->afg)
4462 analog_loop_proc_hook(buffer, codec, 0xfa0);
4463}
4464
4465static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4466 struct hda_codec *codec, hda_nid_t nid)
4467{
4468 if (nid == codec->afg)
4469 analog_loop_proc_hook(buffer, codec, 0xfe0);
4470}
4471
4472static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4473 struct hda_codec *codec, hda_nid_t nid)
4474{
4475 if (nid == codec->afg)
4476 analog_loop_proc_hook(buffer, codec, 0xfeb);
4477}
4478#else
4479#define stac92hd_proc_hook NULL
4480#define stac92hd7x_proc_hook NULL
4481#define stac9205_proc_hook NULL
4482#define stac927x_proc_hook NULL
4483#endif
4484
Takashi Iwaicb53c622007-08-10 17:21:45 +02004485#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004486static int stac92xx_resume(struct hda_codec *codec)
4487{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004488 struct sigmatel_spec *spec = codec->spec;
4489
Richard Fish11b44bb2006-08-23 18:31:34 +02004490 stac92xx_set_config_regs(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004491 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004492 snd_hda_codec_resume_amp(codec);
4493 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004494 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004495 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004496 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4497 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004498 return 0;
4499}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004500
4501static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4502{
4503 struct sigmatel_spec *spec = codec->spec;
4504 if (spec->eapd_mask)
4505 stac_gpio_set(codec, spec->gpio_mask,
4506 spec->gpio_dir, spec->gpio_data &
4507 ~spec->eapd_mask);
4508 return 0;
4509}
Mattff6fdc32005-06-27 15:06:52 +02004510#endif
4511
Matt2f2f4252005-04-13 14:45:30 +02004512static struct hda_codec_ops stac92xx_patch_ops = {
4513 .build_controls = stac92xx_build_controls,
4514 .build_pcms = stac92xx_build_pcms,
4515 .init = stac92xx_init,
4516 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004517 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004518#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004519 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004520 .resume = stac92xx_resume,
4521#endif
Matt2f2f4252005-04-13 14:45:30 +02004522};
4523
4524static int patch_stac9200(struct hda_codec *codec)
4525{
4526 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004527 int err;
Matt2f2f4252005-04-13 14:45:30 +02004528
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004529 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004530 if (spec == NULL)
4531 return -ENOMEM;
4532
4533 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004534 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004535 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004536 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4537 stac9200_models,
4538 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004539 if (spec->board_config < 0) {
4540 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4541 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004542 } else
4543 err = stac_save_pin_cfgs(codec,
4544 stac9200_brd_tbl[spec->board_config]);
4545 if (err < 0) {
4546 stac92xx_free(codec);
4547 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004548 }
Matt2f2f4252005-04-13 14:45:30 +02004549
4550 spec->multiout.max_channels = 2;
4551 spec->multiout.num_dacs = 1;
4552 spec->multiout.dac_nids = stac9200_dac_nids;
4553 spec->adc_nids = stac9200_adc_nids;
4554 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004555 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004556 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004557 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004558 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004559
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004560 if (spec->board_config == STAC_9200_M4 ||
4561 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004562 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004563 spec->init = stac9200_eapd_init;
4564 else
4565 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004566 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004567
Takashi Iwai117f2572008-03-18 09:53:23 +01004568 if (spec->board_config == STAC_9200_PANASONIC) {
4569 spec->gpio_mask = spec->gpio_dir = 0x09;
4570 spec->gpio_data = 0x00;
4571 }
4572
Mattc7d4b2f2005-06-27 14:59:41 +02004573 err = stac9200_parse_auto_config(codec);
4574 if (err < 0) {
4575 stac92xx_free(codec);
4576 return err;
4577 }
Matt2f2f4252005-04-13 14:45:30 +02004578
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004579 /* CF-74 has no headphone detection, and the driver should *NOT*
4580 * do detection and HP/speaker toggle because the hardware does it.
4581 */
4582 if (spec->board_config == STAC_9200_PANASONIC)
4583 spec->hp_detect = 0;
4584
Matt2f2f4252005-04-13 14:45:30 +02004585 codec->patch_ops = stac92xx_patch_ops;
4586
4587 return 0;
4588}
4589
Tobin Davis8e21c342007-01-08 11:04:17 +01004590static int patch_stac925x(struct hda_codec *codec)
4591{
4592 struct sigmatel_spec *spec;
4593 int err;
4594
4595 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4596 if (spec == NULL)
4597 return -ENOMEM;
4598
4599 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004600 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004601 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004602
4603 /* Check first for codec ID */
4604 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4605 STAC_925x_MODELS,
4606 stac925x_models,
4607 stac925x_codec_id_cfg_tbl);
4608
4609 /* Now checks for PCI ID, if codec ID is not found */
4610 if (spec->board_config < 0)
4611 spec->board_config = snd_hda_check_board_config(codec,
4612 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004613 stac925x_models,
4614 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004615 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004616 if (spec->board_config < 0) {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004617 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004618 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004619 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004620 } else
4621 err = stac_save_pin_cfgs(codec,
4622 stac925x_brd_tbl[spec->board_config]);
4623 if (err < 0) {
4624 stac92xx_free(codec);
4625 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01004626 }
4627
4628 spec->multiout.max_channels = 2;
4629 spec->multiout.num_dacs = 1;
4630 spec->multiout.dac_nids = stac925x_dac_nids;
4631 spec->adc_nids = stac925x_adc_nids;
4632 spec->mux_nids = stac925x_mux_nids;
4633 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004634 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004635 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004636 switch (codec->vendor_id) {
4637 case 0x83847632: /* STAC9202 */
4638 case 0x83847633: /* STAC9202D */
4639 case 0x83847636: /* STAC9251 */
4640 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004641 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004642 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004643 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4644 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004645 break;
4646 default:
4647 spec->num_dmics = 0;
4648 break;
4649 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004650
4651 spec->init = stac925x_core_init;
4652 spec->mixer = stac925x_mixer;
4653
4654 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004655 if (!err) {
4656 if (spec->board_config < 0) {
4657 printk(KERN_WARNING "hda_codec: No auto-config is "
4658 "available, default to model=ref\n");
4659 spec->board_config = STAC_925x_REF;
4660 goto again;
4661 }
4662 err = -EINVAL;
4663 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004664 if (err < 0) {
4665 stac92xx_free(codec);
4666 return err;
4667 }
4668
4669 codec->patch_ops = stac92xx_patch_ops;
4670
4671 return 0;
4672}
4673
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004674static struct hda_input_mux stac92hd73xx_dmux = {
4675 .num_items = 4,
4676 .items = {
4677 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004678 { "Digital Mic 1", 0x09 },
4679 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004680 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004681 }
4682};
4683
4684static int patch_stac92hd73xx(struct hda_codec *codec)
4685{
4686 struct sigmatel_spec *spec;
4687 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4688 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004689 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004690
4691 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4692 if (spec == NULL)
4693 return -ENOMEM;
4694
4695 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004696 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004697 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4698 spec->pin_nids = stac92hd73xx_pin_nids;
4699 spec->board_config = snd_hda_check_board_config(codec,
4700 STAC_92HD73XX_MODELS,
4701 stac92hd73xx_models,
4702 stac92hd73xx_cfg_tbl);
4703again:
4704 if (spec->board_config < 0) {
4705 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4706 " STAC92HD73XX, using BIOS defaults\n");
4707 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004708 } else
4709 err = stac_save_pin_cfgs(codec,
4710 stac92hd73xx_brd_tbl[spec->board_config]);
4711 if (err < 0) {
4712 stac92xx_free(codec);
4713 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004714 }
4715
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004716 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004717 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4718
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004719 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004720 printk(KERN_WARNING "hda_codec: Could not determine "
4721 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004722 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004723 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004724 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004725 case 0x3: /* 6 Channel */
4726 spec->mixer = stac92hd73xx_6ch_mixer;
4727 spec->init = stac92hd73xx_6ch_core_init;
4728 break;
4729 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004730 spec->mixer = stac92hd73xx_8ch_mixer;
4731 spec->init = stac92hd73xx_8ch_core_init;
4732 break;
4733 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004734 spec->mixer = stac92hd73xx_10ch_mixer;
4735 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004736 }
4737 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004738
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004739 spec->aloopback_mask = 0x01;
4740 spec->aloopback_shift = 8;
4741
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004742 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004743 spec->mux_nids = stac92hd73xx_mux_nids;
4744 spec->adc_nids = stac92hd73xx_adc_nids;
4745 spec->dmic_nids = stac92hd73xx_dmic_nids;
4746 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004747 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004748 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004749 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004750
4751 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4752 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai16970552007-12-18 18:05:52 +01004753 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004754 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4755 sizeof(stac92hd73xx_dmux));
4756
Matthew Ranostaya7662642008-02-21 07:51:14 +01004757 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004758 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004759 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004760 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004761 case STAC_DELL_M6_AMIC:
4762 case STAC_DELL_M6_DMIC:
4763 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004764 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004765 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4766 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004767 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004768 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004769
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004770 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004771 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004772 switch (spec->board_config) {
4773 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004774 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4775 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004776 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004777 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004778 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004779 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4780 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004781 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004782 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004783 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004784 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4785 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4786 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004787 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004788 break;
4789 }
4790 break;
4791 default:
4792 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004793 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004794 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004795 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004796 if (spec->board_config > STAC_92HD73XX_REF) {
4797 /* GPIO0 High = Enable EAPD */
4798 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4799 spec->gpio_data = 0x01;
4800 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004801 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004802
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004803 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4804 spec->pwr_nids = stac92hd73xx_pwr_nids;
4805
Matthew Ranostayd9737752008-09-07 12:03:41 +02004806 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004807
4808 if (!err) {
4809 if (spec->board_config < 0) {
4810 printk(KERN_WARNING "hda_codec: No auto-config is "
4811 "available, default to model=ref\n");
4812 spec->board_config = STAC_92HD73XX_REF;
4813 goto again;
4814 }
4815 err = -EINVAL;
4816 }
4817
4818 if (err < 0) {
4819 stac92xx_free(codec);
4820 return err;
4821 }
4822
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004823 if (spec->board_config == STAC_92HD73XX_NO_JD)
4824 spec->hp_detect = 0;
4825
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004826 codec->patch_ops = stac92xx_patch_ops;
4827
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004828 codec->proc_widget_hook = stac92hd7x_proc_hook;
4829
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004830 return 0;
4831}
4832
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004833static struct hda_input_mux stac92hd83xxx_dmux = {
4834 .num_items = 3,
4835 .items = {
4836 { "Analog Inputs", 0x03 },
4837 { "Digital Mic 1", 0x04 },
4838 { "Digital Mic 2", 0x05 },
4839 }
4840};
4841
4842static int patch_stac92hd83xxx(struct hda_codec *codec)
4843{
4844 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004845 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004846 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004847 int num_dacs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004848
4849 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4850 if (spec == NULL)
4851 return -ENOMEM;
4852
4853 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004854 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004855 spec->mono_nid = 0x19;
4856 spec->digbeep_nid = 0x21;
4857 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4858 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4859 spec->adc_nids = stac92hd83xxx_adc_nids;
4860 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004861 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004862 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4863 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004864 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004865
Matthew Ranostay65557f32009-01-20 16:50:25 -05004866
4867 /* set port 0xe to select the last DAC
4868 */
4869 num_dacs = snd_hda_get_connections(codec, 0x0e,
4870 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4871
4872 snd_hda_codec_write_cache(codec, 0xe, 0,
4873 AC_VERB_SET_CONNECT_SEL, num_dacs);
4874
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004875 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004876 spec->mixer = stac92hd83xxx_mixer;
4877 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4878 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4879 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004880 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004881 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4882 spec->dinput_mux = &stac92hd83xxx_dmux;
4883 spec->pin_nids = stac92hd83xxx_pin_nids;
4884 spec->board_config = snd_hda_check_board_config(codec,
4885 STAC_92HD83XXX_MODELS,
4886 stac92hd83xxx_models,
4887 stac92hd83xxx_cfg_tbl);
4888again:
4889 if (spec->board_config < 0) {
4890 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4891 " STAC92HD83XXX, using BIOS defaults\n");
4892 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004893 } else
4894 err = stac_save_pin_cfgs(codec,
4895 stac92hd83xxx_brd_tbl[spec->board_config]);
4896 if (err < 0) {
4897 stac92xx_free(codec);
4898 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004899 }
4900
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05004901 switch (codec->vendor_id) {
4902 case 0x111d7604:
4903 case 0x111d7605:
4904 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4905 break;
4906 spec->num_pwrs = 0;
4907 break;
4908 }
4909
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004910 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4911 if (!err) {
4912 if (spec->board_config < 0) {
4913 printk(KERN_WARNING "hda_codec: No auto-config is "
4914 "available, default to model=ref\n");
4915 spec->board_config = STAC_92HD83XXX_REF;
4916 goto again;
4917 }
4918 err = -EINVAL;
4919 }
4920
4921 if (err < 0) {
4922 stac92xx_free(codec);
4923 return err;
4924 }
4925
4926 codec->patch_ops = stac92xx_patch_ops;
4927
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004928 codec->proc_widget_hook = stac92hd_proc_hook;
4929
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004930 return 0;
4931}
4932
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004933static struct hda_input_mux stac92hd71bxx_dmux = {
4934 .num_items = 4,
4935 .items = {
4936 { "Analog Inputs", 0x00 },
4937 { "Mixer", 0x01 },
4938 { "Digital Mic 1", 0x02 },
4939 { "Digital Mic 2", 0x03 },
4940 }
4941};
4942
Matthew Ranostaye035b842007-11-06 11:53:55 +01004943static int patch_stac92hd71bxx(struct hda_codec *codec)
4944{
4945 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05004946 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004947 int err = 0;
4948
4949 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4950 if (spec == NULL)
4951 return -ENOMEM;
4952
4953 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004954 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004955 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004956 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004957 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004958 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4959 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004960 spec->board_config = snd_hda_check_board_config(codec,
4961 STAC_92HD71BXX_MODELS,
4962 stac92hd71bxx_models,
4963 stac92hd71bxx_cfg_tbl);
4964again:
4965 if (spec->board_config < 0) {
4966 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4967 " STAC92HD71BXX, using BIOS defaults\n");
4968 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004969 } else
4970 err = stac_save_pin_cfgs(codec,
4971 stac92hd71bxx_brd_tbl[spec->board_config]);
4972 if (err < 0) {
4973 stac92xx_free(codec);
4974 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004975 }
4976
Takashi Iwai41c3b642008-11-18 10:45:15 +01004977 if (spec->board_config > STAC_92HD71BXX_REF) {
4978 /* GPIO0 = EAPD */
4979 spec->gpio_mask = 0x01;
4980 spec->gpio_dir = 0x01;
4981 spec->gpio_data = 0x01;
4982 }
4983
Matthew Ranostay541eee82007-12-14 12:08:04 +01004984 switch (codec->vendor_id) {
4985 case 0x111d76b6: /* 4 Port without Analog Mixer */
4986 case 0x111d76b7:
4987 case 0x111d76b4: /* 6 Port without Analog Mixer */
4988 case 0x111d76b5:
4989 spec->mixer = stac92hd71bxx_mixer;
4990 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004991 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004992 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004993 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004994 switch (spec->board_config) {
4995 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004996 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004997 err = stac_add_event(spec, codec->afg,
4998 STAC_VREF_EVENT, 0x02);
4999 if (err < 0)
5000 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005001 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005002 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5003 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005004 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005005 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005006 spec->gpio_mask |= 0x02;
5007 break;
5008 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005009 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005010 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005011 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005012
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005013 /* no output amps */
5014 spec->num_pwrs = 0;
5015 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005016 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005017
5018 /* disable VSW */
5019 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005020 unmute_init++;
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005021 stac_change_pin_config(codec, 0xf, 0x40f000f0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005022 break;
5023 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005024 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005025 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005026
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005027 /* no output amps */
5028 spec->num_pwrs = 0;
5029 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005030 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005031 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005032 spec->mixer = stac92hd71bxx_analog_mixer;
5033 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005034 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005035 }
5036
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005037 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5038 snd_hda_sequence_write_cache(codec, unmute_init);
5039
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005040 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005041 spec->aloopback_shift = 0;
5042
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005043 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005044 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005045 spec->mux_nids = stac92hd71bxx_mux_nids;
5046 spec->adc_nids = stac92hd71bxx_adc_nids;
5047 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005048 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005049 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005050 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005051
5052 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5053 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005054
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005055 switch (spec->board_config) {
5056 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005057 /* enable internal microphone */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005058 stac_change_pin_config(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005059 stac92xx_auto_set_pinctl(codec, 0x0e,
5060 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005061 /* fallthru */
5062 case STAC_DELL_M4_2:
5063 spec->num_dmics = 0;
5064 spec->num_smuxes = 0;
5065 spec->num_dmuxes = 0;
5066 break;
5067 case STAC_DELL_M4_1:
5068 case STAC_DELL_M4_3:
5069 spec->num_dmics = 1;
5070 spec->num_smuxes = 0;
5071 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005072 break;
5073 default:
5074 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
5075 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
5076 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5077 };
5078
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005079 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005080 if (spec->dinput_mux)
5081 spec->private_dimux.num_items +=
5082 spec->num_dmics -
5083 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005084
5085 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
5086 if (!err) {
5087 if (spec->board_config < 0) {
5088 printk(KERN_WARNING "hda_codec: No auto-config is "
5089 "available, default to model=ref\n");
5090 spec->board_config = STAC_92HD71BXX_REF;
5091 goto again;
5092 }
5093 err = -EINVAL;
5094 }
5095
5096 if (err < 0) {
5097 stac92xx_free(codec);
5098 return err;
5099 }
5100
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005101 codec->proc_widget_hook = stac92hd7x_proc_hook;
5102
Matthew Ranostaye035b842007-11-06 11:53:55 +01005103 return 0;
5104};
5105
Matt2f2f4252005-04-13 14:45:30 +02005106static int patch_stac922x(struct hda_codec *codec)
5107{
5108 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005109 int err;
Matt2f2f4252005-04-13 14:45:30 +02005110
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005111 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005112 if (spec == NULL)
5113 return -ENOMEM;
5114
5115 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005116 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005117 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005118 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5119 stac922x_models,
5120 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005121 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005122 spec->gpio_mask = spec->gpio_dir = 0x03;
5123 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005124 /* Intel Macs have all same PCI SSID, so we need to check
5125 * codec SSID to distinguish the exact models
5126 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005127 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005128 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005129
5130 case 0x106b0800:
5131 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005132 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005133 case 0x106b0600:
5134 case 0x106b0700:
5135 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005136 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005137 case 0x106b0e00:
5138 case 0x106b0f00:
5139 case 0x106b1600:
5140 case 0x106b1700:
5141 case 0x106b0200:
5142 case 0x106b1e00:
5143 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005144 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005145 case 0x106b1a00:
5146 case 0x00000100:
5147 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005148 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005149 case 0x106b0a00:
5150 case 0x106b2200:
5151 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005152 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005153 default:
5154 spec->board_config = STAC_INTEL_MAC_V3;
5155 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005156 }
5157 }
5158
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005159 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005160 if (spec->board_config < 0) {
5161 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5162 "using BIOS defaults\n");
5163 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005164 } else
5165 err = stac_save_pin_cfgs(codec,
5166 stac922x_brd_tbl[spec->board_config]);
5167 if (err < 0) {
5168 stac92xx_free(codec);
5169 return err;
Matt Porter403d1942005-11-29 15:00:51 +01005170 }
Matt2f2f4252005-04-13 14:45:30 +02005171
Matt2f2f4252005-04-13 14:45:30 +02005172 spec->adc_nids = stac922x_adc_nids;
5173 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005174 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005175 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005176 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005177 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005178
5179 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005180 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005181
5182 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005183
Matt Porter3cc08dc2006-01-23 15:27:49 +01005184 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005185 if (!err) {
5186 if (spec->board_config < 0) {
5187 printk(KERN_WARNING "hda_codec: No auto-config is "
5188 "available, default to model=ref\n");
5189 spec->board_config = STAC_D945_REF;
5190 goto again;
5191 }
5192 err = -EINVAL;
5193 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005194 if (err < 0) {
5195 stac92xx_free(codec);
5196 return err;
5197 }
5198
5199 codec->patch_ops = stac92xx_patch_ops;
5200
Takashi Iwai807a46362007-05-29 19:01:37 +02005201 /* Fix Mux capture level; max to 2 */
5202 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5203 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5204 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5205 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5206 (0 << AC_AMPCAP_MUTE_SHIFT));
5207
Matt Porter3cc08dc2006-01-23 15:27:49 +01005208 return 0;
5209}
5210
5211static int patch_stac927x(struct hda_codec *codec)
5212{
5213 struct sigmatel_spec *spec;
5214 int err;
5215
5216 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5217 if (spec == NULL)
5218 return -ENOMEM;
5219
5220 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005221 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005222 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005223 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5224 stac927x_models,
5225 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005226 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005227 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
5228 if (spec->board_config < 0)
5229 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5230 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02005231 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005232 } else
5233 err = stac_save_pin_cfgs(codec,
5234 stac927x_brd_tbl[spec->board_config]);
5235 if (err < 0) {
5236 stac92xx_free(codec);
5237 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01005238 }
5239
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005240 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005241 spec->adc_nids = stac927x_adc_nids;
5242 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5243 spec->mux_nids = stac927x_mux_nids;
5244 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005245 spec->smux_nids = stac927x_smux_nids;
5246 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005247 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005248 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005249 spec->multiout.dac_nids = spec->dac_nids;
5250
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005251 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005252 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005253 case STAC_D965_5ST:
5254 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005255 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005256 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005257 spec->num_dmics = 0;
5258
Tobin Davis93ed1502006-09-01 21:03:12 +02005259 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005260 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005261 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005262 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005263 switch (codec->subsystem_id) {
5264 case 0x10280209:
5265 case 0x1028022e:
5266 /* correct the device field to SPDIF out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005267 stac_change_pin_config(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005268 break;
5269 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005270 /* configure the analog microphone on some laptops */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005271 stac_change_pin_config(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005272 /* correct the front output jack as a hp out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005273 stac_change_pin_config(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005274 /* correct the front input jack as a mic */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005275 stac_change_pin_config(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005276 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005277 case STAC_DELL_3ST:
5278 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005279 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005280 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005281 spec->dmic_nids = stac927x_dmic_nids;
5282 spec->num_dmics = STAC927X_NUM_DMICS;
5283
Tobin Davis93ed1502006-09-01 21:03:12 +02005284 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005285 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005286 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01005287 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005288 break;
5289 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005290 if (spec->board_config > STAC_D965_REF) {
5291 /* GPIO0 High = Enable EAPD */
5292 spec->eapd_mask = spec->gpio_mask = 0x01;
5293 spec->gpio_dir = spec->gpio_data = 0x01;
5294 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005295 spec->num_dmics = 0;
5296
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005297 spec->init = stac927x_core_init;
5298 spec->mixer = stac927x_mixer;
5299 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005300
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005301 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005302 spec->aloopback_mask = 0x40;
5303 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005304 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005305
Matt Porter3cc08dc2006-01-23 15:27:49 +01005306 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005307 if (!err) {
5308 if (spec->board_config < 0) {
5309 printk(KERN_WARNING "hda_codec: No auto-config is "
5310 "available, default to model=ref\n");
5311 spec->board_config = STAC_D965_REF;
5312 goto again;
5313 }
5314 err = -EINVAL;
5315 }
Mattc7d4b2f2005-06-27 14:59:41 +02005316 if (err < 0) {
5317 stac92xx_free(codec);
5318 return err;
5319 }
Matt2f2f4252005-04-13 14:45:30 +02005320
5321 codec->patch_ops = stac92xx_patch_ops;
5322
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005323 codec->proc_widget_hook = stac927x_proc_hook;
5324
Takashi Iwai52987652008-01-16 16:09:47 +01005325 /*
5326 * !!FIXME!!
5327 * The STAC927x seem to require fairly long delays for certain
5328 * command sequences. With too short delays (even if the answer
5329 * is set to RIRB properly), it results in the silence output
5330 * on some hardwares like Dell.
5331 *
5332 * The below flag enables the longer delay (see get_response
5333 * in hda_intel.c).
5334 */
5335 codec->bus->needs_damn_long_delay = 1;
5336
Takashi Iwaie28d8322008-12-17 13:48:29 +01005337 /* no jack detecion for ref-no-jd model */
5338 if (spec->board_config == STAC_D965_REF_NO_JD)
5339 spec->hp_detect = 0;
5340
Matt2f2f4252005-04-13 14:45:30 +02005341 return 0;
5342}
5343
Matt Porterf3302a592006-07-31 12:49:34 +02005344static int patch_stac9205(struct hda_codec *codec)
5345{
5346 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005347 int err;
Matt Porterf3302a592006-07-31 12:49:34 +02005348
5349 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5350 if (spec == NULL)
5351 return -ENOMEM;
5352
5353 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005354 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005355 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005356 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5357 stac9205_models,
5358 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005359 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005360 if (spec->board_config < 0) {
5361 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5362 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005363 } else
5364 err = stac_save_pin_cfgs(codec,
5365 stac9205_brd_tbl[spec->board_config]);
5366 if (err < 0) {
5367 stac92xx_free(codec);
5368 return err;
Matt Porterf3302a592006-07-31 12:49:34 +02005369 }
5370
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005371 spec->digbeep_nid = 0x23;
Matt Porterf3302a592006-07-31 12:49:34 +02005372 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005373 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a592006-07-31 12:49:34 +02005374 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005375 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005376 spec->smux_nids = stac9205_smux_nids;
5377 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005378 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005379 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005380 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01005381 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005382 spec->num_pwrs = 0;
Matt Porterf3302a592006-07-31 12:49:34 +02005383
5384 spec->init = stac9205_core_init;
5385 spec->mixer = stac9205_mixer;
5386
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005387 spec->aloopback_mask = 0x40;
5388 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005389 /* Turn on/off EAPD per HP plugging */
5390 if (spec->board_config != STAC_9205_EAPD)
5391 spec->eapd_switch = 1;
Matt Porterf3302a592006-07-31 12:49:34 +02005392 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005393
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005394 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005395 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005396 /* Enable SPDIF in/out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005397 stac_change_pin_config(codec, 0x1f, 0x01441030);
5398 stac_change_pin_config(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005399
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005400 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005401 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5402 if (err < 0)
5403 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005404 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005405 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5406 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005407 AC_VERB_SET_UNSOLICITED_ENABLE,
5408 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005409
5410 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005411 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005412 spec->gpio_mask = 0x1b;
5413 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005414 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005415 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005416 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005417 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005418 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005419 case STAC_9205_REF:
5420 /* SPDIF-In enabled */
5421 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005422 default:
5423 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005424 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005425 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005426 break;
5427 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005428
Matt Porterf3302a592006-07-31 12:49:34 +02005429 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005430 if (!err) {
5431 if (spec->board_config < 0) {
5432 printk(KERN_WARNING "hda_codec: No auto-config is "
5433 "available, default to model=ref\n");
5434 spec->board_config = STAC_9205_REF;
5435 goto again;
5436 }
5437 err = -EINVAL;
5438 }
Matt Porterf3302a592006-07-31 12:49:34 +02005439 if (err < 0) {
5440 stac92xx_free(codec);
5441 return err;
5442 }
5443
5444 codec->patch_ops = stac92xx_patch_ops;
5445
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005446 codec->proc_widget_hook = stac9205_proc_hook;
5447
Matt Porterf3302a592006-07-31 12:49:34 +02005448 return 0;
5449}
5450
Matt2f2f4252005-04-13 14:45:30 +02005451/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005452 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005453 */
5454
Takashi Iwai1e137f92009-01-21 07:41:22 +01005455static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005456 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5458 {}
5459};
5460
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005461static struct snd_kcontrol_new stac9872_mixer[] = {
5462 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5463 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005464 { } /* end */
5465};
5466
5467static hda_nid_t stac9872_pin_nids[] = {
5468 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5469 0x11, 0x13, 0x14,
5470};
5471
5472static hda_nid_t stac9872_adc_nids[] = {
5473 0x8 /*,0x6*/
5474};
5475
5476static hda_nid_t stac9872_mux_nids[] = {
5477 0x15
5478};
5479
Guillaume Munch6d859062006-08-22 17:15:47 +02005480static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005481{
5482 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005483 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005484
Takashi Iwaidb064e52006-03-16 16:04:58 +01005485 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5486 if (spec == NULL)
5487 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005488 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005489
Takashi Iwai1e137f92009-01-21 07:41:22 +01005490#if 0 /* no model right now */
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005491 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5492 stac9872_models,
5493 stac9872_cfg_tbl);
Takashi Iwai1e137f92009-01-21 07:41:22 +01005494#endif
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005495
Takashi Iwai1e137f92009-01-21 07:41:22 +01005496 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5497 spec->pin_nids = stac9872_pin_nids;
5498 spec->multiout.dac_nids = spec->dac_nids;
5499 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5500 spec->adc_nids = stac9872_adc_nids;
5501 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5502 spec->mux_nids = stac9872_mux_nids;
5503 spec->mixer = stac9872_mixer;
5504 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005505
Takashi Iwai1e137f92009-01-21 07:41:22 +01005506 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5507 if (err < 0) {
5508 stac92xx_free(codec);
5509 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005510 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005511 spec->input_mux = &spec->private_imux;
5512 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005513 return 0;
5514}
5515
5516
5517/*
Matt2f2f4252005-04-13 14:45:30 +02005518 * patch entries
5519 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005520static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005521 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5522 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5523 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5524 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5525 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5526 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5527 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005528 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5529 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5530 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5531 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5532 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5533 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005534 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5535 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5536 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5537 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5538 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5539 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5540 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5541 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5542 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5543 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005544 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5545 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5546 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5547 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5548 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5549 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005550 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5551 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005552 /* The following does not take into account .id=0x83847661 when subsys =
5553 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5554 * currently not fully supported.
5555 */
5556 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5557 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5558 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a592006-07-31 12:49:34 +02005559 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5560 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5561 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5562 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5563 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5564 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5565 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5566 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005567 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005568 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5569 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005570 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005571 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5572 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005573 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005574 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5575 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5576 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5577 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5578 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5579 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5580 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5581 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005582 {} /* terminator */
5583};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005584
5585MODULE_ALIAS("snd-hda-codec-id:8384*");
5586MODULE_ALIAS("snd-hda-codec-id:111d*");
5587
5588MODULE_LICENSE("GPL");
5589MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5590
5591static struct hda_codec_preset_list sigmatel_list = {
5592 .preset = snd_hda_preset_sigmatel,
5593 .owner = THIS_MODULE,
5594};
5595
5596static int __init patch_sigmatel_init(void)
5597{
5598 return snd_hda_add_codec_preset(&sigmatel_list);
5599}
5600
5601static void __exit patch_sigmatel_exit(void)
5602{
5603 snd_hda_delete_codec_preset(&sigmatel_list);
5604}
5605
5606module_init(patch_sigmatel_init)
5607module_exit(patch_sigmatel_exit)