blob: 80a4c288b319c9b1b3d72b949f609fce2b74ea5d [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040033#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Takashi Iwaic6e4c662008-11-25 11:58:19 +010038enum {
39 STAC_VREF_EVENT = 1,
40 STAC_INSERT_EVENT,
41 STAC_PWR_EVENT,
42 STAC_HP_EVENT,
43};
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
46 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010047 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020048 STAC_9200_DELL_D21,
49 STAC_9200_DELL_D22,
50 STAC_9200_DELL_D23,
51 STAC_9200_DELL_M21,
52 STAC_9200_DELL_M22,
53 STAC_9200_DELL_M23,
54 STAC_9200_DELL_M24,
55 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020058 STAC_9200_M4,
59 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010060 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010061 STAC_9200_MODELS
62};
63
64enum {
65 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020066 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020067 STAC_9205_DELL_M43,
68 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010069 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010070 STAC_9205_MODELS
71};
72
73enum {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010074 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010075 STAC_92HD73XX_REF,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010076 STAC_DELL_M6_AMIC,
77 STAC_DELL_M6_DMIC,
78 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050079 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010080 STAC_92HD73XX_MODELS
81};
82
83enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020084 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050085 STAC_92HD83XXX_PWR_REF,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020086 STAC_92HD83XXX_MODELS
87};
88
89enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010090 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010091 STAC_DELL_M4_1,
92 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050093 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040094 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +010095 STAC_HP_DV5,
Matthew Ranostaye035b842007-11-06 11:53:55 +010096 STAC_92HD71BXX_MODELS
97};
98
99enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100100 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200101 STAC_M1,
102 STAC_M1_2,
103 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100104 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200105 STAC_M3,
106 STAC_M5,
107 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100108 STAC_925x_MODELS
109};
110
111enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100112 STAC_D945_REF,
113 STAC_D945GTP3,
114 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200115 STAC_INTEL_MAC_V1,
116 STAC_INTEL_MAC_V2,
117 STAC_INTEL_MAC_V3,
118 STAC_INTEL_MAC_V4,
119 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800120 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
121 * is given, one of the above models will be
122 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200123 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100124 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100125 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100126 STAC_MACBOOK_PRO_V1,
127 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200128 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200129 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300130 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200131 STAC_922X_DELL_D81,
132 STAC_922X_DELL_D82,
133 STAC_922X_DELL_M81,
134 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100135 STAC_922X_MODELS
136};
137
138enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100139 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100140 STAC_D965_REF,
141 STAC_D965_3ST,
142 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200143 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100144 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100145 STAC_927X_MODELS
146};
Matt Porter403d1942005-11-29 15:00:51 +0100147
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400148struct sigmatel_event {
149 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100150 unsigned char type;
151 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400152 int data;
153};
154
155struct sigmatel_jack {
156 hda_nid_t nid;
157 int type;
158 struct snd_jack *jack;
159};
160
Matt2f2f4252005-04-13 14:45:30 +0200161struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100162 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200163 unsigned int num_mixers;
164
Matt Porter403d1942005-11-29 15:00:51 +0100165 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500166 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200167 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100168 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100169 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400170 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100171 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200172
Matthew 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 Iwai1697055e2007-12-18 18:05:52 +0100218 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200219 hda_nid_t *smux_nids;
220 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400221 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200222
Mattdabbed62005-06-14 10:19:34 +0200223 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100224 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200225 hda_nid_t anabeep_nid;
226 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200227
Matt2f2f4252005-04-13 14:45:30 +0200228 /* pin widgets */
229 hda_nid_t *pin_nids;
230 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200231 unsigned int *pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200232
233 /* codec specific stuff */
234 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100235 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200236
237 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200238 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100239 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200240 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100241 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200242 struct hda_input_mux *sinput_mux;
243 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400244 unsigned int cur_amux;
245 hda_nid_t *amp_nids;
246 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200247 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200248
Matt Porter403d1942005-11-29 15:00:51 +0100249 /* i/o switches */
250 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200251 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100252 hda_nid_t line_switch; /* shared line-in for input and output */
253 hda_nid_t mic_switch; /* shared mic-in for input and output */
254 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200255 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200256
Mattc7d4b2f2005-06-27 14:59:41 +0200257 struct hda_pcm pcm_rec[2]; /* PCM information */
258
259 /* dynamic controls and input_mux */
260 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200261 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200262 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200263 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200264 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400265 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100266 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200267};
268
269static hda_nid_t stac9200_adc_nids[1] = {
270 0x03,
271};
272
273static hda_nid_t stac9200_mux_nids[1] = {
274 0x0c,
275};
276
277static hda_nid_t stac9200_dac_nids[1] = {
278 0x02,
279};
280
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100281static hda_nid_t stac92hd73xx_pwr_nids[8] = {
282 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
283 0x0f, 0x10, 0x11
284};
285
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400286static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
287 0x26, 0,
288};
289
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100290static hda_nid_t stac92hd73xx_adc_nids[2] = {
291 0x1a, 0x1b
292};
293
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400294#define DELL_M6_AMP 2
295static hda_nid_t stac92hd73xx_amp_nids[3] = {
296 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400297};
298
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100299#define STAC92HD73XX_NUM_DMICS 2
300static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
301 0x13, 0x14, 0
302};
303
304#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100305
306static hda_nid_t stac92hd73xx_mux_nids[4] = {
307 0x28, 0x29, 0x2a, 0x2b,
308};
309
310static hda_nid_t stac92hd73xx_dmux_nids[2] = {
311 0x20, 0x21,
312};
313
Matthew Ranostayd9737752008-09-07 12:03:41 +0200314static hda_nid_t stac92hd73xx_smux_nids[2] = {
315 0x22, 0x23,
316};
317
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200318#define STAC92HD83XXX_NUM_DMICS 2
319static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
320 0x11, 0x12, 0
321};
322
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200323#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200324
325static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
326 0x17, 0x18,
327};
328
329static hda_nid_t stac92hd83xxx_adc_nids[2] = {
330 0x15, 0x16,
331};
332
333static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
334 0xa, 0xb, 0xd, 0xe,
335};
336
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400337static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
338 0x1e, 0,
339};
340
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200341static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500342 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200343};
344
Takashi Iwai9248f262009-01-14 09:40:25 +0100345static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500346 0xc,
347};
348
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100349static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
350 0x0a, 0x0d, 0x0f
351};
352
Matthew Ranostaye035b842007-11-06 11:53:55 +0100353static hda_nid_t stac92hd71bxx_adc_nids[2] = {
354 0x12, 0x13,
355};
356
357static hda_nid_t stac92hd71bxx_mux_nids[2] = {
358 0x1a, 0x1b
359};
360
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400361static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
362 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100363};
364
Matthew Ranostayd9737752008-09-07 12:03:41 +0200365static hda_nid_t stac92hd71bxx_smux_nids[2] = {
366 0x24, 0x25,
367};
368
Matthew Ranostaye035b842007-11-06 11:53:55 +0100369#define STAC92HD71BXX_NUM_DMICS 2
370static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
371 0x18, 0x19, 0
372};
373
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400374static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
375 0x22, 0
376};
377
Tobin Davis8e21c342007-01-08 11:04:17 +0100378static hda_nid_t stac925x_adc_nids[1] = {
379 0x03,
380};
381
382static hda_nid_t stac925x_mux_nids[1] = {
383 0x0f,
384};
385
386static hda_nid_t stac925x_dac_nids[1] = {
387 0x02,
388};
389
Takashi Iwaif6e98522007-10-16 14:27:04 +0200390#define STAC925X_NUM_DMICS 1
391static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
392 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200393};
394
Takashi Iwai1697055e2007-12-18 18:05:52 +0100395static hda_nid_t stac925x_dmux_nids[1] = {
396 0x14,
397};
398
Matt2f2f4252005-04-13 14:45:30 +0200399static hda_nid_t stac922x_adc_nids[2] = {
400 0x06, 0x07,
401};
402
403static hda_nid_t stac922x_mux_nids[2] = {
404 0x12, 0x13,
405};
406
Matt Porter3cc08dc2006-01-23 15:27:49 +0100407static hda_nid_t stac927x_adc_nids[3] = {
408 0x07, 0x08, 0x09
409};
410
411static hda_nid_t stac927x_mux_nids[3] = {
412 0x15, 0x16, 0x17
413};
414
Matthew Ranostayd9737752008-09-07 12:03:41 +0200415static hda_nid_t stac927x_smux_nids[1] = {
416 0x21,
417};
418
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100419static hda_nid_t stac927x_dac_nids[6] = {
420 0x02, 0x03, 0x04, 0x05, 0x06, 0
421};
422
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100423static hda_nid_t stac927x_dmux_nids[1] = {
424 0x1b,
425};
426
Matthew Ranostay7f168592007-10-18 17:38:17 +0200427#define STAC927X_NUM_DMICS 2
428static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
429 0x13, 0x14, 0
430};
431
Matthew Ranostay65973632008-09-16 10:39:37 -0400432static const char *stac927x_spdif_labels[5] = {
433 "Digital Playback", "ADAT", "Analog Mux 1",
434 "Analog Mux 2", "Analog Mux 3"
435};
436
Matt Porterf3302a52006-07-31 12:49:34 +0200437static hda_nid_t stac9205_adc_nids[2] = {
438 0x12, 0x13
439};
440
441static hda_nid_t stac9205_mux_nids[2] = {
442 0x19, 0x1a
443};
444
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100445static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100446 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100447};
448
Matthew Ranostayd9737752008-09-07 12:03:41 +0200449static hda_nid_t stac9205_smux_nids[1] = {
450 0x21,
451};
452
Takashi Iwaif6e98522007-10-16 14:27:04 +0200453#define STAC9205_NUM_DMICS 2
454static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
455 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200456};
457
Mattc7d4b2f2005-06-27 14:59:41 +0200458static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200459 0x08, 0x09, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200461};
462
Tobin Davis8e21c342007-01-08 11:04:17 +0100463static hda_nid_t stac925x_pin_nids[8] = {
464 0x07, 0x08, 0x0a, 0x0b,
465 0x0c, 0x0d, 0x10, 0x11,
466};
467
Matt2f2f4252005-04-13 14:45:30 +0200468static hda_nid_t stac922x_pin_nids[10] = {
469 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
470 0x0f, 0x10, 0x11, 0x15, 0x1b,
471};
472
Matthew Ranostaya7662642008-02-21 07:51:14 +0100473static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100474 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
475 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200476 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100477};
478
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200479static hda_nid_t stac92hd83xxx_pin_nids[14] = {
480 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
481 0x0f, 0x10, 0x11, 0x12, 0x13,
482 0x1d, 0x1e, 0x1f, 0x20
483};
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 Porterf3302a52006-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 Porterf3302a52006-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100861 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
862 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
863 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
864 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200865 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100866};
867
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400868#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100869static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200870 /* start of config #1 */
871
872 /* connect port 0f to audio mixer */
873 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200874 /* unmute right and left channels for node 0x0f */
875 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
876 /* start of config #2 */
877
Matthew Ranostay541eee82007-12-14 12:08:04 +0100878 /* set master volume and direct control */
879 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200880 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100881 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
882 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100883 {}
884};
885
Tobin Davis8e21c342007-01-08 11:04:17 +0100886static struct hda_verb stac925x_core_init[] = {
887 /* set dac0mux for dac converter */
888 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100889 /* mute the master volume */
890 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100891 {}
892};
893
Mattc7d4b2f2005-06-27 14:59:41 +0200894static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200895 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200896 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200897 {}
898};
899
Tobin Davis93ed1502006-09-01 21:03:12 +0200900static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200901 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200902 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200903 /* unmute node 0x1b */
904 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
905 /* select node 0x03 as DAC */
906 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
907 {}
908};
909
Matt Porter3cc08dc2006-01-23 15:27:49 +0100910static struct hda_verb stac927x_core_init[] = {
911 /* set master volume and direct control */
912 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200913 /* enable analog pc beep path */
914 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100915 {}
916};
917
Matt Porterf3302a52006-07-31 12:49:34 +0200918static struct hda_verb stac9205_core_init[] = {
919 /* set master volume and direct control */
920 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200921 /* enable analog pc beep path */
922 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200923 {}
924};
925
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100926#define STAC_MONO_MUX \
927 { \
928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
929 .name = "Mono Mux", \
930 .count = 1, \
931 .info = stac92xx_mono_mux_enum_info, \
932 .get = stac92xx_mono_mux_enum_get, \
933 .put = stac92xx_mono_mux_enum_put, \
934 }
935
Matthew Ranostay89385032008-09-11 09:49:39 -0400936#define STAC_AMP_MUX \
937 { \
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
939 .name = "Amp Selector Capture Switch", \
940 .count = 1, \
941 .info = stac92xx_amp_mux_enum_info, \
942 .get = stac92xx_amp_mux_enum_get, \
943 .put = stac92xx_amp_mux_enum_put, \
944 }
945
946#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
947 { \
948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
949 .name = xname, \
950 .index = 0, \
951 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
952 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
953 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
954 .info = stac92xx_amp_volume_info, \
955 .get = stac92xx_amp_volume_get, \
956 .put = stac92xx_amp_volume_put, \
957 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
958 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
959 }
960
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100961#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200962 { \
963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
964 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100965 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200966 .info = stac92xx_aloopback_info, \
967 .get = stac92xx_aloopback_get, \
968 .put = stac92xx_aloopback_put, \
969 .private_value = verb_read | (verb_write << 16), \
970 }
971
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100972static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200973 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
974 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200975 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
976 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200977 { } /* end */
978};
979
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400980#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100981static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400982 /* start of config #1 */
983 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
984 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
985
986 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
987 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
988
989 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
990 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
991
992 /* start of config #2 */
993 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
994 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
995
996 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
997 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
998
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100999 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1000
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001001 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1002 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1003
1004 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1005 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1006
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001007 { } /* end */
1008};
1009
1010static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001011 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1012
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001013 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1014 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1015
1016 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1017 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1018
1019 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1020 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1021
1022 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1023 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1024
1025 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1026 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1027
1028 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1029 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1030
1031 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1032 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1033 { } /* end */
1034};
1035
1036static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001037 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1038
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001039 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1040 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1041
1042 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1044
1045 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1046 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1047
1048 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1049 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1050
1051 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1052 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1053
1054 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1055 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1056
1057 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1058 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1059 { } /* end */
1060};
1061
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001062
1063static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1064 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1065 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1066
1067 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1068 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1069
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001070 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1071 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001072
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001073 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1074 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001075
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001076 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1077 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001078
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001079 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1080 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001081
1082 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001083 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1084 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001085 */
1086 { } /* end */
1087};
1088
Matthew Ranostay541eee82007-12-14 12:08:04 +01001089static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001090 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001091
Matthew Ranostay9b359472007-11-07 13:03:12 +01001092 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1093 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001094
1095 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1096 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001097 /* analog pc-beep replaced with digital beep support */
1098 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001099 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1100 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001101 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001102
Matthew Ranostay687cb982008-10-11 13:52:43 -04001103 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1104 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001105
Matthew Ranostay687cb982008-10-11 13:52:43 -04001106 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1107 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001108
1109 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1110 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1111
1112 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1113 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001114 { } /* end */
1115};
1116
Matthew Ranostay541eee82007-12-14 12:08:04 +01001117static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001118 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1119
Matthew Ranostay541eee82007-12-14 12:08:04 +01001120 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001122
1123 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001125 { } /* end */
1126};
1127
Tobin Davis8e21c342007-01-08 11:04:17 +01001128static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001129 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001131 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001132 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001133 { } /* end */
1134};
1135
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001136static struct snd_kcontrol_new stac9205_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001137 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001138
1139 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1140 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001141
1142 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1143 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001144 { } /* end */
1145};
1146
1147/* This needs to be generated dynamically based on sequence */
1148static struct snd_kcontrol_new stac922x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001151
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001154 { } /* end */
1155};
1156
1157
1158static struct snd_kcontrol_new stac927x_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001159 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001163
1164 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1165 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166
1167 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001169 { } /* end */
1170};
1171
Takashi Iwai1697055e2007-12-18 18:05:52 +01001172static struct snd_kcontrol_new stac_dmux_mixer = {
1173 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1174 .name = "Digital Input Source",
1175 /* count set later */
1176 .info = stac92xx_dmux_enum_info,
1177 .get = stac92xx_dmux_enum_get,
1178 .put = stac92xx_dmux_enum_put,
1179};
1180
Matthew Ranostayd9737752008-09-07 12:03:41 +02001181static struct snd_kcontrol_new stac_smux_mixer = {
1182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001183 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001184 /* count set later */
1185 .info = stac92xx_smux_enum_info,
1186 .get = stac92xx_smux_enum_get,
1187 .put = stac92xx_smux_enum_put,
1188};
1189
Takashi Iwai2134ea42008-01-10 16:53:55 +01001190static const char *slave_vols[] = {
1191 "Front Playback Volume",
1192 "Surround Playback Volume",
1193 "Center Playback Volume",
1194 "LFE Playback Volume",
1195 "Side Playback Volume",
1196 "Headphone Playback Volume",
1197 "Headphone Playback Volume",
1198 "Speaker Playback Volume",
1199 "External Speaker Playback Volume",
1200 "Speaker2 Playback Volume",
1201 NULL
1202};
1203
1204static const char *slave_sws[] = {
1205 "Front Playback Switch",
1206 "Surround Playback Switch",
1207 "Center Playback Switch",
1208 "LFE Playback Switch",
1209 "Side Playback Switch",
1210 "Headphone Playback Switch",
1211 "Headphone Playback Switch",
1212 "Speaker Playback Switch",
1213 "External Speaker Playback Switch",
1214 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001215 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001216 NULL
1217};
1218
Takashi Iwai603c4012008-07-30 15:01:44 +02001219static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001220static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001221
Matt2f2f4252005-04-13 14:45:30 +02001222static int stac92xx_build_controls(struct hda_codec *codec)
1223{
1224 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001225 struct auto_pin_cfg *cfg = &spec->autocfg;
1226 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001227 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001228 int i;
Matt2f2f4252005-04-13 14:45:30 +02001229
1230 err = snd_hda_add_new_ctls(codec, spec->mixer);
1231 if (err < 0)
1232 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001233
1234 for (i = 0; i < spec->num_mixers; i++) {
1235 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1236 if (err < 0)
1237 return err;
1238 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001239 if (spec->num_dmuxes > 0) {
1240 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001241 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001242 snd_ctl_new1(&stac_dmux_mixer, codec));
1243 if (err < 0)
1244 return err;
1245 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001246 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001247 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1248 struct hda_input_mux *smux = &spec->private_smux;
1249 /* check for mute support on SPDIF out */
1250 if (wcaps & AC_WCAP_OUT_AMP) {
1251 smux->items[smux->num_items].label = "Off";
1252 smux->items[smux->num_items].index = 0;
1253 smux->num_items++;
1254 spec->spdif_mute = 1;
1255 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001256 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001257 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001258 snd_ctl_new1(&stac_smux_mixer, codec));
1259 if (err < 0)
1260 return err;
1261 }
Mattc7d4b2f2005-06-27 14:59:41 +02001262
Mattdabbed62005-06-14 10:19:34 +02001263 if (spec->multiout.dig_out_nid) {
1264 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1265 if (err < 0)
1266 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001267 err = snd_hda_create_spdif_share_sw(codec,
1268 &spec->multiout);
1269 if (err < 0)
1270 return err;
1271 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001272 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001273 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001274 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1275 if (err < 0)
1276 return err;
1277 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001278
1279 /* if we have no master control, let's create it */
1280 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001281 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001282 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001283 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001284 /* correct volume offset */
1285 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001286 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001287 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001288 if (err < 0)
1289 return err;
1290 }
1291 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1292 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1293 NULL, slave_sws);
1294 if (err < 0)
1295 return err;
1296 }
1297
Takashi Iwai603c4012008-07-30 15:01:44 +02001298 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001299
1300 /* create jack input elements */
1301 if (spec->hp_detect) {
1302 for (i = 0; i < cfg->hp_outs; i++) {
1303 int type = SND_JACK_HEADPHONE;
1304 nid = cfg->hp_pins[i];
1305 /* jack detection */
1306 if (cfg->hp_outs == i)
1307 type |= SND_JACK_LINEOUT;
1308 err = stac92xx_add_jack(codec, nid, type);
1309 if (err < 0)
1310 return err;
1311 }
1312 }
1313 for (i = 0; i < cfg->line_outs; i++) {
1314 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1315 SND_JACK_LINEOUT);
1316 if (err < 0)
1317 return err;
1318 }
1319 for (i = 0; i < AUTO_PIN_LAST; i++) {
1320 nid = cfg->input_pins[i];
1321 if (nid) {
1322 err = stac92xx_add_jack(codec, nid,
1323 SND_JACK_MICROPHONE);
1324 if (err < 0)
1325 return err;
1326 }
1327 }
1328
Mattdabbed62005-06-14 10:19:34 +02001329 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001330}
1331
Matt Porter403d1942005-11-29 15:00:51 +01001332static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001333 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001334 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1335};
1336
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001337static unsigned int gateway9200_m4_pin_configs[8] = {
1338 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1339 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1340};
1341static unsigned int gateway9200_m4_2_pin_configs[8] = {
1342 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1343 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1344};
1345
1346/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001347 STAC 9200 pin configs for
1348 102801A8
1349 102801DE
1350 102801E8
1351*/
1352static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001353 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1354 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001355};
1356
1357/*
1358 STAC 9200 pin configs for
1359 102801C0
1360 102801C1
1361*/
1362static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001363 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1364 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001365};
1366
1367/*
1368 STAC 9200 pin configs for
1369 102801C4 (Dell Dimension E310)
1370 102801C5
1371 102801C7
1372 102801D9
1373 102801DA
1374 102801E3
1375*/
1376static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001377 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1378 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001379};
1380
1381
1382/*
1383 STAC 9200-32 pin configs for
1384 102801B5 (Dell Inspiron 630m)
1385 102801D8 (Dell Inspiron 640m)
1386*/
1387static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001388 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1389 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390};
1391
1392/*
1393 STAC 9200-32 pin configs for
1394 102801C2 (Dell Latitude D620)
1395 102801C8
1396 102801CC (Dell Latitude D820)
1397 102801D4
1398 102801D6
1399*/
1400static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001401 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1402 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001403};
1404
1405/*
1406 STAC 9200-32 pin configs for
1407 102801CE (Dell XPS M1710)
1408 102801CF (Dell Precision M90)
1409*/
1410static unsigned int dell9200_m23_pin_configs[8] = {
1411 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1412 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1413};
1414
1415/*
1416 STAC 9200-32 pin configs for
1417 102801C9
1418 102801CA
1419 102801CB (Dell Latitude 120L)
1420 102801D3
1421*/
1422static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001423 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1424 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001425};
1426
1427/*
1428 STAC 9200-32 pin configs for
1429 102801BD (Dell Inspiron E1505n)
1430 102801EE
1431 102801EF
1432*/
1433static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001434 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1435 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001436};
1437
1438/*
1439 STAC 9200-32 pin configs for
1440 102801F5 (Dell Inspiron 1501)
1441 102801F6
1442*/
1443static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001444 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1445 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001446};
1447
1448/*
1449 STAC 9200-32
1450 102801CD (Dell Inspiron E1705/9400)
1451*/
1452static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001453 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1454 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001455};
1456
Tobin Davisbf277782008-02-03 20:31:47 +01001457static unsigned int oqo9200_pin_configs[8] = {
1458 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1459 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1460};
1461
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001462
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001463static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1464 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001465 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001466 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1467 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1468 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1469 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1470 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1471 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1472 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1473 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1474 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1475 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001476 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1477 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001478 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001479};
1480
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001481static const char *stac9200_models[STAC_9200_MODELS] = {
1482 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001483 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001484 [STAC_9200_DELL_D21] = "dell-d21",
1485 [STAC_9200_DELL_D22] = "dell-d22",
1486 [STAC_9200_DELL_D23] = "dell-d23",
1487 [STAC_9200_DELL_M21] = "dell-m21",
1488 [STAC_9200_DELL_M22] = "dell-m22",
1489 [STAC_9200_DELL_M23] = "dell-m23",
1490 [STAC_9200_DELL_M24] = "dell-m24",
1491 [STAC_9200_DELL_M25] = "dell-m25",
1492 [STAC_9200_DELL_M26] = "dell-m26",
1493 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001494 [STAC_9200_M4] = "gateway-m4",
1495 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001496 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001497};
1498
1499static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1500 /* SigmaTel reference board */
1501 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1502 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001503 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1504 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001505 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1507 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001509 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1511 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1513 "unknown Dell", STAC_9200_DELL_D22),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1515 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001517 "Dell Latitude D620", STAC_9200_DELL_M22),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1519 "unknown Dell", STAC_9200_DELL_D23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1521 "unknown Dell", STAC_9200_DELL_D23),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1523 "unknown Dell", STAC_9200_DELL_M22),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1525 "unknown Dell", STAC_9200_DELL_M24),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1527 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001529 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001531 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001533 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001535 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001537 "Dell Precision M90", STAC_9200_DELL_M23),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1539 "unknown Dell", STAC_9200_DELL_M22),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1541 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001543 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001545 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1547 "unknown Dell", STAC_9200_DELL_D23),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1549 "unknown Dell", STAC_9200_DELL_D23),
1550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1551 "unknown Dell", STAC_9200_DELL_D21),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1553 "unknown Dell", STAC_9200_DELL_D23),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1555 "unknown Dell", STAC_9200_DELL_D21),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1557 "unknown Dell", STAC_9200_DELL_M25),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1559 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001561 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1563 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001564 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001565 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001566 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001567 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1568 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1569 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001570 /* OQO Mobile */
1571 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001572 {} /* terminator */
1573};
1574
Tobin Davis8e21c342007-01-08 11:04:17 +01001575static unsigned int ref925x_pin_configs[8] = {
1576 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001577 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001578};
1579
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001580static unsigned int stac925xM1_pin_configs[8] = {
1581 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1582 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001583};
1584
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001585static unsigned int stac925xM1_2_pin_configs[8] = {
1586 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1587 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1588};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001589
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001590static unsigned int stac925xM2_pin_configs[8] = {
1591 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1592 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001593};
1594
Tobin Davis8e21c342007-01-08 11:04:17 +01001595static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001596 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1597 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1598};
1599
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001600static unsigned int stac925xM3_pin_configs[8] = {
1601 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1602 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1603};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001604
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001605static unsigned int stac925xM5_pin_configs[8] = {
1606 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1607 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1608};
1609
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001610static unsigned int stac925xM6_pin_configs[8] = {
1611 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1612 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001613};
1614
1615static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1616 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001617 [STAC_M1] = stac925xM1_pin_configs,
1618 [STAC_M1_2] = stac925xM1_2_pin_configs,
1619 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001620 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001621 [STAC_M3] = stac925xM3_pin_configs,
1622 [STAC_M5] = stac925xM5_pin_configs,
1623 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001624};
1625
1626static const char *stac925x_models[STAC_925x_MODELS] = {
1627 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001628 [STAC_M1] = "m1",
1629 [STAC_M1_2] = "m1-2",
1630 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001631 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001632 [STAC_M3] = "m3",
1633 [STAC_M5] = "m5",
1634 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001635};
1636
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001637static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001638 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1639 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1640 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1641 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001642 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001643 /* Not sure about the brand name for those */
1644 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1645 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1646 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1647 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001648 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001649};
1650
1651static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1652 /* SigmaTel reference board */
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001654 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001655 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001656
1657 /* Default table for unknown ID */
1658 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1659
Tobin Davis8e21c342007-01-08 11:04:17 +01001660 {} /* terminator */
1661};
1662
Matthew Ranostaya7662642008-02-21 07:51:14 +01001663static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001664 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1665 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1666 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001667 0x01452050,
1668};
1669
1670static unsigned int dell_m6_pin_configs[13] = {
1671 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001672 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001673 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1674 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001675};
1676
1677static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001678 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001679 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1680 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1681 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001682 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001683};
1684
1685static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001686 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001687 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001688 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1689 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1690 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001691 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001692};
1693
1694static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1695 /* SigmaTel reference board */
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001697 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001698 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1699 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001701 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001703 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001705 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001707 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001709 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001711 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001713 "unknown Dell", STAC_DELL_M6_DMIC),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1715 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001717 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1719 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001720 {} /* terminator */
1721};
1722
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001723static unsigned int ref92hd83xxx_pin_configs[14] = {
1724 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1725 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1726 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1727 0x01451160, 0x98560170,
1728};
1729
1730static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1731 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001732 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001733};
1734
1735static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1736 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001737 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001738};
1739
1740static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1741 /* SigmaTel reference board */
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001743 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001744 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1745 "DFI LanParty", STAC_92HD83XXX_REF),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001746 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001747};
1748
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001749static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001750 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001751 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001752 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001753};
1754
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001755static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001756 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001757 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001758 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001759};
1760
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001761static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001762 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1763 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001764 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001765};
1766
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001767static unsigned int dell_m4_3_pin_configs[11] = {
1768 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1769 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1770 0x40f000f0, 0x044413b0, 0x044413b0,
1771};
1772
Matthew Ranostaye035b842007-11-06 11:53:55 +01001773static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1774 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001775 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1776 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001777 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001778 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001779 [STAC_HP_DV5] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001780};
1781
1782static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1783 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001784 [STAC_DELL_M4_1] = "dell-m4-1",
1785 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001786 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001787 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001788 [STAC_HP_DV5] = "hp-dv5",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001789};
1790
1791static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1792 /* SigmaTel reference board */
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1794 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001795 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1796 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001797 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1798 "HP dv5", STAC_HP_M4),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1800 "HP dv7", STAC_HP_M4),
Takashi Iwaie0c0e942009-01-22 12:58:11 +01001801 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7,
1802 "HP dv4", STAC_HP_DV5),
Takashi Iwai69dfaef2008-12-20 16:57:50 +01001803 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1804 "HP dv7", STAC_HP_M4),
Giuseppe Bilottadafb70c2009-01-13 08:58:49 -05001805 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001806 "HP dv5", STAC_HP_DV5),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1808 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001809 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1810 "unknown Dell", STAC_DELL_M4_1),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1812 "unknown Dell", STAC_DELL_M4_1),
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1814 "unknown Dell", STAC_DELL_M4_1),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1816 "unknown Dell", STAC_DELL_M4_1),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1818 "unknown Dell", STAC_DELL_M4_1),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1820 "unknown Dell", STAC_DELL_M4_1),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1822 "unknown Dell", STAC_DELL_M4_1),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1824 "unknown Dell", STAC_DELL_M4_2),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1826 "unknown Dell", STAC_DELL_M4_2),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1828 "unknown Dell", STAC_DELL_M4_2),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1830 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1832 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001833 {} /* terminator */
1834};
1835
Matt Porter403d1942005-11-29 15:00:51 +01001836static unsigned int ref922x_pin_configs[10] = {
1837 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1838 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001839 0x40000100, 0x40000100,
1840};
1841
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001842/*
1843 STAC 922X pin configs for
1844 102801A7
1845 102801AB
1846 102801A9
1847 102801D1
1848 102801D2
1849*/
1850static unsigned int dell_922x_d81_pin_configs[10] = {
1851 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1852 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1853 0x01813122, 0x400001f2,
1854};
1855
1856/*
1857 STAC 922X pin configs for
1858 102801AC
1859 102801D0
1860*/
1861static unsigned int dell_922x_d82_pin_configs[10] = {
1862 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1863 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1864 0x01813122, 0x400001f1,
1865};
1866
1867/*
1868 STAC 922X pin configs for
1869 102801BF
1870*/
1871static unsigned int dell_922x_m81_pin_configs[10] = {
1872 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1873 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1874 0x40C003f1, 0x405003f0,
1875};
1876
1877/*
1878 STAC 9221 A1 pin configs for
1879 102801D7 (Dell XPS M1210)
1880*/
1881static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001882 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1883 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001884 0x508003f3, 0x405003f4,
1885};
1886
Matt Porter403d1942005-11-29 15:00:51 +01001887static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001888 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001889 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1890 0x02a19120, 0x40000100,
1891};
1892
1893static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001894 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1895 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001896 0x02a19320, 0x40000100,
1897};
1898
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001899static unsigned int intel_mac_v1_pin_configs[10] = {
1900 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1901 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001902 0x400000fc, 0x400000fb,
1903};
1904
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001905static unsigned int intel_mac_v2_pin_configs[10] = {
1906 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1907 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001908 0x400000fc, 0x400000fb,
1909};
1910
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001911static unsigned int intel_mac_v3_pin_configs[10] = {
1912 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1913 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1914 0x400000fc, 0x400000fb,
1915};
1916
1917static unsigned int intel_mac_v4_pin_configs[10] = {
1918 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1919 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1920 0x400000fc, 0x400000fb,
1921};
1922
1923static unsigned int intel_mac_v5_pin_configs[10] = {
1924 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1925 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1926 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001927};
1928
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001929static unsigned int ecs202_pin_configs[10] = {
1930 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1931 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1932 0x9037012e, 0x40e000f2,
1933};
Takashi Iwai76c08822007-06-19 12:17:42 +02001934
Takashi Iwai19039bd2006-06-28 15:52:16 +02001935static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001936 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001937 [STAC_D945GTP3] = d945gtp3_pin_configs,
1938 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001939 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1940 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1941 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1942 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1943 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001944 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001945 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001946 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1947 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1948 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1949 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1950 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1951 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001952 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001953 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1954 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1955 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1956 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001957};
1958
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001959static const char *stac922x_models[STAC_922X_MODELS] = {
1960 [STAC_D945_REF] = "ref",
1961 [STAC_D945GTP5] = "5stack",
1962 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001963 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1964 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1965 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1966 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1967 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001968 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001969 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001970 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001971 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001972 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1973 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001974 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001975 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001976 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001977 [STAC_922X_DELL_D81] = "dell-d81",
1978 [STAC_922X_DELL_D82] = "dell-d82",
1979 [STAC_922X_DELL_M81] = "dell-m81",
1980 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001981};
1982
1983static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1984 /* SigmaTel reference board */
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1986 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001987 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1988 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001989 /* Intel 945G based systems */
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1991 "Intel D945G", STAC_D945GTP3),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1993 "Intel D945G", STAC_D945GTP3),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1995 "Intel D945G", STAC_D945GTP3),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1997 "Intel D945G", STAC_D945GTP3),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1999 "Intel D945G", STAC_D945GTP3),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2001 "Intel D945G", STAC_D945GTP3),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2003 "Intel D945G", STAC_D945GTP3),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2019 "Intel D945G", STAC_D945GTP3),
2020 /* Intel D945G 5-stack systems */
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2022 "Intel D945G", STAC_D945GTP5),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2024 "Intel D945G", STAC_D945GTP5),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2026 "Intel D945G", STAC_D945GTP5),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2028 "Intel D945G", STAC_D945GTP5),
2029 /* Intel 945P based systems */
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2031 "Intel D945P", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2033 "Intel D945P", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2035 "Intel D945P", STAC_D945GTP3),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2037 "Intel D945P", STAC_D945GTP3),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2039 "Intel D945P", STAC_D945GTP3),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2041 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002042 /* other intel */
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2044 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002045 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002046 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002047 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002048 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002049 /* Dell systems */
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2051 "unknown Dell", STAC_922X_DELL_D81),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2053 "unknown Dell", STAC_922X_DELL_D81),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2055 "unknown Dell", STAC_922X_DELL_D81),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2057 "unknown Dell", STAC_922X_DELL_D82),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2059 "unknown Dell", STAC_922X_DELL_M81),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2061 "unknown Dell", STAC_922X_DELL_D82),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2063 "unknown Dell", STAC_922X_DELL_D81),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2065 "unknown Dell", STAC_922X_DELL_D81),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2067 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002068 /* ECS/PC Chips boards */
2069 SND_PCI_QUIRK(0x1019, 0x2144,
2070 "ECS/PC chips", STAC_ECS_202),
2071 SND_PCI_QUIRK(0x1019, 0x2608,
2072 "ECS/PC chips", STAC_ECS_202),
2073 SND_PCI_QUIRK(0x1019, 0x2633,
2074 "ECS/PC chips P17G/1333", STAC_ECS_202),
2075 SND_PCI_QUIRK(0x1019, 0x2811,
2076 "ECS/PC chips", STAC_ECS_202),
2077 SND_PCI_QUIRK(0x1019, 0x2812,
2078 "ECS/PC chips", STAC_ECS_202),
2079 SND_PCI_QUIRK(0x1019, 0x2813,
2080 "ECS/PC chips", STAC_ECS_202),
2081 SND_PCI_QUIRK(0x1019, 0x2814,
2082 "ECS/PC chips", STAC_ECS_202),
2083 SND_PCI_QUIRK(0x1019, 0x2815,
2084 "ECS/PC chips", STAC_ECS_202),
2085 SND_PCI_QUIRK(0x1019, 0x2816,
2086 "ECS/PC chips", STAC_ECS_202),
2087 SND_PCI_QUIRK(0x1019, 0x2817,
2088 "ECS/PC chips", STAC_ECS_202),
2089 SND_PCI_QUIRK(0x1019, 0x2818,
2090 "ECS/PC chips", STAC_ECS_202),
2091 SND_PCI_QUIRK(0x1019, 0x2819,
2092 "ECS/PC chips", STAC_ECS_202),
2093 SND_PCI_QUIRK(0x1019, 0x2820,
2094 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002095 {} /* terminator */
2096};
2097
Matt Porter3cc08dc2006-01-23 15:27:49 +01002098static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002099 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2100 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2101 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2102 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002103};
2104
Tobin Davis93ed1502006-09-01 21:03:12 +02002105static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002106 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2107 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2108 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2109 0x40000100, 0x40000100
2110};
2111
Tobin Davis93ed1502006-09-01 21:03:12 +02002112static unsigned int d965_5st_pin_configs[14] = {
2113 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2114 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2115 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2116 0x40000100, 0x40000100
2117};
2118
Tobin Davis4ff076e2007-08-07 11:48:12 +02002119static unsigned int dell_3st_pin_configs[14] = {
2120 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2121 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002122 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002123 0x40c003fc, 0x40000100
2124};
2125
Tobin Davis93ed1502006-09-01 21:03:12 +02002126static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002127 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002128 [STAC_D965_REF] = ref927x_pin_configs,
2129 [STAC_D965_3ST] = d965_3st_pin_configs,
2130 [STAC_D965_5ST] = d965_5st_pin_configs,
2131 [STAC_DELL_3ST] = dell_3st_pin_configs,
2132 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002133};
2134
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002135static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002136 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002137 [STAC_D965_REF] = "ref",
2138 [STAC_D965_3ST] = "3stack",
2139 [STAC_D965_5ST] = "5stack",
2140 [STAC_DELL_3ST] = "dell-3stack",
2141 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002142};
2143
2144static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2145 /* SigmaTel reference board */
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2147 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002148 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2149 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002150 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002153 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002170 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002175 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002184 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002194 {} /* terminator */
2195};
2196
Matt Porterf3302a52006-07-31 12:49:34 +02002197static unsigned int ref9205_pin_configs[12] = {
2198 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002199 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002200 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002201};
2202
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002203/*
2204 STAC 9205 pin configs for
2205 102801F1
2206 102801F2
2207 102801FC
2208 102801FD
2209 10280204
2210 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002211 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002212*/
2213static unsigned int dell_9205_m42_pin_configs[12] = {
2214 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2215 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2216 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2217};
2218
2219/*
2220 STAC 9205 pin configs for
2221 102801F9
2222 102801FA
2223 102801FE
2224 102801FF (Dell Precision M4300)
2225 10280206
2226 10280200
2227 10280201
2228*/
2229static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002230 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2231 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2232 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2233};
2234
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002235static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002236 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2237 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2238 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2239};
2240
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002241static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002242 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002243 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2244 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2245 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002246 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002247};
2248
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002249static const char *stac9205_models[STAC_9205_MODELS] = {
2250 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002251 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002252 [STAC_9205_DELL_M43] = "dell-m43",
2253 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002254 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002255};
2256
2257static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2258 /* SigmaTel reference board */
2259 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2260 "DFI LanParty", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002261 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2262 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002263 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2265 "unknown Dell", STAC_9205_DELL_M42),
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2267 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002269 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2271 "Dell Precision", STAC_9205_DELL_M43),
2272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2273 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2275 "unknown Dell", STAC_9205_DELL_M42),
2276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2277 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2279 "Dell Precision", STAC_9205_DELL_M43),
2280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002281 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2283 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2285 "Dell Precision", STAC_9205_DELL_M43),
2286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2287 "Dell Precision", STAC_9205_DELL_M43),
2288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2289 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2291 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2293 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002294 /* Gateway */
2295 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002296 {} /* terminator */
2297};
2298
Richard Fish11b44bb2006-08-23 18:31:34 +02002299static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2300{
2301 int i;
2302 struct sigmatel_spec *spec = codec->spec;
2303
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002304 kfree(spec->pin_configs);
2305 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2306 GFP_KERNEL);
2307 if (!spec->pin_configs)
2308 return -ENOMEM;
Richard Fish11b44bb2006-08-23 18:31:34 +02002309
2310 for (i = 0; i < spec->num_pins; i++) {
2311 hda_nid_t nid = spec->pin_nids[i];
2312 unsigned int pin_cfg;
2313
2314 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2315 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2316 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2317 nid, pin_cfg);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002318 spec->pin_configs[i] = pin_cfg;
Richard Fish11b44bb2006-08-23 18:31:34 +02002319 }
2320
2321 return 0;
2322}
2323
Matthew Ranostay87d48362007-07-17 11:52:24 +02002324static void stac92xx_set_config_reg(struct hda_codec *codec,
2325 hda_nid_t pin_nid, unsigned int pin_config)
2326{
2327 int i;
2328 snd_hda_codec_write(codec, pin_nid, 0,
2329 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2330 pin_config & 0x000000ff);
2331 snd_hda_codec_write(codec, pin_nid, 0,
2332 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2333 (pin_config & 0x0000ff00) >> 8);
2334 snd_hda_codec_write(codec, pin_nid, 0,
2335 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2336 (pin_config & 0x00ff0000) >> 16);
2337 snd_hda_codec_write(codec, pin_nid, 0,
2338 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2339 pin_config >> 24);
2340 i = snd_hda_codec_read(codec, pin_nid, 0,
2341 AC_VERB_GET_CONFIG_DEFAULT,
2342 0x00);
2343 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2344 pin_nid, i);
2345}
2346
Matt2f2f4252005-04-13 14:45:30 +02002347static void stac92xx_set_config_regs(struct hda_codec *codec)
2348{
2349 int i;
2350 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002351
Matthew Ranostay87d48362007-07-17 11:52:24 +02002352 if (!spec->pin_configs)
2353 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002354
Matthew Ranostay87d48362007-07-17 11:52:24 +02002355 for (i = 0; i < spec->num_pins; i++)
2356 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2357 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002358}
Matt2f2f4252005-04-13 14:45:30 +02002359
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002360static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2361{
2362 struct sigmatel_spec *spec = codec->spec;
2363
2364 if (!pins)
2365 return stac92xx_save_bios_config_regs(codec);
2366
2367 kfree(spec->pin_configs);
2368 spec->pin_configs = kmemdup(pins,
2369 spec->num_pins * sizeof(*pins),
2370 GFP_KERNEL);
2371 if (!spec->pin_configs)
2372 return -ENOMEM;
2373
2374 stac92xx_set_config_regs(codec);
2375 return 0;
2376}
2377
2378static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2379 unsigned int cfg)
2380{
2381 struct sigmatel_spec *spec = codec->spec;
2382 int i;
2383
2384 for (i = 0; i < spec->num_pins; i++) {
2385 if (spec->pin_nids[i] == nid) {
2386 spec->pin_configs[i] = cfg;
2387 stac92xx_set_config_reg(codec, nid, cfg);
2388 break;
2389 }
2390 }
2391}
2392
Matt2f2f4252005-04-13 14:45:30 +02002393/*
2394 * Analog playback callbacks
2395 */
2396static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2397 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002398 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002399{
2400 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002401 if (spec->stream_delay)
2402 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002403 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2404 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002405}
2406
2407static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2408 struct hda_codec *codec,
2409 unsigned int stream_tag,
2410 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002411 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002412{
2413 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002414 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002415}
2416
2417static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2418 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002419 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002420{
2421 struct sigmatel_spec *spec = codec->spec;
2422 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2423}
2424
2425/*
Mattdabbed62005-06-14 10:19:34 +02002426 * Digital playback callbacks
2427 */
2428static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2429 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002430 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002431{
2432 struct sigmatel_spec *spec = codec->spec;
2433 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2434}
2435
2436static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2437 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002438 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002439{
2440 struct sigmatel_spec *spec = codec->spec;
2441 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2442}
2443
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002444static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2445 struct hda_codec *codec,
2446 unsigned int stream_tag,
2447 unsigned int format,
2448 struct snd_pcm_substream *substream)
2449{
2450 struct sigmatel_spec *spec = codec->spec;
2451 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2452 stream_tag, format, substream);
2453}
2454
Mattdabbed62005-06-14 10:19:34 +02002455
2456/*
Matt2f2f4252005-04-13 14:45:30 +02002457 * Analog capture callbacks
2458 */
2459static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2460 struct hda_codec *codec,
2461 unsigned int stream_tag,
2462 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002463 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002464{
2465 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002466 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002467
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002468 if (spec->powerdown_adcs) {
2469 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002470 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002471 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2472 }
2473 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002474 return 0;
2475}
2476
2477static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2478 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002479 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002480{
2481 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002482 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002483
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002484 snd_hda_codec_cleanup_stream(codec, nid);
2485 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002486 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002487 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002488 return 0;
2489}
2490
Mattdabbed62005-06-14 10:19:34 +02002491static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2492 .substreams = 1,
2493 .channels_min = 2,
2494 .channels_max = 2,
2495 /* NID is set in stac92xx_build_pcms */
2496 .ops = {
2497 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002498 .close = stac92xx_dig_playback_pcm_close,
2499 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002500 },
2501};
2502
2503static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2504 .substreams = 1,
2505 .channels_min = 2,
2506 .channels_max = 2,
2507 /* NID is set in stac92xx_build_pcms */
2508};
2509
Matt2f2f4252005-04-13 14:45:30 +02002510static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2511 .substreams = 1,
2512 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002513 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002514 .nid = 0x02, /* NID to query formats and rates */
2515 .ops = {
2516 .open = stac92xx_playback_pcm_open,
2517 .prepare = stac92xx_playback_pcm_prepare,
2518 .cleanup = stac92xx_playback_pcm_cleanup
2519 },
2520};
2521
Matt Porter3cc08dc2006-01-23 15:27:49 +01002522static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2523 .substreams = 1,
2524 .channels_min = 2,
2525 .channels_max = 2,
2526 .nid = 0x06, /* NID to query formats and rates */
2527 .ops = {
2528 .open = stac92xx_playback_pcm_open,
2529 .prepare = stac92xx_playback_pcm_prepare,
2530 .cleanup = stac92xx_playback_pcm_cleanup
2531 },
2532};
2533
Matt2f2f4252005-04-13 14:45:30 +02002534static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002535 .channels_min = 2,
2536 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002537 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002538 .ops = {
2539 .prepare = stac92xx_capture_pcm_prepare,
2540 .cleanup = stac92xx_capture_pcm_cleanup
2541 },
2542};
2543
2544static int stac92xx_build_pcms(struct hda_codec *codec)
2545{
2546 struct sigmatel_spec *spec = codec->spec;
2547 struct hda_pcm *info = spec->pcm_rec;
2548
2549 codec->num_pcms = 1;
2550 codec->pcm_info = info;
2551
Mattc7d4b2f2005-06-27 14:59:41 +02002552 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002553 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002554 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2555 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002556 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002557 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002558 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002559
2560 if (spec->alt_switch) {
2561 codec->num_pcms++;
2562 info++;
2563 info->name = "STAC92xx Analog Alt";
2564 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2565 }
Matt2f2f4252005-04-13 14:45:30 +02002566
Mattdabbed62005-06-14 10:19:34 +02002567 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2568 codec->num_pcms++;
2569 info++;
2570 info->name = "STAC92xx Digital";
Takashi Iwai8c441982009-01-20 18:30:20 +01002571 info->pcm_type = spec->autocfg.dig_out_type;
Mattdabbed62005-06-14 10:19:34 +02002572 if (spec->multiout.dig_out_nid) {
2573 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2574 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2575 }
2576 if (spec->dig_in_nid) {
2577 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2578 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2579 }
2580 }
2581
Matt2f2f4252005-04-13 14:45:30 +02002582 return 0;
2583}
2584
Takashi Iwaic960a032006-03-23 17:06:28 +01002585static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2586{
2587 unsigned int pincap = snd_hda_param_read(codec, nid,
2588 AC_PAR_PIN_CAP);
2589 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2590 if (pincap & AC_PINCAP_VREF_100)
2591 return AC_PINCTL_VREF_100;
2592 if (pincap & AC_PINCAP_VREF_80)
2593 return AC_PINCTL_VREF_80;
2594 if (pincap & AC_PINCAP_VREF_50)
2595 return AC_PINCTL_VREF_50;
2596 if (pincap & AC_PINCAP_VREF_GRD)
2597 return AC_PINCTL_VREF_GRD;
2598 return 0;
2599}
2600
Matt Porter403d1942005-11-29 15:00:51 +01002601static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2602
2603{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002604 snd_hda_codec_write_cache(codec, nid, 0,
2605 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002606}
2607
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002608#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2609
2610static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2611 struct snd_ctl_elem_value *ucontrol)
2612{
2613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2614 struct sigmatel_spec *spec = codec->spec;
2615
Takashi Iwaid7a89432008-11-12 09:48:04 +01002616 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002617 return 0;
2618}
2619
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002620static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2621 unsigned char type);
2622
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002623static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2624 struct snd_ctl_elem_value *ucontrol)
2625{
2626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2627 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002628 int nid = kcontrol->private_value;
2629
2630 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002631
2632 /* check to be sure that the ports are upto date with
2633 * switch changes
2634 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002635 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002636
2637 return 1;
2638}
2639
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002640#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002641
2642static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2643{
2644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2645 struct sigmatel_spec *spec = codec->spec;
2646 int io_idx = kcontrol-> private_value & 0xff;
2647
2648 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2649 return 0;
2650}
2651
2652static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2653{
2654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2655 struct sigmatel_spec *spec = codec->spec;
2656 hda_nid_t nid = kcontrol->private_value >> 8;
2657 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002658 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002659
2660 spec->io_switch[io_idx] = val;
2661
2662 if (val)
2663 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002664 else {
2665 unsigned int pinctl = AC_PINCTL_IN_EN;
2666 if (io_idx) /* set VREF for mic */
2667 pinctl |= stac92xx_get_vref(codec, nid);
2668 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2669 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002670
2671 /* check the auto-mute again: we need to mute/unmute the speaker
2672 * appropriately according to the pin direction
2673 */
2674 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002675 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002676
Matt Porter403d1942005-11-29 15:00:51 +01002677 return 1;
2678}
2679
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002680#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2681
2682static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2683 struct snd_ctl_elem_value *ucontrol)
2684{
2685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2686 struct sigmatel_spec *spec = codec->spec;
2687
2688 ucontrol->value.integer.value[0] = spec->clfe_swap;
2689 return 0;
2690}
2691
2692static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2693 struct snd_ctl_elem_value *ucontrol)
2694{
2695 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2696 struct sigmatel_spec *spec = codec->spec;
2697 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002698 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002699
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002700 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002701 return 0;
2702
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002703 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002704
2705 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2706 spec->clfe_swap ? 0x4 : 0x0);
2707
2708 return 1;
2709}
2710
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002711#define STAC_CODEC_HP_SWITCH(xname) \
2712 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2713 .name = xname, \
2714 .index = 0, \
2715 .info = stac92xx_hp_switch_info, \
2716 .get = stac92xx_hp_switch_get, \
2717 .put = stac92xx_hp_switch_put, \
2718 }
2719
Matt Porter403d1942005-11-29 15:00:51 +01002720#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2721 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2722 .name = xname, \
2723 .index = 0, \
2724 .info = stac92xx_io_switch_info, \
2725 .get = stac92xx_io_switch_get, \
2726 .put = stac92xx_io_switch_put, \
2727 .private_value = xpval, \
2728 }
2729
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002730#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2731 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2732 .name = xname, \
2733 .index = 0, \
2734 .info = stac92xx_clfe_switch_info, \
2735 .get = stac92xx_clfe_switch_get, \
2736 .put = stac92xx_clfe_switch_put, \
2737 .private_value = xpval, \
2738 }
Matt Porter403d1942005-11-29 15:00:51 +01002739
Mattc7d4b2f2005-06-27 14:59:41 +02002740enum {
2741 STAC_CTL_WIDGET_VOL,
2742 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002743 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002744 STAC_CTL_WIDGET_AMP_MUX,
2745 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002746 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002747 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002748 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002749};
2750
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002751static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002752 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2753 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002754 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002755 STAC_AMP_MUX,
2756 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002757 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002758 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002759 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002760};
2761
2762/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002763static struct snd_kcontrol_new *
2764stac_control_new(struct sigmatel_spec *spec,
2765 struct snd_kcontrol_new *ktemp,
2766 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002767{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002768 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002769
Takashi Iwai603c4012008-07-30 15:01:44 +02002770 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2771 knew = snd_array_new(&spec->kctls);
2772 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002773 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002774 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002775 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002776 if (!knew->name) {
2777 /* roolback */
2778 memset(knew, 0, sizeof(*knew));
2779 spec->kctls.alloced--;
2780 return NULL;
2781 }
2782 return knew;
2783}
2784
2785static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2786 struct snd_kcontrol_new *ktemp,
2787 int idx, const char *name,
2788 unsigned long val)
2789{
2790 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2791 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002792 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002793 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002794 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002795 return 0;
2796}
2797
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002798static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2799 int type, int idx, const char *name,
2800 unsigned long val)
2801{
2802 return stac92xx_add_control_temp(spec,
2803 &stac92xx_control_templates[type],
2804 idx, name, val);
2805}
2806
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002807
2808/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002809static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2810 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002811{
2812 return stac92xx_add_control_idx(spec, type, 0, name, val);
2813}
2814
Takashi Iwaie3c75962009-01-23 11:57:22 +01002815static struct snd_kcontrol_new stac_input_src_temp = {
2816 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2817 .name = "Input Source",
2818 .info = stac92xx_mux_enum_info,
2819 .get = stac92xx_mux_enum_get,
2820 .put = stac92xx_mux_enum_put,
2821};
2822
2823static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2824{
2825 struct snd_kcontrol_new *knew;
2826 struct hda_input_mux *imux = &spec->private_imux;
2827
2828 if (!spec->num_adcs || imux->num_items <= 1)
2829 return 0; /* no need for input source control */
2830 knew = stac_control_new(spec, &stac_input_src_temp,
2831 stac_input_src_temp.name);
2832 if (!knew)
2833 return -ENOMEM;
2834 knew->count = spec->num_adcs;
2835 return 0;
2836}
2837
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002838/* check whether the line-input can be used as line-out */
2839static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002840{
2841 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002842 struct auto_pin_cfg *cfg = &spec->autocfg;
2843 hda_nid_t nid;
2844 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002845
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002846 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2847 return 0;
2848 nid = cfg->input_pins[AUTO_PIN_LINE];
2849 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2850 if (pincap & AC_PINCAP_OUT)
2851 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002852 return 0;
2853}
2854
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002855/* check whether the mic-input can be used as line-out */
2856static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2857{
2858 struct sigmatel_spec *spec = codec->spec;
2859 struct auto_pin_cfg *cfg = &spec->autocfg;
2860 unsigned int def_conf, pincap;
2861 unsigned int mic_pin;
2862
2863 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2864 return 0;
2865 mic_pin = AUTO_PIN_MIC;
2866 for (;;) {
2867 hda_nid_t nid = cfg->input_pins[mic_pin];
2868 def_conf = snd_hda_codec_read(codec, nid, 0,
2869 AC_VERB_GET_CONFIG_DEFAULT, 0);
2870 /* some laptops have an internal analog microphone
2871 * which can't be used as a output */
2872 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2873 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2874 if (pincap & AC_PINCAP_OUT)
2875 return nid;
2876 }
2877 if (mic_pin == AUTO_PIN_MIC)
2878 mic_pin = AUTO_PIN_FRONT_MIC;
2879 else
2880 break;
2881 }
2882 return 0;
2883}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002884
2885static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2886{
2887 int i;
2888
2889 for (i = 0; i < spec->multiout.num_dacs; i++) {
2890 if (spec->multiout.dac_nids[i] == nid)
2891 return 1;
2892 }
2893
2894 return 0;
2895}
2896
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002897static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2898{
2899 int i;
2900 if (is_in_dac_nids(spec, nid))
2901 return 1;
2902 for (i = 0; i < spec->autocfg.hp_outs; i++)
2903 if (spec->hp_dacs[i] == nid)
2904 return 1;
2905 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2906 if (spec->speaker_dacs[i] == nid)
2907 return 1;
2908 return 0;
2909}
2910
2911static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2912{
2913 struct sigmatel_spec *spec = codec->spec;
2914 int j, conn_len;
2915 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2916 unsigned int wcaps, wtype;
2917
2918 conn_len = snd_hda_get_connections(codec, nid, conn,
2919 HDA_MAX_CONNECTIONS);
2920 for (j = 0; j < conn_len; j++) {
2921 wcaps = snd_hda_param_read(codec, conn[j],
2922 AC_PAR_AUDIO_WIDGET_CAP);
2923 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2924 /* we check only analog outputs */
2925 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2926 continue;
2927 /* if this route has a free DAC, assign it */
2928 if (!check_all_dac_nids(spec, conn[j])) {
2929 if (conn_len > 1) {
2930 /* select this DAC in the pin's input mux */
2931 snd_hda_codec_write_cache(codec, nid, 0,
2932 AC_VERB_SET_CONNECT_SEL, j);
2933 }
2934 return conn[j];
2935 }
2936 }
2937 return 0;
2938}
2939
2940static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2941static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2942
Matt Porter3cc08dc2006-01-23 15:27:49 +01002943/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002944 * Fill in the dac_nids table from the parsed pin configuration
2945 * This function only works when every pin in line_out_pins[]
2946 * contains atleast one DAC in its connection list. Some 92xx
2947 * codecs are not connected directly to a DAC, such as the 9200
2948 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002949 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002950static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002951{
2952 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002953 struct auto_pin_cfg *cfg = &spec->autocfg;
2954 int i;
2955 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002956
Mattc7d4b2f2005-06-27 14:59:41 +02002957 for (i = 0; i < cfg->line_outs; i++) {
2958 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002959 dac = get_unassigned_dac(codec, nid);
2960 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002961 if (spec->multiout.num_dacs > 0) {
2962 /* we have already working output pins,
2963 * so let's drop the broken ones again
2964 */
2965 cfg->line_outs = spec->multiout.num_dacs;
2966 break;
2967 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002968 /* error out, no available DAC found */
2969 snd_printk(KERN_ERR
2970 "%s: No available DAC for pin 0x%x\n",
2971 __func__, nid);
2972 return -ENODEV;
2973 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002974 add_spec_dacs(spec, dac);
2975 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002976
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002977 /* add line-in as output */
2978 nid = check_line_out_switch(codec);
2979 if (nid) {
2980 dac = get_unassigned_dac(codec, nid);
2981 if (dac) {
2982 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2983 nid, cfg->line_outs);
2984 cfg->line_out_pins[cfg->line_outs] = nid;
2985 cfg->line_outs++;
2986 spec->line_switch = nid;
2987 add_spec_dacs(spec, dac);
2988 }
2989 }
2990 /* add mic as output */
2991 nid = check_mic_out_switch(codec);
2992 if (nid) {
2993 dac = get_unassigned_dac(codec, nid);
2994 if (dac) {
2995 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2996 nid, cfg->line_outs);
2997 cfg->line_out_pins[cfg->line_outs] = nid;
2998 cfg->line_outs++;
2999 spec->mic_switch = nid;
3000 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003001 }
Mattc7d4b2f2005-06-27 14:59:41 +02003002 }
3003
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003004 for (i = 0; i < cfg->hp_outs; i++) {
3005 nid = cfg->hp_pins[i];
3006 dac = get_unassigned_dac(codec, nid);
3007 if (dac) {
3008 if (!spec->multiout.hp_nid)
3009 spec->multiout.hp_nid = dac;
3010 else
3011 add_spec_extra_dacs(spec, dac);
3012 }
3013 spec->hp_dacs[i] = dac;
3014 }
3015
3016 for (i = 0; i < cfg->speaker_outs; i++) {
3017 nid = cfg->speaker_pins[i];
3018 dac = get_unassigned_dac(codec, nid);
3019 if (dac)
3020 add_spec_extra_dacs(spec, dac);
3021 spec->speaker_dacs[i] = dac;
3022 }
3023
3024 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003025 spec->multiout.num_dacs,
3026 spec->multiout.dac_nids[0],
3027 spec->multiout.dac_nids[1],
3028 spec->multiout.dac_nids[2],
3029 spec->multiout.dac_nids[3],
3030 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003031
Mattc7d4b2f2005-06-27 14:59:41 +02003032 return 0;
3033}
3034
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003035/* create volume control/switch for the given prefx type */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003036static int create_controls(struct hda_codec *codec, const char *pfx,
3037 hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003038{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003039 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003040 char name[32];
3041 int err;
3042
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003043 if (!spec->check_volume_offset) {
3044 unsigned int caps, step, nums, db_scale;
3045 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3046 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3047 AC_AMPCAP_STEP_SIZE_SHIFT;
3048 step = (step + 1) * 25; /* in .01dB unit */
3049 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3050 AC_AMPCAP_NUM_STEPS_SHIFT;
3051 db_scale = nums * step;
3052 /* if dB scale is over -64dB, and finer enough,
3053 * let's reduce it to half
3054 */
3055 if (db_scale > 6400 && nums >= 0x1f)
3056 spec->volume_offset = nums / 2;
3057 spec->check_volume_offset = 1;
3058 }
3059
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003060 sprintf(name, "%s Playback Volume", pfx);
3061 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003062 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3063 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003064 if (err < 0)
3065 return err;
3066 sprintf(name, "%s Playback Switch", pfx);
3067 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
3068 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3069 if (err < 0)
3070 return err;
3071 return 0;
3072}
3073
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003074static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3075{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003076 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003077 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3078 return 1;
3079 } else {
3080 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3081 spec->multiout.num_dacs++;
3082 }
3083 return 0;
3084}
3085
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003086static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003087{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003088 int i;
3089 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3090 if (!spec->multiout.extra_out_nid[i]) {
3091 spec->multiout.extra_out_nid[i] = nid;
3092 return 0;
3093 }
3094 }
3095 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3096 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003097}
3098
Takashi Iwai76624532008-12-19 10:09:47 +01003099static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3100{
3101 int i;
3102
3103 if (spec->autocfg.line_outs != 1)
3104 return 0;
3105 if (spec->multiout.hp_nid == nid)
3106 return 0;
3107 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3108 if (spec->multiout.extra_out_nid[i] == nid)
3109 return 0;
3110 return 1;
3111}
3112
Mattc7d4b2f2005-06-27 14:59:41 +02003113/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003114static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02003115 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003116{
Takashi Iwai76624532008-12-19 10:09:47 +01003117 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003118 static const char *chname[4] = {
3119 "Front", "Surround", NULL /*CLFE*/, "Side"
3120 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04003121 hda_nid_t nid = 0;
Takashi Iwai91589232008-12-19 15:59:40 +01003122 int i, err;
3123 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003124
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003125 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
Mattc7d4b2f2005-06-27 14:59:41 +02003126 nid = spec->multiout.dac_nids[i];
Mattc7d4b2f2005-06-27 14:59:41 +02003127 if (i == 2) {
3128 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003129 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003130 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003131 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003132 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003133 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003134 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003135
3136 wid_caps = get_wcaps(codec, nid);
3137
3138 if (wid_caps & AC_WCAP_LR_SWAP) {
3139 err = stac92xx_add_control(spec,
3140 STAC_CTL_WIDGET_CLFE_SWITCH,
3141 "Swap Center/LFE Playback Switch", nid);
3142
3143 if (err < 0)
3144 return err;
3145 }
3146
Mattc7d4b2f2005-06-27 14:59:41 +02003147 } else {
Takashi Iwai76624532008-12-19 10:09:47 +01003148 const char *name = chname[i];
3149 /* if it's a single DAC, assign a better name */
3150 if (!i && is_unique_dac(spec, nid)) {
3151 switch (cfg->line_out_type) {
3152 case AUTO_PIN_HP_OUT:
3153 name = "Headphone";
3154 break;
3155 case AUTO_PIN_SPEAKER_OUT:
3156 name = "Speaker";
3157 break;
3158 }
3159 }
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003160 err = create_controls(codec, name, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003161 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003162 return err;
3163 }
3164 }
3165
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003166 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003167 err = stac92xx_add_control(spec,
3168 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003169 "Headphone as Line Out Switch",
3170 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003171 if (err < 0)
3172 return err;
3173 }
3174
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003175 if (spec->line_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003176 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3177 "Line In as Output Switch",
3178 spec->line_switch << 8);
3179 if (err < 0)
3180 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003181 }
Matt Porter403d1942005-11-29 15:00:51 +01003182
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003183 if (spec->mic_switch) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003184 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3185 "Mic as Output Switch",
3186 (spec->mic_switch << 8) | 1);
3187 if (err < 0)
3188 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003189 }
Matt Porter403d1942005-11-29 15:00:51 +01003190
Mattc7d4b2f2005-06-27 14:59:41 +02003191 return 0;
3192}
3193
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003194/* add playback controls for Speaker and HP outputs */
3195static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3196 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003197{
3198 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003199 hda_nid_t nid;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003200 int i, err, nums;
Mattc7d4b2f2005-06-27 14:59:41 +02003201
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003202 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003203 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003204 static const char *pfxs[] = {
3205 "Headphone", "Headphone2", "Headphone3",
3206 };
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003207 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3208 if (wid_caps & AC_WCAP_UNSOL_CAP)
3209 spec->hp_detect = 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003210 if (nums >= ARRAY_SIZE(pfxs))
Mattc7d4b2f2005-06-27 14:59:41 +02003211 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003212 nid = spec->hp_dacs[i];
3213 if (!nid)
3214 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003215 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003216 if (err < 0)
3217 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003218 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003219 nums = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003220 for (i = 0; i < cfg->speaker_outs; i++) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003221 static const char *pfxs[] = {
3222 "Speaker", "External Speaker", "Speaker2",
3223 };
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003224 if (nums >= ARRAY_SIZE(pfxs))
3225 continue;
3226 nid = spec->speaker_dacs[i];
3227 if (!nid)
3228 continue;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003229 err = create_controls(codec, pfxs[nums++], nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003230 if (err < 0)
3231 return err;
3232 }
Mattc7d4b2f2005-06-27 14:59:41 +02003233 return 0;
3234}
3235
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003236/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003237static const char *stac92xx_mono_labels[4] = {
3238 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003239};
3240
3241/* create mono mux for mono out on capable codecs */
3242static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3243{
3244 struct sigmatel_spec *spec = codec->spec;
3245 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3246 int i, num_cons;
3247 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3248
3249 num_cons = snd_hda_get_connections(codec,
3250 spec->mono_nid,
3251 con_lst,
3252 HDA_MAX_NUM_INPUTS);
3253 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3254 return -EINVAL;
3255
3256 for (i = 0; i < num_cons; i++) {
3257 mono_mux->items[mono_mux->num_items].label =
3258 stac92xx_mono_labels[i];
3259 mono_mux->items[mono_mux->num_items].index = i;
3260 mono_mux->num_items++;
3261 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003262
3263 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3264 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003265}
3266
Matthew Ranostay89385032008-09-11 09:49:39 -04003267/* labels for amp mux outputs */
3268static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003269 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003270};
3271
3272/* create amp out controls mux on capable codecs */
3273static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3274{
3275 struct sigmatel_spec *spec = codec->spec;
3276 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3277 int i, err;
3278
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003279 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003280 amp_mux->items[amp_mux->num_items].label =
3281 stac92xx_amp_labels[i];
3282 amp_mux->items[amp_mux->num_items].index = i;
3283 amp_mux->num_items++;
3284 }
3285
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003286 if (spec->num_amps > 1) {
3287 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3288 "Amp Selector Capture Switch", 0);
3289 if (err < 0)
3290 return err;
3291 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003292 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3293 "Amp Capture Volume",
3294 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3295}
3296
3297
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003298/* create PC beep volume controls */
3299static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3300 hda_nid_t nid)
3301{
3302 struct sigmatel_spec *spec = codec->spec;
3303 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3304 int err;
3305
3306 /* check for mute support for the the amp */
3307 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3308 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3309 "PC Beep Playback Switch",
3310 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3311 if (err < 0)
3312 return err;
3313 }
3314
3315 /* check to see if there is volume support for the amp */
3316 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3317 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3318 "PC Beep Playback Volume",
3319 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3320 if (err < 0)
3321 return err;
3322 }
3323 return 0;
3324}
3325
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003326#ifdef CONFIG_SND_HDA_INPUT_BEEP
3327#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3328
3329static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3330 struct snd_ctl_elem_value *ucontrol)
3331{
3332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3333 ucontrol->value.integer.value[0] = codec->beep->enabled;
3334 return 0;
3335}
3336
3337static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3338 struct snd_ctl_elem_value *ucontrol)
3339{
3340 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3341 int enabled = !!ucontrol->value.integer.value[0];
3342 if (codec->beep->enabled != enabled) {
3343 codec->beep->enabled = enabled;
3344 return 1;
3345 }
3346 return 0;
3347}
3348
3349static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3351 .info = stac92xx_dig_beep_switch_info,
3352 .get = stac92xx_dig_beep_switch_get,
3353 .put = stac92xx_dig_beep_switch_put,
3354};
3355
3356static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3357{
3358 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3359 0, "PC Beep Playback Switch", 0);
3360}
3361#endif
3362
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003363static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3364{
3365 struct sigmatel_spec *spec = codec->spec;
3366 int wcaps, nid, i, err = 0;
3367
3368 for (i = 0; i < spec->num_muxes; i++) {
3369 nid = spec->mux_nids[i];
3370 wcaps = get_wcaps(codec, nid);
3371
3372 if (wcaps & AC_WCAP_OUT_AMP) {
3373 err = stac92xx_add_control_idx(spec,
3374 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3375 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3376 if (err < 0)
3377 return err;
3378 }
3379 }
3380 return 0;
3381};
3382
Matthew Ranostayd9737752008-09-07 12:03:41 +02003383static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003384 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003385};
3386
3387static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3388{
3389 struct sigmatel_spec *spec = codec->spec;
3390 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003391 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003392 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003393 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003394
3395 num_cons = snd_hda_get_connections(codec,
3396 spec->smux_nids[0],
3397 con_lst,
3398 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003399 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003400 return -EINVAL;
3401
Matthew Ranostay65973632008-09-16 10:39:37 -04003402 if (!labels)
3403 labels = stac92xx_spdif_labels;
3404
Matthew Ranostayd9737752008-09-07 12:03:41 +02003405 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003406 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003407 spdif_mux->items[spdif_mux->num_items].index = i;
3408 spdif_mux->num_items++;
3409 }
3410
3411 return 0;
3412}
3413
Matt Porter8b657272006-10-26 17:12:59 +02003414/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003415static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003416 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3417 "Digital Mic 3", "Digital Mic 4"
3418};
3419
3420/* create playback/capture controls for input pins on dmic capable codecs */
3421static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3422 const struct auto_pin_cfg *cfg)
3423{
3424 struct sigmatel_spec *spec = codec->spec;
3425 struct hda_input_mux *dimux = &spec->private_dimux;
3426 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003427 int err, i, j;
3428 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003429
3430 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3431 dimux->items[dimux->num_items].index = 0;
3432 dimux->num_items++;
3433
3434 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003435 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003436 int index;
3437 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003438 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003439 unsigned int def_conf;
3440
3441 def_conf = snd_hda_codec_read(codec,
3442 spec->dmic_nids[i],
3443 0,
3444 AC_VERB_GET_CONFIG_DEFAULT,
3445 0);
3446 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3447 continue;
3448
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003449 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003450 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003451 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003452 con_lst,
3453 HDA_MAX_NUM_INPUTS);
3454 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003455 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003456 index = j;
3457 goto found;
3458 }
3459 continue;
3460found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003461 wcaps = get_wcaps(codec, nid) &
3462 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003463
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003464 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003465 sprintf(name, "%s Capture Volume",
3466 stac92xx_dmic_labels[dimux->num_items]);
3467
3468 err = stac92xx_add_control(spec,
3469 STAC_CTL_WIDGET_VOL,
3470 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003471 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3472 (wcaps & AC_WCAP_OUT_AMP) ?
3473 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003474 if (err < 0)
3475 return err;
3476 }
3477
Matt Porter8b657272006-10-26 17:12:59 +02003478 dimux->items[dimux->num_items].label =
3479 stac92xx_dmic_labels[dimux->num_items];
3480 dimux->items[dimux->num_items].index = index;
3481 dimux->num_items++;
3482 }
3483
3484 return 0;
3485}
3486
Mattc7d4b2f2005-06-27 14:59:41 +02003487/* create playback/capture controls for input pins */
3488static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3489{
3490 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003491 struct hda_input_mux *imux = &spec->private_imux;
3492 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3493 int i, j, k;
3494
3495 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003496 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003497
Takashi Iwai314634b2006-09-21 11:56:18 +02003498 if (!cfg->input_pins[i])
3499 continue;
3500 index = -1;
3501 for (j = 0; j < spec->num_muxes; j++) {
3502 int num_cons;
3503 num_cons = snd_hda_get_connections(codec,
3504 spec->mux_nids[j],
3505 con_lst,
3506 HDA_MAX_NUM_INPUTS);
3507 for (k = 0; k < num_cons; k++)
3508 if (con_lst[k] == cfg->input_pins[i]) {
3509 index = k;
3510 goto found;
3511 }
Mattc7d4b2f2005-06-27 14:59:41 +02003512 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003513 continue;
3514 found:
3515 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3516 imux->items[imux->num_items].index = index;
3517 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003518 }
3519
Steve Longerbeam7b043892007-05-03 20:50:03 +02003520 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003521 /*
3522 * Set the current input for the muxes.
3523 * The STAC9221 has two input muxes with identical source
3524 * NID lists. Hopefully this won't get confused.
3525 */
3526 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003527 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3528 AC_VERB_SET_CONNECT_SEL,
3529 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003530 }
3531 }
3532
Mattc7d4b2f2005-06-27 14:59:41 +02003533 return 0;
3534}
3535
Mattc7d4b2f2005-06-27 14:59:41 +02003536static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3537{
3538 struct sigmatel_spec *spec = codec->spec;
3539 int i;
3540
3541 for (i = 0; i < spec->autocfg.line_outs; i++) {
3542 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3543 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3544 }
3545}
3546
3547static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3548{
3549 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003550 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003551
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003552 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3553 hda_nid_t pin;
3554 pin = spec->autocfg.hp_pins[i];
3555 if (pin) /* connect to front */
3556 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3557 }
3558 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3559 hda_nid_t pin;
3560 pin = spec->autocfg.speaker_pins[i];
3561 if (pin) /* connect to front */
3562 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3563 }
Mattc7d4b2f2005-06-27 14:59:41 +02003564}
3565
Matt Porter3cc08dc2006-01-23 15:27:49 +01003566static 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 +02003567{
3568 struct sigmatel_spec *spec = codec->spec;
3569 int err;
3570
Matt Porter8b657272006-10-26 17:12:59 +02003571 if ((err = snd_hda_parse_pin_def_config(codec,
3572 &spec->autocfg,
3573 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003574 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003575 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003576 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003577
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003578 /* If we have no real line-out pin and multiple hp-outs, HPs should
3579 * be set up as multi-channel outputs.
3580 */
3581 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3582 spec->autocfg.hp_outs > 1) {
3583 /* Copy hp_outs to line_outs, backup line_outs in
3584 * speaker_outs so that the following routines can handle
3585 * HP pins as primary outputs.
3586 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003587 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003588 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3589 sizeof(spec->autocfg.line_out_pins));
3590 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3591 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3592 sizeof(spec->autocfg.hp_pins));
3593 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003594 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3595 spec->autocfg.hp_outs = 0;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003596 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003597 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003598 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3599 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003600 u32 caps = query_amp_caps(codec,
3601 spec->autocfg.mono_out_pin, dir);
3602 hda_nid_t conn_list[1];
3603
3604 /* get the mixer node and then the mono mux if it exists */
3605 if (snd_hda_get_connections(codec,
3606 spec->autocfg.mono_out_pin, conn_list, 1) &&
3607 snd_hda_get_connections(codec, conn_list[0],
3608 conn_list, 1)) {
3609
3610 int wcaps = get_wcaps(codec, conn_list[0]);
3611 int wid_type = (wcaps & AC_WCAP_TYPE)
3612 >> AC_WCAP_TYPE_SHIFT;
3613 /* LR swap check, some stac925x have a mux that
3614 * changes the DACs output path instead of the
3615 * mono-mux path.
3616 */
3617 if (wid_type == AC_WID_AUD_SEL &&
3618 !(wcaps & AC_WCAP_LR_SWAP))
3619 spec->mono_nid = conn_list[0];
3620 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003621 if (dir) {
3622 hda_nid_t nid = spec->autocfg.mono_out_pin;
3623
3624 /* most mono outs have a least a mute/unmute switch */
3625 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3626 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3627 "Mono Playback Switch",
3628 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003629 if (err < 0)
3630 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003631 /* check for volume support for the amp */
3632 if ((caps & AC_AMPCAP_NUM_STEPS)
3633 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3634 err = stac92xx_add_control(spec,
3635 STAC_CTL_WIDGET_VOL,
3636 "Mono Playback Volume",
3637 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3638 if (err < 0)
3639 return err;
3640 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003641 }
3642
3643 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3644 AC_PINCTL_OUT_EN);
3645 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003646
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003647 if (!spec->multiout.num_dacs) {
3648 err = stac92xx_auto_fill_dac_nids(codec);
3649 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003650 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003651 err = stac92xx_auto_create_multi_out_ctls(codec,
3652 &spec->autocfg);
3653 if (err < 0)
3654 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003655 }
Mattc7d4b2f2005-06-27 14:59:41 +02003656
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003657 /* setup analog beep controls */
3658 if (spec->anabeep_nid > 0) {
3659 err = stac92xx_auto_create_beep_ctls(codec,
3660 spec->anabeep_nid);
3661 if (err < 0)
3662 return err;
3663 }
3664
3665 /* setup digital beep controls and input device */
3666#ifdef CONFIG_SND_HDA_INPUT_BEEP
3667 if (spec->digbeep_nid > 0) {
3668 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003669 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003670
3671 err = stac92xx_auto_create_beep_ctls(codec, nid);
3672 if (err < 0)
3673 return err;
3674 err = snd_hda_attach_beep_device(codec, nid);
3675 if (err < 0)
3676 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003677 /* if no beep switch is available, make its own one */
3678 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3679 if (codec->beep &&
3680 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3681 err = stac92xx_beep_switch_ctl(codec);
3682 if (err < 0)
3683 return err;
3684 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003685 }
3686#endif
3687
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003688 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3689
3690 if (err < 0)
3691 return err;
3692
3693 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3694
3695 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003696 return err;
3697
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003698 if (spec->mono_nid > 0) {
3699 err = stac92xx_auto_create_mono_output_ctls(codec);
3700 if (err < 0)
3701 return err;
3702 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003703 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003704 err = stac92xx_auto_create_amp_output_ctls(codec);
3705 if (err < 0)
3706 return err;
3707 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003708 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003709 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3710 &spec->autocfg)) < 0)
3711 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003712 if (spec->num_muxes > 0) {
3713 err = stac92xx_auto_create_mux_input_ctls(codec);
3714 if (err < 0)
3715 return err;
3716 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003717 if (spec->num_smuxes > 0) {
3718 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3719 if (err < 0)
3720 return err;
3721 }
Matt Porter8b657272006-10-26 17:12:59 +02003722
Takashi Iwaie3c75962009-01-23 11:57:22 +01003723 err = stac92xx_add_input_source(spec);
3724 if (err < 0)
3725 return err;
3726
Mattc7d4b2f2005-06-27 14:59:41 +02003727 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003728 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003729 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003730
Takashi Iwai82bc9552006-03-21 11:24:42 +01003731 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003732 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003733 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003734 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003735
Takashi Iwai603c4012008-07-30 15:01:44 +02003736 if (spec->kctls.list)
3737 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003738
3739 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003740 if (!spec->dinput_mux)
3741 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003742 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003743 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003744 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003745 return 1;
3746}
3747
Takashi Iwai82bc9552006-03-21 11:24:42 +01003748/* add playback controls for HP output */
3749static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3750 struct auto_pin_cfg *cfg)
3751{
3752 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003753 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003754 unsigned int wid_caps;
3755
3756 if (! pin)
3757 return 0;
3758
3759 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003760 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003761 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003762
3763 return 0;
3764}
3765
Richard Fish160ea0d2006-09-06 13:58:25 +02003766/* add playback controls for LFE output */
3767static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3768 struct auto_pin_cfg *cfg)
3769{
3770 struct sigmatel_spec *spec = codec->spec;
3771 int err;
3772 hda_nid_t lfe_pin = 0x0;
3773 int i;
3774
3775 /*
3776 * search speaker outs and line outs for a mono speaker pin
3777 * with an amp. If one is found, add LFE controls
3778 * for it.
3779 */
3780 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3781 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003782 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003783 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3784 if (wcaps == AC_WCAP_OUT_AMP)
3785 /* found a mono speaker with an amp, must be lfe */
3786 lfe_pin = pin;
3787 }
3788
3789 /* if speaker_outs is 0, then speakers may be in line_outs */
3790 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3791 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3792 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003793 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003794 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003795 AC_VERB_GET_CONFIG_DEFAULT,
3796 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003797 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003798 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003799 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3800 if (wcaps == AC_WCAP_OUT_AMP)
3801 /* found a mono speaker with an amp,
3802 must be lfe */
3803 lfe_pin = pin;
3804 }
3805 }
3806 }
3807
3808 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003809 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003810 if (err < 0)
3811 return err;
3812 }
3813
3814 return 0;
3815}
3816
Mattc7d4b2f2005-06-27 14:59:41 +02003817static int stac9200_parse_auto_config(struct hda_codec *codec)
3818{
3819 struct sigmatel_spec *spec = codec->spec;
3820 int err;
3821
Kailang Yangdf694da2005-12-05 19:42:22 +01003822 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003823 return err;
3824
3825 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3826 return err;
3827
Takashi Iwai82bc9552006-03-21 11:24:42 +01003828 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3829 return err;
3830
Richard Fish160ea0d2006-09-06 13:58:25 +02003831 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3832 return err;
3833
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003834 if (spec->num_muxes > 0) {
3835 err = stac92xx_auto_create_mux_input_ctls(codec);
3836 if (err < 0)
3837 return err;
3838 }
3839
Takashi Iwaie3c75962009-01-23 11:57:22 +01003840 err = stac92xx_add_input_source(spec);
3841 if (err < 0)
3842 return err;
3843
Takashi Iwai82bc9552006-03-21 11:24:42 +01003844 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003845 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003846 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003847 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003848
Takashi Iwai603c4012008-07-30 15:01:44 +02003849 if (spec->kctls.list)
3850 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003851
3852 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003853 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003854
3855 return 1;
3856}
3857
Sam Revitch62fe78e2006-05-10 15:09:17 +02003858/*
3859 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3860 * funky external mute control using GPIO pins.
3861 */
3862
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003863static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003864 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003865{
3866 unsigned int gpiostate, gpiomask, gpiodir;
3867
3868 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3869 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003870 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003871
3872 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3873 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003874 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003875
3876 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3877 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003878 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003879
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003880 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003881 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3882
3883 snd_hda_codec_write(codec, codec->afg, 0,
3884 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003885 snd_hda_codec_read(codec, codec->afg, 0,
3886 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003887
3888 msleep(1);
3889
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003890 snd_hda_codec_read(codec, codec->afg, 0,
3891 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003892}
3893
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003894static int stac92xx_add_jack(struct hda_codec *codec,
3895 hda_nid_t nid, int type)
3896{
Takashi Iwaie4973e12008-11-18 09:32:42 +01003897#ifdef CONFIG_SND_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003898 struct sigmatel_spec *spec = codec->spec;
3899 struct sigmatel_jack *jack;
3900 int def_conf = snd_hda_codec_read(codec, nid,
3901 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3902 int connectivity = get_defcfg_connect(def_conf);
3903 char name[32];
3904
3905 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3906 return 0;
3907
3908 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3909 jack = snd_array_new(&spec->jacks);
3910 if (!jack)
3911 return -ENOMEM;
3912 jack->nid = nid;
3913 jack->type = type;
3914
3915 sprintf(name, "%s at %s %s Jack",
3916 snd_hda_get_jack_type(def_conf),
3917 snd_hda_get_jack_connectivity(def_conf),
3918 snd_hda_get_jack_location(def_conf));
3919
3920 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
Takashi Iwaie4973e12008-11-18 09:32:42 +01003921#else
3922 return 0;
3923#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003924}
3925
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003926static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3927 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003928{
3929 struct sigmatel_event *event;
3930
3931 snd_array_init(&spec->events, sizeof(*event), 32);
3932 event = snd_array_new(&spec->events);
3933 if (!event)
3934 return -ENOMEM;
3935 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003936 event->type = type;
3937 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003938 event->data = data;
3939
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003940 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003941}
3942
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003943static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3944 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003945{
3946 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003947 struct sigmatel_event *event = spec->events.list;
3948 int i;
3949
3950 for (i = 0; i < spec->events.used; i++, event++) {
3951 if (event->nid == nid && event->type == type)
3952 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003953 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003954 return NULL;
3955}
3956
3957static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3958 unsigned char tag)
3959{
3960 struct sigmatel_spec *spec = codec->spec;
3961 struct sigmatel_event *event = spec->events.list;
3962 int i;
3963
3964 for (i = 0; i < spec->events.used; i++, event++) {
3965 if (event->tag == tag)
3966 return event;
3967 }
3968 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04003969}
3970
Takashi Iwai314634b2006-09-21 11:56:18 +02003971static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003972 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02003973{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003974 struct sigmatel_event *event;
3975 int tag;
3976
3977 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3978 return;
3979 event = stac_get_event(codec, nid, type);
3980 if (event)
3981 tag = event->tag;
3982 else
3983 tag = stac_add_event(codec->spec, nid, type, 0);
3984 if (tag < 0)
3985 return;
3986 snd_hda_codec_write_cache(codec, nid, 0,
3987 AC_VERB_SET_UNSOLICITED_ENABLE,
3988 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02003989}
3990
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003991static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3992{
3993 int i;
3994 for (i = 0; i < cfg->hp_outs; i++)
3995 if (cfg->hp_pins[i] == nid)
3996 return 1; /* nid is a HP-Out */
3997
3998 return 0; /* nid is not a HP-Out */
3999};
4000
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004001static void stac92xx_power_down(struct hda_codec *codec)
4002{
4003 struct sigmatel_spec *spec = codec->spec;
4004
4005 /* power down inactive DACs */
4006 hda_nid_t *dac;
4007 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004008 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004009 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004010 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4011}
4012
Takashi Iwaif73d3582008-11-25 08:21:51 +01004013static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4014 int enable);
4015
Mattc7d4b2f2005-06-27 14:59:41 +02004016static int stac92xx_init(struct hda_codec *codec)
4017{
4018 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004019 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004020 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004021 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004022
Mattc7d4b2f2005-06-27 14:59:41 +02004023 snd_hda_sequence_write(codec, spec->init);
4024
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004025 /* power down adcs initially */
4026 if (spec->powerdown_adcs)
4027 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004028 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004029 spec->adc_nids[i], 0,
4030 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004031
4032 /* set up GPIO */
4033 gpio = spec->gpio_data;
4034 /* turn on EAPD statically when spec->eapd_switch isn't set.
4035 * otherwise, unsol event will turn it on/off dynamically
4036 */
4037 if (!spec->eapd_switch)
4038 gpio |= spec->eapd_mask;
4039 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4040
Takashi Iwai82bc9552006-03-21 11:24:42 +01004041 /* set up pins */
4042 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004043 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004044 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004045 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004046 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004047 }
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004048 /* force to enable the first line-out; the others are set up
4049 * in unsol_event
4050 */
4051 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004052 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004053 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004054 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4055 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004056 } else {
4057 stac92xx_auto_init_multi_out(codec);
4058 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004059 for (i = 0; i < cfg->hp_outs; i++)
4060 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004061 }
4062 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004063 hda_nid_t nid = cfg->input_pins[i];
4064 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004065 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004066 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4067 /* for mic pins, force to initialize */
4068 pinctl = stac92xx_get_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004069 pinctl |= AC_PINCTL_IN_EN;
4070 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004071 } else {
4072 pinctl = snd_hda_codec_read(codec, nid, 0,
4073 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4074 /* if PINCTL already set then skip */
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004075 if (!(pinctl & AC_PINCTL_IN_EN)) {
4076 pinctl |= AC_PINCTL_IN_EN;
4077 stac92xx_auto_set_pinctl(codec, nid,
4078 pinctl);
4079 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004080 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004081 conf = snd_hda_codec_read(codec, nid, 0,
4082 AC_VERB_GET_CONFIG_DEFAULT, 0);
4083 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4084 enable_pin_detect(codec, nid,
4085 STAC_INSERT_EVENT);
4086 stac_issue_unsol_event(codec, nid,
4087 STAC_INSERT_EVENT);
4088 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004089 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004090 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004091 for (i = 0; i < spec->num_dmics; i++)
4092 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4093 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004094 if (cfg->dig_out_pin)
4095 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
4096 AC_PINCTL_OUT_EN);
4097 if (cfg->dig_in_pin)
4098 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4099 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004100 for (i = 0; i < spec->num_pwrs; i++) {
4101 hda_nid_t nid = spec->pwr_nids[i];
4102 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004103
Takashi Iwaieb632122008-12-19 16:39:48 +01004104 /* power on when no jack detection is available */
4105 if (!spec->hp_detect) {
4106 stac_toggle_power_map(codec, nid, 1);
4107 continue;
4108 }
4109
4110 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004111 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004112
Takashi Iwaif73d3582008-11-25 08:21:51 +01004113 pinctl = snd_hda_codec_read(codec, nid, 0,
4114 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4115 /* outputs are only ports capable of power management
4116 * any attempts on powering down a input port cause the
4117 * referenced VREF to act quirky.
4118 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004119 if (pinctl & AC_PINCTL_IN_EN) {
4120 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004121 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004122 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004123 def_conf = snd_hda_codec_read(codec, nid, 0,
4124 AC_VERB_GET_CONFIG_DEFAULT, 0);
4125 def_conf = get_defcfg_connect(def_conf);
4126 /* skip any ports that don't have jacks since presence
4127 * detection is useless */
4128 if (def_conf != AC_JACK_PORT_COMPLEX) {
4129 if (def_conf != AC_JACK_PORT_NONE)
4130 stac_toggle_power_map(codec, nid, 1);
4131 continue;
4132 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004133 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4134 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4135 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4136 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004137 }
4138 if (spec->dac_list)
4139 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004140 return 0;
4141}
4142
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004143static void stac92xx_free_jacks(struct hda_codec *codec)
4144{
Takashi Iwaie4973e12008-11-18 09:32:42 +01004145#ifdef CONFIG_SND_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004146 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004147 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004148 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004149 struct sigmatel_jack *jacks = spec->jacks.list;
4150 int i;
4151 for (i = 0; i < spec->jacks.used; i++)
4152 snd_device_free(codec->bus->card, &jacks[i].jack);
4153 }
4154 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004155#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004156}
4157
Takashi Iwai603c4012008-07-30 15:01:44 +02004158static void stac92xx_free_kctls(struct hda_codec *codec)
4159{
4160 struct sigmatel_spec *spec = codec->spec;
4161
4162 if (spec->kctls.list) {
4163 struct snd_kcontrol_new *kctl = spec->kctls.list;
4164 int i;
4165 for (i = 0; i < spec->kctls.used; i++)
4166 kfree(kctl[i].name);
4167 }
4168 snd_array_free(&spec->kctls);
4169}
4170
Matt2f2f4252005-04-13 14:45:30 +02004171static void stac92xx_free(struct hda_codec *codec)
4172{
Mattc7d4b2f2005-06-27 14:59:41 +02004173 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004174
4175 if (! spec)
4176 return;
4177
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004178 kfree(spec->pin_configs);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004179 stac92xx_free_jacks(codec);
4180 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004181
Mattc7d4b2f2005-06-27 14:59:41 +02004182 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004183 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004184}
4185
Matt4e550962005-07-04 17:51:39 +02004186static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4187 unsigned int flag)
4188{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004189 unsigned int old_ctl, pin_ctl;
4190
4191 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004192 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004193
Takashi Iwaif9acba42007-05-29 18:01:06 +02004194 if (pin_ctl & AC_PINCTL_IN_EN) {
4195 /*
4196 * we need to check the current set-up direction of
4197 * shared input pins since they can be switched via
4198 * "xxx as Output" mixer switch
4199 */
4200 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004201 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004202 return;
4203 }
4204
Takashi Iwai8ce84192009-01-22 16:59:20 +01004205 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004206 /* if setting pin direction bits, clear the current
4207 direction bits first */
4208 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4209 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4210
Takashi Iwai8ce84192009-01-22 16:59:20 +01004211 pin_ctl |= flag;
4212 if (old_ctl != pin_ctl)
4213 snd_hda_codec_write_cache(codec, nid, 0,
4214 AC_VERB_SET_PIN_WIDGET_CONTROL,
4215 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004216}
4217
4218static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4219 unsigned int flag)
4220{
4221 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4222 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004223 if (pin_ctl & flag)
4224 snd_hda_codec_write_cache(codec, nid, 0,
4225 AC_VERB_SET_PIN_WIDGET_CONTROL,
4226 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004227}
4228
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004229static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004230{
4231 if (!nid)
4232 return 0;
4233 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004234 & (1 << 31))
4235 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004236 return 0;
4237}
4238
Takashi Iwaid7a89432008-11-12 09:48:04 +01004239/* return non-zero if the hp-pin of the given array index isn't
4240 * a jack-detection target
4241 */
4242static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4243{
4244 struct auto_pin_cfg *cfg = &spec->autocfg;
4245
4246 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004247 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004248 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004249 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004250 return 1;
4251 /* ignore if the pin is set as line-out */
4252 if (cfg->hp_pins[i] == spec->hp_switch)
4253 return 1;
4254 return 0;
4255}
4256
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004257static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004258{
4259 struct sigmatel_spec *spec = codec->spec;
4260 struct auto_pin_cfg *cfg = &spec->autocfg;
4261 int i, presence;
4262
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004263 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004264 if (spec->gpio_mute)
4265 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4266 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4267
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004268 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004269 if (presence)
4270 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004271 if (no_hp_sensing(spec, i))
4272 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004273 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4274 if (presence) {
4275 unsigned int pinctl;
4276 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4277 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4278 if (pinctl & AC_PINCTL_IN_EN)
4279 presence = 0; /* mic- or line-input */
4280 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004281 }
Matt4e550962005-07-04 17:51:39 +02004282
4283 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004284 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004285 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004286 stac92xx_reset_pinctl(codec, spec->hp_switch,
4287 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004288 for (i = 0; i < cfg->line_outs; i++)
4289 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4290 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004291 for (i = 0; i < cfg->speaker_outs; i++)
4292 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4293 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004294 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004295 stac_gpio_set(codec, spec->gpio_mask,
4296 spec->gpio_dir, spec->gpio_data &
4297 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004298 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004299 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004300 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004301 stac92xx_set_pinctl(codec, spec->hp_switch,
4302 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004303 for (i = 0; i < cfg->line_outs; i++)
4304 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4305 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004306 for (i = 0; i < cfg->speaker_outs; i++)
4307 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4308 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004309 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004310 stac_gpio_set(codec, spec->gpio_mask,
4311 spec->gpio_dir, spec->gpio_data |
4312 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004313 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004314 /* toggle hp outs */
4315 for (i = 0; i < cfg->hp_outs; i++) {
4316 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4317 if (no_hp_sensing(spec, i))
4318 continue;
4319 if (presence)
4320 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004321#if 0 /* FIXME */
4322/* Resetting the pinctl like below may lead to (a sort of) regressions
4323 * on some devices since they use the HP pin actually for line/speaker
4324 * outs although the default pin config shows a different pin (that is
4325 * wrong and useless).
4326 *
4327 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4328 * But, disabling the code below just works around it, and I'm too tired of
4329 * bug reports with such devices...
4330 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004331 else
4332 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004333#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004334 }
Matt4e550962005-07-04 17:51:39 +02004335}
4336
Takashi Iwaif73d3582008-11-25 08:21:51 +01004337static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4338 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004339{
4340 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004341 unsigned int idx, val;
4342
4343 for (idx = 0; idx < spec->num_pwrs; idx++) {
4344 if (spec->pwr_nids[idx] == nid)
4345 break;
4346 }
4347 if (idx >= spec->num_pwrs)
4348 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004349
4350 /* several codecs have two power down bits */
4351 if (spec->pwr_mapping)
4352 idx = spec->pwr_mapping[idx];
4353 else
4354 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004355
Takashi Iwaif73d3582008-11-25 08:21:51 +01004356 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4357 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004358 val &= ~idx;
4359 else
4360 val |= idx;
4361
4362 /* power down unused output ports */
4363 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004364}
4365
Takashi Iwaif73d3582008-11-25 08:21:51 +01004366static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4367{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004368 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004369}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004370
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004371static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4372{
4373 struct sigmatel_spec *spec = codec->spec;
4374 struct sigmatel_jack *jacks = spec->jacks.list;
4375
4376 if (jacks) {
4377 int i;
4378 for (i = 0; i < spec->jacks.used; i++) {
4379 if (jacks->nid == nid) {
4380 unsigned int pin_ctl =
4381 snd_hda_codec_read(codec, nid,
4382 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4383 0x00);
4384 int type = jacks->type;
4385 if (type == (SND_JACK_LINEOUT
4386 | SND_JACK_HEADPHONE))
4387 type = (pin_ctl & AC_PINCTL_HP_EN)
4388 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4389 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004390 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004391 ? type : 0);
4392 }
4393 jacks++;
4394 }
4395 }
4396}
Matt2f2f4252005-04-13 14:45:30 +02004397
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004398static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4399 unsigned char type)
4400{
4401 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4402 if (!event)
4403 return;
4404 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4405}
4406
Takashi Iwai314634b2006-09-21 11:56:18 +02004407static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4408{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004409 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004410 struct sigmatel_event *event;
4411 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004412
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004413 tag = (res >> 26) & 0x7f;
4414 event = stac_get_event_from_tag(codec, tag);
4415 if (!event)
4416 return;
4417
4418 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004419 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004420 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004421 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004422 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004423 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004424 if (spec->num_pwrs > 0)
4425 stac92xx_pin_sense(codec, event->nid);
4426 stac92xx_report_jack(codec, event->nid);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004427 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004428 case STAC_VREF_EVENT:
4429 data = snd_hda_codec_read(codec, codec->afg, 0,
4430 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004431 /* toggle VREF state based on GPIOx status */
4432 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004433 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004434 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004435 }
4436}
4437
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004438#ifdef CONFIG_PROC_FS
4439static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4440 struct hda_codec *codec, hda_nid_t nid)
4441{
4442 if (nid == codec->afg)
4443 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4444 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4445}
4446
4447static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4448 struct hda_codec *codec,
4449 unsigned int verb)
4450{
4451 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4452 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4453}
4454
4455/* stac92hd71bxx, stac92hd73xx */
4456static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4457 struct hda_codec *codec, hda_nid_t nid)
4458{
4459 stac92hd_proc_hook(buffer, codec, nid);
4460 if (nid == codec->afg)
4461 analog_loop_proc_hook(buffer, codec, 0xfa0);
4462}
4463
4464static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4465 struct hda_codec *codec, hda_nid_t nid)
4466{
4467 if (nid == codec->afg)
4468 analog_loop_proc_hook(buffer, codec, 0xfe0);
4469}
4470
4471static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4472 struct hda_codec *codec, hda_nid_t nid)
4473{
4474 if (nid == codec->afg)
4475 analog_loop_proc_hook(buffer, codec, 0xfeb);
4476}
4477#else
4478#define stac92hd_proc_hook NULL
4479#define stac92hd7x_proc_hook NULL
4480#define stac9205_proc_hook NULL
4481#define stac927x_proc_hook NULL
4482#endif
4483
Takashi Iwaicb53c622007-08-10 17:21:45 +02004484#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004485static int stac92xx_resume(struct hda_codec *codec)
4486{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004487 struct sigmatel_spec *spec = codec->spec;
4488
Richard Fish11b44bb2006-08-23 18:31:34 +02004489 stac92xx_set_config_regs(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004490 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004491 snd_hda_codec_resume_amp(codec);
4492 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004493 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004494 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004495 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4496 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004497 return 0;
4498}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004499
4500static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4501{
4502 struct sigmatel_spec *spec = codec->spec;
4503 if (spec->eapd_mask)
4504 stac_gpio_set(codec, spec->gpio_mask,
4505 spec->gpio_dir, spec->gpio_data &
4506 ~spec->eapd_mask);
4507 return 0;
4508}
Mattff6fdc32005-06-27 15:06:52 +02004509#endif
4510
Matt2f2f4252005-04-13 14:45:30 +02004511static struct hda_codec_ops stac92xx_patch_ops = {
4512 .build_controls = stac92xx_build_controls,
4513 .build_pcms = stac92xx_build_pcms,
4514 .init = stac92xx_init,
4515 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004516 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004517#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004518 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004519 .resume = stac92xx_resume,
4520#endif
Matt2f2f4252005-04-13 14:45:30 +02004521};
4522
4523static int patch_stac9200(struct hda_codec *codec)
4524{
4525 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004526 int err;
Matt2f2f4252005-04-13 14:45:30 +02004527
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004528 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004529 if (spec == NULL)
4530 return -ENOMEM;
4531
4532 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004533 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004534 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004535 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4536 stac9200_models,
4537 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004538 if (spec->board_config < 0) {
4539 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4540 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004541 } else
4542 err = stac_save_pin_cfgs(codec,
4543 stac9200_brd_tbl[spec->board_config]);
4544 if (err < 0) {
4545 stac92xx_free(codec);
4546 return err;
Matt Porter403d1942005-11-29 15:00:51 +01004547 }
Matt2f2f4252005-04-13 14:45:30 +02004548
4549 spec->multiout.max_channels = 2;
4550 spec->multiout.num_dacs = 1;
4551 spec->multiout.dac_nids = stac9200_dac_nids;
4552 spec->adc_nids = stac9200_adc_nids;
4553 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004554 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004555 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004556 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004557 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004558
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004559 if (spec->board_config == STAC_9200_M4 ||
4560 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004561 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004562 spec->init = stac9200_eapd_init;
4563 else
4564 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004565 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004566
Takashi Iwai117f2572008-03-18 09:53:23 +01004567 if (spec->board_config == STAC_9200_PANASONIC) {
4568 spec->gpio_mask = spec->gpio_dir = 0x09;
4569 spec->gpio_data = 0x00;
4570 }
4571
Mattc7d4b2f2005-06-27 14:59:41 +02004572 err = stac9200_parse_auto_config(codec);
4573 if (err < 0) {
4574 stac92xx_free(codec);
4575 return err;
4576 }
Matt2f2f4252005-04-13 14:45:30 +02004577
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004578 /* CF-74 has no headphone detection, and the driver should *NOT*
4579 * do detection and HP/speaker toggle because the hardware does it.
4580 */
4581 if (spec->board_config == STAC_9200_PANASONIC)
4582 spec->hp_detect = 0;
4583
Matt2f2f4252005-04-13 14:45:30 +02004584 codec->patch_ops = stac92xx_patch_ops;
4585
4586 return 0;
4587}
4588
Tobin Davis8e21c342007-01-08 11:04:17 +01004589static int patch_stac925x(struct hda_codec *codec)
4590{
4591 struct sigmatel_spec *spec;
4592 int err;
4593
4594 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4595 if (spec == NULL)
4596 return -ENOMEM;
4597
4598 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004599 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004600 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004601
4602 /* Check first for codec ID */
4603 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4604 STAC_925x_MODELS,
4605 stac925x_models,
4606 stac925x_codec_id_cfg_tbl);
4607
4608 /* Now checks for PCI ID, if codec ID is not found */
4609 if (spec->board_config < 0)
4610 spec->board_config = snd_hda_check_board_config(codec,
4611 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004612 stac925x_models,
4613 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004614 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004615 if (spec->board_config < 0) {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004616 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
Tobin Davis2c11f952007-05-17 09:36:34 +02004617 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004618 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004619 } else
4620 err = stac_save_pin_cfgs(codec,
4621 stac925x_brd_tbl[spec->board_config]);
4622 if (err < 0) {
4623 stac92xx_free(codec);
4624 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01004625 }
4626
4627 spec->multiout.max_channels = 2;
4628 spec->multiout.num_dacs = 1;
4629 spec->multiout.dac_nids = stac925x_dac_nids;
4630 spec->adc_nids = stac925x_adc_nids;
4631 spec->mux_nids = stac925x_mux_nids;
4632 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004633 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004634 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004635 switch (codec->vendor_id) {
4636 case 0x83847632: /* STAC9202 */
4637 case 0x83847633: /* STAC9202D */
4638 case 0x83847636: /* STAC9251 */
4639 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004640 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004641 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004642 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4643 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004644 break;
4645 default:
4646 spec->num_dmics = 0;
4647 break;
4648 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004649
4650 spec->init = stac925x_core_init;
4651 spec->mixer = stac925x_mixer;
4652
4653 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004654 if (!err) {
4655 if (spec->board_config < 0) {
4656 printk(KERN_WARNING "hda_codec: No auto-config is "
4657 "available, default to model=ref\n");
4658 spec->board_config = STAC_925x_REF;
4659 goto again;
4660 }
4661 err = -EINVAL;
4662 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004663 if (err < 0) {
4664 stac92xx_free(codec);
4665 return err;
4666 }
4667
4668 codec->patch_ops = stac92xx_patch_ops;
4669
4670 return 0;
4671}
4672
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004673static struct hda_input_mux stac92hd73xx_dmux = {
4674 .num_items = 4,
4675 .items = {
4676 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004677 { "Digital Mic 1", 0x09 },
4678 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004679 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004680 }
4681};
4682
4683static int patch_stac92hd73xx(struct hda_codec *codec)
4684{
4685 struct sigmatel_spec *spec;
4686 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4687 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004688 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004689
4690 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4691 if (spec == NULL)
4692 return -ENOMEM;
4693
4694 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004695 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004696 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4697 spec->pin_nids = stac92hd73xx_pin_nids;
4698 spec->board_config = snd_hda_check_board_config(codec,
4699 STAC_92HD73XX_MODELS,
4700 stac92hd73xx_models,
4701 stac92hd73xx_cfg_tbl);
4702again:
4703 if (spec->board_config < 0) {
4704 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4705 " STAC92HD73XX, using BIOS defaults\n");
4706 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004707 } else
4708 err = stac_save_pin_cfgs(codec,
4709 stac92hd73xx_brd_tbl[spec->board_config]);
4710 if (err < 0) {
4711 stac92xx_free(codec);
4712 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004713 }
4714
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004715 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004716 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4717
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004718 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004719 printk(KERN_WARNING "hda_codec: Could not determine "
4720 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004721 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004722 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004723 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004724 case 0x3: /* 6 Channel */
4725 spec->mixer = stac92hd73xx_6ch_mixer;
4726 spec->init = stac92hd73xx_6ch_core_init;
4727 break;
4728 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004729 spec->mixer = stac92hd73xx_8ch_mixer;
4730 spec->init = stac92hd73xx_8ch_core_init;
4731 break;
4732 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004733 spec->mixer = stac92hd73xx_10ch_mixer;
4734 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004735 }
4736 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004737
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004738 spec->aloopback_mask = 0x01;
4739 spec->aloopback_shift = 8;
4740
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004741 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004742 spec->mux_nids = stac92hd73xx_mux_nids;
4743 spec->adc_nids = stac92hd73xx_adc_nids;
4744 spec->dmic_nids = stac92hd73xx_dmic_nids;
4745 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004746 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004747 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004748 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004749
4750 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4751 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004752 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004753 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4754 sizeof(stac92hd73xx_dmux));
4755
Matthew Ranostaya7662642008-02-21 07:51:14 +01004756 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004757 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004758 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004759 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004760 case STAC_DELL_M6_AMIC:
4761 case STAC_DELL_M6_DMIC:
4762 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004763 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004764 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4765 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004766 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004767 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004768
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004769 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004770 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004771 switch (spec->board_config) {
4772 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004773 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4774 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004775 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004776 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004777 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004778 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4779 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004780 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004781 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004782 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004783 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4784 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4785 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004786 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004787 break;
4788 }
4789 break;
4790 default:
4791 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004792 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004793 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004794 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004795 if (spec->board_config > STAC_92HD73XX_REF) {
4796 /* GPIO0 High = Enable EAPD */
4797 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4798 spec->gpio_data = 0x01;
4799 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004800 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004801
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004802 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4803 spec->pwr_nids = stac92hd73xx_pwr_nids;
4804
Matthew Ranostayd9737752008-09-07 12:03:41 +02004805 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004806
4807 if (!err) {
4808 if (spec->board_config < 0) {
4809 printk(KERN_WARNING "hda_codec: No auto-config is "
4810 "available, default to model=ref\n");
4811 spec->board_config = STAC_92HD73XX_REF;
4812 goto again;
4813 }
4814 err = -EINVAL;
4815 }
4816
4817 if (err < 0) {
4818 stac92xx_free(codec);
4819 return err;
4820 }
4821
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01004822 if (spec->board_config == STAC_92HD73XX_NO_JD)
4823 spec->hp_detect = 0;
4824
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004825 codec->patch_ops = stac92xx_patch_ops;
4826
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004827 codec->proc_widget_hook = stac92hd7x_proc_hook;
4828
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004829 return 0;
4830}
4831
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004832static struct hda_input_mux stac92hd83xxx_dmux = {
4833 .num_items = 3,
4834 .items = {
4835 { "Analog Inputs", 0x03 },
4836 { "Digital Mic 1", 0x04 },
4837 { "Digital Mic 2", 0x05 },
4838 }
4839};
4840
4841static int patch_stac92hd83xxx(struct hda_codec *codec)
4842{
4843 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004844 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004845 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05004846 int num_dacs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004847
4848 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4849 if (spec == NULL)
4850 return -ENOMEM;
4851
4852 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004853 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004854 spec->mono_nid = 0x19;
4855 spec->digbeep_nid = 0x21;
4856 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4857 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4858 spec->adc_nids = stac92hd83xxx_adc_nids;
4859 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004860 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004861 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4862 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004863 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004864
Matthew Ranostay65557f32009-01-20 16:50:25 -05004865
4866 /* set port 0xe to select the last DAC
4867 */
4868 num_dacs = snd_hda_get_connections(codec, 0x0e,
4869 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4870
4871 snd_hda_codec_write_cache(codec, 0xe, 0,
4872 AC_VERB_SET_CONNECT_SEL, num_dacs);
4873
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004874 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004875 spec->mixer = stac92hd83xxx_mixer;
4876 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4877 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4878 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05004879 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004880 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4881 spec->dinput_mux = &stac92hd83xxx_dmux;
4882 spec->pin_nids = stac92hd83xxx_pin_nids;
4883 spec->board_config = snd_hda_check_board_config(codec,
4884 STAC_92HD83XXX_MODELS,
4885 stac92hd83xxx_models,
4886 stac92hd83xxx_cfg_tbl);
4887again:
4888 if (spec->board_config < 0) {
4889 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4890 " STAC92HD83XXX, using BIOS defaults\n");
4891 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004892 } else
4893 err = stac_save_pin_cfgs(codec,
4894 stac92hd83xxx_brd_tbl[spec->board_config]);
4895 if (err < 0) {
4896 stac92xx_free(codec);
4897 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004898 }
4899
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05004900 switch (codec->vendor_id) {
4901 case 0x111d7604:
4902 case 0x111d7605:
4903 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4904 break;
4905 spec->num_pwrs = 0;
4906 break;
4907 }
4908
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004909 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4910 if (!err) {
4911 if (spec->board_config < 0) {
4912 printk(KERN_WARNING "hda_codec: No auto-config is "
4913 "available, default to model=ref\n");
4914 spec->board_config = STAC_92HD83XXX_REF;
4915 goto again;
4916 }
4917 err = -EINVAL;
4918 }
4919
4920 if (err < 0) {
4921 stac92xx_free(codec);
4922 return err;
4923 }
4924
4925 codec->patch_ops = stac92xx_patch_ops;
4926
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004927 codec->proc_widget_hook = stac92hd_proc_hook;
4928
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004929 return 0;
4930}
4931
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004932static struct hda_input_mux stac92hd71bxx_dmux = {
4933 .num_items = 4,
4934 .items = {
4935 { "Analog Inputs", 0x00 },
4936 { "Mixer", 0x01 },
4937 { "Digital Mic 1", 0x02 },
4938 { "Digital Mic 2", 0x03 },
4939 }
4940};
4941
Matthew Ranostaye035b842007-11-06 11:53:55 +01004942static int patch_stac92hd71bxx(struct hda_codec *codec)
4943{
4944 struct sigmatel_spec *spec;
4945 int err = 0;
4946
4947 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4948 if (spec == NULL)
4949 return -ENOMEM;
4950
4951 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004952 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004953 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004954 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004955 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004956 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4957 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004958 spec->board_config = snd_hda_check_board_config(codec,
4959 STAC_92HD71BXX_MODELS,
4960 stac92hd71bxx_models,
4961 stac92hd71bxx_cfg_tbl);
4962again:
4963 if (spec->board_config < 0) {
4964 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4965 " STAC92HD71BXX, using BIOS defaults\n");
4966 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004967 } else
4968 err = stac_save_pin_cfgs(codec,
4969 stac92hd71bxx_brd_tbl[spec->board_config]);
4970 if (err < 0) {
4971 stac92xx_free(codec);
4972 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004973 }
4974
Takashi Iwai41c3b642008-11-18 10:45:15 +01004975 if (spec->board_config > STAC_92HD71BXX_REF) {
4976 /* GPIO0 = EAPD */
4977 spec->gpio_mask = 0x01;
4978 spec->gpio_dir = 0x01;
4979 spec->gpio_data = 0x01;
4980 }
4981
Matthew Ranostay541eee82007-12-14 12:08:04 +01004982 switch (codec->vendor_id) {
4983 case 0x111d76b6: /* 4 Port without Analog Mixer */
4984 case 0x111d76b7:
4985 case 0x111d76b4: /* 6 Port without Analog Mixer */
4986 case 0x111d76b5:
4987 spec->mixer = stac92hd71bxx_mixer;
4988 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004989 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004990 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004991 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004992 switch (spec->board_config) {
4993 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004994 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004995 err = stac_add_event(spec, codec->afg,
4996 STAC_VREF_EVENT, 0x02);
4997 if (err < 0)
4998 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004999 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005000 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5001 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005002 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005003 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005004 spec->gpio_mask |= 0x02;
5005 break;
5006 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005007 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005008 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005009 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005010
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005011 /* no output amps */
5012 spec->num_pwrs = 0;
5013 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005014 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005015
5016 /* disable VSW */
5017 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005018 stac_change_pin_config(codec, 0xf, 0x40f000f0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005019 break;
5020 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005021 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005022 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005023
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005024 /* no output amps */
5025 spec->num_pwrs = 0;
5026 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005027 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005028 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005029 spec->mixer = stac92hd71bxx_analog_mixer;
5030 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005031 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005032 }
5033
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005034 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005035 spec->aloopback_shift = 0;
5036
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005037 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005038 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005039 spec->mux_nids = stac92hd71bxx_mux_nids;
5040 spec->adc_nids = stac92hd71bxx_adc_nids;
5041 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005042 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005043 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005044 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005045
5046 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5047 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005048
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005049 switch (spec->board_config) {
5050 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005051 /* enable internal microphone */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005052 stac_change_pin_config(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005053 stac92xx_auto_set_pinctl(codec, 0x0e,
5054 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005055 /* fallthru */
5056 case STAC_DELL_M4_2:
5057 spec->num_dmics = 0;
5058 spec->num_smuxes = 0;
5059 spec->num_dmuxes = 0;
5060 break;
5061 case STAC_DELL_M4_1:
5062 case STAC_DELL_M4_3:
5063 spec->num_dmics = 1;
5064 spec->num_smuxes = 0;
5065 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005066 break;
5067 default:
5068 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
5069 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
5070 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5071 };
5072
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005073 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005074 if (spec->dinput_mux)
5075 spec->private_dimux.num_items +=
5076 spec->num_dmics -
5077 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005078
5079 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
5080 if (!err) {
5081 if (spec->board_config < 0) {
5082 printk(KERN_WARNING "hda_codec: No auto-config is "
5083 "available, default to model=ref\n");
5084 spec->board_config = STAC_92HD71BXX_REF;
5085 goto again;
5086 }
5087 err = -EINVAL;
5088 }
5089
5090 if (err < 0) {
5091 stac92xx_free(codec);
5092 return err;
5093 }
5094
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005095 codec->proc_widget_hook = stac92hd7x_proc_hook;
5096
Matthew Ranostaye035b842007-11-06 11:53:55 +01005097 return 0;
5098};
5099
Matt2f2f4252005-04-13 14:45:30 +02005100static int patch_stac922x(struct hda_codec *codec)
5101{
5102 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005103 int err;
Matt2f2f4252005-04-13 14:45:30 +02005104
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005105 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005106 if (spec == NULL)
5107 return -ENOMEM;
5108
5109 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005110 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005111 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005112 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5113 stac922x_models,
5114 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005115 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005116 spec->gpio_mask = spec->gpio_dir = 0x03;
5117 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005118 /* Intel Macs have all same PCI SSID, so we need to check
5119 * codec SSID to distinguish the exact models
5120 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005121 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005122 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005123
5124 case 0x106b0800:
5125 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005126 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005127 case 0x106b0600:
5128 case 0x106b0700:
5129 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005130 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005131 case 0x106b0e00:
5132 case 0x106b0f00:
5133 case 0x106b1600:
5134 case 0x106b1700:
5135 case 0x106b0200:
5136 case 0x106b1e00:
5137 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005138 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005139 case 0x106b1a00:
5140 case 0x00000100:
5141 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005142 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005143 case 0x106b0a00:
5144 case 0x106b2200:
5145 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005146 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005147 default:
5148 spec->board_config = STAC_INTEL_MAC_V3;
5149 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005150 }
5151 }
5152
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005153 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005154 if (spec->board_config < 0) {
5155 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5156 "using BIOS defaults\n");
5157 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005158 } else
5159 err = stac_save_pin_cfgs(codec,
5160 stac922x_brd_tbl[spec->board_config]);
5161 if (err < 0) {
5162 stac92xx_free(codec);
5163 return err;
Matt Porter403d1942005-11-29 15:00:51 +01005164 }
Matt2f2f4252005-04-13 14:45:30 +02005165
Matt2f2f4252005-04-13 14:45:30 +02005166 spec->adc_nids = stac922x_adc_nids;
5167 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005168 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005169 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005170 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005171 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005172
5173 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005174 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005175
5176 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005177
Matt Porter3cc08dc2006-01-23 15:27:49 +01005178 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005179 if (!err) {
5180 if (spec->board_config < 0) {
5181 printk(KERN_WARNING "hda_codec: No auto-config is "
5182 "available, default to model=ref\n");
5183 spec->board_config = STAC_D945_REF;
5184 goto again;
5185 }
5186 err = -EINVAL;
5187 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005188 if (err < 0) {
5189 stac92xx_free(codec);
5190 return err;
5191 }
5192
5193 codec->patch_ops = stac92xx_patch_ops;
5194
Takashi Iwai807a46362007-05-29 19:01:37 +02005195 /* Fix Mux capture level; max to 2 */
5196 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5197 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5198 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5199 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5200 (0 << AC_AMPCAP_MUTE_SHIFT));
5201
Matt Porter3cc08dc2006-01-23 15:27:49 +01005202 return 0;
5203}
5204
5205static int patch_stac927x(struct hda_codec *codec)
5206{
5207 struct sigmatel_spec *spec;
5208 int err;
5209
5210 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5211 if (spec == NULL)
5212 return -ENOMEM;
5213
5214 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005215 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005216 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005217 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5218 stac927x_models,
5219 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005220 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005221 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
5222 if (spec->board_config < 0)
5223 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5224 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02005225 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005226 } else
5227 err = stac_save_pin_cfgs(codec,
5228 stac927x_brd_tbl[spec->board_config]);
5229 if (err < 0) {
5230 stac92xx_free(codec);
5231 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01005232 }
5233
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005234 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005235 spec->adc_nids = stac927x_adc_nids;
5236 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5237 spec->mux_nids = stac927x_mux_nids;
5238 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005239 spec->smux_nids = stac927x_smux_nids;
5240 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005241 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005242 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005243 spec->multiout.dac_nids = spec->dac_nids;
5244
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005245 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005246 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005247 case STAC_D965_5ST:
5248 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005249 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005250 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005251 spec->num_dmics = 0;
5252
Tobin Davis93ed1502006-09-01 21:03:12 +02005253 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005254 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005255 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005256 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005257 switch (codec->subsystem_id) {
5258 case 0x10280209:
5259 case 0x1028022e:
5260 /* correct the device field to SPDIF out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005261 stac_change_pin_config(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005262 break;
5263 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005264 /* configure the analog microphone on some laptops */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005265 stac_change_pin_config(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005266 /* correct the front output jack as a hp out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005267 stac_change_pin_config(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005268 /* correct the front input jack as a mic */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005269 stac_change_pin_config(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005270 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005271 case STAC_DELL_3ST:
5272 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005273 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005274 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005275 spec->dmic_nids = stac927x_dmic_nids;
5276 spec->num_dmics = STAC927X_NUM_DMICS;
5277
Tobin Davis93ed1502006-09-01 21:03:12 +02005278 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005279 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005280 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005281 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005282 break;
5283 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005284 if (spec->board_config > STAC_D965_REF) {
5285 /* GPIO0 High = Enable EAPD */
5286 spec->eapd_mask = spec->gpio_mask = 0x01;
5287 spec->gpio_dir = spec->gpio_data = 0x01;
5288 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005289 spec->num_dmics = 0;
5290
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005291 spec->init = stac927x_core_init;
5292 spec->mixer = stac927x_mixer;
5293 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005294
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005295 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005296 spec->aloopback_mask = 0x40;
5297 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005298 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005299
Matt Porter3cc08dc2006-01-23 15:27:49 +01005300 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005301 if (!err) {
5302 if (spec->board_config < 0) {
5303 printk(KERN_WARNING "hda_codec: No auto-config is "
5304 "available, default to model=ref\n");
5305 spec->board_config = STAC_D965_REF;
5306 goto again;
5307 }
5308 err = -EINVAL;
5309 }
Mattc7d4b2f2005-06-27 14:59:41 +02005310 if (err < 0) {
5311 stac92xx_free(codec);
5312 return err;
5313 }
Matt2f2f4252005-04-13 14:45:30 +02005314
5315 codec->patch_ops = stac92xx_patch_ops;
5316
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005317 codec->proc_widget_hook = stac927x_proc_hook;
5318
Takashi Iwai52987652008-01-16 16:09:47 +01005319 /*
5320 * !!FIXME!!
5321 * The STAC927x seem to require fairly long delays for certain
5322 * command sequences. With too short delays (even if the answer
5323 * is set to RIRB properly), it results in the silence output
5324 * on some hardwares like Dell.
5325 *
5326 * The below flag enables the longer delay (see get_response
5327 * in hda_intel.c).
5328 */
5329 codec->bus->needs_damn_long_delay = 1;
5330
Takashi Iwaie28d8322008-12-17 13:48:29 +01005331 /* no jack detecion for ref-no-jd model */
5332 if (spec->board_config == STAC_D965_REF_NO_JD)
5333 spec->hp_detect = 0;
5334
Matt2f2f4252005-04-13 14:45:30 +02005335 return 0;
5336}
5337
Matt Porterf3302a52006-07-31 12:49:34 +02005338static int patch_stac9205(struct hda_codec *codec)
5339{
5340 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005341 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005342
5343 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5344 if (spec == NULL)
5345 return -ENOMEM;
5346
5347 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005348 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005349 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005350 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5351 stac9205_models,
5352 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005353 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02005354 if (spec->board_config < 0) {
5355 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5356 err = stac92xx_save_bios_config_regs(codec);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005357 } else
5358 err = stac_save_pin_cfgs(codec,
5359 stac9205_brd_tbl[spec->board_config]);
5360 if (err < 0) {
5361 stac92xx_free(codec);
5362 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02005363 }
5364
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005365 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005366 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005367 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005368 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005369 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005370 spec->smux_nids = stac9205_smux_nids;
5371 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005372 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005373 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005374 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005375 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005376 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005377
5378 spec->init = stac9205_core_init;
5379 spec->mixer = stac9205_mixer;
5380
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005381 spec->aloopback_mask = 0x40;
5382 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005383 /* Turn on/off EAPD per HP plugging */
5384 if (spec->board_config != STAC_9205_EAPD)
5385 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005386 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005387
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005388 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005389 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005390 /* Enable SPDIF in/out */
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005391 stac_change_pin_config(codec, 0x1f, 0x01441030);
5392 stac_change_pin_config(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005393
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005394 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005395 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5396 if (err < 0)
5397 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005398 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005399 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5400 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005401 AC_VERB_SET_UNSOLICITED_ENABLE,
5402 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005403
5404 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005405 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005406 spec->gpio_mask = 0x1b;
5407 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005408 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005409 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005410 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005411 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005412 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005413 case STAC_9205_REF:
5414 /* SPDIF-In enabled */
5415 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005416 default:
5417 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005418 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005419 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005420 break;
5421 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005422
Matt Porterf3302a52006-07-31 12:49:34 +02005423 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005424 if (!err) {
5425 if (spec->board_config < 0) {
5426 printk(KERN_WARNING "hda_codec: No auto-config is "
5427 "available, default to model=ref\n");
5428 spec->board_config = STAC_9205_REF;
5429 goto again;
5430 }
5431 err = -EINVAL;
5432 }
Matt Porterf3302a52006-07-31 12:49:34 +02005433 if (err < 0) {
5434 stac92xx_free(codec);
5435 return err;
5436 }
5437
5438 codec->patch_ops = stac92xx_patch_ops;
5439
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005440 codec->proc_widget_hook = stac9205_proc_hook;
5441
Matt Porterf3302a52006-07-31 12:49:34 +02005442 return 0;
5443}
5444
Matt2f2f4252005-04-13 14:45:30 +02005445/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005446 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005447 */
5448
Takashi Iwai1e137f92009-01-21 07:41:22 +01005449static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005450 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5452 {}
5453};
5454
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005455static struct snd_kcontrol_new stac9872_mixer[] = {
5456 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5457 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005458 { } /* end */
5459};
5460
5461static hda_nid_t stac9872_pin_nids[] = {
5462 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5463 0x11, 0x13, 0x14,
5464};
5465
5466static hda_nid_t stac9872_adc_nids[] = {
5467 0x8 /*,0x6*/
5468};
5469
5470static hda_nid_t stac9872_mux_nids[] = {
5471 0x15
5472};
5473
Guillaume Munch6d859062006-08-22 17:15:47 +02005474static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005475{
5476 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005477 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005478
Takashi Iwaidb064e52006-03-16 16:04:58 +01005479 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5480 if (spec == NULL)
5481 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005482 codec->spec = spec;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005483
Takashi Iwai1e137f92009-01-21 07:41:22 +01005484#if 0 /* no model right now */
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005485 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5486 stac9872_models,
5487 stac9872_cfg_tbl);
Takashi Iwai1e137f92009-01-21 07:41:22 +01005488#endif
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005489
Takashi Iwai1e137f92009-01-21 07:41:22 +01005490 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5491 spec->pin_nids = stac9872_pin_nids;
5492 spec->multiout.dac_nids = spec->dac_nids;
5493 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5494 spec->adc_nids = stac9872_adc_nids;
5495 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5496 spec->mux_nids = stac9872_mux_nids;
5497 spec->mixer = stac9872_mixer;
5498 spec->init = stac9872_core_init;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005499
Takashi Iwai1e137f92009-01-21 07:41:22 +01005500 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5501 if (err < 0) {
5502 stac92xx_free(codec);
5503 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005504 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005505 spec->input_mux = &spec->private_imux;
5506 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005507 return 0;
5508}
5509
5510
5511/*
Matt2f2f4252005-04-13 14:45:30 +02005512 * patch entries
5513 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005514static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005515 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5516 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5517 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5518 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5519 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5520 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5521 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005522 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5523 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5524 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5525 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5526 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5527 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005528 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5529 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5530 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5531 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5532 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5533 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5534 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5535 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5536 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5537 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005538 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5539 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5540 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5541 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5542 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5543 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005544 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5545 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005546 /* The following does not take into account .id=0x83847661 when subsys =
5547 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5548 * currently not fully supported.
5549 */
5550 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5551 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5552 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005553 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5554 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5555 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5556 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5557 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5558 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5559 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5560 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005561 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005562 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5563 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005564 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005565 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5566 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005567 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005568 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5569 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5570 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5571 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5572 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5573 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5574 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5575 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005576 {} /* terminator */
5577};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005578
5579MODULE_ALIAS("snd-hda-codec-id:8384*");
5580MODULE_ALIAS("snd-hda-codec-id:111d*");
5581
5582MODULE_LICENSE("GPL");
5583MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5584
5585static struct hda_codec_preset_list sigmatel_list = {
5586 .preset = snd_hda_preset_sigmatel,
5587 .owner = THIS_MODULE,
5588};
5589
5590static int __init patch_sigmatel_init(void)
5591{
5592 return snd_hda_add_codec_preset(&sigmatel_list);
5593}
5594
5595static void __exit patch_sigmatel_exit(void)
5596{
5597 snd_hda_delete_codec_preset(&sigmatel_list);
5598}
5599
5600module_init(patch_sigmatel_init)
5601module_exit(patch_sigmatel_exit)