blob: b8d730c47df1099ded7f9087616a0244d64f522e [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>
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +010031#include <linux/dmi.h>
Matt2f2f4252005-04-13 14:45:30 +020032#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020033#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040034#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020035#include "hda_codec.h"
36#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020037#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020038
Takashi Iwaic6e4c662008-11-25 11:58:19 +010039enum {
40 STAC_VREF_EVENT = 1,
41 STAC_INSERT_EVENT,
42 STAC_PWR_EVENT,
43 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020044 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020045 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010046};
Matt4e550962005-07-04 17:51:39 +020047
Takashi Iwaif5fcc132006-11-24 17:07:44 +010048enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010049 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010050 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010051 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020052 STAC_9200_DELL_D21,
53 STAC_9200_DELL_D22,
54 STAC_9200_DELL_D23,
55 STAC_9200_DELL_M21,
56 STAC_9200_DELL_M22,
57 STAC_9200_DELL_M23,
58 STAC_9200_DELL_M24,
59 STAC_9200_DELL_M25,
60 STAC_9200_DELL_M26,
61 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020062 STAC_9200_M4,
63 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010064 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010065 STAC_9200_MODELS
66};
67
68enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010069 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010070 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020071 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020072 STAC_9205_DELL_M43,
73 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010074 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010075 STAC_9205_MODELS
76};
77
78enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010079 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010080 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010081 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080082 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010083 STAC_DELL_M6_AMIC,
84 STAC_DELL_M6_DMIC,
85 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050086 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020087 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010088 STAC_92HD73XX_MODELS
89};
90
91enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010092 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020093 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050094 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050095 STAC_DELL_S14,
Takashi Iwaib4e81872009-11-18 17:20:24 +010096 STAC_92HD83XXX_HP,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020097 STAC_92HD83XXX_MODELS
98};
99
100enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100101 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100102 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100103 STAC_DELL_M4_1,
104 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500105 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400106 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200107 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100108 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100109 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400110 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100111 STAC_92HD71BXX_MODELS
112};
113
114enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100115 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100116 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200117 STAC_M1,
118 STAC_M1_2,
119 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100120 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200121 STAC_M3,
122 STAC_M5,
123 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100124 STAC_925x_MODELS
125};
126
127enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100128 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100129 STAC_D945_REF,
130 STAC_D945GTP3,
131 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200132 STAC_INTEL_MAC_V1,
133 STAC_INTEL_MAC_V2,
134 STAC_INTEL_MAC_V3,
135 STAC_INTEL_MAC_V4,
136 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800137 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
138 * is given, one of the above models will be
139 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200140 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100141 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100142 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100143 STAC_MACBOOK_PRO_V1,
144 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200145 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200146 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300147 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200148 STAC_922X_DELL_D81,
149 STAC_922X_DELL_D82,
150 STAC_922X_DELL_M81,
151 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100152 STAC_922X_MODELS
153};
154
155enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100156 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100157 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100158 STAC_D965_REF,
159 STAC_D965_3ST,
160 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200161 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200162 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100163 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200164 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100165 STAC_927X_MODELS
166};
Matt Porter403d1942005-11-29 15:00:51 +0100167
Takashi Iwai307282c2009-03-12 18:17:58 +0100168enum {
169 STAC_9872_AUTO,
170 STAC_9872_VAIO,
171 STAC_9872_MODELS
172};
173
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400174struct sigmatel_event {
175 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100176 unsigned char type;
177 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400178 int data;
179};
180
181struct sigmatel_jack {
182 hda_nid_t nid;
183 int type;
184 struct snd_jack *jack;
185};
186
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200187struct sigmatel_mic_route {
188 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200189 signed char mux_idx;
190 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200191};
192
Matt2f2f4252005-04-13 14:45:30 +0200193struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100194 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200195 unsigned int num_mixers;
196
Matt Porter403d1942005-11-29 15:00:51 +0100197 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500198 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200199 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100200 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100201 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400202 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100203 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200204 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100205 unsigned int linear_tone_beep:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200206
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100207 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200208 unsigned int eapd_mask;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100209 unsigned int gpio_mask;
210 unsigned int gpio_dir;
211 unsigned int gpio_data;
212 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200213 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100214 unsigned int gpio_led_polarity;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100215
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200216 /* stream */
217 unsigned int stream_delay;
218
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100219 /* analog loopback */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100220 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100221 unsigned char aloopback_mask;
222 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200223
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100224 /* power management */
225 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200226 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100228 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100229
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400230 /* jack detection */
231 struct snd_array jacks;
232
233 /* events */
234 struct snd_array events;
235
Matt2f2f4252005-04-13 14:45:30 +0200236 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100237 struct hda_input_mux *mono_mux;
238 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200239 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100240 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100241 hda_nid_t hp_dacs[5];
242 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200243
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100244 int volume_offset;
245
Matt2f2f4252005-04-13 14:45:30 +0200246 /* capture */
247 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200248 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200249 hda_nid_t *mux_nids;
250 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200251 hda_nid_t *dmic_nids;
252 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100253 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100254 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200255 hda_nid_t *smux_nids;
256 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200257 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200258
259 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
260 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
261 unsigned int num_caps; /* number of capture volume/switch elements */
262
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200263 struct sigmatel_mic_route ext_mic;
264 struct sigmatel_mic_route int_mic;
265
Matthew Ranostay65973632008-09-16 10:39:37 -0400266 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200267
Mattdabbed62005-06-14 10:19:34 +0200268 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100269 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200270 hda_nid_t anabeep_nid;
271 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200272
Matt2f2f4252005-04-13 14:45:30 +0200273 /* pin widgets */
274 hda_nid_t *pin_nids;
275 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200276
277 /* codec specific stuff */
278 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100279 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200280
281 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200282 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100283 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200284 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100285 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200286 struct hda_input_mux *sinput_mux;
287 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400288 unsigned int cur_amux;
289 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200290 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200291
Matt Porter403d1942005-11-29 15:00:51 +0100292 /* i/o switches */
293 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200294 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100295 hda_nid_t line_switch; /* shared line-in for input and output */
296 hda_nid_t mic_switch; /* shared mic-in for input and output */
297 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200298 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200299
Mattc7d4b2f2005-06-27 14:59:41 +0200300 struct hda_pcm pcm_rec[2]; /* PCM information */
301
302 /* dynamic controls and input_mux */
303 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200304 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200305 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200306 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200307 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100308 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200309};
310
311static hda_nid_t stac9200_adc_nids[1] = {
312 0x03,
313};
314
315static hda_nid_t stac9200_mux_nids[1] = {
316 0x0c,
317};
318
319static hda_nid_t stac9200_dac_nids[1] = {
320 0x02,
321};
322
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100323static hda_nid_t stac92hd73xx_pwr_nids[8] = {
324 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
325 0x0f, 0x10, 0x11
326};
327
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400328static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
329 0x26, 0,
330};
331
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100332static hda_nid_t stac92hd73xx_adc_nids[2] = {
333 0x1a, 0x1b
334};
335
336#define STAC92HD73XX_NUM_DMICS 2
337static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
338 0x13, 0x14, 0
339};
340
341#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100342
Takashi Iwaie2aec172009-09-02 01:00:05 +0200343static hda_nid_t stac92hd73xx_mux_nids[2] = {
344 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345};
346
347static hda_nid_t stac92hd73xx_dmux_nids[2] = {
348 0x20, 0x21,
349};
350
Matthew Ranostayd9737752008-09-07 12:03:41 +0200351static hda_nid_t stac92hd73xx_smux_nids[2] = {
352 0x22, 0x23,
353};
354
Takashi Iwai6479c632009-07-28 18:20:25 +0200355#define STAC92HD73XX_NUM_CAPS 2
356static unsigned long stac92hd73xx_capvols[] = {
357 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
358 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
359};
360#define stac92hd73xx_capsws stac92hd73xx_capvols
361
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200362#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200363
Takashi Iwai667067d2009-08-13 18:14:42 +0200364static hda_nid_t stac92hd83xxx_mux_nids[2] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200365 0x17, 0x18,
366};
367
368static hda_nid_t stac92hd83xxx_adc_nids[2] = {
369 0x15, 0x16,
370};
371
372static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
373 0xa, 0xb, 0xd, 0xe,
374};
375
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400376static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
377 0x1e, 0,
378};
379
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200380static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500381 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200382};
383
Takashi Iwai6479c632009-07-28 18:20:25 +0200384#define STAC92HD83XXX_NUM_CAPS 2
385static unsigned long stac92hd83xxx_capvols[] = {
386 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
387 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
388};
389#define stac92hd83xxx_capsws stac92hd83xxx_capvols
390
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100391static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
392 0x0a, 0x0d, 0x0f
393};
394
Matthew Ranostaye035b842007-11-06 11:53:55 +0100395static hda_nid_t stac92hd71bxx_adc_nids[2] = {
396 0x12, 0x13,
397};
398
399static hda_nid_t stac92hd71bxx_mux_nids[2] = {
400 0x1a, 0x1b
401};
402
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400403static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
404 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100405};
406
Matthew Ranostayd9737752008-09-07 12:03:41 +0200407static hda_nid_t stac92hd71bxx_smux_nids[2] = {
408 0x24, 0x25,
409};
410
Matthew Ranostaye035b842007-11-06 11:53:55 +0100411#define STAC92HD71BXX_NUM_DMICS 2
412static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
413 0x18, 0x19, 0
414};
415
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400416static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
417 0x22, 0
418};
419
Takashi Iwai6479c632009-07-28 18:20:25 +0200420#define STAC92HD71BXX_NUM_CAPS 2
421static unsigned long stac92hd71bxx_capvols[] = {
422 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
423 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
424};
425#define stac92hd71bxx_capsws stac92hd71bxx_capvols
426
Tobin Davis8e21c342007-01-08 11:04:17 +0100427static hda_nid_t stac925x_adc_nids[1] = {
428 0x03,
429};
430
431static hda_nid_t stac925x_mux_nids[1] = {
432 0x0f,
433};
434
435static hda_nid_t stac925x_dac_nids[1] = {
436 0x02,
437};
438
Takashi Iwaif6e98522007-10-16 14:27:04 +0200439#define STAC925X_NUM_DMICS 1
440static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
441 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200442};
443
Takashi Iwai1697055e2007-12-18 18:05:52 +0100444static hda_nid_t stac925x_dmux_nids[1] = {
445 0x14,
446};
447
Takashi Iwai6479c632009-07-28 18:20:25 +0200448static unsigned long stac925x_capvols[] = {
449 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
450};
451static unsigned long stac925x_capsws[] = {
452 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
453};
454
Matt2f2f4252005-04-13 14:45:30 +0200455static hda_nid_t stac922x_adc_nids[2] = {
456 0x06, 0x07,
457};
458
459static hda_nid_t stac922x_mux_nids[2] = {
460 0x12, 0x13,
461};
462
Takashi Iwai6479c632009-07-28 18:20:25 +0200463#define STAC922X_NUM_CAPS 2
464static unsigned long stac922x_capvols[] = {
465 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
466 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
467};
468#define stac922x_capsws stac922x_capvols
469
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500470static hda_nid_t stac927x_slave_dig_outs[2] = {
471 0x1f, 0,
472};
473
Matt Porter3cc08dc2006-01-23 15:27:49 +0100474static hda_nid_t stac927x_adc_nids[3] = {
475 0x07, 0x08, 0x09
476};
477
478static hda_nid_t stac927x_mux_nids[3] = {
479 0x15, 0x16, 0x17
480};
481
Matthew Ranostayd9737752008-09-07 12:03:41 +0200482static hda_nid_t stac927x_smux_nids[1] = {
483 0x21,
484};
485
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100486static hda_nid_t stac927x_dac_nids[6] = {
487 0x02, 0x03, 0x04, 0x05, 0x06, 0
488};
489
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100490static hda_nid_t stac927x_dmux_nids[1] = {
491 0x1b,
492};
493
Matthew Ranostay7f168592007-10-18 17:38:17 +0200494#define STAC927X_NUM_DMICS 2
495static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
496 0x13, 0x14, 0
497};
498
Takashi Iwai6479c632009-07-28 18:20:25 +0200499#define STAC927X_NUM_CAPS 3
500static unsigned long stac927x_capvols[] = {
501 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
502 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
503 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
504};
505static unsigned long stac927x_capsws[] = {
506 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
507 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
508 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
509};
510
Matthew Ranostay65973632008-09-16 10:39:37 -0400511static const char *stac927x_spdif_labels[5] = {
512 "Digital Playback", "ADAT", "Analog Mux 1",
513 "Analog Mux 2", "Analog Mux 3"
514};
515
Matt Porterf3302a52006-07-31 12:49:34 +0200516static hda_nid_t stac9205_adc_nids[2] = {
517 0x12, 0x13
518};
519
520static hda_nid_t stac9205_mux_nids[2] = {
521 0x19, 0x1a
522};
523
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100524static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100525 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100526};
527
Matthew Ranostayd9737752008-09-07 12:03:41 +0200528static hda_nid_t stac9205_smux_nids[1] = {
529 0x21,
530};
531
Takashi Iwaif6e98522007-10-16 14:27:04 +0200532#define STAC9205_NUM_DMICS 2
533static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
534 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200535};
536
Takashi Iwai6479c632009-07-28 18:20:25 +0200537#define STAC9205_NUM_CAPS 2
538static unsigned long stac9205_capvols[] = {
539 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
540 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
541};
542static unsigned long stac9205_capsws[] = {
543 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
544 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
545};
546
Mattc7d4b2f2005-06-27 14:59:41 +0200547static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200548 0x08, 0x09, 0x0d, 0x0e,
549 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200550};
551
Tobin Davis8e21c342007-01-08 11:04:17 +0100552static hda_nid_t stac925x_pin_nids[8] = {
553 0x07, 0x08, 0x0a, 0x0b,
554 0x0c, 0x0d, 0x10, 0x11,
555};
556
Matt2f2f4252005-04-13 14:45:30 +0200557static hda_nid_t stac922x_pin_nids[10] = {
558 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
559 0x0f, 0x10, 0x11, 0x15, 0x1b,
560};
561
Matthew Ranostaya7662642008-02-21 07:51:14 +0100562static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100563 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
564 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200565 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100566};
567
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500568static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200569 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500570 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200571};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500572
Charles Chin36706002010-01-29 12:05:51 +0100573static hda_nid_t stac92hd88xxx_pin_nids[10] = {
574 0x0a, 0x0b, 0x0c, 0x0d,
575 0x0f, 0x11, 0x1f, 0x20,
576};
577
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500578#define STAC92HD71BXX_NUM_PINS 13
579static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
580 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
581 0x00, 0x14, 0x18, 0x19, 0x1e,
582 0x1f, 0x20, 0x27
583};
584static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100585 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
586 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500587 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100588};
589
Matt Porter3cc08dc2006-01-23 15:27:49 +0100590static hda_nid_t stac927x_pin_nids[14] = {
591 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
592 0x0f, 0x10, 0x11, 0x12, 0x13,
593 0x14, 0x21, 0x22, 0x23,
594};
595
Matt Porterf3302a52006-07-31 12:49:34 +0200596static hda_nid_t stac9205_pin_nids[12] = {
597 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
598 0x0f, 0x14, 0x16, 0x17, 0x18,
599 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200600};
601
Matt Porter8b657272006-10-26 17:12:59 +0200602static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_info *uinfo)
604{
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
608}
609
610static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
612{
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100615 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200616
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100617 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200618 return 0;
619}
620
621static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100626 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200627
628 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100629 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200630}
631
Matthew Ranostayd9737752008-09-07 12:03:41 +0200632static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_info *uinfo)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
638}
639
640static int stac92xx_smux_enum_get(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;
645 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
646
647 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
648 return 0;
649}
650
651static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400656 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200657 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400658 int err, val;
659 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200660
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400661 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200662 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400663 if (err < 0)
664 return err;
665
666 if (spec->spdif_mute) {
667 if (smux_idx == 0)
668 nid = spec->multiout.dig_out_nid;
669 else
670 nid = codec->slave_dig_outs[smux_idx - 1];
671 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100672 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400673 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100674 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400675 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100676 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
677 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400678 }
679 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200680}
681
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200682static unsigned int stac92xx_vref_set(struct hda_codec *codec,
683 hda_nid_t nid, unsigned int new_vref)
684{
Takashi Iwaib8621512009-06-22 08:00:10 +0200685 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200686 unsigned int pincfg;
687 pincfg = snd_hda_codec_read(codec, nid, 0,
688 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
689
690 pincfg &= 0xff;
691 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
692 pincfg |= new_vref;
693
694 if (new_vref == AC_PINCTL_VREF_HIZ)
695 pincfg |= AC_PINCTL_OUT_EN;
696 else
697 pincfg |= AC_PINCTL_IN_EN;
698
699 error = snd_hda_codec_write_cache(codec, nid, 0,
700 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
701 if (error < 0)
702 return error;
703 else
704 return 1;
705}
706
707static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
708{
709 unsigned int vref;
710 vref = snd_hda_codec_read(codec, nid, 0,
711 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
712 vref &= AC_PINCTL_VREFEN;
713 return vref;
714}
715
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100716static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200717{
718 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
719 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200720 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200721}
722
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100723static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200724{
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 struct sigmatel_spec *spec = codec->spec;
727 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
728
729 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
730 return 0;
731}
732
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100733static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200734{
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 struct sigmatel_spec *spec = codec->spec;
737 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200738 const struct hda_input_mux *imux = spec->input_mux;
739 unsigned int idx, prev_idx;
Matt2f2f4252005-04-13 14:45:30 +0200740
Takashi Iwai5207e102009-07-30 13:09:08 +0200741 idx = ucontrol->value.enumerated.item[0];
742 if (idx >= imux->num_items)
743 idx = imux->num_items - 1;
744 prev_idx = spec->cur_mux[adc_idx];
745 if (prev_idx == idx)
746 return 0;
747 if (idx < spec->num_analog_muxes) {
748 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
749 AC_VERB_SET_CONNECT_SEL,
750 imux->items[idx].index);
751 if (prev_idx >= spec->num_analog_muxes) {
752 imux = spec->dinput_mux;
753 /* 0 = analog */
754 snd_hda_codec_write_cache(codec,
755 spec->dmux_nids[adc_idx], 0,
756 AC_VERB_SET_CONNECT_SEL,
757 imux->items[0].index);
758 }
759 } else {
760 imux = spec->dinput_mux;
761 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
762 AC_VERB_SET_CONNECT_SEL,
763 imux->items[idx - 1].index);
764 }
765 spec->cur_mux[adc_idx] = idx;
766 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200767}
768
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100769static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
770 struct snd_ctl_elem_info *uinfo)
771{
772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
773 struct sigmatel_spec *spec = codec->spec;
774 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
775}
776
777static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value *ucontrol)
779{
780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
781 struct sigmatel_spec *spec = codec->spec;
782
783 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
784 return 0;
785}
786
787static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
788 struct snd_ctl_elem_value *ucontrol)
789{
790 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
791 struct sigmatel_spec *spec = codec->spec;
792
793 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
794 spec->mono_nid, &spec->cur_mmux);
795}
796
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200797#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
798
799static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
800 struct snd_ctl_elem_value *ucontrol)
801{
802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100803 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200804 struct sigmatel_spec *spec = codec->spec;
805
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100806 ucontrol->value.integer.value[0] = !!(spec->aloopback &
807 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200808 return 0;
809}
810
811static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
812 struct snd_ctl_elem_value *ucontrol)
813{
814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
815 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100816 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200817 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100818 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200819
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100820 idx_val = spec->aloopback_mask << idx;
821 if (ucontrol->value.integer.value[0])
822 val = spec->aloopback | idx_val;
823 else
824 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100825 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200826 return 0;
827
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100828 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200829
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830 /* Only return the bits defined by the shift value of the
831 * first two bytes of the mask
832 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200833 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 kcontrol->private_value & 0xFFFF, 0x0);
835 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200836
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200838 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100839 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200840 } else {
841 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100842 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200843 }
844
845 snd_hda_codec_write_cache(codec, codec->afg, 0,
846 kcontrol->private_value >> 16, dac_mode);
847
848 return 1;
849}
850
Mattc7d4b2f2005-06-27 14:59:41 +0200851static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200852 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200853 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200854 {}
855};
856
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200857static struct hda_verb stac9200_eapd_init[] = {
858 /* set dac0mux for dac converter */
859 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
860 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
861 {}
862};
863
Matthew Ranostayd654a662008-03-14 08:46:51 +0100864static struct hda_verb dell_eq_core_init[] = {
865 /* set master volume to max value without distortion
866 * and direct control */
867 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100868 {}
869};
870
Takashi Iwaie2aec172009-09-02 01:00:05 +0200871static struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100872 /* set master volume and direct control */
873 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100874 {}
875};
876
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200877static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200878 /* power state controls amps */
879 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200880 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200881};
882
Matthew Ranostaye035b842007-11-06 11:53:55 +0100883static struct hda_verb stac92hd71bxx_core_init[] = {
884 /* set master volume and direct control */
885 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200886 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100887};
888
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500889static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
890 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
891 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100892 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
893 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100894 {}
895};
896
Tobin Davis8e21c342007-01-08 11:04:17 +0100897static struct hda_verb stac925x_core_init[] = {
898 /* set dac0mux for dac converter */
899 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100900 /* mute the master volume */
901 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100902 {}
903};
904
Mattc7d4b2f2005-06-27 14:59:41 +0200905static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200906 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200907 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200908 {}
909};
910
Tobin Davis93ed1502006-09-01 21:03:12 +0200911static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200912 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200913 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200914 /* unmute node 0x1b */
915 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
916 /* select node 0x03 as DAC */
917 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
918 {}
919};
920
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200921static struct hda_verb dell_3st_core_init[] = {
922 /* don't set delta bit */
923 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
924 /* unmute node 0x1b */
925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
926 /* select node 0x03 as DAC */
927 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
928 {}
929};
930
Matt Porter3cc08dc2006-01-23 15:27:49 +0100931static struct hda_verb stac927x_core_init[] = {
932 /* set master volume and direct control */
933 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200934 /* enable analog pc beep path */
935 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100936 {}
937};
938
Takashi Iwai54930532009-10-11 17:38:29 +0200939static struct hda_verb stac927x_volknob_core_init[] = {
940 /* don't set delta bit */
941 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
942 /* enable analog pc beep path */
943 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
944 {}
945};
946
Matt Porterf3302a52006-07-31 12:49:34 +0200947static struct hda_verb stac9205_core_init[] = {
948 /* set master volume and direct control */
949 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200950 /* enable analog pc beep path */
951 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200952 {}
953};
954
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100955#define STAC_MONO_MUX \
956 { \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .name = "Mono Mux", \
959 .count = 1, \
960 .info = stac92xx_mono_mux_enum_info, \
961 .get = stac92xx_mono_mux_enum_get, \
962 .put = stac92xx_mono_mux_enum_put, \
963 }
964
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100965#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200966 { \
967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
968 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100969 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200970 .info = stac92xx_aloopback_info, \
971 .get = stac92xx_aloopback_get, \
972 .put = stac92xx_aloopback_put, \
973 .private_value = verb_read | (verb_write << 16), \
974 }
975
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200976#define DC_BIAS(xname, idx, nid) \
977 { \
978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
979 .name = xname, \
980 .index = idx, \
981 .info = stac92xx_dc_bias_info, \
982 .get = stac92xx_dc_bias_get, \
983 .put = stac92xx_dc_bias_put, \
984 .private_value = nid, \
985 }
986
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100987static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200988 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200990 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200992 { } /* end */
993};
994
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100995static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
996 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
997 {}
998};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100999
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001000static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1001 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1002 {}
1003};
1004
1005static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1006 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1007 {}
1008};
1009
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001010
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001011static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1012 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1013};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001014
Tobin Davis8e21c342007-01-08 11:04:17 +01001015static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001016 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1017 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001018 { } /* end */
1019};
1020
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001021static struct snd_kcontrol_new stac9205_loopback[] = {
1022 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1023 {}
1024};
1025
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001026static struct snd_kcontrol_new stac927x_loopback[] = {
1027 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1028 {}
1029};
1030
Takashi Iwai1697055e2007-12-18 18:05:52 +01001031static struct snd_kcontrol_new stac_dmux_mixer = {
1032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1033 .name = "Digital Input Source",
1034 /* count set later */
1035 .info = stac92xx_dmux_enum_info,
1036 .get = stac92xx_dmux_enum_get,
1037 .put = stac92xx_dmux_enum_put,
1038};
1039
Matthew Ranostayd9737752008-09-07 12:03:41 +02001040static struct snd_kcontrol_new stac_smux_mixer = {
1041 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001042 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001043 /* count set later */
1044 .info = stac92xx_smux_enum_info,
1045 .get = stac92xx_smux_enum_get,
1046 .put = stac92xx_smux_enum_put,
1047};
1048
Takashi Iwai2134ea42008-01-10 16:53:55 +01001049static const char *slave_vols[] = {
1050 "Front Playback Volume",
1051 "Surround Playback Volume",
1052 "Center Playback Volume",
1053 "LFE Playback Volume",
1054 "Side Playback Volume",
1055 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001056 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001057 NULL
1058};
1059
1060static const char *slave_sws[] = {
1061 "Front Playback Switch",
1062 "Surround Playback Switch",
1063 "Center Playback Switch",
1064 "LFE Playback Switch",
1065 "Side Playback Switch",
1066 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001067 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001068 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001069 NULL
1070};
1071
Takashi Iwai603c4012008-07-30 15:01:44 +02001072static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001073static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001074
Matt2f2f4252005-04-13 14:45:30 +02001075static int stac92xx_build_controls(struct hda_codec *codec)
1076{
1077 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001078 struct auto_pin_cfg *cfg = &spec->autocfg;
1079 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001080 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001081 int i;
Matt2f2f4252005-04-13 14:45:30 +02001082
Takashi Iwai6479c632009-07-28 18:20:25 +02001083 if (spec->mixer) {
1084 err = snd_hda_add_new_ctls(codec, spec->mixer);
1085 if (err < 0)
1086 return err;
1087 }
Mattc7d4b2f2005-06-27 14:59:41 +02001088
1089 for (i = 0; i < spec->num_mixers; i++) {
1090 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1091 if (err < 0)
1092 return err;
1093 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001094 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1095 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001096 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001097 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001098 snd_ctl_new1(&stac_dmux_mixer, codec));
1099 if (err < 0)
1100 return err;
1101 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001102 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001103 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1104 struct hda_input_mux *smux = &spec->private_smux;
1105 /* check for mute support on SPDIF out */
1106 if (wcaps & AC_WCAP_OUT_AMP) {
1107 smux->items[smux->num_items].label = "Off";
1108 smux->items[smux->num_items].index = 0;
1109 smux->num_items++;
1110 spec->spdif_mute = 1;
1111 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001112 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001113 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001114 snd_ctl_new1(&stac_smux_mixer, codec));
1115 if (err < 0)
1116 return err;
1117 }
Mattc7d4b2f2005-06-27 14:59:41 +02001118
Mattdabbed62005-06-14 10:19:34 +02001119 if (spec->multiout.dig_out_nid) {
1120 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1121 if (err < 0)
1122 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001123 err = snd_hda_create_spdif_share_sw(codec,
1124 &spec->multiout);
1125 if (err < 0)
1126 return err;
1127 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001128 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001129 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001130 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1131 if (err < 0)
1132 return err;
1133 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001134
1135 /* if we have no master control, let's create it */
1136 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001137 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001138 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001139 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001140 /* correct volume offset */
1141 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001142 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001143 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001144 if (err < 0)
1145 return err;
1146 }
1147 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1148 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1149 NULL, slave_sws);
1150 if (err < 0)
1151 return err;
1152 }
1153
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001154 if (spec->aloopback_ctl &&
1155 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1156 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1157 if (err < 0)
1158 return err;
1159 }
1160
Takashi Iwai603c4012008-07-30 15:01:44 +02001161 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001162
1163 /* create jack input elements */
1164 if (spec->hp_detect) {
1165 for (i = 0; i < cfg->hp_outs; i++) {
1166 int type = SND_JACK_HEADPHONE;
1167 nid = cfg->hp_pins[i];
1168 /* jack detection */
1169 if (cfg->hp_outs == i)
1170 type |= SND_JACK_LINEOUT;
1171 err = stac92xx_add_jack(codec, nid, type);
1172 if (err < 0)
1173 return err;
1174 }
1175 }
1176 for (i = 0; i < cfg->line_outs; i++) {
1177 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1178 SND_JACK_LINEOUT);
1179 if (err < 0)
1180 return err;
1181 }
1182 for (i = 0; i < AUTO_PIN_LAST; i++) {
1183 nid = cfg->input_pins[i];
1184 if (nid) {
1185 err = stac92xx_add_jack(codec, nid,
1186 SND_JACK_MICROPHONE);
1187 if (err < 0)
1188 return err;
1189 }
1190 }
1191
Mattdabbed62005-06-14 10:19:34 +02001192 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001193}
1194
Matt Porter403d1942005-11-29 15:00:51 +01001195static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001196 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001197 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1198};
1199
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001200static unsigned int gateway9200_m4_pin_configs[8] = {
1201 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1202 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1203};
1204static unsigned int gateway9200_m4_2_pin_configs[8] = {
1205 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1206 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1207};
1208
1209/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001210 STAC 9200 pin configs for
1211 102801A8
1212 102801DE
1213 102801E8
1214*/
1215static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001216 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1217 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001218};
1219
1220/*
1221 STAC 9200 pin configs for
1222 102801C0
1223 102801C1
1224*/
1225static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001226 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1227 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001228};
1229
1230/*
1231 STAC 9200 pin configs for
1232 102801C4 (Dell Dimension E310)
1233 102801C5
1234 102801C7
1235 102801D9
1236 102801DA
1237 102801E3
1238*/
1239static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001240 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1241 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001242};
1243
1244
1245/*
1246 STAC 9200-32 pin configs for
1247 102801B5 (Dell Inspiron 630m)
1248 102801D8 (Dell Inspiron 640m)
1249*/
1250static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001251 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1252 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001253};
1254
1255/*
1256 STAC 9200-32 pin configs for
1257 102801C2 (Dell Latitude D620)
1258 102801C8
1259 102801CC (Dell Latitude D820)
1260 102801D4
1261 102801D6
1262*/
1263static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001264 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1265 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001266};
1267
1268/*
1269 STAC 9200-32 pin configs for
1270 102801CE (Dell XPS M1710)
1271 102801CF (Dell Precision M90)
1272*/
1273static unsigned int dell9200_m23_pin_configs[8] = {
1274 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1275 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1276};
1277
1278/*
1279 STAC 9200-32 pin configs for
1280 102801C9
1281 102801CA
1282 102801CB (Dell Latitude 120L)
1283 102801D3
1284*/
1285static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001286 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1287 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001288};
1289
1290/*
1291 STAC 9200-32 pin configs for
1292 102801BD (Dell Inspiron E1505n)
1293 102801EE
1294 102801EF
1295*/
1296static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001297 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1298 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001299};
1300
1301/*
1302 STAC 9200-32 pin configs for
1303 102801F5 (Dell Inspiron 1501)
1304 102801F6
1305*/
1306static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001307 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1308 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001309};
1310
1311/*
1312 STAC 9200-32
1313 102801CD (Dell Inspiron E1705/9400)
1314*/
1315static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001316 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1317 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001318};
1319
Tobin Davisbf277782008-02-03 20:31:47 +01001320static unsigned int oqo9200_pin_configs[8] = {
1321 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1322 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1323};
1324
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001325
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001326static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1327 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001328 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001329 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1330 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1331 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1332 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1333 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1334 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1335 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1336 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1337 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1338 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001339 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1340 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001341 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001342};
1343
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001344static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001345 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001346 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001347 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001348 [STAC_9200_DELL_D21] = "dell-d21",
1349 [STAC_9200_DELL_D22] = "dell-d22",
1350 [STAC_9200_DELL_D23] = "dell-d23",
1351 [STAC_9200_DELL_M21] = "dell-m21",
1352 [STAC_9200_DELL_M22] = "dell-m22",
1353 [STAC_9200_DELL_M23] = "dell-m23",
1354 [STAC_9200_DELL_M24] = "dell-m24",
1355 [STAC_9200_DELL_M25] = "dell-m25",
1356 [STAC_9200_DELL_M26] = "dell-m26",
1357 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001358 [STAC_9200_M4] = "gateway-m4",
1359 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001360 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001361};
1362
1363static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1364 /* SigmaTel reference board */
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1366 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001367 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1368 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001369 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1371 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001373 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1375 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1377 "unknown Dell", STAC_9200_DELL_D22),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1379 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001381 "Dell Latitude D620", STAC_9200_DELL_M22),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1383 "unknown Dell", STAC_9200_DELL_D23),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1385 "unknown Dell", STAC_9200_DELL_D23),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1387 "unknown Dell", STAC_9200_DELL_M22),
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1389 "unknown Dell", STAC_9200_DELL_M24),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1391 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001393 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001395 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001397 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001401 "Dell Precision M90", STAC_9200_DELL_M23),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1403 "unknown Dell", STAC_9200_DELL_M22),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1405 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001407 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001409 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1411 "unknown Dell", STAC_9200_DELL_D23),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1413 "unknown Dell", STAC_9200_DELL_D23),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1415 "unknown Dell", STAC_9200_DELL_D21),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1417 "unknown Dell", STAC_9200_DELL_D23),
1418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1419 "unknown Dell", STAC_9200_DELL_D21),
1420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1421 "unknown Dell", STAC_9200_DELL_M25),
1422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1423 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001424 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001425 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1427 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001428 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001429 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001430 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001431 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1432 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1433 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001434 /* OQO Mobile */
1435 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001436 {} /* terminator */
1437};
1438
Tobin Davis8e21c342007-01-08 11:04:17 +01001439static unsigned int ref925x_pin_configs[8] = {
1440 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001441 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001442};
1443
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001444static unsigned int stac925xM1_pin_configs[8] = {
1445 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1446 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001447};
1448
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001449static unsigned int stac925xM1_2_pin_configs[8] = {
1450 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1451 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1452};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001453
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001454static unsigned int stac925xM2_pin_configs[8] = {
1455 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1456 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001457};
1458
Tobin Davis8e21c342007-01-08 11:04:17 +01001459static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001460 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1461 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1462};
1463
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001464static unsigned int stac925xM3_pin_configs[8] = {
1465 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1466 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1467};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001468
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001469static unsigned int stac925xM5_pin_configs[8] = {
1470 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1471 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1472};
1473
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001474static unsigned int stac925xM6_pin_configs[8] = {
1475 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1476 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001477};
1478
1479static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1480 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001481 [STAC_M1] = stac925xM1_pin_configs,
1482 [STAC_M1_2] = stac925xM1_2_pin_configs,
1483 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001484 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001485 [STAC_M3] = stac925xM3_pin_configs,
1486 [STAC_M5] = stac925xM5_pin_configs,
1487 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001488};
1489
1490static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001491 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001492 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001493 [STAC_M1] = "m1",
1494 [STAC_M1_2] = "m1-2",
1495 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001496 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001497 [STAC_M3] = "m3",
1498 [STAC_M5] = "m5",
1499 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001500};
1501
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001502static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001503 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1504 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1505 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1506 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001507 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001508 /* Not sure about the brand name for those */
1509 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1510 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1511 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1512 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001513 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001514};
1515
1516static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1517 /* SigmaTel reference board */
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001519 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001520 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001521
1522 /* Default table for unknown ID */
1523 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1524
Tobin Davis8e21c342007-01-08 11:04:17 +01001525 {} /* terminator */
1526};
1527
Matthew Ranostaya7662642008-02-21 07:51:14 +01001528static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001529 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1530 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1531 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001532 0x01452050,
1533};
1534
1535static unsigned int dell_m6_pin_configs[13] = {
1536 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001537 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001538 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1539 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001540};
1541
Takashi Iwai842ae632009-09-02 07:43:08 +02001542static unsigned int alienware_m17x_pin_configs[13] = {
1543 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1544 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1545 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1546 0x904601b0,
1547};
1548
Wu Fengguang4d26f442010-05-07 08:47:54 +08001549static unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001550 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001551 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001552};
1553
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001554static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001555 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001556 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1557 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1558 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001559 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001560 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001561 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001562};
1563
1564static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001565 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001566 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001567 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001568 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001569 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1570 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1571 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001572 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001573 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001574};
1575
1576static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1577 /* SigmaTel reference board */
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001579 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001580 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1581 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001582 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1583 "Intel DG45ID", STAC_92HD73XX_INTEL),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1585 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001587 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001589 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001591 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001593 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001595 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001597 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001599 "unknown Dell", STAC_DELL_M6_DMIC),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1601 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001603 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1605 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1607 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1609 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1611 "Dell Studio XPS 1645", STAC_DELL_M6_BOTH),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1613 "Dell Studio 1558", STAC_DELL_M6_BOTH),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001614 {} /* terminator */
1615};
1616
Takashi Iwai842ae632009-09-02 07:43:08 +02001617static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1619 "Alienware M17x", STAC_ALIENWARE_M17X),
1620 {} /* terminator */
1621};
1622
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001623static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001624 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1625 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001626 0x01451160, 0x98560170,
1627};
1628
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001629static unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001630 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1631 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001632 0x40f000f0, 0x40f000f0,
1633};
1634
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001635static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1636 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001637 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001638 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001639};
1640
1641static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001642 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001643 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001644 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001645 [STAC_DELL_S14] = "dell-s14",
Takashi Iwaib4e81872009-11-18 17:20:24 +01001646 [STAC_92HD83XXX_HP] = "hp",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001647};
1648
1649static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1650 /* SigmaTel reference board */
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001652 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001653 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1654 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1656 "unknown Dell", STAC_DELL_S14),
Takashi Iwaib4e81872009-11-18 17:20:24 +01001657 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1658 "HP", STAC_92HD83XXX_HP),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001659 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001660};
1661
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001662static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001663 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001664 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001665 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1666 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001667};
1668
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001669static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001670 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001671 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001672 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1673 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001674};
1675
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001676static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001677 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1678 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001679 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1680 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001681};
1682
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001683static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001684 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1685 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001686 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1687 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001688};
1689
Matthew Ranostaye035b842007-11-06 11:53:55 +01001690static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1691 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001692 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1693 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001694 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001695 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001696 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001697 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001698 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001699 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001700};
1701
1702static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001703 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001704 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001705 [STAC_DELL_M4_1] = "dell-m4-1",
1706 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001707 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001708 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001709 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001710 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001711 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001712 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001713};
1714
1715static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1716 /* SigmaTel reference board */
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1718 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001719 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1720 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1722 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001723 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1724 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001725 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1726 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001727 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001728 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001729 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1730 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001731 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1732 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001733 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001734 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001735 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001736 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001737 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1738 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301739 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1740 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Takashi Iwai1972d022009-08-06 08:44:43 +02001741 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1742 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001743 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1744 "unknown Dell", STAC_DELL_M4_1),
1745 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1746 "unknown Dell", STAC_DELL_M4_1),
1747 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1748 "unknown Dell", STAC_DELL_M4_1),
1749 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1750 "unknown Dell", STAC_DELL_M4_1),
1751 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1752 "unknown Dell", STAC_DELL_M4_1),
1753 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1754 "unknown Dell", STAC_DELL_M4_1),
1755 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1756 "unknown Dell", STAC_DELL_M4_1),
1757 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1758 "unknown Dell", STAC_DELL_M4_2),
1759 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1760 "unknown Dell", STAC_DELL_M4_2),
1761 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1762 "unknown Dell", STAC_DELL_M4_2),
1763 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1764 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001765 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1766 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001767 {} /* terminator */
1768};
1769
Matt Porter403d1942005-11-29 15:00:51 +01001770static unsigned int ref922x_pin_configs[10] = {
1771 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1772 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001773 0x40000100, 0x40000100,
1774};
1775
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001776/*
1777 STAC 922X pin configs for
1778 102801A7
1779 102801AB
1780 102801A9
1781 102801D1
1782 102801D2
1783*/
1784static unsigned int dell_922x_d81_pin_configs[10] = {
1785 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1786 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1787 0x01813122, 0x400001f2,
1788};
1789
1790/*
1791 STAC 922X pin configs for
1792 102801AC
1793 102801D0
1794*/
1795static unsigned int dell_922x_d82_pin_configs[10] = {
1796 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1797 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1798 0x01813122, 0x400001f1,
1799};
1800
1801/*
1802 STAC 922X pin configs for
1803 102801BF
1804*/
1805static unsigned int dell_922x_m81_pin_configs[10] = {
1806 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1807 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1808 0x40C003f1, 0x405003f0,
1809};
1810
1811/*
1812 STAC 9221 A1 pin configs for
1813 102801D7 (Dell XPS M1210)
1814*/
1815static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001816 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1817 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001818 0x508003f3, 0x405003f4,
1819};
1820
Matt Porter403d1942005-11-29 15:00:51 +01001821static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001822 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001823 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1824 0x02a19120, 0x40000100,
1825};
1826
1827static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001828 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1829 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001830 0x02a19320, 0x40000100,
1831};
1832
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001833static unsigned int intel_mac_v1_pin_configs[10] = {
1834 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1835 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001836 0x400000fc, 0x400000fb,
1837};
1838
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001839static unsigned int intel_mac_v2_pin_configs[10] = {
1840 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1841 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001842 0x400000fc, 0x400000fb,
1843};
1844
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001845static unsigned int intel_mac_v3_pin_configs[10] = {
1846 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1847 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1848 0x400000fc, 0x400000fb,
1849};
1850
1851static unsigned int intel_mac_v4_pin_configs[10] = {
1852 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1853 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1854 0x400000fc, 0x400000fb,
1855};
1856
1857static unsigned int intel_mac_v5_pin_configs[10] = {
1858 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1859 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1860 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001861};
1862
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001863static unsigned int ecs202_pin_configs[10] = {
1864 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1865 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1866 0x9037012e, 0x40e000f2,
1867};
Takashi Iwai76c08822007-06-19 12:17:42 +02001868
Takashi Iwai19039bd2006-06-28 15:52:16 +02001869static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001870 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001871 [STAC_D945GTP3] = d945gtp3_pin_configs,
1872 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001873 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1874 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1875 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1876 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1877 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001878 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001879 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001880 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1881 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1882 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1883 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1884 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1885 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001886 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001887 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1888 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1889 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1890 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001891};
1892
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001893static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001894 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001895 [STAC_D945_REF] = "ref",
1896 [STAC_D945GTP5] = "5stack",
1897 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001898 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1899 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1900 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1901 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1902 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001903 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001904 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001905 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001906 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001907 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1908 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001909 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001910 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001911 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001912 [STAC_922X_DELL_D81] = "dell-d81",
1913 [STAC_922X_DELL_D82] = "dell-d82",
1914 [STAC_922X_DELL_M81] = "dell-m81",
1915 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001916};
1917
1918static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1919 /* SigmaTel reference board */
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1921 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001922 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1923 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001924 /* Intel 945G based systems */
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1926 "Intel D945G", STAC_D945GTP3),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1928 "Intel D945G", STAC_D945GTP3),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1930 "Intel D945G", STAC_D945GTP3),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1932 "Intel D945G", STAC_D945GTP3),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1934 "Intel D945G", STAC_D945GTP3),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1936 "Intel D945G", STAC_D945GTP3),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1938 "Intel D945G", STAC_D945GTP3),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1940 "Intel D945G", STAC_D945GTP3),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1942 "Intel D945G", STAC_D945GTP3),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1944 "Intel D945G", STAC_D945GTP3),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1946 "Intel D945G", STAC_D945GTP3),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1948 "Intel D945G", STAC_D945GTP3),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1950 "Intel D945G", STAC_D945GTP3),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1952 "Intel D945G", STAC_D945GTP3),
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1954 "Intel D945G", STAC_D945GTP3),
1955 /* Intel D945G 5-stack systems */
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1957 "Intel D945G", STAC_D945GTP5),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1959 "Intel D945G", STAC_D945GTP5),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1961 "Intel D945G", STAC_D945GTP5),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1963 "Intel D945G", STAC_D945GTP5),
1964 /* Intel 945P based systems */
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1966 "Intel D945P", STAC_D945GTP3),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1968 "Intel D945P", STAC_D945GTP3),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1970 "Intel D945P", STAC_D945GTP3),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1972 "Intel D945P", STAC_D945GTP3),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1974 "Intel D945P", STAC_D945GTP3),
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1976 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01001977 /* other intel */
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
1979 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001980 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001981 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001982 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001983 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001984 /* Dell systems */
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1986 "unknown Dell", STAC_922X_DELL_D81),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1988 "unknown Dell", STAC_922X_DELL_D81),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1990 "unknown Dell", STAC_922X_DELL_D81),
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1992 "unknown Dell", STAC_922X_DELL_D82),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1994 "unknown Dell", STAC_922X_DELL_M81),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1996 "unknown Dell", STAC_922X_DELL_D82),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1998 "unknown Dell", STAC_922X_DELL_D81),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2000 "unknown Dell", STAC_922X_DELL_D81),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2002 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002003 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002004 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002005 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002006 {} /* terminator */
2007};
2008
Matt Porter3cc08dc2006-01-23 15:27:49 +01002009static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002010 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2011 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2012 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2013 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002014};
2015
Tobin Davis93ed1502006-09-01 21:03:12 +02002016static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002017 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2018 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2019 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2020 0x40000100, 0x40000100
2021};
2022
Tobin Davis93ed1502006-09-01 21:03:12 +02002023static unsigned int d965_5st_pin_configs[14] = {
2024 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2025 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2026 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2027 0x40000100, 0x40000100
2028};
2029
Takashi Iwai679d92e2009-05-24 19:00:08 +02002030static unsigned int d965_5st_no_fp_pin_configs[14] = {
2031 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2032 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2033 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2034 0x40000100, 0x40000100
2035};
2036
Tobin Davis4ff076e2007-08-07 11:48:12 +02002037static unsigned int dell_3st_pin_configs[14] = {
2038 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2039 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002040 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002041 0x40c003fc, 0x40000100
2042};
2043
Tobin Davis93ed1502006-09-01 21:03:12 +02002044static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002045 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002046 [STAC_D965_REF] = ref927x_pin_configs,
2047 [STAC_D965_3ST] = d965_3st_pin_configs,
2048 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002049 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002050 [STAC_DELL_3ST] = dell_3st_pin_configs,
2051 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002052 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002053};
2054
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002055static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002056 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002057 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002058 [STAC_D965_REF] = "ref",
2059 [STAC_D965_3ST] = "3stack",
2060 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002061 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002062 [STAC_DELL_3ST] = "dell-3stack",
2063 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002064 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002065};
2066
2067static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2068 /* SigmaTel reference board */
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2070 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002071 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2072 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002073 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002076 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002077 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2078 "Intel D965", STAC_D965_3ST),
2079 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2080 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002081 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002085 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002091 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002095 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002096 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2097 "Intel D965", STAC_D965_5ST),
2098 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2099 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002100 /* volume-knob fixes */
2101 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002102 {} /* terminator */
2103};
2104
Matt Porterf3302a52006-07-31 12:49:34 +02002105static unsigned int ref9205_pin_configs[12] = {
2106 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002107 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002108 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002109};
2110
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002111/*
2112 STAC 9205 pin configs for
2113 102801F1
2114 102801F2
2115 102801FC
2116 102801FD
2117 10280204
2118 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002119 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002120 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002121*/
2122static unsigned int dell_9205_m42_pin_configs[12] = {
2123 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2124 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2125 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2126};
2127
2128/*
2129 STAC 9205 pin configs for
2130 102801F9
2131 102801FA
2132 102801FE
2133 102801FF (Dell Precision M4300)
2134 10280206
2135 10280200
2136 10280201
2137*/
2138static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002139 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2140 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2141 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2142};
2143
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002144static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002145 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2146 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2147 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2148};
2149
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002151 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002152 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2153 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2154 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002155 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002156};
2157
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002158static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002159 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002160 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002161 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002162 [STAC_9205_DELL_M43] = "dell-m43",
2163 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002164 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002165};
2166
2167static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2168 /* SigmaTel reference board */
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2170 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2172 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002173 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2174 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002175 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2177 "unknown Dell", STAC_9205_DELL_M42),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2179 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002181 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2183 "Dell Precision", STAC_9205_DELL_M43),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2185 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2187 "unknown Dell", STAC_9205_DELL_M42),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2189 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2191 "Dell Precision", STAC_9205_DELL_M43),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002193 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2195 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2197 "Dell Precision", STAC_9205_DELL_M43),
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2199 "Dell Precision", STAC_9205_DELL_M43),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2201 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2203 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2205 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2207 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002208 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002209 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002210 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002211 {} /* terminator */
2212};
2213
Takashi Iwai330ee992009-02-20 14:33:36 +01002214static void stac92xx_set_config_regs(struct hda_codec *codec,
2215 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002216{
2217 int i;
2218 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002219
Takashi Iwai330ee992009-02-20 14:33:36 +01002220 if (!pincfgs)
2221 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002222
Matthew Ranostay87d48362007-07-17 11:52:24 +02002223 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002224 if (spec->pin_nids[i] && pincfgs[i])
2225 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2226 pincfgs[i]);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01002227}
2228
Matt2f2f4252005-04-13 14:45:30 +02002229/*
2230 * Analog playback callbacks
2231 */
2232static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2233 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002234 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002235{
2236 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002237 if (spec->stream_delay)
2238 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002239 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2240 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002241}
2242
2243static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2244 struct hda_codec *codec,
2245 unsigned int stream_tag,
2246 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002247 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002248{
2249 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002250 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002251}
2252
2253static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2254 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002255 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002256{
2257 struct sigmatel_spec *spec = codec->spec;
2258 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2259}
2260
2261/*
Mattdabbed62005-06-14 10:19:34 +02002262 * Digital playback callbacks
2263 */
2264static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2265 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002266 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002267{
2268 struct sigmatel_spec *spec = codec->spec;
2269 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2270}
2271
2272static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2273 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002274 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002275{
2276 struct sigmatel_spec *spec = codec->spec;
2277 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2278}
2279
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002280static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2281 struct hda_codec *codec,
2282 unsigned int stream_tag,
2283 unsigned int format,
2284 struct snd_pcm_substream *substream)
2285{
2286 struct sigmatel_spec *spec = codec->spec;
2287 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2288 stream_tag, format, substream);
2289}
2290
Takashi Iwai9411e212009-02-13 11:32:28 +01002291static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2292 struct hda_codec *codec,
2293 struct snd_pcm_substream *substream)
2294{
2295 struct sigmatel_spec *spec = codec->spec;
2296 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2297}
2298
Mattdabbed62005-06-14 10:19:34 +02002299
2300/*
Matt2f2f4252005-04-13 14:45:30 +02002301 * Analog capture callbacks
2302 */
2303static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2304 struct hda_codec *codec,
2305 unsigned int stream_tag,
2306 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002307 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002308{
2309 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002310 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002311
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002312 if (spec->powerdown_adcs) {
2313 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002314 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002315 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2316 }
2317 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002318 return 0;
2319}
2320
2321static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2322 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002323 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002324{
2325 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002326 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002327
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002328 snd_hda_codec_cleanup_stream(codec, nid);
2329 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002330 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002331 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002332 return 0;
2333}
2334
Mattdabbed62005-06-14 10:19:34 +02002335static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2336 .substreams = 1,
2337 .channels_min = 2,
2338 .channels_max = 2,
2339 /* NID is set in stac92xx_build_pcms */
2340 .ops = {
2341 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002342 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002343 .prepare = stac92xx_dig_playback_pcm_prepare,
2344 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002345 },
2346};
2347
2348static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2349 .substreams = 1,
2350 .channels_min = 2,
2351 .channels_max = 2,
2352 /* NID is set in stac92xx_build_pcms */
2353};
2354
Matt2f2f4252005-04-13 14:45:30 +02002355static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2356 .substreams = 1,
2357 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002358 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002359 .nid = 0x02, /* NID to query formats and rates */
2360 .ops = {
2361 .open = stac92xx_playback_pcm_open,
2362 .prepare = stac92xx_playback_pcm_prepare,
2363 .cleanup = stac92xx_playback_pcm_cleanup
2364 },
2365};
2366
Matt Porter3cc08dc2006-01-23 15:27:49 +01002367static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2368 .substreams = 1,
2369 .channels_min = 2,
2370 .channels_max = 2,
2371 .nid = 0x06, /* NID to query formats and rates */
2372 .ops = {
2373 .open = stac92xx_playback_pcm_open,
2374 .prepare = stac92xx_playback_pcm_prepare,
2375 .cleanup = stac92xx_playback_pcm_cleanup
2376 },
2377};
2378
Matt2f2f4252005-04-13 14:45:30 +02002379static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002380 .channels_min = 2,
2381 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002382 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002383 .ops = {
2384 .prepare = stac92xx_capture_pcm_prepare,
2385 .cleanup = stac92xx_capture_pcm_cleanup
2386 },
2387};
2388
2389static int stac92xx_build_pcms(struct hda_codec *codec)
2390{
2391 struct sigmatel_spec *spec = codec->spec;
2392 struct hda_pcm *info = spec->pcm_rec;
2393
2394 codec->num_pcms = 1;
2395 codec->pcm_info = info;
2396
Mattc7d4b2f2005-06-27 14:59:41 +02002397 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002398 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002399 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2400 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002401 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002402 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002403 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002404
2405 if (spec->alt_switch) {
2406 codec->num_pcms++;
2407 info++;
2408 info->name = "STAC92xx Analog Alt";
2409 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2410 }
Matt2f2f4252005-04-13 14:45:30 +02002411
Mattdabbed62005-06-14 10:19:34 +02002412 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2413 codec->num_pcms++;
2414 info++;
2415 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002416 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002417 if (spec->multiout.dig_out_nid) {
2418 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2419 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2420 }
2421 if (spec->dig_in_nid) {
2422 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2423 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2424 }
2425 }
2426
Matt2f2f4252005-04-13 14:45:30 +02002427 return 0;
2428}
2429
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002430static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2431 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002432{
Takashi Iwai1327a322009-03-23 13:07:47 +01002433 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002434 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2435 if (pincap & AC_PINCAP_VREF_100)
2436 return AC_PINCTL_VREF_100;
2437 if (pincap & AC_PINCAP_VREF_80)
2438 return AC_PINCTL_VREF_80;
2439 if (pincap & AC_PINCAP_VREF_50)
2440 return AC_PINCTL_VREF_50;
2441 if (pincap & AC_PINCAP_VREF_GRD)
2442 return AC_PINCTL_VREF_GRD;
2443 return 0;
2444}
2445
Matt Porter403d1942005-11-29 15:00:51 +01002446static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2447
2448{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002449 snd_hda_codec_write_cache(codec, nid, 0,
2450 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002451}
2452
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002453#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2454
2455static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2456 struct snd_ctl_elem_value *ucontrol)
2457{
2458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2459 struct sigmatel_spec *spec = codec->spec;
2460
Takashi Iwaid7a89432008-11-12 09:48:04 +01002461 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002462 return 0;
2463}
2464
Takashi Iwai62558ce2009-07-29 14:23:09 +02002465static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002466
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002467static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2468 struct snd_ctl_elem_value *ucontrol)
2469{
2470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2471 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002472 int nid = kcontrol->private_value;
2473
2474 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002475
2476 /* check to be sure that the ports are upto date with
2477 * switch changes
2478 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002479 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002480
2481 return 1;
2482}
2483
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002484static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2485 struct snd_ctl_elem_info *uinfo)
2486{
2487 int i;
2488 static char *texts[] = {
2489 "Mic In", "Line In", "Line Out"
2490 };
2491
2492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2493 struct sigmatel_spec *spec = codec->spec;
2494 hda_nid_t nid = kcontrol->private_value;
2495
2496 if (nid == spec->mic_switch || nid == spec->line_switch)
2497 i = 3;
2498 else
2499 i = 2;
2500
2501 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2502 uinfo->value.enumerated.items = i;
2503 uinfo->count = 1;
2504 if (uinfo->value.enumerated.item >= i)
2505 uinfo->value.enumerated.item = i-1;
2506 strcpy(uinfo->value.enumerated.name,
2507 texts[uinfo->value.enumerated.item]);
2508
2509 return 0;
2510}
2511
2512static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2513 struct snd_ctl_elem_value *ucontrol)
2514{
2515 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2516 hda_nid_t nid = kcontrol->private_value;
2517 unsigned int vref = stac92xx_vref_get(codec, nid);
2518
2519 if (vref == stac92xx_get_default_vref(codec, nid))
2520 ucontrol->value.enumerated.item[0] = 0;
2521 else if (vref == AC_PINCTL_VREF_GRD)
2522 ucontrol->value.enumerated.item[0] = 1;
2523 else if (vref == AC_PINCTL_VREF_HIZ)
2524 ucontrol->value.enumerated.item[0] = 2;
2525
2526 return 0;
2527}
2528
2529static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2530 struct snd_ctl_elem_value *ucontrol)
2531{
2532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2533 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002534 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002535 hda_nid_t nid = kcontrol->private_value;
2536
2537 if (ucontrol->value.enumerated.item[0] == 0)
2538 new_vref = stac92xx_get_default_vref(codec, nid);
2539 else if (ucontrol->value.enumerated.item[0] == 1)
2540 new_vref = AC_PINCTL_VREF_GRD;
2541 else if (ucontrol->value.enumerated.item[0] == 2)
2542 new_vref = AC_PINCTL_VREF_HIZ;
2543 else
2544 return 0;
2545
2546 if (new_vref != stac92xx_vref_get(codec, nid)) {
2547 error = stac92xx_vref_set(codec, nid, new_vref);
2548 return error;
2549 }
2550
2551 return 0;
2552}
2553
2554static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2555 struct snd_ctl_elem_info *uinfo)
2556{
2557 static char *texts[2];
2558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2559 struct sigmatel_spec *spec = codec->spec;
2560
2561 if (kcontrol->private_value == spec->line_switch)
2562 texts[0] = "Line In";
2563 else
2564 texts[0] = "Mic In";
2565 texts[1] = "Line Out";
2566 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2567 uinfo->value.enumerated.items = 2;
2568 uinfo->count = 1;
2569
2570 if (uinfo->value.enumerated.item >= 2)
2571 uinfo->value.enumerated.item = 1;
2572 strcpy(uinfo->value.enumerated.name,
2573 texts[uinfo->value.enumerated.item]);
2574
2575 return 0;
2576}
Matt Porter403d1942005-11-29 15:00:51 +01002577
2578static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2579{
2580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2581 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002582 hda_nid_t nid = kcontrol->private_value;
2583 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002584
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002585 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002586 return 0;
2587}
2588
2589static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2590{
2591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2592 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002593 hda_nid_t nid = kcontrol->private_value;
2594 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2595 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002596
2597 spec->io_switch[io_idx] = val;
2598
2599 if (val)
2600 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002601 else {
2602 unsigned int pinctl = AC_PINCTL_IN_EN;
2603 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002604 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002605 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2606 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002607
2608 /* check the auto-mute again: we need to mute/unmute the speaker
2609 * appropriately according to the pin direction
2610 */
2611 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002612 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002613
Matt Porter403d1942005-11-29 15:00:51 +01002614 return 1;
2615}
2616
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002617#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2618
2619static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2620 struct snd_ctl_elem_value *ucontrol)
2621{
2622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2623 struct sigmatel_spec *spec = codec->spec;
2624
2625 ucontrol->value.integer.value[0] = spec->clfe_swap;
2626 return 0;
2627}
2628
2629static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2630 struct snd_ctl_elem_value *ucontrol)
2631{
2632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2633 struct sigmatel_spec *spec = codec->spec;
2634 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002635 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002636
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002637 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002638 return 0;
2639
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002640 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002641
2642 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2643 spec->clfe_swap ? 0x4 : 0x0);
2644
2645 return 1;
2646}
2647
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002648#define STAC_CODEC_HP_SWITCH(xname) \
2649 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2650 .name = xname, \
2651 .index = 0, \
2652 .info = stac92xx_hp_switch_info, \
2653 .get = stac92xx_hp_switch_get, \
2654 .put = stac92xx_hp_switch_put, \
2655 }
2656
Matt Porter403d1942005-11-29 15:00:51 +01002657#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2658 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2659 .name = xname, \
2660 .index = 0, \
2661 .info = stac92xx_io_switch_info, \
2662 .get = stac92xx_io_switch_get, \
2663 .put = stac92xx_io_switch_put, \
2664 .private_value = xpval, \
2665 }
2666
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002667#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2668 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2669 .name = xname, \
2670 .index = 0, \
2671 .info = stac92xx_clfe_switch_info, \
2672 .get = stac92xx_clfe_switch_get, \
2673 .put = stac92xx_clfe_switch_put, \
2674 .private_value = xpval, \
2675 }
Matt Porter403d1942005-11-29 15:00:51 +01002676
Mattc7d4b2f2005-06-27 14:59:41 +02002677enum {
2678 STAC_CTL_WIDGET_VOL,
2679 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002680 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002681 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002682 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002683 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002684 STAC_CTL_WIDGET_CLFE_SWITCH,
2685 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002686};
2687
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002688static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002689 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2690 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002691 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002692 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002693 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002694 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002695 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002696 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002697};
2698
2699/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002700static struct snd_kcontrol_new *
2701stac_control_new(struct sigmatel_spec *spec,
2702 struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002703 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002704 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002705{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002706 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002707
Takashi Iwai603c4012008-07-30 15:01:44 +02002708 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2709 knew = snd_array_new(&spec->kctls);
2710 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002711 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002712 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002713 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002714 if (!knew->name) {
2715 /* roolback */
2716 memset(knew, 0, sizeof(*knew));
2717 spec->kctls.alloced--;
2718 return NULL;
2719 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002720 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002721 return knew;
2722}
2723
2724static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2725 struct snd_kcontrol_new *ktemp,
2726 int idx, const char *name,
2727 unsigned long val)
2728{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002729 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002730 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002731 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002732 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002733 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002734 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002735 return 0;
2736}
2737
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002738static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2739 int type, int idx, const char *name,
2740 unsigned long val)
2741{
2742 return stac92xx_add_control_temp(spec,
2743 &stac92xx_control_templates[type],
2744 idx, name, val);
2745}
2746
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002747
2748/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002749static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2750 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002751{
2752 return stac92xx_add_control_idx(spec, type, 0, name, val);
2753}
2754
Takashi Iwaie3c75962009-01-23 11:57:22 +01002755static struct snd_kcontrol_new stac_input_src_temp = {
2756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2757 .name = "Input Source",
2758 .info = stac92xx_mux_enum_info,
2759 .get = stac92xx_mux_enum_get,
2760 .put = stac92xx_mux_enum_put,
2761};
2762
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002763static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2764 hda_nid_t nid, int idx)
2765{
2766 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2767 int control = 0;
2768 struct sigmatel_spec *spec = codec->spec;
2769 char name[22];
2770
2771 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2772 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2773 && nid == spec->line_switch)
2774 control = STAC_CTL_WIDGET_IO_SWITCH;
2775 else if (snd_hda_query_pin_caps(codec, nid)
2776 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2777 control = STAC_CTL_WIDGET_DC_BIAS;
2778 else if (nid == spec->mic_switch)
2779 control = STAC_CTL_WIDGET_IO_SWITCH;
2780 }
2781
2782 if (control) {
2783 strcpy(name, auto_pin_cfg_labels[idx]);
2784 return stac92xx_add_control(codec->spec, control,
2785 strcat(name, " Jack Mode"), nid);
2786 }
2787
2788 return 0;
2789}
2790
Takashi Iwaie3c75962009-01-23 11:57:22 +01002791static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2792{
2793 struct snd_kcontrol_new *knew;
2794 struct hda_input_mux *imux = &spec->private_imux;
2795
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002796 if (spec->auto_mic)
2797 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002798 if (!spec->num_adcs || imux->num_items <= 1)
2799 return 0; /* no need for input source control */
2800 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002801 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002802 if (!knew)
2803 return -ENOMEM;
2804 knew->count = spec->num_adcs;
2805 return 0;
2806}
2807
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002808/* check whether the line-input can be used as line-out */
2809static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002810{
2811 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002812 struct auto_pin_cfg *cfg = &spec->autocfg;
2813 hda_nid_t nid;
2814 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002815
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002816 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2817 return 0;
2818 nid = cfg->input_pins[AUTO_PIN_LINE];
Takashi Iwai1327a322009-03-23 13:07:47 +01002819 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002820 if (pincap & AC_PINCAP_OUT)
2821 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002822 return 0;
2823}
2824
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002825/* check whether the mic-input can be used as line-out */
2826static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2827{
2828 struct sigmatel_spec *spec = codec->spec;
2829 struct auto_pin_cfg *cfg = &spec->autocfg;
2830 unsigned int def_conf, pincap;
2831 unsigned int mic_pin;
2832
2833 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2834 return 0;
2835 mic_pin = AUTO_PIN_MIC;
2836 for (;;) {
2837 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002838 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002839 /* some laptops have an internal analog microphone
2840 * which can't be used as a output */
2841 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai1327a322009-03-23 13:07:47 +01002842 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002843 if (pincap & AC_PINCAP_OUT)
2844 return nid;
2845 }
2846 if (mic_pin == AUTO_PIN_MIC)
2847 mic_pin = AUTO_PIN_FRONT_MIC;
2848 else
2849 break;
2850 }
2851 return 0;
2852}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002853
2854static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2855{
2856 int i;
2857
2858 for (i = 0; i < spec->multiout.num_dacs; i++) {
2859 if (spec->multiout.dac_nids[i] == nid)
2860 return 1;
2861 }
2862
2863 return 0;
2864}
2865
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002866static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2867{
2868 int i;
2869 if (is_in_dac_nids(spec, nid))
2870 return 1;
2871 for (i = 0; i < spec->autocfg.hp_outs; i++)
2872 if (spec->hp_dacs[i] == nid)
2873 return 1;
2874 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2875 if (spec->speaker_dacs[i] == nid)
2876 return 1;
2877 return 0;
2878}
2879
2880static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2881{
2882 struct sigmatel_spec *spec = codec->spec;
2883 int j, conn_len;
2884 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2885 unsigned int wcaps, wtype;
2886
2887 conn_len = snd_hda_get_connections(codec, nid, conn,
2888 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002889 /* 92HD88: trace back up the link of nids to find the DAC */
2890 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2891 != AC_WID_AUD_OUT)) {
2892 nid = conn[0];
2893 conn_len = snd_hda_get_connections(codec, nid, conn,
2894 HDA_MAX_CONNECTIONS);
2895 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002896 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002897 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002898 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002899 /* we check only analog outputs */
2900 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2901 continue;
2902 /* if this route has a free DAC, assign it */
2903 if (!check_all_dac_nids(spec, conn[j])) {
2904 if (conn_len > 1) {
2905 /* select this DAC in the pin's input mux */
2906 snd_hda_codec_write_cache(codec, nid, 0,
2907 AC_VERB_SET_CONNECT_SEL, j);
2908 }
2909 return conn[j];
2910 }
2911 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002912 /* if all DACs are already assigned, connect to the primary DAC */
2913 if (conn_len > 1) {
2914 for (j = 0; j < conn_len; j++) {
2915 if (conn[j] == spec->multiout.dac_nids[0]) {
2916 snd_hda_codec_write_cache(codec, nid, 0,
2917 AC_VERB_SET_CONNECT_SEL, j);
2918 break;
2919 }
2920 }
2921 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002922 return 0;
2923}
2924
2925static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2926static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2927
Matt Porter3cc08dc2006-01-23 15:27:49 +01002928/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002929 * Fill in the dac_nids table from the parsed pin configuration
2930 * This function only works when every pin in line_out_pins[]
2931 * contains atleast one DAC in its connection list. Some 92xx
2932 * codecs are not connected directly to a DAC, such as the 9200
2933 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002934 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002935static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002936{
2937 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002938 struct auto_pin_cfg *cfg = &spec->autocfg;
2939 int i;
2940 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002941
Mattc7d4b2f2005-06-27 14:59:41 +02002942 for (i = 0; i < cfg->line_outs; i++) {
2943 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002944 dac = get_unassigned_dac(codec, nid);
2945 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002946 if (spec->multiout.num_dacs > 0) {
2947 /* we have already working output pins,
2948 * so let's drop the broken ones again
2949 */
2950 cfg->line_outs = spec->multiout.num_dacs;
2951 break;
2952 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002953 /* error out, no available DAC found */
2954 snd_printk(KERN_ERR
2955 "%s: No available DAC for pin 0x%x\n",
2956 __func__, nid);
2957 return -ENODEV;
2958 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002959 add_spec_dacs(spec, dac);
2960 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002961
Takashi Iwai139e0712009-03-06 12:10:41 +01002962 for (i = 0; i < cfg->hp_outs; i++) {
2963 nid = cfg->hp_pins[i];
2964 dac = get_unassigned_dac(codec, nid);
2965 if (dac) {
2966 if (!spec->multiout.hp_nid)
2967 spec->multiout.hp_nid = dac;
2968 else
2969 add_spec_extra_dacs(spec, dac);
2970 }
2971 spec->hp_dacs[i] = dac;
2972 }
2973
2974 for (i = 0; i < cfg->speaker_outs; i++) {
2975 nid = cfg->speaker_pins[i];
2976 dac = get_unassigned_dac(codec, nid);
2977 if (dac)
2978 add_spec_extra_dacs(spec, dac);
2979 spec->speaker_dacs[i] = dac;
2980 }
2981
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002982 /* add line-in as output */
2983 nid = check_line_out_switch(codec);
2984 if (nid) {
2985 dac = get_unassigned_dac(codec, nid);
2986 if (dac) {
2987 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2988 nid, cfg->line_outs);
2989 cfg->line_out_pins[cfg->line_outs] = nid;
2990 cfg->line_outs++;
2991 spec->line_switch = nid;
2992 add_spec_dacs(spec, dac);
2993 }
2994 }
2995 /* add mic as output */
2996 nid = check_mic_out_switch(codec);
2997 if (nid) {
2998 dac = get_unassigned_dac(codec, nid);
2999 if (dac) {
3000 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3001 nid, cfg->line_outs);
3002 cfg->line_out_pins[cfg->line_outs] = nid;
3003 cfg->line_outs++;
3004 spec->mic_switch = nid;
3005 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003006 }
Mattc7d4b2f2005-06-27 14:59:41 +02003007 }
3008
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003009 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003010 spec->multiout.num_dacs,
3011 spec->multiout.dac_nids[0],
3012 spec->multiout.dac_nids[1],
3013 spec->multiout.dac_nids[2],
3014 spec->multiout.dac_nids[3],
3015 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003016
Mattc7d4b2f2005-06-27 14:59:41 +02003017 return 0;
3018}
3019
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003020/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003021static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3022 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003023{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003024 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003025 char name[32];
3026 int err;
3027
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003028 if (!spec->check_volume_offset) {
3029 unsigned int caps, step, nums, db_scale;
3030 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3031 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3032 AC_AMPCAP_STEP_SIZE_SHIFT;
3033 step = (step + 1) * 25; /* in .01dB unit */
3034 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3035 AC_AMPCAP_NUM_STEPS_SHIFT;
3036 db_scale = nums * step;
3037 /* if dB scale is over -64dB, and finer enough,
3038 * let's reduce it to half
3039 */
3040 if (db_scale > 6400 && nums >= 0x1f)
3041 spec->volume_offset = nums / 2;
3042 spec->check_volume_offset = 1;
3043 }
3044
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003045 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003046 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003047 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3048 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003049 if (err < 0)
3050 return err;
3051 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003052 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003053 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3054 if (err < 0)
3055 return err;
3056 return 0;
3057}
3058
Takashi Iwai668b9652009-03-06 10:13:24 +01003059#define create_controls(codec, pfx, nid, chs) \
3060 create_controls_idx(codec, pfx, 0, nid, chs)
3061
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003062static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3063{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003064 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003065 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3066 return 1;
3067 } else {
3068 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3069 spec->multiout.num_dacs++;
3070 }
3071 return 0;
3072}
3073
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003074static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003075{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003076 int i;
3077 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3078 if (!spec->multiout.extra_out_nid[i]) {
3079 spec->multiout.extra_out_nid[i] = nid;
3080 return 0;
3081 }
3082 }
3083 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3084 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003085}
3086
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003087/* Create output controls
3088 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3089 */
3090static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3091 const hda_nid_t *pins,
3092 const hda_nid_t *dac_nids,
3093 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003094{
Takashi Iwai76624532008-12-19 10:09:47 +01003095 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003096 static const char *chname[4] = {
3097 "Front", "Surround", NULL /*CLFE*/, "Side"
3098 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003099 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003100 int i, err;
3101 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003102
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003103 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003104 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3105 wid_caps = get_wcaps(codec, pins[i]);
3106 if (wid_caps & AC_WCAP_UNSOL_CAP)
3107 spec->hp_detect = 1;
3108 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003109 nid = dac_nids[i];
3110 if (!nid)
3111 continue;
3112 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003113 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003114 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003115 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003116 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003117 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003118 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003119 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003120
3121 wid_caps = get_wcaps(codec, nid);
3122
3123 if (wid_caps & AC_WCAP_LR_SWAP) {
3124 err = stac92xx_add_control(spec,
3125 STAC_CTL_WIDGET_CLFE_SWITCH,
3126 "Swap Center/LFE Playback Switch", nid);
3127
3128 if (err < 0)
3129 return err;
3130 }
3131
Mattc7d4b2f2005-06-27 14:59:41 +02003132 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003133 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003134 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003135 switch (type) {
3136 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003137 name = "Headphone";
3138 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003139 break;
3140 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003141 name = "Speaker";
3142 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003143 break;
3144 default:
3145 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003146 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003147 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003148 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003149 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003150 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003151 return err;
3152 }
3153 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003154 return 0;
3155}
3156
Takashi Iwai6479c632009-07-28 18:20:25 +02003157static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3158 unsigned long sw, int idx)
3159{
3160 int err;
3161 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003162 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003163 if (err < 0)
3164 return err;
3165 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003166 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003167 if (err < 0)
3168 return err;
3169 return 0;
3170}
3171
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003172/* add playback controls from the parsed DAC table */
3173static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3174 const struct auto_pin_cfg *cfg)
3175{
3176 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003177 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003178 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003179 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003180
3181 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3182 spec->multiout.dac_nids,
3183 cfg->line_out_type);
3184 if (err < 0)
3185 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003186
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003187 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003188 err = stac92xx_add_control(spec,
3189 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003190 "Headphone as Line Out Switch",
3191 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003192 if (err < 0)
3193 return err;
3194 }
3195
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003196 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3197 nid = cfg->input_pins[idx];
3198 if (nid) {
3199 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3200 if (err < 0)
3201 return err;
3202 }
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003203 }
Matt Porter403d1942005-11-29 15:00:51 +01003204
Mattc7d4b2f2005-06-27 14:59:41 +02003205 return 0;
3206}
3207
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003208/* add playback controls for Speaker and HP outputs */
3209static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3210 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003211{
3212 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003213 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003214
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003215 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3216 spec->hp_dacs, AUTO_PIN_HP_OUT);
3217 if (err < 0)
3218 return err;
3219
3220 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3221 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3222 if (err < 0)
3223 return err;
3224
Mattc7d4b2f2005-06-27 14:59:41 +02003225 return 0;
3226}
3227
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003228/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003229static const char *stac92xx_mono_labels[4] = {
3230 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003231};
3232
3233/* create mono mux for mono out on capable codecs */
3234static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3235{
3236 struct sigmatel_spec *spec = codec->spec;
3237 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3238 int i, num_cons;
3239 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3240
3241 num_cons = snd_hda_get_connections(codec,
3242 spec->mono_nid,
3243 con_lst,
3244 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003245 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003246 return -EINVAL;
3247
3248 for (i = 0; i < num_cons; i++) {
3249 mono_mux->items[mono_mux->num_items].label =
3250 stac92xx_mono_labels[i];
3251 mono_mux->items[mono_mux->num_items].index = i;
3252 mono_mux->num_items++;
3253 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003254
3255 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3256 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003257}
3258
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003259/* create PC beep volume controls */
3260static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3261 hda_nid_t nid)
3262{
3263 struct sigmatel_spec *spec = codec->spec;
3264 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003265 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3266
3267 if (spec->anabeep_nid == nid)
3268 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003269
3270 /* check for mute support for the the amp */
3271 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003272 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003273 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003274 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3275 if (err < 0)
3276 return err;
3277 }
3278
3279 /* check to see if there is volume support for the amp */
3280 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3281 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003282 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003283 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3284 if (err < 0)
3285 return err;
3286 }
3287 return 0;
3288}
3289
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003290#ifdef CONFIG_SND_HDA_INPUT_BEEP
3291#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3292
3293static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3294 struct snd_ctl_elem_value *ucontrol)
3295{
3296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3297 ucontrol->value.integer.value[0] = codec->beep->enabled;
3298 return 0;
3299}
3300
3301static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3302 struct snd_ctl_elem_value *ucontrol)
3303{
3304 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003305 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003306}
3307
3308static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3309 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3310 .info = stac92xx_dig_beep_switch_info,
3311 .get = stac92xx_dig_beep_switch_get,
3312 .put = stac92xx_dig_beep_switch_put,
3313};
3314
3315static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3316{
3317 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003318 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003319}
3320#endif
3321
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003322static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3323{
3324 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003325 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003326
3327 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003328 hda_nid_t nid;
3329 unsigned int wcaps;
3330 unsigned long val;
3331
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003332 nid = spec->mux_nids[i];
3333 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003334 if (!(wcaps & AC_WCAP_OUT_AMP))
3335 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003336
Takashi Iwai667067d2009-08-13 18:14:42 +02003337 /* check whether already the same control was created as
3338 * normal Capture Volume.
3339 */
3340 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3341 for (j = 0; j < spec->num_caps; j++) {
3342 if (spec->capvols[j] == val)
3343 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003344 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003345 if (j < spec->num_caps)
3346 continue;
3347
3348 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3349 "Mux Capture Volume", val);
3350 if (err < 0)
3351 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003352 }
3353 return 0;
3354};
3355
Matthew Ranostayd9737752008-09-07 12:03:41 +02003356static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003357 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003358};
3359
3360static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3361{
3362 struct sigmatel_spec *spec = codec->spec;
3363 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003364 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003365 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003366 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003367
3368 num_cons = snd_hda_get_connections(codec,
3369 spec->smux_nids[0],
3370 con_lst,
3371 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003372 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003373 return -EINVAL;
3374
Matthew Ranostay65973632008-09-16 10:39:37 -04003375 if (!labels)
3376 labels = stac92xx_spdif_labels;
3377
Matthew Ranostayd9737752008-09-07 12:03:41 +02003378 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003379 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003380 spdif_mux->items[spdif_mux->num_items].index = i;
3381 spdif_mux->num_items++;
3382 }
3383
3384 return 0;
3385}
3386
Matt Porter8b657272006-10-26 17:12:59 +02003387/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003388static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003389 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3390 "Digital Mic 3", "Digital Mic 4"
3391};
3392
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003393static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3394 hda_nid_t nid)
3395{
3396 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3397 int i, nums;
3398
3399 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3400 for (i = 0; i < nums; i++)
3401 if (conn[i] == nid)
3402 return i;
3403 return -1;
3404}
3405
Takashi Iwai667067d2009-08-13 18:14:42 +02003406/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003407/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003408static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003409 const char *label, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003410{
3411 unsigned int caps, nums;
3412 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003413 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003414
Takashi Iwai96f845d2009-08-29 00:49:36 +02003415 if (direction == HDA_OUTPUT)
3416 caps = AC_WCAP_OUT_AMP;
3417 else
3418 caps = AC_WCAP_IN_AMP;
3419 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003420 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003421 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003422 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3423 if (!nums)
3424 return 0;
3425 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003426 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3427 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3428 if (err < 0)
3429 return err;
3430 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003431}
3432
Matt Porter8b657272006-10-26 17:12:59 +02003433/* create playback/capture controls for input pins on dmic capable codecs */
3434static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3435 const struct auto_pin_cfg *cfg)
3436{
3437 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003438 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003439 struct hda_input_mux *dimux = &spec->private_dimux;
Takashi Iwai5207e102009-07-30 13:09:08 +02003440 int err, i, active_mics;
3441 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003442
3443 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3444 dimux->items[dimux->num_items].index = 0;
3445 dimux->num_items++;
3446
Takashi Iwai5207e102009-07-30 13:09:08 +02003447 active_mics = 0;
3448 for (i = 0; i < spec->num_dmics; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003449 /* check the validity: sometimes it's a dead vendor-spec node */
3450 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3451 != AC_WID_PIN)
3452 continue;
Takashi Iwai5207e102009-07-30 13:09:08 +02003453 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3454 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3455 active_mics++;
3456 }
3457
Matt Porter8b657272006-10-26 17:12:59 +02003458 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003459 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003460 int index;
Takashi Iwai5207e102009-07-30 13:09:08 +02003461 const char *label;
Matt Porter8b657272006-10-26 17:12:59 +02003462
Takashi Iwai667067d2009-08-13 18:14:42 +02003463 nid = spec->dmic_nids[i];
3464 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3465 continue;
3466 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003467 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3468 continue;
3469
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003470 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3471 if (index < 0)
3472 continue;
3473
Takashi Iwai5207e102009-07-30 13:09:08 +02003474 if (active_mics == 1)
3475 label = "Digital Mic";
3476 else
3477 label = stac92xx_dmic_labels[dimux->num_items];
3478
Takashi Iwai96f845d2009-08-29 00:49:36 +02003479 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003480 if (err < 0)
3481 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003482 if (!err) {
3483 err = create_elem_capture_vol(codec, nid, label,
3484 HDA_OUTPUT);
3485 if (err < 0)
3486 return err;
3487 }
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003488
Takashi Iwai5207e102009-07-30 13:09:08 +02003489 dimux->items[dimux->num_items].label = label;
Matt Porter8b657272006-10-26 17:12:59 +02003490 dimux->items[dimux->num_items].index = index;
3491 dimux->num_items++;
Takashi Iwai5207e102009-07-30 13:09:08 +02003492 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3493 imux->items[imux->num_items].label = label;
3494 imux->items[imux->num_items].index = index;
3495 imux->num_items++;
3496 }
Matt Porter8b657272006-10-26 17:12:59 +02003497 }
3498
3499 return 0;
3500}
3501
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003502static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3503 hda_nid_t *fixed, hda_nid_t *ext)
3504{
3505 unsigned int cfg;
3506
3507 if (!nid)
3508 return 0;
3509 cfg = snd_hda_codec_get_pincfg(codec, nid);
3510 switch (get_defcfg_connect(cfg)) {
3511 case AC_JACK_PORT_FIXED:
3512 if (*fixed)
3513 return 1; /* already occupied */
3514 *fixed = nid;
3515 break;
3516 case AC_JACK_PORT_COMPLEX:
3517 if (*ext)
3518 return 1; /* already occupied */
3519 *ext = nid;
3520 break;
3521 }
3522 return 0;
3523}
3524
3525static int set_mic_route(struct hda_codec *codec,
3526 struct sigmatel_mic_route *mic,
3527 hda_nid_t pin)
3528{
3529 struct sigmatel_spec *spec = codec->spec;
3530 struct auto_pin_cfg *cfg = &spec->autocfg;
3531 int i;
3532
3533 mic->pin = pin;
3534 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3535 if (pin == cfg->input_pins[i])
3536 break;
3537 if (i <= AUTO_PIN_FRONT_MIC) {
3538 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003539 i = get_connection_index(codec, spec->mux_nids[0], pin);
3540 if (i < 0)
3541 return -1;
3542 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003543 mic->dmux_idx = -1;
3544 if (spec->dmux_nids)
3545 mic->dmux_idx = get_connection_index(codec,
3546 spec->dmux_nids[0],
3547 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003548 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003549 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003550 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3551 if (i < 0)
3552 return -1;
3553 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003554 mic->mux_idx = -1;
3555 if (spec->mux_nids)
3556 mic->mux_idx = get_connection_index(codec,
3557 spec->mux_nids[0],
3558 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003559 }
3560 return 0;
3561}
3562
3563/* return non-zero if the device is for automatic mic switch */
3564static int stac_check_auto_mic(struct hda_codec *codec)
3565{
3566 struct sigmatel_spec *spec = codec->spec;
3567 struct auto_pin_cfg *cfg = &spec->autocfg;
3568 hda_nid_t fixed, ext;
3569 int i;
3570
3571 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3572 if (cfg->input_pins[i])
3573 return 0; /* must be exclusively mics */
3574 }
3575 fixed = ext = 0;
3576 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3577 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3578 return 0;
3579 for (i = 0; i < spec->num_dmics; i++)
3580 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3581 return 0;
3582 if (!fixed || !ext)
3583 return 0;
3584 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3585 return 0; /* no unsol support */
3586 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3587 set_mic_route(codec, &spec->int_mic, fixed))
3588 return 0; /* something is wrong */
3589 return 1;
3590}
3591
Mattc7d4b2f2005-06-27 14:59:41 +02003592/* create playback/capture controls for input pins */
3593static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3594{
3595 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003596 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003597 int i, j;
Mattc7d4b2f2005-06-27 14:59:41 +02003598
3599 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003600 hda_nid_t nid = cfg->input_pins[i];
3601 int index, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003602
Takashi Iwai667067d2009-08-13 18:14:42 +02003603 if (!nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003604 continue;
3605 index = -1;
3606 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003607 index = get_connection_index(codec, spec->mux_nids[j],
3608 nid);
3609 if (index >= 0)
3610 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003611 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003612 if (index < 0)
3613 continue;
3614
3615 err = create_elem_capture_vol(codec, nid,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003616 auto_pin_cfg_labels[i],
3617 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003618 if (err < 0)
3619 return err;
3620
Takashi Iwai314634b2006-09-21 11:56:18 +02003621 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3622 imux->items[imux->num_items].index = index;
3623 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003624 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003625 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003626
Steve Longerbeam7b043892007-05-03 20:50:03 +02003627 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003628 /*
3629 * Set the current input for the muxes.
3630 * The STAC9221 has two input muxes with identical source
3631 * NID lists. Hopefully this won't get confused.
3632 */
3633 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003634 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3635 AC_VERB_SET_CONNECT_SEL,
3636 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003637 }
3638 }
3639
Mattc7d4b2f2005-06-27 14:59:41 +02003640 return 0;
3641}
3642
Mattc7d4b2f2005-06-27 14:59:41 +02003643static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3644{
3645 struct sigmatel_spec *spec = codec->spec;
3646 int i;
3647
3648 for (i = 0; i < spec->autocfg.line_outs; i++) {
3649 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3650 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3651 }
3652}
3653
3654static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3655{
3656 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003657 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003658
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003659 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3660 hda_nid_t pin;
3661 pin = spec->autocfg.hp_pins[i];
3662 if (pin) /* connect to front */
3663 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3664 }
3665 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3666 hda_nid_t pin;
3667 pin = spec->autocfg.speaker_pins[i];
3668 if (pin) /* connect to front */
3669 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3670 }
Mattc7d4b2f2005-06-27 14:59:41 +02003671}
3672
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003673static int is_dual_headphones(struct hda_codec *codec)
3674{
3675 struct sigmatel_spec *spec = codec->spec;
3676 int i, valid_hps;
3677
3678 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3679 spec->autocfg.hp_outs <= 1)
3680 return 0;
3681 valid_hps = 0;
3682 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3683 hda_nid_t nid = spec->autocfg.hp_pins[i];
3684 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3685 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3686 continue;
3687 valid_hps++;
3688 }
3689 return (valid_hps > 1);
3690}
3691
3692
Matt Porter3cc08dc2006-01-23 15:27:49 +01003693static 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 +02003694{
3695 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003696 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003697 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003698
Matt Porter8b657272006-10-26 17:12:59 +02003699 if ((err = snd_hda_parse_pin_def_config(codec,
3700 &spec->autocfg,
3701 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003702 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003703 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003704 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003705
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003706 /* If we have no real line-out pin and multiple hp-outs, HPs should
3707 * be set up as multi-channel outputs.
3708 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003709 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003710 /* Copy hp_outs to line_outs, backup line_outs in
3711 * speaker_outs so that the following routines can handle
3712 * HP pins as primary outputs.
3713 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003714 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003715 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3716 sizeof(spec->autocfg.line_out_pins));
3717 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3718 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3719 sizeof(spec->autocfg.hp_pins));
3720 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003721 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3722 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003723 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003724 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003725 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003726 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3727 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003728 u32 caps = query_amp_caps(codec,
3729 spec->autocfg.mono_out_pin, dir);
3730 hda_nid_t conn_list[1];
3731
3732 /* get the mixer node and then the mono mux if it exists */
3733 if (snd_hda_get_connections(codec,
3734 spec->autocfg.mono_out_pin, conn_list, 1) &&
3735 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003736 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003737
3738 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003739 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003740 /* LR swap check, some stac925x have a mux that
3741 * changes the DACs output path instead of the
3742 * mono-mux path.
3743 */
3744 if (wid_type == AC_WID_AUD_SEL &&
3745 !(wcaps & AC_WCAP_LR_SWAP))
3746 spec->mono_nid = conn_list[0];
3747 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003748 if (dir) {
3749 hda_nid_t nid = spec->autocfg.mono_out_pin;
3750
3751 /* most mono outs have a least a mute/unmute switch */
3752 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3753 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3754 "Mono Playback Switch",
3755 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003756 if (err < 0)
3757 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003758 /* check for volume support for the amp */
3759 if ((caps & AC_AMPCAP_NUM_STEPS)
3760 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3761 err = stac92xx_add_control(spec,
3762 STAC_CTL_WIDGET_VOL,
3763 "Mono Playback Volume",
3764 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3765 if (err < 0)
3766 return err;
3767 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003768 }
3769
3770 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3771 AC_PINCTL_OUT_EN);
3772 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003773
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003774 if (!spec->multiout.num_dacs) {
3775 err = stac92xx_auto_fill_dac_nids(codec);
3776 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003777 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003778 err = stac92xx_auto_create_multi_out_ctls(codec,
3779 &spec->autocfg);
3780 if (err < 0)
3781 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003782 }
Mattc7d4b2f2005-06-27 14:59:41 +02003783
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003784 /* setup analog beep controls */
3785 if (spec->anabeep_nid > 0) {
3786 err = stac92xx_auto_create_beep_ctls(codec,
3787 spec->anabeep_nid);
3788 if (err < 0)
3789 return err;
3790 }
3791
3792 /* setup digital beep controls and input device */
3793#ifdef CONFIG_SND_HDA_INPUT_BEEP
3794 if (spec->digbeep_nid > 0) {
3795 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003796 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003797
3798 err = stac92xx_auto_create_beep_ctls(codec, nid);
3799 if (err < 0)
3800 return err;
3801 err = snd_hda_attach_beep_device(codec, nid);
3802 if (err < 0)
3803 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003804 if (codec->beep) {
3805 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003806 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003807 /* if no beep switch is available, make its own one */
3808 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3809 if (!(caps & AC_AMPCAP_MUTE)) {
3810 err = stac92xx_beep_switch_ctl(codec);
3811 if (err < 0)
3812 return err;
3813 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003814 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003815 }
3816#endif
3817
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003818 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003819 if (err < 0)
3820 return err;
3821
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003822 /* All output parsing done, now restore the swapped hp pins */
3823 if (hp_swap) {
3824 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3825 sizeof(spec->autocfg.hp_pins));
3826 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3827 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3828 spec->autocfg.line_outs = 0;
3829 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003830
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003831 if (stac_check_auto_mic(codec)) {
3832 spec->auto_mic = 1;
3833 /* only one capture for auto-mic */
3834 spec->num_adcs = 1;
3835 spec->num_caps = 1;
3836 spec->num_muxes = 1;
3837 }
3838
Takashi Iwai6479c632009-07-28 18:20:25 +02003839 for (i = 0; i < spec->num_caps; i++) {
3840 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3841 spec->capsws[i], i);
3842 if (err < 0)
3843 return err;
3844 }
3845
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003846 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003847 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003848 return err;
3849
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003850 if (spec->mono_nid > 0) {
3851 err = stac92xx_auto_create_mono_output_ctls(codec);
3852 if (err < 0)
3853 return err;
3854 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003855 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003856 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3857 &spec->autocfg)) < 0)
3858 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003859 if (spec->num_muxes > 0) {
3860 err = stac92xx_auto_create_mux_input_ctls(codec);
3861 if (err < 0)
3862 return err;
3863 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003864 if (spec->num_smuxes > 0) {
3865 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3866 if (err < 0)
3867 return err;
3868 }
Matt Porter8b657272006-10-26 17:12:59 +02003869
Takashi Iwaie3c75962009-01-23 11:57:22 +01003870 err = stac92xx_add_input_source(spec);
3871 if (err < 0)
3872 return err;
3873
Mattc7d4b2f2005-06-27 14:59:41 +02003874 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003875 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003876 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003877
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003878 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003879 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003880 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003881 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003882
Takashi Iwai603c4012008-07-30 15:01:44 +02003883 if (spec->kctls.list)
3884 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003885
3886 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003887 if (!spec->dinput_mux)
3888 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003889 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003890 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003891 return 1;
3892}
3893
Takashi Iwai82bc9552006-03-21 11:24:42 +01003894/* add playback controls for HP output */
3895static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3896 struct auto_pin_cfg *cfg)
3897{
3898 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003899 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003900 unsigned int wid_caps;
3901
3902 if (! pin)
3903 return 0;
3904
3905 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003906 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003907 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003908
3909 return 0;
3910}
3911
Richard Fish160ea0d2006-09-06 13:58:25 +02003912/* add playback controls for LFE output */
3913static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3914 struct auto_pin_cfg *cfg)
3915{
3916 struct sigmatel_spec *spec = codec->spec;
3917 int err;
3918 hda_nid_t lfe_pin = 0x0;
3919 int i;
3920
3921 /*
3922 * search speaker outs and line outs for a mono speaker pin
3923 * with an amp. If one is found, add LFE controls
3924 * for it.
3925 */
3926 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3927 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003928 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003929 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3930 if (wcaps == AC_WCAP_OUT_AMP)
3931 /* found a mono speaker with an amp, must be lfe */
3932 lfe_pin = pin;
3933 }
3934
3935 /* if speaker_outs is 0, then speakers may be in line_outs */
3936 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3937 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3938 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003939 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003940 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003941 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003942 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003943 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3944 if (wcaps == AC_WCAP_OUT_AMP)
3945 /* found a mono speaker with an amp,
3946 must be lfe */
3947 lfe_pin = pin;
3948 }
3949 }
3950 }
3951
3952 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003953 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003954 if (err < 0)
3955 return err;
3956 }
3957
3958 return 0;
3959}
3960
Mattc7d4b2f2005-06-27 14:59:41 +02003961static int stac9200_parse_auto_config(struct hda_codec *codec)
3962{
3963 struct sigmatel_spec *spec = codec->spec;
3964 int err;
3965
Kailang Yangdf694da2005-12-05 19:42:22 +01003966 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003967 return err;
3968
3969 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3970 return err;
3971
Takashi Iwai82bc9552006-03-21 11:24:42 +01003972 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3973 return err;
3974
Richard Fish160ea0d2006-09-06 13:58:25 +02003975 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3976 return err;
3977
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003978 if (spec->num_muxes > 0) {
3979 err = stac92xx_auto_create_mux_input_ctls(codec);
3980 if (err < 0)
3981 return err;
3982 }
3983
Takashi Iwaie3c75962009-01-23 11:57:22 +01003984 err = stac92xx_add_input_source(spec);
3985 if (err < 0)
3986 return err;
3987
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003988 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02003989 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003990 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003991 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003992
Takashi Iwai603c4012008-07-30 15:01:44 +02003993 if (spec->kctls.list)
3994 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003995
3996 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003997 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003998
3999 return 1;
4000}
4001
Sam Revitch62fe78e2006-05-10 15:09:17 +02004002/*
4003 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4004 * funky external mute control using GPIO pins.
4005 */
4006
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004007static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004008 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004009{
4010 unsigned int gpiostate, gpiomask, gpiodir;
4011
4012 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4013 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004014 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004015
4016 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4017 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004018 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004019
4020 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4021 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004022 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004023
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004024 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004025 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4026
4027 snd_hda_codec_write(codec, codec->afg, 0,
4028 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004029 snd_hda_codec_read(codec, codec->afg, 0,
4030 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004031
4032 msleep(1);
4033
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004034 snd_hda_codec_read(codec, codec->afg, 0,
4035 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004036}
4037
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004038#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwai95c09092009-04-14 16:15:29 +02004039static void stac92xx_free_jack_priv(struct snd_jack *jack)
4040{
4041 struct sigmatel_jack *jacks = jack->private_data;
4042 jacks->nid = 0;
4043 jacks->jack = NULL;
4044}
4045#endif
4046
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004047static int stac92xx_add_jack(struct hda_codec *codec,
4048 hda_nid_t nid, int type)
4049{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004050#ifdef CONFIG_SND_HDA_INPUT_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004051 struct sigmatel_spec *spec = codec->spec;
4052 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01004053 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004054 int connectivity = get_defcfg_connect(def_conf);
4055 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02004056 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004057
4058 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4059 return 0;
4060
4061 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4062 jack = snd_array_new(&spec->jacks);
4063 if (!jack)
4064 return -ENOMEM;
4065 jack->nid = nid;
4066 jack->type = type;
4067
Takashi Iwai86de7412009-07-22 16:02:46 +02004068 snprintf(name, sizeof(name), "%s at %s %s Jack",
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004069 snd_hda_get_jack_type(def_conf),
4070 snd_hda_get_jack_connectivity(def_conf),
4071 snd_hda_get_jack_location(def_conf));
4072
Takashi Iwai95c09092009-04-14 16:15:29 +02004073 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4074 if (err < 0) {
4075 jack->nid = 0;
4076 return err;
4077 }
4078 jack->jack->private_data = jack;
4079 jack->jack->private_free = stac92xx_free_jack_priv;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004080#endif
Takashi Iwai95c09092009-04-14 16:15:29 +02004081 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004082}
4083
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004084static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4085 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004086{
4087 struct sigmatel_event *event;
4088
4089 snd_array_init(&spec->events, sizeof(*event), 32);
4090 event = snd_array_new(&spec->events);
4091 if (!event)
4092 return -ENOMEM;
4093 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004094 event->type = type;
4095 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004096 event->data = data;
4097
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004098 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004099}
4100
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004101static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
Takashi Iwai62558ce2009-07-29 14:23:09 +02004102 hda_nid_t nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004103{
4104 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004105 struct sigmatel_event *event = spec->events.list;
4106 int i;
4107
4108 for (i = 0; i < spec->events.used; i++, event++) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004109 if (event->nid == nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004110 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004111 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004112 return NULL;
4113}
4114
4115static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4116 unsigned char tag)
4117{
4118 struct sigmatel_spec *spec = codec->spec;
4119 struct sigmatel_event *event = spec->events.list;
4120 int i;
4121
4122 for (i = 0; i < spec->events.used; i++, event++) {
4123 if (event->tag == tag)
4124 return event;
4125 }
4126 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004127}
4128
Takashi Iwai62558ce2009-07-29 14:23:09 +02004129/* check if given nid is a valid pin and no other events are assigned
4130 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4131 * Otherwise, returns zero.
4132 */
4133static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4134 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004135{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004136 struct sigmatel_event *event;
4137 int tag;
4138
4139 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004140 return 0;
4141 event = stac_get_event(codec, nid);
4142 if (event) {
4143 if (event->type != type)
4144 return 0;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004145 tag = event->tag;
Takashi Iwai62558ce2009-07-29 14:23:09 +02004146 } else {
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004147 tag = stac_add_event(codec->spec, nid, type, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004148 if (tag < 0)
4149 return 0;
4150 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004151 snd_hda_codec_write_cache(codec, nid, 0,
4152 AC_VERB_SET_UNSOLICITED_ENABLE,
4153 AC_USRSP_EN | tag);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004154 return 1;
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 Iwai014c41f2009-12-27 13:53:24 +01004182static inline int get_int_hint(struct hda_codec *codec, const char *key,
4183 int *valp)
4184{
4185 const char *p;
4186 p = snd_hda_get_hint(codec, key);
4187 if (p) {
4188 unsigned long val;
4189 if (!strict_strtoul(p, 0, &val)) {
4190 *valp = val;
4191 return 1;
4192 }
4193 }
4194 return 0;
4195}
4196
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004197/* override some hints from the hwdep entry */
4198static void stac_store_hints(struct hda_codec *codec)
4199{
4200 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004201 int val;
4202
4203 val = snd_hda_get_bool_hint(codec, "hp_detect");
4204 if (val >= 0)
4205 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004206 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004207 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4208 spec->gpio_mask;
4209 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004210 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4211 spec->gpio_mask &= spec->gpio_mask;
4212 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4213 spec->gpio_dir &= spec->gpio_mask;
4214 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4215 spec->eapd_mask &= spec->gpio_mask;
4216 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4217 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004218 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4219 if (val >= 0)
4220 spec->eapd_switch = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004221 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4222 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
Takashi Iwai043958e2009-12-26 10:36:12 +01004223 spec->gpio_mask |= spec->gpio_led;
4224 spec->gpio_dir |= spec->gpio_led;
4225 if (spec->gpio_led_polarity)
4226 spec->gpio_data |= spec->gpio_led;
4227 }
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004228}
4229
Mattc7d4b2f2005-06-27 14:59:41 +02004230static int stac92xx_init(struct hda_codec *codec)
4231{
4232 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004233 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004234 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004235 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004236
Mattc7d4b2f2005-06-27 14:59:41 +02004237 snd_hda_sequence_write(codec, spec->init);
4238
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004239 /* power down adcs initially */
4240 if (spec->powerdown_adcs)
4241 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004242 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004243 spec->adc_nids[i], 0,
4244 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004245
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004246 /* override some hints */
4247 stac_store_hints(codec);
4248
Takashi Iwaif73d3582008-11-25 08:21:51 +01004249 /* set up GPIO */
4250 gpio = spec->gpio_data;
4251 /* turn on EAPD statically when spec->eapd_switch isn't set.
4252 * otherwise, unsol event will turn it on/off dynamically
4253 */
4254 if (!spec->eapd_switch)
4255 gpio |= spec->eapd_mask;
4256 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4257
Takashi Iwai82bc9552006-03-21 11:24:42 +01004258 /* set up pins */
4259 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004260 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004261 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004262 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004263 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004264 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004265 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4266 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004267 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004268 for (i = 0; i < cfg->line_outs; i++) {
4269 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004270 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4271 }
4272 }
4273
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004274 /* force to enable the first line-out; the others are set up
4275 * in unsol_event
4276 */
4277 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004278 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004279 /* fake event to set up pins */
Takashi Iwai5f380eb2009-09-14 15:36:14 +02004280 if (cfg->hp_pins[0])
4281 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4282 else if (cfg->line_out_pins[0])
4283 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004284 } else {
4285 stac92xx_auto_init_multi_out(codec);
4286 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004287 for (i = 0; i < cfg->hp_outs; i++)
4288 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004289 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004290 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004291 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004292 if (spec->dmux_nids)
4293 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004294 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004295 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4296 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4297 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004298 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004299 hda_nid_t nid = cfg->input_pins[i];
4300 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004301 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004302 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4303 /* for mic pins, force to initialize */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004304 pinctl = stac92xx_get_default_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004305 pinctl |= AC_PINCTL_IN_EN;
4306 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004307 } else {
4308 pinctl = snd_hda_codec_read(codec, nid, 0,
4309 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4310 /* if PINCTL already set then skip */
Takashi Iwai5dd17cb2009-05-07 16:22:53 +02004311 /* Also, if both INPUT and OUTPUT are set,
4312 * it must be a BIOS bug; need to override, too
4313 */
4314 if (!(pinctl & AC_PINCTL_IN_EN) ||
4315 (pinctl & AC_PINCTL_OUT_EN)) {
4316 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004317 pinctl |= AC_PINCTL_IN_EN;
4318 stac92xx_auto_set_pinctl(codec, nid,
4319 pinctl);
4320 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004321 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004322 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004323 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004324 if (enable_pin_detect(codec, nid,
4325 STAC_INSERT_EVENT))
4326 stac_issue_unsol_event(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004327 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004328 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004329 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004330 for (i = 0; i < spec->num_dmics; i++)
4331 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4332 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004333 if (cfg->dig_out_pins[0])
4334 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004335 AC_PINCTL_OUT_EN);
4336 if (cfg->dig_in_pin)
4337 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4338 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004339 for (i = 0; i < spec->num_pwrs; i++) {
4340 hda_nid_t nid = spec->pwr_nids[i];
4341 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004342
Takashi Iwaieb632122008-12-19 16:39:48 +01004343 /* power on when no jack detection is available */
4344 if (!spec->hp_detect) {
4345 stac_toggle_power_map(codec, nid, 1);
4346 continue;
4347 }
4348
4349 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004350 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004351
Takashi Iwaif73d3582008-11-25 08:21:51 +01004352 pinctl = snd_hda_codec_read(codec, nid, 0,
4353 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4354 /* outputs are only ports capable of power management
4355 * any attempts on powering down a input port cause the
4356 * referenced VREF to act quirky.
4357 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004358 if (pinctl & AC_PINCTL_IN_EN) {
4359 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004360 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004361 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004362 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004363 def_conf = get_defcfg_connect(def_conf);
4364 /* skip any ports that don't have jacks since presence
4365 * detection is useless */
4366 if (def_conf != AC_JACK_PORT_COMPLEX) {
4367 if (def_conf != AC_JACK_PORT_NONE)
4368 stac_toggle_power_map(codec, nid, 1);
4369 continue;
4370 }
Takashi Iwai62558ce2009-07-29 14:23:09 +02004371 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4372 stac_issue_unsol_event(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004373 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004374
4375#ifdef CONFIG_SND_HDA_POWER_SAVE
4376 /* sync mute LED */
4377 if (spec->gpio_led && codec->patch_ops.check_power_status)
4378 codec->patch_ops.check_power_status(codec, 0x01);
4379#endif
Takashi Iwaif73d3582008-11-25 08:21:51 +01004380 if (spec->dac_list)
4381 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004382 return 0;
4383}
4384
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004385static void stac92xx_free_jacks(struct hda_codec *codec)
4386{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004387#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004388 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004389 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004390 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004391 struct sigmatel_jack *jacks = spec->jacks.list;
4392 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +02004393 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4394 if (jacks->jack)
4395 snd_device_free(codec->bus->card, jacks->jack);
4396 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004397 }
4398 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004399#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004400}
4401
Takashi Iwai603c4012008-07-30 15:01:44 +02004402static void stac92xx_free_kctls(struct hda_codec *codec)
4403{
4404 struct sigmatel_spec *spec = codec->spec;
4405
4406 if (spec->kctls.list) {
4407 struct snd_kcontrol_new *kctl = spec->kctls.list;
4408 int i;
4409 for (i = 0; i < spec->kctls.used; i++)
4410 kfree(kctl[i].name);
4411 }
4412 snd_array_free(&spec->kctls);
4413}
4414
Takashi Iwai167eae52009-11-06 15:47:50 +01004415static void stac92xx_shutup(struct hda_codec *codec)
4416{
4417 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004418
Takashi Iwai92ee6162009-12-27 11:18:59 +01004419 snd_hda_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004420
4421 if (spec->eapd_mask)
4422 stac_gpio_set(codec, spec->gpio_mask,
4423 spec->gpio_dir, spec->gpio_data &
4424 ~spec->eapd_mask);
4425}
4426
Matt2f2f4252005-04-13 14:45:30 +02004427static void stac92xx_free(struct hda_codec *codec)
4428{
Mattc7d4b2f2005-06-27 14:59:41 +02004429 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004430
4431 if (! spec)
4432 return;
4433
Takashi Iwai167eae52009-11-06 15:47:50 +01004434 stac92xx_shutup(codec);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004435 stac92xx_free_jacks(codec);
4436 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004437
Mattc7d4b2f2005-06-27 14:59:41 +02004438 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004439 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004440}
4441
Matt4e550962005-07-04 17:51:39 +02004442static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4443 unsigned int flag)
4444{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004445 unsigned int old_ctl, pin_ctl;
4446
4447 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004448 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004449
Takashi Iwaif9acba42007-05-29 18:01:06 +02004450 if (pin_ctl & AC_PINCTL_IN_EN) {
4451 /*
4452 * we need to check the current set-up direction of
4453 * shared input pins since they can be switched via
4454 * "xxx as Output" mixer switch
4455 */
4456 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004457 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004458 return;
4459 }
4460
Takashi Iwai8ce84192009-01-22 16:59:20 +01004461 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004462 /* if setting pin direction bits, clear the current
4463 direction bits first */
4464 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4465 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4466
Takashi Iwai8ce84192009-01-22 16:59:20 +01004467 pin_ctl |= flag;
4468 if (old_ctl != pin_ctl)
4469 snd_hda_codec_write_cache(codec, nid, 0,
4470 AC_VERB_SET_PIN_WIDGET_CONTROL,
4471 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004472}
4473
4474static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4475 unsigned int flag)
4476{
4477 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4478 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004479 if (pin_ctl & flag)
4480 snd_hda_codec_write_cache(codec, nid, 0,
4481 AC_VERB_SET_PIN_WIDGET_CONTROL,
4482 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004483}
4484
Takashi Iwaid56757a2009-11-18 08:00:14 +01004485static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004486{
4487 if (!nid)
4488 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004489 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004490}
4491
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004492static void stac92xx_line_out_detect(struct hda_codec *codec,
4493 int presence)
4494{
4495 struct sigmatel_spec *spec = codec->spec;
4496 struct auto_pin_cfg *cfg = &spec->autocfg;
4497 int i;
4498
4499 for (i = 0; i < cfg->line_outs; i++) {
4500 if (presence)
4501 break;
4502 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4503 if (presence) {
4504 unsigned int pinctl;
4505 pinctl = snd_hda_codec_read(codec,
4506 cfg->line_out_pins[i], 0,
4507 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4508 if (pinctl & AC_PINCTL_IN_EN)
4509 presence = 0; /* mic- or line-input */
4510 }
4511 }
4512
4513 if (presence) {
4514 /* disable speakers */
4515 for (i = 0; i < cfg->speaker_outs; i++)
4516 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4517 AC_PINCTL_OUT_EN);
4518 if (spec->eapd_mask && spec->eapd_switch)
4519 stac_gpio_set(codec, spec->gpio_mask,
4520 spec->gpio_dir, spec->gpio_data &
4521 ~spec->eapd_mask);
4522 } else {
4523 /* enable speakers */
4524 for (i = 0; i < cfg->speaker_outs; i++)
4525 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4526 AC_PINCTL_OUT_EN);
4527 if (spec->eapd_mask && spec->eapd_switch)
4528 stac_gpio_set(codec, spec->gpio_mask,
4529 spec->gpio_dir, spec->gpio_data |
4530 spec->eapd_mask);
4531 }
4532}
4533
Takashi Iwaid7a89432008-11-12 09:48:04 +01004534/* return non-zero if the hp-pin of the given array index isn't
4535 * a jack-detection target
4536 */
4537static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4538{
4539 struct auto_pin_cfg *cfg = &spec->autocfg;
4540
4541 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004542 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004543 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004544 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004545 return 1;
4546 /* ignore if the pin is set as line-out */
4547 if (cfg->hp_pins[i] == spec->hp_switch)
4548 return 1;
4549 return 0;
4550}
4551
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004552static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004553{
4554 struct sigmatel_spec *spec = codec->spec;
4555 struct auto_pin_cfg *cfg = &spec->autocfg;
4556 int i, presence;
4557
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004558 presence = 0;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004559 if (spec->gpio_mute)
4560 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4561 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4562
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004563 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004564 if (presence)
4565 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004566 if (no_hp_sensing(spec, i))
4567 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004568 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4569 if (presence) {
4570 unsigned int pinctl;
4571 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4572 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4573 if (pinctl & AC_PINCTL_IN_EN)
4574 presence = 0; /* mic- or line-input */
4575 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004576 }
Matt4e550962005-07-04 17:51:39 +02004577
4578 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004579 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004580 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004581 stac92xx_reset_pinctl(codec, spec->hp_switch,
4582 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004583 for (i = 0; i < cfg->line_outs; i++)
4584 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4585 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004586 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004587 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004588 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004589 stac92xx_set_pinctl(codec, spec->hp_switch,
4590 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004591 for (i = 0; i < cfg->line_outs; i++)
4592 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4593 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004594 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004595 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004596 /* toggle hp outs */
4597 for (i = 0; i < cfg->hp_outs; i++) {
4598 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4599 if (no_hp_sensing(spec, i))
4600 continue;
4601 if (presence)
4602 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004603#if 0 /* FIXME */
4604/* Resetting the pinctl like below may lead to (a sort of) regressions
4605 * on some devices since they use the HP pin actually for line/speaker
4606 * outs although the default pin config shows a different pin (that is
4607 * wrong and useless).
4608 *
4609 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4610 * But, disabling the code below just works around it, and I'm too tired of
4611 * bug reports with such devices...
4612 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004613 else
4614 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004615#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004616 }
Matt4e550962005-07-04 17:51:39 +02004617}
4618
Takashi Iwaif73d3582008-11-25 08:21:51 +01004619static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4620 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004621{
4622 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004623 unsigned int idx, val;
4624
4625 for (idx = 0; idx < spec->num_pwrs; idx++) {
4626 if (spec->pwr_nids[idx] == nid)
4627 break;
4628 }
4629 if (idx >= spec->num_pwrs)
4630 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004631
4632 /* several codecs have two power down bits */
4633 if (spec->pwr_mapping)
4634 idx = spec->pwr_mapping[idx];
4635 else
4636 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004637
Takashi Iwaif73d3582008-11-25 08:21:51 +01004638 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4639 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004640 val &= ~idx;
4641 else
4642 val |= idx;
4643
4644 /* power down unused output ports */
4645 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004646}
4647
Takashi Iwaif73d3582008-11-25 08:21:51 +01004648static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4649{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004650 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004651}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004652
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004653static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4654{
4655 struct sigmatel_spec *spec = codec->spec;
4656 struct sigmatel_jack *jacks = spec->jacks.list;
4657
4658 if (jacks) {
4659 int i;
4660 for (i = 0; i < spec->jacks.used; i++) {
4661 if (jacks->nid == nid) {
4662 unsigned int pin_ctl =
4663 snd_hda_codec_read(codec, nid,
4664 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4665 0x00);
4666 int type = jacks->type;
4667 if (type == (SND_JACK_LINEOUT
4668 | SND_JACK_HEADPHONE))
4669 type = (pin_ctl & AC_PINCTL_HP_EN)
4670 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4671 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004672 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004673 ? type : 0);
4674 }
4675 jacks++;
4676 }
4677 }
4678}
Matt2f2f4252005-04-13 14:45:30 +02004679
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004680static void stac92xx_mic_detect(struct hda_codec *codec)
4681{
4682 struct sigmatel_spec *spec = codec->spec;
4683 struct sigmatel_mic_route *mic;
4684
4685 if (get_pin_presence(codec, spec->ext_mic.pin))
4686 mic = &spec->ext_mic;
4687 else
4688 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004689 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004690 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4691 AC_VERB_SET_CONNECT_SEL,
4692 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004693 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004694 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4695 AC_VERB_SET_CONNECT_SEL,
4696 mic->mux_idx);
4697}
4698
Takashi Iwai62558ce2009-07-29 14:23:09 +02004699static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004700{
Takashi Iwai62558ce2009-07-29 14:23:09 +02004701 struct sigmatel_event *event = stac_get_event(codec, nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004702 if (!event)
4703 return;
4704 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4705}
4706
Takashi Iwai314634b2006-09-21 11:56:18 +02004707static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4708{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004709 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004710 struct sigmatel_event *event;
4711 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004712
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004713 tag = (res >> 26) & 0x7f;
4714 event = stac_get_event_from_tag(codec, tag);
4715 if (!event)
4716 return;
4717
4718 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004719 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004720 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004721 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004722 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004723 case STAC_MIC_EVENT:
4724 stac92xx_mic_detect(codec);
4725 break;
4726 }
4727
4728 switch (event->type) {
4729 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004730 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004731 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004732 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004733 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004734 if (spec->num_pwrs > 0)
4735 stac92xx_pin_sense(codec, event->nid);
4736 stac92xx_report_jack(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004737
4738 switch (codec->subsystem_id) {
4739 case 0x103c308f:
4740 if (event->nid == 0xb) {
4741 int pin = AC_PINCTL_IN_EN;
4742
4743 if (get_pin_presence(codec, 0xa)
4744 && get_pin_presence(codec, 0xb))
4745 pin |= AC_PINCTL_VREF_80;
4746 if (!get_pin_presence(codec, 0xb))
4747 pin |= AC_PINCTL_VREF_80;
4748
4749 /* toggle VREF state based on mic + hp pin
4750 * status
4751 */
4752 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4753 }
4754 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004755 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004756 case STAC_VREF_EVENT:
4757 data = snd_hda_codec_read(codec, codec->afg, 0,
4758 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004759 /* toggle VREF state based on GPIOx status */
4760 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004761 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004762 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004763 }
4764}
4765
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304766static int hp_blike_system(u32 subsystem_id);
4767
4768static void set_hp_led_gpio(struct hda_codec *codec)
4769{
4770 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004771 unsigned int gpio;
4772
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004773 if (spec->gpio_led)
4774 return;
4775
Takashi Iwai07f80442010-02-08 15:06:13 +01004776 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4777 gpio &= AC_GPIO_IO_COUNT;
4778 if (gpio > 3)
4779 spec->gpio_led = 0x08; /* GPIO 3 */
4780 else
4781 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304782}
4783
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004784/*
4785 * This method searches for the mute LED GPIO configuration
4786 * provided as OEM string in SMBIOS. The format of that string
4787 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4788 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4789 * that corresponds to the NOT muted state of the master volume
4790 * and G is the index of the GPIO to use as the mute LED control (0..9)
4791 * If _G portion is missing it is assigned based on the codec ID
4792 *
4793 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4794 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304795 *
4796 *
4797 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4798 * SMBIOS - at least the ones I have seen do not have them - which include
4799 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4800 * HP Pavilion dv9500t CTO.
4801 * Need more information on whether it is true across the entire series.
4802 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004803 */
Takashi Iwaidce17d42010-02-09 09:25:26 +01004804static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004805{
4806 struct sigmatel_spec *spec = codec->spec;
4807 const struct dmi_device *dev = NULL;
4808
4809 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4810 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4811 NULL, dev))) {
4812 if (sscanf(dev->name, "HP_Mute_LED_%d_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304813 &spec->gpio_led_polarity,
4814 &spec->gpio_led) == 2) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004815 spec->gpio_led = 1 << spec->gpio_led;
4816 return 1;
4817 }
4818 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304819 &spec->gpio_led_polarity) == 1) {
4820 set_hp_led_gpio(codec);
4821 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004822 }
4823 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304824
4825 /*
4826 * Fallback case - if we don't find the DMI strings,
4827 * we statically set the GPIO - if not a B-series system.
4828 */
4829 if (!hp_blike_system(codec->subsystem_id)) {
4830 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004831 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304832 return 1;
4833 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004834 }
4835 return 0;
4836}
4837
4838static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004839{
4840 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004841 case 0x103c1520:
4842 case 0x103c1521:
4843 case 0x103c1523:
4844 case 0x103c1524:
4845 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004846 case 0x103c1722:
4847 case 0x103c1723:
4848 case 0x103c1724:
4849 case 0x103c1725:
4850 case 0x103c1726:
4851 case 0x103c1727:
4852 case 0x103c1728:
4853 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004854 case 0x103c172a:
4855 case 0x103c172b:
4856 case 0x103c307e:
4857 case 0x103c307f:
4858 case 0x103c3080:
4859 case 0x103c3081:
4860 case 0x103c7007:
4861 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004862 return 1;
4863 }
4864 return 0;
4865}
4866
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004867#ifdef CONFIG_PROC_FS
4868static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4869 struct hda_codec *codec, hda_nid_t nid)
4870{
4871 if (nid == codec->afg)
4872 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4873 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4874}
4875
4876static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4877 struct hda_codec *codec,
4878 unsigned int verb)
4879{
4880 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4881 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4882}
4883
4884/* stac92hd71bxx, stac92hd73xx */
4885static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4886 struct hda_codec *codec, hda_nid_t nid)
4887{
4888 stac92hd_proc_hook(buffer, codec, nid);
4889 if (nid == codec->afg)
4890 analog_loop_proc_hook(buffer, codec, 0xfa0);
4891}
4892
4893static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4894 struct hda_codec *codec, hda_nid_t nid)
4895{
4896 if (nid == codec->afg)
4897 analog_loop_proc_hook(buffer, codec, 0xfe0);
4898}
4899
4900static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4901 struct hda_codec *codec, hda_nid_t nid)
4902{
4903 if (nid == codec->afg)
4904 analog_loop_proc_hook(buffer, codec, 0xfeb);
4905}
4906#else
4907#define stac92hd_proc_hook NULL
4908#define stac92hd7x_proc_hook NULL
4909#define stac9205_proc_hook NULL
4910#define stac927x_proc_hook NULL
4911#endif
4912
Takashi Iwaicb53c622007-08-10 17:21:45 +02004913#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004914static int stac92xx_resume(struct hda_codec *codec)
4915{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004916 struct sigmatel_spec *spec = codec->spec;
4917
Takashi Iwai2c885872008-11-18 09:36:55 +01004918 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004919 snd_hda_codec_resume_amp(codec);
4920 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004921 /* fake event to set up pins again to override cached values */
Takashi Iwai5f380eb2009-09-14 15:36:14 +02004922 if (spec->hp_detect) {
4923 if (spec->autocfg.hp_pins[0])
4924 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4925 else if (spec->autocfg.line_out_pins[0])
4926 stac_issue_unsol_event(codec,
4927 spec->autocfg.line_out_pins[0]);
4928 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004929#ifdef CONFIG_SND_HDA_POWER_SAVE
4930 /* sync mute LED */
4931 if (spec->gpio_led && codec->patch_ops.check_power_status)
4932 codec->patch_ops.check_power_status(codec, 0x01);
4933#endif
Mattff6fdc32005-06-27 15:06:52 +02004934 return 0;
4935}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004936
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004937/*
James Gardiner514bf542009-05-03 04:00:44 -04004938 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004939 * check for mute state only on Speakers (nid = 0x10)
4940 *
4941 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4942 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004943 *
4944 * Changed name to reflect that it now works for any designated
4945 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004946 */
4947
4948#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004949static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004950 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004951{
4952 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21bd022010-02-08 15:16:08 +01004953 int i, muted = 1;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004954
Takashi Iwaic21bd022010-02-08 15:16:08 +01004955 for (i = 0; i < spec->multiout.num_dacs; i++) {
4956 nid = spec->multiout.dac_nids[i];
4957 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4958 HDA_AMP_MUTE)) {
4959 muted = 0; /* something heard */
4960 break;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01004961 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004962 }
4963 if (muted)
4964 spec->gpio_data &= ~spec->gpio_led; /* orange */
4965 else
4966 spec->gpio_data |= spec->gpio_led; /* white */
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01004967
Takashi Iwaic21bd022010-02-08 15:16:08 +01004968 if (!spec->gpio_led_polarity) {
4969 /* LED state is inverted on these systems */
4970 spec->gpio_data ^= spec->gpio_led;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004971 }
4972
Takashi Iwaib4e81872009-11-18 17:20:24 +01004973 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
Takashi Iwaib4e81872009-11-18 17:20:24 +01004974 return 0;
4975}
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004976#endif
4977
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004978static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4979{
Takashi Iwai167eae52009-11-06 15:47:50 +01004980 stac92xx_shutup(codec);
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004981 return 0;
4982}
Mattff6fdc32005-06-27 15:06:52 +02004983#endif
4984
Matt2f2f4252005-04-13 14:45:30 +02004985static struct hda_codec_ops stac92xx_patch_ops = {
4986 .build_controls = stac92xx_build_controls,
4987 .build_pcms = stac92xx_build_pcms,
4988 .init = stac92xx_init,
4989 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004990 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004991#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004992 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004993 .resume = stac92xx_resume,
4994#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01004995 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02004996};
4997
4998static int patch_stac9200(struct hda_codec *codec)
4999{
5000 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005001 int err;
Matt2f2f4252005-04-13 14:45:30 +02005002
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005004 if (spec == NULL)
5005 return -ENOMEM;
5006
Takashi Iwaia252c812009-12-25 22:56:20 +01005007 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005008 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005009 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005010 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005011 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005012 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5013 stac9200_models,
5014 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005015 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005016 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5017 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005018 else
5019 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005020 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005021
5022 spec->multiout.max_channels = 2;
5023 spec->multiout.num_dacs = 1;
5024 spec->multiout.dac_nids = stac9200_dac_nids;
5025 spec->adc_nids = stac9200_adc_nids;
5026 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005027 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005028 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005029 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005030 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005031
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005032 if (spec->board_config == STAC_9200_M4 ||
5033 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005034 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005035 spec->init = stac9200_eapd_init;
5036 else
5037 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005038 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005039
Takashi Iwai117f2572008-03-18 09:53:23 +01005040 if (spec->board_config == STAC_9200_PANASONIC) {
5041 spec->gpio_mask = spec->gpio_dir = 0x09;
5042 spec->gpio_data = 0x00;
5043 }
5044
Mattc7d4b2f2005-06-27 14:59:41 +02005045 err = stac9200_parse_auto_config(codec);
5046 if (err < 0) {
5047 stac92xx_free(codec);
5048 return err;
5049 }
Matt2f2f4252005-04-13 14:45:30 +02005050
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005051 /* CF-74 has no headphone detection, and the driver should *NOT*
5052 * do detection and HP/speaker toggle because the hardware does it.
5053 */
5054 if (spec->board_config == STAC_9200_PANASONIC)
5055 spec->hp_detect = 0;
5056
Matt2f2f4252005-04-13 14:45:30 +02005057 codec->patch_ops = stac92xx_patch_ops;
5058
5059 return 0;
5060}
5061
Tobin Davis8e21c342007-01-08 11:04:17 +01005062static int patch_stac925x(struct hda_codec *codec)
5063{
5064 struct sigmatel_spec *spec;
5065 int err;
5066
5067 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5068 if (spec == NULL)
5069 return -ENOMEM;
5070
Takashi Iwaia252c812009-12-25 22:56:20 +01005071 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005072 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005073 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005074 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005075 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005076
5077 /* Check first for codec ID */
5078 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5079 STAC_925x_MODELS,
5080 stac925x_models,
5081 stac925x_codec_id_cfg_tbl);
5082
5083 /* Now checks for PCI ID, if codec ID is not found */
5084 if (spec->board_config < 0)
5085 spec->board_config = snd_hda_check_board_config(codec,
5086 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005087 stac925x_models,
5088 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005089 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005090 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005091 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5092 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005093 else
5094 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005095 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005096
5097 spec->multiout.max_channels = 2;
5098 spec->multiout.num_dacs = 1;
5099 spec->multiout.dac_nids = stac925x_dac_nids;
5100 spec->adc_nids = stac925x_adc_nids;
5101 spec->mux_nids = stac925x_mux_nids;
5102 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005103 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005104 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005105 switch (codec->vendor_id) {
5106 case 0x83847632: /* STAC9202 */
5107 case 0x83847633: /* STAC9202D */
5108 case 0x83847636: /* STAC9251 */
5109 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005110 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005111 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005112 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5113 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005114 break;
5115 default:
5116 spec->num_dmics = 0;
5117 break;
5118 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005119
5120 spec->init = stac925x_core_init;
5121 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005122 spec->num_caps = 1;
5123 spec->capvols = stac925x_capvols;
5124 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005125
5126 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005127 if (!err) {
5128 if (spec->board_config < 0) {
5129 printk(KERN_WARNING "hda_codec: No auto-config is "
5130 "available, default to model=ref\n");
5131 spec->board_config = STAC_925x_REF;
5132 goto again;
5133 }
5134 err = -EINVAL;
5135 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005136 if (err < 0) {
5137 stac92xx_free(codec);
5138 return err;
5139 }
5140
5141 codec->patch_ops = stac92xx_patch_ops;
5142
5143 return 0;
5144}
5145
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005146static int patch_stac92hd73xx(struct hda_codec *codec)
5147{
5148 struct sigmatel_spec *spec;
5149 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5150 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005151 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005152
5153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5154 if (spec == NULL)
5155 return -ENOMEM;
5156
Takashi Iwaia252c812009-12-25 22:56:20 +01005157 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005158 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005159 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005160 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005161 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5162 spec->pin_nids = stac92hd73xx_pin_nids;
5163 spec->board_config = snd_hda_check_board_config(codec,
5164 STAC_92HD73XX_MODELS,
5165 stac92hd73xx_models,
5166 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005167 /* check codec subsystem id if not found */
5168 if (spec->board_config < 0)
5169 spec->board_config =
5170 snd_hda_check_board_codec_sid_config(codec,
5171 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5172 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005173again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005174 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005175 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5176 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005177 else
5178 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005179 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005180
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005181 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005182 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5183
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005184 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005185 printk(KERN_WARNING "hda_codec: Could not determine "
5186 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005187 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005188 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005189 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005190 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005191 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005192 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005193 break;
5194 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005195 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005196 break;
5197 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005198 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5199 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005200 }
5201 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005202
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005203 spec->aloopback_mask = 0x01;
5204 spec->aloopback_shift = 8;
5205
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005206 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005207 spec->mux_nids = stac92hd73xx_mux_nids;
5208 spec->adc_nids = stac92hd73xx_adc_nids;
5209 spec->dmic_nids = stac92hd73xx_dmic_nids;
5210 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005211 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005212
5213 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5214 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005215 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005216
Takashi Iwai6479c632009-07-28 18:20:25 +02005217 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5218 spec->capvols = stac92hd73xx_capvols;
5219 spec->capsws = stac92hd73xx_capsws;
5220
Matthew Ranostaya7662642008-02-21 07:51:14 +01005221 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005222 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005223 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005224 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005225 case STAC_DELL_M6_AMIC:
5226 case STAC_DELL_M6_DMIC:
5227 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005228 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005229 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005230
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005231 switch (spec->board_config) {
5232 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005233 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005234 spec->num_dmics = 0;
5235 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005236 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005237 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005238 spec->num_dmics = 1;
5239 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005240 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005241 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5242 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005243 spec->num_dmics = 1;
5244 break;
5245 }
5246 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005247 case STAC_ALIENWARE_M17X:
5248 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5249 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5250 spec->eapd_switch = 0;
5251 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005252 default:
5253 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005254 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005255 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005256 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005257 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005258 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005259 /* GPIO0 High = Enable EAPD */
5260 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5261 spec->gpio_data = 0x01;
5262 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005263
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005264 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5265 spec->pwr_nids = stac92hd73xx_pwr_nids;
5266
Matthew Ranostayd9737752008-09-07 12:03:41 +02005267 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005268
5269 if (!err) {
5270 if (spec->board_config < 0) {
5271 printk(KERN_WARNING "hda_codec: No auto-config is "
5272 "available, default to model=ref\n");
5273 spec->board_config = STAC_92HD73XX_REF;
5274 goto again;
5275 }
5276 err = -EINVAL;
5277 }
5278
5279 if (err < 0) {
5280 stac92xx_free(codec);
5281 return err;
5282 }
5283
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005284 if (spec->board_config == STAC_92HD73XX_NO_JD)
5285 spec->hp_detect = 0;
5286
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005287 codec->patch_ops = stac92xx_patch_ops;
5288
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005289 codec->proc_widget_hook = stac92hd7x_proc_hook;
5290
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005291 return 0;
5292}
5293
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005294static int patch_stac92hd83xxx(struct hda_codec *codec)
5295{
5296 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005297 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005298 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005299 int num_dacs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005300
5301 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5302 if (spec == NULL)
5303 return -ENOMEM;
5304
Takashi Iwaia252c812009-12-25 22:56:20 +01005305 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005306 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005307 spec->linear_tone_beep = 1;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005308 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005309 spec->digbeep_nid = 0x21;
Takashi Iwai667067d2009-08-13 18:14:42 +02005310 spec->mux_nids = stac92hd83xxx_mux_nids;
5311 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005312 spec->adc_nids = stac92hd83xxx_adc_nids;
Takashi Iwai7570ef12009-08-15 11:57:53 +02005313 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005314 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5315 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5316 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005317 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005318
5319 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005320 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005321 spec->pin_nids = stac92hd83xxx_pin_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02005322 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5323 spec->capvols = stac92hd83xxx_capvols;
5324 spec->capsws = stac92hd83xxx_capsws;
5325
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005326 spec->board_config = snd_hda_check_board_config(codec,
5327 STAC_92HD83XXX_MODELS,
5328 stac92hd83xxx_models,
5329 stac92hd83xxx_cfg_tbl);
5330again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005331 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005332 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5333 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005334 else
5335 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005336 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005337
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005338 switch (codec->vendor_id) {
Charles Chin36706002010-01-29 12:05:51 +01005339 case 0x111d7666:
5340 case 0x111d7667:
5341 case 0x111d7668:
5342 case 0x111d7669:
5343 spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids);
5344 spec->pin_nids = stac92hd88xxx_pin_nids;
5345 spec->mono_nid = 0;
5346 spec->digbeep_nid = 0;
5347 spec->num_pwrs = 0;
5348 break;
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005349 case 0x111d7604:
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01005350 case 0x111d76d4:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005351 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005352 case 0x111d76d5:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005353 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5354 break;
5355 spec->num_pwrs = 0;
5356 break;
5357 }
5358
Takashi Iwaib4e81872009-11-18 17:20:24 +01005359 codec->patch_ops = stac92xx_patch_ops;
5360
Takashi Iwaidce17d42010-02-09 09:25:26 +01005361 if (find_mute_led_gpio(codec, 0))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005362 snd_printd("mute LED gpio %d polarity %d\n",
5363 spec->gpio_led,
5364 spec->gpio_led_polarity);
5365
Takashi Iwaib4e81872009-11-18 17:20:24 +01005366#ifdef CONFIG_SND_HDA_POWER_SAVE
5367 if (spec->gpio_led) {
5368 spec->gpio_mask |= spec->gpio_led;
5369 spec->gpio_dir |= spec->gpio_led;
5370 spec->gpio_data |= spec->gpio_led;
5371 /* register check_power_status callback. */
5372 codec->patch_ops.check_power_status =
Takashi Iwaic21bd022010-02-08 15:16:08 +01005373 stac92xx_hp_check_power_status;
Takashi Iwaib4e81872009-11-18 17:20:24 +01005374 }
5375#endif
5376
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005377 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5378 if (!err) {
5379 if (spec->board_config < 0) {
5380 printk(KERN_WARNING "hda_codec: No auto-config is "
5381 "available, default to model=ref\n");
5382 spec->board_config = STAC_92HD83XXX_REF;
5383 goto again;
5384 }
5385 err = -EINVAL;
5386 }
5387
5388 if (err < 0) {
5389 stac92xx_free(codec);
5390 return err;
5391 }
5392
Charles Chin04b5efe2010-02-04 10:28:02 +01005393 /* docking output support */
5394 num_dacs = snd_hda_get_connections(codec, 0xF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005395 conn, STAC92HD83_DAC_COUNT + 1) - 1;
Charles Chin04b5efe2010-02-04 10:28:02 +01005396 /* skip non-DAC connections */
5397 while (num_dacs >= 0 &&
5398 (get_wcaps_type(get_wcaps(codec, conn[num_dacs]))
5399 != AC_WID_AUD_OUT))
5400 num_dacs--;
5401 /* set port E and F to select the last DAC */
5402 if (num_dacs >= 0) {
5403 snd_hda_codec_write_cache(codec, 0xE, 0,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005404 AC_VERB_SET_CONNECT_SEL, num_dacs);
Charles Chin04b5efe2010-02-04 10:28:02 +01005405 snd_hda_codec_write_cache(codec, 0xF, 0,
5406 AC_VERB_SET_CONNECT_SEL, num_dacs);
5407 }
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005408
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005409 codec->proc_widget_hook = stac92hd_proc_hook;
5410
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005411 return 0;
5412}
5413
Takashi Iwai330ee992009-02-20 14:33:36 +01005414/* get the pin connection (fixed, none, etc) */
5415static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5416{
5417 struct sigmatel_spec *spec = codec->spec;
5418 unsigned int cfg;
5419
5420 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5421 return get_defcfg_connect(cfg);
5422}
5423
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005424static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5425 hda_nid_t *nids, int num_nids)
5426{
5427 struct sigmatel_spec *spec = codec->spec;
5428 int idx, num;
5429 unsigned int def_conf;
5430
5431 for (num = 0; num < num_nids; num++) {
5432 for (idx = 0; idx < spec->num_pins; idx++)
5433 if (spec->pin_nids[idx] == nids[num])
5434 break;
5435 if (idx >= spec->num_pins)
5436 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01005437 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005438 if (def_conf == AC_JACK_PORT_NONE)
5439 break;
5440 }
5441 return num;
5442}
5443
5444static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5445 hda_nid_t dig0pin)
5446{
5447 struct sigmatel_spec *spec = codec->spec;
5448 int idx;
5449
5450 for (idx = 0; idx < spec->num_pins; idx++)
5451 if (spec->pin_nids[idx] == dig0pin)
5452 break;
5453 if ((idx + 2) >= spec->num_pins)
5454 return 0;
5455
5456 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005457 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005458 return 2;
5459
5460 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005461 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005462 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005463 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005464 return 1;
5465 else
5466 return 0;
5467}
5468
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005469/* HP dv7 bass switch - GPIO5 */
5470#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5471static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5472 struct snd_ctl_elem_value *ucontrol)
5473{
5474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5475 struct sigmatel_spec *spec = codec->spec;
5476 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5477 return 0;
5478}
5479
5480static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5481 struct snd_ctl_elem_value *ucontrol)
5482{
5483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5484 struct sigmatel_spec *spec = codec->spec;
5485 unsigned int gpio_data;
5486
5487 gpio_data = (spec->gpio_data & ~0x20) |
5488 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5489 if (gpio_data == spec->gpio_data)
5490 return 0;
5491 spec->gpio_data = gpio_data;
5492 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5493 return 1;
5494}
5495
5496static struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
5497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5498 .info = stac_hp_bass_gpio_info,
5499 .get = stac_hp_bass_gpio_get,
5500 .put = stac_hp_bass_gpio_put,
5501};
5502
5503static int stac_add_hp_bass_switch(struct hda_codec *codec)
5504{
5505 struct sigmatel_spec *spec = codec->spec;
5506
5507 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5508 "Bass Speaker Playback Switch", 0))
5509 return -ENOMEM;
5510
5511 spec->gpio_mask |= 0x20;
5512 spec->gpio_dir |= 0x20;
5513 spec->gpio_data |= 0x20;
5514 return 0;
5515}
5516
Matthew Ranostaye035b842007-11-06 11:53:55 +01005517static int patch_stac92hd71bxx(struct hda_codec *codec)
5518{
5519 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005520 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005521 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005522 int err = 0;
5523
5524 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5525 if (spec == NULL)
5526 return -ENOMEM;
5527
Takashi Iwaia252c812009-12-25 22:56:20 +01005528 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005529 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005530 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005531 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005532 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5533 switch (codec->vendor_id) {
5534 case 0x111d76b6:
5535 case 0x111d76b7:
5536 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5537 break;
5538 case 0x111d7603:
5539 case 0x111d7608:
5540 /* On 92HD75Bx 0x27 isn't a pin nid */
5541 spec->num_pins--;
5542 /* fallthrough */
5543 default:
5544 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5545 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005546 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005547 spec->board_config = snd_hda_check_board_config(codec,
5548 STAC_92HD71BXX_MODELS,
5549 stac92hd71bxx_models,
5550 stac92hd71bxx_cfg_tbl);
5551again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005552 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005553 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5554 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005555 else
5556 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005557 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005558
Takashi Iwaifc64b262009-09-14 15:33:01 +02005559 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005560 /* GPIO0 = EAPD */
5561 spec->gpio_mask = 0x01;
5562 spec->gpio_dir = 0x01;
5563 spec->gpio_data = 0x01;
5564 }
5565
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005566 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5567 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5568
Takashi Iwai6479c632009-07-28 18:20:25 +02005569 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5570 spec->capvols = stac92hd71bxx_capvols;
5571 spec->capsws = stac92hd71bxx_capsws;
5572
Matthew Ranostay541eee82007-12-14 12:08:04 +01005573 switch (codec->vendor_id) {
5574 case 0x111d76b6: /* 4 Port without Analog Mixer */
5575 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005576 unmute_init++;
5577 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005578 case 0x111d76b4: /* 6 Port without Analog Mixer */
5579 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005580 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005581 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005582 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5583 stac92hd71bxx_dmic_nids,
5584 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005585 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005586 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005587 switch (spec->board_config) {
5588 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005589 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005590 err = stac_add_event(spec, codec->afg,
5591 STAC_VREF_EVENT, 0x02);
5592 if (err < 0)
5593 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005594 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005595 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5596 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005597 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005598 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005599 spec->gpio_mask |= 0x02;
5600 break;
5601 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005602 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005603 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005604 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005605
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005606 /* no output amps */
5607 spec->num_pwrs = 0;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005608 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005609 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005610 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005611 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5612 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005613 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5614 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5615 stac92hd71bxx_dmic_nids,
5616 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005617 break;
5618 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005619 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005620 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005621
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005622 /* no output amps */
5623 spec->num_pwrs = 0;
5624 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005625 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005626 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005627 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005628 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5629 stac92hd71bxx_dmic_nids,
5630 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005631 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005632 }
5633
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005634 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5635 snd_hda_sequence_write_cache(codec, unmute_init);
5636
Takashi Iwaib20f3b82009-06-02 01:20:22 +02005637 /* Some HP machines seem to have unstable codec communications
5638 * especially with ATI fglrx driver. For recovering from the
5639 * CORB/RIRB stall, allow the BUS reset and keep always sync
5640 */
5641 if (spec->board_config == STAC_HP_DV5) {
5642 codec->bus->sync_write = 1;
5643 codec->bus->allow_bus_reset = 1;
5644 }
5645
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005646 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005647 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005648 spec->aloopback_shift = 0;
5649
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005650 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005651 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005652 spec->mux_nids = stac92hd71bxx_mux_nids;
5653 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005654 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005655 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005656
5657 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5658 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005659 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005660 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005661
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305662 snd_printdd("Found board config: %d\n", spec->board_config);
5663
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005664 switch (spec->board_config) {
5665 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005666 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005667 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005668 stac92xx_auto_set_pinctl(codec, 0x0e,
5669 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005670 /* fallthru */
5671 case STAC_DELL_M4_2:
5672 spec->num_dmics = 0;
5673 spec->num_smuxes = 0;
5674 spec->num_dmuxes = 0;
5675 break;
5676 case STAC_DELL_M4_1:
5677 case STAC_DELL_M4_3:
5678 spec->num_dmics = 1;
5679 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005680 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005681 break;
James Gardiner514bf542009-05-03 04:00:44 -04005682 case STAC_HP_DV4_1222NR:
5683 spec->num_dmics = 1;
5684 /* I don't know if it needs 1 or 2 smuxes - will wait for
5685 * bug reports to fix if needed
5686 */
5687 spec->num_smuxes = 1;
5688 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005689 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005690 case STAC_HP_DV4:
5691 spec->gpio_led = 0x01;
5692 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005693 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005694 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005695 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005696 /* HP dv6 gives the headphone pin as a line-out. Thus we
5697 * need to set hp_detect flag here to force to enable HP
5698 * detection.
5699 */
5700 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005701 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005702 case STAC_HP_HDX:
5703 spec->num_dmics = 1;
5704 spec->num_dmuxes = 1;
5705 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005706 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005707 break;
5708 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005709
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005710 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005711 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5712 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5713 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5714 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5715 /* It was changed in the BIOS to just satisfy MS DTM.
5716 * Lets turn it back into slaved HP
5717 */
5718 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5719 | (AC_JACK_HP_OUT <<
5720 AC_DEFCFG_DEVICE_SHIFT);
5721 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5722 | AC_DEFCFG_SEQUENCE)))
5723 | 0x1f;
5724 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5725 }
5726 }
5727
Takashi Iwaidce17d42010-02-09 09:25:26 +01005728 if (find_mute_led_gpio(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005729 snd_printd("mute LED gpio %d polarity %d\n",
5730 spec->gpio_led,
5731 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005732
Takashi Iwai86d190e2009-05-26 15:18:58 +02005733#ifdef CONFIG_SND_HDA_POWER_SAVE
5734 if (spec->gpio_led) {
5735 spec->gpio_mask |= spec->gpio_led;
5736 spec->gpio_dir |= spec->gpio_led;
5737 spec->gpio_data |= spec->gpio_led;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005738 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005739 codec->patch_ops.check_power_status =
Takashi Iwai86d190e2009-05-26 15:18:58 +02005740 stac92xx_hp_check_power_status;
5741 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005742#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005743
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005744 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005745
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005746 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005747 if (!err) {
5748 if (spec->board_config < 0) {
5749 printk(KERN_WARNING "hda_codec: No auto-config is "
5750 "available, default to model=ref\n");
5751 spec->board_config = STAC_92HD71BXX_REF;
5752 goto again;
5753 }
5754 err = -EINVAL;
5755 }
5756
5757 if (err < 0) {
5758 stac92xx_free(codec);
5759 return err;
5760 }
5761
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005762 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005763 if (spec->board_config == STAC_HP_DV4 ||
5764 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005765 unsigned int cap;
5766 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5767 cap &= AC_GPIO_IO_COUNT;
5768 if (cap >= 6)
5769 stac_add_hp_bass_switch(codec);
5770 }
5771
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005772 codec->proc_widget_hook = stac92hd7x_proc_hook;
5773
Matthew Ranostaye035b842007-11-06 11:53:55 +01005774 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005775}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005776
Matt2f2f4252005-04-13 14:45:30 +02005777static int patch_stac922x(struct hda_codec *codec)
5778{
5779 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005780 int err;
Matt2f2f4252005-04-13 14:45:30 +02005781
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005782 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005783 if (spec == NULL)
5784 return -ENOMEM;
5785
Takashi Iwaia252c812009-12-25 22:56:20 +01005786 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005787 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005788 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005789 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005790 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005791 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5792 stac922x_models,
5793 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005794 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005795 spec->gpio_mask = spec->gpio_dir = 0x03;
5796 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005797 /* Intel Macs have all same PCI SSID, so we need to check
5798 * codec SSID to distinguish the exact models
5799 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005800 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005801 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005802
5803 case 0x106b0800:
5804 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005805 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005806 case 0x106b0600:
5807 case 0x106b0700:
5808 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005809 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005810 case 0x106b0e00:
5811 case 0x106b0f00:
5812 case 0x106b1600:
5813 case 0x106b1700:
5814 case 0x106b0200:
5815 case 0x106b1e00:
5816 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005817 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005818 case 0x106b1a00:
5819 case 0x00000100:
5820 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005821 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005822 case 0x106b0a00:
5823 case 0x106b2200:
5824 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005825 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005826 default:
5827 spec->board_config = STAC_INTEL_MAC_V3;
5828 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005829 }
5830 }
5831
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005832 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005833 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005834 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5835 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005836 else
5837 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005838 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005839
Matt2f2f4252005-04-13 14:45:30 +02005840 spec->adc_nids = stac922x_adc_nids;
5841 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005842 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005843 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005844 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005845 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005846
5847 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005848
5849 spec->num_caps = STAC922X_NUM_CAPS;
5850 spec->capvols = stac922x_capvols;
5851 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005852
5853 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005854
Matt Porter3cc08dc2006-01-23 15:27:49 +01005855 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005856 if (!err) {
5857 if (spec->board_config < 0) {
5858 printk(KERN_WARNING "hda_codec: No auto-config is "
5859 "available, default to model=ref\n");
5860 spec->board_config = STAC_D945_REF;
5861 goto again;
5862 }
5863 err = -EINVAL;
5864 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005865 if (err < 0) {
5866 stac92xx_free(codec);
5867 return err;
5868 }
5869
5870 codec->patch_ops = stac92xx_patch_ops;
5871
Takashi Iwai807a46362007-05-29 19:01:37 +02005872 /* Fix Mux capture level; max to 2 */
5873 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5874 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5875 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5876 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5877 (0 << AC_AMPCAP_MUTE_SHIFT));
5878
Matt Porter3cc08dc2006-01-23 15:27:49 +01005879 return 0;
5880}
5881
5882static int patch_stac927x(struct hda_codec *codec)
5883{
5884 struct sigmatel_spec *spec;
5885 int err;
5886
5887 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5888 if (spec == NULL)
5889 return -ENOMEM;
5890
Takashi Iwaia252c812009-12-25 22:56:20 +01005891 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01005892 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005893 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005894 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005895 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005896 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005897 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5898 stac927x_models,
5899 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005900 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005901 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005902 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5903 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005904 else
5905 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005906 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005907
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005908 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005909 spec->adc_nids = stac927x_adc_nids;
5910 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5911 spec->mux_nids = stac927x_mux_nids;
5912 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005913 spec->smux_nids = stac927x_smux_nids;
5914 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005915 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005916 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005917 spec->multiout.dac_nids = spec->dac_nids;
5918
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005919 if (spec->board_config != STAC_D965_REF) {
5920 /* GPIO0 High = Enable EAPD */
5921 spec->eapd_mask = spec->gpio_mask = 0x01;
5922 spec->gpio_dir = spec->gpio_data = 0x01;
5923 }
5924
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005925 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005926 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005927 case STAC_D965_5ST:
5928 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005929 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02005930 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005931 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005932 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005933 switch (codec->subsystem_id) {
5934 case 0x10280209:
5935 case 0x1028022e:
5936 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005937 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005938 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005939 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005940 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005941 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005942 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005943 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005944 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005945 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005946 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005947 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005948 if (codec->subsystem_id != 0x1028022f) {
5949 /* GPIO2 High = Enable EAPD */
5950 spec->eapd_mask = spec->gpio_mask = 0x04;
5951 spec->gpio_dir = spec->gpio_data = 0x04;
5952 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005953 spec->dmic_nids = stac927x_dmic_nids;
5954 spec->num_dmics = STAC927X_NUM_DMICS;
5955
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02005956 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005957 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005958 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005959 break;
Takashi Iwai54930532009-10-11 17:38:29 +02005960 case STAC_927X_VOLKNOB:
5961 spec->num_dmics = 0;
5962 spec->init = stac927x_volknob_core_init;
5963 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005964 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005965 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005966 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005967 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005968 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005969
Takashi Iwai6479c632009-07-28 18:20:25 +02005970 spec->num_caps = STAC927X_NUM_CAPS;
5971 spec->capvols = stac927x_capvols;
5972 spec->capsws = stac927x_capsws;
5973
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005974 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005975 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005976 spec->aloopback_mask = 0x40;
5977 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005978 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005979
Matt Porter3cc08dc2006-01-23 15:27:49 +01005980 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005981 if (!err) {
5982 if (spec->board_config < 0) {
5983 printk(KERN_WARNING "hda_codec: No auto-config is "
5984 "available, default to model=ref\n");
5985 spec->board_config = STAC_D965_REF;
5986 goto again;
5987 }
5988 err = -EINVAL;
5989 }
Mattc7d4b2f2005-06-27 14:59:41 +02005990 if (err < 0) {
5991 stac92xx_free(codec);
5992 return err;
5993 }
Matt2f2f4252005-04-13 14:45:30 +02005994
5995 codec->patch_ops = stac92xx_patch_ops;
5996
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005997 codec->proc_widget_hook = stac927x_proc_hook;
5998
Takashi Iwai52987652008-01-16 16:09:47 +01005999 /*
6000 * !!FIXME!!
6001 * The STAC927x seem to require fairly long delays for certain
6002 * command sequences. With too short delays (even if the answer
6003 * is set to RIRB properly), it results in the silence output
6004 * on some hardwares like Dell.
6005 *
6006 * The below flag enables the longer delay (see get_response
6007 * in hda_intel.c).
6008 */
6009 codec->bus->needs_damn_long_delay = 1;
6010
Takashi Iwaie28d8322008-12-17 13:48:29 +01006011 /* no jack detecion for ref-no-jd model */
6012 if (spec->board_config == STAC_D965_REF_NO_JD)
6013 spec->hp_detect = 0;
6014
Matt2f2f4252005-04-13 14:45:30 +02006015 return 0;
6016}
6017
Matt Porterf3302a52006-07-31 12:49:34 +02006018static int patch_stac9205(struct hda_codec *codec)
6019{
6020 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006021 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006022
6023 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6024 if (spec == NULL)
6025 return -ENOMEM;
6026
Takashi Iwaia252c812009-12-25 22:56:20 +01006027 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006028 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006029 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006030 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006031 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006032 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6033 stac9205_models,
6034 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006035 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006036 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006037 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6038 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006039 else
6040 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01006041 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006042
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006043 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006044 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006045 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006046 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006047 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006048 spec->smux_nids = stac9205_smux_nids;
6049 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006050 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006051 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006052 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006053 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006054 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006055
6056 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006057 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006058
Takashi Iwai6479c632009-07-28 18:20:25 +02006059 spec->num_caps = STAC9205_NUM_CAPS;
6060 spec->capvols = stac9205_capvols;
6061 spec->capsws = stac9205_capsws;
6062
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006063 spec->aloopback_mask = 0x40;
6064 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006065 /* Turn on/off EAPD per HP plugging */
6066 if (spec->board_config != STAC_9205_EAPD)
6067 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006068 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006069
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006070 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006071 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006072 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006073 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6074 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006075
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006076 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006077 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6078 if (err < 0)
6079 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006080 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006081 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6082 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006083 AC_VERB_SET_UNSOLICITED_ENABLE,
6084 AC_USRSP_EN | err);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006085
6086 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006087 spec->eapd_mask = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006088 spec->gpio_mask = 0x1b;
6089 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006090 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006091 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006092 */
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006093 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006094 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006095 case STAC_9205_REF:
6096 /* SPDIF-In enabled */
6097 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006098 default:
6099 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006100 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006101 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006102 break;
6103 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006104
Matt Porterf3302a52006-07-31 12:49:34 +02006105 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006106 if (!err) {
6107 if (spec->board_config < 0) {
6108 printk(KERN_WARNING "hda_codec: No auto-config is "
6109 "available, default to model=ref\n");
6110 spec->board_config = STAC_9205_REF;
6111 goto again;
6112 }
6113 err = -EINVAL;
6114 }
Matt Porterf3302a52006-07-31 12:49:34 +02006115 if (err < 0) {
6116 stac92xx_free(codec);
6117 return err;
6118 }
6119
6120 codec->patch_ops = stac92xx_patch_ops;
6121
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006122 codec->proc_widget_hook = stac9205_proc_hook;
6123
Matt Porterf3302a52006-07-31 12:49:34 +02006124 return 0;
6125}
6126
Matt2f2f4252005-04-13 14:45:30 +02006127/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006128 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006129 */
6130
Takashi Iwai1e137f92009-01-21 07:41:22 +01006131static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6134 {}
6135};
6136
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006137static hda_nid_t stac9872_pin_nids[] = {
6138 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6139 0x11, 0x13, 0x14,
6140};
6141
6142static hda_nid_t stac9872_adc_nids[] = {
6143 0x8 /*,0x6*/
6144};
6145
6146static hda_nid_t stac9872_mux_nids[] = {
6147 0x15
6148};
6149
Takashi Iwai6479c632009-07-28 18:20:25 +02006150static unsigned long stac9872_capvols[] = {
6151 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6152};
6153#define stac9872_capsws stac9872_capvols
6154
Takashi Iwai307282c2009-03-12 18:17:58 +01006155static unsigned int stac9872_vaio_pin_configs[9] = {
6156 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6157 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6158 0x90a7013e
6159};
6160
6161static const char *stac9872_models[STAC_9872_MODELS] = {
6162 [STAC_9872_AUTO] = "auto",
6163 [STAC_9872_VAIO] = "vaio",
6164};
6165
6166static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6167 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6168};
6169
6170static struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006171 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6172 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006173 {} /* terminator */
6174};
6175
Guillaume Munch6d859062006-08-22 17:15:47 +02006176static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006177{
6178 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006179 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006180
Takashi Iwaidb064e52006-03-16 16:04:58 +01006181 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6182 if (spec == NULL)
6183 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006184 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006185 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006186 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006187 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6188 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006189
6190 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6191 stac9872_models,
6192 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006193 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006194 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6195 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006196 else
6197 stac92xx_set_config_regs(codec,
6198 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006199
Takashi Iwai1e137f92009-01-21 07:41:22 +01006200 spec->multiout.dac_nids = spec->dac_nids;
6201 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6202 spec->adc_nids = stac9872_adc_nids;
6203 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6204 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006205 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006206 spec->num_caps = 1;
6207 spec->capvols = stac9872_capvols;
6208 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006209
Takashi Iwai1e137f92009-01-21 07:41:22 +01006210 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
6211 if (err < 0) {
6212 stac92xx_free(codec);
6213 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006214 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006215 spec->input_mux = &spec->private_imux;
6216 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006217 return 0;
6218}
6219
6220
6221/*
Matt2f2f4252005-04-13 14:45:30 +02006222 * patch entries
6223 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006224static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006225 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6226 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6227 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6228 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6229 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6230 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6231 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006232 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6233 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6234 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6235 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6236 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6237 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006238 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6239 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6240 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6241 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6242 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6243 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6244 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6245 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6246 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6247 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006248 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6249 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6250 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6251 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6252 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6253 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006254 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6255 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006256 /* The following does not take into account .id=0x83847661 when subsys =
6257 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6258 * currently not fully supported.
6259 */
6260 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6261 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6262 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006263 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006264 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6265 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6266 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6267 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6268 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6269 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6270 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6271 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006272 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006273 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006274 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006275 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006276 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006277 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6278 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6279 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6280 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006281 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006282 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6283 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006284 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006285 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6286 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6287 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6288 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6289 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6290 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6291 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6292 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02006293 {} /* terminator */
6294};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006295
6296MODULE_ALIAS("snd-hda-codec-id:8384*");
6297MODULE_ALIAS("snd-hda-codec-id:111d*");
6298
6299MODULE_LICENSE("GPL");
6300MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6301
6302static struct hda_codec_preset_list sigmatel_list = {
6303 .preset = snd_hda_preset_sigmatel,
6304 .owner = THIS_MODULE,
6305};
6306
6307static int __init patch_sigmatel_init(void)
6308{
6309 return snd_hda_add_codec_preset(&sigmatel_list);
6310}
6311
6312static void __exit patch_sigmatel_exit(void)
6313{
6314 snd_hda_delete_codec_preset(&sigmatel_list);
6315}
6316
6317module_init(patch_sigmatel_init)
6318module_exit(patch_sigmatel_exit)