blob: 4cce92cf8eadf1a6a1873939df31e2140beead16 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040033#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Takashi Iwaic6e4c662008-11-25 11:58:19 +010038enum {
39 STAC_VREF_EVENT = 1,
40 STAC_INSERT_EVENT,
41 STAC_PWR_EVENT,
42 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020043 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020044 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010045};
Matt4e550962005-07-04 17:51:39 +020046
Takashi Iwaif5fcc132006-11-24 17:07:44 +010047enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010048 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010049 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010050 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020051 STAC_9200_DELL_D21,
52 STAC_9200_DELL_D22,
53 STAC_9200_DELL_D23,
54 STAC_9200_DELL_M21,
55 STAC_9200_DELL_M22,
56 STAC_9200_DELL_M23,
57 STAC_9200_DELL_M24,
58 STAC_9200_DELL_M25,
59 STAC_9200_DELL_M26,
60 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020061 STAC_9200_M4,
62 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010063 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010064 STAC_9200_MODELS
65};
66
67enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010068 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020070 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020071 STAC_9205_DELL_M43,
72 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010073 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010074 STAC_9205_MODELS
75};
76
77enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010078 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010079 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010080 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080081 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010082 STAC_DELL_M6_AMIC,
83 STAC_DELL_M6_DMIC,
84 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050085 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010086 STAC_92HD73XX_MODELS
87};
88
89enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010090 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020091 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050092 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050093 STAC_DELL_S14,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020094 STAC_92HD83XXX_MODELS
95};
96
97enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010098 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +010099 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100100 STAC_DELL_M4_1,
101 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500102 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400103 STAC_HP_M4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100104 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100105 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400106 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100107 STAC_92HD71BXX_MODELS
108};
109
110enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100111 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100112 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200113 STAC_M1,
114 STAC_M1_2,
115 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100116 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200117 STAC_M3,
118 STAC_M5,
119 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100120 STAC_925x_MODELS
121};
122
123enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100124 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100125 STAC_D945_REF,
126 STAC_D945GTP3,
127 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200128 STAC_INTEL_MAC_V1,
129 STAC_INTEL_MAC_V2,
130 STAC_INTEL_MAC_V3,
131 STAC_INTEL_MAC_V4,
132 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800133 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
134 * is given, one of the above models will be
135 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200136 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100137 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100138 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100139 STAC_MACBOOK_PRO_V1,
140 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200141 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200142 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300143 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200144 STAC_922X_DELL_D81,
145 STAC_922X_DELL_D82,
146 STAC_922X_DELL_M81,
147 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100148 STAC_922X_MODELS
149};
150
151enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100152 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100153 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100154 STAC_D965_REF,
155 STAC_D965_3ST,
156 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200157 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200158 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100159 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100160 STAC_927X_MODELS
161};
Matt Porter403d1942005-11-29 15:00:51 +0100162
Takashi Iwai307282c2009-03-12 18:17:58 +0100163enum {
164 STAC_9872_AUTO,
165 STAC_9872_VAIO,
166 STAC_9872_MODELS
167};
168
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400169struct sigmatel_event {
170 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100171 unsigned char type;
172 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400173 int data;
174};
175
176struct sigmatel_jack {
177 hda_nid_t nid;
178 int type;
179 struct snd_jack *jack;
180};
181
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200182struct sigmatel_mic_route {
183 hda_nid_t pin;
184 unsigned char mux_idx;
185 unsigned char dmux_idx;
186};
187
Matt2f2f4252005-04-13 14:45:30 +0200188struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100189 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200190 unsigned int num_mixers;
191
Matt Porter403d1942005-11-29 15:00:51 +0100192 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500193 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200194 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100195 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100196 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400197 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100198 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200199 unsigned int auto_mic:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200200
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100201 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200202 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100203 unsigned int gpio_mask;
204 unsigned int gpio_dir;
205 unsigned int gpio_data;
206 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200207 unsigned int gpio_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100208
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200209 /* stream */
210 unsigned int stream_delay;
211
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100212 /* analog loopback */
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100213 struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100214 unsigned char aloopback_mask;
215 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200216
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100217 /* power management */
218 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200219 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100220 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100221 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100222
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400223 /* jack detection */
224 struct snd_array jacks;
225
226 /* events */
227 struct snd_array events;
228
Matt2f2f4252005-04-13 14:45:30 +0200229 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100230 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400231 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100232 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200233 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100234 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100235 hda_nid_t hp_dacs[5];
236 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200237
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100238 int volume_offset;
239
Matt2f2f4252005-04-13 14:45:30 +0200240 /* capture */
241 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200242 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200243 hda_nid_t *mux_nids;
244 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200245 hda_nid_t *dmic_nids;
246 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100247 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100248 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200249 hda_nid_t *smux_nids;
250 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200251 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200252
253 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
255 unsigned int num_caps; /* number of capture volume/switch elements */
256
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200257 struct sigmatel_mic_route ext_mic;
258 struct sigmatel_mic_route int_mic;
259
Matthew Ranostay65973632008-09-16 10:39:37 -0400260 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200261
Mattdabbed62005-06-14 10:19:34 +0200262 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100263 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200264 hda_nid_t anabeep_nid;
265 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200266
Matt2f2f4252005-04-13 14:45:30 +0200267 /* pin widgets */
268 hda_nid_t *pin_nids;
269 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200270
271 /* codec specific stuff */
272 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100273 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200274
275 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200276 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100277 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200278 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100279 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200280 struct hda_input_mux *sinput_mux;
281 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400282 unsigned int cur_amux;
283 hda_nid_t *amp_nids;
284 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200285 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200286
Matt Porter403d1942005-11-29 15:00:51 +0100287 /* i/o switches */
288 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200289 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100290 hda_nid_t line_switch; /* shared line-in for input and output */
291 hda_nid_t mic_switch; /* shared mic-in for input and output */
292 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200293 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200294
Mattc7d4b2f2005-06-27 14:59:41 +0200295 struct hda_pcm pcm_rec[2]; /* PCM information */
296
297 /* dynamic controls and input_mux */
298 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200299 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200300 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200301 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200302 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400303 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100304 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200305};
306
307static hda_nid_t stac9200_adc_nids[1] = {
308 0x03,
309};
310
311static hda_nid_t stac9200_mux_nids[1] = {
312 0x0c,
313};
314
315static hda_nid_t stac9200_dac_nids[1] = {
316 0x02,
317};
318
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100319static hda_nid_t stac92hd73xx_pwr_nids[8] = {
320 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
321 0x0f, 0x10, 0x11
322};
323
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400324static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
325 0x26, 0,
326};
327
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100328static hda_nid_t stac92hd73xx_adc_nids[2] = {
329 0x1a, 0x1b
330};
331
332#define STAC92HD73XX_NUM_DMICS 2
333static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
334 0x13, 0x14, 0
335};
336
337#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100338
Takashi Iwaie2aec172009-09-02 01:00:05 +0200339static hda_nid_t stac92hd73xx_mux_nids[2] = {
340 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100341};
342
343static hda_nid_t stac92hd73xx_dmux_nids[2] = {
344 0x20, 0x21,
345};
346
Matthew Ranostayd9737752008-09-07 12:03:41 +0200347static hda_nid_t stac92hd73xx_smux_nids[2] = {
348 0x22, 0x23,
349};
350
Takashi Iwai6479c632009-07-28 18:20:25 +0200351#define STAC92HD73XX_NUM_CAPS 2
352static unsigned long stac92hd73xx_capvols[] = {
353 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
354 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
355};
356#define stac92hd73xx_capsws stac92hd73xx_capvols
357
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200358#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200359
Takashi Iwai667067d2009-08-13 18:14:42 +0200360static hda_nid_t stac92hd83xxx_mux_nids[2] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200361 0x17, 0x18,
362};
363
364static hda_nid_t stac92hd83xxx_adc_nids[2] = {
365 0x15, 0x16,
366};
367
368static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
369 0xa, 0xb, 0xd, 0xe,
370};
371
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400372static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
373 0x1e, 0,
374};
375
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200376static unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500377 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200378};
379
Takashi Iwai6479c632009-07-28 18:20:25 +0200380#define STAC92HD83XXX_NUM_CAPS 2
381static unsigned long stac92hd83xxx_capvols[] = {
382 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
383 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
384};
385#define stac92hd83xxx_capsws stac92hd83xxx_capvols
386
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100387static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
388 0x0a, 0x0d, 0x0f
389};
390
Matthew Ranostaye035b842007-11-06 11:53:55 +0100391static hda_nid_t stac92hd71bxx_adc_nids[2] = {
392 0x12, 0x13,
393};
394
395static hda_nid_t stac92hd71bxx_mux_nids[2] = {
396 0x1a, 0x1b
397};
398
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400399static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
400 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100401};
402
Matthew Ranostayd9737752008-09-07 12:03:41 +0200403static hda_nid_t stac92hd71bxx_smux_nids[2] = {
404 0x24, 0x25,
405};
406
Matthew Ranostaye035b842007-11-06 11:53:55 +0100407#define STAC92HD71BXX_NUM_DMICS 2
408static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
409 0x18, 0x19, 0
410};
411
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400412static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
413 0x22, 0
414};
415
Takashi Iwai6479c632009-07-28 18:20:25 +0200416#define STAC92HD71BXX_NUM_CAPS 2
417static unsigned long stac92hd71bxx_capvols[] = {
418 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
419 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
420};
421#define stac92hd71bxx_capsws stac92hd71bxx_capvols
422
Tobin Davis8e21c342007-01-08 11:04:17 +0100423static hda_nid_t stac925x_adc_nids[1] = {
424 0x03,
425};
426
427static hda_nid_t stac925x_mux_nids[1] = {
428 0x0f,
429};
430
431static hda_nid_t stac925x_dac_nids[1] = {
432 0x02,
433};
434
Takashi Iwaif6e98522007-10-16 14:27:04 +0200435#define STAC925X_NUM_DMICS 1
436static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
437 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200438};
439
Takashi Iwai1697055e2007-12-18 18:05:52 +0100440static hda_nid_t stac925x_dmux_nids[1] = {
441 0x14,
442};
443
Takashi Iwai6479c632009-07-28 18:20:25 +0200444static unsigned long stac925x_capvols[] = {
445 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
446};
447static unsigned long stac925x_capsws[] = {
448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
449};
450
Matt2f2f4252005-04-13 14:45:30 +0200451static hda_nid_t stac922x_adc_nids[2] = {
452 0x06, 0x07,
453};
454
455static hda_nid_t stac922x_mux_nids[2] = {
456 0x12, 0x13,
457};
458
Takashi Iwai6479c632009-07-28 18:20:25 +0200459#define STAC922X_NUM_CAPS 2
460static unsigned long stac922x_capvols[] = {
461 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
462 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
463};
464#define stac922x_capsws stac922x_capvols
465
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500466static hda_nid_t stac927x_slave_dig_outs[2] = {
467 0x1f, 0,
468};
469
Matt Porter3cc08dc2006-01-23 15:27:49 +0100470static hda_nid_t stac927x_adc_nids[3] = {
471 0x07, 0x08, 0x09
472};
473
474static hda_nid_t stac927x_mux_nids[3] = {
475 0x15, 0x16, 0x17
476};
477
Matthew Ranostayd9737752008-09-07 12:03:41 +0200478static hda_nid_t stac927x_smux_nids[1] = {
479 0x21,
480};
481
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100482static hda_nid_t stac927x_dac_nids[6] = {
483 0x02, 0x03, 0x04, 0x05, 0x06, 0
484};
485
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100486static hda_nid_t stac927x_dmux_nids[1] = {
487 0x1b,
488};
489
Matthew Ranostay7f168592007-10-18 17:38:17 +0200490#define STAC927X_NUM_DMICS 2
491static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
492 0x13, 0x14, 0
493};
494
Takashi Iwai6479c632009-07-28 18:20:25 +0200495#define STAC927X_NUM_CAPS 3
496static unsigned long stac927x_capvols[] = {
497 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
500};
501static unsigned long stac927x_capsws[] = {
502 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
505};
506
Matthew Ranostay65973632008-09-16 10:39:37 -0400507static const char *stac927x_spdif_labels[5] = {
508 "Digital Playback", "ADAT", "Analog Mux 1",
509 "Analog Mux 2", "Analog Mux 3"
510};
511
Matt Porterf3302a52006-07-31 12:49:34 +0200512static hda_nid_t stac9205_adc_nids[2] = {
513 0x12, 0x13
514};
515
516static hda_nid_t stac9205_mux_nids[2] = {
517 0x19, 0x1a
518};
519
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100520static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100521 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522};
523
Matthew Ranostayd9737752008-09-07 12:03:41 +0200524static hda_nid_t stac9205_smux_nids[1] = {
525 0x21,
526};
527
Takashi Iwaif6e98522007-10-16 14:27:04 +0200528#define STAC9205_NUM_DMICS 2
529static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
530 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200531};
532
Takashi Iwai6479c632009-07-28 18:20:25 +0200533#define STAC9205_NUM_CAPS 2
534static unsigned long stac9205_capvols[] = {
535 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
536 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
537};
538static unsigned long stac9205_capsws[] = {
539 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
541};
542
Mattc7d4b2f2005-06-27 14:59:41 +0200543static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200544 0x08, 0x09, 0x0d, 0x0e,
545 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200546};
547
Tobin Davis8e21c342007-01-08 11:04:17 +0100548static hda_nid_t stac925x_pin_nids[8] = {
549 0x07, 0x08, 0x0a, 0x0b,
550 0x0c, 0x0d, 0x10, 0x11,
551};
552
Matt2f2f4252005-04-13 14:45:30 +0200553static hda_nid_t stac922x_pin_nids[10] = {
554 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
555 0x0f, 0x10, 0x11, 0x15, 0x1b,
556};
557
Matthew Ranostaya7662642008-02-21 07:51:14 +0100558static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100562};
563
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500564static hda_nid_t stac92hd83xxx_pin_nids[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500566 0x0f, 0x10, 0x11, 0x1f, 0x20,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200567};
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500568
569#define STAC92HD71BXX_NUM_PINS 13
570static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
571 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
572 0x00, 0x14, 0x18, 0x19, 0x1e,
573 0x1f, 0x20, 0x27
574};
575static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100576 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
577 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500578 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100579};
580
Matt Porter3cc08dc2006-01-23 15:27:49 +0100581static hda_nid_t stac927x_pin_nids[14] = {
582 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
583 0x0f, 0x10, 0x11, 0x12, 0x13,
584 0x14, 0x21, 0x22, 0x23,
585};
586
Matt Porterf3302a52006-07-31 12:49:34 +0200587static hda_nid_t stac9205_pin_nids[12] = {
588 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
589 0x0f, 0x14, 0x16, 0x17, 0x18,
590 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200591};
592
Matthew Ranostay89385032008-09-11 09:49:39 -0400593#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
594
595static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
597{
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
601
602 kcontrol->private_value ^= get_amp_nid(kcontrol);
603 kcontrol->private_value |= nid;
604
605 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
606}
607
608static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
610{
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
613 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
614
615 kcontrol->private_value ^= get_amp_nid(kcontrol);
616 kcontrol->private_value |= nid;
617
618 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
619}
620
Matt Porter8b657272006-10-26 17:12:59 +0200621static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_info *uinfo)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
627}
628
629static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
630 struct snd_ctl_elem_value *ucontrol)
631{
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100634 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200635
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100636 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200637 return 0;
638}
639
640static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100645 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200646
647 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100648 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200649}
650
Matthew Ranostayd9737752008-09-07 12:03:41 +0200651static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_info *uinfo)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
657}
658
659static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
661{
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 struct sigmatel_spec *spec = codec->spec;
664 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
665
666 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
667 return 0;
668}
669
670static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
672{
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400675 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200676 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400677 int err, val;
678 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200679
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400680 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200681 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400682 if (err < 0)
683 return err;
684
685 if (spec->spdif_mute) {
686 if (smux_idx == 0)
687 nid = spec->multiout.dig_out_nid;
688 else
689 nid = codec->slave_dig_outs[smux_idx - 1];
690 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100691 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400692 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100693 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400694 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100695 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
696 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400697 }
698 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200699}
700
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200701static unsigned int stac92xx_vref_set(struct hda_codec *codec,
702 hda_nid_t nid, unsigned int new_vref)
703{
Takashi Iwaib8621512009-06-22 08:00:10 +0200704 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200705 unsigned int pincfg;
706 pincfg = snd_hda_codec_read(codec, nid, 0,
707 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
708
709 pincfg &= 0xff;
710 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
711 pincfg |= new_vref;
712
713 if (new_vref == AC_PINCTL_VREF_HIZ)
714 pincfg |= AC_PINCTL_OUT_EN;
715 else
716 pincfg |= AC_PINCTL_IN_EN;
717
718 error = snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
720 if (error < 0)
721 return error;
722 else
723 return 1;
724}
725
726static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
727{
728 unsigned int vref;
729 vref = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
731 vref &= AC_PINCTL_VREFEN;
732 return vref;
733}
734
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100735static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200736{
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200739 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200740}
741
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100742static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200743{
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 struct sigmatel_spec *spec = codec->spec;
746 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
747
748 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
749 return 0;
750}
751
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100752static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200753{
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 struct sigmatel_spec *spec = codec->spec;
756 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200757 const struct hda_input_mux *imux = spec->input_mux;
758 unsigned int idx, prev_idx;
Matt2f2f4252005-04-13 14:45:30 +0200759
Takashi Iwai5207e102009-07-30 13:09:08 +0200760 idx = ucontrol->value.enumerated.item[0];
761 if (idx >= imux->num_items)
762 idx = imux->num_items - 1;
763 prev_idx = spec->cur_mux[adc_idx];
764 if (prev_idx == idx)
765 return 0;
766 if (idx < spec->num_analog_muxes) {
767 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
768 AC_VERB_SET_CONNECT_SEL,
769 imux->items[idx].index);
770 if (prev_idx >= spec->num_analog_muxes) {
771 imux = spec->dinput_mux;
772 /* 0 = analog */
773 snd_hda_codec_write_cache(codec,
774 spec->dmux_nids[adc_idx], 0,
775 AC_VERB_SET_CONNECT_SEL,
776 imux->items[0].index);
777 }
778 } else {
779 imux = spec->dinput_mux;
780 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
781 AC_VERB_SET_CONNECT_SEL,
782 imux->items[idx - 1].index);
783 }
784 spec->cur_mux[adc_idx] = idx;
785 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200786}
787
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100788static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
789 struct snd_ctl_elem_info *uinfo)
790{
791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
792 struct sigmatel_spec *spec = codec->spec;
793 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
794}
795
796static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
797 struct snd_ctl_elem_value *ucontrol)
798{
799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
800 struct sigmatel_spec *spec = codec->spec;
801
802 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
803 return 0;
804}
805
806static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
807 struct snd_ctl_elem_value *ucontrol)
808{
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 struct sigmatel_spec *spec = codec->spec;
811
812 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
813 spec->mono_nid, &spec->cur_mmux);
814}
815
Matthew Ranostay89385032008-09-11 09:49:39 -0400816static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
817 struct snd_ctl_elem_info *uinfo)
818{
819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
820 struct sigmatel_spec *spec = codec->spec;
821 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
822}
823
824static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
825 struct snd_ctl_elem_value *ucontrol)
826{
827 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
828 struct sigmatel_spec *spec = codec->spec;
829
830 ucontrol->value.enumerated.item[0] = spec->cur_amux;
831 return 0;
832}
833
834static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
835 struct snd_ctl_elem_value *ucontrol)
836{
837 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
838 struct sigmatel_spec *spec = codec->spec;
839 struct snd_kcontrol *ctl =
840 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
841 if (!ctl)
842 return -EINVAL;
843
844 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
845 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
846
847 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
848 0, &spec->cur_amux);
849}
850
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200851#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
852
853static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
854 struct snd_ctl_elem_value *ucontrol)
855{
856 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100857 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200858 struct sigmatel_spec *spec = codec->spec;
859
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100860 ucontrol->value.integer.value[0] = !!(spec->aloopback &
861 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200862 return 0;
863}
864
865static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
866 struct snd_ctl_elem_value *ucontrol)
867{
868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
869 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100870 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200871 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100872 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200873
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100874 idx_val = spec->aloopback_mask << idx;
875 if (ucontrol->value.integer.value[0])
876 val = spec->aloopback | idx_val;
877 else
878 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100879 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200880 return 0;
881
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100882 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200883
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100884 /* Only return the bits defined by the shift value of the
885 * first two bytes of the mask
886 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200887 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100888 kcontrol->private_value & 0xFFFF, 0x0);
889 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200890
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100891 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200892 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100893 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200894 } else {
895 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100896 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200897 }
898
899 snd_hda_codec_write_cache(codec, codec->afg, 0,
900 kcontrol->private_value >> 16, dac_mode);
901
902 return 1;
903}
904
Mattc7d4b2f2005-06-27 14:59:41 +0200905static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200906 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200907 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200908 {}
909};
910
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200911static struct hda_verb stac9200_eapd_init[] = {
912 /* set dac0mux for dac converter */
913 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
914 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
915 {}
916};
917
Matthew Ranostayd654a662008-03-14 08:46:51 +0100918static struct hda_verb dell_eq_core_init[] = {
919 /* set master volume to max value without distortion
920 * and direct control */
921 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100922 {}
923};
924
Takashi Iwaie2aec172009-09-02 01:00:05 +0200925static struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100926 /* set master volume and direct control */
927 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100928 {}
929};
930
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200931static struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -0500932 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
933 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
934 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200935
936 /* power state controls amps */
937 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200938 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200939};
940
Matthew Ranostaye035b842007-11-06 11:53:55 +0100941static struct hda_verb stac92hd71bxx_core_init[] = {
942 /* set master volume and direct control */
943 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200944 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100945};
946
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500947static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
948 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
949 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100950 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
951 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100952 {}
953};
954
Tobin Davis8e21c342007-01-08 11:04:17 +0100955static struct hda_verb stac925x_core_init[] = {
956 /* set dac0mux for dac converter */
957 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100958 /* mute the master volume */
959 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100960 {}
961};
962
Mattc7d4b2f2005-06-27 14:59:41 +0200963static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200964 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200965 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200966 {}
967};
968
Tobin Davis93ed1502006-09-01 21:03:12 +0200969static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200970 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200971 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200972 /* unmute node 0x1b */
973 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
974 /* select node 0x03 as DAC */
975 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
976 {}
977};
978
Matt Porter3cc08dc2006-01-23 15:27:49 +0100979static struct hda_verb stac927x_core_init[] = {
980 /* set master volume and direct control */
981 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200982 /* enable analog pc beep path */
983 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100984 {}
985};
986
Matt Porterf3302a52006-07-31 12:49:34 +0200987static struct hda_verb stac9205_core_init[] = {
988 /* set master volume and direct control */
989 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200990 /* enable analog pc beep path */
991 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200992 {}
993};
994
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100995#define STAC_MONO_MUX \
996 { \
997 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
998 .name = "Mono Mux", \
999 .count = 1, \
1000 .info = stac92xx_mono_mux_enum_info, \
1001 .get = stac92xx_mono_mux_enum_get, \
1002 .put = stac92xx_mono_mux_enum_put, \
1003 }
1004
Matthew Ranostay89385032008-09-11 09:49:39 -04001005#define STAC_AMP_MUX \
1006 { \
1007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1008 .name = "Amp Selector Capture Switch", \
1009 .count = 1, \
1010 .info = stac92xx_amp_mux_enum_info, \
1011 .get = stac92xx_amp_mux_enum_get, \
1012 .put = stac92xx_amp_mux_enum_put, \
1013 }
1014
1015#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1016 { \
1017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1018 .name = xname, \
1019 .index = 0, \
1020 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1021 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1022 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1023 .info = stac92xx_amp_volume_info, \
1024 .get = stac92xx_amp_volume_get, \
1025 .put = stac92xx_amp_volume_put, \
1026 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1027 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1028 }
1029
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001030#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001031 { \
1032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1033 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001034 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001035 .info = stac92xx_aloopback_info, \
1036 .get = stac92xx_aloopback_get, \
1037 .put = stac92xx_aloopback_put, \
1038 .private_value = verb_read | (verb_write << 16), \
1039 }
1040
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001041#define DC_BIAS(xname, idx, nid) \
1042 { \
1043 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1044 .name = xname, \
1045 .index = idx, \
1046 .info = stac92xx_dc_bias_info, \
1047 .get = stac92xx_dc_bias_get, \
1048 .put = stac92xx_dc_bias_put, \
1049 .private_value = nid, \
1050 }
1051
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001052static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +02001053 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001055 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1056 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001057 { } /* end */
1058};
1059
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001060static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1061 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1062 {}
1063};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001064
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001065static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1066 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1067 {}
1068};
1069
1070static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1071 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1072 {}
1073};
1074
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001075
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001076static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1077 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1078};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001079
Tobin Davis8e21c342007-01-08 11:04:17 +01001080static struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwaic9280d62009-01-15 17:31:00 +01001081 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001083 { } /* end */
1084};
1085
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001086static struct snd_kcontrol_new stac9205_loopback[] = {
1087 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1088 {}
1089};
1090
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001091static struct snd_kcontrol_new stac927x_loopback[] = {
1092 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1093 {}
1094};
1095
Takashi Iwai1697055e2007-12-18 18:05:52 +01001096static struct snd_kcontrol_new stac_dmux_mixer = {
1097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1098 .name = "Digital Input Source",
1099 /* count set later */
1100 .info = stac92xx_dmux_enum_info,
1101 .get = stac92xx_dmux_enum_get,
1102 .put = stac92xx_dmux_enum_put,
1103};
1104
Matthew Ranostayd9737752008-09-07 12:03:41 +02001105static struct snd_kcontrol_new stac_smux_mixer = {
1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001107 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001108 /* count set later */
1109 .info = stac92xx_smux_enum_info,
1110 .get = stac92xx_smux_enum_get,
1111 .put = stac92xx_smux_enum_put,
1112};
1113
Takashi Iwai2134ea42008-01-10 16:53:55 +01001114static const char *slave_vols[] = {
1115 "Front Playback Volume",
1116 "Surround Playback Volume",
1117 "Center Playback Volume",
1118 "LFE Playback Volume",
1119 "Side Playback Volume",
1120 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001121 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001122 NULL
1123};
1124
1125static const char *slave_sws[] = {
1126 "Front Playback Switch",
1127 "Surround Playback Switch",
1128 "Center Playback Switch",
1129 "LFE Playback Switch",
1130 "Side Playback Switch",
1131 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001132 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001133 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001134 NULL
1135};
1136
Takashi Iwai603c4012008-07-30 15:01:44 +02001137static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001138static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001139
Matt2f2f4252005-04-13 14:45:30 +02001140static int stac92xx_build_controls(struct hda_codec *codec)
1141{
1142 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001143 struct auto_pin_cfg *cfg = &spec->autocfg;
1144 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001145 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001146 int i;
Matt2f2f4252005-04-13 14:45:30 +02001147
Takashi Iwai6479c632009-07-28 18:20:25 +02001148 if (spec->mixer) {
1149 err = snd_hda_add_new_ctls(codec, spec->mixer);
1150 if (err < 0)
1151 return err;
1152 }
Mattc7d4b2f2005-06-27 14:59:41 +02001153
1154 for (i = 0; i < spec->num_mixers; i++) {
1155 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1156 if (err < 0)
1157 return err;
1158 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001159 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1160 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001161 stac_dmux_mixer.count = spec->num_dmuxes;
Takashi Iwaid13bd412008-07-30 15:01:45 +02001162 err = snd_hda_ctl_add(codec,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001163 snd_ctl_new1(&stac_dmux_mixer, codec));
1164 if (err < 0)
1165 return err;
1166 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001167 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001168 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1169 struct hda_input_mux *smux = &spec->private_smux;
1170 /* check for mute support on SPDIF out */
1171 if (wcaps & AC_WCAP_OUT_AMP) {
1172 smux->items[smux->num_items].label = "Off";
1173 smux->items[smux->num_items].index = 0;
1174 smux->num_items++;
1175 spec->spdif_mute = 1;
1176 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001177 stac_smux_mixer.count = spec->num_smuxes;
Takashi Iwai4f2d23e2008-12-19 10:14:13 +01001178 err = snd_hda_ctl_add(codec,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001179 snd_ctl_new1(&stac_smux_mixer, codec));
1180 if (err < 0)
1181 return err;
1182 }
Mattc7d4b2f2005-06-27 14:59:41 +02001183
Mattdabbed62005-06-14 10:19:34 +02001184 if (spec->multiout.dig_out_nid) {
1185 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1186 if (err < 0)
1187 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001188 err = snd_hda_create_spdif_share_sw(codec,
1189 &spec->multiout);
1190 if (err < 0)
1191 return err;
1192 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001193 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001194 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001195 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1196 if (err < 0)
1197 return err;
1198 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001199
1200 /* if we have no master control, let's create it */
1201 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001202 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001203 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001204 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001205 /* correct volume offset */
1206 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001207 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001208 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001209 if (err < 0)
1210 return err;
1211 }
1212 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1213 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1214 NULL, slave_sws);
1215 if (err < 0)
1216 return err;
1217 }
1218
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001219 if (spec->aloopback_ctl &&
1220 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1221 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1222 if (err < 0)
1223 return err;
1224 }
1225
Takashi Iwai603c4012008-07-30 15:01:44 +02001226 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001227
1228 /* create jack input elements */
1229 if (spec->hp_detect) {
1230 for (i = 0; i < cfg->hp_outs; i++) {
1231 int type = SND_JACK_HEADPHONE;
1232 nid = cfg->hp_pins[i];
1233 /* jack detection */
1234 if (cfg->hp_outs == i)
1235 type |= SND_JACK_LINEOUT;
1236 err = stac92xx_add_jack(codec, nid, type);
1237 if (err < 0)
1238 return err;
1239 }
1240 }
1241 for (i = 0; i < cfg->line_outs; i++) {
1242 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1243 SND_JACK_LINEOUT);
1244 if (err < 0)
1245 return err;
1246 }
1247 for (i = 0; i < AUTO_PIN_LAST; i++) {
1248 nid = cfg->input_pins[i];
1249 if (nid) {
1250 err = stac92xx_add_jack(codec, nid,
1251 SND_JACK_MICROPHONE);
1252 if (err < 0)
1253 return err;
1254 }
1255 }
1256
Mattdabbed62005-06-14 10:19:34 +02001257 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001258}
1259
Matt Porter403d1942005-11-29 15:00:51 +01001260static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001261 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001262 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1263};
1264
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001265static unsigned int gateway9200_m4_pin_configs[8] = {
1266 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1267 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1268};
1269static unsigned int gateway9200_m4_2_pin_configs[8] = {
1270 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1271 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1272};
1273
1274/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001275 STAC 9200 pin configs for
1276 102801A8
1277 102801DE
1278 102801E8
1279*/
1280static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001281 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1282 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001283};
1284
1285/*
1286 STAC 9200 pin configs for
1287 102801C0
1288 102801C1
1289*/
1290static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001291 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1292 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001293};
1294
1295/*
1296 STAC 9200 pin configs for
1297 102801C4 (Dell Dimension E310)
1298 102801C5
1299 102801C7
1300 102801D9
1301 102801DA
1302 102801E3
1303*/
1304static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001305 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1306 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001307};
1308
1309
1310/*
1311 STAC 9200-32 pin configs for
1312 102801B5 (Dell Inspiron 630m)
1313 102801D8 (Dell Inspiron 640m)
1314*/
1315static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001316 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1317 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001318};
1319
1320/*
1321 STAC 9200-32 pin configs for
1322 102801C2 (Dell Latitude D620)
1323 102801C8
1324 102801CC (Dell Latitude D820)
1325 102801D4
1326 102801D6
1327*/
1328static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001329 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1330 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001331};
1332
1333/*
1334 STAC 9200-32 pin configs for
1335 102801CE (Dell XPS M1710)
1336 102801CF (Dell Precision M90)
1337*/
1338static unsigned int dell9200_m23_pin_configs[8] = {
1339 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1340 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1341};
1342
1343/*
1344 STAC 9200-32 pin configs for
1345 102801C9
1346 102801CA
1347 102801CB (Dell Latitude 120L)
1348 102801D3
1349*/
1350static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001351 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1352 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001353};
1354
1355/*
1356 STAC 9200-32 pin configs for
1357 102801BD (Dell Inspiron E1505n)
1358 102801EE
1359 102801EF
1360*/
1361static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001362 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1363 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364};
1365
1366/*
1367 STAC 9200-32 pin configs for
1368 102801F5 (Dell Inspiron 1501)
1369 102801F6
1370*/
1371static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001372 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1373 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001374};
1375
1376/*
1377 STAC 9200-32
1378 102801CD (Dell Inspiron E1705/9400)
1379*/
1380static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001381 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1382 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001383};
1384
Tobin Davisbf277782008-02-03 20:31:47 +01001385static unsigned int oqo9200_pin_configs[8] = {
1386 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1387 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1388};
1389
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001391static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1392 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001393 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001394 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1395 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1396 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1397 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1398 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1399 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1400 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1401 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1402 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1403 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001404 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1405 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001406 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001407};
1408
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001409static const char *stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001410 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001411 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001412 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001413 [STAC_9200_DELL_D21] = "dell-d21",
1414 [STAC_9200_DELL_D22] = "dell-d22",
1415 [STAC_9200_DELL_D23] = "dell-d23",
1416 [STAC_9200_DELL_M21] = "dell-m21",
1417 [STAC_9200_DELL_M22] = "dell-m22",
1418 [STAC_9200_DELL_M23] = "dell-m23",
1419 [STAC_9200_DELL_M24] = "dell-m24",
1420 [STAC_9200_DELL_M25] = "dell-m25",
1421 [STAC_9200_DELL_M26] = "dell-m26",
1422 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001423 [STAC_9200_M4] = "gateway-m4",
1424 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001425 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001426};
1427
1428static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1429 /* SigmaTel reference board */
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1431 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001432 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1433 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001434 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001435 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1436 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001437 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001438 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1439 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1440 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1441 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1442 "unknown Dell", STAC_9200_DELL_D22),
1443 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1444 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001445 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001446 "Dell Latitude D620", STAC_9200_DELL_M22),
1447 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1448 "unknown Dell", STAC_9200_DELL_D23),
1449 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1450 "unknown Dell", STAC_9200_DELL_D23),
1451 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1452 "unknown Dell", STAC_9200_DELL_M22),
1453 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1454 "unknown Dell", STAC_9200_DELL_M24),
1455 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1456 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001457 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001458 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001459 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001460 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001461 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001462 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001463 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001464 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001465 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001466 "Dell Precision M90", STAC_9200_DELL_M23),
1467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1468 "unknown Dell", STAC_9200_DELL_M22),
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1470 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001472 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001474 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1476 "unknown Dell", STAC_9200_DELL_D23),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1478 "unknown Dell", STAC_9200_DELL_D23),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1480 "unknown Dell", STAC_9200_DELL_D21),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1482 "unknown Dell", STAC_9200_DELL_D23),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1484 "unknown Dell", STAC_9200_DELL_D21),
1485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1486 "unknown Dell", STAC_9200_DELL_M25),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1488 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001490 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1492 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001493 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001494 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001495 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001496 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1497 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1498 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001499 /* OQO Mobile */
1500 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001501 {} /* terminator */
1502};
1503
Tobin Davis8e21c342007-01-08 11:04:17 +01001504static unsigned int ref925x_pin_configs[8] = {
1505 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001506 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001507};
1508
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001509static unsigned int stac925xM1_pin_configs[8] = {
1510 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1511 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001512};
1513
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001514static unsigned int stac925xM1_2_pin_configs[8] = {
1515 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1516 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1517};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001518
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001519static unsigned int stac925xM2_pin_configs[8] = {
1520 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1521 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001522};
1523
Tobin Davis8e21c342007-01-08 11:04:17 +01001524static unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001525 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1526 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1527};
1528
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001529static unsigned int stac925xM3_pin_configs[8] = {
1530 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1531 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1532};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001533
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001534static unsigned int stac925xM5_pin_configs[8] = {
1535 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1536 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1537};
1538
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001539static unsigned int stac925xM6_pin_configs[8] = {
1540 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1541 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001542};
1543
1544static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1545 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001546 [STAC_M1] = stac925xM1_pin_configs,
1547 [STAC_M1_2] = stac925xM1_2_pin_configs,
1548 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001549 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001550 [STAC_M3] = stac925xM3_pin_configs,
1551 [STAC_M5] = stac925xM5_pin_configs,
1552 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001553};
1554
1555static const char *stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001556 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001557 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001558 [STAC_M1] = "m1",
1559 [STAC_M1_2] = "m1-2",
1560 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001561 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001562 [STAC_M3] = "m3",
1563 [STAC_M5] = "m5",
1564 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001565};
1566
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001567static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001568 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1569 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1570 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1571 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001572 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001573 /* Not sure about the brand name for those */
1574 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1575 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1576 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1577 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001578 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001579};
1580
1581static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1582 /* SigmaTel reference board */
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001584 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001585 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001586
1587 /* Default table for unknown ID */
1588 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1589
Tobin Davis8e21c342007-01-08 11:04:17 +01001590 {} /* terminator */
1591};
1592
Matthew Ranostaya7662642008-02-21 07:51:14 +01001593static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001594 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1595 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1596 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001597 0x01452050,
1598};
1599
1600static unsigned int dell_m6_pin_configs[13] = {
1601 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001602 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001603 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1604 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001605};
1606
1607static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001608 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001609 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1610 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1611 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001612 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001613};
1614
1615static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001616 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001617 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001618 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001619 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001620 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1621 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1622 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001623 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001624};
1625
1626static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1627 /* SigmaTel reference board */
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001629 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001630 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1631 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001632 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1633 "Intel DG45ID", STAC_92HD73XX_INTEL),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1635 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001637 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001639 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001641 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001643 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001645 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001647 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001649 "unknown Dell", STAC_DELL_M6_DMIC),
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1651 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001652 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001653 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001654 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1655 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001656 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1657 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001658 {} /* terminator */
1659};
1660
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001661static unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001662 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1663 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001664 0x01451160, 0x98560170,
1665};
1666
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001667static unsigned int dell_s14_pin_configs[10] = {
1668 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1669 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1670 0x40f000f0, 0x40f000f0,
1671};
1672
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001673static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1674 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001675 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001676 [STAC_DELL_S14] = dell_s14_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001677};
1678
1679static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001680 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001681 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001682 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001683 [STAC_DELL_S14] = "dell-s14",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001684};
1685
1686static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1687 /* SigmaTel reference board */
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001689 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001690 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1691 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1693 "unknown Dell", STAC_DELL_S14),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001694 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001695};
1696
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001697static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001698 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001699 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001700 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1701 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001702};
1703
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001704static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001705 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001706 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001707 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1708 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001709};
1710
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001711static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001712 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1713 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001714 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1715 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001716};
1717
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001718static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001719 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1720 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001721 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1722 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001723};
1724
Matthew Ranostaye035b842007-11-06 11:53:55 +01001725static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1726 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001727 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1728 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001729 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001730 [STAC_HP_M4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001731 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001732 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001733 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001734};
1735
1736static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001737 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001738 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001739 [STAC_DELL_M4_1] = "dell-m4-1",
1740 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001741 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001742 [STAC_HP_M4] = "hp-m4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001743 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001744 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001745 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001746};
1747
1748static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1749 /* SigmaTel reference board */
1750 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1751 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001752 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1753 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001754 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1755 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Takashi Iwai58d83952009-03-13 17:04:34 +01001756 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1757 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001758 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1759 "HP dv4-7", STAC_HP_DV5),
1760 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1761 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001762 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1763 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001764 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001765 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001766 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001767 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai1972d022009-08-06 08:44:43 +02001768 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1769 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001770 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1771 "unknown Dell", STAC_DELL_M4_1),
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1773 "unknown Dell", STAC_DELL_M4_1),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1775 "unknown Dell", STAC_DELL_M4_1),
1776 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1777 "unknown Dell", STAC_DELL_M4_1),
1778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1779 "unknown Dell", STAC_DELL_M4_1),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1781 "unknown Dell", STAC_DELL_M4_1),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1783 "unknown Dell", STAC_DELL_M4_1),
1784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1785 "unknown Dell", STAC_DELL_M4_2),
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1787 "unknown Dell", STAC_DELL_M4_2),
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1789 "unknown Dell", STAC_DELL_M4_2),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1791 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1793 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001794 {} /* terminator */
1795};
1796
Matt Porter403d1942005-11-29 15:00:51 +01001797static unsigned int ref922x_pin_configs[10] = {
1798 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1799 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001800 0x40000100, 0x40000100,
1801};
1802
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001803/*
1804 STAC 922X pin configs for
1805 102801A7
1806 102801AB
1807 102801A9
1808 102801D1
1809 102801D2
1810*/
1811static unsigned int dell_922x_d81_pin_configs[10] = {
1812 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1813 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1814 0x01813122, 0x400001f2,
1815};
1816
1817/*
1818 STAC 922X pin configs for
1819 102801AC
1820 102801D0
1821*/
1822static unsigned int dell_922x_d82_pin_configs[10] = {
1823 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1824 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1825 0x01813122, 0x400001f1,
1826};
1827
1828/*
1829 STAC 922X pin configs for
1830 102801BF
1831*/
1832static unsigned int dell_922x_m81_pin_configs[10] = {
1833 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1834 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1835 0x40C003f1, 0x405003f0,
1836};
1837
1838/*
1839 STAC 9221 A1 pin configs for
1840 102801D7 (Dell XPS M1210)
1841*/
1842static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001843 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1844 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001845 0x508003f3, 0x405003f4,
1846};
1847
Matt Porter403d1942005-11-29 15:00:51 +01001848static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001849 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001850 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1851 0x02a19120, 0x40000100,
1852};
1853
1854static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001855 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1856 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001857 0x02a19320, 0x40000100,
1858};
1859
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001860static unsigned int intel_mac_v1_pin_configs[10] = {
1861 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1862 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001863 0x400000fc, 0x400000fb,
1864};
1865
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001866static unsigned int intel_mac_v2_pin_configs[10] = {
1867 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1868 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001869 0x400000fc, 0x400000fb,
1870};
1871
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001872static unsigned int intel_mac_v3_pin_configs[10] = {
1873 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1874 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1875 0x400000fc, 0x400000fb,
1876};
1877
1878static unsigned int intel_mac_v4_pin_configs[10] = {
1879 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1880 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1881 0x400000fc, 0x400000fb,
1882};
1883
1884static unsigned int intel_mac_v5_pin_configs[10] = {
1885 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1886 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1887 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001888};
1889
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001890static unsigned int ecs202_pin_configs[10] = {
1891 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1892 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1893 0x9037012e, 0x40e000f2,
1894};
Takashi Iwai76c08822007-06-19 12:17:42 +02001895
Takashi Iwai19039bd2006-06-28 15:52:16 +02001896static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001897 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001898 [STAC_D945GTP3] = d945gtp3_pin_configs,
1899 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001900 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1901 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1902 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1903 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1904 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001905 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001906 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001907 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1908 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1909 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1910 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1911 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1912 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001913 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001914 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1915 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1916 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1917 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001918};
1919
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001920static const char *stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001921 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001922 [STAC_D945_REF] = "ref",
1923 [STAC_D945GTP5] = "5stack",
1924 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001925 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1926 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1927 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1928 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1929 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001930 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001931 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001932 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001933 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001934 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1935 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001936 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001937 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001938 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001939 [STAC_922X_DELL_D81] = "dell-d81",
1940 [STAC_922X_DELL_D82] = "dell-d82",
1941 [STAC_922X_DELL_M81] = "dell-m81",
1942 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001943};
1944
1945static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1946 /* SigmaTel reference board */
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1948 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001949 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1950 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001951 /* Intel 945G based systems */
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1953 "Intel D945G", STAC_D945GTP3),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1955 "Intel D945G", STAC_D945GTP3),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1957 "Intel D945G", STAC_D945GTP3),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1959 "Intel D945G", STAC_D945GTP3),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1961 "Intel D945G", STAC_D945GTP3),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1963 "Intel D945G", STAC_D945GTP3),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1965 "Intel D945G", STAC_D945GTP3),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1967 "Intel D945G", STAC_D945GTP3),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1969 "Intel D945G", STAC_D945GTP3),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1971 "Intel D945G", STAC_D945GTP3),
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1973 "Intel D945G", STAC_D945GTP3),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1975 "Intel D945G", STAC_D945GTP3),
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1977 "Intel D945G", STAC_D945GTP3),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1979 "Intel D945G", STAC_D945GTP3),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1981 "Intel D945G", STAC_D945GTP3),
1982 /* Intel D945G 5-stack systems */
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1984 "Intel D945G", STAC_D945GTP5),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1986 "Intel D945G", STAC_D945GTP5),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1988 "Intel D945G", STAC_D945GTP5),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1990 "Intel D945G", STAC_D945GTP5),
1991 /* Intel 945P based systems */
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1993 "Intel D945P", STAC_D945GTP3),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1995 "Intel D945P", STAC_D945GTP3),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1997 "Intel D945P", STAC_D945GTP3),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1999 "Intel D945P", STAC_D945GTP3),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2001 "Intel D945P", STAC_D945GTP3),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2003 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002004 /* other intel */
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2006 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002007 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002008 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002009 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002010 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002011 /* Dell systems */
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2013 "unknown Dell", STAC_922X_DELL_D81),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2015 "unknown Dell", STAC_922X_DELL_D81),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2017 "unknown Dell", STAC_922X_DELL_D81),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2019 "unknown Dell", STAC_922X_DELL_D82),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2021 "unknown Dell", STAC_922X_DELL_M81),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2023 "unknown Dell", STAC_922X_DELL_D82),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2025 "unknown Dell", STAC_922X_DELL_D81),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2027 "unknown Dell", STAC_922X_DELL_D81),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2029 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002030 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002031 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002032 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002033 {} /* terminator */
2034};
2035
Matt Porter3cc08dc2006-01-23 15:27:49 +01002036static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002037 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2038 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2039 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2040 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002041};
2042
Tobin Davis93ed1502006-09-01 21:03:12 +02002043static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002044 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2045 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2046 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2047 0x40000100, 0x40000100
2048};
2049
Tobin Davis93ed1502006-09-01 21:03:12 +02002050static unsigned int d965_5st_pin_configs[14] = {
2051 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2052 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2053 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2054 0x40000100, 0x40000100
2055};
2056
Takashi Iwai679d92e2009-05-24 19:00:08 +02002057static unsigned int d965_5st_no_fp_pin_configs[14] = {
2058 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2059 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2060 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2061 0x40000100, 0x40000100
2062};
2063
Tobin Davis4ff076e2007-08-07 11:48:12 +02002064static unsigned int dell_3st_pin_configs[14] = {
2065 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2066 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002067 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002068 0x40c003fc, 0x40000100
2069};
2070
Tobin Davis93ed1502006-09-01 21:03:12 +02002071static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002072 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002073 [STAC_D965_REF] = ref927x_pin_configs,
2074 [STAC_D965_3ST] = d965_3st_pin_configs,
2075 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002076 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002077 [STAC_DELL_3ST] = dell_3st_pin_configs,
2078 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002079};
2080
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002081static const char *stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002082 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002083 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002084 [STAC_D965_REF] = "ref",
2085 [STAC_D965_3ST] = "3stack",
2086 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002087 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002088 [STAC_DELL_3ST] = "dell-3stack",
2089 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002090};
2091
2092static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2093 /* SigmaTel reference board */
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2095 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002096 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2097 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002098 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002101 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002102 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2103 "Intel D965", STAC_D965_3ST),
2104 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2105 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002106 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002109 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002111 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002115 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002120 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002121 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2122 "Intel D965", STAC_D965_5ST),
2123 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2124 "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002125 {} /* terminator */
2126};
2127
Matt Porterf3302a52006-07-31 12:49:34 +02002128static unsigned int ref9205_pin_configs[12] = {
2129 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002130 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002131 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002132};
2133
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002134/*
2135 STAC 9205 pin configs for
2136 102801F1
2137 102801F2
2138 102801FC
2139 102801FD
2140 10280204
2141 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002142 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002143*/
2144static unsigned int dell_9205_m42_pin_configs[12] = {
2145 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2146 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2147 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2148};
2149
2150/*
2151 STAC 9205 pin configs for
2152 102801F9
2153 102801FA
2154 102801FE
2155 102801FF (Dell Precision M4300)
2156 10280206
2157 10280200
2158 10280201
2159*/
2160static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002161 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2162 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2163 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2164};
2165
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002166static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002167 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2168 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2169 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2170};
2171
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002172static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002173 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002174 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2175 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2176 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002177 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002178};
2179
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002180static const char *stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002181 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002182 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002183 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002184 [STAC_9205_DELL_M43] = "dell-m43",
2185 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002186 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002187};
2188
2189static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2190 /* SigmaTel reference board */
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2192 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002193 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2194 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002195 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2196 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002197 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2199 "unknown Dell", STAC_9205_DELL_M42),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2201 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002203 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2205 "Dell Precision", STAC_9205_DELL_M43),
2206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2207 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2209 "unknown Dell", STAC_9205_DELL_M42),
2210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2211 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2213 "Dell Precision", STAC_9205_DELL_M43),
2214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002215 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2217 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2219 "Dell Precision", STAC_9205_DELL_M43),
2220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2221 "Dell Precision", STAC_9205_DELL_M43),
2222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2223 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002224 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2225 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2227 "Dell Vostro 1500", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002228 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002229 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002230 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002231 {} /* terminator */
2232};
2233
Takashi Iwai330ee992009-02-20 14:33:36 +01002234static void stac92xx_set_config_regs(struct hda_codec *codec,
2235 unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002236{
2237 int i;
2238 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002239
Takashi Iwai330ee992009-02-20 14:33:36 +01002240 if (!pincfgs)
2241 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002242
Matthew Ranostay87d48362007-07-17 11:52:24 +02002243 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002244 if (spec->pin_nids[i] && pincfgs[i])
2245 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2246 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002247}
2248
Matt2f2f4252005-04-13 14:45:30 +02002249/*
2250 * Analog playback callbacks
2251 */
2252static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2253 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002254 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002255{
2256 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002257 if (spec->stream_delay)
2258 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002259 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2260 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002261}
2262
2263static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2264 struct hda_codec *codec,
2265 unsigned int stream_tag,
2266 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002267 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002268{
2269 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002270 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002271}
2272
2273static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2274 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002275 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002276{
2277 struct sigmatel_spec *spec = codec->spec;
2278 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2279}
2280
2281/*
Mattdabbed62005-06-14 10:19:34 +02002282 * Digital playback callbacks
2283 */
2284static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2285 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002286 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002287{
2288 struct sigmatel_spec *spec = codec->spec;
2289 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2290}
2291
2292static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2293 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002294 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002295{
2296 struct sigmatel_spec *spec = codec->spec;
2297 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2298}
2299
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002300static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2301 struct hda_codec *codec,
2302 unsigned int stream_tag,
2303 unsigned int format,
2304 struct snd_pcm_substream *substream)
2305{
2306 struct sigmatel_spec *spec = codec->spec;
2307 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2308 stream_tag, format, substream);
2309}
2310
Takashi Iwai9411e212009-02-13 11:32:28 +01002311static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
2313 struct snd_pcm_substream *substream)
2314{
2315 struct sigmatel_spec *spec = codec->spec;
2316 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2317}
2318
Mattdabbed62005-06-14 10:19:34 +02002319
2320/*
Matt2f2f4252005-04-13 14:45:30 +02002321 * Analog capture callbacks
2322 */
2323static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2324 struct hda_codec *codec,
2325 unsigned int stream_tag,
2326 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002327 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002328{
2329 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002330 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002331
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002332 if (spec->powerdown_adcs) {
2333 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002334 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002335 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2336 }
2337 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002338 return 0;
2339}
2340
2341static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2342 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002343 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002344{
2345 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002346 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002347
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002348 snd_hda_codec_cleanup_stream(codec, nid);
2349 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002350 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002351 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002352 return 0;
2353}
2354
Mattdabbed62005-06-14 10:19:34 +02002355static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2356 .substreams = 1,
2357 .channels_min = 2,
2358 .channels_max = 2,
2359 /* NID is set in stac92xx_build_pcms */
2360 .ops = {
2361 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002362 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002363 .prepare = stac92xx_dig_playback_pcm_prepare,
2364 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002365 },
2366};
2367
2368static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2369 .substreams = 1,
2370 .channels_min = 2,
2371 .channels_max = 2,
2372 /* NID is set in stac92xx_build_pcms */
2373};
2374
Matt2f2f4252005-04-13 14:45:30 +02002375static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2376 .substreams = 1,
2377 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002378 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002379 .nid = 0x02, /* NID to query formats and rates */
2380 .ops = {
2381 .open = stac92xx_playback_pcm_open,
2382 .prepare = stac92xx_playback_pcm_prepare,
2383 .cleanup = stac92xx_playback_pcm_cleanup
2384 },
2385};
2386
Matt Porter3cc08dc2006-01-23 15:27:49 +01002387static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2388 .substreams = 1,
2389 .channels_min = 2,
2390 .channels_max = 2,
2391 .nid = 0x06, /* NID to query formats and rates */
2392 .ops = {
2393 .open = stac92xx_playback_pcm_open,
2394 .prepare = stac92xx_playback_pcm_prepare,
2395 .cleanup = stac92xx_playback_pcm_cleanup
2396 },
2397};
2398
Matt2f2f4252005-04-13 14:45:30 +02002399static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002400 .channels_min = 2,
2401 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002402 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002403 .ops = {
2404 .prepare = stac92xx_capture_pcm_prepare,
2405 .cleanup = stac92xx_capture_pcm_cleanup
2406 },
2407};
2408
2409static int stac92xx_build_pcms(struct hda_codec *codec)
2410{
2411 struct sigmatel_spec *spec = codec->spec;
2412 struct hda_pcm *info = spec->pcm_rec;
2413
2414 codec->num_pcms = 1;
2415 codec->pcm_info = info;
2416
Mattc7d4b2f2005-06-27 14:59:41 +02002417 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002418 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002419 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2420 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002421 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002422 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002423 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002424
2425 if (spec->alt_switch) {
2426 codec->num_pcms++;
2427 info++;
2428 info->name = "STAC92xx Analog Alt";
2429 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2430 }
Matt2f2f4252005-04-13 14:45:30 +02002431
Mattdabbed62005-06-14 10:19:34 +02002432 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2433 codec->num_pcms++;
2434 info++;
2435 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002436 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002437 if (spec->multiout.dig_out_nid) {
2438 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2439 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2440 }
2441 if (spec->dig_in_nid) {
2442 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2443 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2444 }
2445 }
2446
Matt2f2f4252005-04-13 14:45:30 +02002447 return 0;
2448}
2449
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002450static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2451 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002452{
Takashi Iwai1327a322009-03-23 13:07:47 +01002453 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002454 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2455 if (pincap & AC_PINCAP_VREF_100)
2456 return AC_PINCTL_VREF_100;
2457 if (pincap & AC_PINCAP_VREF_80)
2458 return AC_PINCTL_VREF_80;
2459 if (pincap & AC_PINCAP_VREF_50)
2460 return AC_PINCTL_VREF_50;
2461 if (pincap & AC_PINCAP_VREF_GRD)
2462 return AC_PINCTL_VREF_GRD;
2463 return 0;
2464}
2465
Matt Porter403d1942005-11-29 15:00:51 +01002466static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2467
2468{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002469 snd_hda_codec_write_cache(codec, nid, 0,
2470 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002471}
2472
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002473#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2474
2475static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2476 struct snd_ctl_elem_value *ucontrol)
2477{
2478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2479 struct sigmatel_spec *spec = codec->spec;
2480
Takashi Iwaid7a89432008-11-12 09:48:04 +01002481 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002482 return 0;
2483}
2484
Takashi Iwai62558ce2009-07-29 14:23:09 +02002485static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002486
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002487static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2488 struct snd_ctl_elem_value *ucontrol)
2489{
2490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2491 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002492 int nid = kcontrol->private_value;
2493
2494 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002495
2496 /* check to be sure that the ports are upto date with
2497 * switch changes
2498 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002499 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002500
2501 return 1;
2502}
2503
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002504static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2505 struct snd_ctl_elem_info *uinfo)
2506{
2507 int i;
2508 static char *texts[] = {
2509 "Mic In", "Line In", "Line Out"
2510 };
2511
2512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2513 struct sigmatel_spec *spec = codec->spec;
2514 hda_nid_t nid = kcontrol->private_value;
2515
2516 if (nid == spec->mic_switch || nid == spec->line_switch)
2517 i = 3;
2518 else
2519 i = 2;
2520
2521 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2522 uinfo->value.enumerated.items = i;
2523 uinfo->count = 1;
2524 if (uinfo->value.enumerated.item >= i)
2525 uinfo->value.enumerated.item = i-1;
2526 strcpy(uinfo->value.enumerated.name,
2527 texts[uinfo->value.enumerated.item]);
2528
2529 return 0;
2530}
2531
2532static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2533 struct snd_ctl_elem_value *ucontrol)
2534{
2535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2536 hda_nid_t nid = kcontrol->private_value;
2537 unsigned int vref = stac92xx_vref_get(codec, nid);
2538
2539 if (vref == stac92xx_get_default_vref(codec, nid))
2540 ucontrol->value.enumerated.item[0] = 0;
2541 else if (vref == AC_PINCTL_VREF_GRD)
2542 ucontrol->value.enumerated.item[0] = 1;
2543 else if (vref == AC_PINCTL_VREF_HIZ)
2544 ucontrol->value.enumerated.item[0] = 2;
2545
2546 return 0;
2547}
2548
2549static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2550 struct snd_ctl_elem_value *ucontrol)
2551{
2552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2553 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002554 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002555 hda_nid_t nid = kcontrol->private_value;
2556
2557 if (ucontrol->value.enumerated.item[0] == 0)
2558 new_vref = stac92xx_get_default_vref(codec, nid);
2559 else if (ucontrol->value.enumerated.item[0] == 1)
2560 new_vref = AC_PINCTL_VREF_GRD;
2561 else if (ucontrol->value.enumerated.item[0] == 2)
2562 new_vref = AC_PINCTL_VREF_HIZ;
2563 else
2564 return 0;
2565
2566 if (new_vref != stac92xx_vref_get(codec, nid)) {
2567 error = stac92xx_vref_set(codec, nid, new_vref);
2568 return error;
2569 }
2570
2571 return 0;
2572}
2573
2574static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2575 struct snd_ctl_elem_info *uinfo)
2576{
2577 static char *texts[2];
2578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2579 struct sigmatel_spec *spec = codec->spec;
2580
2581 if (kcontrol->private_value == spec->line_switch)
2582 texts[0] = "Line In";
2583 else
2584 texts[0] = "Mic In";
2585 texts[1] = "Line Out";
2586 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2587 uinfo->value.enumerated.items = 2;
2588 uinfo->count = 1;
2589
2590 if (uinfo->value.enumerated.item >= 2)
2591 uinfo->value.enumerated.item = 1;
2592 strcpy(uinfo->value.enumerated.name,
2593 texts[uinfo->value.enumerated.item]);
2594
2595 return 0;
2596}
Matt Porter403d1942005-11-29 15:00:51 +01002597
2598static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2599{
2600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2601 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002602 hda_nid_t nid = kcontrol->private_value;
2603 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002604
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002605 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002606 return 0;
2607}
2608
2609static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2610{
2611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2612 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002613 hda_nid_t nid = kcontrol->private_value;
2614 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2615 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002616
2617 spec->io_switch[io_idx] = val;
2618
2619 if (val)
2620 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002621 else {
2622 unsigned int pinctl = AC_PINCTL_IN_EN;
2623 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002624 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002625 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2626 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002627
2628 /* check the auto-mute again: we need to mute/unmute the speaker
2629 * appropriately according to the pin direction
2630 */
2631 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002632 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002633
Matt Porter403d1942005-11-29 15:00:51 +01002634 return 1;
2635}
2636
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002637#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2638
2639static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2640 struct snd_ctl_elem_value *ucontrol)
2641{
2642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2643 struct sigmatel_spec *spec = codec->spec;
2644
2645 ucontrol->value.integer.value[0] = spec->clfe_swap;
2646 return 0;
2647}
2648
2649static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2650 struct snd_ctl_elem_value *ucontrol)
2651{
2652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2653 struct sigmatel_spec *spec = codec->spec;
2654 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002655 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002656
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002657 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002658 return 0;
2659
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002660 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002661
2662 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2663 spec->clfe_swap ? 0x4 : 0x0);
2664
2665 return 1;
2666}
2667
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002668#define STAC_CODEC_HP_SWITCH(xname) \
2669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2670 .name = xname, \
2671 .index = 0, \
2672 .info = stac92xx_hp_switch_info, \
2673 .get = stac92xx_hp_switch_get, \
2674 .put = stac92xx_hp_switch_put, \
2675 }
2676
Matt Porter403d1942005-11-29 15:00:51 +01002677#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2678 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2679 .name = xname, \
2680 .index = 0, \
2681 .info = stac92xx_io_switch_info, \
2682 .get = stac92xx_io_switch_get, \
2683 .put = stac92xx_io_switch_put, \
2684 .private_value = xpval, \
2685 }
2686
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002687#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2688 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2689 .name = xname, \
2690 .index = 0, \
2691 .info = stac92xx_clfe_switch_info, \
2692 .get = stac92xx_clfe_switch_get, \
2693 .put = stac92xx_clfe_switch_put, \
2694 .private_value = xpval, \
2695 }
Matt Porter403d1942005-11-29 15:00:51 +01002696
Mattc7d4b2f2005-06-27 14:59:41 +02002697enum {
2698 STAC_CTL_WIDGET_VOL,
2699 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002700 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002701 STAC_CTL_WIDGET_AMP_MUX,
2702 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002703 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002704 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002705 STAC_CTL_WIDGET_CLFE_SWITCH,
2706 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002707};
2708
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002709static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002710 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2711 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002712 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002713 STAC_AMP_MUX,
2714 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002715 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002716 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002717 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002718 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002719};
2720
2721/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002722static struct snd_kcontrol_new *
2723stac_control_new(struct sigmatel_spec *spec,
2724 struct snd_kcontrol_new *ktemp,
2725 const char *name)
Mattc7d4b2f2005-06-27 14:59:41 +02002726{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002727 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002728
Takashi Iwai603c4012008-07-30 15:01:44 +02002729 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2730 knew = snd_array_new(&spec->kctls);
2731 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002732 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002733 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002734 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002735 if (!knew->name) {
2736 /* roolback */
2737 memset(knew, 0, sizeof(*knew));
2738 spec->kctls.alloced--;
2739 return NULL;
2740 }
2741 return knew;
2742}
2743
2744static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2745 struct snd_kcontrol_new *ktemp,
2746 int idx, const char *name,
2747 unsigned long val)
2748{
2749 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2750 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002751 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002752 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002753 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002754 return 0;
2755}
2756
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002757static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2758 int type, int idx, const char *name,
2759 unsigned long val)
2760{
2761 return stac92xx_add_control_temp(spec,
2762 &stac92xx_control_templates[type],
2763 idx, name, val);
2764}
2765
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002766
2767/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002768static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2769 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002770{
2771 return stac92xx_add_control_idx(spec, type, 0, name, val);
2772}
2773
Takashi Iwaie3c75962009-01-23 11:57:22 +01002774static struct snd_kcontrol_new stac_input_src_temp = {
2775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2776 .name = "Input Source",
2777 .info = stac92xx_mux_enum_info,
2778 .get = stac92xx_mux_enum_get,
2779 .put = stac92xx_mux_enum_put,
2780};
2781
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002782static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2783 hda_nid_t nid, int idx)
2784{
2785 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2786 int control = 0;
2787 struct sigmatel_spec *spec = codec->spec;
2788 char name[22];
2789
2790 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2791 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2792 && nid == spec->line_switch)
2793 control = STAC_CTL_WIDGET_IO_SWITCH;
2794 else if (snd_hda_query_pin_caps(codec, nid)
2795 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2796 control = STAC_CTL_WIDGET_DC_BIAS;
2797 else if (nid == spec->mic_switch)
2798 control = STAC_CTL_WIDGET_IO_SWITCH;
2799 }
2800
2801 if (control) {
2802 strcpy(name, auto_pin_cfg_labels[idx]);
2803 return stac92xx_add_control(codec->spec, control,
2804 strcat(name, " Jack Mode"), nid);
2805 }
2806
2807 return 0;
2808}
2809
Takashi Iwaie3c75962009-01-23 11:57:22 +01002810static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2811{
2812 struct snd_kcontrol_new *knew;
2813 struct hda_input_mux *imux = &spec->private_imux;
2814
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002815 if (spec->auto_mic)
2816 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002817 if (!spec->num_adcs || imux->num_items <= 1)
2818 return 0; /* no need for input source control */
2819 knew = stac_control_new(spec, &stac_input_src_temp,
2820 stac_input_src_temp.name);
2821 if (!knew)
2822 return -ENOMEM;
2823 knew->count = spec->num_adcs;
2824 return 0;
2825}
2826
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002827/* check whether the line-input can be used as line-out */
2828static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002829{
2830 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002831 struct auto_pin_cfg *cfg = &spec->autocfg;
2832 hda_nid_t nid;
2833 unsigned int pincap;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002834
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002835 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2836 return 0;
2837 nid = cfg->input_pins[AUTO_PIN_LINE];
Takashi Iwai1327a322009-03-23 13:07:47 +01002838 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002839 if (pincap & AC_PINCAP_OUT)
2840 return nid;
Matt Porter403d1942005-11-29 15:00:51 +01002841 return 0;
2842}
2843
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002844/* check whether the mic-input can be used as line-out */
2845static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2846{
2847 struct sigmatel_spec *spec = codec->spec;
2848 struct auto_pin_cfg *cfg = &spec->autocfg;
2849 unsigned int def_conf, pincap;
2850 unsigned int mic_pin;
2851
2852 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2853 return 0;
2854 mic_pin = AUTO_PIN_MIC;
2855 for (;;) {
2856 hda_nid_t nid = cfg->input_pins[mic_pin];
Takashi Iwai330ee992009-02-20 14:33:36 +01002857 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002858 /* some laptops have an internal analog microphone
2859 * which can't be used as a output */
2860 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai1327a322009-03-23 13:07:47 +01002861 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002862 if (pincap & AC_PINCAP_OUT)
2863 return nid;
2864 }
2865 if (mic_pin == AUTO_PIN_MIC)
2866 mic_pin = AUTO_PIN_FRONT_MIC;
2867 else
2868 break;
2869 }
2870 return 0;
2871}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002872
2873static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2874{
2875 int i;
2876
2877 for (i = 0; i < spec->multiout.num_dacs; i++) {
2878 if (spec->multiout.dac_nids[i] == nid)
2879 return 1;
2880 }
2881
2882 return 0;
2883}
2884
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002885static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2886{
2887 int i;
2888 if (is_in_dac_nids(spec, nid))
2889 return 1;
2890 for (i = 0; i < spec->autocfg.hp_outs; i++)
2891 if (spec->hp_dacs[i] == nid)
2892 return 1;
2893 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2894 if (spec->speaker_dacs[i] == nid)
2895 return 1;
2896 return 0;
2897}
2898
2899static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2900{
2901 struct sigmatel_spec *spec = codec->spec;
2902 int j, conn_len;
2903 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2904 unsigned int wcaps, wtype;
2905
2906 conn_len = snd_hda_get_connections(codec, nid, conn,
2907 HDA_MAX_CONNECTIONS);
2908 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002909 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002910 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002911 /* we check only analog outputs */
2912 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2913 continue;
2914 /* if this route has a free DAC, assign it */
2915 if (!check_all_dac_nids(spec, conn[j])) {
2916 if (conn_len > 1) {
2917 /* select this DAC in the pin's input mux */
2918 snd_hda_codec_write_cache(codec, nid, 0,
2919 AC_VERB_SET_CONNECT_SEL, j);
2920 }
2921 return conn[j];
2922 }
2923 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002924 /* if all DACs are already assigned, connect to the primary DAC */
2925 if (conn_len > 1) {
2926 for (j = 0; j < conn_len; j++) {
2927 if (conn[j] == spec->multiout.dac_nids[0]) {
2928 snd_hda_codec_write_cache(codec, nid, 0,
2929 AC_VERB_SET_CONNECT_SEL, j);
2930 break;
2931 }
2932 }
2933 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002934 return 0;
2935}
2936
2937static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2938static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2939
Matt Porter3cc08dc2006-01-23 15:27:49 +01002940/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002941 * Fill in the dac_nids table from the parsed pin configuration
2942 * This function only works when every pin in line_out_pins[]
2943 * contains atleast one DAC in its connection list. Some 92xx
2944 * codecs are not connected directly to a DAC, such as the 9200
2945 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002946 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002947static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02002948{
2949 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002950 struct auto_pin_cfg *cfg = &spec->autocfg;
2951 int i;
2952 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002953
Mattc7d4b2f2005-06-27 14:59:41 +02002954 for (i = 0; i < cfg->line_outs; i++) {
2955 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002956 dac = get_unassigned_dac(codec, nid);
2957 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002958 if (spec->multiout.num_dacs > 0) {
2959 /* we have already working output pins,
2960 * so let's drop the broken ones again
2961 */
2962 cfg->line_outs = spec->multiout.num_dacs;
2963 break;
2964 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002965 /* error out, no available DAC found */
2966 snd_printk(KERN_ERR
2967 "%s: No available DAC for pin 0x%x\n",
2968 __func__, nid);
2969 return -ENODEV;
2970 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002971 add_spec_dacs(spec, dac);
2972 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002973
Takashi Iwai139e0712009-03-06 12:10:41 +01002974 for (i = 0; i < cfg->hp_outs; i++) {
2975 nid = cfg->hp_pins[i];
2976 dac = get_unassigned_dac(codec, nid);
2977 if (dac) {
2978 if (!spec->multiout.hp_nid)
2979 spec->multiout.hp_nid = dac;
2980 else
2981 add_spec_extra_dacs(spec, dac);
2982 }
2983 spec->hp_dacs[i] = dac;
2984 }
2985
2986 for (i = 0; i < cfg->speaker_outs; i++) {
2987 nid = cfg->speaker_pins[i];
2988 dac = get_unassigned_dac(codec, nid);
2989 if (dac)
2990 add_spec_extra_dacs(spec, dac);
2991 spec->speaker_dacs[i] = dac;
2992 }
2993
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002994 /* add line-in as output */
2995 nid = check_line_out_switch(codec);
2996 if (nid) {
2997 dac = get_unassigned_dac(codec, nid);
2998 if (dac) {
2999 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3000 nid, cfg->line_outs);
3001 cfg->line_out_pins[cfg->line_outs] = nid;
3002 cfg->line_outs++;
3003 spec->line_switch = nid;
3004 add_spec_dacs(spec, dac);
3005 }
3006 }
3007 /* add mic as output */
3008 nid = check_mic_out_switch(codec);
3009 if (nid) {
3010 dac = get_unassigned_dac(codec, nid);
3011 if (dac) {
3012 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3013 nid, cfg->line_outs);
3014 cfg->line_out_pins[cfg->line_outs] = nid;
3015 cfg->line_outs++;
3016 spec->mic_switch = nid;
3017 add_spec_dacs(spec, dac);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003018 }
Mattc7d4b2f2005-06-27 14:59:41 +02003019 }
3020
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003021 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003022 spec->multiout.num_dacs,
3023 spec->multiout.dac_nids[0],
3024 spec->multiout.dac_nids[1],
3025 spec->multiout.dac_nids[2],
3026 spec->multiout.dac_nids[3],
3027 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003028
Mattc7d4b2f2005-06-27 14:59:41 +02003029 return 0;
3030}
3031
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003032/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003033static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3034 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003035{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003036 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003037 char name[32];
3038 int err;
3039
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003040 if (!spec->check_volume_offset) {
3041 unsigned int caps, step, nums, db_scale;
3042 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3043 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3044 AC_AMPCAP_STEP_SIZE_SHIFT;
3045 step = (step + 1) * 25; /* in .01dB unit */
3046 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3047 AC_AMPCAP_NUM_STEPS_SHIFT;
3048 db_scale = nums * step;
3049 /* if dB scale is over -64dB, and finer enough,
3050 * let's reduce it to half
3051 */
3052 if (db_scale > 6400 && nums >= 0x1f)
3053 spec->volume_offset = nums / 2;
3054 spec->check_volume_offset = 1;
3055 }
3056
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003057 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003058 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003059 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3060 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003061 if (err < 0)
3062 return err;
3063 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003064 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003065 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3066 if (err < 0)
3067 return err;
3068 return 0;
3069}
3070
Takashi Iwai668b9652009-03-06 10:13:24 +01003071#define create_controls(codec, pfx, nid, chs) \
3072 create_controls_idx(codec, pfx, 0, nid, chs)
3073
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003074static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3075{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003076 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003077 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3078 return 1;
3079 } else {
3080 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3081 spec->multiout.num_dacs++;
3082 }
3083 return 0;
3084}
3085
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003086static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003087{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003088 int i;
3089 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3090 if (!spec->multiout.extra_out_nid[i]) {
3091 spec->multiout.extra_out_nid[i] = nid;
3092 return 0;
3093 }
3094 }
3095 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3096 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003097}
3098
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003099/* Create output controls
3100 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3101 */
3102static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3103 const hda_nid_t *pins,
3104 const hda_nid_t *dac_nids,
3105 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003106{
Takashi Iwai76624532008-12-19 10:09:47 +01003107 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003108 static const char *chname[4] = {
3109 "Front", "Surround", NULL /*CLFE*/, "Side"
3110 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003111 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003112 int i, err;
3113 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003114
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003115 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003116 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3117 wid_caps = get_wcaps(codec, pins[i]);
3118 if (wid_caps & AC_WCAP_UNSOL_CAP)
3119 spec->hp_detect = 1;
3120 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003121 nid = dac_nids[i];
3122 if (!nid)
3123 continue;
3124 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003125 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003126 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003127 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003128 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003129 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003130 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003131 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003132
3133 wid_caps = get_wcaps(codec, nid);
3134
3135 if (wid_caps & AC_WCAP_LR_SWAP) {
3136 err = stac92xx_add_control(spec,
3137 STAC_CTL_WIDGET_CLFE_SWITCH,
3138 "Swap Center/LFE Playback Switch", nid);
3139
3140 if (err < 0)
3141 return err;
3142 }
3143
Mattc7d4b2f2005-06-27 14:59:41 +02003144 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003145 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003146 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003147 switch (type) {
3148 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003149 name = "Headphone";
3150 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003151 break;
3152 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003153 name = "Speaker";
3154 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003155 break;
3156 default:
3157 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003158 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003159 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003160 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003161 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003162 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003163 return err;
3164 }
3165 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003166 return 0;
3167}
3168
Takashi Iwai6479c632009-07-28 18:20:25 +02003169static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3170 unsigned long sw, int idx)
3171{
3172 int err;
3173 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003174 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003175 if (err < 0)
3176 return err;
3177 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003178 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003179 if (err < 0)
3180 return err;
3181 return 0;
3182}
3183
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003184/* add playback controls from the parsed DAC table */
3185static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3186 const struct auto_pin_cfg *cfg)
3187{
3188 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003189 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003190 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003191 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003192
3193 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3194 spec->multiout.dac_nids,
3195 cfg->line_out_type);
3196 if (err < 0)
3197 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003198
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003199 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003200 err = stac92xx_add_control(spec,
3201 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003202 "Headphone as Line Out Switch",
3203 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003204 if (err < 0)
3205 return err;
3206 }
3207
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003208 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3209 nid = cfg->input_pins[idx];
3210 if (nid) {
3211 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3212 if (err < 0)
3213 return err;
3214 }
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003215 }
Matt Porter403d1942005-11-29 15:00:51 +01003216
Mattc7d4b2f2005-06-27 14:59:41 +02003217 return 0;
3218}
3219
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003220/* add playback controls for Speaker and HP outputs */
3221static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3222 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003223{
3224 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003225 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003226
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003227 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3228 spec->hp_dacs, AUTO_PIN_HP_OUT);
3229 if (err < 0)
3230 return err;
3231
3232 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3233 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3234 if (err < 0)
3235 return err;
3236
Mattc7d4b2f2005-06-27 14:59:41 +02003237 return 0;
3238}
3239
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003240/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003241static const char *stac92xx_mono_labels[4] = {
3242 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003243};
3244
3245/* create mono mux for mono out on capable codecs */
3246static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3247{
3248 struct sigmatel_spec *spec = codec->spec;
3249 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3250 int i, num_cons;
3251 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3252
3253 num_cons = snd_hda_get_connections(codec,
3254 spec->mono_nid,
3255 con_lst,
3256 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003257 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003258 return -EINVAL;
3259
3260 for (i = 0; i < num_cons; i++) {
3261 mono_mux->items[mono_mux->num_items].label =
3262 stac92xx_mono_labels[i];
3263 mono_mux->items[mono_mux->num_items].index = i;
3264 mono_mux->num_items++;
3265 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003266
3267 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3268 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003269}
3270
Matthew Ranostay89385032008-09-11 09:49:39 -04003271/* labels for amp mux outputs */
3272static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003273 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003274};
3275
3276/* create amp out controls mux on capable codecs */
3277static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3278{
3279 struct sigmatel_spec *spec = codec->spec;
3280 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3281 int i, err;
3282
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003283 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003284 amp_mux->items[amp_mux->num_items].label =
3285 stac92xx_amp_labels[i];
3286 amp_mux->items[amp_mux->num_items].index = i;
3287 amp_mux->num_items++;
3288 }
3289
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003290 if (spec->num_amps > 1) {
3291 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3292 "Amp Selector Capture Switch", 0);
3293 if (err < 0)
3294 return err;
3295 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003296 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3297 "Amp Capture Volume",
3298 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3299}
3300
3301
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003302/* create PC beep volume controls */
3303static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3304 hda_nid_t nid)
3305{
3306 struct sigmatel_spec *spec = codec->spec;
3307 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3308 int err;
3309
3310 /* check for mute support for the the amp */
3311 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3312 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3313 "PC Beep Playback Switch",
3314 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3315 if (err < 0)
3316 return err;
3317 }
3318
3319 /* check to see if there is volume support for the amp */
3320 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3321 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3322 "PC Beep Playback Volume",
3323 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3324 if (err < 0)
3325 return err;
3326 }
3327 return 0;
3328}
3329
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003330#ifdef CONFIG_SND_HDA_INPUT_BEEP
3331#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3332
3333static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3334 struct snd_ctl_elem_value *ucontrol)
3335{
3336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3337 ucontrol->value.integer.value[0] = codec->beep->enabled;
3338 return 0;
3339}
3340
3341static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3342 struct snd_ctl_elem_value *ucontrol)
3343{
3344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3345 int enabled = !!ucontrol->value.integer.value[0];
3346 if (codec->beep->enabled != enabled) {
3347 codec->beep->enabled = enabled;
3348 return 1;
3349 }
3350 return 0;
3351}
3352
3353static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3355 .info = stac92xx_dig_beep_switch_info,
3356 .get = stac92xx_dig_beep_switch_get,
3357 .put = stac92xx_dig_beep_switch_put,
3358};
3359
3360static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3361{
3362 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3363 0, "PC Beep Playback Switch", 0);
3364}
3365#endif
3366
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003367static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3368{
3369 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003370 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003371
3372 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003373 hda_nid_t nid;
3374 unsigned int wcaps;
3375 unsigned long val;
3376
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003377 nid = spec->mux_nids[i];
3378 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003379 if (!(wcaps & AC_WCAP_OUT_AMP))
3380 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003381
Takashi Iwai667067d2009-08-13 18:14:42 +02003382 /* check whether already the same control was created as
3383 * normal Capture Volume.
3384 */
3385 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3386 for (j = 0; j < spec->num_caps; j++) {
3387 if (spec->capvols[j] == val)
3388 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003389 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003390 if (j < spec->num_caps)
3391 continue;
3392
3393 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3394 "Mux Capture Volume", val);
3395 if (err < 0)
3396 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003397 }
3398 return 0;
3399};
3400
Matthew Ranostayd9737752008-09-07 12:03:41 +02003401static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003402 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003403};
3404
3405static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3406{
3407 struct sigmatel_spec *spec = codec->spec;
3408 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003409 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003410 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003411 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003412
3413 num_cons = snd_hda_get_connections(codec,
3414 spec->smux_nids[0],
3415 con_lst,
3416 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003417 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003418 return -EINVAL;
3419
Matthew Ranostay65973632008-09-16 10:39:37 -04003420 if (!labels)
3421 labels = stac92xx_spdif_labels;
3422
Matthew Ranostayd9737752008-09-07 12:03:41 +02003423 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003424 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003425 spdif_mux->items[spdif_mux->num_items].index = i;
3426 spdif_mux->num_items++;
3427 }
3428
3429 return 0;
3430}
3431
Matt Porter8b657272006-10-26 17:12:59 +02003432/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003433static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003434 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3435 "Digital Mic 3", "Digital Mic 4"
3436};
3437
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003438static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3439 hda_nid_t nid)
3440{
3441 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3442 int i, nums;
3443
3444 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3445 for (i = 0; i < nums; i++)
3446 if (conn[i] == nid)
3447 return i;
3448 return -1;
3449}
3450
Takashi Iwai667067d2009-08-13 18:14:42 +02003451/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003452/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003453static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003454 const char *label, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003455{
3456 unsigned int caps, nums;
3457 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003458 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003459
Takashi Iwai96f845d2009-08-29 00:49:36 +02003460 if (direction == HDA_OUTPUT)
3461 caps = AC_WCAP_OUT_AMP;
3462 else
3463 caps = AC_WCAP_IN_AMP;
3464 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003465 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003466 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003467 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3468 if (!nums)
3469 return 0;
3470 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003471 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3472 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3473 if (err < 0)
3474 return err;
3475 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003476}
3477
Matt Porter8b657272006-10-26 17:12:59 +02003478/* create playback/capture controls for input pins on dmic capable codecs */
3479static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3480 const struct auto_pin_cfg *cfg)
3481{
3482 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003483 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003484 struct hda_input_mux *dimux = &spec->private_dimux;
Takashi Iwai5207e102009-07-30 13:09:08 +02003485 int err, i, active_mics;
3486 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003487
3488 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3489 dimux->items[dimux->num_items].index = 0;
3490 dimux->num_items++;
3491
Takashi Iwai5207e102009-07-30 13:09:08 +02003492 active_mics = 0;
3493 for (i = 0; i < spec->num_dmics; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003494 /* check the validity: sometimes it's a dead vendor-spec node */
3495 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3496 != AC_WID_PIN)
3497 continue;
Takashi Iwai5207e102009-07-30 13:09:08 +02003498 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3499 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3500 active_mics++;
3501 }
3502
Matt Porter8b657272006-10-26 17:12:59 +02003503 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003504 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003505 int index;
Takashi Iwai5207e102009-07-30 13:09:08 +02003506 const char *label;
Matt Porter8b657272006-10-26 17:12:59 +02003507
Takashi Iwai667067d2009-08-13 18:14:42 +02003508 nid = spec->dmic_nids[i];
3509 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3510 continue;
3511 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003512 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3513 continue;
3514
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003515 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3516 if (index < 0)
3517 continue;
3518
Takashi Iwai5207e102009-07-30 13:09:08 +02003519 if (active_mics == 1)
3520 label = "Digital Mic";
3521 else
3522 label = stac92xx_dmic_labels[dimux->num_items];
3523
Takashi Iwai96f845d2009-08-29 00:49:36 +02003524 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003525 if (err < 0)
3526 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003527 if (!err) {
3528 err = create_elem_capture_vol(codec, nid, label,
3529 HDA_OUTPUT);
3530 if (err < 0)
3531 return err;
3532 }
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003533
Takashi Iwai5207e102009-07-30 13:09:08 +02003534 dimux->items[dimux->num_items].label = label;
Matt Porter8b657272006-10-26 17:12:59 +02003535 dimux->items[dimux->num_items].index = index;
3536 dimux->num_items++;
Takashi Iwai5207e102009-07-30 13:09:08 +02003537 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3538 imux->items[imux->num_items].label = label;
3539 imux->items[imux->num_items].index = index;
3540 imux->num_items++;
3541 }
Matt Porter8b657272006-10-26 17:12:59 +02003542 }
3543
3544 return 0;
3545}
3546
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003547static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3548 hda_nid_t *fixed, hda_nid_t *ext)
3549{
3550 unsigned int cfg;
3551
3552 if (!nid)
3553 return 0;
3554 cfg = snd_hda_codec_get_pincfg(codec, nid);
3555 switch (get_defcfg_connect(cfg)) {
3556 case AC_JACK_PORT_FIXED:
3557 if (*fixed)
3558 return 1; /* already occupied */
3559 *fixed = nid;
3560 break;
3561 case AC_JACK_PORT_COMPLEX:
3562 if (*ext)
3563 return 1; /* already occupied */
3564 *ext = nid;
3565 break;
3566 }
3567 return 0;
3568}
3569
3570static int set_mic_route(struct hda_codec *codec,
3571 struct sigmatel_mic_route *mic,
3572 hda_nid_t pin)
3573{
3574 struct sigmatel_spec *spec = codec->spec;
3575 struct auto_pin_cfg *cfg = &spec->autocfg;
3576 int i;
3577
3578 mic->pin = pin;
3579 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3580 if (pin == cfg->input_pins[i])
3581 break;
3582 if (i <= AUTO_PIN_FRONT_MIC) {
3583 /* analog pin */
3584 mic->dmux_idx = 0;
3585 i = get_connection_index(codec, spec->mux_nids[0], pin);
3586 if (i < 0)
3587 return -1;
3588 mic->mux_idx = i;
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003589 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003590 /* digital pin */
3591 mic->mux_idx = 0;
3592 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3593 if (i < 0)
3594 return -1;
3595 mic->dmux_idx = i;
3596 }
3597 return 0;
3598}
3599
3600/* return non-zero if the device is for automatic mic switch */
3601static int stac_check_auto_mic(struct hda_codec *codec)
3602{
3603 struct sigmatel_spec *spec = codec->spec;
3604 struct auto_pin_cfg *cfg = &spec->autocfg;
3605 hda_nid_t fixed, ext;
3606 int i;
3607
3608 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3609 if (cfg->input_pins[i])
3610 return 0; /* must be exclusively mics */
3611 }
3612 fixed = ext = 0;
3613 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3614 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3615 return 0;
3616 for (i = 0; i < spec->num_dmics; i++)
3617 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3618 return 0;
3619 if (!fixed || !ext)
3620 return 0;
3621 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3622 return 0; /* no unsol support */
3623 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3624 set_mic_route(codec, &spec->int_mic, fixed))
3625 return 0; /* something is wrong */
3626 return 1;
3627}
3628
Mattc7d4b2f2005-06-27 14:59:41 +02003629/* create playback/capture controls for input pins */
3630static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3631{
3632 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003633 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003634 int i, j;
Mattc7d4b2f2005-06-27 14:59:41 +02003635
3636 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003637 hda_nid_t nid = cfg->input_pins[i];
3638 int index, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003639
Takashi Iwai667067d2009-08-13 18:14:42 +02003640 if (!nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003641 continue;
3642 index = -1;
3643 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003644 index = get_connection_index(codec, spec->mux_nids[j],
3645 nid);
3646 if (index >= 0)
3647 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003648 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003649 if (index < 0)
3650 continue;
3651
3652 err = create_elem_capture_vol(codec, nid,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003653 auto_pin_cfg_labels[i],
3654 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003655 if (err < 0)
3656 return err;
3657
Takashi Iwai314634b2006-09-21 11:56:18 +02003658 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3659 imux->items[imux->num_items].index = index;
3660 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003661 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003662 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003663
Steve Longerbeam7b043892007-05-03 20:50:03 +02003664 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003665 /*
3666 * Set the current input for the muxes.
3667 * The STAC9221 has two input muxes with identical source
3668 * NID lists. Hopefully this won't get confused.
3669 */
3670 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003671 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3672 AC_VERB_SET_CONNECT_SEL,
3673 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003674 }
3675 }
3676
Mattc7d4b2f2005-06-27 14:59:41 +02003677 return 0;
3678}
3679
Mattc7d4b2f2005-06-27 14:59:41 +02003680static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3681{
3682 struct sigmatel_spec *spec = codec->spec;
3683 int i;
3684
3685 for (i = 0; i < spec->autocfg.line_outs; i++) {
3686 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3687 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3688 }
3689}
3690
3691static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3692{
3693 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003694 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003695
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003696 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3697 hda_nid_t pin;
3698 pin = spec->autocfg.hp_pins[i];
3699 if (pin) /* connect to front */
3700 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3701 }
3702 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3703 hda_nid_t pin;
3704 pin = spec->autocfg.speaker_pins[i];
3705 if (pin) /* connect to front */
3706 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3707 }
Mattc7d4b2f2005-06-27 14:59:41 +02003708}
3709
Matt Porter3cc08dc2006-01-23 15:27:49 +01003710static 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 +02003711{
3712 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003713 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003714 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003715
Matt Porter8b657272006-10-26 17:12:59 +02003716 if ((err = snd_hda_parse_pin_def_config(codec,
3717 &spec->autocfg,
3718 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003719 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003720 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003721 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003722
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003723 /* If we have no real line-out pin and multiple hp-outs, HPs should
3724 * be set up as multi-channel outputs.
3725 */
3726 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3727 spec->autocfg.hp_outs > 1) {
3728 /* Copy hp_outs to line_outs, backup line_outs in
3729 * speaker_outs so that the following routines can handle
3730 * HP pins as primary outputs.
3731 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003732 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003733 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3734 sizeof(spec->autocfg.line_out_pins));
3735 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3736 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3737 sizeof(spec->autocfg.hp_pins));
3738 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003739 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3740 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003741 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003742 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003743 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003744 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3745 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003746 u32 caps = query_amp_caps(codec,
3747 spec->autocfg.mono_out_pin, dir);
3748 hda_nid_t conn_list[1];
3749
3750 /* get the mixer node and then the mono mux if it exists */
3751 if (snd_hda_get_connections(codec,
3752 spec->autocfg.mono_out_pin, conn_list, 1) &&
3753 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003754 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003755
3756 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003757 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003758 /* LR swap check, some stac925x have a mux that
3759 * changes the DACs output path instead of the
3760 * mono-mux path.
3761 */
3762 if (wid_type == AC_WID_AUD_SEL &&
3763 !(wcaps & AC_WCAP_LR_SWAP))
3764 spec->mono_nid = conn_list[0];
3765 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003766 if (dir) {
3767 hda_nid_t nid = spec->autocfg.mono_out_pin;
3768
3769 /* most mono outs have a least a mute/unmute switch */
3770 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3771 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3772 "Mono Playback Switch",
3773 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003774 if (err < 0)
3775 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003776 /* check for volume support for the amp */
3777 if ((caps & AC_AMPCAP_NUM_STEPS)
3778 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3779 err = stac92xx_add_control(spec,
3780 STAC_CTL_WIDGET_VOL,
3781 "Mono Playback Volume",
3782 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3783 if (err < 0)
3784 return err;
3785 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003786 }
3787
3788 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3789 AC_PINCTL_OUT_EN);
3790 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003791
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003792 if (!spec->multiout.num_dacs) {
3793 err = stac92xx_auto_fill_dac_nids(codec);
3794 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003795 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003796 err = stac92xx_auto_create_multi_out_ctls(codec,
3797 &spec->autocfg);
3798 if (err < 0)
3799 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003800 }
Mattc7d4b2f2005-06-27 14:59:41 +02003801
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003802 /* setup analog beep controls */
3803 if (spec->anabeep_nid > 0) {
3804 err = stac92xx_auto_create_beep_ctls(codec,
3805 spec->anabeep_nid);
3806 if (err < 0)
3807 return err;
3808 }
3809
3810 /* setup digital beep controls and input device */
3811#ifdef CONFIG_SND_HDA_INPUT_BEEP
3812 if (spec->digbeep_nid > 0) {
3813 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003814 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003815
3816 err = stac92xx_auto_create_beep_ctls(codec, nid);
3817 if (err < 0)
3818 return err;
3819 err = snd_hda_attach_beep_device(codec, nid);
3820 if (err < 0)
3821 return err;
Takashi Iwaifa797962009-05-19 12:50:04 +02003822 /* IDT/STAC codecs have linear beep tone parameter */
3823 codec->beep->linear_tone = 1;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003824 /* if no beep switch is available, make its own one */
3825 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3826 if (codec->beep &&
3827 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3828 err = stac92xx_beep_switch_ctl(codec);
3829 if (err < 0)
3830 return err;
3831 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003832 }
3833#endif
3834
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003835 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003836 if (err < 0)
3837 return err;
3838
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003839 /* All output parsing done, now restore the swapped hp pins */
3840 if (hp_swap) {
3841 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3842 sizeof(spec->autocfg.hp_pins));
3843 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3844 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3845 spec->autocfg.line_outs = 0;
3846 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003847
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003848 if (stac_check_auto_mic(codec)) {
3849 spec->auto_mic = 1;
3850 /* only one capture for auto-mic */
3851 spec->num_adcs = 1;
3852 spec->num_caps = 1;
3853 spec->num_muxes = 1;
3854 }
3855
Takashi Iwai6479c632009-07-28 18:20:25 +02003856 for (i = 0; i < spec->num_caps; i++) {
3857 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3858 spec->capsws[i], i);
3859 if (err < 0)
3860 return err;
3861 }
3862
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003863 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003864 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003865 return err;
3866
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003867 if (spec->mono_nid > 0) {
3868 err = stac92xx_auto_create_mono_output_ctls(codec);
3869 if (err < 0)
3870 return err;
3871 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003872 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003873 err = stac92xx_auto_create_amp_output_ctls(codec);
3874 if (err < 0)
3875 return err;
3876 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003877 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003878 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3879 &spec->autocfg)) < 0)
3880 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003881 if (spec->num_muxes > 0) {
3882 err = stac92xx_auto_create_mux_input_ctls(codec);
3883 if (err < 0)
3884 return err;
3885 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003886 if (spec->num_smuxes > 0) {
3887 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3888 if (err < 0)
3889 return err;
3890 }
Matt Porter8b657272006-10-26 17:12:59 +02003891
Takashi Iwaie3c75962009-01-23 11:57:22 +01003892 err = stac92xx_add_input_source(spec);
3893 if (err < 0)
3894 return err;
3895
Mattc7d4b2f2005-06-27 14:59:41 +02003896 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003897 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003898 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003899
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003900 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003901 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003902 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003903 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003904
Takashi Iwai603c4012008-07-30 15:01:44 +02003905 if (spec->kctls.list)
3906 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003907
3908 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003909 if (!spec->dinput_mux)
3910 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003911 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003912 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003913 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003914 return 1;
3915}
3916
Takashi Iwai82bc9552006-03-21 11:24:42 +01003917/* add playback controls for HP output */
3918static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3919 struct auto_pin_cfg *cfg)
3920{
3921 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003922 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003923 unsigned int wid_caps;
3924
3925 if (! pin)
3926 return 0;
3927
3928 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003929 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003930 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003931
3932 return 0;
3933}
3934
Richard Fish160ea0d2006-09-06 13:58:25 +02003935/* add playback controls for LFE output */
3936static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3937 struct auto_pin_cfg *cfg)
3938{
3939 struct sigmatel_spec *spec = codec->spec;
3940 int err;
3941 hda_nid_t lfe_pin = 0x0;
3942 int i;
3943
3944 /*
3945 * search speaker outs and line outs for a mono speaker pin
3946 * with an amp. If one is found, add LFE controls
3947 * for it.
3948 */
3949 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3950 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003951 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003952 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3953 if (wcaps == AC_WCAP_OUT_AMP)
3954 /* found a mono speaker with an amp, must be lfe */
3955 lfe_pin = pin;
3956 }
3957
3958 /* if speaker_outs is 0, then speakers may be in line_outs */
3959 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3960 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3961 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003962 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01003963 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01003964 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003965 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003966 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3967 if (wcaps == AC_WCAP_OUT_AMP)
3968 /* found a mono speaker with an amp,
3969 must be lfe */
3970 lfe_pin = pin;
3971 }
3972 }
3973 }
3974
3975 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003976 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003977 if (err < 0)
3978 return err;
3979 }
3980
3981 return 0;
3982}
3983
Mattc7d4b2f2005-06-27 14:59:41 +02003984static int stac9200_parse_auto_config(struct hda_codec *codec)
3985{
3986 struct sigmatel_spec *spec = codec->spec;
3987 int err;
3988
Kailang Yangdf694da2005-12-05 19:42:22 +01003989 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003990 return err;
3991
3992 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3993 return err;
3994
Takashi Iwai82bc9552006-03-21 11:24:42 +01003995 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3996 return err;
3997
Richard Fish160ea0d2006-09-06 13:58:25 +02003998 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3999 return err;
4000
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004001 if (spec->num_muxes > 0) {
4002 err = stac92xx_auto_create_mux_input_ctls(codec);
4003 if (err < 0)
4004 return err;
4005 }
4006
Takashi Iwaie3c75962009-01-23 11:57:22 +01004007 err = stac92xx_add_input_source(spec);
4008 if (err < 0)
4009 return err;
4010
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004011 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004012 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004013 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004014 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004015
Takashi Iwai603c4012008-07-30 15:01:44 +02004016 if (spec->kctls.list)
4017 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004018
4019 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004020 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004021
4022 return 1;
4023}
4024
Sam Revitch62fe78e2006-05-10 15:09:17 +02004025/*
4026 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4027 * funky external mute control using GPIO pins.
4028 */
4029
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004030static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004031 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004032{
4033 unsigned int gpiostate, gpiomask, gpiodir;
4034
4035 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4036 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004037 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004038
4039 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4040 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004041 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004042
4043 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4044 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004045 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004046
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004047 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004048 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4049
4050 snd_hda_codec_write(codec, codec->afg, 0,
4051 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004052 snd_hda_codec_read(codec, codec->afg, 0,
4053 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004054
4055 msleep(1);
4056
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004057 snd_hda_codec_read(codec, codec->afg, 0,
4058 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004059}
4060
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004061#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwai95c09092009-04-14 16:15:29 +02004062static void stac92xx_free_jack_priv(struct snd_jack *jack)
4063{
4064 struct sigmatel_jack *jacks = jack->private_data;
4065 jacks->nid = 0;
4066 jacks->jack = NULL;
4067}
4068#endif
4069
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004070static int stac92xx_add_jack(struct hda_codec *codec,
4071 hda_nid_t nid, int type)
4072{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004073#ifdef CONFIG_SND_HDA_INPUT_JACK
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004074 struct sigmatel_spec *spec = codec->spec;
4075 struct sigmatel_jack *jack;
Takashi Iwai330ee992009-02-20 14:33:36 +01004076 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004077 int connectivity = get_defcfg_connect(def_conf);
4078 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02004079 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004080
4081 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4082 return 0;
4083
4084 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4085 jack = snd_array_new(&spec->jacks);
4086 if (!jack)
4087 return -ENOMEM;
4088 jack->nid = nid;
4089 jack->type = type;
4090
Takashi Iwai86de7412009-07-22 16:02:46 +02004091 snprintf(name, sizeof(name), "%s at %s %s Jack",
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004092 snd_hda_get_jack_type(def_conf),
4093 snd_hda_get_jack_connectivity(def_conf),
4094 snd_hda_get_jack_location(def_conf));
4095
Takashi Iwai95c09092009-04-14 16:15:29 +02004096 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4097 if (err < 0) {
4098 jack->nid = 0;
4099 return err;
4100 }
4101 jack->jack->private_data = jack;
4102 jack->jack->private_free = stac92xx_free_jack_priv;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004103#endif
Takashi Iwai95c09092009-04-14 16:15:29 +02004104 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004105}
4106
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004107static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4108 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004109{
4110 struct sigmatel_event *event;
4111
4112 snd_array_init(&spec->events, sizeof(*event), 32);
4113 event = snd_array_new(&spec->events);
4114 if (!event)
4115 return -ENOMEM;
4116 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004117 event->type = type;
4118 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004119 event->data = data;
4120
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004121 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004122}
4123
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004124static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
Takashi Iwai62558ce2009-07-29 14:23:09 +02004125 hda_nid_t nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004126{
4127 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004128 struct sigmatel_event *event = spec->events.list;
4129 int i;
4130
4131 for (i = 0; i < spec->events.used; i++, event++) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004132 if (event->nid == nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004133 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004134 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004135 return NULL;
4136}
4137
4138static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4139 unsigned char tag)
4140{
4141 struct sigmatel_spec *spec = codec->spec;
4142 struct sigmatel_event *event = spec->events.list;
4143 int i;
4144
4145 for (i = 0; i < spec->events.used; i++, event++) {
4146 if (event->tag == tag)
4147 return event;
4148 }
4149 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004150}
4151
Takashi Iwai62558ce2009-07-29 14:23:09 +02004152/* check if given nid is a valid pin and no other events are assigned
4153 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4154 * Otherwise, returns zero.
4155 */
4156static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4157 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004158{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004159 struct sigmatel_event *event;
4160 int tag;
4161
4162 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004163 return 0;
4164 event = stac_get_event(codec, nid);
4165 if (event) {
4166 if (event->type != type)
4167 return 0;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004168 tag = event->tag;
Takashi Iwai62558ce2009-07-29 14:23:09 +02004169 } else {
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004170 tag = stac_add_event(codec->spec, nid, type, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004171 if (tag < 0)
4172 return 0;
4173 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004174 snd_hda_codec_write_cache(codec, nid, 0,
4175 AC_VERB_SET_UNSOLICITED_ENABLE,
4176 AC_USRSP_EN | tag);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004177 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004178}
4179
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004180static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4181{
4182 int i;
4183 for (i = 0; i < cfg->hp_outs; i++)
4184 if (cfg->hp_pins[i] == nid)
4185 return 1; /* nid is a HP-Out */
4186
4187 return 0; /* nid is not a HP-Out */
4188};
4189
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004190static void stac92xx_power_down(struct hda_codec *codec)
4191{
4192 struct sigmatel_spec *spec = codec->spec;
4193
4194 /* power down inactive DACs */
4195 hda_nid_t *dac;
4196 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004197 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004198 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004199 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4200}
4201
Takashi Iwaif73d3582008-11-25 08:21:51 +01004202static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4203 int enable);
4204
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004205/* override some hints from the hwdep entry */
4206static void stac_store_hints(struct hda_codec *codec)
4207{
4208 struct sigmatel_spec *spec = codec->spec;
4209 const char *p;
4210 int val;
4211
4212 val = snd_hda_get_bool_hint(codec, "hp_detect");
4213 if (val >= 0)
4214 spec->hp_detect = val;
4215 p = snd_hda_get_hint(codec, "gpio_mask");
4216 if (p) {
4217 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4218 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4219 spec->gpio_mask;
4220 }
4221 p = snd_hda_get_hint(codec, "gpio_dir");
4222 if (p)
4223 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4224 p = snd_hda_get_hint(codec, "gpio_data");
4225 if (p)
4226 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4227 p = snd_hda_get_hint(codec, "eapd_mask");
4228 if (p)
4229 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4230 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4231 if (val >= 0)
4232 spec->eapd_switch = val;
4233}
4234
Mattc7d4b2f2005-06-27 14:59:41 +02004235static int stac92xx_init(struct hda_codec *codec)
4236{
4237 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004238 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004239 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004240 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004241
Mattc7d4b2f2005-06-27 14:59:41 +02004242 snd_hda_sequence_write(codec, spec->init);
4243
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004244 /* power down adcs initially */
4245 if (spec->powerdown_adcs)
4246 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004247 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004248 spec->adc_nids[i], 0,
4249 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004250
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004251 /* override some hints */
4252 stac_store_hints(codec);
4253
Takashi Iwaif73d3582008-11-25 08:21:51 +01004254 /* set up GPIO */
4255 gpio = spec->gpio_data;
4256 /* turn on EAPD statically when spec->eapd_switch isn't set.
4257 * otherwise, unsol event will turn it on/off dynamically
4258 */
4259 if (!spec->eapd_switch)
4260 gpio |= spec->eapd_mask;
4261 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4262
Takashi Iwai82bc9552006-03-21 11:24:42 +01004263 /* set up pins */
4264 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004265 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004266 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004267 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004268 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004269 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004270 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4271 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004272 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004273 for (i = 0; i < cfg->line_outs; i++) {
4274 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004275 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4276 }
4277 }
4278
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004279 /* force to enable the first line-out; the others are set up
4280 * in unsol_event
4281 */
4282 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004283 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004284 /* fake event to set up pins */
Takashi Iwai62558ce2009-07-29 14:23:09 +02004285 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004286 } else {
4287 stac92xx_auto_init_multi_out(codec);
4288 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004289 for (i = 0; i < cfg->hp_outs; i++)
4290 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004291 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004292 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004293 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004294 if (spec->dmux_nids)
4295 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004296 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004297 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4298 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4299 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004300 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01004301 hda_nid_t nid = cfg->input_pins[i];
4302 if (nid) {
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004303 unsigned int pinctl, conf;
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004304 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4305 /* for mic pins, force to initialize */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004306 pinctl = stac92xx_get_default_vref(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004307 pinctl |= AC_PINCTL_IN_EN;
4308 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004309 } else {
4310 pinctl = snd_hda_codec_read(codec, nid, 0,
4311 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4312 /* if PINCTL already set then skip */
Takashi Iwai5dd17cb2009-05-07 16:22:53 +02004313 /* Also, if both INPUT and OUTPUT are set,
4314 * it must be a BIOS bug; need to override, too
4315 */
4316 if (!(pinctl & AC_PINCTL_IN_EN) ||
4317 (pinctl & AC_PINCTL_OUT_EN)) {
4318 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004319 pinctl |= AC_PINCTL_IN_EN;
4320 stac92xx_auto_set_pinctl(codec, nid,
4321 pinctl);
4322 }
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004323 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004324 conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004325 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004326 if (enable_pin_detect(codec, nid,
4327 STAC_INSERT_EVENT))
4328 stac_issue_unsol_event(codec, nid);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004329 }
Takashi Iwaic960a032006-03-23 17:06:28 +01004330 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004331 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004332 for (i = 0; i < spec->num_dmics; i++)
4333 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4334 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004335 if (cfg->dig_out_pins[0])
4336 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004337 AC_PINCTL_OUT_EN);
4338 if (cfg->dig_in_pin)
4339 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4340 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004341 for (i = 0; i < spec->num_pwrs; i++) {
4342 hda_nid_t nid = spec->pwr_nids[i];
4343 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004344
Takashi Iwaieb632122008-12-19 16:39:48 +01004345 /* power on when no jack detection is available */
4346 if (!spec->hp_detect) {
4347 stac_toggle_power_map(codec, nid, 1);
4348 continue;
4349 }
4350
4351 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004352 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004353
Takashi Iwaif73d3582008-11-25 08:21:51 +01004354 pinctl = snd_hda_codec_read(codec, nid, 0,
4355 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4356 /* outputs are only ports capable of power management
4357 * any attempts on powering down a input port cause the
4358 * referenced VREF to act quirky.
4359 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004360 if (pinctl & AC_PINCTL_IN_EN) {
4361 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004362 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004363 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004364 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004365 def_conf = get_defcfg_connect(def_conf);
4366 /* skip any ports that don't have jacks since presence
4367 * detection is useless */
4368 if (def_conf != AC_JACK_PORT_COMPLEX) {
4369 if (def_conf != AC_JACK_PORT_NONE)
4370 stac_toggle_power_map(codec, nid, 1);
4371 continue;
4372 }
Takashi Iwai62558ce2009-07-29 14:23:09 +02004373 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4374 stac_issue_unsol_event(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004375 }
4376 if (spec->dac_list)
4377 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004378 return 0;
4379}
4380
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004381static void stac92xx_free_jacks(struct hda_codec *codec)
4382{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004383#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwaib94d35392008-11-21 09:08:06 +01004384 /* free jack instances manually when clearing/reconfiguring */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004385 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaib94d35392008-11-21 09:08:06 +01004386 if (!codec->bus->shutdown && spec->jacks.list) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004387 struct sigmatel_jack *jacks = spec->jacks.list;
4388 int i;
Takashi Iwai95c09092009-04-14 16:15:29 +02004389 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4390 if (jacks->jack)
4391 snd_device_free(codec->bus->card, jacks->jack);
4392 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004393 }
4394 snd_array_free(&spec->jacks);
Takashi Iwaie4973e12008-11-18 09:32:42 +01004395#endif
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004396}
4397
Takashi Iwai603c4012008-07-30 15:01:44 +02004398static void stac92xx_free_kctls(struct hda_codec *codec)
4399{
4400 struct sigmatel_spec *spec = codec->spec;
4401
4402 if (spec->kctls.list) {
4403 struct snd_kcontrol_new *kctl = spec->kctls.list;
4404 int i;
4405 for (i = 0; i < spec->kctls.used; i++)
4406 kfree(kctl[i].name);
4407 }
4408 snd_array_free(&spec->kctls);
4409}
4410
Matt2f2f4252005-04-13 14:45:30 +02004411static void stac92xx_free(struct hda_codec *codec)
4412{
Mattc7d4b2f2005-06-27 14:59:41 +02004413 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004414
4415 if (! spec)
4416 return;
4417
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004418 stac92xx_free_jacks(codec);
4419 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004420
Mattc7d4b2f2005-06-27 14:59:41 +02004421 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004422 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004423}
4424
Matt4e550962005-07-04 17:51:39 +02004425static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4426 unsigned int flag)
4427{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004428 unsigned int old_ctl, pin_ctl;
4429
4430 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004431 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004432
Takashi Iwaif9acba42007-05-29 18:01:06 +02004433 if (pin_ctl & AC_PINCTL_IN_EN) {
4434 /*
4435 * we need to check the current set-up direction of
4436 * shared input pins since they can be switched via
4437 * "xxx as Output" mixer switch
4438 */
4439 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004440 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004441 return;
4442 }
4443
Takashi Iwai8ce84192009-01-22 16:59:20 +01004444 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004445 /* if setting pin direction bits, clear the current
4446 direction bits first */
4447 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4448 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4449
Takashi Iwai8ce84192009-01-22 16:59:20 +01004450 pin_ctl |= flag;
4451 if (old_ctl != pin_ctl)
4452 snd_hda_codec_write_cache(codec, nid, 0,
4453 AC_VERB_SET_PIN_WIDGET_CONTROL,
4454 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004455}
4456
4457static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4458 unsigned int flag)
4459{
4460 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4461 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004462 if (pin_ctl & flag)
4463 snd_hda_codec_write_cache(codec, nid, 0,
4464 AC_VERB_SET_PIN_WIDGET_CONTROL,
4465 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004466}
4467
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004468static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004469{
4470 if (!nid)
4471 return 0;
4472 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004473 & (1 << 31))
4474 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004475 return 0;
4476}
4477
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004478static void stac92xx_line_out_detect(struct hda_codec *codec,
4479 int presence)
4480{
4481 struct sigmatel_spec *spec = codec->spec;
4482 struct auto_pin_cfg *cfg = &spec->autocfg;
4483 int i;
4484
4485 for (i = 0; i < cfg->line_outs; i++) {
4486 if (presence)
4487 break;
4488 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4489 if (presence) {
4490 unsigned int pinctl;
4491 pinctl = snd_hda_codec_read(codec,
4492 cfg->line_out_pins[i], 0,
4493 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4494 if (pinctl & AC_PINCTL_IN_EN)
4495 presence = 0; /* mic- or line-input */
4496 }
4497 }
4498
4499 if (presence) {
4500 /* disable speakers */
4501 for (i = 0; i < cfg->speaker_outs; i++)
4502 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4503 AC_PINCTL_OUT_EN);
4504 if (spec->eapd_mask && spec->eapd_switch)
4505 stac_gpio_set(codec, spec->gpio_mask,
4506 spec->gpio_dir, spec->gpio_data &
4507 ~spec->eapd_mask);
4508 } else {
4509 /* enable speakers */
4510 for (i = 0; i < cfg->speaker_outs; i++)
4511 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4512 AC_PINCTL_OUT_EN);
4513 if (spec->eapd_mask && spec->eapd_switch)
4514 stac_gpio_set(codec, spec->gpio_mask,
4515 spec->gpio_dir, spec->gpio_data |
4516 spec->eapd_mask);
4517 }
4518}
4519
Takashi Iwaid7a89432008-11-12 09:48:04 +01004520/* return non-zero if the hp-pin of the given array index isn't
4521 * a jack-detection target
4522 */
4523static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4524{
4525 struct auto_pin_cfg *cfg = &spec->autocfg;
4526
4527 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004528 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004529 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004530 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004531 return 1;
4532 /* ignore if the pin is set as line-out */
4533 if (cfg->hp_pins[i] == spec->hp_switch)
4534 return 1;
4535 return 0;
4536}
4537
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004538static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004539{
4540 struct sigmatel_spec *spec = codec->spec;
4541 struct auto_pin_cfg *cfg = &spec->autocfg;
4542 int i, presence;
4543
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004544 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004545 if (spec->gpio_mute)
4546 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4547 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4548
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004549 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004550 if (presence)
4551 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004552 if (no_hp_sensing(spec, i))
4553 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004554 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4555 if (presence) {
4556 unsigned int pinctl;
4557 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4558 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4559 if (pinctl & AC_PINCTL_IN_EN)
4560 presence = 0; /* mic- or line-input */
4561 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004562 }
Matt4e550962005-07-04 17:51:39 +02004563
4564 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004565 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004566 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004567 stac92xx_reset_pinctl(codec, spec->hp_switch,
4568 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004569 for (i = 0; i < cfg->line_outs; i++)
4570 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4571 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004572 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004573 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004574 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004575 stac92xx_set_pinctl(codec, spec->hp_switch,
4576 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004577 for (i = 0; i < cfg->line_outs; i++)
4578 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4579 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004580 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004581 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004582 /* toggle hp outs */
4583 for (i = 0; i < cfg->hp_outs; i++) {
4584 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4585 if (no_hp_sensing(spec, i))
4586 continue;
4587 if (presence)
4588 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004589#if 0 /* FIXME */
4590/* Resetting the pinctl like below may lead to (a sort of) regressions
4591 * on some devices since they use the HP pin actually for line/speaker
4592 * outs although the default pin config shows a different pin (that is
4593 * wrong and useless).
4594 *
4595 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4596 * But, disabling the code below just works around it, and I'm too tired of
4597 * bug reports with such devices...
4598 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004599 else
4600 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004601#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004602 }
Matt4e550962005-07-04 17:51:39 +02004603}
4604
Takashi Iwaif73d3582008-11-25 08:21:51 +01004605static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4606 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004607{
4608 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004609 unsigned int idx, val;
4610
4611 for (idx = 0; idx < spec->num_pwrs; idx++) {
4612 if (spec->pwr_nids[idx] == nid)
4613 break;
4614 }
4615 if (idx >= spec->num_pwrs)
4616 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004617
4618 /* several codecs have two power down bits */
4619 if (spec->pwr_mapping)
4620 idx = spec->pwr_mapping[idx];
4621 else
4622 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004623
Takashi Iwaif73d3582008-11-25 08:21:51 +01004624 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4625 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004626 val &= ~idx;
4627 else
4628 val |= idx;
4629
4630 /* power down unused output ports */
4631 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004632}
4633
Takashi Iwaif73d3582008-11-25 08:21:51 +01004634static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4635{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004636 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004637}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004638
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004639static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4640{
4641 struct sigmatel_spec *spec = codec->spec;
4642 struct sigmatel_jack *jacks = spec->jacks.list;
4643
4644 if (jacks) {
4645 int i;
4646 for (i = 0; i < spec->jacks.used; i++) {
4647 if (jacks->nid == nid) {
4648 unsigned int pin_ctl =
4649 snd_hda_codec_read(codec, nid,
4650 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4651 0x00);
4652 int type = jacks->type;
4653 if (type == (SND_JACK_LINEOUT
4654 | SND_JACK_HEADPHONE))
4655 type = (pin_ctl & AC_PINCTL_HP_EN)
4656 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4657 snd_jack_report(jacks->jack,
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004658 get_pin_presence(codec, nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004659 ? type : 0);
4660 }
4661 jacks++;
4662 }
4663 }
4664}
Matt2f2f4252005-04-13 14:45:30 +02004665
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004666static void stac92xx_mic_detect(struct hda_codec *codec)
4667{
4668 struct sigmatel_spec *spec = codec->spec;
4669 struct sigmatel_mic_route *mic;
4670
4671 if (get_pin_presence(codec, spec->ext_mic.pin))
4672 mic = &spec->ext_mic;
4673 else
4674 mic = &spec->int_mic;
4675 if (mic->dmux_idx)
4676 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4677 AC_VERB_SET_CONNECT_SEL,
4678 mic->dmux_idx);
4679 else
4680 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4681 AC_VERB_SET_CONNECT_SEL,
4682 mic->mux_idx);
4683}
4684
Takashi Iwai62558ce2009-07-29 14:23:09 +02004685static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004686{
Takashi Iwai62558ce2009-07-29 14:23:09 +02004687 struct sigmatel_event *event = stac_get_event(codec, nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004688 if (!event)
4689 return;
4690 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4691}
4692
Takashi Iwai314634b2006-09-21 11:56:18 +02004693static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4694{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004695 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004696 struct sigmatel_event *event;
4697 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004698
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004699 tag = (res >> 26) & 0x7f;
4700 event = stac_get_event_from_tag(codec, tag);
4701 if (!event)
4702 return;
4703
4704 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004705 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004706 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004707 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004708 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004709 case STAC_MIC_EVENT:
4710 stac92xx_mic_detect(codec);
4711 break;
4712 }
4713
4714 switch (event->type) {
4715 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004716 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004717 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004718 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004719 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004720 if (spec->num_pwrs > 0)
4721 stac92xx_pin_sense(codec, event->nid);
4722 stac92xx_report_jack(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004723
4724 switch (codec->subsystem_id) {
4725 case 0x103c308f:
4726 if (event->nid == 0xb) {
4727 int pin = AC_PINCTL_IN_EN;
4728
4729 if (get_pin_presence(codec, 0xa)
4730 && get_pin_presence(codec, 0xb))
4731 pin |= AC_PINCTL_VREF_80;
4732 if (!get_pin_presence(codec, 0xb))
4733 pin |= AC_PINCTL_VREF_80;
4734
4735 /* toggle VREF state based on mic + hp pin
4736 * status
4737 */
4738 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4739 }
4740 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004741 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004742 case STAC_VREF_EVENT:
4743 data = snd_hda_codec_read(codec, codec->afg, 0,
4744 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004745 /* toggle VREF state based on GPIOx status */
4746 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004747 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004748 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004749 }
4750}
4751
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004752#ifdef CONFIG_PROC_FS
4753static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4754 struct hda_codec *codec, hda_nid_t nid)
4755{
4756 if (nid == codec->afg)
4757 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4758 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4759}
4760
4761static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4762 struct hda_codec *codec,
4763 unsigned int verb)
4764{
4765 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4766 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4767}
4768
4769/* stac92hd71bxx, stac92hd73xx */
4770static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4771 struct hda_codec *codec, hda_nid_t nid)
4772{
4773 stac92hd_proc_hook(buffer, codec, nid);
4774 if (nid == codec->afg)
4775 analog_loop_proc_hook(buffer, codec, 0xfa0);
4776}
4777
4778static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4779 struct hda_codec *codec, hda_nid_t nid)
4780{
4781 if (nid == codec->afg)
4782 analog_loop_proc_hook(buffer, codec, 0xfe0);
4783}
4784
4785static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4786 struct hda_codec *codec, hda_nid_t nid)
4787{
4788 if (nid == codec->afg)
4789 analog_loop_proc_hook(buffer, codec, 0xfeb);
4790}
4791#else
4792#define stac92hd_proc_hook NULL
4793#define stac92hd7x_proc_hook NULL
4794#define stac9205_proc_hook NULL
4795#define stac927x_proc_hook NULL
4796#endif
4797
Takashi Iwaicb53c622007-08-10 17:21:45 +02004798#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004799static int stac92xx_resume(struct hda_codec *codec)
4800{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004801 struct sigmatel_spec *spec = codec->spec;
4802
Takashi Iwai2c885872008-11-18 09:36:55 +01004803 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004804 snd_hda_codec_resume_amp(codec);
4805 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004806 /* fake event to set up pins again to override cached values */
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004807 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02004808 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
Mattff6fdc32005-06-27 15:06:52 +02004809 return 0;
4810}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004811
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004812/*
James Gardiner514bf542009-05-03 04:00:44 -04004813 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004814 * check for mute state only on Speakers (nid = 0x10)
4815 *
4816 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4817 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004818 *
4819 * Changed name to reflect that it now works for any designated
4820 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004821 */
4822
4823#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004824static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004825 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004826{
4827 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004828
4829 if (nid == 0x10) {
4830 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004831 HDA_AMP_MUTE)
Takashi Iwai86d190e2009-05-26 15:18:58 +02004832 spec->gpio_data &= ~spec->gpio_led; /* orange */
Takashi Iwaiba84bfc2009-05-30 08:59:03 +02004833 else
4834 spec->gpio_data |= spec->gpio_led; /* white */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004835
4836 stac_gpio_set(codec, spec->gpio_mask,
4837 spec->gpio_dir,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004838 spec->gpio_data);
4839 }
4840
4841 return 0;
4842}
4843#endif
4844
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004845static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4846{
4847 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai05ff7e12009-07-22 12:39:24 +02004848 int i;
4849 hda_nid_t nid;
4850
4851 /* reset each pin before powering down DAC/ADC to avoid click noise */
4852 nid = codec->start_nid;
4853 for (i = 0; i < codec->num_nodes; i++, nid++) {
4854 unsigned int wcaps = get_wcaps(codec, nid);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004855 unsigned int wid_type = get_wcaps_type(wcaps);
Takashi Iwai05ff7e12009-07-22 12:39:24 +02004856 if (wid_type == AC_WID_PIN)
4857 snd_hda_codec_read(codec, nid, 0,
4858 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4859 }
4860
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004861 if (spec->eapd_mask)
4862 stac_gpio_set(codec, spec->gpio_mask,
4863 spec->gpio_dir, spec->gpio_data &
4864 ~spec->eapd_mask);
4865 return 0;
4866}
Mattff6fdc32005-06-27 15:06:52 +02004867#endif
4868
Matt2f2f4252005-04-13 14:45:30 +02004869static struct hda_codec_ops stac92xx_patch_ops = {
4870 .build_controls = stac92xx_build_controls,
4871 .build_pcms = stac92xx_build_pcms,
4872 .init = stac92xx_init,
4873 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004874 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004875#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004876 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02004877 .resume = stac92xx_resume,
4878#endif
Matt2f2f4252005-04-13 14:45:30 +02004879};
4880
4881static int patch_stac9200(struct hda_codec *codec)
4882{
4883 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004884 int err;
Matt2f2f4252005-04-13 14:45:30 +02004885
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004886 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004887 if (spec == NULL)
4888 return -ENOMEM;
4889
4890 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004891 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004892 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004893 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4894 stac9200_models,
4895 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01004896 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004897 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4898 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004899 else
4900 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004901 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02004902
4903 spec->multiout.max_channels = 2;
4904 spec->multiout.num_dacs = 1;
4905 spec->multiout.dac_nids = stac9200_dac_nids;
4906 spec->adc_nids = stac9200_adc_nids;
4907 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004908 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004909 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004910 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004911 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004912
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02004913 if (spec->board_config == STAC_9200_M4 ||
4914 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01004915 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004916 spec->init = stac9200_eapd_init;
4917 else
4918 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004919 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004920
Takashi Iwai117f2572008-03-18 09:53:23 +01004921 if (spec->board_config == STAC_9200_PANASONIC) {
4922 spec->gpio_mask = spec->gpio_dir = 0x09;
4923 spec->gpio_data = 0x00;
4924 }
4925
Mattc7d4b2f2005-06-27 14:59:41 +02004926 err = stac9200_parse_auto_config(codec);
4927 if (err < 0) {
4928 stac92xx_free(codec);
4929 return err;
4930 }
Matt2f2f4252005-04-13 14:45:30 +02004931
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01004932 /* CF-74 has no headphone detection, and the driver should *NOT*
4933 * do detection and HP/speaker toggle because the hardware does it.
4934 */
4935 if (spec->board_config == STAC_9200_PANASONIC)
4936 spec->hp_detect = 0;
4937
Matt2f2f4252005-04-13 14:45:30 +02004938 codec->patch_ops = stac92xx_patch_ops;
4939
4940 return 0;
4941}
4942
Tobin Davis8e21c342007-01-08 11:04:17 +01004943static int patch_stac925x(struct hda_codec *codec)
4944{
4945 struct sigmatel_spec *spec;
4946 int err;
4947
4948 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4949 if (spec == NULL)
4950 return -ENOMEM;
4951
4952 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004953 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004954 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02004955
4956 /* Check first for codec ID */
4957 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4958 STAC_925x_MODELS,
4959 stac925x_models,
4960 stac925x_codec_id_cfg_tbl);
4961
4962 /* Now checks for PCI ID, if codec ID is not found */
4963 if (spec->board_config < 0)
4964 spec->board_config = snd_hda_check_board_config(codec,
4965 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01004966 stac925x_models,
4967 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004968 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01004969 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004970 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4971 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01004972 else
4973 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01004974 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01004975
4976 spec->multiout.max_channels = 2;
4977 spec->multiout.num_dacs = 1;
4978 spec->multiout.dac_nids = stac925x_dac_nids;
4979 spec->adc_nids = stac925x_adc_nids;
4980 spec->mux_nids = stac925x_mux_nids;
4981 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004982 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004983 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004984 switch (codec->vendor_id) {
4985 case 0x83847632: /* STAC9202 */
4986 case 0x83847633: /* STAC9202D */
4987 case 0x83847636: /* STAC9251 */
4988 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004989 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004990 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004991 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4992 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004993 break;
4994 default:
4995 spec->num_dmics = 0;
4996 break;
4997 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004998
4999 spec->init = stac925x_core_init;
5000 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005001 spec->num_caps = 1;
5002 spec->capvols = stac925x_capvols;
5003 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005004
5005 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005006 if (!err) {
5007 if (spec->board_config < 0) {
5008 printk(KERN_WARNING "hda_codec: No auto-config is "
5009 "available, default to model=ref\n");
5010 spec->board_config = STAC_925x_REF;
5011 goto again;
5012 }
5013 err = -EINVAL;
5014 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005015 if (err < 0) {
5016 stac92xx_free(codec);
5017 return err;
5018 }
5019
5020 codec->patch_ops = stac92xx_patch_ops;
5021
5022 return 0;
5023}
5024
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005025static int patch_stac92hd73xx(struct hda_codec *codec)
5026{
5027 struct sigmatel_spec *spec;
5028 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5029 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005030 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005031
5032 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5033 if (spec == NULL)
5034 return -ENOMEM;
5035
5036 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005037 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005038 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5039 spec->pin_nids = stac92hd73xx_pin_nids;
5040 spec->board_config = snd_hda_check_board_config(codec,
5041 STAC_92HD73XX_MODELS,
5042 stac92hd73xx_models,
5043 stac92hd73xx_cfg_tbl);
5044again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005045 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005046 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5047 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005048 else
5049 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005050 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005051
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005052 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005053 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5054
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005055 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005056 printk(KERN_WARNING "hda_codec: Could not determine "
5057 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005058 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005059 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005060 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005061 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005062 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005063 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005064 break;
5065 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005066 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005067 break;
5068 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005069 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5070 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005071 }
5072 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005073
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005074 spec->aloopback_mask = 0x01;
5075 spec->aloopback_shift = 8;
5076
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005077 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005078 spec->mux_nids = stac92hd73xx_mux_nids;
5079 spec->adc_nids = stac92hd73xx_adc_nids;
5080 spec->dmic_nids = stac92hd73xx_dmic_nids;
5081 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005082 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005083
5084 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5085 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005086 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005087
Takashi Iwai6479c632009-07-28 18:20:25 +02005088 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5089 spec->capvols = stac92hd73xx_capvols;
5090 spec->capsws = stac92hd73xx_capsws;
5091
Matthew Ranostaya7662642008-02-21 07:51:14 +01005092 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005093 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005094 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005095 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005096 case STAC_DELL_M6_AMIC:
5097 case STAC_DELL_M6_DMIC:
5098 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005099 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005100 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005101
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005102 switch (spec->board_config) {
5103 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005104 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005105 spec->num_dmics = 0;
5106 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005107 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005108 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005109 spec->num_dmics = 1;
5110 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005111 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005112 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5113 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005114 spec->num_dmics = 1;
5115 break;
5116 }
5117 break;
5118 default:
5119 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005120 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005121 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005122 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005123 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005124 if (spec->board_config > STAC_92HD73XX_REF) {
5125 /* GPIO0 High = Enable EAPD */
5126 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5127 spec->gpio_data = 0x01;
5128 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005129
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005130 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5131 spec->pwr_nids = stac92hd73xx_pwr_nids;
5132
Matthew Ranostayd9737752008-09-07 12:03:41 +02005133 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005134
5135 if (!err) {
5136 if (spec->board_config < 0) {
5137 printk(KERN_WARNING "hda_codec: No auto-config is "
5138 "available, default to model=ref\n");
5139 spec->board_config = STAC_92HD73XX_REF;
5140 goto again;
5141 }
5142 err = -EINVAL;
5143 }
5144
5145 if (err < 0) {
5146 stac92xx_free(codec);
5147 return err;
5148 }
5149
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005150 if (spec->board_config == STAC_92HD73XX_NO_JD)
5151 spec->hp_detect = 0;
5152
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005153 codec->patch_ops = stac92xx_patch_ops;
5154
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005155 codec->proc_widget_hook = stac92hd7x_proc_hook;
5156
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005157 return 0;
5158}
5159
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005160static int patch_stac92hd83xxx(struct hda_codec *codec)
5161{
5162 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005163 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005164 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005165 int num_dacs;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005166 hda_nid_t nid;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005167
5168 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5169 if (spec == NULL)
5170 return -ENOMEM;
5171
5172 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005173 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005174 spec->mono_nid = 0x19;
5175 spec->digbeep_nid = 0x21;
Takashi Iwai667067d2009-08-13 18:14:42 +02005176 spec->mux_nids = stac92hd83xxx_mux_nids;
5177 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005178 spec->adc_nids = stac92hd83xxx_adc_nids;
Takashi Iwai7570ef12009-08-15 11:57:53 +02005179 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005180 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5181 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5182 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005183 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005184
5185 spec->init = stac92hd83xxx_core_init;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005186 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005187 spec->pin_nids = stac92hd83xxx_pin_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02005188 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5189 spec->capvols = stac92hd83xxx_capvols;
5190 spec->capsws = stac92hd83xxx_capsws;
5191
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005192 spec->board_config = snd_hda_check_board_config(codec,
5193 STAC_92HD83XXX_MODELS,
5194 stac92hd83xxx_models,
5195 stac92hd83xxx_cfg_tbl);
5196again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005197 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005198 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5199 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005200 else
5201 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005202 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005203
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005204 switch (codec->vendor_id) {
5205 case 0x111d7604:
5206 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005207 case 0x111d76d5:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005208 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5209 break;
5210 spec->num_pwrs = 0;
5211 break;
5212 }
5213
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005214 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5215 if (!err) {
5216 if (spec->board_config < 0) {
5217 printk(KERN_WARNING "hda_codec: No auto-config is "
5218 "available, default to model=ref\n");
5219 spec->board_config = STAC_92HD83XXX_REF;
5220 goto again;
5221 }
5222 err = -EINVAL;
5223 }
5224
5225 if (err < 0) {
5226 stac92xx_free(codec);
5227 return err;
5228 }
5229
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005230 switch (spec->board_config) {
5231 case STAC_DELL_S14:
5232 nid = 0xf;
5233 break;
5234 default:
5235 nid = 0xe;
5236 break;
5237 }
5238
5239 num_dacs = snd_hda_get_connections(codec, nid,
5240 conn, STAC92HD83_DAC_COUNT + 1) - 1;
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02005241 if (num_dacs < 0)
5242 num_dacs = STAC92HD83_DAC_COUNT;
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005243
5244 /* set port X to select the last DAC
5245 */
5246 snd_hda_codec_write_cache(codec, nid, 0,
5247 AC_VERB_SET_CONNECT_SEL, num_dacs);
5248
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005249 codec->patch_ops = stac92xx_patch_ops;
5250
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005251 codec->proc_widget_hook = stac92hd_proc_hook;
5252
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005253 return 0;
5254}
5255
Takashi Iwai330ee992009-02-20 14:33:36 +01005256/* get the pin connection (fixed, none, etc) */
5257static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5258{
5259 struct sigmatel_spec *spec = codec->spec;
5260 unsigned int cfg;
5261
5262 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5263 return get_defcfg_connect(cfg);
5264}
5265
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005266static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5267 hda_nid_t *nids, int num_nids)
5268{
5269 struct sigmatel_spec *spec = codec->spec;
5270 int idx, num;
5271 unsigned int def_conf;
5272
5273 for (num = 0; num < num_nids; num++) {
5274 for (idx = 0; idx < spec->num_pins; idx++)
5275 if (spec->pin_nids[idx] == nids[num])
5276 break;
5277 if (idx >= spec->num_pins)
5278 break;
Takashi Iwai330ee992009-02-20 14:33:36 +01005279 def_conf = stac_get_defcfg_connect(codec, idx);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005280 if (def_conf == AC_JACK_PORT_NONE)
5281 break;
5282 }
5283 return num;
5284}
5285
5286static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5287 hda_nid_t dig0pin)
5288{
5289 struct sigmatel_spec *spec = codec->spec;
5290 int idx;
5291
5292 for (idx = 0; idx < spec->num_pins; idx++)
5293 if (spec->pin_nids[idx] == dig0pin)
5294 break;
5295 if ((idx + 2) >= spec->num_pins)
5296 return 0;
5297
5298 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005299 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005300 return 2;
5301
5302 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005303 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005304 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005305 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005306 return 1;
5307 else
5308 return 0;
5309}
5310
Matthew Ranostaye035b842007-11-06 11:53:55 +01005311static int patch_stac92hd71bxx(struct hda_codec *codec)
5312{
5313 struct sigmatel_spec *spec;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005314 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005315 int err = 0;
5316
5317 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5318 if (spec == NULL)
5319 return -ENOMEM;
5320
5321 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005322 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005323 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5324 switch (codec->vendor_id) {
5325 case 0x111d76b6:
5326 case 0x111d76b7:
5327 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5328 break;
5329 case 0x111d7603:
5330 case 0x111d7608:
5331 /* On 92HD75Bx 0x27 isn't a pin nid */
5332 spec->num_pins--;
5333 /* fallthrough */
5334 default:
5335 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5336 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005337 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005338 spec->board_config = snd_hda_check_board_config(codec,
5339 STAC_92HD71BXX_MODELS,
5340 stac92hd71bxx_models,
5341 stac92hd71bxx_cfg_tbl);
5342again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005343 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005344 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5345 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005346 else
5347 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005348 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005349
Takashi Iwai41c3b642008-11-18 10:45:15 +01005350 if (spec->board_config > STAC_92HD71BXX_REF) {
5351 /* GPIO0 = EAPD */
5352 spec->gpio_mask = 0x01;
5353 spec->gpio_dir = 0x01;
5354 spec->gpio_data = 0x01;
5355 }
5356
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005357 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5358 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5359
Takashi Iwai6479c632009-07-28 18:20:25 +02005360 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5361 spec->capvols = stac92hd71bxx_capvols;
5362 spec->capsws = stac92hd71bxx_capsws;
5363
Matthew Ranostay541eee82007-12-14 12:08:04 +01005364 switch (codec->vendor_id) {
5365 case 0x111d76b6: /* 4 Port without Analog Mixer */
5366 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005367 unmute_init++;
5368 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005369 case 0x111d76b4: /* 6 Port without Analog Mixer */
5370 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005371 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005372 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005373 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5374 stac92hd71bxx_dmic_nids,
5375 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005376 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005377 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005378 switch (spec->board_config) {
5379 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005380 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005381 err = stac_add_event(spec, codec->afg,
5382 STAC_VREF_EVENT, 0x02);
5383 if (err < 0)
5384 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005385 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005386 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5387 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005388 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005389 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005390 spec->gpio_mask |= 0x02;
5391 break;
5392 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005393 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005394 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005395 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005396
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005397 /* no output amps */
5398 spec->num_pwrs = 0;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005399 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005400 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005401 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005402 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5403 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005404 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5405 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5406 stac92hd71bxx_dmic_nids,
5407 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005408 break;
5409 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005410 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005411 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005412
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005413 /* no output amps */
5414 spec->num_pwrs = 0;
5415 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005416 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005417 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005418 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005419 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5420 stac92hd71bxx_dmic_nids,
5421 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005422 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005423 }
5424
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005425 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5426 snd_hda_sequence_write_cache(codec, unmute_init);
5427
Takashi Iwaib20f3b82009-06-02 01:20:22 +02005428 /* Some HP machines seem to have unstable codec communications
5429 * especially with ATI fglrx driver. For recovering from the
5430 * CORB/RIRB stall, allow the BUS reset and keep always sync
5431 */
5432 if (spec->board_config == STAC_HP_DV5) {
5433 codec->bus->sync_write = 1;
5434 codec->bus->allow_bus_reset = 1;
5435 }
5436
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005437 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005438 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005439 spec->aloopback_shift = 0;
5440
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005441 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005442 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005443 spec->mux_nids = stac92hd71bxx_mux_nids;
5444 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005445 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005446 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005447
5448 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5449 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005450 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005451 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005452
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005453 switch (spec->board_config) {
5454 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005455 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005456 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005457 stac92xx_auto_set_pinctl(codec, 0x0e,
5458 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005459 /* fallthru */
5460 case STAC_DELL_M4_2:
5461 spec->num_dmics = 0;
5462 spec->num_smuxes = 0;
5463 spec->num_dmuxes = 0;
5464 break;
5465 case STAC_DELL_M4_1:
5466 case STAC_DELL_M4_3:
5467 spec->num_dmics = 1;
5468 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005469 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005470 break;
James Gardiner514bf542009-05-03 04:00:44 -04005471 case STAC_HP_DV4_1222NR:
5472 spec->num_dmics = 1;
5473 /* I don't know if it needs 1 or 2 smuxes - will wait for
5474 * bug reports to fix if needed
5475 */
5476 spec->num_smuxes = 1;
5477 spec->num_dmuxes = 1;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005478 spec->gpio_led = 0x01;
James Gardiner514bf542009-05-03 04:00:44 -04005479 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005480 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005481 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005482 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5483 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005484 case STAC_HP_HDX:
5485 spec->num_dmics = 1;
5486 spec->num_dmuxes = 1;
5487 spec->num_smuxes = 1;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005488 /* orange/white mute led on GPIO3, orange=0, white=1 */
Takashi Iwai86d190e2009-05-26 15:18:58 +02005489 spec->gpio_led = 0x08;
5490 break;
5491 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005492
Takashi Iwai86d190e2009-05-26 15:18:58 +02005493#ifdef CONFIG_SND_HDA_POWER_SAVE
5494 if (spec->gpio_led) {
5495 spec->gpio_mask |= spec->gpio_led;
5496 spec->gpio_dir |= spec->gpio_led;
5497 spec->gpio_data |= spec->gpio_led;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005498 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005499 codec->patch_ops.check_power_status =
Takashi Iwai86d190e2009-05-26 15:18:58 +02005500 stac92xx_hp_check_power_status;
5501 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005502#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005503
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005504 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005505
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005506 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005507 if (!err) {
5508 if (spec->board_config < 0) {
5509 printk(KERN_WARNING "hda_codec: No auto-config is "
5510 "available, default to model=ref\n");
5511 spec->board_config = STAC_92HD71BXX_REF;
5512 goto again;
5513 }
5514 err = -EINVAL;
5515 }
5516
5517 if (err < 0) {
5518 stac92xx_free(codec);
5519 return err;
5520 }
5521
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005522 codec->proc_widget_hook = stac92hd7x_proc_hook;
5523
Matthew Ranostaye035b842007-11-06 11:53:55 +01005524 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005525}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005526
Matt2f2f4252005-04-13 14:45:30 +02005527static int patch_stac922x(struct hda_codec *codec)
5528{
5529 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005530 int err;
Matt2f2f4252005-04-13 14:45:30 +02005531
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005532 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005533 if (spec == NULL)
5534 return -ENOMEM;
5535
5536 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005537 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005538 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005539 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5540 stac922x_models,
5541 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005542 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005543 spec->gpio_mask = spec->gpio_dir = 0x03;
5544 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005545 /* Intel Macs have all same PCI SSID, so we need to check
5546 * codec SSID to distinguish the exact models
5547 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005548 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005549 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005550
5551 case 0x106b0800:
5552 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005553 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005554 case 0x106b0600:
5555 case 0x106b0700:
5556 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005557 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005558 case 0x106b0e00:
5559 case 0x106b0f00:
5560 case 0x106b1600:
5561 case 0x106b1700:
5562 case 0x106b0200:
5563 case 0x106b1e00:
5564 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005565 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005566 case 0x106b1a00:
5567 case 0x00000100:
5568 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005569 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005570 case 0x106b0a00:
5571 case 0x106b2200:
5572 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005573 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005574 default:
5575 spec->board_config = STAC_INTEL_MAC_V3;
5576 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005577 }
5578 }
5579
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005580 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005581 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005582 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5583 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005584 else
5585 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005586 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005587
Matt2f2f4252005-04-13 14:45:30 +02005588 spec->adc_nids = stac922x_adc_nids;
5589 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005590 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005591 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005592 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005593 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005594
5595 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005596
5597 spec->num_caps = STAC922X_NUM_CAPS;
5598 spec->capvols = stac922x_capvols;
5599 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005600
5601 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005602
Matt Porter3cc08dc2006-01-23 15:27:49 +01005603 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005604 if (!err) {
5605 if (spec->board_config < 0) {
5606 printk(KERN_WARNING "hda_codec: No auto-config is "
5607 "available, default to model=ref\n");
5608 spec->board_config = STAC_D945_REF;
5609 goto again;
5610 }
5611 err = -EINVAL;
5612 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005613 if (err < 0) {
5614 stac92xx_free(codec);
5615 return err;
5616 }
5617
5618 codec->patch_ops = stac92xx_patch_ops;
5619
Takashi Iwai807a46362007-05-29 19:01:37 +02005620 /* Fix Mux capture level; max to 2 */
5621 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5622 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5623 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5624 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5625 (0 << AC_AMPCAP_MUTE_SHIFT));
5626
Matt Porter3cc08dc2006-01-23 15:27:49 +01005627 return 0;
5628}
5629
5630static int patch_stac927x(struct hda_codec *codec)
5631{
5632 struct sigmatel_spec *spec;
5633 int err;
5634
5635 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5636 if (spec == NULL)
5637 return -ENOMEM;
5638
5639 codec->spec = spec;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05005640 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005641 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005642 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005643 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5644 stac927x_models,
5645 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005646 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005647 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005648 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5649 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005650 else
5651 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005652 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01005653
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005654 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005655 spec->adc_nids = stac927x_adc_nids;
5656 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5657 spec->mux_nids = stac927x_mux_nids;
5658 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005659 spec->smux_nids = stac927x_smux_nids;
5660 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04005661 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005662 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005663 spec->multiout.dac_nids = spec->dac_nids;
5664
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005665 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02005666 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005667 case STAC_D965_5ST:
5668 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005669 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005670 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005671 spec->num_dmics = 0;
5672
Tobin Davis93ed1502006-09-01 21:03:12 +02005673 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005674 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005675 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005676 switch (codec->subsystem_id) {
5677 case 0x10280209:
5678 case 0x1028022e:
5679 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005680 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02005681 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005682 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01005683 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01005684 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01005685 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005686 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005687 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01005688 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01005689 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005690 case STAC_DELL_3ST:
5691 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005692 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005693 spec->gpio_data = 0x04;
Chengu Wang84d3dc22009-07-30 19:43:55 +08005694 switch (codec->subsystem_id) {
5695 case 0x1028022f:
5696 /* correct EAPD to be GPIO0 */
5697 spec->eapd_mask = spec->gpio_mask = 0x01;
5698 spec->gpio_dir = spec->gpio_data = 0x01;
5699 break;
5700 };
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005701 spec->dmic_nids = stac927x_dmic_nids;
5702 spec->num_dmics = STAC927X_NUM_DMICS;
5703
Tobin Davis93ed1502006-09-01 21:03:12 +02005704 spec->init = d965_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005705 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005706 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005707 break;
5708 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005709 if (spec->board_config > STAC_D965_REF) {
5710 /* GPIO0 High = Enable EAPD */
5711 spec->eapd_mask = spec->gpio_mask = 0x01;
5712 spec->gpio_dir = spec->gpio_data = 0x01;
5713 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005714 spec->num_dmics = 0;
5715
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005716 spec->init = stac927x_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02005717 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005718
Takashi Iwai6479c632009-07-28 18:20:25 +02005719 spec->num_caps = STAC927X_NUM_CAPS;
5720 spec->capvols = stac927x_capvols;
5721 spec->capsws = stac927x_capsws;
5722
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005723 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005724 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005725 spec->aloopback_mask = 0x40;
5726 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005727 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01005728
Matt Porter3cc08dc2006-01-23 15:27:49 +01005729 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005730 if (!err) {
5731 if (spec->board_config < 0) {
5732 printk(KERN_WARNING "hda_codec: No auto-config is "
5733 "available, default to model=ref\n");
5734 spec->board_config = STAC_D965_REF;
5735 goto again;
5736 }
5737 err = -EINVAL;
5738 }
Mattc7d4b2f2005-06-27 14:59:41 +02005739 if (err < 0) {
5740 stac92xx_free(codec);
5741 return err;
5742 }
Matt2f2f4252005-04-13 14:45:30 +02005743
5744 codec->patch_ops = stac92xx_patch_ops;
5745
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005746 codec->proc_widget_hook = stac927x_proc_hook;
5747
Takashi Iwai52987652008-01-16 16:09:47 +01005748 /*
5749 * !!FIXME!!
5750 * The STAC927x seem to require fairly long delays for certain
5751 * command sequences. With too short delays (even if the answer
5752 * is set to RIRB properly), it results in the silence output
5753 * on some hardwares like Dell.
5754 *
5755 * The below flag enables the longer delay (see get_response
5756 * in hda_intel.c).
5757 */
5758 codec->bus->needs_damn_long_delay = 1;
5759
Takashi Iwaie28d8322008-12-17 13:48:29 +01005760 /* no jack detecion for ref-no-jd model */
5761 if (spec->board_config == STAC_D965_REF_NO_JD)
5762 spec->hp_detect = 0;
5763
Matt2f2f4252005-04-13 14:45:30 +02005764 return 0;
5765}
5766
Matt Porterf3302a52006-07-31 12:49:34 +02005767static int patch_stac9205(struct hda_codec *codec)
5768{
5769 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02005770 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02005771
5772 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5773 if (spec == NULL)
5774 return -ENOMEM;
5775
5776 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005777 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005778 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005779 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5780 stac9205_models,
5781 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005782 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005783 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005784 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5785 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005786 else
5787 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005788 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02005789
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005790 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02005791 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005792 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02005793 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005794 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02005795 spec->smux_nids = stac9205_smux_nids;
5796 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005797 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02005798 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005799 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005800 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005801 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02005802
5803 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005804 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02005805
Takashi Iwai6479c632009-07-28 18:20:25 +02005806 spec->num_caps = STAC9205_NUM_CAPS;
5807 spec->capvols = stac9205_capvols;
5808 spec->capsws = stac9205_capsws;
5809
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005810 spec->aloopback_mask = 0x40;
5811 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01005812 /* Turn on/off EAPD per HP plugging */
5813 if (spec->board_config != STAC_9205_EAPD)
5814 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02005815 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02005816
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005817 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005818 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02005819 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01005820 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5821 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01005822
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005823 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005824 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5825 if (err < 0)
5826 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005827 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005828 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5829 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005830 AC_VERB_SET_UNSOLICITED_ENABLE,
5831 AC_USRSP_EN | err);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005832
5833 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005834 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005835 spec->gpio_mask = 0x1b;
5836 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01005837 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005838 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02005839 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005840 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005841 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005842 case STAC_9205_REF:
5843 /* SPDIF-In enabled */
5844 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005845 default:
5846 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02005847 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005848 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02005849 break;
5850 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02005851
Matt Porterf3302a52006-07-31 12:49:34 +02005852 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005853 if (!err) {
5854 if (spec->board_config < 0) {
5855 printk(KERN_WARNING "hda_codec: No auto-config is "
5856 "available, default to model=ref\n");
5857 spec->board_config = STAC_9205_REF;
5858 goto again;
5859 }
5860 err = -EINVAL;
5861 }
Matt Porterf3302a52006-07-31 12:49:34 +02005862 if (err < 0) {
5863 stac92xx_free(codec);
5864 return err;
5865 }
5866
5867 codec->patch_ops = stac92xx_patch_ops;
5868
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005869 codec->proc_widget_hook = stac9205_proc_hook;
5870
Matt Porterf3302a52006-07-31 12:49:34 +02005871 return 0;
5872}
5873
Matt2f2f4252005-04-13 14:45:30 +02005874/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005875 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005876 */
5877
Takashi Iwai1e137f92009-01-21 07:41:22 +01005878static struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02005879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5881 {}
5882};
5883
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005884static hda_nid_t stac9872_pin_nids[] = {
5885 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5886 0x11, 0x13, 0x14,
5887};
5888
5889static hda_nid_t stac9872_adc_nids[] = {
5890 0x8 /*,0x6*/
5891};
5892
5893static hda_nid_t stac9872_mux_nids[] = {
5894 0x15
5895};
5896
Takashi Iwai6479c632009-07-28 18:20:25 +02005897static unsigned long stac9872_capvols[] = {
5898 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5899};
5900#define stac9872_capsws stac9872_capvols
5901
Takashi Iwai307282c2009-03-12 18:17:58 +01005902static unsigned int stac9872_vaio_pin_configs[9] = {
5903 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5904 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5905 0x90a7013e
5906};
5907
5908static const char *stac9872_models[STAC_9872_MODELS] = {
5909 [STAC_9872_AUTO] = "auto",
5910 [STAC_9872_VAIO] = "vaio",
5911};
5912
5913static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5914 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5915};
5916
5917static struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02005918 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5919 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01005920 {} /* terminator */
5921};
5922
Guillaume Munch6d859062006-08-22 17:15:47 +02005923static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005924{
5925 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005926 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005927
Takashi Iwaidb064e52006-03-16 16:04:58 +01005928 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5929 if (spec == NULL)
5930 return -ENOMEM;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005931 codec->spec = spec;
Takashi Iwaib04add92009-07-20 08:01:36 +02005932 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5933 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005934
5935 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5936 stac9872_models,
5937 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01005938 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005939 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5940 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01005941 else
5942 stac92xx_set_config_regs(codec,
5943 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005944
Takashi Iwai1e137f92009-01-21 07:41:22 +01005945 spec->multiout.dac_nids = spec->dac_nids;
5946 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5947 spec->adc_nids = stac9872_adc_nids;
5948 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5949 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01005950 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005951 spec->num_caps = 1;
5952 spec->capvols = stac9872_capvols;
5953 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005954
Takashi Iwai1e137f92009-01-21 07:41:22 +01005955 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5956 if (err < 0) {
5957 stac92xx_free(codec);
5958 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01005959 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01005960 spec->input_mux = &spec->private_imux;
5961 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005962 return 0;
5963}
5964
5965
5966/*
Matt2f2f4252005-04-13 14:45:30 +02005967 * patch entries
5968 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +01005969static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02005970 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5971 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5972 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5973 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5974 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5975 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5976 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005977 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5978 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5979 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5980 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5981 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5982 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005983 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5984 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5985 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5986 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5987 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5988 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5989 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5990 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5991 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5992 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005993 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5994 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5995 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5996 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5997 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5998 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005999 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6000 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006001 /* The following does not take into account .id=0x83847661 when subsys =
6002 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6003 * currently not fully supported.
6004 */
6005 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6006 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6007 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006008 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006009 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6010 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6011 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6012 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6013 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6014 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6015 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6016 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006017 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006018 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6019 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006020 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006021 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006022 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6023 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006024 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006025 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6026 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6027 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6028 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6029 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6030 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6031 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6032 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02006033 {} /* terminator */
6034};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006035
6036MODULE_ALIAS("snd-hda-codec-id:8384*");
6037MODULE_ALIAS("snd-hda-codec-id:111d*");
6038
6039MODULE_LICENSE("GPL");
6040MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6041
6042static struct hda_codec_preset_list sigmatel_list = {
6043 .preset = snd_hda_preset_sigmatel,
6044 .owner = THIS_MODULE,
6045};
6046
6047static int __init patch_sigmatel_init(void)
6048{
6049 return snd_hda_add_codec_preset(&sigmatel_list);
6050}
6051
6052static void __exit patch_sigmatel_exit(void)
6053{
6054 snd_hda_delete_codec_preset(&sigmatel_list);
6055}
6056
6057module_init(patch_sigmatel_init)
6058module_exit(patch_sigmatel_exit)