blob: 66b1f3cfc87168dbf4a0ec05a118c49eb7a330e1 [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 {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010046 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010047 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010048 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020049 STAC_9200_DELL_D21,
50 STAC_9200_DELL_D22,
51 STAC_9200_DELL_D23,
52 STAC_9200_DELL_M21,
53 STAC_9200_DELL_M22,
54 STAC_9200_DELL_M23,
55 STAC_9200_DELL_M24,
56 STAC_9200_DELL_M25,
57 STAC_9200_DELL_M26,
58 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020059 STAC_9200_M4,
60 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010061 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010062 STAC_9200_MODELS
63};
64
65enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010066 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010067 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020068 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020069 STAC_9205_DELL_M43,
70 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010071 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010072 STAC_9205_MODELS
73};
74
75enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010076 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010077 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010078 STAC_92HD73XX_REF,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010079 STAC_DELL_M6_AMIC,
80 STAC_DELL_M6_DMIC,
81 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050082 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010083 STAC_92HD73XX_MODELS
84};
85
86enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010087 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020088 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050089 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050090 STAC_DELL_S14,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020091 STAC_92HD83XXX_MODELS
92};
93
94enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010095 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +010096 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010097 STAC_DELL_M4_1,
98 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050099 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400100 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100101 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100102 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400103 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100104 STAC_92HD71BXX_MODELS
105};
106
107enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100108 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100109 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200110 STAC_M1,
111 STAC_M1_2,
112 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100113 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200114 STAC_M3,
115 STAC_M5,
116 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100117 STAC_925x_MODELS
118};
119
120enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100121 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100122 STAC_D945_REF,
123 STAC_D945GTP3,
124 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200125 STAC_INTEL_MAC_V1,
126 STAC_INTEL_MAC_V2,
127 STAC_INTEL_MAC_V3,
128 STAC_INTEL_MAC_V4,
129 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800130 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
131 * is given, one of the above models will be
132 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200133 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100134 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100135 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100136 STAC_MACBOOK_PRO_V1,
137 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200138 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200139 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300140 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200141 STAC_922X_DELL_D81,
142 STAC_922X_DELL_D82,
143 STAC_922X_DELL_M81,
144 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100145 STAC_922X_MODELS
146};
147
148enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100149 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100150 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100151 STAC_D965_REF,
152 STAC_D965_3ST,
153 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200154 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200155 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100156 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100157 STAC_927X_MODELS
158};
Matt Porter403d1942005-11-29 15:00:51 +0100159
Takashi Iwai307282c2009-03-12 18:17:58 +0100160enum {
161 STAC_9872_AUTO,
162 STAC_9872_VAIO,
163 STAC_9872_MODELS
164};
165
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400166struct sigmatel_event {
167 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100168 unsigned char type;
169 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400170 int data;
171};
172
173struct sigmatel_jack {
174 hda_nid_t nid;
175 int type;
176 struct snd_jack *jack;
177};
178
Matt2f2f4252005-04-13 14:45:30 +0200179struct sigmatel_spec {
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100180 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200181 unsigned int num_mixers;
182
Matt Porter403d1942005-11-29 15:00:51 +0100183 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500184 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200185 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100186 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100187 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400188 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100189 unsigned int check_volume_offset:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200190
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100191 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200192 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100193 unsigned int gpio_mask;
194 unsigned int gpio_dir;
195 unsigned int gpio_data;
196 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200197 unsigned int gpio_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100198
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200199 /* stream */
200 unsigned int stream_delay;
201
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100202 /* analog loopback */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100203 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100204 unsigned char aloopback_mask;
205 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200206
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100207 /* power management */
208 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200209 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100210 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100211 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100212
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400213 /* jack detection */
214 struct snd_array jacks;
215
216 /* events */
217 struct snd_array events;
218
Matt2f2f4252005-04-13 14:45:30 +0200219 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100220 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400221 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100222 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200223 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100224 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100225 hda_nid_t hp_dacs[5];
226 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200227
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100228 int volume_offset;
229
Matt2f2f4252005-04-13 14:45:30 +0200230 /* capture */
231 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200232 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200233 hda_nid_t *mux_nids;
234 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200235 hda_nid_t *dmic_nids;
236 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100237 hda_nid_t *dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +0100238 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200239 hda_nid_t *smux_nids;
240 unsigned int num_smuxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200241
242 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
243 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
244 unsigned int num_caps; /* number of capture volume/switch elements */
245
Matthew Ranostay65973632008-09-16 10:39:37 -0400246 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200247
Mattdabbed62005-06-14 10:19:34 +0200248 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100249 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200250 hda_nid_t anabeep_nid;
251 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200252
Matt2f2f4252005-04-13 14:45:30 +0200253 /* pin widgets */
254 hda_nid_t *pin_nids;
255 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200256
257 /* codec specific stuff */
258 struct hda_verb *init;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100259 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200260
261 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200262 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100263 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200264 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100265 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200266 struct hda_input_mux *sinput_mux;
267 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400268 unsigned int cur_amux;
269 hda_nid_t *amp_nids;
270 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200271 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200272
Matt Porter403d1942005-11-29 15:00:51 +0100273 /* i/o switches */
274 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200275 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100276 hda_nid_t line_switch; /* shared line-in for input and output */
277 hda_nid_t mic_switch; /* shared mic-in for input and output */
278 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200279 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200280
Mattc7d4b2f2005-06-27 14:59:41 +0200281 struct hda_pcm pcm_rec[2]; /* PCM information */
282
283 /* dynamic controls and input_mux */
284 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200285 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200286 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200287 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200288 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400289 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100290 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200291};
292
293static hda_nid_t stac9200_adc_nids[1] = {
294 0x03,
295};
296
297static hda_nid_t stac9200_mux_nids[1] = {
298 0x0c,
299};
300
301static hda_nid_t stac9200_dac_nids[1] = {
302 0x02,
303};
304
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100305static hda_nid_t stac92hd73xx_pwr_nids[8] = {
306 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
307 0x0f, 0x10, 0x11
308};
309
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400310static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
311 0x26, 0,
312};
313
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100314static hda_nid_t stac92hd73xx_adc_nids[2] = {
315 0x1a, 0x1b
316};
317
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400318#define DELL_M6_AMP 2
319static hda_nid_t stac92hd73xx_amp_nids[3] = {
320 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400321};
322
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100323#define STAC92HD73XX_NUM_DMICS 2
324static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
325 0x13, 0x14, 0
326};
327
328#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100329
330static hda_nid_t stac92hd73xx_mux_nids[4] = {
331 0x28, 0x29, 0x2a, 0x2b,
332};
333
334static hda_nid_t stac92hd73xx_dmux_nids[2] = {
335 0x20, 0x21,
336};
337
Matthew Ranostayd9737752008-09-07 12:03:41 +0200338static hda_nid_t stac92hd73xx_smux_nids[2] = {
339 0x22, 0x23,
340};
341
Takashi Iwai6479c632009-07-28 18:20:25 +0200342#define STAC92HD73XX_NUM_CAPS 2
343static unsigned long stac92hd73xx_capvols[] = {
344 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
345 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
346};
347#define stac92hd73xx_capsws stac92hd73xx_capvols
348
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200349#define STAC92HD83XXX_NUM_DMICS 2
350static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
351 0x11, 0x12, 0
352};
353
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200354#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200355
356static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
357 0x17, 0x18,
358};
359
360static hda_nid_t stac92hd83xxx_adc_nids[2] = {
361 0x15, 0x16,
362};
363
364static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
365 0xa, 0xb, 0xd, 0xe,
366};
367
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400368static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
369 0x1e, 0,
370};
371
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200372static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500373 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200374};
375
Takashi Iwai9248f262009-01-14 09:40:25 +0100376static hda_nid_t stac92hd83xxx_amp_nids[1] = {
Matthew Ranostayc15c5062009-01-13 13:30:07 -0500377 0xc,
378};
379
Takashi Iwai6479c632009-07-28 18:20:25 +0200380#define STAC92HD83XXX_NUM_CAPS 2
381static unsigned long stac92hd83xxx_capvols[] = {
382 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
383 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
384};
385#define stac92hd83xxx_capsws stac92hd83xxx_capvols
386
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100387static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
388 0x0a, 0x0d, 0x0f
389};
390
Matthew Ranostaye035b842007-11-06 11:53:55 +0100391static hda_nid_t stac92hd71bxx_adc_nids[2] = {
392 0x12, 0x13,
393};
394
395static hda_nid_t stac92hd71bxx_mux_nids[2] = {
396 0x1a, 0x1b
397};
398
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400399static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
400 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100401};
402
Matthew Ranostayd9737752008-09-07 12:03:41 +0200403static hda_nid_t stac92hd71bxx_smux_nids[2] = {
404 0x24, 0x25,
405};
406
Matthew Ranostaye035b842007-11-06 11:53:55 +0100407#define STAC92HD71BXX_NUM_DMICS 2
408static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
409 0x18, 0x19, 0
410};
411
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400412static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
413 0x22, 0
414};
415
Takashi Iwai6479c632009-07-28 18:20:25 +0200416#define STAC92HD71BXX_NUM_CAPS 2
417static unsigned long stac92hd71bxx_capvols[] = {
418 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
419 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
420};
421#define stac92hd71bxx_capsws stac92hd71bxx_capvols
422
Tobin Davis8e21c342007-01-08 11:04:17 +0100423static hda_nid_t stac925x_adc_nids[1] = {
424 0x03,
425};
426
427static hda_nid_t stac925x_mux_nids[1] = {
428 0x0f,
429};
430
431static hda_nid_t stac925x_dac_nids[1] = {
432 0x02,
433};
434
Takashi Iwaif6e98522007-10-16 14:27:04 +0200435#define STAC925X_NUM_DMICS 1
436static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
437 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200438};
439
Takashi Iwai16970552007-12-18 18:05:52 +0100440static hda_nid_t stac925x_dmux_nids[1] = {
441 0x14,
442};
443
Takashi Iwai6479c632009-07-28 18:20:25 +0200444static unsigned long stac925x_capvols[] = {
445 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
446};
447static unsigned long stac925x_capsws[] = {
448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
449};
450
Matt2f2f4252005-04-13 14:45:30 +0200451static hda_nid_t stac922x_adc_nids[2] = {
452 0x06, 0x07,
453};
454
455static hda_nid_t stac922x_mux_nids[2] = {
456 0x12, 0x13,
457};
458
Takashi Iwai6479c632009-07-28 18:20:25 +0200459#define STAC922X_NUM_CAPS 2
460static unsigned long stac922x_capvols[] = {
461 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
462 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
463};
464#define stac922x_capsws stac922x_capvols
465
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500466static hda_nid_t stac927x_slave_dig_outs[2] = {
467 0x1f, 0,
468};
469
Matt Porter3cc08dc2006-01-23 15:27:49 +0100470static hda_nid_t stac927x_adc_nids[3] = {
471 0x07, 0x08, 0x09
472};
473
474static hda_nid_t stac927x_mux_nids[3] = {
475 0x15, 0x16, 0x17
476};
477
Matthew Ranostayd9737752008-09-07 12:03:41 +0200478static hda_nid_t stac927x_smux_nids[1] = {
479 0x21,
480};
481
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100482static hda_nid_t stac927x_dac_nids[6] = {
483 0x02, 0x03, 0x04, 0x05, 0x06, 0
484};
485
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100486static hda_nid_t stac927x_dmux_nids[1] = {
487 0x1b,
488};
489
Matthew Ranostay7f168592007-10-18 17:38:17 +0200490#define STAC927X_NUM_DMICS 2
491static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
492 0x13, 0x14, 0
493};
494
Takashi Iwai6479c632009-07-28 18:20:25 +0200495#define STAC927X_NUM_CAPS 3
496static unsigned long stac927x_capvols[] = {
497 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
500};
501static unsigned long stac927x_capsws[] = {
502 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
505};
506
Matthew Ranostay65973632008-09-16 10:39:37 -0400507static const char *stac927x_spdif_labels[5] = {
508 "Digital Playback", "ADAT", "Analog Mux 1",
509 "Analog Mux 2", "Analog Mux 3"
510};
511
Matt Porterf3302a52006-07-31 12:49:34 +0200512static hda_nid_t stac9205_adc_nids[2] = {
513 0x12, 0x13
514};
515
516static hda_nid_t stac9205_mux_nids[2] = {
517 0x19, 0x1a
518};
519
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100520static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai16970552007-12-18 18:05:52 +0100521 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522};
523
Matthew Ranostayd9737752008-09-07 12:03:41 +0200524static hda_nid_t stac9205_smux_nids[1] = {
525 0x21,
526};
527
Takashi Iwaif6e98522007-10-16 14:27:04 +0200528#define STAC9205_NUM_DMICS 2
529static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
530 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200531};
532
Takashi Iwai6479c632009-07-28 18:20:25 +0200533#define STAC9205_NUM_CAPS 2
534static unsigned long stac9205_capvols[] = {
535 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
536 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
537};
538static unsigned long stac9205_capsws[] = {
539 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
541};
542
Mattc7d4b2f2005-06-27 14:59:41 +0200543static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200544 0x08, 0x09, 0x0d, 0x0e,
545 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200546};
547
Tobin Davis8e21c342007-01-08 11:04:17 +0100548static hda_nid_t stac925x_pin_nids[8] = {
549 0x07, 0x08, 0x0a, 0x0b,
550 0x0c, 0x0d, 0x10, 0x11,
551};
552
Matt2f2f4252005-04-13 14:45:30 +0200553static hda_nid_t stac922x_pin_nids[10] = {
554 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
555 0x0f, 0x10, 0x11, 0x15, 0x1b,
556};
557
Matthew Ranostaya7662642008-02-21 07:51:14 +0100558static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100562};
563
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500564static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500566 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200567};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500568
569#define STAC92HD71BXX_NUM_PINS 13
570static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
571 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
572 0x00, 0x14, 0x18, 0x19, 0x1e,
573 0x1f, 0x20, 0x27
574};
575static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100576 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
577 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500578 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100579};
580
Matt Porter3cc08dc2006-01-23 15:27:49 +0100581static hda_nid_t stac927x_pin_nids[14] = {
582 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
583 0x0f, 0x10, 0x11, 0x12, 0x13,
584 0x14, 0x21, 0x22, 0x23,
585};
586
Matt Porterf3302a52006-07-31 12:49:34 +0200587static hda_nid_t stac9205_pin_nids[12] = {
588 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
589 0x0f, 0x14, 0x16, 0x17, 0x18,
590 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200591};
592
Matthew Ranostay89385032008-09-11 09:49:39 -0400593#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
594
595static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
597{
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
601
602 kcontrol->private_value ^= get_amp_nid(kcontrol);
603 kcontrol->private_value |= nid;
604
605 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
606}
607
608static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
610{
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
613 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
614
615 kcontrol->private_value ^= get_amp_nid(kcontrol);
616 kcontrol->private_value |= nid;
617
618 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
619}
620
Matt Porter8b657272006-10-26 17:12:59 +0200621static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_info *uinfo)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
627}
628
629static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
630 struct snd_ctl_elem_value *ucontrol)
631{
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100634 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200635
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100636 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200637 return 0;
638}
639
640static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100645 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200646
647 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100648 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200649}
650
Matthew Ranostayd9737752008-09-07 12:03:41 +0200651static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_info *uinfo)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
657}
658
659static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
661{
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 struct sigmatel_spec *spec = codec->spec;
664 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
665
666 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
667 return 0;
668}
669
670static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
672{
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400675 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200676 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400677 int err, val;
678 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200679
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400680 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200681 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400682 if (err < 0)
683 return err;
684
685 if (spec->spdif_mute) {
686 if (smux_idx == 0)
687 nid = spec->multiout.dig_out_nid;
688 else
689 nid = codec->slave_dig_outs[smux_idx - 1];
690 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100691 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400692 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100693 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400694 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100695 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
696 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400697 }
698 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200699}
700
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200701static unsigned int stac92xx_vref_set(struct hda_codec *codec,
702 hda_nid_t nid, unsigned int new_vref)
703{
Takashi Iwaib8621512009-06-22 08:00:10 +0200704 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200705 unsigned int pincfg;
706 pincfg = snd_hda_codec_read(codec, nid, 0,
707 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
708
709 pincfg &= 0xff;
710 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
711 pincfg |= new_vref;
712
713 if (new_vref == AC_PINCTL_VREF_HIZ)
714 pincfg |= AC_PINCTL_OUT_EN;
715 else
716 pincfg |= AC_PINCTL_IN_EN;
717
718 error = snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
720 if (error < 0)
721 return error;
722 else
723 return 1;
724}
725
726static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
727{
728 unsigned int vref;
729 vref = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
731 vref &= AC_PINCTL_VREFEN;
732 return vref;
733}
734
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100735static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200736{
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200739 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200740}
741
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100742static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200743{
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 struct sigmatel_spec *spec = codec->spec;
746 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
747
748 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
749 return 0;
750}
751
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100752static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200753{
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 struct sigmatel_spec *spec = codec->spec;
756 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
757
Mattc7d4b2f2005-06-27 14:59:41 +0200758 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200759 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
760}
761
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100762static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
763 struct snd_ctl_elem_info *uinfo)
764{
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 struct sigmatel_spec *spec = codec->spec;
767 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
768}
769
770static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
771 struct snd_ctl_elem_value *ucontrol)
772{
773 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
774 struct sigmatel_spec *spec = codec->spec;
775
776 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
777 return 0;
778}
779
780static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
781 struct snd_ctl_elem_value *ucontrol)
782{
783 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
784 struct sigmatel_spec *spec = codec->spec;
785
786 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
787 spec->mono_nid, &spec->cur_mmux);
788}
789
Matthew Ranostay89385032008-09-11 09:49:39 -0400790static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_info *uinfo)
792{
793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
794 struct sigmatel_spec *spec = codec->spec;
795 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
796}
797
798static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
799 struct snd_ctl_elem_value *ucontrol)
800{
801 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
802 struct sigmatel_spec *spec = codec->spec;
803
804 ucontrol->value.enumerated.item[0] = spec->cur_amux;
805 return 0;
806}
807
808static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
809 struct snd_ctl_elem_value *ucontrol)
810{
811 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
812 struct sigmatel_spec *spec = codec->spec;
813 struct snd_kcontrol *ctl =
814 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
815 if (!ctl)
816 return -EINVAL;
817
818 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
819 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
820
821 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
822 0, &spec->cur_amux);
823}
824
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200825#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
826
827static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
828 struct snd_ctl_elem_value *ucontrol)
829{
830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100831 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200832 struct sigmatel_spec *spec = codec->spec;
833
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 ucontrol->value.integer.value[0] = !!(spec->aloopback &
835 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200836 return 0;
837}
838
839static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
840 struct snd_ctl_elem_value *ucontrol)
841{
842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
843 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100844 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200845 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100846 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200847
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100848 idx_val = spec->aloopback_mask << idx;
849 if (ucontrol->value.integer.value[0])
850 val = spec->aloopback | idx_val;
851 else
852 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100853 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200854 return 0;
855
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100856 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200857
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100858 /* Only return the bits defined by the shift value of the
859 * first two bytes of the mask
860 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200861 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100862 kcontrol->private_value & 0xFFFF, 0x0);
863 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200864
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100865 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200866 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100867 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200868 } else {
869 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100870 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200871 }
872
873 snd_hda_codec_write_cache(codec, codec->afg, 0,
874 kcontrol->private_value >> 16, dac_mode);
875
876 return 1;
877}
878
Mattc7d4b2f2005-06-27 14:59:41 +0200879static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200880 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200881 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200882 {}
883};
884
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200885static struct hda_verb stac9200_eapd_init[] = {
886 /* set dac0mux for dac converter */
887 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
888 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
889 {}
890};
891
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100892static struct hda_verb stac92hd73xx_6ch_core_init[] = {
893 /* set master volume and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100895 /* setup adcs to point to mixer */
896 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
897 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100898 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
899 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
900 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
901 /* setup import muxs */
902 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
903 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
904 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
905 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
906 {}
907};
908
Matthew Ranostayd654a662008-03-14 08:46:51 +0100909static struct hda_verb dell_eq_core_init[] = {
910 /* set master volume to max value without distortion
911 * and direct control */
912 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100913 /* setup adcs to point to mixer */
914 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
915 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
916 /* setup import muxs */
917 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
918 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
919 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
920 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
921 {}
922};
923
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100924static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500925 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100926 /* setup adcs to point to mixer */
927 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
928 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
929 /* setup import muxs */
930 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
931 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
932 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
933 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
934 {}
935};
936
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100937static struct hda_verb stac92hd73xx_8ch_core_init[] = {
938 /* set master volume and direct control */
939 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100940 /* setup adcs to point to mixer */
941 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
942 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100943 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
944 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
945 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
946 /* setup import muxs */
947 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
948 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
949 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
950 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
951 {}
952};
953
954static struct hda_verb stac92hd73xx_10ch_core_init[] = {
955 /* set master volume and direct control */
956 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100957 /* dac3 is connected to import3 mux */
958 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100959 /* setup adcs to point to mixer */
960 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
961 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100962 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
963 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
964 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
965 /* setup import muxs */
966 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
967 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
968 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
969 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
970 {}
971};
972
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200973static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500974 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
975 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
976 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200977
978 /* power state controls amps */
979 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200980 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200981};
982
Matthew Ranostaye035b842007-11-06 11:53:55 +0100983static struct hda_verb stac92hd71bxx_core_init[] = {
984 /* set master volume and direct control */
985 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200986 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100987};
988
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500989#define HD_DISABLE_PORTF 1
Matthew Ranostay541eee82007-12-14 12:08:04 +0100990static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200991 /* start of config #1 */
992
993 /* connect port 0f to audio mixer */
994 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200995 /* start of config #2 */
996
Matthew Ranostay541eee82007-12-14 12:08:04 +0100997 /* set master volume and direct control */
998 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500999 {}
1000};
1001
1002static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
1003 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
1004 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +01001005 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1006 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +01001007 {}
1008};
1009
Tobin Davis8e21c342007-01-08 11:04:17 +01001010static struct hda_verb stac925x_core_init[] = {
1011 /* set dac0mux for dac converter */
1012 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +01001013 /* mute the master volume */
1014 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +01001015 {}
1016};
1017
Mattc7d4b2f2005-06-27 14:59:41 +02001018static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +02001019 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +02001020 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +02001021 {}
1022};
1023
Tobin Davis93ed1502006-09-01 21:03:12 +02001024static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02001025 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +02001026 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +02001027 /* unmute node 0x1b */
1028 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1029 /* select node 0x03 as DAC */
1030 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1031 {}
1032};
1033
Matt Porter3cc08dc2006-01-23 15:27:49 +01001034static struct hda_verb stac927x_core_init[] = {
1035 /* set master volume and direct control */
1036 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001037 /* enable analog pc beep path */
1038 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +01001039 {}
1040};
1041
Matt Porterf3302a52006-07-31 12:49:34 +02001042static struct hda_verb stac9205_core_init[] = {
1043 /* set master volume and direct control */
1044 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001045 /* enable analog pc beep path */
1046 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +02001047 {}
1048};
1049
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001050#define STAC_MONO_MUX \
1051 { \
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1053 .name = "Mono Mux", \
1054 .count = 1, \
1055 .info = stac92xx_mono_mux_enum_info, \
1056 .get = stac92xx_mono_mux_enum_get, \
1057 .put = stac92xx_mono_mux_enum_put, \
1058 }
1059
Matthew Ranostay89385032008-09-11 09:49:39 -04001060#define STAC_AMP_MUX \
1061 { \
1062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1063 .name = "Amp Selector Capture Switch", \
1064 .count = 1, \
1065 .info = stac92xx_amp_mux_enum_info, \
1066 .get = stac92xx_amp_mux_enum_get, \
1067 .put = stac92xx_amp_mux_enum_put, \
1068 }
1069
1070#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1071 { \
1072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1073 .name = xname, \
1074 .index = 0, \
1075 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1076 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1077 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1078 .info = stac92xx_amp_volume_info, \
1079 .get = stac92xx_amp_volume_get, \
1080 .put = stac92xx_amp_volume_put, \
1081 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1082 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1083 }
1084
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001085#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001086 { \
1087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1088 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001089 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001090 .info = stac92xx_aloopback_info, \
1091 .get = stac92xx_aloopback_get, \
1092 .put = stac92xx_aloopback_put, \
1093 .private_value = verb_read | (verb_write << 16), \
1094 }
1095
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001096#define DC_BIAS(xname, idx, nid) \
1097 { \
1098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1099 .name = xname, \
1100 .index = idx, \
1101 .info = stac92xx_dc_bias_info, \
1102 .get = stac92xx_dc_bias_get, \
1103 .put = stac92xx_dc_bias_put, \
1104 .private_value = nid, \
1105 }
1106
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001107static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +02001108 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1109 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001110 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001112 { } /* end */
1113};
1114
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001115#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001116static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04001117 /* start of config #1 */
1118 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1119 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1120
1121 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1122 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1123
1124 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1125 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1126
1127 /* start of config #2 */
1128 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1129 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1130
1131 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1132 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1133
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001134 { } /* end */
1135};
1136
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001137static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1138 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1139 {}
1140};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001141
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001142static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1143 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1144 {}
1145};
1146
1147static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1148 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1149 {}
1150};
1151
1152static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001153 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1154 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1155
1156 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1157 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1158
1159 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1160 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1161
1162 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1163 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1164
1165 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1166 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1167 { } /* end */
1168};
1169
1170static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001171 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1172 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1173
1174 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1175 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1176
1177 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1178 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1179
1180 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1181 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1182
1183 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1184 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1185 { } /* end */
1186};
1187
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001188
1189static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001190 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1191 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001192
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001193 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1194 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001195
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001196 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1197 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001198
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001199 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1200 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001201
1202 /*
Matthew Ranostay74b7ff42008-12-20 17:47:24 -05001203 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1204 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001205 */
1206 { } /* end */
1207};
1208
Matthew Ranostay541eee82007-12-14 12:08:04 +01001209static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostay687cb98e2008-10-11 13:52:43 -04001210 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001212
Matthew Ranostay687cb98e2008-10-11 13:52:43 -04001213 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1214 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001215
1216 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1217 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1218
1219 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1220 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001221 { } /* end */
1222};
1223
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001224static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1225 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1226};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001227
Tobin Davis8e21c342007-01-08 11:04:17 +01001228static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001229 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1230 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001231 { } /* end */
1232};
1233
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001234static struct snd_kcontrol_new stac9205_loopback[] = {
1235 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1236 {}
1237};
1238
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001239static struct snd_kcontrol_new stac927x_loopback[] = {
1240 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1241 {}
1242};
1243
Takashi Iwai16970552007-12-18 18:05:52 +01001244static struct snd_kcontrol_new stac_dmux_mixer = {
1245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1246 .name = "Digital Input Source",
1247 /* count set later */
1248 .info = stac92xx_dmux_enum_info,
1249 .get = stac92xx_dmux_enum_get,
1250 .put = stac92xx_dmux_enum_put,
1251};
1252
Matthew Ranostayd9737752008-09-07 12:03:41 +02001253static struct snd_kcontrol_new stac_smux_mixer = {
1254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001255 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001256 /* count set later */
1257 .info = stac92xx_smux_enum_info,
1258 .get = stac92xx_smux_enum_get,
1259 .put = stac92xx_smux_enum_put,
1260};
1261
Takashi Iwai2134ea42008-01-10 16:53:55 +01001262static const char *slave_vols[] = {
1263 "Front Playback Volume",
1264 "Surround Playback Volume",
1265 "Center Playback Volume",
1266 "LFE Playback Volume",
1267 "Side Playback Volume",
1268 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001269 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001270 NULL
1271};
1272
1273static const char *slave_sws[] = {
1274 "Front Playback Switch",
1275 "Surround Playback Switch",
1276 "Center Playback Switch",
1277 "LFE Playback Switch",
1278 "Side Playback Switch",
1279 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001280 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001281 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001282 NULL
1283};
1284
Takashi Iwai603c4012008-07-30 15:01:44 +02001285static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001286static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001287
Matt2f2f4252005-04-13 14:45:30 +02001288static int stac92xx_build_controls(struct hda_codec *codec)
1289{
1290 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001291 struct auto_pin_cfg *cfg = &spec->autocfg;
1292 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001293 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001294 int i;
Matt2f2f4252005-04-13 14:45:30 +02001295
Takashi Iwai6479c632009-07-28 18:20:25 +02001296 if (spec->mixer) {
1297 err = snd_hda_add_new_ctls(codec, spec->mixer);
1298 if (err < 0)
1299 return err;
1300 }
Mattc7d4b2f2005-06-27 14:59:41 +02001301
1302 for (i = 0; i < spec->num_mixers; i++) {
1303 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1304 if (err < 0)
1305 return err;
1306 }
Takashi Iwai16970552007-12-18 18:05:52 +01001307 if (spec->num_dmuxes > 0) {
1308 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001309 err = snd_hda_ctl_add(codec,
Takashi Iwai16970552007-12-18 18:05:52 +01001310 snd_ctl_new1(&stac_dmux_mixer, codec));
1311 if (err < 0)
1312 return err;
1313 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001314 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001315 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1316 struct hda_input_mux *smux = &spec->private_smux;
1317 /* check for mute support on SPDIF out */
1318 if (wcaps & AC_WCAP_OUT_AMP) {
1319 smux->items[smux->num_items].label = "Off";
1320 smux->items[smux->num_items].index = 0;
1321 smux->num_items++;
1322 spec->spdif_mute = 1;
1323 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001324 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001325 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001326 snd_ctl_new1(&stac_smux_mixer, codec));
1327 if (err < 0)
1328 return err;
1329 }
Mattc7d4b2f2005-06-27 14:59:41 +02001330
Mattdabbed62005-06-14 10:19:34 +02001331 if (spec->multiout.dig_out_nid) {
1332 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1333 if (err < 0)
1334 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001335 err = snd_hda_create_spdif_share_sw(codec,
1336 &spec->multiout);
1337 if (err < 0)
1338 return err;
1339 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001340 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001341 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001342 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1343 if (err < 0)
1344 return err;
1345 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001346
1347 /* if we have no master control, let's create it */
1348 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001349 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001350 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001351 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001352 /* correct volume offset */
1353 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001354 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001355 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001356 if (err < 0)
1357 return err;
1358 }
1359 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1360 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1361 NULL, slave_sws);
1362 if (err < 0)
1363 return err;
1364 }
1365
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001366 if (spec->aloopback_ctl &&
1367 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1368 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1369 if (err < 0)
1370 return err;
1371 }
1372
Takashi Iwai603c4012008-07-30 15:01:44 +02001373 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001374
1375 /* create jack input elements */
1376 if (spec->hp_detect) {
1377 for (i = 0; i < cfg->hp_outs; i++) {
1378 int type = SND_JACK_HEADPHONE;
1379 nid = cfg->hp_pins[i];
1380 /* jack detection */
1381 if (cfg->hp_outs == i)
1382 type |= SND_JACK_LINEOUT;
1383 err = stac92xx_add_jack(codec, nid, type);
1384 if (err < 0)
1385 return err;
1386 }
1387 }
1388 for (i = 0; i < cfg->line_outs; i++) {
1389 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1390 SND_JACK_LINEOUT);
1391 if (err < 0)
1392 return err;
1393 }
1394 for (i = 0; i < AUTO_PIN_LAST; i++) {
1395 nid = cfg->input_pins[i];
1396 if (nid) {
1397 err = stac92xx_add_jack(codec, nid,
1398 SND_JACK_MICROPHONE);
1399 if (err < 0)
1400 return err;
1401 }
1402 }
1403
Mattdabbed62005-06-14 10:19:34 +02001404 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001405}
1406
Matt Porter403d1942005-11-29 15:00:51 +01001407static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001408 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001409 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1410};
1411
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001412static unsigned int gateway9200_m4_pin_configs[8] = {
1413 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1414 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1415};
1416static unsigned int gateway9200_m4_2_pin_configs[8] = {
1417 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1418 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1419};
1420
1421/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001422 STAC 9200 pin configs for
1423 102801A8
1424 102801DE
1425 102801E8
1426*/
1427static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001428 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1429 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001430};
1431
1432/*
1433 STAC 9200 pin configs for
1434 102801C0
1435 102801C1
1436*/
1437static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001438 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1439 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001440};
1441
1442/*
1443 STAC 9200 pin configs for
1444 102801C4 (Dell Dimension E310)
1445 102801C5
1446 102801C7
1447 102801D9
1448 102801DA
1449 102801E3
1450*/
1451static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001452 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1453 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001454};
1455
1456
1457/*
1458 STAC 9200-32 pin configs for
1459 102801B5 (Dell Inspiron 630m)
1460 102801D8 (Dell Inspiron 640m)
1461*/
1462static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001463 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1464 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001465};
1466
1467/*
1468 STAC 9200-32 pin configs for
1469 102801C2 (Dell Latitude D620)
1470 102801C8
1471 102801CC (Dell Latitude D820)
1472 102801D4
1473 102801D6
1474*/
1475static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001476 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1477 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001478};
1479
1480/*
1481 STAC 9200-32 pin configs for
1482 102801CE (Dell XPS M1710)
1483 102801CF (Dell Precision M90)
1484*/
1485static unsigned int dell9200_m23_pin_configs[8] = {
1486 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1487 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1488};
1489
1490/*
1491 STAC 9200-32 pin configs for
1492 102801C9
1493 102801CA
1494 102801CB (Dell Latitude 120L)
1495 102801D3
1496*/
1497static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001498 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1499 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001500};
1501
1502/*
1503 STAC 9200-32 pin configs for
1504 102801BD (Dell Inspiron E1505n)
1505 102801EE
1506 102801EF
1507*/
1508static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001509 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1510 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001511};
1512
1513/*
1514 STAC 9200-32 pin configs for
1515 102801F5 (Dell Inspiron 1501)
1516 102801F6
1517*/
1518static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001519 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1520 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001521};
1522
1523/*
1524 STAC 9200-32
1525 102801CD (Dell Inspiron E1705/9400)
1526*/
1527static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001528 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1529 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001530};
1531
Tobin Davisbf277782008-02-03 20:31:47 +01001532static unsigned int oqo9200_pin_configs[8] = {
1533 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1534 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1535};
1536
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001537
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001538static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1539 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001540 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001541 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1542 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1543 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1544 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1545 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1546 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1547 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1548 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1549 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1550 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001551 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1552 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001553 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001554};
1555
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001556static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001557 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001558 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001559 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001560 [STAC_9200_DELL_D21] = "dell-d21",
1561 [STAC_9200_DELL_D22] = "dell-d22",
1562 [STAC_9200_DELL_D23] = "dell-d23",
1563 [STAC_9200_DELL_M21] = "dell-m21",
1564 [STAC_9200_DELL_M22] = "dell-m22",
1565 [STAC_9200_DELL_M23] = "dell-m23",
1566 [STAC_9200_DELL_M24] = "dell-m24",
1567 [STAC_9200_DELL_M25] = "dell-m25",
1568 [STAC_9200_DELL_M26] = "dell-m26",
1569 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001570 [STAC_9200_M4] = "gateway-m4",
1571 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001572 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001573};
1574
1575static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1576 /* SigmaTel reference board */
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1578 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1580 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001581 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1583 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001585 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1587 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1589 "unknown Dell", STAC_9200_DELL_D22),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1591 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001593 "Dell Latitude D620", STAC_9200_DELL_M22),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1595 "unknown Dell", STAC_9200_DELL_D23),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1597 "unknown Dell", STAC_9200_DELL_D23),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1599 "unknown Dell", STAC_9200_DELL_M22),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1601 "unknown Dell", STAC_9200_DELL_M24),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1603 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001605 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001607 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001609 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001611 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001613 "Dell Precision M90", STAC_9200_DELL_M23),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1615 "unknown Dell", STAC_9200_DELL_M22),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1617 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001619 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001621 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1623 "unknown Dell", STAC_9200_DELL_D23),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1625 "unknown Dell", STAC_9200_DELL_D23),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1627 "unknown Dell", STAC_9200_DELL_D21),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1629 "unknown Dell", STAC_9200_DELL_D23),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1631 "unknown Dell", STAC_9200_DELL_D21),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1633 "unknown Dell", STAC_9200_DELL_M25),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1635 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001637 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1639 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001640 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001641 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001642 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001643 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1644 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1645 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001646 /* OQO Mobile */
1647 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001648 {} /* terminator */
1649};
1650
Tobin Davis8e21c342007-01-08 11:04:17 +01001651static unsigned int ref925x_pin_configs[8] = {
1652 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001653 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001654};
1655
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001656static unsigned int stac925xM1_pin_configs[8] = {
1657 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1658 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001659};
1660
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001661static unsigned int stac925xM1_2_pin_configs[8] = {
1662 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1663 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1664};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001665
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001666static unsigned int stac925xM2_pin_configs[8] = {
1667 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1668 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001669};
1670
Tobin Davis8e21c342007-01-08 11:04:17 +01001671static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001672 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1673 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1674};
1675
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001676static unsigned int stac925xM3_pin_configs[8] = {
1677 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1678 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1679};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001680
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001681static unsigned int stac925xM5_pin_configs[8] = {
1682 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1683 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1684};
1685
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001686static unsigned int stac925xM6_pin_configs[8] = {
1687 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1688 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001689};
1690
1691static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1692 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001693 [STAC_M1] = stac925xM1_pin_configs,
1694 [STAC_M1_2] = stac925xM1_2_pin_configs,
1695 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001696 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001697 [STAC_M3] = stac925xM3_pin_configs,
1698 [STAC_M5] = stac925xM5_pin_configs,
1699 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001700};
1701
1702static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001703 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001704 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001705 [STAC_M1] = "m1",
1706 [STAC_M1_2] = "m1-2",
1707 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001708 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001709 [STAC_M3] = "m3",
1710 [STAC_M5] = "m5",
1711 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001712};
1713
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001714static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001715 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1716 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1717 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1718 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001719 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001720 /* Not sure about the brand name for those */
1721 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1722 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1723 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1724 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001725 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001726};
1727
1728static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1729 /* SigmaTel reference board */
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001731 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001732 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001733
1734 /* Default table for unknown ID */
1735 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1736
Tobin Davis8e21c342007-01-08 11:04:17 +01001737 {} /* terminator */
1738};
1739
Matthew Ranostaya7662642008-02-21 07:51:14 +01001740static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001741 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1742 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1743 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001744 0x01452050,
1745};
1746
1747static unsigned int dell_m6_pin_configs[13] = {
1748 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001749 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001750 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1751 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001752};
1753
1754static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001755 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001756 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1757 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1758 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001759 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001760};
1761
1762static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001763 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001764 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001765 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001766 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1767 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1768 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001769 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001770};
1771
1772static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1773 /* SigmaTel reference board */
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001775 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001776 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1777 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001779 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001781 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001783 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001785 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001787 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001789 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001791 "unknown Dell", STAC_DELL_M6_DMIC),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1793 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001795 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1797 "Dell Studio 17", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001798 {} /* terminator */
1799};
1800
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001801static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001802 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1803 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001804 0x01451160, 0x98560170,
1805};
1806
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001807static unsigned int dell_s14_pin_configs[10] = {
1808 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1809 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1810 0x40f000f0, 0x40f000f0,
1811};
1812
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001813static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1814 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001815 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001816 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001817};
1818
1819static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001820 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001821 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001822 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001823 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001824};
1825
1826static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1827 /* SigmaTel reference board */
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001829 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001830 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1831 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1833 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001834 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001835};
1836
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001837static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001838 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001839 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001840 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1841 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001842};
1843
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001844static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001845 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001846 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001847 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1848 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001849};
1850
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001851static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001852 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1853 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001854 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1855 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001856};
1857
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001858static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001859 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1860 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001861 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1862 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001863};
1864
Matthew Ranostaye035b842007-11-06 11:53:55 +01001865static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1866 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001867 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1868 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001869 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001870 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001871 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001872 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001873 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001874};
1875
1876static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001877 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001878 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001879 [STAC_DELL_M4_1] = "dell-m4-1",
1880 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001881 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001882 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001883 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001884 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001885 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001886};
1887
1888static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1889 /* SigmaTel reference board */
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1891 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001892 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1893 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001894 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1895 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Takashi Iwai58d83952009-03-13 17:04:34 +01001896 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1897 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001898 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1899 "HP dv4-7", STAC_HP_DV5),
1900 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1901 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001902 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1903 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001904 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001905 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001906 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001907 "HP HDX", STAC_HP_HDX), /* HDX16 */
Matthew Ranostaya7662642008-02-21 07:51:14 +01001908 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1909 "unknown Dell", STAC_DELL_M4_1),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1911 "unknown Dell", STAC_DELL_M4_1),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1913 "unknown Dell", STAC_DELL_M4_1),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1915 "unknown Dell", STAC_DELL_M4_1),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1917 "unknown Dell", STAC_DELL_M4_1),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1919 "unknown Dell", STAC_DELL_M4_1),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1921 "unknown Dell", STAC_DELL_M4_1),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1923 "unknown Dell", STAC_DELL_M4_2),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1925 "unknown Dell", STAC_DELL_M4_2),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1927 "unknown Dell", STAC_DELL_M4_2),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1929 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1931 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001932 {} /* terminator */
1933};
1934
Matt Porter403d1942005-11-29 15:00:51 +01001935static unsigned int ref922x_pin_configs[10] = {
1936 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1937 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001938 0x40000100, 0x40000100,
1939};
1940
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001941/*
1942 STAC 922X pin configs for
1943 102801A7
1944 102801AB
1945 102801A9
1946 102801D1
1947 102801D2
1948*/
1949static unsigned int dell_922x_d81_pin_configs[10] = {
1950 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1951 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1952 0x01813122, 0x400001f2,
1953};
1954
1955/*
1956 STAC 922X pin configs for
1957 102801AC
1958 102801D0
1959*/
1960static unsigned int dell_922x_d82_pin_configs[10] = {
1961 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1962 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1963 0x01813122, 0x400001f1,
1964};
1965
1966/*
1967 STAC 922X pin configs for
1968 102801BF
1969*/
1970static unsigned int dell_922x_m81_pin_configs[10] = {
1971 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1972 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1973 0x40C003f1, 0x405003f0,
1974};
1975
1976/*
1977 STAC 9221 A1 pin configs for
1978 102801D7 (Dell XPS M1210)
1979*/
1980static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001981 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1982 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001983 0x508003f3, 0x405003f4,
1984};
1985
Matt Porter403d1942005-11-29 15:00:51 +01001986static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001987 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001988 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1989 0x02a19120, 0x40000100,
1990};
1991
1992static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001993 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1994 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001995 0x02a19320, 0x40000100,
1996};
1997
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001998static unsigned int intel_mac_v1_pin_configs[10] = {
1999 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2000 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002001 0x400000fc, 0x400000fb,
2002};
2003
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002004static unsigned int intel_mac_v2_pin_configs[10] = {
2005 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2006 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02002007 0x400000fc, 0x400000fb,
2008};
2009
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002010static unsigned int intel_mac_v3_pin_configs[10] = {
2011 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2012 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2013 0x400000fc, 0x400000fb,
2014};
2015
2016static unsigned int intel_mac_v4_pin_configs[10] = {
2017 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2018 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2019 0x400000fc, 0x400000fb,
2020};
2021
2022static unsigned int intel_mac_v5_pin_configs[10] = {
2023 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2024 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2025 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002026};
2027
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002028static unsigned int ecs202_pin_configs[10] = {
2029 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2030 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2031 0x9037012e, 0x40e000f2,
2032};
Takashi Iwai76c08822007-06-19 12:17:42 +02002033
Takashi Iwai19039bd2006-06-28 15:52:16 +02002034static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002035 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002036 [STAC_D945GTP3] = d945gtp3_pin_configs,
2037 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002038 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2039 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2040 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2041 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2042 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002043 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002044 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002045 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2046 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2047 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2048 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2049 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2050 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002051 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002052 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2053 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2054 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2055 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01002056};
2057
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002058static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002059 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002060 [STAC_D945_REF] = "ref",
2061 [STAC_D945GTP5] = "5stack",
2062 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002063 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2064 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2065 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2066 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2067 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08002068 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002069 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002070 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002071 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002072 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2073 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02002074 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002075 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002076 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002077 [STAC_922X_DELL_D81] = "dell-d81",
2078 [STAC_922X_DELL_D82] = "dell-d82",
2079 [STAC_922X_DELL_M81] = "dell-m81",
2080 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002081};
2082
2083static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2084 /* SigmaTel reference board */
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2086 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002087 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2088 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002089 /* Intel 945G based systems */
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2091 "Intel D945G", STAC_D945GTP3),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2093 "Intel D945G", STAC_D945GTP3),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2095 "Intel D945G", STAC_D945GTP3),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2097 "Intel D945G", STAC_D945GTP3),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2099 "Intel D945G", STAC_D945GTP3),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2101 "Intel D945G", STAC_D945GTP3),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2103 "Intel D945G", STAC_D945GTP3),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2105 "Intel D945G", STAC_D945GTP3),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2107 "Intel D945G", STAC_D945GTP3),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2109 "Intel D945G", STAC_D945GTP3),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2111 "Intel D945G", STAC_D945GTP3),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2113 "Intel D945G", STAC_D945GTP3),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2115 "Intel D945G", STAC_D945GTP3),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2117 "Intel D945G", STAC_D945GTP3),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2119 "Intel D945G", STAC_D945GTP3),
2120 /* Intel D945G 5-stack systems */
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2122 "Intel D945G", STAC_D945GTP5),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2124 "Intel D945G", STAC_D945GTP5),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2126 "Intel D945G", STAC_D945GTP5),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2128 "Intel D945G", STAC_D945GTP5),
2129 /* Intel 945P based systems */
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2131 "Intel D945P", STAC_D945GTP3),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2133 "Intel D945P", STAC_D945GTP3),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2135 "Intel D945P", STAC_D945GTP3),
2136 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2137 "Intel D945P", STAC_D945GTP3),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2139 "Intel D945P", STAC_D945GTP3),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2141 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002142 /* other intel */
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2144 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002145 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002146 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002147 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002148 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002149 /* Dell systems */
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2151 "unknown Dell", STAC_922X_DELL_D81),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2153 "unknown Dell", STAC_922X_DELL_D81),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2155 "unknown Dell", STAC_922X_DELL_D81),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2157 "unknown Dell", STAC_922X_DELL_D82),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2159 "unknown Dell", STAC_922X_DELL_M81),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2161 "unknown Dell", STAC_922X_DELL_D82),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2163 "unknown Dell", STAC_922X_DELL_D81),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2165 "unknown Dell", STAC_922X_DELL_D81),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2167 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002168 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002169 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002170 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002171 {} /* terminator */
2172};
2173
Matt Porter3cc08dc2006-01-23 15:27:49 +01002174static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002175 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2176 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2177 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2178 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002179};
2180
Tobin Davis93ed1502006-09-01 21:03:12 +02002181static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002182 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2183 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2184 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2185 0x40000100, 0x40000100
2186};
2187
Tobin Davis93ed1502006-09-01 21:03:12 +02002188static unsigned int d965_5st_pin_configs[14] = {
2189 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2190 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2191 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2192 0x40000100, 0x40000100
2193};
2194
Takashi Iwai679d92e2009-05-24 19:00:08 +02002195static unsigned int d965_5st_no_fp_pin_configs[14] = {
2196 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2197 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2198 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2199 0x40000100, 0x40000100
2200};
2201
Tobin Davis4ff076e2007-08-07 11:48:12 +02002202static unsigned int dell_3st_pin_configs[14] = {
2203 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2204 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002205 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002206 0x40c003fc, 0x40000100
2207};
2208
Tobin Davis93ed1502006-09-01 21:03:12 +02002209static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002210 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002211 [STAC_D965_REF] = ref927x_pin_configs,
2212 [STAC_D965_3ST] = d965_3st_pin_configs,
2213 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002214 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002215 [STAC_DELL_3ST] = dell_3st_pin_configs,
2216 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002217};
2218
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002219static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002220 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002221 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002222 [STAC_D965_REF] = "ref",
2223 [STAC_D965_3ST] = "3stack",
2224 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002225 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002226 [STAC_DELL_3ST] = "dell-3stack",
2227 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002228};
2229
2230static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2231 /* SigmaTel reference board */
2232 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2233 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002234 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2235 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002236 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002237 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2238 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002239 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002240 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2241 "Intel D965", STAC_D965_3ST),
2242 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2243 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002244 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002245 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002246 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002247 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2248 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002249 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002250 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2251 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002258 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002259 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2260 "Intel D965", STAC_D965_5ST),
2261 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2262 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002263 {} /* terminator */
2264};
2265
Matt Porterf3302a52006-07-31 12:49:34 +02002266static unsigned int ref9205_pin_configs[12] = {
2267 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002268 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002269 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002270};
2271
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002272/*
2273 STAC 9205 pin configs for
2274 102801F1
2275 102801F2
2276 102801FC
2277 102801FD
2278 10280204
2279 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002280 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002281*/
2282static unsigned int dell_9205_m42_pin_configs[12] = {
2283 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2284 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2285 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2286};
2287
2288/*
2289 STAC 9205 pin configs for
2290 102801F9
2291 102801FA
2292 102801FE
2293 102801FF (Dell Precision M4300)
2294 10280206
2295 10280200
2296 10280201
2297*/
2298static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002299 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2300 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2301 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2302};
2303
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002304static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002305 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2306 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2307 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2308};
2309
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002310static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002311 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002312 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2313 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2314 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002315 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002316};
2317
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002318static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002319 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002320 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002321 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002322 [STAC_9205_DELL_M43] = "dell-m43",
2323 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002324 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002325};
2326
2327static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2328 /* SigmaTel reference board */
2329 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2330 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002331 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2332 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002333 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2334 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002335 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002336 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2337 "unknown Dell", STAC_9205_DELL_M42),
2338 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2339 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002340 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002341 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002342 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2343 "Dell Precision", STAC_9205_DELL_M43),
2344 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2345 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002346 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2347 "unknown Dell", STAC_9205_DELL_M42),
2348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2349 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2351 "Dell Precision", STAC_9205_DELL_M43),
2352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002353 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2355 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2357 "Dell Precision", STAC_9205_DELL_M43),
2358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2359 "Dell Precision", STAC_9205_DELL_M43),
2360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2361 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2363 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2365 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002366 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002367 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002368 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002369 {} /* terminator */
2370};
2371
Takashi Iwai330ee992009-02-20 14:33:36 +01002372static void stac92xx_set_config_regs(struct hda_codec *codec,
2373 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002374{
2375 int i;
2376 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002377
Takashi Iwai330ee992009-02-20 14:33:36 +01002378 if (!pincfgs)
2379 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002380
Matthew Ranostay87d48362007-07-17 11:52:24 +02002381 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002382 if (spec->pin_nids[i] && pincfgs[i])
2383 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2384 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002385}
2386
Matt2f2f4252005-04-13 14:45:30 +02002387/*
2388 * Analog playback callbacks
2389 */
2390static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2391 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002392 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002393{
2394 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002395 if (spec->stream_delay)
2396 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002397 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2398 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002399}
2400
2401static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2402 struct hda_codec *codec,
2403 unsigned int stream_tag,
2404 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002405 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002406{
2407 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002408 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002409}
2410
2411static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2412 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002413 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002414{
2415 struct sigmatel_spec *spec = codec->spec;
2416 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2417}
2418
2419/*
Mattdabbed62005-06-14 10:19:34 +02002420 * Digital playback callbacks
2421 */
2422static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2423 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002424 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002425{
2426 struct sigmatel_spec *spec = codec->spec;
2427 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2428}
2429
2430static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2431 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002432 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002433{
2434 struct sigmatel_spec *spec = codec->spec;
2435 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2436}
2437
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002438static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2439 struct hda_codec *codec,
2440 unsigned int stream_tag,
2441 unsigned int format,
2442 struct snd_pcm_substream *substream)
2443{
2444 struct sigmatel_spec *spec = codec->spec;
2445 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2446 stream_tag, format, substream);
2447}
2448
Takashi Iwai9411e212009-02-13 11:32:28 +01002449static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2450 struct hda_codec *codec,
2451 struct snd_pcm_substream *substream)
2452{
2453 struct sigmatel_spec *spec = codec->spec;
2454 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2455}
2456
Mattdabbed62005-06-14 10:19:34 +02002457
2458/*
Matt2f2f4252005-04-13 14:45:30 +02002459 * Analog capture callbacks
2460 */
2461static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2462 struct hda_codec *codec,
2463 unsigned int stream_tag,
2464 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002465 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002466{
2467 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002468 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002469
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002470 if (spec->powerdown_adcs) {
2471 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002472 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002473 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2474 }
2475 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002476 return 0;
2477}
2478
2479static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2480 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002481 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002482{
2483 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002484 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002485
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002486 snd_hda_codec_cleanup_stream(codec, nid);
2487 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002488 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002489 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002490 return 0;
2491}
2492
Mattdabbed62005-06-14 10:19:34 +02002493static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2494 .substreams = 1,
2495 .channels_min = 2,
2496 .channels_max = 2,
2497 /* NID is set in stac92xx_build_pcms */
2498 .ops = {
2499 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002500 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002501 .prepare = stac92xx_dig_playback_pcm_prepare,
2502 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002503 },
2504};
2505
2506static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2507 .substreams = 1,
2508 .channels_min = 2,
2509 .channels_max = 2,
2510 /* NID is set in stac92xx_build_pcms */
2511};
2512
Matt2f2f4252005-04-13 14:45:30 +02002513static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2514 .substreams = 1,
2515 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002516 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002517 .nid = 0x02, /* NID to query formats and rates */
2518 .ops = {
2519 .open = stac92xx_playback_pcm_open,
2520 .prepare = stac92xx_playback_pcm_prepare,
2521 .cleanup = stac92xx_playback_pcm_cleanup
2522 },
2523};
2524
Matt Porter3cc08dc2006-01-23 15:27:49 +01002525static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2526 .substreams = 1,
2527 .channels_min = 2,
2528 .channels_max = 2,
2529 .nid = 0x06, /* NID to query formats and rates */
2530 .ops = {
2531 .open = stac92xx_playback_pcm_open,
2532 .prepare = stac92xx_playback_pcm_prepare,
2533 .cleanup = stac92xx_playback_pcm_cleanup
2534 },
2535};
2536
Matt2f2f4252005-04-13 14:45:30 +02002537static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002538 .channels_min = 2,
2539 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002540 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002541 .ops = {
2542 .prepare = stac92xx_capture_pcm_prepare,
2543 .cleanup = stac92xx_capture_pcm_cleanup
2544 },
2545};
2546
2547static int stac92xx_build_pcms(struct hda_codec *codec)
2548{
2549 struct sigmatel_spec *spec = codec->spec;
2550 struct hda_pcm *info = spec->pcm_rec;
2551
2552 codec->num_pcms = 1;
2553 codec->pcm_info = info;
2554
Mattc7d4b2f2005-06-27 14:59:41 +02002555 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002556 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002557 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2558 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002559 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002560 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002561 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002562
2563 if (spec->alt_switch) {
2564 codec->num_pcms++;
2565 info++;
2566 info->name = "STAC92xx Analog Alt";
2567 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2568 }
Matt2f2f4252005-04-13 14:45:30 +02002569
Mattdabbed62005-06-14 10:19:34 +02002570 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2571 codec->num_pcms++;
2572 info++;
2573 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002574 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002575 if (spec->multiout.dig_out_nid) {
2576 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2577 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2578 }
2579 if (spec->dig_in_nid) {
2580 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2581 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2582 }
2583 }
2584
Matt2f2f4252005-04-13 14:45:30 +02002585 return 0;
2586}
2587
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002588static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2589 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002590{
Takashi Iwai1327a322009-03-23 13:07:47 +01002591 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002592 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2593 if (pincap & AC_PINCAP_VREF_100)
2594 return AC_PINCTL_VREF_100;
2595 if (pincap & AC_PINCAP_VREF_80)
2596 return AC_PINCTL_VREF_80;
2597 if (pincap & AC_PINCAP_VREF_50)
2598 return AC_PINCTL_VREF_50;
2599 if (pincap & AC_PINCAP_VREF_GRD)
2600 return AC_PINCTL_VREF_GRD;
2601 return 0;
2602}
2603
Matt Porter403d1942005-11-29 15:00:51 +01002604static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2605
2606{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002607 snd_hda_codec_write_cache(codec, nid, 0,
2608 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002609}
2610
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002611#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2612
2613static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2614 struct snd_ctl_elem_value *ucontrol)
2615{
2616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2617 struct sigmatel_spec *spec = codec->spec;
2618
Takashi Iwaid7a89432008-11-12 09:48:04 +01002619 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002620 return 0;
2621}
2622
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002623static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2624 unsigned char type);
2625
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002626static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
2628{
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002631 int nid = kcontrol->private_value;
2632
2633 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002634
2635 /* check to be sure that the ports are upto date with
2636 * switch changes
2637 */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002638 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002639
2640 return 1;
2641}
2642
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002643static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2644 struct snd_ctl_elem_info *uinfo)
2645{
2646 int i;
2647 static char *texts[] = {
2648 "Mic In", "Line In", "Line Out"
2649 };
2650
2651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2652 struct sigmatel_spec *spec = codec->spec;
2653 hda_nid_t nid = kcontrol->private_value;
2654
2655 if (nid == spec->mic_switch || nid == spec->line_switch)
2656 i = 3;
2657 else
2658 i = 2;
2659
2660 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2661 uinfo->value.enumerated.items = i;
2662 uinfo->count = 1;
2663 if (uinfo->value.enumerated.item >= i)
2664 uinfo->value.enumerated.item = i-1;
2665 strcpy(uinfo->value.enumerated.name,
2666 texts[uinfo->value.enumerated.item]);
2667
2668 return 0;
2669}
2670
2671static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2672 struct snd_ctl_elem_value *ucontrol)
2673{
2674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2675 hda_nid_t nid = kcontrol->private_value;
2676 unsigned int vref = stac92xx_vref_get(codec, nid);
2677
2678 if (vref == stac92xx_get_default_vref(codec, nid))
2679 ucontrol->value.enumerated.item[0] = 0;
2680 else if (vref == AC_PINCTL_VREF_GRD)
2681 ucontrol->value.enumerated.item[0] = 1;
2682 else if (vref == AC_PINCTL_VREF_HIZ)
2683 ucontrol->value.enumerated.item[0] = 2;
2684
2685 return 0;
2686}
2687
2688static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2689 struct snd_ctl_elem_value *ucontrol)
2690{
2691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2692 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002693 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002694 hda_nid_t nid = kcontrol->private_value;
2695
2696 if (ucontrol->value.enumerated.item[0] == 0)
2697 new_vref = stac92xx_get_default_vref(codec, nid);
2698 else if (ucontrol->value.enumerated.item[0] == 1)
2699 new_vref = AC_PINCTL_VREF_GRD;
2700 else if (ucontrol->value.enumerated.item[0] == 2)
2701 new_vref = AC_PINCTL_VREF_HIZ;
2702 else
2703 return 0;
2704
2705 if (new_vref != stac92xx_vref_get(codec, nid)) {
2706 error = stac92xx_vref_set(codec, nid, new_vref);
2707 return error;
2708 }
2709
2710 return 0;
2711}
2712
2713static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2714 struct snd_ctl_elem_info *uinfo)
2715{
2716 static char *texts[2];
2717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2718 struct sigmatel_spec *spec = codec->spec;
2719
2720 if (kcontrol->private_value == spec->line_switch)
2721 texts[0] = "Line In";
2722 else
2723 texts[0] = "Mic In";
2724 texts[1] = "Line Out";
2725 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2726 uinfo->value.enumerated.items = 2;
2727 uinfo->count = 1;
2728
2729 if (uinfo->value.enumerated.item >= 2)
2730 uinfo->value.enumerated.item = 1;
2731 strcpy(uinfo->value.enumerated.name,
2732 texts[uinfo->value.enumerated.item]);
2733
2734 return 0;
2735}
Matt Porter403d1942005-11-29 15:00:51 +01002736
2737static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2738{
2739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2740 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002741 hda_nid_t nid = kcontrol->private_value;
2742 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002743
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002744 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002745 return 0;
2746}
2747
2748static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2749{
2750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2751 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002752 hda_nid_t nid = kcontrol->private_value;
2753 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2754 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002755
2756 spec->io_switch[io_idx] = val;
2757
2758 if (val)
2759 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002760 else {
2761 unsigned int pinctl = AC_PINCTL_IN_EN;
2762 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002763 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002764 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2765 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002766
2767 /* check the auto-mute again: we need to mute/unmute the speaker
2768 * appropriately according to the pin direction
2769 */
2770 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002771 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002772
Matt Porter403d1942005-11-29 15:00:51 +01002773 return 1;
2774}
2775
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002776#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2777
2778static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2779 struct snd_ctl_elem_value *ucontrol)
2780{
2781 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2782 struct sigmatel_spec *spec = codec->spec;
2783
2784 ucontrol->value.integer.value[0] = spec->clfe_swap;
2785 return 0;
2786}
2787
2788static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2789 struct snd_ctl_elem_value *ucontrol)
2790{
2791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2792 struct sigmatel_spec *spec = codec->spec;
2793 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002794 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002795
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002796 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002797 return 0;
2798
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002799 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002800
2801 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2802 spec->clfe_swap ? 0x4 : 0x0);
2803
2804 return 1;
2805}
2806
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002807#define STAC_CODEC_HP_SWITCH(xname) \
2808 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2809 .name = xname, \
2810 .index = 0, \
2811 .info = stac92xx_hp_switch_info, \
2812 .get = stac92xx_hp_switch_get, \
2813 .put = stac92xx_hp_switch_put, \
2814 }
2815
Matt Porter403d1942005-11-29 15:00:51 +01002816#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2817 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2818 .name = xname, \
2819 .index = 0, \
2820 .info = stac92xx_io_switch_info, \
2821 .get = stac92xx_io_switch_get, \
2822 .put = stac92xx_io_switch_put, \
2823 .private_value = xpval, \
2824 }
2825
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002826#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2827 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2828 .name = xname, \
2829 .index = 0, \
2830 .info = stac92xx_clfe_switch_info, \
2831 .get = stac92xx_clfe_switch_get, \
2832 .put = stac92xx_clfe_switch_put, \
2833 .private_value = xpval, \
2834 }
Matt Porter403d1942005-11-29 15:00:51 +01002835
Mattc7d4b2f2005-06-27 14:59:41 +02002836enum {
2837 STAC_CTL_WIDGET_VOL,
2838 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002839 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002840 STAC_CTL_WIDGET_AMP_MUX,
2841 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002842 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002843 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002844 STAC_CTL_WIDGET_CLFE_SWITCH,
2845 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002846};
2847
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002848static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002849 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2850 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002851 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002852 STAC_AMP_MUX,
2853 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002854 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002855 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002856 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002857 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002858};
2859
2860/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002861static struct snd_kcontrol_new *
2862stac_control_new(struct sigmatel_spec *spec,
2863 struct snd_kcontrol_new *ktemp,
2864 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002865{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002866 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002867
Takashi Iwai603c4012008-07-30 15:01:44 +02002868 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2869 knew = snd_array_new(&spec->kctls);
2870 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002871 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002872 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002873 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002874 if (!knew->name) {
2875 /* roolback */
2876 memset(knew, 0, sizeof(*knew));
2877 spec->kctls.alloced--;
2878 return NULL;
2879 }
2880 return knew;
2881}
2882
2883static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2884 struct snd_kcontrol_new *ktemp,
2885 int idx, const char *name,
2886 unsigned long val)
2887{
2888 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2889 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002890 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002891 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002892 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002893 return 0;
2894}
2895
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002896static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2897 int type, int idx, const char *name,
2898 unsigned long val)
2899{
2900 return stac92xx_add_control_temp(spec,
2901 &stac92xx_control_templates[type],
2902 idx, name, val);
2903}
2904
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002905
2906/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002907static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2908 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002909{
2910 return stac92xx_add_control_idx(spec, type, 0, name, val);
2911}
2912
Takashi Iwaie3c75962009-01-23 11:57:22 +01002913static struct snd_kcontrol_new stac_input_src_temp = {
2914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2915 .name = "Input Source",
2916 .info = stac92xx_mux_enum_info,
2917 .get = stac92xx_mux_enum_get,
2918 .put = stac92xx_mux_enum_put,
2919};
2920
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002921static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2922 hda_nid_t nid, int idx)
2923{
2924 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2925 int control = 0;
2926 struct sigmatel_spec *spec = codec->spec;
2927 char name[22];
2928
2929 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2930 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2931 && nid == spec->line_switch)
2932 control = STAC_CTL_WIDGET_IO_SWITCH;
2933 else if (snd_hda_query_pin_caps(codec, nid)
2934 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2935 control = STAC_CTL_WIDGET_DC_BIAS;
2936 else if (nid == spec->mic_switch)
2937 control = STAC_CTL_WIDGET_IO_SWITCH;
2938 }
2939
2940 if (control) {
2941 strcpy(name, auto_pin_cfg_labels[idx]);
2942 return stac92xx_add_control(codec->spec, control,
2943 strcat(name, " Jack Mode"), nid);
2944 }
2945
2946 return 0;
2947}
2948
Takashi Iwaie3c75962009-01-23 11:57:22 +01002949static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2950{
2951 struct snd_kcontrol_new *knew;
2952 struct hda_input_mux *imux = &spec->private_imux;
2953
2954 if (!spec->num_adcs || imux->num_items <= 1)
2955 return 0; /* no need for input source control */
2956 knew = stac_control_new(spec, &stac_input_src_temp,
2957 stac_input_src_temp.name);
2958 if (!knew)
2959 return -ENOMEM;
2960 knew->count = spec->num_adcs;
2961 return 0;
2962}
2963
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002964/* check whether the line-input can be used as line-out */
2965static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002966{
2967 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002968 struct auto_pin_cfg *cfg = &spec->autocfg;
2969 hda_nid_t nid;
2970 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002971
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002972 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2973 return 0;
2974 nid = cfg->input_pins[AUTO_PIN_LINE];
Takashi Iwai1327a322009-03-23 13:07:47 +01002975 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002976 if (pincap & AC_PINCAP_OUT)
2977 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002978 return 0;
2979}
2980
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002981/* check whether the mic-input can be used as line-out */
2982static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2983{
2984 struct sigmatel_spec *spec = codec->spec;
2985 struct auto_pin_cfg *cfg = &spec->autocfg;
2986 unsigned int def_conf, pincap;
2987 unsigned int mic_pin;
2988
2989 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2990 return 0;
2991 mic_pin = AUTO_PIN_MIC;
2992 for (;;) {
2993 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002994 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002995 /* some laptops have an internal analog microphone
2996 * which can't be used as a output */
2997 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai1327a322009-03-23 13:07:47 +01002998 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002999 if (pincap & AC_PINCAP_OUT)
3000 return nid;
3001 }
3002 if (mic_pin == AUTO_PIN_MIC)
3003 mic_pin = AUTO_PIN_FRONT_MIC;
3004 else
3005 break;
3006 }
3007 return 0;
3008}
Steve Longerbeam7b043892007-05-03 20:50:03 +02003009
3010static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3011{
3012 int i;
3013
3014 for (i = 0; i < spec->multiout.num_dacs; i++) {
3015 if (spec->multiout.dac_nids[i] == nid)
3016 return 1;
3017 }
3018
3019 return 0;
3020}
3021
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003022static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3023{
3024 int i;
3025 if (is_in_dac_nids(spec, nid))
3026 return 1;
3027 for (i = 0; i < spec->autocfg.hp_outs; i++)
3028 if (spec->hp_dacs[i] == nid)
3029 return 1;
3030 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3031 if (spec->speaker_dacs[i] == nid)
3032 return 1;
3033 return 0;
3034}
3035
3036static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3037{
3038 struct sigmatel_spec *spec = codec->spec;
3039 int j, conn_len;
3040 hda_nid_t conn[HDA_MAX_CONNECTIONS];
3041 unsigned int wcaps, wtype;
3042
3043 conn_len = snd_hda_get_connections(codec, nid, conn,
3044 HDA_MAX_CONNECTIONS);
3045 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01003046 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003047 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003048 /* we check only analog outputs */
3049 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3050 continue;
3051 /* if this route has a free DAC, assign it */
3052 if (!check_all_dac_nids(spec, conn[j])) {
3053 if (conn_len > 1) {
3054 /* select this DAC in the pin's input mux */
3055 snd_hda_codec_write_cache(codec, nid, 0,
3056 AC_VERB_SET_CONNECT_SEL, j);
3057 }
3058 return conn[j];
3059 }
3060 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003061 /* if all DACs are already assigned, connect to the primary DAC */
3062 if (conn_len > 1) {
3063 for (j = 0; j < conn_len; j++) {
3064 if (conn[j] == spec->multiout.dac_nids[0]) {
3065 snd_hda_codec_write_cache(codec, nid, 0,
3066 AC_VERB_SET_CONNECT_SEL, j);
3067 break;
3068 }
3069 }
3070 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003071 return 0;
3072}
3073
3074static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3075static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3076
Matt Porter3cc08dc2006-01-23 15:27:49 +01003077/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003078 * Fill in the dac_nids table from the parsed pin configuration
3079 * This function only works when every pin in line_out_pins[]
3080 * contains atleast one DAC in its connection list. Some 92xx
3081 * codecs are not connected directly to a DAC, such as the 9200
3082 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003083 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003084static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003085{
3086 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003087 struct auto_pin_cfg *cfg = &spec->autocfg;
3088 int i;
3089 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003090
Mattc7d4b2f2005-06-27 14:59:41 +02003091 for (i = 0; i < cfg->line_outs; i++) {
3092 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003093 dac = get_unassigned_dac(codec, nid);
3094 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003095 if (spec->multiout.num_dacs > 0) {
3096 /* we have already working output pins,
3097 * so let's drop the broken ones again
3098 */
3099 cfg->line_outs = spec->multiout.num_dacs;
3100 break;
3101 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003102 /* error out, no available DAC found */
3103 snd_printk(KERN_ERR
3104 "%s: No available DAC for pin 0x%x\n",
3105 __func__, nid);
3106 return -ENODEV;
3107 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003108 add_spec_dacs(spec, dac);
3109 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003110
Takashi Iwai139e0712009-03-06 12:10:41 +01003111 for (i = 0; i < cfg->hp_outs; i++) {
3112 nid = cfg->hp_pins[i];
3113 dac = get_unassigned_dac(codec, nid);
3114 if (dac) {
3115 if (!spec->multiout.hp_nid)
3116 spec->multiout.hp_nid = dac;
3117 else
3118 add_spec_extra_dacs(spec, dac);
3119 }
3120 spec->hp_dacs[i] = dac;
3121 }
3122
3123 for (i = 0; i < cfg->speaker_outs; i++) {
3124 nid = cfg->speaker_pins[i];
3125 dac = get_unassigned_dac(codec, nid);
3126 if (dac)
3127 add_spec_extra_dacs(spec, dac);
3128 spec->speaker_dacs[i] = dac;
3129 }
3130
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003131 /* add line-in as output */
3132 nid = check_line_out_switch(codec);
3133 if (nid) {
3134 dac = get_unassigned_dac(codec, nid);
3135 if (dac) {
3136 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3137 nid, cfg->line_outs);
3138 cfg->line_out_pins[cfg->line_outs] = nid;
3139 cfg->line_outs++;
3140 spec->line_switch = nid;
3141 add_spec_dacs(spec, dac);
3142 }
3143 }
3144 /* add mic as output */
3145 nid = check_mic_out_switch(codec);
3146 if (nid) {
3147 dac = get_unassigned_dac(codec, nid);
3148 if (dac) {
3149 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3150 nid, cfg->line_outs);
3151 cfg->line_out_pins[cfg->line_outs] = nid;
3152 cfg->line_outs++;
3153 spec->mic_switch = nid;
3154 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003155 }
Mattc7d4b2f2005-06-27 14:59:41 +02003156 }
3157
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003158 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003159 spec->multiout.num_dacs,
3160 spec->multiout.dac_nids[0],
3161 spec->multiout.dac_nids[1],
3162 spec->multiout.dac_nids[2],
3163 spec->multiout.dac_nids[3],
3164 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003165
Mattc7d4b2f2005-06-27 14:59:41 +02003166 return 0;
3167}
3168
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003169/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003170static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3171 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003172{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003173 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003174 char name[32];
3175 int err;
3176
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003177 if (!spec->check_volume_offset) {
3178 unsigned int caps, step, nums, db_scale;
3179 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3180 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3181 AC_AMPCAP_STEP_SIZE_SHIFT;
3182 step = (step + 1) * 25; /* in .01dB unit */
3183 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3184 AC_AMPCAP_NUM_STEPS_SHIFT;
3185 db_scale = nums * step;
3186 /* if dB scale is over -64dB, and finer enough,
3187 * let's reduce it to half
3188 */
3189 if (db_scale > 6400 && nums >= 0x1f)
3190 spec->volume_offset = nums / 2;
3191 spec->check_volume_offset = 1;
3192 }
3193
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003194 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003195 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003196 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3197 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003198 if (err < 0)
3199 return err;
3200 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003201 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003202 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3203 if (err < 0)
3204 return err;
3205 return 0;
3206}
3207
Takashi Iwai668b9652009-03-06 10:13:24 +01003208#define create_controls(codec, pfx, nid, chs) \
3209 create_controls_idx(codec, pfx, 0, nid, chs)
3210
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003211static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3212{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003213 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003214 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3215 return 1;
3216 } else {
3217 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3218 spec->multiout.num_dacs++;
3219 }
3220 return 0;
3221}
3222
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003223static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003224{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003225 int i;
3226 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3227 if (!spec->multiout.extra_out_nid[i]) {
3228 spec->multiout.extra_out_nid[i] = nid;
3229 return 0;
3230 }
3231 }
3232 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3233 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003234}
3235
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003236/* Create output controls
3237 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3238 */
3239static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3240 const hda_nid_t *pins,
3241 const hda_nid_t *dac_nids,
3242 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003243{
Takashi Iwai76624532008-12-19 10:09:47 +01003244 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003245 static const char *chname[4] = {
3246 "Front", "Surround", NULL /*CLFE*/, "Side"
3247 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003248 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003249 int i, err;
3250 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003251
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003252 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003253 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3254 wid_caps = get_wcaps(codec, pins[i]);
3255 if (wid_caps & AC_WCAP_UNSOL_CAP)
3256 spec->hp_detect = 1;
3257 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003258 nid = dac_nids[i];
3259 if (!nid)
3260 continue;
3261 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003262 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003263 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003264 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003265 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003266 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003267 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003268 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003269
3270 wid_caps = get_wcaps(codec, nid);
3271
3272 if (wid_caps & AC_WCAP_LR_SWAP) {
3273 err = stac92xx_add_control(spec,
3274 STAC_CTL_WIDGET_CLFE_SWITCH,
3275 "Swap Center/LFE Playback Switch", nid);
3276
3277 if (err < 0)
3278 return err;
3279 }
3280
Mattc7d4b2f2005-06-27 14:59:41 +02003281 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003282 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003283 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003284 switch (type) {
3285 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003286 name = "Headphone";
3287 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003288 break;
3289 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003290 name = "Speaker";
3291 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003292 break;
3293 default:
3294 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003295 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003296 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003297 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003298 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003299 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003300 return err;
3301 }
3302 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003303 return 0;
3304}
3305
Takashi Iwai6479c632009-07-28 18:20:25 +02003306static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3307 unsigned long sw, int idx)
3308{
3309 int err;
3310 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3311 "Captuer Volume", vol);
3312 if (err < 0)
3313 return err;
3314 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3315 "Captuer Switch", sw);
3316 if (err < 0)
3317 return err;
3318 return 0;
3319}
3320
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003321/* add playback controls from the parsed DAC table */
3322static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3323 const struct auto_pin_cfg *cfg)
3324{
3325 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003326 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003327 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003328 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003329
3330 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3331 spec->multiout.dac_nids,
3332 cfg->line_out_type);
3333 if (err < 0)
3334 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003335
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003336 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003337 err = stac92xx_add_control(spec,
3338 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003339 "Headphone as Line Out Switch",
3340 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003341 if (err < 0)
3342 return err;
3343 }
3344
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003345 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3346 nid = cfg->input_pins[idx];
3347 if (nid) {
3348 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3349 if (err < 0)
3350 return err;
3351 }
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003352 }
Matt Porter403d1942005-11-29 15:00:51 +01003353
Mattc7d4b2f2005-06-27 14:59:41 +02003354 return 0;
3355}
3356
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003357/* add playback controls for Speaker and HP outputs */
3358static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3359 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003360{
3361 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003362 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003363
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003364 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3365 spec->hp_dacs, AUTO_PIN_HP_OUT);
3366 if (err < 0)
3367 return err;
3368
3369 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3370 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3371 if (err < 0)
3372 return err;
3373
Mattc7d4b2f2005-06-27 14:59:41 +02003374 return 0;
3375}
3376
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003377/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003378static const char *stac92xx_mono_labels[4] = {
3379 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003380};
3381
3382/* create mono mux for mono out on capable codecs */
3383static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3384{
3385 struct sigmatel_spec *spec = codec->spec;
3386 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3387 int i, num_cons;
3388 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3389
3390 num_cons = snd_hda_get_connections(codec,
3391 spec->mono_nid,
3392 con_lst,
3393 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003394 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003395 return -EINVAL;
3396
3397 for (i = 0; i < num_cons; i++) {
3398 mono_mux->items[mono_mux->num_items].label =
3399 stac92xx_mono_labels[i];
3400 mono_mux->items[mono_mux->num_items].index = i;
3401 mono_mux->num_items++;
3402 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003403
3404 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3405 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003406}
3407
Matthew Ranostay89385032008-09-11 09:49:39 -04003408/* labels for amp mux outputs */
3409static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003410 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003411};
3412
3413/* create amp out controls mux on capable codecs */
3414static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3415{
3416 struct sigmatel_spec *spec = codec->spec;
3417 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3418 int i, err;
3419
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003420 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003421 amp_mux->items[amp_mux->num_items].label =
3422 stac92xx_amp_labels[i];
3423 amp_mux->items[amp_mux->num_items].index = i;
3424 amp_mux->num_items++;
3425 }
3426
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003427 if (spec->num_amps > 1) {
3428 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3429 "Amp Selector Capture Switch", 0);
3430 if (err < 0)
3431 return err;
3432 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003433 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3434 "Amp Capture Volume",
3435 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3436}
3437
3438
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003439/* create PC beep volume controls */
3440static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3441 hda_nid_t nid)
3442{
3443 struct sigmatel_spec *spec = codec->spec;
3444 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3445 int err;
3446
3447 /* check for mute support for the the amp */
3448 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3449 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3450 "PC Beep Playback Switch",
3451 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3452 if (err < 0)
3453 return err;
3454 }
3455
3456 /* check to see if there is volume support for the amp */
3457 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3458 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3459 "PC Beep Playback Volume",
3460 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3461 if (err < 0)
3462 return err;
3463 }
3464 return 0;
3465}
3466
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003467#ifdef CONFIG_SND_HDA_INPUT_BEEP
3468#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3469
3470static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3471 struct snd_ctl_elem_value *ucontrol)
3472{
3473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3474 ucontrol->value.integer.value[0] = codec->beep->enabled;
3475 return 0;
3476}
3477
3478static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3479 struct snd_ctl_elem_value *ucontrol)
3480{
3481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3482 int enabled = !!ucontrol->value.integer.value[0];
3483 if (codec->beep->enabled != enabled) {
3484 codec->beep->enabled = enabled;
3485 return 1;
3486 }
3487 return 0;
3488}
3489
3490static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3492 .info = stac92xx_dig_beep_switch_info,
3493 .get = stac92xx_dig_beep_switch_get,
3494 .put = stac92xx_dig_beep_switch_put,
3495};
3496
3497static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3498{
3499 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3500 0, "PC Beep Playback Switch", 0);
3501}
3502#endif
3503
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003504static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3505{
3506 struct sigmatel_spec *spec = codec->spec;
3507 int wcaps, nid, i, err = 0;
3508
3509 for (i = 0; i < spec->num_muxes; i++) {
3510 nid = spec->mux_nids[i];
3511 wcaps = get_wcaps(codec, nid);
3512
3513 if (wcaps & AC_WCAP_OUT_AMP) {
3514 err = stac92xx_add_control_idx(spec,
3515 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3516 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3517 if (err < 0)
3518 return err;
3519 }
3520 }
3521 return 0;
3522};
3523
Matthew Ranostayd9737752008-09-07 12:03:41 +02003524static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003525 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003526};
3527
3528static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3529{
3530 struct sigmatel_spec *spec = codec->spec;
3531 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003532 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003533 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003534 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003535
3536 num_cons = snd_hda_get_connections(codec,
3537 spec->smux_nids[0],
3538 con_lst,
3539 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003540 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003541 return -EINVAL;
3542
Matthew Ranostay65973632008-09-16 10:39:37 -04003543 if (!labels)
3544 labels = stac92xx_spdif_labels;
3545
Matthew Ranostayd9737752008-09-07 12:03:41 +02003546 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003547 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003548 spdif_mux->items[spdif_mux->num_items].index = i;
3549 spdif_mux->num_items++;
3550 }
3551
3552 return 0;
3553}
3554
Matt Porter8b657272006-10-26 17:12:59 +02003555/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003556static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003557 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3558 "Digital Mic 3", "Digital Mic 4"
3559};
3560
3561/* create playback/capture controls for input pins on dmic capable codecs */
3562static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3563 const struct auto_pin_cfg *cfg)
3564{
3565 struct sigmatel_spec *spec = codec->spec;
3566 struct hda_input_mux *dimux = &spec->private_dimux;
3567 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003568 int err, i, j;
3569 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003570
3571 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3572 dimux->items[dimux->num_items].index = 0;
3573 dimux->num_items++;
3574
3575 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003576 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003577 int index;
3578 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003579 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003580 unsigned int def_conf;
3581
Takashi Iwai330ee992009-02-20 14:33:36 +01003582 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
Matt Porter8b657272006-10-26 17:12:59 +02003583 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3584 continue;
3585
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003586 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003587 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003588 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003589 con_lst,
3590 HDA_MAX_NUM_INPUTS);
3591 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003592 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003593 index = j;
3594 goto found;
3595 }
3596 continue;
3597found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003598 wcaps = get_wcaps(codec, nid) &
3599 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003600
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003601 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003602 sprintf(name, "%s Capture Volume",
3603 stac92xx_dmic_labels[dimux->num_items]);
3604
3605 err = stac92xx_add_control(spec,
3606 STAC_CTL_WIDGET_VOL,
3607 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003608 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3609 (wcaps & AC_WCAP_OUT_AMP) ?
3610 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003611 if (err < 0)
3612 return err;
3613 }
3614
Matt Porter8b657272006-10-26 17:12:59 +02003615 dimux->items[dimux->num_items].label =
3616 stac92xx_dmic_labels[dimux->num_items];
3617 dimux->items[dimux->num_items].index = index;
3618 dimux->num_items++;
3619 }
3620
3621 return 0;
3622}
3623
Mattc7d4b2f2005-06-27 14:59:41 +02003624/* create playback/capture controls for input pins */
3625static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3626{
3627 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003628 struct hda_input_mux *imux = &spec->private_imux;
3629 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3630 int i, j, k;
3631
3632 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003633 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003634
Takashi Iwai314634b2006-09-21 11:56:18 +02003635 if (!cfg->input_pins[i])
3636 continue;
3637 index = -1;
3638 for (j = 0; j < spec->num_muxes; j++) {
3639 int num_cons;
3640 num_cons = snd_hda_get_connections(codec,
3641 spec->mux_nids[j],
3642 con_lst,
3643 HDA_MAX_NUM_INPUTS);
3644 for (k = 0; k < num_cons; k++)
3645 if (con_lst[k] == cfg->input_pins[i]) {
3646 index = k;
3647 goto found;
3648 }
Mattc7d4b2f2005-06-27 14:59:41 +02003649 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003650 continue;
3651 found:
3652 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3653 imux->items[imux->num_items].index = index;
3654 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003655 }
3656
Steve Longerbeam7b043892007-05-03 20:50:03 +02003657 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003658 /*
3659 * Set the current input for the muxes.
3660 * The STAC9221 has two input muxes with identical source
3661 * NID lists. Hopefully this won't get confused.
3662 */
3663 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003664 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3665 AC_VERB_SET_CONNECT_SEL,
3666 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003667 }
3668 }
3669
Mattc7d4b2f2005-06-27 14:59:41 +02003670 return 0;
3671}
3672
Mattc7d4b2f2005-06-27 14:59:41 +02003673static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3674{
3675 struct sigmatel_spec *spec = codec->spec;
3676 int i;
3677
3678 for (i = 0; i < spec->autocfg.line_outs; i++) {
3679 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3680 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3681 }
3682}
3683
3684static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3685{
3686 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003687 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003688
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003689 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3690 hda_nid_t pin;
3691 pin = spec->autocfg.hp_pins[i];
3692 if (pin) /* connect to front */
3693 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3694 }
3695 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3696 hda_nid_t pin;
3697 pin = spec->autocfg.speaker_pins[i];
3698 if (pin) /* connect to front */
3699 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3700 }
Mattc7d4b2f2005-06-27 14:59:41 +02003701}
3702
Matt Porter3cc08dc2006-01-23 15:27:49 +01003703static 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 +02003704{
3705 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003706 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003707 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003708
Matt Porter8b657272006-10-26 17:12:59 +02003709 if ((err = snd_hda_parse_pin_def_config(codec,
3710 &spec->autocfg,
3711 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003712 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003713 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003714 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003715
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003716 /* If we have no real line-out pin and multiple hp-outs, HPs should
3717 * be set up as multi-channel outputs.
3718 */
3719 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3720 spec->autocfg.hp_outs > 1) {
3721 /* Copy hp_outs to line_outs, backup line_outs in
3722 * speaker_outs so that the following routines can handle
3723 * HP pins as primary outputs.
3724 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003725 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003726 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3727 sizeof(spec->autocfg.line_out_pins));
3728 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3729 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3730 sizeof(spec->autocfg.hp_pins));
3731 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003732 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3733 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003734 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003735 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003736 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003737 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3738 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003739 u32 caps = query_amp_caps(codec,
3740 spec->autocfg.mono_out_pin, dir);
3741 hda_nid_t conn_list[1];
3742
3743 /* get the mixer node and then the mono mux if it exists */
3744 if (snd_hda_get_connections(codec,
3745 spec->autocfg.mono_out_pin, conn_list, 1) &&
3746 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003747 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003748
3749 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003750 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003751 /* LR swap check, some stac925x have a mux that
3752 * changes the DACs output path instead of the
3753 * mono-mux path.
3754 */
3755 if (wid_type == AC_WID_AUD_SEL &&
3756 !(wcaps & AC_WCAP_LR_SWAP))
3757 spec->mono_nid = conn_list[0];
3758 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003759 if (dir) {
3760 hda_nid_t nid = spec->autocfg.mono_out_pin;
3761
3762 /* most mono outs have a least a mute/unmute switch */
3763 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3764 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3765 "Mono Playback Switch",
3766 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003767 if (err < 0)
3768 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003769 /* check for volume support for the amp */
3770 if ((caps & AC_AMPCAP_NUM_STEPS)
3771 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3772 err = stac92xx_add_control(spec,
3773 STAC_CTL_WIDGET_VOL,
3774 "Mono Playback Volume",
3775 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3776 if (err < 0)
3777 return err;
3778 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003779 }
3780
3781 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3782 AC_PINCTL_OUT_EN);
3783 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003784
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003785 if (!spec->multiout.num_dacs) {
3786 err = stac92xx_auto_fill_dac_nids(codec);
3787 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003788 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003789 err = stac92xx_auto_create_multi_out_ctls(codec,
3790 &spec->autocfg);
3791 if (err < 0)
3792 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003793 }
Mattc7d4b2f2005-06-27 14:59:41 +02003794
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003795 /* setup analog beep controls */
3796 if (spec->anabeep_nid > 0) {
3797 err = stac92xx_auto_create_beep_ctls(codec,
3798 spec->anabeep_nid);
3799 if (err < 0)
3800 return err;
3801 }
3802
3803 /* setup digital beep controls and input device */
3804#ifdef CONFIG_SND_HDA_INPUT_BEEP
3805 if (spec->digbeep_nid > 0) {
3806 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003807 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003808
3809 err = stac92xx_auto_create_beep_ctls(codec, nid);
3810 if (err < 0)
3811 return err;
3812 err = snd_hda_attach_beep_device(codec, nid);
3813 if (err < 0)
3814 return err;
Takashi Iwaifa797962009-05-19 12:50:04 +02003815 /* IDT/STAC codecs have linear beep tone parameter */
3816 codec->beep->linear_tone = 1;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003817 /* if no beep switch is available, make its own one */
3818 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3819 if (codec->beep &&
3820 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3821 err = stac92xx_beep_switch_ctl(codec);
3822 if (err < 0)
3823 return err;
3824 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003825 }
3826#endif
3827
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003828 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003829 if (err < 0)
3830 return err;
3831
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003832 /* All output parsing done, now restore the swapped hp pins */
3833 if (hp_swap) {
3834 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3835 sizeof(spec->autocfg.hp_pins));
3836 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3837 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3838 spec->autocfg.line_outs = 0;
3839 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003840
Takashi Iwai6479c632009-07-28 18:20:25 +02003841 for (i = 0; i < spec->num_caps; i++) {
3842 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3843 spec->capsws[i], i);
3844 if (err < 0)
3845 return err;
3846 }
3847
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003848 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003849 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003850 return err;
3851
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003852 if (spec->mono_nid > 0) {
3853 err = stac92xx_auto_create_mono_output_ctls(codec);
3854 if (err < 0)
3855 return err;
3856 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003857 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003858 err = stac92xx_auto_create_amp_output_ctls(codec);
3859 if (err < 0)
3860 return err;
3861 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003862 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003863 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3864 &spec->autocfg)) < 0)
3865 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003866 if (spec->num_muxes > 0) {
3867 err = stac92xx_auto_create_mux_input_ctls(codec);
3868 if (err < 0)
3869 return err;
3870 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003871 if (spec->num_smuxes > 0) {
3872 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3873 if (err < 0)
3874 return err;
3875 }
Matt Porter8b657272006-10-26 17:12:59 +02003876
Takashi Iwaie3c75962009-01-23 11:57:22 +01003877 err = stac92xx_add_input_source(spec);
3878 if (err < 0)
3879 return err;
3880
Mattc7d4b2f2005-06-27 14:59:41 +02003881 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003882 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003883 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003884
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003885 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003886 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003887 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003888 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003889
Takashi Iwai603c4012008-07-30 15:01:44 +02003890 if (spec->kctls.list)
3891 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003892
3893 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003894 if (!spec->dinput_mux)
3895 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003896 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003897 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003898 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003899 return 1;
3900}
3901
Takashi Iwai82bc9552006-03-21 11:24:42 +01003902/* add playback controls for HP output */
3903static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3904 struct auto_pin_cfg *cfg)
3905{
3906 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003907 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003908 unsigned int wid_caps;
3909
3910 if (! pin)
3911 return 0;
3912
3913 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003914 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003915 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003916
3917 return 0;
3918}
3919
Richard Fish160ea0d2006-09-06 13:58:25 +02003920/* add playback controls for LFE output */
3921static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3922 struct auto_pin_cfg *cfg)
3923{
3924 struct sigmatel_spec *spec = codec->spec;
3925 int err;
3926 hda_nid_t lfe_pin = 0x0;
3927 int i;
3928
3929 /*
3930 * search speaker outs and line outs for a mono speaker pin
3931 * with an amp. If one is found, add LFE controls
3932 * for it.
3933 */
3934 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3935 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003936 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003937 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3938 if (wcaps == AC_WCAP_OUT_AMP)
3939 /* found a mono speaker with an amp, must be lfe */
3940 lfe_pin = pin;
3941 }
3942
3943 /* if speaker_outs is 0, then speakers may be in line_outs */
3944 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3945 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3946 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003947 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003948 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003949 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003950 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003951 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3952 if (wcaps == AC_WCAP_OUT_AMP)
3953 /* found a mono speaker with an amp,
3954 must be lfe */
3955 lfe_pin = pin;
3956 }
3957 }
3958 }
3959
3960 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003961 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003962 if (err < 0)
3963 return err;
3964 }
3965
3966 return 0;
3967}
3968
Mattc7d4b2f2005-06-27 14:59:41 +02003969static int stac9200_parse_auto_config(struct hda_codec *codec)
3970{
3971 struct sigmatel_spec *spec = codec->spec;
3972 int err;
3973
Kailang Yangdf694da2005-12-05 19:42:22 +01003974 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003975 return err;
3976
3977 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3978 return err;
3979
Takashi Iwai82bc9552006-03-21 11:24:42 +01003980 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3981 return err;
3982
Richard Fish160ea0d2006-09-06 13:58:25 +02003983 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3984 return err;
3985
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003986 if (spec->num_muxes > 0) {
3987 err = stac92xx_auto_create_mux_input_ctls(codec);
3988 if (err < 0)
3989 return err;
3990 }
3991
Takashi Iwaie3c75962009-01-23 11:57:22 +01003992 err = stac92xx_add_input_source(spec);
3993 if (err < 0)
3994 return err;
3995
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003996 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003997 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003998 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003999 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004000
Takashi Iwai603c4012008-07-30 15:01:44 +02004001 if (spec->kctls.list)
4002 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004003
4004 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004005 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004006
4007 return 1;
4008}
4009
Sam Revitch62fe78e2006-05-10 15:09:17 +02004010/*
4011 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4012 * funky external mute control using GPIO pins.
4013 */
4014
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004015static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004016 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004017{
4018 unsigned int gpiostate, gpiomask, gpiodir;
4019
4020 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4021 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004022 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004023
4024 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4025 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004026 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004027
4028 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4029 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004030 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004031
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004032 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004033 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4034
4035 snd_hda_codec_write(codec, codec->afg, 0,
4036 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004037 snd_hda_codec_read(codec, codec->afg, 0,
4038 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004039
4040 msleep(1);
4041
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004042 snd_hda_codec_read(codec, codec->afg, 0,
4043 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004044}
4045
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004046#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwai95c09092009-04-14 16:15:29 +02004047static void stac92xx_free_jack_priv(struct snd_jack *jack)
4048{
4049 struct sigmatel_jack *jacks = jack->private_data;
4050 jacks->nid = 0;
4051 jacks->jack = NULL;
4052}
4053#endif
4054
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004055static int stac92xx_add_jack(struct hda_codec *codec,
4056 hda_nid_t nid, int type)
4057{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004058#ifdef CONFIG_SND_HDA_INPUT_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004059 struct sigmatel_spec *spec = codec->spec;
4060 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01004061 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004062 int connectivity = get_defcfg_connect(def_conf);
4063 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02004064 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004065
4066 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4067 return 0;
4068
4069 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4070 jack = snd_array_new(&spec->jacks);
4071 if (!jack)
4072 return -ENOMEM;
4073 jack->nid = nid;
4074 jack->type = type;
4075
Takashi Iwai86de7412009-07-22 16:02:46 +02004076 snprintf(name, sizeof(name), "%s at %s %s Jack",
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004077 snd_hda_get_jack_type(def_conf),
4078 snd_hda_get_jack_connectivity(def_conf),
4079 snd_hda_get_jack_location(def_conf));
4080
Takashi Iwai95c09092009-04-14 16:15:29 +02004081 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4082 if (err < 0) {
4083 jack->nid = 0;
4084 return err;
4085 }
4086 jack->jack->private_data = jack;
4087 jack->jack->private_free = stac92xx_free_jack_priv;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004088#endif
Takashi Iwai95c09092009-04-14 16:15:29 +02004089 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004090}
4091
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004092static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4093 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004094{
4095 struct sigmatel_event *event;
4096
4097 snd_array_init(&spec->events, sizeof(*event), 32);
4098 event = snd_array_new(&spec->events);
4099 if (!event)
4100 return -ENOMEM;
4101 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004102 event->type = type;
4103 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004104 event->data = data;
4105
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004106 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004107}
4108
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004109static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4110 hda_nid_t nid, unsigned char type)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004111{
4112 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004113 struct sigmatel_event *event = spec->events.list;
4114 int i;
4115
4116 for (i = 0; i < spec->events.used; i++, event++) {
4117 if (event->nid == nid && event->type == type)
4118 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004119 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004120 return NULL;
4121}
4122
4123static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4124 unsigned char tag)
4125{
4126 struct sigmatel_spec *spec = codec->spec;
4127 struct sigmatel_event *event = spec->events.list;
4128 int i;
4129
4130 for (i = 0; i < spec->events.used; i++, event++) {
4131 if (event->tag == tag)
4132 return event;
4133 }
4134 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004135}
4136
Takashi Iwai314634b2006-09-21 11:56:18 +02004137static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004138 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004139{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004140 struct sigmatel_event *event;
4141 int tag;
4142
4143 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4144 return;
4145 event = stac_get_event(codec, nid, type);
4146 if (event)
4147 tag = event->tag;
4148 else
4149 tag = stac_add_event(codec->spec, nid, type, 0);
4150 if (tag < 0)
4151 return;
4152 snd_hda_codec_write_cache(codec, nid, 0,
4153 AC_VERB_SET_UNSOLICITED_ENABLE,
4154 AC_USRSP_EN | tag);
Takashi Iwai314634b2006-09-21 11:56:18 +02004155}
4156
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004157static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4158{
4159 int i;
4160 for (i = 0; i < cfg->hp_outs; i++)
4161 if (cfg->hp_pins[i] == nid)
4162 return 1; /* nid is a HP-Out */
4163
4164 return 0; /* nid is not a HP-Out */
4165};
4166
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004167static void stac92xx_power_down(struct hda_codec *codec)
4168{
4169 struct sigmatel_spec *spec = codec->spec;
4170
4171 /* power down inactive DACs */
4172 hda_nid_t *dac;
4173 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004174 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004175 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004176 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4177}
4178
Takashi Iwaif73d3582008-11-25 08:21:51 +01004179static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4180 int enable);
4181
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004182/* override some hints from the hwdep entry */
4183static void stac_store_hints(struct hda_codec *codec)
4184{
4185 struct sigmatel_spec *spec = codec->spec;
4186 const char *p;
4187 int val;
4188
4189 val = snd_hda_get_bool_hint(codec, "hp_detect");
4190 if (val >= 0)
4191 spec->hp_detect = val;
4192 p = snd_hda_get_hint(codec, "gpio_mask");
4193 if (p) {
4194 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4195 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4196 spec->gpio_mask;
4197 }
4198 p = snd_hda_get_hint(codec, "gpio_dir");
4199 if (p)
4200 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4201 p = snd_hda_get_hint(codec, "gpio_data");
4202 if (p)
4203 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4204 p = snd_hda_get_hint(codec, "eapd_mask");
4205 if (p)
4206 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4207 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4208 if (val >= 0)
4209 spec->eapd_switch = val;
4210}
4211
Mattc7d4b2f2005-06-27 14:59:41 +02004212static int stac92xx_init(struct hda_codec *codec)
4213{
4214 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004215 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004216 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004217 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004218
Mattc7d4b2f2005-06-27 14:59:41 +02004219 snd_hda_sequence_write(codec, spec->init);
4220
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004221 /* power down adcs initially */
4222 if (spec->powerdown_adcs)
4223 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004224 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004225 spec->adc_nids[i], 0,
4226 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004227
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004228 /* override some hints */
4229 stac_store_hints(codec);
4230
Takashi Iwaif73d3582008-11-25 08:21:51 +01004231 /* set up GPIO */
4232 gpio = spec->gpio_data;
4233 /* turn on EAPD statically when spec->eapd_switch isn't set.
4234 * otherwise, unsol event will turn it on/off dynamically
4235 */
4236 if (!spec->eapd_switch)
4237 gpio |= spec->eapd_mask;
4238 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4239
Takashi Iwai82bc9552006-03-21 11:24:42 +01004240 /* set up pins */
4241 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004242 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004243 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004244 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004245 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004246 }
Takashi Iwai0a07aca2007-03-13 10:40:23 +01004247 /* force to enable the first line-out; the others are set up
4248 * in unsol_event
4249 */
4250 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004251 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004252 /* fake event to set up pins */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004253 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4254 STAC_HP_EVENT);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004255 } else {
4256 stac92xx_auto_init_multi_out(codec);
4257 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004258 for (i = 0; i < cfg->hp_outs; i++)
4259 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004260 }
4261 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004262 hda_nid_t nid = cfg->input_pins[i];
4263 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004264 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004265 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4266 /* for mic pins, force to initialize */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004267 pinctl = stac92xx_get_default_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004268 pinctl |= AC_PINCTL_IN_EN;
4269 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004270 } else {
4271 pinctl = snd_hda_codec_read(codec, nid, 0,
4272 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4273 /* if PINCTL already set then skip */
Takashi Iwai5dd17cb92009-05-07 16:22:53 +02004274 /* Also, if both INPUT and OUTPUT are set,
4275 * it must be a BIOS bug; need to override, too
4276 */
4277 if (!(pinctl & AC_PINCTL_IN_EN) ||
4278 (pinctl & AC_PINCTL_OUT_EN)) {
4279 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004280 pinctl |= AC_PINCTL_IN_EN;
4281 stac92xx_auto_set_pinctl(codec, nid,
4282 pinctl);
4283 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004284 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004285 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004286 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4287 enable_pin_detect(codec, nid,
4288 STAC_INSERT_EVENT);
4289 stac_issue_unsol_event(codec, nid,
4290 STAC_INSERT_EVENT);
4291 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004292 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004293 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004294 for (i = 0; i < spec->num_dmics; i++)
4295 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4296 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004297 if (cfg->dig_out_pins[0])
4298 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004299 AC_PINCTL_OUT_EN);
4300 if (cfg->dig_in_pin)
4301 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4302 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004303 for (i = 0; i < spec->num_pwrs; i++) {
4304 hda_nid_t nid = spec->pwr_nids[i];
4305 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004306
Takashi Iwaieb632122008-12-19 16:39:48 +01004307 /* power on when no jack detection is available */
4308 if (!spec->hp_detect) {
4309 stac_toggle_power_map(codec, nid, 1);
4310 continue;
4311 }
4312
4313 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004314 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004315
Takashi Iwaif73d3582008-11-25 08:21:51 +01004316 pinctl = snd_hda_codec_read(codec, nid, 0,
4317 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4318 /* outputs are only ports capable of power management
4319 * any attempts on powering down a input port cause the
4320 * referenced VREF to act quirky.
4321 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004322 if (pinctl & AC_PINCTL_IN_EN) {
4323 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004324 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004325 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004326 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004327 def_conf = get_defcfg_connect(def_conf);
4328 /* skip any ports that don't have jacks since presence
4329 * detection is useless */
4330 if (def_conf != AC_JACK_PORT_COMPLEX) {
4331 if (def_conf != AC_JACK_PORT_NONE)
4332 stac_toggle_power_map(codec, nid, 1);
4333 continue;
4334 }
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004335 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4336 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4337 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4338 }
Takashi Iwaif73d3582008-11-25 08:21:51 +01004339 }
4340 if (spec->dac_list)
4341 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004342 return 0;
4343}
4344
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004345static void stac92xx_free_jacks(struct hda_codec *codec)
4346{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004347#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwaib94d3532008-11-21 09:08:06 +01004348 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004349 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d3532008-11-21 09:08:06 +01004350 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004351 struct sigmatel_jack *jacks = spec->jacks.list;
4352 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +02004353 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4354 if (jacks->jack)
4355 snd_device_free(codec->bus->card, jacks->jack);
4356 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004357 }
4358 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004359#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004360}
4361
Takashi Iwai603c4012008-07-30 15:01:44 +02004362static void stac92xx_free_kctls(struct hda_codec *codec)
4363{
4364 struct sigmatel_spec *spec = codec->spec;
4365
4366 if (spec->kctls.list) {
4367 struct snd_kcontrol_new *kctl = spec->kctls.list;
4368 int i;
4369 for (i = 0; i < spec->kctls.used; i++)
4370 kfree(kctl[i].name);
4371 }
4372 snd_array_free(&spec->kctls);
4373}
4374
Matt2f2f4252005-04-13 14:45:30 +02004375static void stac92xx_free(struct hda_codec *codec)
4376{
Mattc7d4b2f2005-06-27 14:59:41 +02004377 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004378
4379 if (! spec)
4380 return;
4381
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004382 stac92xx_free_jacks(codec);
4383 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004384
Mattc7d4b2f2005-06-27 14:59:41 +02004385 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004386 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004387}
4388
Matt4e550962005-07-04 17:51:39 +02004389static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4390 unsigned int flag)
4391{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004392 unsigned int old_ctl, pin_ctl;
4393
4394 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004395 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004396
Takashi Iwaif9acba42007-05-29 18:01:06 +02004397 if (pin_ctl & AC_PINCTL_IN_EN) {
4398 /*
4399 * we need to check the current set-up direction of
4400 * shared input pins since they can be switched via
4401 * "xxx as Output" mixer switch
4402 */
4403 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004404 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004405 return;
4406 }
4407
Takashi Iwai8ce84192009-01-22 16:59:20 +01004408 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004409 /* if setting pin direction bits, clear the current
4410 direction bits first */
4411 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4412 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4413
Takashi Iwai8ce84192009-01-22 16:59:20 +01004414 pin_ctl |= flag;
4415 if (old_ctl != pin_ctl)
4416 snd_hda_codec_write_cache(codec, nid, 0,
4417 AC_VERB_SET_PIN_WIDGET_CONTROL,
4418 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004419}
4420
4421static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4422 unsigned int flag)
4423{
4424 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4425 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004426 if (pin_ctl & flag)
4427 snd_hda_codec_write_cache(codec, nid, 0,
4428 AC_VERB_SET_PIN_WIDGET_CONTROL,
4429 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004430}
4431
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004432static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004433{
4434 if (!nid)
4435 return 0;
4436 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004437 & (1 << 31))
4438 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004439 return 0;
4440}
4441
Takashi Iwaid7a89432008-11-12 09:48:04 +01004442/* return non-zero if the hp-pin of the given array index isn't
4443 * a jack-detection target
4444 */
4445static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4446{
4447 struct auto_pin_cfg *cfg = &spec->autocfg;
4448
4449 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004450 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004451 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004452 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004453 return 1;
4454 /* ignore if the pin is set as line-out */
4455 if (cfg->hp_pins[i] == spec->hp_switch)
4456 return 1;
4457 return 0;
4458}
4459
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004460static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004461{
4462 struct sigmatel_spec *spec = codec->spec;
4463 struct auto_pin_cfg *cfg = &spec->autocfg;
4464 int i, presence;
4465
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004466 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004467 if (spec->gpio_mute)
4468 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4469 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4470
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004471 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004472 if (presence)
4473 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004474 if (no_hp_sensing(spec, i))
4475 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004476 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4477 if (presence) {
4478 unsigned int pinctl;
4479 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4480 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4481 if (pinctl & AC_PINCTL_IN_EN)
4482 presence = 0; /* mic- or line-input */
4483 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004484 }
Matt4e550962005-07-04 17:51:39 +02004485
4486 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004487 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004488 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004489 stac92xx_reset_pinctl(codec, spec->hp_switch,
4490 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004491 for (i = 0; i < cfg->line_outs; i++)
4492 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4493 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004494 for (i = 0; i < cfg->speaker_outs; i++)
4495 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4496 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004497 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004498 stac_gpio_set(codec, spec->gpio_mask,
4499 spec->gpio_dir, spec->gpio_data &
4500 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004501 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004502 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004503 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004504 stac92xx_set_pinctl(codec, spec->hp_switch,
4505 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004506 for (i = 0; i < cfg->line_outs; i++)
4507 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4508 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004509 for (i = 0; i < cfg->speaker_outs; i++)
4510 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4511 AC_PINCTL_OUT_EN);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05004512 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004513 stac_gpio_set(codec, spec->gpio_mask,
4514 spec->gpio_dir, spec->gpio_data |
4515 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02004516 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01004517 /* toggle hp outs */
4518 for (i = 0; i < cfg->hp_outs; i++) {
4519 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4520 if (no_hp_sensing(spec, i))
4521 continue;
4522 if (presence)
4523 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004524#if 0 /* FIXME */
4525/* Resetting the pinctl like below may lead to (a sort of) regressions
4526 * on some devices since they use the HP pin actually for line/speaker
4527 * outs although the default pin config shows a different pin (that is
4528 * wrong and useless).
4529 *
4530 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4531 * But, disabling the code below just works around it, and I'm too tired of
4532 * bug reports with such devices...
4533 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004534 else
4535 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004536#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004537 }
Matt4e550962005-07-04 17:51:39 +02004538}
4539
Takashi Iwaif73d3582008-11-25 08:21:51 +01004540static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4541 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004542{
4543 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004544 unsigned int idx, val;
4545
4546 for (idx = 0; idx < spec->num_pwrs; idx++) {
4547 if (spec->pwr_nids[idx] == nid)
4548 break;
4549 }
4550 if (idx >= spec->num_pwrs)
4551 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004552
4553 /* several codecs have two power down bits */
4554 if (spec->pwr_mapping)
4555 idx = spec->pwr_mapping[idx];
4556 else
4557 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004558
Takashi Iwaif73d3582008-11-25 08:21:51 +01004559 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4560 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004561 val &= ~idx;
4562 else
4563 val |= idx;
4564
4565 /* power down unused output ports */
4566 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004567}
4568
Takashi Iwaif73d3582008-11-25 08:21:51 +01004569static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4570{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004571 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004572}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004573
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004574static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4575{
4576 struct sigmatel_spec *spec = codec->spec;
4577 struct sigmatel_jack *jacks = spec->jacks.list;
4578
4579 if (jacks) {
4580 int i;
4581 for (i = 0; i < spec->jacks.used; i++) {
4582 if (jacks->nid == nid) {
4583 unsigned int pin_ctl =
4584 snd_hda_codec_read(codec, nid,
4585 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4586 0x00);
4587 int type = jacks->type;
4588 if (type == (SND_JACK_LINEOUT
4589 | SND_JACK_HEADPHONE))
4590 type = (pin_ctl & AC_PINCTL_HP_EN)
4591 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4592 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004593 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004594 ? type : 0);
4595 }
4596 jacks++;
4597 }
4598 }
4599}
Matt2f2f4252005-04-13 14:45:30 +02004600
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004601static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4602 unsigned char type)
4603{
4604 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4605 if (!event)
4606 return;
4607 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4608}
4609
Takashi Iwai314634b2006-09-21 11:56:18 +02004610static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4611{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004612 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004613 struct sigmatel_event *event;
4614 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004615
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004616 tag = (res >> 26) & 0x7f;
4617 event = stac_get_event_from_tag(codec, tag);
4618 if (!event)
4619 return;
4620
4621 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004622 case STAC_HP_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004623 stac92xx_hp_detect(codec);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004624 /* fallthru */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004625 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004626 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004627 if (spec->num_pwrs > 0)
4628 stac92xx_pin_sense(codec, event->nid);
4629 stac92xx_report_jack(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004630
4631 switch (codec->subsystem_id) {
4632 case 0x103c308f:
4633 if (event->nid == 0xb) {
4634 int pin = AC_PINCTL_IN_EN;
4635
4636 if (get_pin_presence(codec, 0xa)
4637 && get_pin_presence(codec, 0xb))
4638 pin |= AC_PINCTL_VREF_80;
4639 if (!get_pin_presence(codec, 0xb))
4640 pin |= AC_PINCTL_VREF_80;
4641
4642 /* toggle VREF state based on mic + hp pin
4643 * status
4644 */
4645 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4646 }
4647 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004648 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004649 case STAC_VREF_EVENT:
4650 data = snd_hda_codec_read(codec, codec->afg, 0,
4651 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004652 /* toggle VREF state based on GPIOx status */
4653 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004654 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004655 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004656 }
4657}
4658
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004659#ifdef CONFIG_PROC_FS
4660static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4661 struct hda_codec *codec, hda_nid_t nid)
4662{
4663 if (nid == codec->afg)
4664 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4665 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4666}
4667
4668static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4669 struct hda_codec *codec,
4670 unsigned int verb)
4671{
4672 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4673 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4674}
4675
4676/* stac92hd71bxx, stac92hd73xx */
4677static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4678 struct hda_codec *codec, hda_nid_t nid)
4679{
4680 stac92hd_proc_hook(buffer, codec, nid);
4681 if (nid == codec->afg)
4682 analog_loop_proc_hook(buffer, codec, 0xfa0);
4683}
4684
4685static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4686 struct hda_codec *codec, hda_nid_t nid)
4687{
4688 if (nid == codec->afg)
4689 analog_loop_proc_hook(buffer, codec, 0xfe0);
4690}
4691
4692static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4693 struct hda_codec *codec, hda_nid_t nid)
4694{
4695 if (nid == codec->afg)
4696 analog_loop_proc_hook(buffer, codec, 0xfeb);
4697}
4698#else
4699#define stac92hd_proc_hook NULL
4700#define stac92hd7x_proc_hook NULL
4701#define stac9205_proc_hook NULL
4702#define stac927x_proc_hook NULL
4703#endif
4704
Takashi Iwaicb53c622007-08-10 17:21:45 +02004705#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004706static int stac92xx_resume(struct hda_codec *codec)
4707{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004708 struct sigmatel_spec *spec = codec->spec;
4709
Takashi Iwai2c885872008-11-18 09:36:55 +01004710 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004711 snd_hda_codec_resume_amp(codec);
4712 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004713 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004714 if (spec->hp_detect)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004715 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4716 STAC_HP_EVENT);
Mattff6fdc32005-06-27 15:06:52 +02004717 return 0;
4718}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004719
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004720/*
James Gardiner514bf542009-05-03 04:00:44 -04004721 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004722 * check for mute state only on Speakers (nid = 0x10)
4723 *
4724 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4725 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004726 *
4727 * Changed name to reflect that it now works for any designated
4728 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004729 */
4730
4731#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004732static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004733 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004734{
4735 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004736
4737 if (nid == 0x10) {
4738 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004739 HDA_AMP_MUTE)
Takashi Iwai86d190e2009-05-26 15:18:58 +02004740 spec->gpio_data &= ~spec->gpio_led; /* orange */
Takashi Iwaiba84bfc2009-05-30 08:59:03 +02004741 else
4742 spec->gpio_data |= spec->gpio_led; /* white */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004743
4744 stac_gpio_set(codec, spec->gpio_mask,
4745 spec->gpio_dir,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004746 spec->gpio_data);
4747 }
4748
4749 return 0;
4750}
4751#endif
4752
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004753static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4754{
4755 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai05ff7e12009-07-22 12:39:24 +02004756 int i;
4757 hda_nid_t nid;
4758
4759 /* reset each pin before powering down DAC/ADC to avoid click noise */
4760 nid = codec->start_nid;
4761 for (i = 0; i < codec->num_nodes; i++, nid++) {
4762 unsigned int wcaps = get_wcaps(codec, nid);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004763 unsigned int wid_type = get_wcaps_type(wcaps);
Takashi Iwai05ff7e12009-07-22 12:39:24 +02004764 if (wid_type == AC_WID_PIN)
4765 snd_hda_codec_read(codec, nid, 0,
4766 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4767 }
4768
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004769 if (spec->eapd_mask)
4770 stac_gpio_set(codec, spec->gpio_mask,
4771 spec->gpio_dir, spec->gpio_data &
4772 ~spec->eapd_mask);
4773 return 0;
4774}
Mattff6fdc32005-06-27 15:06:52 +02004775#endif
4776
Matt2f2f4252005-04-13 14:45:30 +02004777static struct hda_codec_ops stac92xx_patch_ops = {
4778 .build_controls = stac92xx_build_controls,
4779 .build_pcms = stac92xx_build_pcms,
4780 .init = stac92xx_init,
4781 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004782 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004783#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004784 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004785 .resume = stac92xx_resume,
4786#endif
Matt2f2f4252005-04-13 14:45:30 +02004787};
4788
4789static int patch_stac9200(struct hda_codec *codec)
4790{
4791 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004792 int err;
Matt2f2f4252005-04-13 14:45:30 +02004793
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004794 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004795 if (spec == NULL)
4796 return -ENOMEM;
4797
4798 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004799 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004800 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004801 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4802 stac9200_models,
4803 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004804 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004805 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4806 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004807 else
4808 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004809 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004810
4811 spec->multiout.max_channels = 2;
4812 spec->multiout.num_dacs = 1;
4813 spec->multiout.dac_nids = stac9200_dac_nids;
4814 spec->adc_nids = stac9200_adc_nids;
4815 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004816 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004817 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004818 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004819 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004820
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004821 if (spec->board_config == STAC_9200_M4 ||
4822 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004823 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004824 spec->init = stac9200_eapd_init;
4825 else
4826 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004827 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004828
Takashi Iwai117f2572008-03-18 09:53:23 +01004829 if (spec->board_config == STAC_9200_PANASONIC) {
4830 spec->gpio_mask = spec->gpio_dir = 0x09;
4831 spec->gpio_data = 0x00;
4832 }
4833
Mattc7d4b2f2005-06-27 14:59:41 +02004834 err = stac9200_parse_auto_config(codec);
4835 if (err < 0) {
4836 stac92xx_free(codec);
4837 return err;
4838 }
Matt2f2f4252005-04-13 14:45:30 +02004839
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004840 /* CF-74 has no headphone detection, and the driver should *NOT*
4841 * do detection and HP/speaker toggle because the hardware does it.
4842 */
4843 if (spec->board_config == STAC_9200_PANASONIC)
4844 spec->hp_detect = 0;
4845
Matt2f2f4252005-04-13 14:45:30 +02004846 codec->patch_ops = stac92xx_patch_ops;
4847
4848 return 0;
4849}
4850
Tobin Davis8e21c342007-01-08 11:04:17 +01004851static int patch_stac925x(struct hda_codec *codec)
4852{
4853 struct sigmatel_spec *spec;
4854 int err;
4855
4856 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4857 if (spec == NULL)
4858 return -ENOMEM;
4859
4860 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004861 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004862 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004863
4864 /* Check first for codec ID */
4865 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4866 STAC_925x_MODELS,
4867 stac925x_models,
4868 stac925x_codec_id_cfg_tbl);
4869
4870 /* Now checks for PCI ID, if codec ID is not found */
4871 if (spec->board_config < 0)
4872 spec->board_config = snd_hda_check_board_config(codec,
4873 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004874 stac925x_models,
4875 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004876 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004877 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004878 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4879 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004880 else
4881 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004882 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004883
4884 spec->multiout.max_channels = 2;
4885 spec->multiout.num_dacs = 1;
4886 spec->multiout.dac_nids = stac925x_dac_nids;
4887 spec->adc_nids = stac925x_adc_nids;
4888 spec->mux_nids = stac925x_mux_nids;
4889 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004890 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004891 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004892 switch (codec->vendor_id) {
4893 case 0x83847632: /* STAC9202 */
4894 case 0x83847633: /* STAC9202D */
4895 case 0x83847636: /* STAC9251 */
4896 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004897 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004898 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004899 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4900 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004901 break;
4902 default:
4903 spec->num_dmics = 0;
4904 break;
4905 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004906
4907 spec->init = stac925x_core_init;
4908 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02004909 spec->num_caps = 1;
4910 spec->capvols = stac925x_capvols;
4911 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01004912
4913 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004914 if (!err) {
4915 if (spec->board_config < 0) {
4916 printk(KERN_WARNING "hda_codec: No auto-config is "
4917 "available, default to model=ref\n");
4918 spec->board_config = STAC_925x_REF;
4919 goto again;
4920 }
4921 err = -EINVAL;
4922 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004923 if (err < 0) {
4924 stac92xx_free(codec);
4925 return err;
4926 }
4927
4928 codec->patch_ops = stac92xx_patch_ops;
4929
4930 return 0;
4931}
4932
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004933static struct hda_input_mux stac92hd73xx_dmux = {
4934 .num_items = 4,
4935 .items = {
4936 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004937 { "Digital Mic 1", 0x09 },
4938 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004939 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004940 }
4941};
4942
4943static int patch_stac92hd73xx(struct hda_codec *codec)
4944{
4945 struct sigmatel_spec *spec;
4946 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4947 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004948 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004949
4950 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4951 if (spec == NULL)
4952 return -ENOMEM;
4953
4954 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004955 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004956 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4957 spec->pin_nids = stac92hd73xx_pin_nids;
4958 spec->board_config = snd_hda_check_board_config(codec,
4959 STAC_92HD73XX_MODELS,
4960 stac92hd73xx_models,
4961 stac92hd73xx_cfg_tbl);
4962again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004963 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004964 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4965 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004966 else
4967 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004968 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004969
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004970 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004971 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4972
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004973 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004974 printk(KERN_WARNING "hda_codec: Could not determine "
4975 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004976 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004977 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004978 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004979 case 0x3: /* 6 Channel */
4980 spec->mixer = stac92hd73xx_6ch_mixer;
4981 spec->init = stac92hd73xx_6ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004982 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004983 break;
4984 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004985 spec->mixer = stac92hd73xx_8ch_mixer;
4986 spec->init = stac92hd73xx_8ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004987 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004988 break;
4989 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004990 spec->mixer = stac92hd73xx_10ch_mixer;
4991 spec->init = stac92hd73xx_10ch_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01004992 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4993 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004994 }
4995 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004996
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004997 spec->aloopback_mask = 0x01;
4998 spec->aloopback_shift = 8;
4999
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005000 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005001 spec->mux_nids = stac92hd73xx_mux_nids;
5002 spec->adc_nids = stac92hd73xx_adc_nids;
5003 spec->dmic_nids = stac92hd73xx_dmic_nids;
5004 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005005 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04005006 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005007 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005008
5009 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5010 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai16970552007-12-18 18:05:52 +01005011 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005012 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
5013 sizeof(stac92hd73xx_dmux));
5014
Takashi Iwai6479c632009-07-28 18:20:25 +02005015 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5016 spec->capvols = stac92hd73xx_capvols;
5017 spec->capsws = stac92hd73xx_capsws;
5018
Matthew Ranostaya7662642008-02-21 07:51:14 +01005019 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005020 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005021 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005022 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005023 case STAC_DELL_M6_AMIC:
5024 case STAC_DELL_M6_DMIC:
5025 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005026 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005027 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
5028 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005029 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005030 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005031
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005032 if (spec->board_config != STAC_DELL_EQ)
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005033 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005034 switch (spec->board_config) {
5035 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005036 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005037 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005038 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005039 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005040 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005041 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005042 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005043 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005044 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005045 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005046 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5047 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005048 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005049 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005050 break;
5051 }
5052 break;
5053 default:
5054 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005055 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005056 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005057 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005058 if (spec->board_config > STAC_92HD73XX_REF) {
5059 /* GPIO0 High = Enable EAPD */
5060 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5061 spec->gpio_data = 0x01;
5062 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005063 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005064
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005065 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5066 spec->pwr_nids = stac92hd73xx_pwr_nids;
5067
Matthew Ranostayd9737752008-09-07 12:03:41 +02005068 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005069
5070 if (!err) {
5071 if (spec->board_config < 0) {
5072 printk(KERN_WARNING "hda_codec: No auto-config is "
5073 "available, default to model=ref\n");
5074 spec->board_config = STAC_92HD73XX_REF;
5075 goto again;
5076 }
5077 err = -EINVAL;
5078 }
5079
5080 if (err < 0) {
5081 stac92xx_free(codec);
5082 return err;
5083 }
5084
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005085 if (spec->board_config == STAC_92HD73XX_NO_JD)
5086 spec->hp_detect = 0;
5087
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005088 codec->patch_ops = stac92xx_patch_ops;
5089
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005090 codec->proc_widget_hook = stac92hd7x_proc_hook;
5091
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005092 return 0;
5093}
5094
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005095static struct hda_input_mux stac92hd83xxx_dmux = {
5096 .num_items = 3,
5097 .items = {
5098 { "Analog Inputs", 0x03 },
5099 { "Digital Mic 1", 0x04 },
5100 { "Digital Mic 2", 0x05 },
5101 }
5102};
5103
5104static int patch_stac92hd83xxx(struct hda_codec *codec)
5105{
5106 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005107 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005108 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005109 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005110 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005111
5112 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5113 if (spec == NULL)
5114 return -ENOMEM;
5115
5116 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005117 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005118 spec->mono_nid = 0x19;
5119 spec->digbeep_nid = 0x21;
5120 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5121 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5122 spec->adc_nids = stac92hd83xxx_adc_nids;
5123 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005124 spec->amp_nids = stac92hd83xxx_amp_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005125 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5126 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005127 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005128
5129 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005130 spec->mixer = stac92hd83xxx_mixer;
5131 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5132 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5133 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayc15c5062009-01-13 13:30:07 -05005134 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005135 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5136 spec->dinput_mux = &stac92hd83xxx_dmux;
5137 spec->pin_nids = stac92hd83xxx_pin_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02005138 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5139 spec->capvols = stac92hd83xxx_capvols;
5140 spec->capsws = stac92hd83xxx_capsws;
5141
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005142 spec->board_config = snd_hda_check_board_config(codec,
5143 STAC_92HD83XXX_MODELS,
5144 stac92hd83xxx_models,
5145 stac92hd83xxx_cfg_tbl);
5146again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005147 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005148 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5149 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005150 else
5151 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005152 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005153
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005154 switch (codec->vendor_id) {
5155 case 0x111d7604:
5156 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005157 case 0x111d76d5:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005158 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5159 break;
5160 spec->num_pwrs = 0;
5161 break;
5162 }
5163
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005164 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5165 if (!err) {
5166 if (spec->board_config < 0) {
5167 printk(KERN_WARNING "hda_codec: No auto-config is "
5168 "available, default to model=ref\n");
5169 spec->board_config = STAC_92HD83XXX_REF;
5170 goto again;
5171 }
5172 err = -EINVAL;
5173 }
5174
5175 if (err < 0) {
5176 stac92xx_free(codec);
5177 return err;
5178 }
5179
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005180 switch (spec->board_config) {
5181 case STAC_DELL_S14:
5182 nid = 0xf;
5183 break;
5184 default:
5185 nid = 0xe;
5186 break;
5187 }
5188
5189 num_dacs = snd_hda_get_connections(codec, nid,
5190 conn, STAC92HD83_DAC_COUNT + 1) - 1;
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02005191 if (num_dacs < 0)
5192 num_dacs = STAC92HD83_DAC_COUNT;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005193
5194 /* set port X to select the last DAC
5195 */
5196 snd_hda_codec_write_cache(codec, nid, 0,
5197 AC_VERB_SET_CONNECT_SEL, num_dacs);
5198
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005199 codec->patch_ops = stac92xx_patch_ops;
5200
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005201 codec->proc_widget_hook = stac92hd_proc_hook;
5202
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005203 return 0;
5204}
5205
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005206static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5207 .num_items = 3,
5208 .items = {
5209 { "Analog Inputs", 0x00 },
5210 { "Digital Mic 1", 0x02 },
5211 { "Digital Mic 2", 0x03 },
5212 }
5213};
5214
5215static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005216 .num_items = 4,
5217 .items = {
5218 { "Analog Inputs", 0x00 },
5219 { "Mixer", 0x01 },
5220 { "Digital Mic 1", 0x02 },
5221 { "Digital Mic 2", 0x03 },
5222 }
5223};
5224
Takashi Iwai330ee992009-02-20 14:33:36 +01005225/* get the pin connection (fixed, none, etc) */
5226static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5227{
5228 struct sigmatel_spec *spec = codec->spec;
5229 unsigned int cfg;
5230
5231 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5232 return get_defcfg_connect(cfg);
5233}
5234
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005235static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5236 hda_nid_t *nids, int num_nids)
5237{
5238 struct sigmatel_spec *spec = codec->spec;
5239 int idx, num;
5240 unsigned int def_conf;
5241
5242 for (num = 0; num < num_nids; num++) {
5243 for (idx = 0; idx < spec->num_pins; idx++)
5244 if (spec->pin_nids[idx] == nids[num])
5245 break;
5246 if (idx >= spec->num_pins)
5247 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01005248 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005249 if (def_conf == AC_JACK_PORT_NONE)
5250 break;
5251 }
5252 return num;
5253}
5254
5255static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5256 hda_nid_t dig0pin)
5257{
5258 struct sigmatel_spec *spec = codec->spec;
5259 int idx;
5260
5261 for (idx = 0; idx < spec->num_pins; idx++)
5262 if (spec->pin_nids[idx] == dig0pin)
5263 break;
5264 if ((idx + 2) >= spec->num_pins)
5265 return 0;
5266
5267 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005268 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005269 return 2;
5270
5271 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005272 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005273 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005274 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005275 return 1;
5276 else
5277 return 0;
5278}
5279
Matthew Ranostaye035b842007-11-06 11:53:55 +01005280static int patch_stac92hd71bxx(struct hda_codec *codec)
5281{
5282 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005283 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005284 int err = 0;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005285 unsigned int ndmic_nids = 0;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005286
5287 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5288 if (spec == NULL)
5289 return -ENOMEM;
5290
5291 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005292 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005293 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5294 switch (codec->vendor_id) {
5295 case 0x111d76b6:
5296 case 0x111d76b7:
5297 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5298 break;
5299 case 0x111d7603:
5300 case 0x111d7608:
5301 /* On 92HD75Bx 0x27 isn't a pin nid */
5302 spec->num_pins--;
5303 /* fallthrough */
5304 default:
5305 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5306 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005307 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005308 spec->board_config = snd_hda_check_board_config(codec,
5309 STAC_92HD71BXX_MODELS,
5310 stac92hd71bxx_models,
5311 stac92hd71bxx_cfg_tbl);
5312again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005313 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005314 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5315 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005316 else
5317 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005318 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005319
Takashi Iwai41c3b642008-11-18 10:45:15 +01005320 if (spec->board_config > STAC_92HD71BXX_REF) {
5321 /* GPIO0 = EAPD */
5322 spec->gpio_mask = 0x01;
5323 spec->gpio_dir = 0x01;
5324 spec->gpio_data = 0x01;
5325 }
5326
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005327 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5328 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5329
Takashi Iwai6479c632009-07-28 18:20:25 +02005330 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5331 spec->capvols = stac92hd71bxx_capvols;
5332 spec->capsws = stac92hd71bxx_capsws;
5333
Matthew Ranostay541eee82007-12-14 12:08:04 +01005334 switch (codec->vendor_id) {
5335 case 0x111d76b6: /* 4 Port without Analog Mixer */
5336 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005337 unmute_init++;
5338 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005339 case 0x111d76b4: /* 6 Port without Analog Mixer */
5340 case 0x111d76b5:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005341 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5342 sizeof(stac92hd71bxx_dmux_nomixer));
Matthew Ranostay541eee82007-12-14 12:08:04 +01005343 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005344 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005345 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5346 stac92hd71bxx_dmic_nids,
5347 STAC92HD71BXX_NUM_DMICS);
5348 if (spec->num_dmics) {
5349 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5350 spec->dinput_mux = &spec->private_dimux;
5351 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5352 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01005353 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005354 case 0x111d7608: /* 5 Port with Analog Mixer */
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005355 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5356 sizeof(stac92hd71bxx_dmux_amixer));
5357 spec->private_dimux.num_items--;
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005358 switch (spec->board_config) {
5359 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005360 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005361 err = stac_add_event(spec, codec->afg,
5362 STAC_VREF_EVENT, 0x02);
5363 if (err < 0)
5364 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005365 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005366 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5367 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005368 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005369 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005370 spec->gpio_mask |= 0x02;
5371 break;
5372 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005373 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005374 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005375 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005376
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005377 /* no output amps */
5378 spec->num_pwrs = 0;
Takashi Iwai50c62f02009-07-28 18:25:29 +02005379 if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1)
5380 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005381
5382 /* disable VSW */
5383 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005384 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005385 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5386 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005387 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5388 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5389 stac92hd71bxx_dmic_nids,
5390 STAC92HD71BXX_NUM_DMICS - 1);
Takashi Iwai44179322009-07-28 17:03:49 +02005391 if (spec->num_dmics) {
5392 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5393 spec->dinput_mux = &spec->private_dimux;
5394 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5395 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005396 break;
5397 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005398 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005399 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005400
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005401 /* no output amps */
5402 spec->num_pwrs = 0;
5403 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005404 default:
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005405 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5406 sizeof(stac92hd71bxx_dmux_amixer));
Takashi Iwai50c62f02009-07-28 18:25:29 +02005407 if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1)
5408 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005409 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005410 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005411 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5412 stac92hd71bxx_dmic_nids,
5413 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai44179322009-07-28 17:03:49 +02005414 if (spec->num_dmics) {
5415 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5416 spec->dinput_mux = &spec->private_dimux;
5417 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5418 }
Matthew Ranostay541eee82007-12-14 12:08:04 +01005419 }
5420
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005421 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5422 snd_hda_sequence_write_cache(codec, unmute_init);
5423
Takashi Iwaib20f3b82009-06-02 01:20:22 +02005424 /* Some HP machines seem to have unstable codec communications
5425 * especially with ATI fglrx driver. For recovering from the
5426 * CORB/RIRB stall, allow the BUS reset and keep always sync
5427 */
5428 if (spec->board_config == STAC_HP_DV5) {
5429 codec->bus->sync_write = 1;
5430 codec->bus->allow_bus_reset = 1;
5431 }
5432
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005433 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005434 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005435 spec->aloopback_shift = 0;
5436
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005437 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005438 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005439 spec->mux_nids = stac92hd71bxx_mux_nids;
5440 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005441 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005442 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005443
5444 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5445 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005446 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005447
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005448 switch (spec->board_config) {
5449 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005450 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005451 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005452 stac92xx_auto_set_pinctl(codec, 0x0e,
5453 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005454 /* fallthru */
5455 case STAC_DELL_M4_2:
5456 spec->num_dmics = 0;
5457 spec->num_smuxes = 0;
5458 spec->num_dmuxes = 0;
5459 break;
5460 case STAC_DELL_M4_1:
5461 case STAC_DELL_M4_3:
5462 spec->num_dmics = 1;
5463 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005464 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005465 break;
James Gardiner514bf542009-05-03 04:00:44 -04005466 case STAC_HP_DV4_1222NR:
5467 spec->num_dmics = 1;
5468 /* I don't know if it needs 1 or 2 smuxes - will wait for
5469 * bug reports to fix if needed
5470 */
5471 spec->num_smuxes = 1;
5472 spec->num_dmuxes = 1;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005473 spec->gpio_led = 0x01;
James Gardiner514bf542009-05-03 04:00:44 -04005474 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005475 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005476 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005477 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5478 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005479 case STAC_HP_HDX:
5480 spec->num_dmics = 1;
5481 spec->num_dmuxes = 1;
5482 spec->num_smuxes = 1;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005483 /* orange/white mute led on GPIO3, orange=0, white=1 */
Takashi Iwai86d190e2009-05-26 15:18:58 +02005484 spec->gpio_led = 0x08;
5485 break;
5486 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005487
Takashi Iwai86d190e2009-05-26 15:18:58 +02005488#ifdef CONFIG_SND_HDA_POWER_SAVE
5489 if (spec->gpio_led) {
5490 spec->gpio_mask |= spec->gpio_led;
5491 spec->gpio_dir |= spec->gpio_led;
5492 spec->gpio_data |= spec->gpio_led;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005493 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005494 codec->patch_ops.check_power_status =
Takashi Iwai86d190e2009-05-26 15:18:58 +02005495 stac92xx_hp_check_power_status;
5496 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005497#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005498
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005499 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005500 if (spec->dinput_mux)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005501 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005502
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005503 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005504 if (!err) {
5505 if (spec->board_config < 0) {
5506 printk(KERN_WARNING "hda_codec: No auto-config is "
5507 "available, default to model=ref\n");
5508 spec->board_config = STAC_92HD71BXX_REF;
5509 goto again;
5510 }
5511 err = -EINVAL;
5512 }
5513
5514 if (err < 0) {
5515 stac92xx_free(codec);
5516 return err;
5517 }
5518
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005519 codec->proc_widget_hook = stac92hd7x_proc_hook;
5520
Matthew Ranostaye035b842007-11-06 11:53:55 +01005521 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005522}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005523
Matt2f2f4252005-04-13 14:45:30 +02005524static int patch_stac922x(struct hda_codec *codec)
5525{
5526 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005527 int err;
Matt2f2f4252005-04-13 14:45:30 +02005528
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005529 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005530 if (spec == NULL)
5531 return -ENOMEM;
5532
5533 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005534 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005535 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005536 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5537 stac922x_models,
5538 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005539 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005540 spec->gpio_mask = spec->gpio_dir = 0x03;
5541 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005542 /* Intel Macs have all same PCI SSID, so we need to check
5543 * codec SSID to distinguish the exact models
5544 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005545 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005546 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005547
5548 case 0x106b0800:
5549 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005550 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005551 case 0x106b0600:
5552 case 0x106b0700:
5553 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005554 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005555 case 0x106b0e00:
5556 case 0x106b0f00:
5557 case 0x106b1600:
5558 case 0x106b1700:
5559 case 0x106b0200:
5560 case 0x106b1e00:
5561 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005562 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005563 case 0x106b1a00:
5564 case 0x00000100:
5565 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005566 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005567 case 0x106b0a00:
5568 case 0x106b2200:
5569 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005570 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005571 default:
5572 spec->board_config = STAC_INTEL_MAC_V3;
5573 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005574 }
5575 }
5576
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005577 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005578 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005579 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5580 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005581 else
5582 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005583 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005584
Matt2f2f4252005-04-13 14:45:30 +02005585 spec->adc_nids = stac922x_adc_nids;
5586 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005587 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005588 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005589 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005590 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005591
5592 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005593
5594 spec->num_caps = STAC922X_NUM_CAPS;
5595 spec->capvols = stac922x_capvols;
5596 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005597
5598 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005599
Matt Porter3cc08dc2006-01-23 15:27:49 +01005600 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005601 if (!err) {
5602 if (spec->board_config < 0) {
5603 printk(KERN_WARNING "hda_codec: No auto-config is "
5604 "available, default to model=ref\n");
5605 spec->board_config = STAC_D945_REF;
5606 goto again;
5607 }
5608 err = -EINVAL;
5609 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005610 if (err < 0) {
5611 stac92xx_free(codec);
5612 return err;
5613 }
5614
5615 codec->patch_ops = stac92xx_patch_ops;
5616
Takashi Iwai807a46362007-05-29 19:01:37 +02005617 /* Fix Mux capture level; max to 2 */
5618 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5619 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5620 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5621 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5622 (0 << AC_AMPCAP_MUTE_SHIFT));
5623
Matt Porter3cc08dc2006-01-23 15:27:49 +01005624 return 0;
5625}
5626
5627static int patch_stac927x(struct hda_codec *codec)
5628{
5629 struct sigmatel_spec *spec;
5630 int err;
5631
5632 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5633 if (spec == NULL)
5634 return -ENOMEM;
5635
5636 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005637 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005638 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005639 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005640 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5641 stac927x_models,
5642 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005643 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005644 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005645 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5646 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005647 else
5648 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005649 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005650
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005651 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005652 spec->adc_nids = stac927x_adc_nids;
5653 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5654 spec->mux_nids = stac927x_mux_nids;
5655 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005656 spec->smux_nids = stac927x_smux_nids;
5657 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005658 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005659 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005660 spec->multiout.dac_nids = spec->dac_nids;
5661
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005662 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005663 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005664 case STAC_D965_5ST:
5665 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005666 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005667 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005668 spec->num_dmics = 0;
5669
Tobin Davis93ed1502006-09-01 21:03:12 +02005670 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005671 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005672 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005673 switch (codec->subsystem_id) {
5674 case 0x10280209:
5675 case 0x1028022e:
5676 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005677 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005678 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005679 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005680 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005681 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005682 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005683 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005684 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005685 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005686 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005687 case STAC_DELL_3ST:
5688 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005689 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005690 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005691 spec->dmic_nids = stac927x_dmic_nids;
5692 spec->num_dmics = STAC927X_NUM_DMICS;
5693
Tobin Davis93ed1502006-09-01 21:03:12 +02005694 spec->init = d965_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005695 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01005696 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005697 break;
5698 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005699 if (spec->board_config > STAC_D965_REF) {
5700 /* GPIO0 High = Enable EAPD */
5701 spec->eapd_mask = spec->gpio_mask = 0x01;
5702 spec->gpio_dir = spec->gpio_data = 0x01;
5703 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005704 spec->num_dmics = 0;
5705
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005706 spec->init = stac927x_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005707 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005708
Takashi Iwai6479c632009-07-28 18:20:25 +02005709 spec->num_caps = STAC927X_NUM_CAPS;
5710 spec->capvols = stac927x_capvols;
5711 spec->capsws = stac927x_capsws;
5712
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005713 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005714 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005715 spec->aloopback_mask = 0x40;
5716 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005717 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005718
Matt Porter3cc08dc2006-01-23 15:27:49 +01005719 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005720 if (!err) {
5721 if (spec->board_config < 0) {
5722 printk(KERN_WARNING "hda_codec: No auto-config is "
5723 "available, default to model=ref\n");
5724 spec->board_config = STAC_D965_REF;
5725 goto again;
5726 }
5727 err = -EINVAL;
5728 }
Mattc7d4b2f2005-06-27 14:59:41 +02005729 if (err < 0) {
5730 stac92xx_free(codec);
5731 return err;
5732 }
Matt2f2f4252005-04-13 14:45:30 +02005733
5734 codec->patch_ops = stac92xx_patch_ops;
5735
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005736 codec->proc_widget_hook = stac927x_proc_hook;
5737
Takashi Iwai52987652008-01-16 16:09:47 +01005738 /*
5739 * !!FIXME!!
5740 * The STAC927x seem to require fairly long delays for certain
5741 * command sequences. With too short delays (even if the answer
5742 * is set to RIRB properly), it results in the silence output
5743 * on some hardwares like Dell.
5744 *
5745 * The below flag enables the longer delay (see get_response
5746 * in hda_intel.c).
5747 */
5748 codec->bus->needs_damn_long_delay = 1;
5749
Takashi Iwaie28d8322008-12-17 13:48:29 +01005750 /* no jack detecion for ref-no-jd model */
5751 if (spec->board_config == STAC_D965_REF_NO_JD)
5752 spec->hp_detect = 0;
5753
Matt2f2f4252005-04-13 14:45:30 +02005754 return 0;
5755}
5756
Matt Porterf3302a52006-07-31 12:49:34 +02005757static int patch_stac9205(struct hda_codec *codec)
5758{
5759 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005760 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005761
5762 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5763 if (spec == NULL)
5764 return -ENOMEM;
5765
5766 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005767 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005768 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005769 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5770 stac9205_models,
5771 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005772 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005773 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005774 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5775 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005776 else
5777 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005778 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005779
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005780 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005781 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005782 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005783 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005784 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005785 spec->smux_nids = stac9205_smux_nids;
5786 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005787 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005788 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005789 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01005790 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005791 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005792
5793 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005794 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02005795
Takashi Iwai6479c632009-07-28 18:20:25 +02005796 spec->num_caps = STAC9205_NUM_CAPS;
5797 spec->capvols = stac9205_capvols;
5798 spec->capsws = stac9205_capsws;
5799
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005800 spec->aloopback_mask = 0x40;
5801 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005802 /* Turn on/off EAPD per HP plugging */
5803 if (spec->board_config != STAC_9205_EAPD)
5804 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005805 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005806
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005807 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005808 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005809 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005810 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5811 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005812
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005813 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005814 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5815 if (err < 0)
5816 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005817 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005818 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5819 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005820 AC_VERB_SET_UNSOLICITED_ENABLE,
5821 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005822
5823 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005824 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005825 spec->gpio_mask = 0x1b;
5826 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005827 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005828 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005829 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005830 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005831 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005832 case STAC_9205_REF:
5833 /* SPDIF-In enabled */
5834 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005835 default:
5836 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005837 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005838 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005839 break;
5840 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005841
Matt Porterf3302a52006-07-31 12:49:34 +02005842 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005843 if (!err) {
5844 if (spec->board_config < 0) {
5845 printk(KERN_WARNING "hda_codec: No auto-config is "
5846 "available, default to model=ref\n");
5847 spec->board_config = STAC_9205_REF;
5848 goto again;
5849 }
5850 err = -EINVAL;
5851 }
Matt Porterf3302a52006-07-31 12:49:34 +02005852 if (err < 0) {
5853 stac92xx_free(codec);
5854 return err;
5855 }
5856
5857 codec->patch_ops = stac92xx_patch_ops;
5858
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005859 codec->proc_widget_hook = stac9205_proc_hook;
5860
Matt Porterf3302a52006-07-31 12:49:34 +02005861 return 0;
5862}
5863
Matt2f2f4252005-04-13 14:45:30 +02005864/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005865 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005866 */
5867
Takashi Iwai1e137f92009-01-21 07:41:22 +01005868static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005869 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005870 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5871 {}
5872};
5873
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005874static hda_nid_t stac9872_pin_nids[] = {
5875 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5876 0x11, 0x13, 0x14,
5877};
5878
5879static hda_nid_t stac9872_adc_nids[] = {
5880 0x8 /*,0x6*/
5881};
5882
5883static hda_nid_t stac9872_mux_nids[] = {
5884 0x15
5885};
5886
Takashi Iwai6479c632009-07-28 18:20:25 +02005887static unsigned long stac9872_capvols[] = {
5888 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5889};
5890#define stac9872_capsws stac9872_capvols
5891
Takashi Iwai307282c2009-03-12 18:17:58 +01005892static unsigned int stac9872_vaio_pin_configs[9] = {
5893 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5894 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5895 0x90a7013e
5896};
5897
5898static const char *stac9872_models[STAC_9872_MODELS] = {
5899 [STAC_9872_AUTO] = "auto",
5900 [STAC_9872_VAIO] = "vaio",
5901};
5902
5903static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5904 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5905};
5906
5907static struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02005908 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5909 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01005910 {} /* terminator */
5911};
5912
Guillaume Munch6d859062006-08-22 17:15:47 +02005913static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005914{
5915 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005916 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005917
Takashi Iwaidb064e52006-03-16 16:04:58 +01005918 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5919 if (spec == NULL)
5920 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005921 codec->spec = spec;
Takashi Iwaib04add92009-07-20 08:01:36 +02005922 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5923 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005924
5925 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5926 stac9872_models,
5927 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01005928 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005929 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5930 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01005931 else
5932 stac92xx_set_config_regs(codec,
5933 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005934
Takashi Iwai1e137f92009-01-21 07:41:22 +01005935 spec->multiout.dac_nids = spec->dac_nids;
5936 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5937 spec->adc_nids = stac9872_adc_nids;
5938 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5939 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005940 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005941 spec->num_caps = 1;
5942 spec->capvols = stac9872_capvols;
5943 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005944
Takashi Iwai1e137f92009-01-21 07:41:22 +01005945 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5946 if (err < 0) {
5947 stac92xx_free(codec);
5948 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005949 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005950 spec->input_mux = &spec->private_imux;
5951 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005952 return 0;
5953}
5954
5955
5956/*
Matt2f2f4252005-04-13 14:45:30 +02005957 * patch entries
5958 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005959static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005960 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5961 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5962 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5963 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5964 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5965 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5966 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005967 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5968 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5969 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5970 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5971 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5972 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005973 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5974 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5975 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5976 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5977 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5978 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5979 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5980 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5981 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5982 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005983 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5984 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5985 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5986 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5987 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5988 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005989 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5990 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005991 /* The following does not take into account .id=0x83847661 when subsys =
5992 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5993 * currently not fully supported.
5994 */
5995 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5996 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5997 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01005998 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02005999 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6000 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6001 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6002 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6003 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6004 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6005 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6006 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006007 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006008 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6009 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006010 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006011 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006012 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6013 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006014 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006015 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6016 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6017 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6018 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6019 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6020 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6021 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6022 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02006023 {} /* terminator */
6024};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006025
6026MODULE_ALIAS("snd-hda-codec-id:8384*");
6027MODULE_ALIAS("snd-hda-codec-id:111d*");
6028
6029MODULE_LICENSE("GPL");
6030MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6031
6032static struct hda_codec_preset_list sigmatel_list = {
6033 .preset = snd_hda_preset_sigmatel,
6034 .owner = THIS_MODULE,
6035};
6036
6037static int __init patch_sigmatel_init(void)
6038{
6039 return snd_hda_add_codec_preset(&sigmatel_list);
6040}
6041
6042static void __exit patch_sigmatel_exit(void)
6043{
6044 snd_hda_delete_codec_preset(&sigmatel_list);
6045}
6046
6047module_init(patch_sigmatel_init)
6048module_exit(patch_sigmatel_exit)