blob: c4a6ecb8e085721a7c6b62382594f64fc3b74731 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +010031#include <linux/dmi.h>
Matt2f2f4252005-04-13 14:45:30 +020032#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020033#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040034#include <sound/jack.h>
Clemens Ladischa74ccea2010-10-22 15:52:34 +020035#include <sound/tlv.h>
Matt2f2f4252005-04-13 14:45:30 +020036#include "hda_codec.h"
37#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020038#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020039
Takashi Iwaic6e4c662008-11-25 11:58:19 +010040enum {
41 STAC_VREF_EVENT = 1,
42 STAC_INSERT_EVENT,
43 STAC_PWR_EVENT,
44 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020045 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020046 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010047};
Matt4e550962005-07-04 17:51:39 +020048
Takashi Iwaif5fcc132006-11-24 17:07:44 +010049enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010050 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010051 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010052 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020053 STAC_9200_DELL_D21,
54 STAC_9200_DELL_D22,
55 STAC_9200_DELL_D23,
56 STAC_9200_DELL_M21,
57 STAC_9200_DELL_M22,
58 STAC_9200_DELL_M23,
59 STAC_9200_DELL_M24,
60 STAC_9200_DELL_M25,
61 STAC_9200_DELL_M26,
62 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020063 STAC_9200_M4,
64 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010065 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010066 STAC_9200_MODELS
67};
68
69enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010070 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010071 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020072 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020073 STAC_9205_DELL_M43,
74 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010075 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010076 STAC_9205_MODELS
77};
78
79enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010080 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010081 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010082 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080083 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010084 STAC_DELL_M6_AMIC,
85 STAC_DELL_M6_DMIC,
86 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050087 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020088 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010089 STAC_92HD73XX_MODELS
90};
91
92enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010093 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020094 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050095 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050096 STAC_DELL_S14,
Takashi Iwaib4e81872009-11-18 17:20:24 +010097 STAC_92HD83XXX_HP,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -050098 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -060099 STAC_HP_DV7_4000,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200100 STAC_92HD83XXX_MODELS
101};
102
103enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100104 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100105 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100106 STAC_DELL_M4_1,
107 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500108 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400109 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200110 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100111 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100112 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400113 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100114 STAC_92HD71BXX_MODELS
115};
116
117enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100118 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100119 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200120 STAC_M1,
121 STAC_M1_2,
122 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100123 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200124 STAC_M3,
125 STAC_M5,
126 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100127 STAC_925x_MODELS
128};
129
130enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100131 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100132 STAC_D945_REF,
133 STAC_D945GTP3,
134 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200135 STAC_INTEL_MAC_V1,
136 STAC_INTEL_MAC_V2,
137 STAC_INTEL_MAC_V3,
138 STAC_INTEL_MAC_V4,
139 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800140 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
141 * is given, one of the above models will be
142 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200143 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100144 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100145 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100146 STAC_MACBOOK_PRO_V1,
147 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200148 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200149 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300150 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200151 STAC_922X_DELL_D81,
152 STAC_922X_DELL_D82,
153 STAC_922X_DELL_M81,
154 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100155 STAC_922X_MODELS
156};
157
158enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100159 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100160 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100161 STAC_D965_REF,
162 STAC_D965_3ST,
163 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200164 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200165 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100166 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200167 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100168 STAC_927X_MODELS
169};
Matt Porter403d1942005-11-29 15:00:51 +0100170
Takashi Iwai307282c2009-03-12 18:17:58 +0100171enum {
172 STAC_9872_AUTO,
173 STAC_9872_VAIO,
174 STAC_9872_MODELS
175};
176
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400177struct sigmatel_event {
178 hda_nid_t nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +0100179 unsigned char type;
180 unsigned char tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400181 int data;
182};
183
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200184struct sigmatel_mic_route {
185 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200186 signed char mux_idx;
187 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200188};
189
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600190#define MAX_PINS_NUM 16
191#define MAX_ADCS_NUM 4
192#define MAX_DMICS_NUM 4
193
Matt2f2f4252005-04-13 14:45:30 +0200194struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100195 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200196 unsigned int num_mixers;
197
Matt Porter403d1942005-11-29 15:00:51 +0100198 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500199 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200200 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100201 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100202 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400203 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100204 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200205 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100206 unsigned int linear_tone_beep:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200207
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100208 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200209 unsigned int eapd_mask;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100210 unsigned int gpio_mask;
211 unsigned int gpio_dir;
212 unsigned int gpio_data;
213 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200214 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100215 unsigned int gpio_led_polarity;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100216
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200217 /* stream */
218 unsigned int stream_delay;
219
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +0100220 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200221 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100222 unsigned char aloopback_mask;
223 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200224
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100225 /* power management */
226 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200227 const unsigned int *pwr_mapping;
228 const hda_nid_t *pwr_nids;
229 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100230
Matthew Ranostay74aeaab2008-10-25 01:06:04 -0400231 /* events */
232 struct snd_array events;
233
Matt2f2f4252005-04-13 14:45:30 +0200234 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100235 struct hda_input_mux *mono_mux;
236 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200237 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100238 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100239 hda_nid_t hp_dacs[5];
240 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200241
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100242 int volume_offset;
243
Matt2f2f4252005-04-13 14:45:30 +0200244 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200245 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200246 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200247 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200248 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200249 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200250 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200251 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100252 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200253 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200254 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200255 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200256
Takashi Iwai2b635362011-05-02 12:33:43 +0200257 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
258 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200259 unsigned int num_caps; /* number of capture volume/switch elements */
260
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200261 struct sigmatel_mic_route ext_mic;
262 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200263 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200264
Takashi Iwaiea734962011-01-17 11:29:34 +0100265 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200266
Mattdabbed62005-06-14 10:19:34 +0200267 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100268 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200269 hda_nid_t anabeep_nid;
270 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200271
Matt2f2f4252005-04-13 14:45:30 +0200272 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200273 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200274 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200275
276 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200277 const struct hda_verb *init;
278 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200279
280 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200281 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100282 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200283 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100284 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200285 struct hda_input_mux *sinput_mux;
286 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400287 unsigned int cur_amux;
288 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200289 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200290
Matt Porter403d1942005-11-29 15:00:51 +0100291 /* i/o switches */
292 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200293 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100294 hda_nid_t line_switch; /* shared line-in for input and output */
295 hda_nid_t mic_switch; /* shared mic-in for input and output */
296 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200297 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200298
Mattc7d4b2f2005-06-27 14:59:41 +0200299 struct hda_pcm pcm_rec[2]; /* PCM information */
300
301 /* dynamic controls and input_mux */
302 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200303 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200304 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200305 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200306 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100307 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600308
309 /* auto spec */
310 unsigned auto_pin_cnt;
311 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
312 unsigned auto_adc_cnt;
313 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
314 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
315 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
316 unsigned long auto_capvols[MAX_ADCS_NUM];
317 unsigned auto_dmic_cnt;
318 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Matt2f2f4252005-04-13 14:45:30 +0200319};
320
Takashi Iwai2b635362011-05-02 12:33:43 +0200321static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200322 0x03,
323};
324
Takashi Iwai2b635362011-05-02 12:33:43 +0200325static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200326 0x0c,
327};
328
Takashi Iwai2b635362011-05-02 12:33:43 +0200329static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200330 0x02,
331};
332
Takashi Iwai2b635362011-05-02 12:33:43 +0200333static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100334 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
335 0x0f, 0x10, 0x11
336};
337
Takashi Iwai2b635362011-05-02 12:33:43 +0200338static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400339 0x26, 0,
340};
341
Takashi Iwai2b635362011-05-02 12:33:43 +0200342static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100343 0x1a, 0x1b
344};
345
346#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200347static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100348 0x13, 0x14, 0
349};
350
351#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100352
Takashi Iwai2b635362011-05-02 12:33:43 +0200353static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200354 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100355};
356
Takashi Iwai2b635362011-05-02 12:33:43 +0200357static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100358 0x20, 0x21,
359};
360
Takashi Iwai2b635362011-05-02 12:33:43 +0200361static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200362 0x22, 0x23,
363};
364
Takashi Iwai6479c632009-07-28 18:20:25 +0200365#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200366static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200367 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
368 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
369};
370#define stac92hd73xx_capsws stac92hd73xx_capvols
371
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200372#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200373
Takashi Iwai2b635362011-05-02 12:33:43 +0200374static const hda_nid_t stac92hd83xxx_pwr_nids[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200375 0xa, 0xb, 0xd, 0xe,
376};
377
Takashi Iwai2b635362011-05-02 12:33:43 +0200378static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400379 0x1e, 0,
380};
381
Takashi Iwai2b635362011-05-02 12:33:43 +0200382static const unsigned int stac92hd83xxx_pwr_mapping[4] = {
Matthew Ranostay87e88a72009-01-22 20:38:42 -0500383 0x03, 0x0c, 0x20, 0x40,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200384};
385
Takashi Iwai2b635362011-05-02 12:33:43 +0200386static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600387 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200388};
389
Takashi Iwai2b635362011-05-02 12:33:43 +0200390static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100391 0x0a, 0x0d, 0x0f
392};
393
Takashi Iwai2b635362011-05-02 12:33:43 +0200394static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100395 0x12, 0x13,
396};
397
Takashi Iwai2b635362011-05-02 12:33:43 +0200398static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100399 0x1a, 0x1b
400};
401
Takashi Iwai2b635362011-05-02 12:33:43 +0200402static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400403 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100404};
405
Takashi Iwai2b635362011-05-02 12:33:43 +0200406static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200407 0x24, 0x25,
408};
409
Matthew Ranostaye035b842007-11-06 11:53:55 +0100410#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200411static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100412 0x18, 0x19, 0
413};
414
Takashi Iwai2b635362011-05-02 12:33:43 +0200415static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
416 0x18, 0
417};
418
419static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400420 0x22, 0
421};
422
Takashi Iwai6479c632009-07-28 18:20:25 +0200423#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200424static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200425 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
426 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
427};
428#define stac92hd71bxx_capsws stac92hd71bxx_capvols
429
Takashi Iwai2b635362011-05-02 12:33:43 +0200430static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100431 0x03,
432};
433
Takashi Iwai2b635362011-05-02 12:33:43 +0200434static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100435 0x0f,
436};
437
Takashi Iwai2b635362011-05-02 12:33:43 +0200438static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100439 0x02,
440};
441
Takashi Iwaif6e98522007-10-16 14:27:04 +0200442#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200443static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200444 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200445};
446
Takashi Iwai2b635362011-05-02 12:33:43 +0200447static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100448 0x14,
449};
450
Takashi Iwai2b635362011-05-02 12:33:43 +0200451static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200452 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
453};
Takashi Iwai2b635362011-05-02 12:33:43 +0200454static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200455 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
456};
457
Takashi Iwai2b635362011-05-02 12:33:43 +0200458static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200459 0x06, 0x07,
460};
461
Takashi Iwai2b635362011-05-02 12:33:43 +0200462static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200463 0x12, 0x13,
464};
465
Takashi Iwai6479c632009-07-28 18:20:25 +0200466#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200467static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200468 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
469 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
470};
471#define stac922x_capsws stac922x_capvols
472
Takashi Iwai2b635362011-05-02 12:33:43 +0200473static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500474 0x1f, 0,
475};
476
Takashi Iwai2b635362011-05-02 12:33:43 +0200477static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100478 0x07, 0x08, 0x09
479};
480
Takashi Iwai2b635362011-05-02 12:33:43 +0200481static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100482 0x15, 0x16, 0x17
483};
484
Takashi Iwai2b635362011-05-02 12:33:43 +0200485static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200486 0x21,
487};
488
Takashi Iwai2b635362011-05-02 12:33:43 +0200489static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100490 0x02, 0x03, 0x04, 0x05, 0x06, 0
491};
492
Takashi Iwai2b635362011-05-02 12:33:43 +0200493static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100494 0x1b,
495};
496
Matthew Ranostay7f168592007-10-18 17:38:17 +0200497#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200498static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200499 0x13, 0x14, 0
500};
501
Takashi Iwai6479c632009-07-28 18:20:25 +0200502#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200503static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200504 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
506 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
507};
Takashi Iwai2b635362011-05-02 12:33:43 +0200508static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200509 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
511 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
512};
513
Takashi Iwaiea734962011-01-17 11:29:34 +0100514static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400515 "Digital Playback", "ADAT", "Analog Mux 1",
516 "Analog Mux 2", "Analog Mux 3"
517};
518
Takashi Iwai2b635362011-05-02 12:33:43 +0200519static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200520 0x12, 0x13
521};
522
Takashi Iwai2b635362011-05-02 12:33:43 +0200523static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200524 0x19, 0x1a
525};
526
Takashi Iwai2b635362011-05-02 12:33:43 +0200527static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100528 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100529};
530
Takashi Iwai2b635362011-05-02 12:33:43 +0200531static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200532 0x21,
533};
534
Takashi Iwaif6e98522007-10-16 14:27:04 +0200535#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200536static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200537 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200538};
539
Takashi Iwai6479c632009-07-28 18:20:25 +0200540#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200541static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200542 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
543 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
544};
Takashi Iwai2b635362011-05-02 12:33:43 +0200545static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200546 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
547 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
548};
549
Takashi Iwai2b635362011-05-02 12:33:43 +0200550static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200551 0x08, 0x09, 0x0d, 0x0e,
552 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200553};
554
Takashi Iwai2b635362011-05-02 12:33:43 +0200555static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100556 0x07, 0x08, 0x0a, 0x0b,
557 0x0c, 0x0d, 0x10, 0x11,
558};
559
Takashi Iwai2b635362011-05-02 12:33:43 +0200560static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200561 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
562 0x0f, 0x10, 0x11, 0x15, 0x1b,
563};
564
Takashi Iwai2b635362011-05-02 12:33:43 +0200565static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100566 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
567 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200568 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100569};
570
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500571#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200572static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500573 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
574 0x00, 0x14, 0x18, 0x19, 0x1e,
575 0x1f, 0x20, 0x27
576};
Takashi Iwai2b635362011-05-02 12:33:43 +0200577static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100578 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
579 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500580 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100581};
582
Takashi Iwai2b635362011-05-02 12:33:43 +0200583static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100584 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
585 0x0f, 0x10, 0x11, 0x12, 0x13,
586 0x14, 0x21, 0x22, 0x23,
587};
588
Takashi Iwai2b635362011-05-02 12:33:43 +0200589static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200590 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
591 0x0f, 0x14, 0x16, 0x17, 0x18,
592 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200593};
594
Matt Porter8b657272006-10-26 17:12:59 +0200595static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_info *uinfo)
597{
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
601}
602
603static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
604 struct snd_ctl_elem_value *ucontrol)
605{
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100608 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200609
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100610 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200611 return 0;
612}
613
614static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
616{
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100619 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200620
621 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100622 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200623}
624
Matthew Ranostayd9737752008-09-07 12:03:41 +0200625static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_info *uinfo)
627{
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 struct sigmatel_spec *spec = codec->spec;
630 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
631}
632
633static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_value *ucontrol)
635{
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
639
640 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
641 return 0;
642}
643
644static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646{
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400649 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200650 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400651 int err, val;
652 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200653
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400654 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200655 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400656 if (err < 0)
657 return err;
658
659 if (spec->spdif_mute) {
660 if (smux_idx == 0)
661 nid = spec->multiout.dig_out_nid;
662 else
663 nid = codec->slave_dig_outs[smux_idx - 1];
664 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100665 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400666 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100667 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400668 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100669 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
670 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400671 }
672 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200673}
674
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200675static unsigned int stac92xx_vref_set(struct hda_codec *codec,
676 hda_nid_t nid, unsigned int new_vref)
677{
Takashi Iwaib8621512009-06-22 08:00:10 +0200678 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200679 unsigned int pincfg;
680 pincfg = snd_hda_codec_read(codec, nid, 0,
681 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
682
683 pincfg &= 0xff;
684 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
685 pincfg |= new_vref;
686
687 if (new_vref == AC_PINCTL_VREF_HIZ)
688 pincfg |= AC_PINCTL_OUT_EN;
689 else
690 pincfg |= AC_PINCTL_IN_EN;
691
692 error = snd_hda_codec_write_cache(codec, nid, 0,
693 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
694 if (error < 0)
695 return error;
696 else
697 return 1;
698}
699
700static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
701{
702 unsigned int vref;
703 vref = snd_hda_codec_read(codec, nid, 0,
704 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
705 vref &= AC_PINCTL_VREFEN;
706 return vref;
707}
708
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100709static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200710{
711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
712 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200713 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200714}
715
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100716static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200717{
718 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
719 struct sigmatel_spec *spec = codec->spec;
720 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
721
722 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
723 return 0;
724}
725
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100726static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200727{
728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
729 struct sigmatel_spec *spec = codec->spec;
730 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200731 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600732 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200733
Takashi Iwai5207e102009-07-30 13:09:08 +0200734 idx = ucontrol->value.enumerated.item[0];
735 if (idx >= imux->num_items)
736 idx = imux->num_items - 1;
737 prev_idx = spec->cur_mux[adc_idx];
738 if (prev_idx == idx)
739 return 0;
740 if (idx < spec->num_analog_muxes) {
741 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
742 AC_VERB_SET_CONNECT_SEL,
743 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600744 if (prev_idx >= spec->num_analog_muxes &&
745 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200746 imux = spec->dinput_mux;
747 /* 0 = analog */
748 snd_hda_codec_write_cache(codec,
749 spec->dmux_nids[adc_idx], 0,
750 AC_VERB_SET_CONNECT_SEL,
751 imux->items[0].index);
752 }
753 } else {
754 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600755 /* first dimux item is hardcoded to select analog imux,
756 * so lets skip it
757 */
758 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200759 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
760 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600761 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200762 }
763 spec->cur_mux[adc_idx] = idx;
764 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200765}
766
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100767static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
768 struct snd_ctl_elem_info *uinfo)
769{
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 struct sigmatel_spec *spec = codec->spec;
772 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
773}
774
775static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
776 struct snd_ctl_elem_value *ucontrol)
777{
778 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
779 struct sigmatel_spec *spec = codec->spec;
780
781 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
782 return 0;
783}
784
785static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
786 struct snd_ctl_elem_value *ucontrol)
787{
788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
789 struct sigmatel_spec *spec = codec->spec;
790
791 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
792 spec->mono_nid, &spec->cur_mmux);
793}
794
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200795#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
796
797static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
798 struct snd_ctl_elem_value *ucontrol)
799{
800 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100801 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200802 struct sigmatel_spec *spec = codec->spec;
803
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100804 ucontrol->value.integer.value[0] = !!(spec->aloopback &
805 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200806 return 0;
807}
808
809static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
810 struct snd_ctl_elem_value *ucontrol)
811{
812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
813 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100814 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200815 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100816 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200817
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100818 idx_val = spec->aloopback_mask << idx;
819 if (ucontrol->value.integer.value[0])
820 val = spec->aloopback | idx_val;
821 else
822 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100823 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200824 return 0;
825
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100826 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200827
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100828 /* Only return the bits defined by the shift value of the
829 * first two bytes of the mask
830 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200831 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100832 kcontrol->private_value & 0xFFFF, 0x0);
833 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200834
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100835 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200836 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200838 } else {
839 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100840 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200841 }
842
843 snd_hda_codec_write_cache(codec, codec->afg, 0,
844 kcontrol->private_value >> 16, dac_mode);
845
846 return 1;
847}
848
Takashi Iwai2b635362011-05-02 12:33:43 +0200849static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200850 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200851 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200852 {}
853};
854
Takashi Iwai2b635362011-05-02 12:33:43 +0200855static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200856 /* set dac0mux for dac converter */
857 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
858 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
859 {}
860};
861
Takashi Iwai2b635362011-05-02 12:33:43 +0200862static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100863 /* set master volume to max value without distortion
864 * and direct control */
865 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100866 {}
867};
868
Takashi Iwai2b635362011-05-02 12:33:43 +0200869static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100870 /* set master volume and direct control */
871 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100872 {}
873};
874
Takashi Iwai2b635362011-05-02 12:33:43 +0200875static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200876 /* power state controls amps */
877 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200878 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200879};
880
Takashi Iwai2b635362011-05-02 12:33:43 +0200881static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100882 /* set master volume and direct control */
883 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200884 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100885};
886
Takashi Iwai2b635362011-05-02 12:33:43 +0200887static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500888 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
889 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100890 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
891 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100892 {}
893};
894
Takashi Iwai2b635362011-05-02 12:33:43 +0200895static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100896 /* set dac0mux for dac converter */
897 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100898 /* mute the master volume */
899 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100900 {}
901};
902
Takashi Iwai2b635362011-05-02 12:33:43 +0200903static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200904 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200905 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200906 {}
907};
908
Takashi Iwai2b635362011-05-02 12:33:43 +0200909static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200910 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200911 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200912 /* unmute node 0x1b */
913 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
914 /* select node 0x03 as DAC */
915 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
916 {}
917};
918
Takashi Iwai2b635362011-05-02 12:33:43 +0200919static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200920 /* don't set delta bit */
921 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
922 /* unmute node 0x1b */
923 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
924 /* select node 0x03 as DAC */
925 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
926 {}
927};
928
Takashi Iwai2b635362011-05-02 12:33:43 +0200929static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100930 /* set master volume and direct control */
931 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200932 /* enable analog pc beep path */
933 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100934 {}
935};
936
Takashi Iwai2b635362011-05-02 12:33:43 +0200937static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200938 /* don't set delta bit */
939 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
940 /* enable analog pc beep path */
941 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
942 {}
943};
944
Takashi Iwai2b635362011-05-02 12:33:43 +0200945static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200946 /* set master volume and direct control */
947 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200948 /* enable analog pc beep path */
949 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200950 {}
951};
952
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100953#define STAC_MONO_MUX \
954 { \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = "Mono Mux", \
957 .count = 1, \
958 .info = stac92xx_mono_mux_enum_info, \
959 .get = stac92xx_mono_mux_enum_get, \
960 .put = stac92xx_mono_mux_enum_put, \
961 }
962
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100963#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200964 { \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100967 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200968 .info = stac92xx_aloopback_info, \
969 .get = stac92xx_aloopback_get, \
970 .put = stac92xx_aloopback_put, \
971 .private_value = verb_read | (verb_write << 16), \
972 }
973
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200974#define DC_BIAS(xname, idx, nid) \
975 { \
976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
977 .name = xname, \
978 .index = idx, \
979 .info = stac92xx_dc_bias_info, \
980 .get = stac92xx_dc_bias_get, \
981 .put = stac92xx_dc_bias_put, \
982 .private_value = nid, \
983 }
984
Takashi Iwai2b635362011-05-02 12:33:43 +0200985static const struct snd_kcontrol_new stac9200_mixer[] = {
Clemens Ladischde8c85f2010-10-15 10:32:50 +0200986 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200987 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200988 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200990 { } /* end */
991};
992
Takashi Iwai2b635362011-05-02 12:33:43 +0200993static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100994 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
995 {}
996};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100997
Takashi Iwai2b635362011-05-02 12:33:43 +0200998static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +0100999 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1000 {}
1001};
1002
Takashi Iwai2b635362011-05-02 12:33:43 +02001003static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001004 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1005 {}
1006};
1007
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001008
Takashi Iwai2b635362011-05-02 12:33:43 +02001009static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001010 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1011};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001012
Takashi Iwai2b635362011-05-02 12:33:43 +02001013static const struct snd_kcontrol_new stac925x_mixer[] = {
Clemens Ladischde8c85f2010-10-15 10:32:50 +02001014 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
Takashi Iwaic9280d62009-01-15 17:31:00 +01001015 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001016 { } /* end */
1017};
1018
Takashi Iwai2b635362011-05-02 12:33:43 +02001019static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001020 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1021 {}
1022};
1023
Takashi Iwai2b635362011-05-02 12:33:43 +02001024static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001025 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1026 {}
1027};
1028
Takashi Iwai1697055e2007-12-18 18:05:52 +01001029static struct snd_kcontrol_new stac_dmux_mixer = {
1030 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1031 .name = "Digital Input Source",
1032 /* count set later */
1033 .info = stac92xx_dmux_enum_info,
1034 .get = stac92xx_dmux_enum_get,
1035 .put = stac92xx_dmux_enum_put,
1036};
1037
Matthew Ranostayd9737752008-09-07 12:03:41 +02001038static struct snd_kcontrol_new stac_smux_mixer = {
1039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001040 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001041 /* count set later */
1042 .info = stac92xx_smux_enum_info,
1043 .get = stac92xx_smux_enum_get,
1044 .put = stac92xx_smux_enum_put,
1045};
1046
Takashi Iwaiea734962011-01-17 11:29:34 +01001047static const char * const slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001048 "Front Playback Volume",
1049 "Surround Playback Volume",
1050 "Center Playback Volume",
1051 "LFE Playback Volume",
1052 "Side Playback Volume",
1053 "Headphone Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001054 "Speaker Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001055 NULL
1056};
1057
Takashi Iwaiea734962011-01-17 11:29:34 +01001058static const char * const slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001059 "Front Playback Switch",
1060 "Surround Playback Switch",
1061 "Center Playback Switch",
1062 "LFE Playback Switch",
1063 "Side Playback Switch",
1064 "Headphone Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001065 "Speaker Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001066 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001067 NULL
1068};
1069
Takashi Iwai603c4012008-07-30 15:01:44 +02001070static void stac92xx_free_kctls(struct hda_codec *codec);
Takashi Iwaie4973e12008-11-18 09:32:42 +01001071static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
Takashi Iwai603c4012008-07-30 15:01:44 +02001072
Matt2f2f4252005-04-13 14:45:30 +02001073static int stac92xx_build_controls(struct hda_codec *codec)
1074{
1075 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001076 struct auto_pin_cfg *cfg = &spec->autocfg;
1077 hda_nid_t nid;
Matt2f2f4252005-04-13 14:45:30 +02001078 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001079 int i;
Matt2f2f4252005-04-13 14:45:30 +02001080
Takashi Iwai6479c632009-07-28 18:20:25 +02001081 if (spec->mixer) {
1082 err = snd_hda_add_new_ctls(codec, spec->mixer);
1083 if (err < 0)
1084 return err;
1085 }
Mattc7d4b2f2005-06-27 14:59:41 +02001086
1087 for (i = 0; i < spec->num_mixers; i++) {
1088 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1089 if (err < 0)
1090 return err;
1091 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001092 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1093 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001094 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001095 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001096 snd_ctl_new1(&stac_dmux_mixer, codec));
1097 if (err < 0)
1098 return err;
1099 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001100 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001101 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1102 struct hda_input_mux *smux = &spec->private_smux;
1103 /* check for mute support on SPDIF out */
1104 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001105 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001106 spec->spdif_mute = 1;
1107 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001108 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001109 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001110 snd_ctl_new1(&stac_smux_mixer, codec));
1111 if (err < 0)
1112 return err;
1113 }
Mattc7d4b2f2005-06-27 14:59:41 +02001114
Mattdabbed62005-06-14 10:19:34 +02001115 if (spec->multiout.dig_out_nid) {
Stephen Warren74b654c2011-06-01 11:14:18 -06001116 err = snd_hda_create_spdif_out_ctls(codec,
1117 spec->multiout.dig_out_nid,
1118 spec->multiout.dig_out_nid);
Mattdabbed62005-06-14 10:19:34 +02001119 if (err < 0)
1120 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001121 err = snd_hda_create_spdif_share_sw(codec,
1122 &spec->multiout);
1123 if (err < 0)
1124 return err;
1125 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001126 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001127 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001128 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1129 if (err < 0)
1130 return err;
1131 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001132
1133 /* if we have no master control, let's create it */
1134 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001135 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001136 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001137 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai7c7767e2009-01-20 15:28:38 +01001138 /* correct volume offset */
1139 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
Clemens Ladischde8c85f2010-10-15 10:32:50 +02001140 /* minimum value is actually mute */
Clemens Ladischa74ccea2010-10-22 15:52:34 +02001141 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001142 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001143 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001144 if (err < 0)
1145 return err;
1146 }
1147 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1148 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1149 NULL, slave_sws);
1150 if (err < 0)
1151 return err;
1152 }
1153
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001154 if (spec->aloopback_ctl &&
1155 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1156 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1157 if (err < 0)
1158 return err;
1159 }
1160
Takashi Iwai603c4012008-07-30 15:01:44 +02001161 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001162
1163 /* create jack input elements */
1164 if (spec->hp_detect) {
1165 for (i = 0; i < cfg->hp_outs; i++) {
1166 int type = SND_JACK_HEADPHONE;
1167 nid = cfg->hp_pins[i];
1168 /* jack detection */
1169 if (cfg->hp_outs == i)
1170 type |= SND_JACK_LINEOUT;
1171 err = stac92xx_add_jack(codec, nid, type);
1172 if (err < 0)
1173 return err;
1174 }
1175 }
1176 for (i = 0; i < cfg->line_outs; i++) {
1177 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1178 SND_JACK_LINEOUT);
1179 if (err < 0)
1180 return err;
1181 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02001182 for (i = 0; i < cfg->num_inputs; i++) {
1183 nid = cfg->inputs[i].pin;
1184 err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE);
1185 if (err < 0)
1186 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001187 }
1188
Mattdabbed62005-06-14 10:19:34 +02001189 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001190}
1191
Takashi Iwai2b635362011-05-02 12:33:43 +02001192static const unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001193 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001194 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1195};
1196
Takashi Iwai2b635362011-05-02 12:33:43 +02001197static const unsigned int gateway9200_m4_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001198 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1199 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1200};
Takashi Iwai2b635362011-05-02 12:33:43 +02001201static const unsigned int gateway9200_m4_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001202 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1203 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1204};
1205
1206/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001207 STAC 9200 pin configs for
1208 102801A8
1209 102801DE
1210 102801E8
1211*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001212static const unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001213 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1214 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001215};
1216
1217/*
1218 STAC 9200 pin configs for
1219 102801C0
1220 102801C1
1221*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001222static const unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001223 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1224 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001225};
1226
1227/*
1228 STAC 9200 pin configs for
1229 102801C4 (Dell Dimension E310)
1230 102801C5
1231 102801C7
1232 102801D9
1233 102801DA
1234 102801E3
1235*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001236static const unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001237 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1238 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001239};
1240
1241
1242/*
1243 STAC 9200-32 pin configs for
1244 102801B5 (Dell Inspiron 630m)
1245 102801D8 (Dell Inspiron 640m)
1246*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001247static const unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001248 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1249 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001250};
1251
1252/*
1253 STAC 9200-32 pin configs for
1254 102801C2 (Dell Latitude D620)
1255 102801C8
1256 102801CC (Dell Latitude D820)
1257 102801D4
1258 102801D6
1259*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001260static const unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001261 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1262 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001263};
1264
1265/*
1266 STAC 9200-32 pin configs for
1267 102801CE (Dell XPS M1710)
1268 102801CF (Dell Precision M90)
1269*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001270static const unsigned int dell9200_m23_pin_configs[8] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001271 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1272 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1273};
1274
1275/*
1276 STAC 9200-32 pin configs for
1277 102801C9
1278 102801CA
1279 102801CB (Dell Latitude 120L)
1280 102801D3
1281*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001282static const unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001283 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1284 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001285};
1286
1287/*
1288 STAC 9200-32 pin configs for
1289 102801BD (Dell Inspiron E1505n)
1290 102801EE
1291 102801EF
1292*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001293static const unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001294 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1295 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001296};
1297
1298/*
1299 STAC 9200-32 pin configs for
1300 102801F5 (Dell Inspiron 1501)
1301 102801F6
1302*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001303static const unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001304 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1305 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001306};
1307
1308/*
1309 STAC 9200-32
1310 102801CD (Dell Inspiron E1705/9400)
1311*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001312static const unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001313 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1314 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001315};
1316
Takashi Iwai2b635362011-05-02 12:33:43 +02001317static const unsigned int oqo9200_pin_configs[8] = {
Tobin Davisbf277782008-02-03 20:31:47 +01001318 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1319 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1320};
1321
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001322
Takashi Iwai2b635362011-05-02 12:33:43 +02001323static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001324 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001325 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001326 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1327 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1328 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1329 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1330 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1331 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1332 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1333 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1334 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1335 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001336 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1337 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001338 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001339};
1340
Takashi Iwaiea734962011-01-17 11:29:34 +01001341static const char * const stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001342 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001343 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001344 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001345 [STAC_9200_DELL_D21] = "dell-d21",
1346 [STAC_9200_DELL_D22] = "dell-d22",
1347 [STAC_9200_DELL_D23] = "dell-d23",
1348 [STAC_9200_DELL_M21] = "dell-m21",
1349 [STAC_9200_DELL_M22] = "dell-m22",
1350 [STAC_9200_DELL_M23] = "dell-m23",
1351 [STAC_9200_DELL_M24] = "dell-m24",
1352 [STAC_9200_DELL_M25] = "dell-m25",
1353 [STAC_9200_DELL_M26] = "dell-m26",
1354 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001355 [STAC_9200_M4] = "gateway-m4",
1356 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001357 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001358};
1359
Takashi Iwai2b635362011-05-02 12:33:43 +02001360static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001361 /* SigmaTel reference board */
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1363 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001364 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1365 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001366 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1368 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001370 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1372 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1374 "unknown Dell", STAC_9200_DELL_D22),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1376 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001378 "Dell Latitude D620", STAC_9200_DELL_M22),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1380 "unknown Dell", STAC_9200_DELL_D23),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1382 "unknown Dell", STAC_9200_DELL_D23),
1383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1384 "unknown Dell", STAC_9200_DELL_M22),
1385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1386 "unknown Dell", STAC_9200_DELL_M24),
1387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1388 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001392 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001394 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001396 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398 "Dell Precision M90", STAC_9200_DELL_M23),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1400 "unknown Dell", STAC_9200_DELL_M22),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1402 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001404 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001406 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1408 "unknown Dell", STAC_9200_DELL_D23),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1410 "unknown Dell", STAC_9200_DELL_D23),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1412 "unknown Dell", STAC_9200_DELL_D21),
1413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1414 "unknown Dell", STAC_9200_DELL_D23),
1415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1416 "unknown Dell", STAC_9200_DELL_D21),
1417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1418 "unknown Dell", STAC_9200_DELL_M25),
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1420 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001421 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001422 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1423 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1424 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001425 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001426 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001427 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001428 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1429 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1430 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001431 /* OQO Mobile */
1432 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001433 {} /* terminator */
1434};
1435
Takashi Iwai2b635362011-05-02 12:33:43 +02001436static const unsigned int ref925x_pin_configs[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001437 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001438 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001439};
1440
Takashi Iwai2b635362011-05-02 12:33:43 +02001441static const unsigned int stac925xM1_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001442 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1443 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001444};
1445
Takashi Iwai2b635362011-05-02 12:33:43 +02001446static const unsigned int stac925xM1_2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001447 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1448 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1449};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001450
Takashi Iwai2b635362011-05-02 12:33:43 +02001451static const unsigned int stac925xM2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001452 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1453 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001454};
1455
Takashi Iwai2b635362011-05-02 12:33:43 +02001456static const unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001457 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1458 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1459};
1460
Takashi Iwai2b635362011-05-02 12:33:43 +02001461static const unsigned int stac925xM3_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001462 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1463 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1464};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001465
Takashi Iwai2b635362011-05-02 12:33:43 +02001466static const unsigned int stac925xM5_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001467 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1468 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1469};
1470
Takashi Iwai2b635362011-05-02 12:33:43 +02001471static const unsigned int stac925xM6_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001472 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1473 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001474};
1475
Takashi Iwai2b635362011-05-02 12:33:43 +02001476static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001477 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001478 [STAC_M1] = stac925xM1_pin_configs,
1479 [STAC_M1_2] = stac925xM1_2_pin_configs,
1480 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001481 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001482 [STAC_M3] = stac925xM3_pin_configs,
1483 [STAC_M5] = stac925xM5_pin_configs,
1484 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001485};
1486
Takashi Iwaiea734962011-01-17 11:29:34 +01001487static const char * const stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001488 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001489 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001490 [STAC_M1] = "m1",
1491 [STAC_M1_2] = "m1-2",
1492 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001493 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001494 [STAC_M3] = "m3",
1495 [STAC_M5] = "m5",
1496 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001497};
1498
Takashi Iwai2b635362011-05-02 12:33:43 +02001499static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001500 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1501 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1502 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1503 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001504 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001505 /* Not sure about the brand name for those */
1506 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1507 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1508 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1509 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001510 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001511};
1512
Takashi Iwai2b635362011-05-02 12:33:43 +02001513static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001514 /* SigmaTel reference board */
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001516 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001517 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001518
1519 /* Default table for unknown ID */
1520 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1521
Tobin Davis8e21c342007-01-08 11:04:17 +01001522 {} /* terminator */
1523};
1524
Takashi Iwai2b635362011-05-02 12:33:43 +02001525static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001526 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1527 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1528 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001529 0x01452050,
1530};
1531
Takashi Iwai2b635362011-05-02 12:33:43 +02001532static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001533 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001534 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001535 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1536 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001537};
1538
Takashi Iwai2b635362011-05-02 12:33:43 +02001539static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001540 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1541 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1542 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1543 0x904601b0,
1544};
1545
Takashi Iwai2b635362011-05-02 12:33:43 +02001546static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001547 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001548 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001549};
1550
Takashi Iwai2b635362011-05-02 12:33:43 +02001551static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001552 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001553 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1554 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1555 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001556 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001557 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001558 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001559};
1560
Takashi Iwaiea734962011-01-17 11:29:34 +01001561static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001562 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001563 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001564 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001565 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001566 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1567 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1568 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001569 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001570 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001571};
1572
Takashi Iwai2b635362011-05-02 12:33:43 +02001573static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001574 /* SigmaTel reference board */
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001576 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1578 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001579 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1580 "Intel DG45ID", STAC_92HD73XX_INTEL),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1582 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001584 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001586 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001588 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001590 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001592 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001594 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001596 "unknown Dell", STAC_DELL_M6_DMIC),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1598 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001600 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1602 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1604 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1606 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1608 "Dell Studio XPS 1645", STAC_DELL_M6_BOTH),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001610 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001611 {} /* terminator */
1612};
1613
Takashi Iwai2b635362011-05-02 12:33:43 +02001614static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1616 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1618 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwai842ae632009-09-02 07:43:08 +02001619 {} /* terminator */
1620};
1621
Takashi Iwai2b635362011-05-02 12:33:43 +02001622static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001623 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1624 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001625 0x01451160, 0x98560170,
1626};
1627
Takashi Iwai2b635362011-05-02 12:33:43 +02001628static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001629 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1630 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001631 0x40f000f0, 0x40f000f0,
1632};
1633
Takashi Iwai2b635362011-05-02 12:33:43 +02001634static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001635 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1636 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1637 0x40f000f0, 0x40f000f0,
1638};
1639
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001640static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1641 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1642 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1643 0x40f000f0, 0x40f000f0,
1644};
1645
Takashi Iwai2b635362011-05-02 12:33:43 +02001646static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001647 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001648 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001649 [STAC_DELL_S14] = dell_s14_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001650 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001651 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001652};
1653
Takashi Iwaiea734962011-01-17 11:29:34 +01001654static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001655 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001656 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001657 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001658 [STAC_DELL_S14] = "dell-s14",
Takashi Iwaib4e81872009-11-18 17:20:24 +01001659 [STAC_92HD83XXX_HP] = "hp",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001660 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001661 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001662};
1663
Takashi Iwai2b635362011-05-02 12:33:43 +02001664static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001665 /* SigmaTel reference board */
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001667 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001668 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1669 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001670 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1671 "unknown Dell", STAC_DELL_S14),
Takashi Iwaib4e81872009-11-18 17:20:24 +01001672 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001673 "HP", STAC_92HD83XXX_HP),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1675 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1677 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1679 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1681 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1683 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1685 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1687 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1689 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1691 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1693 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1695 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1697 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1699 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1701 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1703 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1705 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1707 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1709 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1711 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001714 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001715};
1716
Takashi Iwai2b635362011-05-02 12:33:43 +02001717static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001718 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001719 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001720 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1721 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001722};
1723
Takashi Iwai2b635362011-05-02 12:33:43 +02001724static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001725 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001726 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001727 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1728 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001729};
1730
Takashi Iwai2b635362011-05-02 12:33:43 +02001731static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001732 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1733 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001734 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1735 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001736};
1737
Takashi Iwai2b635362011-05-02 12:33:43 +02001738static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001739 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1740 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001741 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1742 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001743};
1744
Takashi Iwai2b635362011-05-02 12:33:43 +02001745static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001746 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001747 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1748 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001749 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001750 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001751 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001752 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001753 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001754 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001755};
1756
Takashi Iwaiea734962011-01-17 11:29:34 +01001757static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001758 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001759 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001760 [STAC_DELL_M4_1] = "dell-m4-1",
1761 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001762 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001763 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001764 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001765 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001766 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001767 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001768};
1769
Takashi Iwai2b635362011-05-02 12:33:43 +02001770static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001771 /* SigmaTel reference board */
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1773 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001774 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1775 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001776 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1777 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001778 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1779 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001780 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1781 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001782 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001783 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001784 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1785 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001786 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1787 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001788 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001789 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001790 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001791 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001792 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1793 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301794 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1795 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11001796 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1797 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001798 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1799 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1801 "unknown Dell", STAC_DELL_M4_1),
1802 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1803 "unknown Dell", STAC_DELL_M4_1),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1805 "unknown Dell", STAC_DELL_M4_1),
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1807 "unknown Dell", STAC_DELL_M4_1),
1808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1809 "unknown Dell", STAC_DELL_M4_1),
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1811 "unknown Dell", STAC_DELL_M4_1),
1812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1813 "unknown Dell", STAC_DELL_M4_1),
1814 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1815 "unknown Dell", STAC_DELL_M4_2),
1816 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1817 "unknown Dell", STAC_DELL_M4_2),
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1819 "unknown Dell", STAC_DELL_M4_2),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1821 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001822 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1823 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001824 {} /* terminator */
1825};
1826
Takashi Iwai2b635362011-05-02 12:33:43 +02001827static const unsigned int ref922x_pin_configs[10] = {
Matt Porter403d1942005-11-29 15:00:51 +01001828 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1829 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001830 0x40000100, 0x40000100,
1831};
1832
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001833/*
1834 STAC 922X pin configs for
1835 102801A7
1836 102801AB
1837 102801A9
1838 102801D1
1839 102801D2
1840*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001841static const unsigned int dell_922x_d81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001842 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1843 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1844 0x01813122, 0x400001f2,
1845};
1846
1847/*
1848 STAC 922X pin configs for
1849 102801AC
1850 102801D0
1851*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001852static const unsigned int dell_922x_d82_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001853 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1854 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1855 0x01813122, 0x400001f1,
1856};
1857
1858/*
1859 STAC 922X pin configs for
1860 102801BF
1861*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001862static const unsigned int dell_922x_m81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001863 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1864 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1865 0x40C003f1, 0x405003f0,
1866};
1867
1868/*
1869 STAC 9221 A1 pin configs for
1870 102801D7 (Dell XPS M1210)
1871*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001872static const unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001873 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1874 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001875 0x508003f3, 0x405003f4,
1876};
1877
Takashi Iwai2b635362011-05-02 12:33:43 +02001878static const unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001879 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001880 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1881 0x02a19120, 0x40000100,
1882};
1883
Takashi Iwai2b635362011-05-02 12:33:43 +02001884static const unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001885 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1886 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001887 0x02a19320, 0x40000100,
1888};
1889
Takashi Iwai2b635362011-05-02 12:33:43 +02001890static const unsigned int intel_mac_v1_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001891 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1892 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001893 0x400000fc, 0x400000fb,
1894};
1895
Takashi Iwai2b635362011-05-02 12:33:43 +02001896static const unsigned int intel_mac_v2_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001897 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1898 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001899 0x400000fc, 0x400000fb,
1900};
1901
Takashi Iwai2b635362011-05-02 12:33:43 +02001902static const unsigned int intel_mac_v3_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001903 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1904 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1905 0x400000fc, 0x400000fb,
1906};
1907
Takashi Iwai2b635362011-05-02 12:33:43 +02001908static const unsigned int intel_mac_v4_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001909 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1910 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1911 0x400000fc, 0x400000fb,
1912};
1913
Takashi Iwai2b635362011-05-02 12:33:43 +02001914static const unsigned int intel_mac_v5_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001915 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1916 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1917 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001918};
1919
Takashi Iwai2b635362011-05-02 12:33:43 +02001920static const unsigned int ecs202_pin_configs[10] = {
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001921 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1922 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1923 0x9037012e, 0x40e000f2,
1924};
Takashi Iwai76c08822007-06-19 12:17:42 +02001925
Takashi Iwai2b635362011-05-02 12:33:43 +02001926static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001927 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001928 [STAC_D945GTP3] = d945gtp3_pin_configs,
1929 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001930 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1931 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1932 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1933 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1934 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001935 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001936 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001937 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1938 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1939 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1940 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1941 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1942 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001943 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001944 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1945 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1946 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1947 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001948};
1949
Takashi Iwaiea734962011-01-17 11:29:34 +01001950static const char * const stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001951 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001952 [STAC_D945_REF] = "ref",
1953 [STAC_D945GTP5] = "5stack",
1954 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001955 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1956 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1957 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1958 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1959 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001960 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001961 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001962 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001963 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001964 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1965 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001966 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001967 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001968 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001969 [STAC_922X_DELL_D81] = "dell-d81",
1970 [STAC_922X_DELL_D82] = "dell-d82",
1971 [STAC_922X_DELL_M81] = "dell-m81",
1972 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001973};
1974
Takashi Iwai2b635362011-05-02 12:33:43 +02001975static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001976 /* SigmaTel reference board */
1977 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1978 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001979 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1980 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001981 /* Intel 945G based systems */
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1983 "Intel D945G", STAC_D945GTP3),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1985 "Intel D945G", STAC_D945GTP3),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1987 "Intel D945G", STAC_D945GTP3),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1989 "Intel D945G", STAC_D945GTP3),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1991 "Intel D945G", STAC_D945GTP3),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1993 "Intel D945G", STAC_D945GTP3),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1995 "Intel D945G", STAC_D945GTP3),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1997 "Intel D945G", STAC_D945GTP3),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1999 "Intel D945G", STAC_D945GTP3),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2001 "Intel D945G", STAC_D945GTP3),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2003 "Intel D945G", STAC_D945GTP3),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2011 "Intel D945G", STAC_D945GTP3),
2012 /* Intel D945G 5-stack systems */
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2014 "Intel D945G", STAC_D945GTP5),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2016 "Intel D945G", STAC_D945GTP5),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2018 "Intel D945G", STAC_D945GTP5),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2020 "Intel D945G", STAC_D945GTP5),
2021 /* Intel 945P based systems */
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2023 "Intel D945P", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2025 "Intel D945P", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2027 "Intel D945P", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2029 "Intel D945P", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2031 "Intel D945P", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2033 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002034 /* other intel */
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2036 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002037 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002038 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002039 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002040 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002041 /* Dell systems */
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2043 "unknown Dell", STAC_922X_DELL_D81),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2045 "unknown Dell", STAC_922X_DELL_D81),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2047 "unknown Dell", STAC_922X_DELL_D81),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2049 "unknown Dell", STAC_922X_DELL_D82),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2051 "unknown Dell", STAC_922X_DELL_M81),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2053 "unknown Dell", STAC_922X_DELL_D82),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2055 "unknown Dell", STAC_922X_DELL_D81),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2057 "unknown Dell", STAC_922X_DELL_D81),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2059 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002060 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002061 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002062 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002063 {} /* terminator */
2064};
2065
Takashi Iwai2b635362011-05-02 12:33:43 +02002066static const unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002067 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2068 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2069 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2070 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002071};
2072
Takashi Iwai2b635362011-05-02 12:33:43 +02002073static const unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002074 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2075 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2076 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2077 0x40000100, 0x40000100
2078};
2079
Takashi Iwai2b635362011-05-02 12:33:43 +02002080static const unsigned int d965_5st_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002081 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2082 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2083 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2084 0x40000100, 0x40000100
2085};
2086
Takashi Iwai2b635362011-05-02 12:33:43 +02002087static const unsigned int d965_5st_no_fp_pin_configs[14] = {
Takashi Iwai679d92e2009-05-24 19:00:08 +02002088 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2089 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2090 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2091 0x40000100, 0x40000100
2092};
2093
Takashi Iwai2b635362011-05-02 12:33:43 +02002094static const unsigned int dell_3st_pin_configs[14] = {
Tobin Davis4ff076e2007-08-07 11:48:12 +02002095 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2096 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002097 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002098 0x40c003fc, 0x40000100
2099};
2100
Takashi Iwai2b635362011-05-02 12:33:43 +02002101static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002102 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002103 [STAC_D965_REF] = ref927x_pin_configs,
2104 [STAC_D965_3ST] = d965_3st_pin_configs,
2105 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002106 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002107 [STAC_DELL_3ST] = dell_3st_pin_configs,
2108 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002109 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002110};
2111
Takashi Iwaiea734962011-01-17 11:29:34 +01002112static const char * const stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002113 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002114 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002115 [STAC_D965_REF] = "ref",
2116 [STAC_D965_3ST] = "3stack",
2117 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002118 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002119 [STAC_DELL_3ST] = "dell-3stack",
2120 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002121 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002122};
2123
Takashi Iwai2b635362011-05-02 12:33:43 +02002124static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002125 /* SigmaTel reference board */
2126 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2127 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002128 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2129 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002130 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002131 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002133 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002134 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2135 "Intel D965", STAC_D965_3ST),
2136 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2137 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002138 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002142 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002152 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002153 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2154 "Intel D965", STAC_D965_5ST),
2155 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2156 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002157 /* volume-knob fixes */
2158 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002159 {} /* terminator */
2160};
2161
Takashi Iwai2b635362011-05-02 12:33:43 +02002162static const unsigned int ref9205_pin_configs[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +02002163 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002164 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002165 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002166};
2167
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002168/*
2169 STAC 9205 pin configs for
2170 102801F1
2171 102801F2
2172 102801FC
2173 102801FD
2174 10280204
2175 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002176 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002177 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002178*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002179static const unsigned int dell_9205_m42_pin_configs[12] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002180 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2181 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2182 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2183};
2184
2185/*
2186 STAC 9205 pin configs for
2187 102801F9
2188 102801FA
2189 102801FE
2190 102801FF (Dell Precision M4300)
2191 10280206
2192 10280200
2193 10280201
2194*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002195static const unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002196 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2197 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2198 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2199};
2200
Takashi Iwai2b635362011-05-02 12:33:43 +02002201static const unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002202 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2203 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2204 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2205};
2206
Takashi Iwai2b635362011-05-02 12:33:43 +02002207static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002208 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002209 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2210 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2211 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002212 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002213};
2214
Takashi Iwaiea734962011-01-17 11:29:34 +01002215static const char * const stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002216 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002217 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002218 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002219 [STAC_9205_DELL_M43] = "dell-m43",
2220 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002221 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002222};
2223
Takashi Iwai2b635362011-05-02 12:33:43 +02002224static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002225 /* SigmaTel reference board */
2226 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2227 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002228 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2229 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002230 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2231 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002232 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002233 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2234 "unknown Dell", STAC_9205_DELL_M42),
2235 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2236 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002237 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002238 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002239 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2240 "Dell Precision", STAC_9205_DELL_M43),
2241 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2242 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002243 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2244 "unknown Dell", STAC_9205_DELL_M42),
2245 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2246 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002247 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2248 "Dell Precision", STAC_9205_DELL_M43),
2249 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002250 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002251 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2252 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2254 "Dell Precision", STAC_9205_DELL_M43),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2256 "Dell Precision", STAC_9205_DELL_M43),
2257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2258 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2260 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2262 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2264 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002265 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002266 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002267 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002268 {} /* terminator */
2269};
2270
Takashi Iwai330ee992009-02-20 14:33:36 +01002271static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002272 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002273{
2274 int i;
2275 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002276
Takashi Iwai330ee992009-02-20 14:33:36 +01002277 if (!pincfgs)
2278 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002279
Matthew Ranostay87d48362007-07-17 11:52:24 +02002280 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002281 if (spec->pin_nids[i] && pincfgs[i])
2282 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2283 pincfgs[i]);
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01002284}
2285
Matt2f2f4252005-04-13 14:45:30 +02002286/*
2287 * Analog playback callbacks
2288 */
2289static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2290 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002291 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002292{
2293 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002294 if (spec->stream_delay)
2295 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002296 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2297 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002298}
2299
2300static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2301 struct hda_codec *codec,
2302 unsigned int stream_tag,
2303 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002304 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002305{
2306 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002307 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002308}
2309
2310static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2311 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002312 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002313{
2314 struct sigmatel_spec *spec = codec->spec;
2315 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2316}
2317
2318/*
Mattdabbed62005-06-14 10:19:34 +02002319 * Digital playback callbacks
2320 */
2321static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2322 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002323 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002324{
2325 struct sigmatel_spec *spec = codec->spec;
2326 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2327}
2328
2329static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002331 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002332{
2333 struct sigmatel_spec *spec = codec->spec;
2334 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2335}
2336
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002337static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2338 struct hda_codec *codec,
2339 unsigned int stream_tag,
2340 unsigned int format,
2341 struct snd_pcm_substream *substream)
2342{
2343 struct sigmatel_spec *spec = codec->spec;
2344 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2345 stream_tag, format, substream);
2346}
2347
Takashi Iwai9411e212009-02-13 11:32:28 +01002348static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
2350 struct snd_pcm_substream *substream)
2351{
2352 struct sigmatel_spec *spec = codec->spec;
2353 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2354}
2355
Mattdabbed62005-06-14 10:19:34 +02002356
2357/*
Matt2f2f4252005-04-13 14:45:30 +02002358 * Analog capture callbacks
2359 */
2360static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2361 struct hda_codec *codec,
2362 unsigned int stream_tag,
2363 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002364 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002365{
2366 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002367 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002368
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002369 if (spec->powerdown_adcs) {
2370 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002371 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002372 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2373 }
2374 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002375 return 0;
2376}
2377
2378static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2379 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002380 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002381{
2382 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002383 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002384
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002385 snd_hda_codec_cleanup_stream(codec, nid);
2386 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002387 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002388 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002389 return 0;
2390}
2391
Takashi Iwai2b635362011-05-02 12:33:43 +02002392static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02002393 .substreams = 1,
2394 .channels_min = 2,
2395 .channels_max = 2,
2396 /* NID is set in stac92xx_build_pcms */
2397 .ops = {
2398 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002399 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002400 .prepare = stac92xx_dig_playback_pcm_prepare,
2401 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002402 },
2403};
2404
Takashi Iwai2b635362011-05-02 12:33:43 +02002405static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02002406 .substreams = 1,
2407 .channels_min = 2,
2408 .channels_max = 2,
2409 /* NID is set in stac92xx_build_pcms */
2410};
2411
Takashi Iwai2b635362011-05-02 12:33:43 +02002412static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02002413 .substreams = 1,
2414 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002415 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002416 .nid = 0x02, /* NID to query formats and rates */
2417 .ops = {
2418 .open = stac92xx_playback_pcm_open,
2419 .prepare = stac92xx_playback_pcm_prepare,
2420 .cleanup = stac92xx_playback_pcm_cleanup
2421 },
2422};
2423
Takashi Iwai2b635362011-05-02 12:33:43 +02002424static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002425 .substreams = 1,
2426 .channels_min = 2,
2427 .channels_max = 2,
2428 .nid = 0x06, /* NID to query formats and rates */
2429 .ops = {
2430 .open = stac92xx_playback_pcm_open,
2431 .prepare = stac92xx_playback_pcm_prepare,
2432 .cleanup = stac92xx_playback_pcm_cleanup
2433 },
2434};
2435
Takashi Iwai2b635362011-05-02 12:33:43 +02002436static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002437 .channels_min = 2,
2438 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002439 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002440 .ops = {
2441 .prepare = stac92xx_capture_pcm_prepare,
2442 .cleanup = stac92xx_capture_pcm_cleanup
2443 },
2444};
2445
2446static int stac92xx_build_pcms(struct hda_codec *codec)
2447{
2448 struct sigmatel_spec *spec = codec->spec;
2449 struct hda_pcm *info = spec->pcm_rec;
2450
2451 codec->num_pcms = 1;
2452 codec->pcm_info = info;
2453
Mattc7d4b2f2005-06-27 14:59:41 +02002454 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002455 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002456 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2457 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002458 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002459 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002460 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002461
2462 if (spec->alt_switch) {
2463 codec->num_pcms++;
2464 info++;
2465 info->name = "STAC92xx Analog Alt";
2466 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2467 }
Matt2f2f4252005-04-13 14:45:30 +02002468
Mattdabbed62005-06-14 10:19:34 +02002469 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2470 codec->num_pcms++;
2471 info++;
2472 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002473 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002474 if (spec->multiout.dig_out_nid) {
2475 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2476 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2477 }
2478 if (spec->dig_in_nid) {
2479 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2480 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2481 }
2482 }
2483
Matt2f2f4252005-04-13 14:45:30 +02002484 return 0;
2485}
2486
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002487static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2488 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002489{
Takashi Iwai1327a322009-03-23 13:07:47 +01002490 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002491 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2492 if (pincap & AC_PINCAP_VREF_100)
2493 return AC_PINCTL_VREF_100;
2494 if (pincap & AC_PINCAP_VREF_80)
2495 return AC_PINCTL_VREF_80;
2496 if (pincap & AC_PINCAP_VREF_50)
2497 return AC_PINCTL_VREF_50;
2498 if (pincap & AC_PINCAP_VREF_GRD)
2499 return AC_PINCTL_VREF_GRD;
2500 return 0;
2501}
2502
Matt Porter403d1942005-11-29 15:00:51 +01002503static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2504
2505{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002506 snd_hda_codec_write_cache(codec, nid, 0,
2507 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002508}
2509
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002510#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2511
2512static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2513 struct snd_ctl_elem_value *ucontrol)
2514{
2515 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2516 struct sigmatel_spec *spec = codec->spec;
2517
Takashi Iwaid7a89432008-11-12 09:48:04 +01002518 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002519 return 0;
2520}
2521
Takashi Iwai62558ce2009-07-29 14:23:09 +02002522static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002523
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002524static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2525 struct snd_ctl_elem_value *ucontrol)
2526{
2527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2528 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002529 int nid = kcontrol->private_value;
2530
2531 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002532
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002533 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002534 * switch changes
2535 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002536 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002537
2538 return 1;
2539}
2540
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002541static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2542 struct snd_ctl_elem_info *uinfo)
2543{
2544 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02002545 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002546 "Mic In", "Line In", "Line Out"
2547 };
2548
2549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2550 struct sigmatel_spec *spec = codec->spec;
2551 hda_nid_t nid = kcontrol->private_value;
2552
2553 if (nid == spec->mic_switch || nid == spec->line_switch)
2554 i = 3;
2555 else
2556 i = 2;
2557
2558 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2559 uinfo->value.enumerated.items = i;
2560 uinfo->count = 1;
2561 if (uinfo->value.enumerated.item >= i)
2562 uinfo->value.enumerated.item = i-1;
2563 strcpy(uinfo->value.enumerated.name,
2564 texts[uinfo->value.enumerated.item]);
2565
2566 return 0;
2567}
2568
2569static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2570 struct snd_ctl_elem_value *ucontrol)
2571{
2572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2573 hda_nid_t nid = kcontrol->private_value;
2574 unsigned int vref = stac92xx_vref_get(codec, nid);
2575
2576 if (vref == stac92xx_get_default_vref(codec, nid))
2577 ucontrol->value.enumerated.item[0] = 0;
2578 else if (vref == AC_PINCTL_VREF_GRD)
2579 ucontrol->value.enumerated.item[0] = 1;
2580 else if (vref == AC_PINCTL_VREF_HIZ)
2581 ucontrol->value.enumerated.item[0] = 2;
2582
2583 return 0;
2584}
2585
2586static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2587 struct snd_ctl_elem_value *ucontrol)
2588{
2589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2590 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002591 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002592 hda_nid_t nid = kcontrol->private_value;
2593
2594 if (ucontrol->value.enumerated.item[0] == 0)
2595 new_vref = stac92xx_get_default_vref(codec, nid);
2596 else if (ucontrol->value.enumerated.item[0] == 1)
2597 new_vref = AC_PINCTL_VREF_GRD;
2598 else if (ucontrol->value.enumerated.item[0] == 2)
2599 new_vref = AC_PINCTL_VREF_HIZ;
2600 else
2601 return 0;
2602
2603 if (new_vref != stac92xx_vref_get(codec, nid)) {
2604 error = stac92xx_vref_set(codec, nid, new_vref);
2605 return error;
2606 }
2607
2608 return 0;
2609}
2610
2611static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2612 struct snd_ctl_elem_info *uinfo)
2613{
Takashi Iwai2b635362011-05-02 12:33:43 +02002614 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2616 struct sigmatel_spec *spec = codec->spec;
2617
2618 if (kcontrol->private_value == spec->line_switch)
2619 texts[0] = "Line In";
2620 else
2621 texts[0] = "Mic In";
2622 texts[1] = "Line Out";
2623 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2624 uinfo->value.enumerated.items = 2;
2625 uinfo->count = 1;
2626
2627 if (uinfo->value.enumerated.item >= 2)
2628 uinfo->value.enumerated.item = 1;
2629 strcpy(uinfo->value.enumerated.name,
2630 texts[uinfo->value.enumerated.item]);
2631
2632 return 0;
2633}
Matt Porter403d1942005-11-29 15:00:51 +01002634
2635static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2636{
2637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2638 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002639 hda_nid_t nid = kcontrol->private_value;
2640 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002641
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002642 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002643 return 0;
2644}
2645
2646static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2647{
2648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2649 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002650 hda_nid_t nid = kcontrol->private_value;
2651 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2652 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002653
2654 spec->io_switch[io_idx] = val;
2655
2656 if (val)
2657 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002658 else {
2659 unsigned int pinctl = AC_PINCTL_IN_EN;
2660 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002661 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002662 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2663 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002664
2665 /* check the auto-mute again: we need to mute/unmute the speaker
2666 * appropriately according to the pin direction
2667 */
2668 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002669 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002670
Matt Porter403d1942005-11-29 15:00:51 +01002671 return 1;
2672}
2673
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002674#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2675
2676static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2677 struct snd_ctl_elem_value *ucontrol)
2678{
2679 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2680 struct sigmatel_spec *spec = codec->spec;
2681
2682 ucontrol->value.integer.value[0] = spec->clfe_swap;
2683 return 0;
2684}
2685
2686static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2687 struct snd_ctl_elem_value *ucontrol)
2688{
2689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2690 struct sigmatel_spec *spec = codec->spec;
2691 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002692 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002693
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002694 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002695 return 0;
2696
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002697 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002698
2699 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2700 spec->clfe_swap ? 0x4 : 0x0);
2701
2702 return 1;
2703}
2704
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002705#define STAC_CODEC_HP_SWITCH(xname) \
2706 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2707 .name = xname, \
2708 .index = 0, \
2709 .info = stac92xx_hp_switch_info, \
2710 .get = stac92xx_hp_switch_get, \
2711 .put = stac92xx_hp_switch_put, \
2712 }
2713
Matt Porter403d1942005-11-29 15:00:51 +01002714#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2715 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2716 .name = xname, \
2717 .index = 0, \
2718 .info = stac92xx_io_switch_info, \
2719 .get = stac92xx_io_switch_get, \
2720 .put = stac92xx_io_switch_put, \
2721 .private_value = xpval, \
2722 }
2723
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002724#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2725 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2726 .name = xname, \
2727 .index = 0, \
2728 .info = stac92xx_clfe_switch_info, \
2729 .get = stac92xx_clfe_switch_get, \
2730 .put = stac92xx_clfe_switch_put, \
2731 .private_value = xpval, \
2732 }
Matt Porter403d1942005-11-29 15:00:51 +01002733
Mattc7d4b2f2005-06-27 14:59:41 +02002734enum {
2735 STAC_CTL_WIDGET_VOL,
2736 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002737 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002738 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002739 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002740 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002741 STAC_CTL_WIDGET_CLFE_SWITCH,
2742 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002743};
2744
Takashi Iwai2b635362011-05-02 12:33:43 +02002745static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002746 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2747 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002748 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002749 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002750 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002751 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002752 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002753 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002754};
2755
2756/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002757static struct snd_kcontrol_new *
2758stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002759 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002760 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002761 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002762{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002763 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002764
Takashi Iwai603c4012008-07-30 15:01:44 +02002765 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2766 knew = snd_array_new(&spec->kctls);
2767 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002768 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002769 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002770 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002771 if (!knew->name) {
2772 /* roolback */
2773 memset(knew, 0, sizeof(*knew));
2774 spec->kctls.alloced--;
2775 return NULL;
2776 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002777 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002778 return knew;
2779}
2780
2781static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002782 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01002783 int idx, const char *name,
2784 unsigned long val)
2785{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002786 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002787 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002788 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002789 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002790 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002791 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002792 return 0;
2793}
2794
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002795static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2796 int type, int idx, const char *name,
2797 unsigned long val)
2798{
2799 return stac92xx_add_control_temp(spec,
2800 &stac92xx_control_templates[type],
2801 idx, name, val);
2802}
2803
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002804
2805/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002806static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2807 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002808{
2809 return stac92xx_add_control_idx(spec, type, 0, name, val);
2810}
2811
Takashi Iwai2b635362011-05-02 12:33:43 +02002812static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01002813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2814 .name = "Input Source",
2815 .info = stac92xx_mux_enum_info,
2816 .get = stac92xx_mux_enum_get,
2817 .put = stac92xx_mux_enum_put,
2818};
2819
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002820static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2821 hda_nid_t nid, int idx)
2822{
2823 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2824 int control = 0;
2825 struct sigmatel_spec *spec = codec->spec;
2826 char name[22];
2827
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002828 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002829 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2830 && nid == spec->line_switch)
2831 control = STAC_CTL_WIDGET_IO_SWITCH;
2832 else if (snd_hda_query_pin_caps(codec, nid)
2833 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2834 control = STAC_CTL_WIDGET_DC_BIAS;
2835 else if (nid == spec->mic_switch)
2836 control = STAC_CTL_WIDGET_IO_SWITCH;
2837 }
2838
2839 if (control) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02002840 strcpy(name, hda_get_input_pin_label(codec, nid, 1));
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002841 return stac92xx_add_control(codec->spec, control,
2842 strcat(name, " Jack Mode"), nid);
2843 }
2844
2845 return 0;
2846}
2847
Takashi Iwaie3c75962009-01-23 11:57:22 +01002848static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2849{
2850 struct snd_kcontrol_new *knew;
2851 struct hda_input_mux *imux = &spec->private_imux;
2852
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002853 if (spec->auto_mic)
2854 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002855 if (!spec->num_adcs || imux->num_items <= 1)
2856 return 0; /* no need for input source control */
2857 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002858 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002859 if (!knew)
2860 return -ENOMEM;
2861 knew->count = spec->num_adcs;
2862 return 0;
2863}
2864
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002865/* check whether the line-input can be used as line-out */
2866static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002867{
2868 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002869 struct auto_pin_cfg *cfg = &spec->autocfg;
2870 hda_nid_t nid;
2871 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002872 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002873
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002874 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2875 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002876 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02002877 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002878 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01002879 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002880 if (pincap & AC_PINCAP_OUT)
2881 return nid;
2882 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002883 }
Matt Porter403d1942005-11-29 15:00:51 +01002884 return 0;
2885}
2886
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002887static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2888
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002889/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002890static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002891{
2892 struct sigmatel_spec *spec = codec->spec;
2893 struct auto_pin_cfg *cfg = &spec->autocfg;
2894 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02002895 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002896
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002897 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002898 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2899 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002900 for (i = 0; i < cfg->num_inputs; i++) {
2901 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02002902 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002903 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002904 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2905 /* some laptops have an internal analog microphone
2906 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002907 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002908 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002909 if (pincap & AC_PINCAP_OUT) {
2910 *dac = get_unassigned_dac(codec, nid);
2911 if (*dac)
2912 return nid;
2913 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002914 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002915 }
2916 return 0;
2917}
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002918
2919static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2920{
2921 int i;
2922
2923 for (i = 0; i < spec->multiout.num_dacs; i++) {
2924 if (spec->multiout.dac_nids[i] == nid)
2925 return 1;
2926 }
2927
2928 return 0;
2929}
2930
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002931static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2932{
2933 int i;
2934 if (is_in_dac_nids(spec, nid))
2935 return 1;
2936 for (i = 0; i < spec->autocfg.hp_outs; i++)
2937 if (spec->hp_dacs[i] == nid)
2938 return 1;
2939 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2940 if (spec->speaker_dacs[i] == nid)
2941 return 1;
2942 return 0;
2943}
2944
2945static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2946{
2947 struct sigmatel_spec *spec = codec->spec;
2948 int j, conn_len;
2949 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2950 unsigned int wcaps, wtype;
2951
2952 conn_len = snd_hda_get_connections(codec, nid, conn,
2953 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002954 /* 92HD88: trace back up the link of nids to find the DAC */
2955 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2956 != AC_WID_AUD_OUT)) {
2957 nid = conn[0];
2958 conn_len = snd_hda_get_connections(codec, nid, conn,
2959 HDA_MAX_CONNECTIONS);
2960 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002961 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002962 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002963 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002964 /* we check only analog outputs */
2965 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2966 continue;
2967 /* if this route has a free DAC, assign it */
2968 if (!check_all_dac_nids(spec, conn[j])) {
2969 if (conn_len > 1) {
2970 /* select this DAC in the pin's input mux */
2971 snd_hda_codec_write_cache(codec, nid, 0,
2972 AC_VERB_SET_CONNECT_SEL, j);
2973 }
2974 return conn[j];
2975 }
2976 }
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002977 /* if all DACs are already assigned, connect to the primary DAC */
2978 if (conn_len > 1) {
2979 for (j = 0; j < conn_len; j++) {
2980 if (conn[j] == spec->multiout.dac_nids[0]) {
2981 snd_hda_codec_write_cache(codec, nid, 0,
2982 AC_VERB_SET_CONNECT_SEL, j);
2983 break;
2984 }
2985 }
2986 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002987 return 0;
2988}
2989
2990static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2991static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2992
Matt Porter3cc08dc2006-01-23 15:27:49 +01002993/*
Steve Longerbeam7b0438992007-05-03 20:50:03 +02002994 * Fill in the dac_nids table from the parsed pin configuration
2995 * This function only works when every pin in line_out_pins[]
2996 * contains atleast one DAC in its connection list. Some 92xx
2997 * codecs are not connected directly to a DAC, such as the 9200
2998 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002999 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003000static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003001{
3002 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003003 struct auto_pin_cfg *cfg = &spec->autocfg;
3004 int i;
3005 hda_nid_t nid, dac;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003006
Mattc7d4b2f2005-06-27 14:59:41 +02003007 for (i = 0; i < cfg->line_outs; i++) {
3008 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003009 dac = get_unassigned_dac(codec, nid);
3010 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003011 if (spec->multiout.num_dacs > 0) {
3012 /* we have already working output pins,
3013 * so let's drop the broken ones again
3014 */
3015 cfg->line_outs = spec->multiout.num_dacs;
3016 break;
3017 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003018 /* error out, no available DAC found */
3019 snd_printk(KERN_ERR
3020 "%s: No available DAC for pin 0x%x\n",
3021 __func__, nid);
3022 return -ENODEV;
3023 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003024 add_spec_dacs(spec, dac);
3025 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003026
Takashi Iwai139e0712009-03-06 12:10:41 +01003027 for (i = 0; i < cfg->hp_outs; i++) {
3028 nid = cfg->hp_pins[i];
3029 dac = get_unassigned_dac(codec, nid);
3030 if (dac) {
3031 if (!spec->multiout.hp_nid)
3032 spec->multiout.hp_nid = dac;
3033 else
3034 add_spec_extra_dacs(spec, dac);
3035 }
3036 spec->hp_dacs[i] = dac;
3037 }
3038
3039 for (i = 0; i < cfg->speaker_outs; i++) {
3040 nid = cfg->speaker_pins[i];
3041 dac = get_unassigned_dac(codec, nid);
3042 if (dac)
3043 add_spec_extra_dacs(spec, dac);
3044 spec->speaker_dacs[i] = dac;
3045 }
3046
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003047 /* add line-in as output */
3048 nid = check_line_out_switch(codec);
3049 if (nid) {
3050 dac = get_unassigned_dac(codec, nid);
3051 if (dac) {
3052 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3053 nid, cfg->line_outs);
3054 cfg->line_out_pins[cfg->line_outs] = nid;
3055 cfg->line_outs++;
3056 spec->line_switch = nid;
3057 add_spec_dacs(spec, dac);
3058 }
3059 }
3060 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003061 nid = check_mic_out_switch(codec, &dac);
3062 if (nid && dac) {
3063 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3064 nid, cfg->line_outs);
3065 cfg->line_out_pins[cfg->line_outs] = nid;
3066 cfg->line_outs++;
3067 spec->mic_switch = nid;
3068 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003069 }
3070
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003071 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003072 spec->multiout.num_dacs,
3073 spec->multiout.dac_nids[0],
3074 spec->multiout.dac_nids[1],
3075 spec->multiout.dac_nids[2],
3076 spec->multiout.dac_nids[3],
3077 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003078
Mattc7d4b2f2005-06-27 14:59:41 +02003079 return 0;
3080}
3081
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003082/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003083static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3084 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003085{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003086 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003087 char name[32];
3088 int err;
3089
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003090 if (!spec->check_volume_offset) {
3091 unsigned int caps, step, nums, db_scale;
3092 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3093 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3094 AC_AMPCAP_STEP_SIZE_SHIFT;
3095 step = (step + 1) * 25; /* in .01dB unit */
3096 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3097 AC_AMPCAP_NUM_STEPS_SHIFT;
3098 db_scale = nums * step;
3099 /* if dB scale is over -64dB, and finer enough,
3100 * let's reduce it to half
3101 */
3102 if (db_scale > 6400 && nums >= 0x1f)
3103 spec->volume_offset = nums / 2;
3104 spec->check_volume_offset = 1;
3105 }
3106
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003107 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003108 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003109 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3110 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003111 if (err < 0)
3112 return err;
3113 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003114 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003115 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3116 if (err < 0)
3117 return err;
3118 return 0;
3119}
3120
Takashi Iwai668b9652009-03-06 10:13:24 +01003121#define create_controls(codec, pfx, nid, chs) \
3122 create_controls_idx(codec, pfx, 0, nid, chs)
3123
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003124static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3125{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003126 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003127 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3128 return 1;
3129 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003130 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3131 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003132 spec->multiout.num_dacs++;
3133 }
3134 return 0;
3135}
3136
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003137static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003138{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003139 int i;
3140 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3141 if (!spec->multiout.extra_out_nid[i]) {
3142 spec->multiout.extra_out_nid[i] = nid;
3143 return 0;
3144 }
3145 }
3146 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3147 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003148}
3149
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003150/* Create output controls
3151 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3152 */
3153static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3154 const hda_nid_t *pins,
3155 const hda_nid_t *dac_nids,
3156 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003157{
Takashi Iwai76624532008-12-19 10:09:47 +01003158 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003159 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003160 "Front", "Surround", NULL /*CLFE*/, "Side"
3161 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003162 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003163 int i, err;
3164 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003165
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003166 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003167 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003168 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003169 spec->hp_detect = 1;
3170 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003171 nid = dac_nids[i];
3172 if (!nid)
3173 continue;
3174 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003175 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003176 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003177 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003178 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003179 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003180 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003181 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003182
3183 wid_caps = get_wcaps(codec, nid);
3184
3185 if (wid_caps & AC_WCAP_LR_SWAP) {
3186 err = stac92xx_add_control(spec,
3187 STAC_CTL_WIDGET_CLFE_SWITCH,
3188 "Swap Center/LFE Playback Switch", nid);
3189
3190 if (err < 0)
3191 return err;
3192 }
3193
Mattc7d4b2f2005-06-27 14:59:41 +02003194 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003195 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003196 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003197 switch (type) {
3198 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003199 name = "Headphone";
3200 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003201 break;
3202 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003203 name = "Speaker";
3204 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003205 break;
3206 default:
3207 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003208 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003209 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003210 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003211 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003212 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003213 return err;
3214 }
3215 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003216 return 0;
3217}
3218
Takashi Iwai6479c632009-07-28 18:20:25 +02003219static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3220 unsigned long sw, int idx)
3221{
3222 int err;
3223 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd82009-07-30 09:24:29 +02003224 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003225 if (err < 0)
3226 return err;
3227 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd82009-07-30 09:24:29 +02003228 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003229 if (err < 0)
3230 return err;
3231 return 0;
3232}
3233
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003234/* add playback controls from the parsed DAC table */
3235static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3236 const struct auto_pin_cfg *cfg)
3237{
3238 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003239 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003240 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003241 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003242
3243 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3244 spec->multiout.dac_nids,
3245 cfg->line_out_type);
3246 if (err < 0)
3247 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003248
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003249 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003250 err = stac92xx_add_control(spec,
3251 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003252 "Headphone as Line Out Switch",
3253 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003254 if (err < 0)
3255 return err;
3256 }
3257
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003258 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003259 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003260 break;
3261 nid = cfg->inputs[idx].pin;
3262 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3263 if (err < 0)
3264 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003265 }
Matt Porter403d1942005-11-29 15:00:51 +01003266
Mattc7d4b2f2005-06-27 14:59:41 +02003267 return 0;
3268}
3269
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003270/* add playback controls for Speaker and HP outputs */
3271static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3272 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003273{
3274 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003275 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003276
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003277 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3278 spec->hp_dacs, AUTO_PIN_HP_OUT);
3279 if (err < 0)
3280 return err;
3281
3282 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3283 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3284 if (err < 0)
3285 return err;
3286
Mattc7d4b2f2005-06-27 14:59:41 +02003287 return 0;
3288}
3289
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003290/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003291static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003292 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003293};
3294
3295/* create mono mux for mono out on capable codecs */
3296static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3297{
3298 struct sigmatel_spec *spec = codec->spec;
3299 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3300 int i, num_cons;
3301 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3302
3303 num_cons = snd_hda_get_connections(codec,
3304 spec->mono_nid,
3305 con_lst,
3306 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003307 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003308 return -EINVAL;
3309
Takashi Iwai10a20af2010-09-09 16:28:02 +02003310 for (i = 0; i < num_cons; i++)
3311 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3312 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003313
3314 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3315 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003316}
3317
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003318/* create PC beep volume controls */
3319static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3320 hda_nid_t nid)
3321{
3322 struct sigmatel_spec *spec = codec->spec;
3323 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003324 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3325
3326 if (spec->anabeep_nid == nid)
3327 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003328
3329 /* check for mute support for the the amp */
3330 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003331 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003332 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003333 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3334 if (err < 0)
3335 return err;
3336 }
3337
3338 /* check to see if there is volume support for the amp */
3339 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3340 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003341 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003342 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3343 if (err < 0)
3344 return err;
3345 }
3346 return 0;
3347}
3348
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003349#ifdef CONFIG_SND_HDA_INPUT_BEEP
3350#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3351
3352static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3353 struct snd_ctl_elem_value *ucontrol)
3354{
3355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3356 ucontrol->value.integer.value[0] = codec->beep->enabled;
3357 return 0;
3358}
3359
3360static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3361 struct snd_ctl_elem_value *ucontrol)
3362{
3363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003364 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003365}
3366
Takashi Iwai2b635362011-05-02 12:33:43 +02003367static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3369 .info = stac92xx_dig_beep_switch_info,
3370 .get = stac92xx_dig_beep_switch_get,
3371 .put = stac92xx_dig_beep_switch_put,
3372};
3373
3374static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3375{
3376 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003377 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003378}
3379#endif
3380
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003381static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3382{
3383 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003384 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003385
3386 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003387 hda_nid_t nid;
3388 unsigned int wcaps;
3389 unsigned long val;
3390
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003391 nid = spec->mux_nids[i];
3392 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003393 if (!(wcaps & AC_WCAP_OUT_AMP))
3394 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003395
Takashi Iwai667067d2009-08-13 18:14:42 +02003396 /* check whether already the same control was created as
3397 * normal Capture Volume.
3398 */
3399 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3400 for (j = 0; j < spec->num_caps; j++) {
3401 if (spec->capvols[j] == val)
3402 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003403 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003404 if (j < spec->num_caps)
3405 continue;
3406
3407 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3408 "Mux Capture Volume", val);
3409 if (err < 0)
3410 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003411 }
3412 return 0;
3413};
3414
Takashi Iwaiea734962011-01-17 11:29:34 +01003415static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003416 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003417};
3418
3419static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3420{
3421 struct sigmatel_spec *spec = codec->spec;
3422 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01003423 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003424 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003425 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003426
3427 num_cons = snd_hda_get_connections(codec,
3428 spec->smux_nids[0],
3429 con_lst,
3430 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003431 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003432 return -EINVAL;
3433
Matthew Ranostay65973632008-09-16 10:39:37 -04003434 if (!labels)
3435 labels = stac92xx_spdif_labels;
3436
Takashi Iwai10a20af2010-09-09 16:28:02 +02003437 for (i = 0; i < num_cons; i++)
3438 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02003439
3440 return 0;
3441}
3442
Matt Porter8b657272006-10-26 17:12:59 +02003443/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003444static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003445 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3446 "Digital Mic 3", "Digital Mic 4"
3447};
3448
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003449static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3450 int idx)
3451{
3452 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3453 int nums;
3454 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3455 if (idx >= 0 && idx < nums)
3456 return conn[idx];
3457 return 0;
3458}
3459
Takashi Iwai8d087c72011-06-28 12:45:47 +02003460/* look for NID recursively */
3461#define get_connection_index(codec, mux, nid) \
3462 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003463
Takashi Iwai667067d2009-08-13 18:14:42 +02003464/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003465/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003466static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003467 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003468{
3469 unsigned int caps, nums;
3470 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003471 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003472
Takashi Iwai96f845d2009-08-29 00:49:36 +02003473 if (direction == HDA_OUTPUT)
3474 caps = AC_WCAP_OUT_AMP;
3475 else
3476 caps = AC_WCAP_IN_AMP;
3477 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003478 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003479 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003480 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3481 if (!nums)
3482 return 0;
3483 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003484 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3485 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02003486 if (err < 0)
3487 return err;
3488 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003489}
3490
Matt Porter8b657272006-10-26 17:12:59 +02003491/* create playback/capture controls for input pins on dmic capable codecs */
3492static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3493 const struct auto_pin_cfg *cfg)
3494{
3495 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003496 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003497 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003498 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02003499 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003500
Takashi Iwai10a20af2010-09-09 16:28:02 +02003501 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02003502
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;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003505 int index, type_idx;
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 Iwai10a20af2010-09-09 16:28:02 +02003519 label = hda_get_input_pin_label(codec, nid, 1);
3520 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01003521 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3522 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02003523
Takashi Iwai10a20af2010-09-09 16:28:02 +02003524 err = create_elem_capture_vol(codec, nid, label, type_idx,
3525 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003526 if (err < 0)
3527 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003528 if (!err) {
3529 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02003530 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003531 if (err < 0)
3532 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003533 if (!err) {
3534 nid = get_connected_node(codec,
3535 spec->dmux_nids[0], index);
3536 if (nid)
3537 err = create_elem_capture_vol(codec,
3538 nid, label,
3539 type_idx, HDA_INPUT);
3540 if (err < 0)
3541 return err;
3542 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02003543 }
Matt Porter8b657272006-10-26 17:12:59 +02003544 }
3545
3546 return 0;
3547}
3548
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003549static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02003550 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003551{
3552 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003553 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003554
3555 if (!nid)
3556 return 0;
3557 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003558 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003559 switch (snd_hda_get_input_pin_attr(cfg)) {
3560 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003561 if (*fixed)
3562 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003563 if (type != AC_JACK_MIC_IN)
3564 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003565 *fixed = nid;
3566 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003567 case INPUT_PIN_ATTR_UNUSED:
3568 break;
3569 case INPUT_PIN_ATTR_DOCK:
3570 if (*dock)
3571 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003572 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3573 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003574 *dock = nid;
3575 break;
3576 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003577 if (*ext)
3578 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003579 if (type != AC_JACK_MIC_IN)
3580 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003581 *ext = nid;
3582 break;
3583 }
3584 return 0;
3585}
3586
3587static int set_mic_route(struct hda_codec *codec,
3588 struct sigmatel_mic_route *mic,
3589 hda_nid_t pin)
3590{
3591 struct sigmatel_spec *spec = codec->spec;
3592 struct auto_pin_cfg *cfg = &spec->autocfg;
3593 int i;
3594
3595 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02003596 if (pin == 0)
3597 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003598 for (i = 0; i < cfg->num_inputs; i++) {
3599 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003600 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003601 }
Takashi Iwai86e29592010-09-09 14:50:17 +02003602 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003603 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003604 i = get_connection_index(codec, spec->mux_nids[0], pin);
3605 if (i < 0)
3606 return -1;
3607 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003608 mic->dmux_idx = -1;
3609 if (spec->dmux_nids)
3610 mic->dmux_idx = get_connection_index(codec,
3611 spec->dmux_nids[0],
3612 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003613 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003614 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003615 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3616 if (i < 0)
3617 return -1;
3618 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003619 mic->mux_idx = -1;
3620 if (spec->mux_nids)
3621 mic->mux_idx = get_connection_index(codec,
3622 spec->mux_nids[0],
3623 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003624 }
3625 return 0;
3626}
3627
3628/* return non-zero if the device is for automatic mic switch */
3629static int stac_check_auto_mic(struct hda_codec *codec)
3630{
3631 struct sigmatel_spec *spec = codec->spec;
3632 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02003633 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003634 int i;
3635
Charles Chin99077902010-09-17 10:22:32 +02003636 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003637 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02003638 if (check_mic_pin(codec, cfg->inputs[i].pin,
3639 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003640 return 0;
3641 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02003642 if (check_mic_pin(codec, spec->dmic_nids[i],
3643 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003644 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01003645 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02003646 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003647 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003648 return 0; /* no unsol support */
3649 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02003650 set_mic_route(codec, &spec->int_mic, fixed) ||
3651 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003652 return 0; /* something is wrong */
3653 return 1;
3654}
3655
Mattc7d4b2f2005-06-27 14:59:41 +02003656/* create playback/capture controls for input pins */
3657static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3658{
3659 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003660 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003661 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003662 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02003663
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003664 for (i = 0; i < cfg->num_inputs; i++) {
3665 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003666 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02003667
Takashi Iwai314634b2006-09-21 11:56:18 +02003668 index = -1;
3669 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003670 index = get_connection_index(codec, spec->mux_nids[j],
3671 nid);
3672 if (index >= 0)
3673 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003674 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003675 if (index < 0)
3676 continue;
3677
Takashi Iwai10a20af2010-09-09 16:28:02 +02003678 label = hda_get_autocfg_input_label(codec, cfg, i);
3679 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003680
Takashi Iwai667067d2009-08-13 18:14:42 +02003681 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003682 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003683 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003684 if (err < 0)
3685 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003686 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003687 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003688
Steve Longerbeam7b0438992007-05-03 20:50:03 +02003689 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003690 /*
3691 * Set the current input for the muxes.
3692 * The STAC9221 has two input muxes with identical source
3693 * NID lists. Hopefully this won't get confused.
3694 */
3695 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003696 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3697 AC_VERB_SET_CONNECT_SEL,
3698 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003699 }
3700 }
3701
Mattc7d4b2f2005-06-27 14:59:41 +02003702 return 0;
3703}
3704
Mattc7d4b2f2005-06-27 14:59:41 +02003705static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3706{
3707 struct sigmatel_spec *spec = codec->spec;
3708 int i;
3709
3710 for (i = 0; i < spec->autocfg.line_outs; i++) {
3711 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3712 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3713 }
3714}
3715
3716static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3717{
3718 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003719 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003720
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003721 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3722 hda_nid_t pin;
3723 pin = spec->autocfg.hp_pins[i];
3724 if (pin) /* connect to front */
3725 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3726 }
3727 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3728 hda_nid_t pin;
3729 pin = spec->autocfg.speaker_pins[i];
3730 if (pin) /* connect to front */
3731 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3732 }
Mattc7d4b2f2005-06-27 14:59:41 +02003733}
3734
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003735static int is_dual_headphones(struct hda_codec *codec)
3736{
3737 struct sigmatel_spec *spec = codec->spec;
3738 int i, valid_hps;
3739
3740 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3741 spec->autocfg.hp_outs <= 1)
3742 return 0;
3743 valid_hps = 0;
3744 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3745 hda_nid_t nid = spec->autocfg.hp_pins[i];
3746 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3747 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3748 continue;
3749 valid_hps++;
3750 }
3751 return (valid_hps > 1);
3752}
3753
3754
Matt Porter3cc08dc2006-01-23 15:27:49 +01003755static 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 +02003756{
3757 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003758 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003759 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003760
Matt Porter8b657272006-10-26 17:12:59 +02003761 if ((err = snd_hda_parse_pin_def_config(codec,
3762 &spec->autocfg,
3763 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003764 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003765 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003766 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003767
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003768 /* If we have no real line-out pin and multiple hp-outs, HPs should
3769 * be set up as multi-channel outputs.
3770 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003771 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003772 /* Copy hp_outs to line_outs, backup line_outs in
3773 * speaker_outs so that the following routines can handle
3774 * HP pins as primary outputs.
3775 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003776 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003777 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3778 sizeof(spec->autocfg.line_out_pins));
3779 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3780 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3781 sizeof(spec->autocfg.hp_pins));
3782 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003783 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3784 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003785 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003786 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003787 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003788 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3789 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003790 u32 caps = query_amp_caps(codec,
3791 spec->autocfg.mono_out_pin, dir);
3792 hda_nid_t conn_list[1];
3793
3794 /* get the mixer node and then the mono mux if it exists */
3795 if (snd_hda_get_connections(codec,
3796 spec->autocfg.mono_out_pin, conn_list, 1) &&
3797 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003798 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003799
3800 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003801 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003802 /* LR swap check, some stac925x have a mux that
3803 * changes the DACs output path instead of the
3804 * mono-mux path.
3805 */
3806 if (wid_type == AC_WID_AUD_SEL &&
3807 !(wcaps & AC_WCAP_LR_SWAP))
3808 spec->mono_nid = conn_list[0];
3809 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003810 if (dir) {
3811 hda_nid_t nid = spec->autocfg.mono_out_pin;
3812
3813 /* most mono outs have a least a mute/unmute switch */
3814 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3815 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3816 "Mono Playback Switch",
3817 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003818 if (err < 0)
3819 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003820 /* check for volume support for the amp */
3821 if ((caps & AC_AMPCAP_NUM_STEPS)
3822 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3823 err = stac92xx_add_control(spec,
3824 STAC_CTL_WIDGET_VOL,
3825 "Mono Playback Volume",
3826 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3827 if (err < 0)
3828 return err;
3829 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003830 }
3831
3832 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3833 AC_PINCTL_OUT_EN);
3834 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003835
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003836 if (!spec->multiout.num_dacs) {
3837 err = stac92xx_auto_fill_dac_nids(codec);
3838 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003839 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003840 err = stac92xx_auto_create_multi_out_ctls(codec,
3841 &spec->autocfg);
3842 if (err < 0)
3843 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003844 }
Mattc7d4b2f2005-06-27 14:59:41 +02003845
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003846 /* setup analog beep controls */
3847 if (spec->anabeep_nid > 0) {
3848 err = stac92xx_auto_create_beep_ctls(codec,
3849 spec->anabeep_nid);
3850 if (err < 0)
3851 return err;
3852 }
3853
3854 /* setup digital beep controls and input device */
3855#ifdef CONFIG_SND_HDA_INPUT_BEEP
3856 if (spec->digbeep_nid > 0) {
3857 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003858 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003859
3860 err = stac92xx_auto_create_beep_ctls(codec, nid);
3861 if (err < 0)
3862 return err;
3863 err = snd_hda_attach_beep_device(codec, nid);
3864 if (err < 0)
3865 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003866 if (codec->beep) {
3867 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003868 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003869 /* if no beep switch is available, make its own one */
3870 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3871 if (!(caps & AC_AMPCAP_MUTE)) {
3872 err = stac92xx_beep_switch_ctl(codec);
3873 if (err < 0)
3874 return err;
3875 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003876 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003877 }
3878#endif
3879
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003880 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003881 if (err < 0)
3882 return err;
3883
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003884 /* All output parsing done, now restore the swapped hp pins */
3885 if (hp_swap) {
3886 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3887 sizeof(spec->autocfg.hp_pins));
3888 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3889 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3890 spec->autocfg.line_outs = 0;
3891 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003892
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003893 if (stac_check_auto_mic(codec)) {
3894 spec->auto_mic = 1;
3895 /* only one capture for auto-mic */
3896 spec->num_adcs = 1;
3897 spec->num_caps = 1;
3898 spec->num_muxes = 1;
3899 }
3900
Takashi Iwai6479c632009-07-28 18:20:25 +02003901 for (i = 0; i < spec->num_caps; i++) {
3902 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3903 spec->capsws[i], i);
3904 if (err < 0)
3905 return err;
3906 }
3907
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003908 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003909 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003910 return err;
3911
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003912 if (spec->mono_nid > 0) {
3913 err = stac92xx_auto_create_mono_output_ctls(codec);
3914 if (err < 0)
3915 return err;
3916 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003917 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003918 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3919 &spec->autocfg)) < 0)
3920 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003921 if (spec->num_muxes > 0) {
3922 err = stac92xx_auto_create_mux_input_ctls(codec);
3923 if (err < 0)
3924 return err;
3925 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003926 if (spec->num_smuxes > 0) {
3927 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3928 if (err < 0)
3929 return err;
3930 }
Matt Porter8b657272006-10-26 17:12:59 +02003931
Takashi Iwaie3c75962009-01-23 11:57:22 +01003932 err = stac92xx_add_input_source(spec);
3933 if (err < 0)
3934 return err;
3935
Mattc7d4b2f2005-06-27 14:59:41 +02003936 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003937 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003938 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003939
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003940 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003941 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003942 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003943 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003944
Takashi Iwai603c4012008-07-30 15:01:44 +02003945 if (spec->kctls.list)
3946 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003947
3948 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003949 if (!spec->dinput_mux)
3950 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003951 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003952 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003953 return 1;
3954}
3955
Takashi Iwai82bc9552006-03-21 11:24:42 +01003956/* add playback controls for HP output */
3957static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3958 struct auto_pin_cfg *cfg)
3959{
3960 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003961 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003962
3963 if (! pin)
3964 return 0;
3965
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003966 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01003967 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003968
3969 return 0;
3970}
3971
Richard Fish160ea0d2006-09-06 13:58:25 +02003972/* add playback controls for LFE output */
3973static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3974 struct auto_pin_cfg *cfg)
3975{
3976 struct sigmatel_spec *spec = codec->spec;
3977 int err;
3978 hda_nid_t lfe_pin = 0x0;
3979 int i;
3980
3981 /*
3982 * search speaker outs and line outs for a mono speaker pin
3983 * with an amp. If one is found, add LFE controls
3984 * for it.
3985 */
3986 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3987 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003988 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003989 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3990 if (wcaps == AC_WCAP_OUT_AMP)
3991 /* found a mono speaker with an amp, must be lfe */
3992 lfe_pin = pin;
3993 }
3994
3995 /* if speaker_outs is 0, then speakers may be in line_outs */
3996 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3997 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3998 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003999 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004000 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004001 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004002 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004003 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4004 if (wcaps == AC_WCAP_OUT_AMP)
4005 /* found a mono speaker with an amp,
4006 must be lfe */
4007 lfe_pin = pin;
4008 }
4009 }
4010 }
4011
4012 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004013 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004014 if (err < 0)
4015 return err;
4016 }
4017
4018 return 0;
4019}
4020
Mattc7d4b2f2005-06-27 14:59:41 +02004021static int stac9200_parse_auto_config(struct hda_codec *codec)
4022{
4023 struct sigmatel_spec *spec = codec->spec;
4024 int err;
4025
Kailang Yangdf694da2005-12-05 19:42:22 +01004026 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004027 return err;
4028
4029 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4030 return err;
4031
Takashi Iwai82bc9552006-03-21 11:24:42 +01004032 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4033 return err;
4034
Richard Fish160ea0d2006-09-06 13:58:25 +02004035 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4036 return err;
4037
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004038 if (spec->num_muxes > 0) {
4039 err = stac92xx_auto_create_mux_input_ctls(codec);
4040 if (err < 0)
4041 return err;
4042 }
4043
Takashi Iwaie3c75962009-01-23 11:57:22 +01004044 err = stac92xx_add_input_source(spec);
4045 if (err < 0)
4046 return err;
4047
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004048 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004049 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004050 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004051 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004052
Takashi Iwai603c4012008-07-30 15:01:44 +02004053 if (spec->kctls.list)
4054 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004055
4056 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004057 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004058
4059 return 1;
4060}
4061
Sam Revitch62fe78e2006-05-10 15:09:17 +02004062/*
4063 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4064 * funky external mute control using GPIO pins.
4065 */
4066
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004067static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004068 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004069{
4070 unsigned int gpiostate, gpiomask, gpiodir;
4071
4072 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4073 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004074 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004075
4076 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4077 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004078 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004079
4080 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4081 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004082 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004083
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004084 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004085 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4086
4087 snd_hda_codec_write(codec, codec->afg, 0,
4088 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004089 snd_hda_codec_read(codec, codec->afg, 0,
4090 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004091
4092 msleep(1);
4093
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004094 snd_hda_codec_read(codec, codec->afg, 0,
4095 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004096}
4097
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004098static int stac92xx_add_jack(struct hda_codec *codec,
4099 hda_nid_t nid, int type)
4100{
Takashi Iwai8c8145b2009-06-22 17:00:38 +02004101#ifdef CONFIG_SND_HDA_INPUT_JACK
Takashi Iwai330ee992009-02-20 14:33:36 +01004102 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004103 int connectivity = get_defcfg_connect(def_conf);
4104 char name[32];
Takashi Iwai95c09092009-04-14 16:15:29 +02004105 int err;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004106
4107 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4108 return 0;
4109
Takashi Iwai86de7412009-07-22 16:02:46 +02004110 snprintf(name, sizeof(name), "%s at %s %s Jack",
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004111 snd_hda_get_jack_type(def_conf),
4112 snd_hda_get_jack_connectivity(def_conf),
4113 snd_hda_get_jack_location(def_conf));
4114
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004115 err = snd_hda_input_jack_add(codec, nid, type, name);
4116 if (err < 0)
Takashi Iwai95c09092009-04-14 16:15:29 +02004117 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004118#endif /* CONFIG_SND_HDA_INPUT_JACK */
Takashi Iwai95c09092009-04-14 16:15:29 +02004119 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004120}
4121
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004122static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4123 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004124{
4125 struct sigmatel_event *event;
4126
4127 snd_array_init(&spec->events, sizeof(*event), 32);
4128 event = snd_array_new(&spec->events);
4129 if (!event)
4130 return -ENOMEM;
4131 event->nid = nid;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004132 event->type = type;
4133 event->tag = spec->events.used;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004134 event->data = data;
4135
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004136 return event->tag;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004137}
4138
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004139static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
Takashi Iwai62558ce2009-07-29 14:23:09 +02004140 hda_nid_t nid)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004141{
4142 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004143 struct sigmatel_event *event = spec->events.list;
4144 int i;
4145
4146 for (i = 0; i < spec->events.used; i++, event++) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004147 if (event->nid == nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004148 return event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004149 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004150 return NULL;
4151}
4152
4153static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4154 unsigned char tag)
4155{
4156 struct sigmatel_spec *spec = codec->spec;
4157 struct sigmatel_event *event = spec->events.list;
4158 int i;
4159
4160 for (i = 0; i < spec->events.used; i++, event++) {
4161 if (event->tag == tag)
4162 return event;
4163 }
4164 return NULL;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004165}
4166
Takashi Iwai62558ce2009-07-29 14:23:09 +02004167/* check if given nid is a valid pin and no other events are assigned
4168 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4169 * Otherwise, returns zero.
4170 */
4171static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4172 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004173{
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004174 struct sigmatel_event *event;
4175 int tag;
4176
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004177 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004178 return 0;
4179 event = stac_get_event(codec, nid);
4180 if (event) {
4181 if (event->type != type)
4182 return 0;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004183 tag = event->tag;
Takashi Iwai62558ce2009-07-29 14:23:09 +02004184 } else {
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004185 tag = stac_add_event(codec->spec, nid, type, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004186 if (tag < 0)
4187 return 0;
4188 }
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004189 snd_hda_codec_write_cache(codec, nid, 0,
4190 AC_VERB_SET_UNSOLICITED_ENABLE,
4191 AC_USRSP_EN | tag);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004192 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004193}
4194
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004195static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4196{
4197 int i;
4198 for (i = 0; i < cfg->hp_outs; i++)
4199 if (cfg->hp_pins[i] == nid)
4200 return 1; /* nid is a HP-Out */
4201
4202 return 0; /* nid is not a HP-Out */
4203};
4204
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004205static void stac92xx_power_down(struct hda_codec *codec)
4206{
4207 struct sigmatel_spec *spec = codec->spec;
4208
4209 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02004210 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004211 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004212 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004213 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004214 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4215}
4216
Takashi Iwaif73d3582008-11-25 08:21:51 +01004217static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4218 int enable);
4219
Takashi Iwai014c41f2009-12-27 13:53:24 +01004220static inline int get_int_hint(struct hda_codec *codec, const char *key,
4221 int *valp)
4222{
4223 const char *p;
4224 p = snd_hda_get_hint(codec, key);
4225 if (p) {
4226 unsigned long val;
4227 if (!strict_strtoul(p, 0, &val)) {
4228 *valp = val;
4229 return 1;
4230 }
4231 }
4232 return 0;
4233}
4234
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004235/* override some hints from the hwdep entry */
4236static void stac_store_hints(struct hda_codec *codec)
4237{
4238 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004239 int val;
4240
4241 val = snd_hda_get_bool_hint(codec, "hp_detect");
4242 if (val >= 0)
4243 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004244 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004245 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4246 spec->gpio_mask;
4247 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004248 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4249 spec->gpio_mask &= spec->gpio_mask;
4250 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4251 spec->gpio_dir &= spec->gpio_mask;
4252 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4253 spec->eapd_mask &= spec->gpio_mask;
4254 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4255 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004256 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4257 if (val >= 0)
4258 spec->eapd_switch = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004259 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4260 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
Takashi Iwai043958e2009-12-26 10:36:12 +01004261 spec->gpio_mask |= spec->gpio_led;
4262 spec->gpio_dir |= spec->gpio_led;
4263 if (spec->gpio_led_polarity)
4264 spec->gpio_data |= spec->gpio_led;
4265 }
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004266}
4267
Mattc7d4b2f2005-06-27 14:59:41 +02004268static int stac92xx_init(struct hda_codec *codec)
4269{
4270 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004271 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004272 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004273 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004274
Mattc7d4b2f2005-06-27 14:59:41 +02004275 snd_hda_sequence_write(codec, spec->init);
4276
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004277 /* power down adcs initially */
4278 if (spec->powerdown_adcs)
4279 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004280 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004281 spec->adc_nids[i], 0,
4282 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004283
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004284 /* override some hints */
4285 stac_store_hints(codec);
4286
Takashi Iwaif73d3582008-11-25 08:21:51 +01004287 /* set up GPIO */
4288 gpio = spec->gpio_data;
4289 /* turn on EAPD statically when spec->eapd_switch isn't set.
4290 * otherwise, unsol event will turn it on/off dynamically
4291 */
4292 if (!spec->eapd_switch)
4293 gpio |= spec->eapd_mask;
4294 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4295
Takashi Iwai82bc9552006-03-21 11:24:42 +01004296 /* set up pins */
4297 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004298 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004299 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004300 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004301 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004302 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004303 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4304 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004305 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004306 for (i = 0; i < cfg->line_outs; i++) {
4307 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004308 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4309 }
4310 }
4311
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004312 /* force to enable the first line-out; the others are set up
4313 * in unsol_event
4314 */
4315 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004316 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004317 /* fake event to set up pins */
Takashi Iwai5f380eb2009-09-14 15:36:14 +02004318 if (cfg->hp_pins[0])
4319 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4320 else if (cfg->line_out_pins[0])
4321 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004322 } else {
4323 stac92xx_auto_init_multi_out(codec);
4324 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004325 for (i = 0; i < cfg->hp_outs; i++)
4326 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004327 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004328 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004329 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004330 if (spec->dmux_nids)
4331 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004332 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004333 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4334 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02004335 if (enable_pin_detect(codec, spec->dock_mic.pin,
4336 STAC_MIC_EVENT))
4337 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004338 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004339 for (i = 0; i < cfg->num_inputs; i++) {
4340 hda_nid_t nid = cfg->inputs[i].pin;
4341 int type = cfg->inputs[i].type;
4342 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02004343 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004344 /* for mic pins, force to initialize */
4345 pinctl = stac92xx_get_default_vref(codec, nid);
4346 pinctl |= AC_PINCTL_IN_EN;
4347 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4348 } else {
4349 pinctl = snd_hda_codec_read(codec, nid, 0,
4350 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4351 /* if PINCTL already set then skip */
4352 /* Also, if both INPUT and OUTPUT are set,
4353 * it must be a BIOS bug; need to override, too
4354 */
4355 if (!(pinctl & AC_PINCTL_IN_EN) ||
4356 (pinctl & AC_PINCTL_OUT_EN)) {
4357 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004358 pinctl |= AC_PINCTL_IN_EN;
4359 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004360 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004361 }
4362 conf = snd_hda_codec_get_pincfg(codec, nid);
4363 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4364 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4365 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01004366 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004367 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004368 for (i = 0; i < spec->num_dmics; i++)
4369 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4370 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004371 if (cfg->dig_out_pins[0])
4372 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004373 AC_PINCTL_OUT_EN);
4374 if (cfg->dig_in_pin)
4375 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4376 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004377 for (i = 0; i < spec->num_pwrs; i++) {
4378 hda_nid_t nid = spec->pwr_nids[i];
4379 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004380
Takashi Iwaieb632122008-12-19 16:39:48 +01004381 /* power on when no jack detection is available */
4382 if (!spec->hp_detect) {
4383 stac_toggle_power_map(codec, nid, 1);
4384 continue;
4385 }
4386
4387 if (is_nid_hp_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004388 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004389
Takashi Iwaif73d3582008-11-25 08:21:51 +01004390 pinctl = snd_hda_codec_read(codec, nid, 0,
4391 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4392 /* outputs are only ports capable of power management
4393 * any attempts on powering down a input port cause the
4394 * referenced VREF to act quirky.
4395 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004396 if (pinctl & AC_PINCTL_IN_EN) {
4397 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004398 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004399 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004400 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004401 def_conf = get_defcfg_connect(def_conf);
4402 /* skip any ports that don't have jacks since presence
4403 * detection is useless */
4404 if (def_conf != AC_JACK_PORT_COMPLEX) {
4405 if (def_conf != AC_JACK_PORT_NONE)
4406 stac_toggle_power_map(codec, nid, 1);
4407 continue;
4408 }
Takashi Iwai62558ce2009-07-29 14:23:09 +02004409 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4410 stac_issue_unsol_event(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004411 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004412
Takashi Iwaic21bd022010-02-08 15:16:08 +01004413 /* sync mute LED */
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004414 if (spec->gpio_led)
4415 hda_call_check_power_status(codec, 0x01);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004416 if (spec->dac_list)
4417 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004418 return 0;
4419}
4420
Takashi Iwai603c4012008-07-30 15:01:44 +02004421static void stac92xx_free_kctls(struct hda_codec *codec)
4422{
4423 struct sigmatel_spec *spec = codec->spec;
4424
4425 if (spec->kctls.list) {
4426 struct snd_kcontrol_new *kctl = spec->kctls.list;
4427 int i;
4428 for (i = 0; i < spec->kctls.used; i++)
4429 kfree(kctl[i].name);
4430 }
4431 snd_array_free(&spec->kctls);
4432}
4433
Takashi Iwai167eae52009-11-06 15:47:50 +01004434static void stac92xx_shutup(struct hda_codec *codec)
4435{
4436 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004437
Takashi Iwai92ee6162009-12-27 11:18:59 +01004438 snd_hda_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004439
4440 if (spec->eapd_mask)
4441 stac_gpio_set(codec, spec->gpio_mask,
4442 spec->gpio_dir, spec->gpio_data &
4443 ~spec->eapd_mask);
4444}
4445
Matt2f2f4252005-04-13 14:45:30 +02004446static void stac92xx_free(struct hda_codec *codec)
4447{
Mattc7d4b2f2005-06-27 14:59:41 +02004448 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004449
4450 if (! spec)
4451 return;
4452
Takashi Iwai167eae52009-11-06 15:47:50 +01004453 stac92xx_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004454 snd_hda_input_jack_free(codec);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004455 snd_array_free(&spec->events);
Richard Fish11b44bb2006-08-23 18:31:34 +02004456
Mattc7d4b2f2005-06-27 14:59:41 +02004457 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004458 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004459}
4460
Matt4e550962005-07-04 17:51:39 +02004461static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4462 unsigned int flag)
4463{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004464 unsigned int old_ctl, pin_ctl;
4465
4466 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004467 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b0438992007-05-03 20:50:03 +02004468
Takashi Iwaif9acba42007-05-29 18:01:06 +02004469 if (pin_ctl & AC_PINCTL_IN_EN) {
4470 /*
4471 * we need to check the current set-up direction of
4472 * shared input pins since they can be switched via
4473 * "xxx as Output" mixer switch
4474 */
4475 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004476 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004477 return;
4478 }
4479
Takashi Iwai8ce84192009-01-22 16:59:20 +01004480 old_ctl = pin_ctl;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02004481 /* if setting pin direction bits, clear the current
4482 direction bits first */
4483 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4484 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4485
Takashi Iwai8ce84192009-01-22 16:59:20 +01004486 pin_ctl |= flag;
4487 if (old_ctl != pin_ctl)
4488 snd_hda_codec_write_cache(codec, nid, 0,
4489 AC_VERB_SET_PIN_WIDGET_CONTROL,
4490 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004491}
4492
4493static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4494 unsigned int flag)
4495{
4496 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4497 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004498 if (pin_ctl & flag)
4499 snd_hda_codec_write_cache(codec, nid, 0,
4500 AC_VERB_SET_PIN_WIDGET_CONTROL,
4501 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004502}
4503
Takashi Iwaid56757a2009-11-18 08:00:14 +01004504static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004505{
4506 if (!nid)
4507 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004508 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004509}
4510
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004511static void stac92xx_line_out_detect(struct hda_codec *codec,
4512 int presence)
4513{
4514 struct sigmatel_spec *spec = codec->spec;
4515 struct auto_pin_cfg *cfg = &spec->autocfg;
4516 int i;
4517
4518 for (i = 0; i < cfg->line_outs; i++) {
4519 if (presence)
4520 break;
4521 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4522 if (presence) {
4523 unsigned int pinctl;
4524 pinctl = snd_hda_codec_read(codec,
4525 cfg->line_out_pins[i], 0,
4526 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4527 if (pinctl & AC_PINCTL_IN_EN)
4528 presence = 0; /* mic- or line-input */
4529 }
4530 }
4531
4532 if (presence) {
4533 /* disable speakers */
4534 for (i = 0; i < cfg->speaker_outs; i++)
4535 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4536 AC_PINCTL_OUT_EN);
4537 if (spec->eapd_mask && spec->eapd_switch)
4538 stac_gpio_set(codec, spec->gpio_mask,
4539 spec->gpio_dir, spec->gpio_data &
4540 ~spec->eapd_mask);
4541 } else {
4542 /* enable speakers */
4543 for (i = 0; i < cfg->speaker_outs; i++)
4544 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4545 AC_PINCTL_OUT_EN);
4546 if (spec->eapd_mask && spec->eapd_switch)
4547 stac_gpio_set(codec, spec->gpio_mask,
4548 spec->gpio_dir, spec->gpio_data |
4549 spec->eapd_mask);
4550 }
4551}
4552
Takashi Iwaid7a89432008-11-12 09:48:04 +01004553/* return non-zero if the hp-pin of the given array index isn't
4554 * a jack-detection target
4555 */
4556static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4557{
4558 struct auto_pin_cfg *cfg = &spec->autocfg;
4559
4560 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004561 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004562 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004563 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004564 return 1;
4565 /* ignore if the pin is set as line-out */
4566 if (cfg->hp_pins[i] == spec->hp_switch)
4567 return 1;
4568 return 0;
4569}
4570
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004571static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004572{
4573 struct sigmatel_spec *spec = codec->spec;
4574 struct auto_pin_cfg *cfg = &spec->autocfg;
4575 int i, presence;
4576
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004577 presence = 0;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01004578 if (spec->gpio_mute)
4579 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4580 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4581
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004582 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004583 if (presence)
4584 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004585 if (no_hp_sensing(spec, i))
4586 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004587 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4588 if (presence) {
4589 unsigned int pinctl;
4590 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4591 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4592 if (pinctl & AC_PINCTL_IN_EN)
4593 presence = 0; /* mic- or line-input */
4594 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004595 }
Matt4e550962005-07-04 17:51:39 +02004596
4597 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004598 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004599 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004600 stac92xx_reset_pinctl(codec, spec->hp_switch,
4601 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004602 for (i = 0; i < cfg->line_outs; i++)
4603 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4604 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004605 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004606 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004607 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004608 stac92xx_set_pinctl(codec, spec->hp_switch,
4609 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004610 for (i = 0; i < cfg->line_outs; i++)
4611 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4612 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004613 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004614 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004615 /* toggle hp outs */
4616 for (i = 0; i < cfg->hp_outs; i++) {
4617 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4618 if (no_hp_sensing(spec, i))
4619 continue;
4620 if (presence)
4621 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004622#if 0 /* FIXME */
4623/* Resetting the pinctl like below may lead to (a sort of) regressions
4624 * on some devices since they use the HP pin actually for line/speaker
4625 * outs although the default pin config shows a different pin (that is
4626 * wrong and useless).
4627 *
4628 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4629 * But, disabling the code below just works around it, and I'm too tired of
4630 * bug reports with such devices...
4631 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004632 else
4633 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004634#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004635 }
Matt4e550962005-07-04 17:51:39 +02004636}
4637
Takashi Iwaif73d3582008-11-25 08:21:51 +01004638static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4639 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004640{
4641 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004642 unsigned int idx, val;
4643
4644 for (idx = 0; idx < spec->num_pwrs; idx++) {
4645 if (spec->pwr_nids[idx] == nid)
4646 break;
4647 }
4648 if (idx >= spec->num_pwrs)
4649 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004650
4651 /* several codecs have two power down bits */
4652 if (spec->pwr_mapping)
4653 idx = spec->pwr_mapping[idx];
4654 else
4655 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004656
Takashi Iwaif73d3582008-11-25 08:21:51 +01004657 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4658 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004659 val &= ~idx;
4660 else
4661 val |= idx;
4662
4663 /* power down unused output ports */
4664 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004665}
4666
Takashi Iwaif73d3582008-11-25 08:21:51 +01004667static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4668{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004669 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004670}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004671
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004672/* get the pin connection (fixed, none, etc) */
4673static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4674{
4675 struct sigmatel_spec *spec = codec->spec;
4676 unsigned int cfg;
4677
4678 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4679 return get_defcfg_connect(cfg);
4680}
4681
4682static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004683 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004684{
4685 struct sigmatel_spec *spec = codec->spec;
4686 int idx, num;
4687 unsigned int def_conf;
4688
4689 for (num = 0; num < num_nids; num++) {
4690 for (idx = 0; idx < spec->num_pins; idx++)
4691 if (spec->pin_nids[idx] == nids[num])
4692 break;
4693 if (idx >= spec->num_pins)
4694 break;
4695 def_conf = stac_get_defcfg_connect(codec, idx);
4696 if (def_conf == AC_JACK_PORT_NONE)
4697 break;
4698 }
4699 return num;
4700}
4701
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004702static void stac92xx_mic_detect(struct hda_codec *codec)
4703{
4704 struct sigmatel_spec *spec = codec->spec;
4705 struct sigmatel_mic_route *mic;
4706
4707 if (get_pin_presence(codec, spec->ext_mic.pin))
4708 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02004709 else if (get_pin_presence(codec, spec->dock_mic.pin))
4710 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004711 else
4712 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004713 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004714 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4715 AC_VERB_SET_CONNECT_SEL,
4716 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004717 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004718 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4719 AC_VERB_SET_CONNECT_SEL,
4720 mic->mux_idx);
4721}
4722
Takashi Iwai62558ce2009-07-29 14:23:09 +02004723static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004724{
Takashi Iwai62558ce2009-07-29 14:23:09 +02004725 struct sigmatel_event *event = stac_get_event(codec, nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004726 if (!event)
4727 return;
4728 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4729}
4730
Takashi Iwai314634b2006-09-21 11:56:18 +02004731static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4732{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004733 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004734 struct sigmatel_event *event;
4735 int tag, data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004736
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004737 tag = (res >> 26) & 0x7f;
4738 event = stac_get_event_from_tag(codec, tag);
4739 if (!event)
4740 return;
4741
4742 switch (event->type) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004743 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004744 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004745 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004746 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004747 case STAC_MIC_EVENT:
4748 stac92xx_mic_detect(codec);
4749 break;
4750 }
4751
4752 switch (event->type) {
4753 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004754 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004755 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004756 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004757 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004758 if (spec->num_pwrs > 0)
4759 stac92xx_pin_sense(codec, event->nid);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004760 snd_hda_input_jack_report(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004761
4762 switch (codec->subsystem_id) {
4763 case 0x103c308f:
4764 if (event->nid == 0xb) {
4765 int pin = AC_PINCTL_IN_EN;
4766
4767 if (get_pin_presence(codec, 0xa)
4768 && get_pin_presence(codec, 0xb))
4769 pin |= AC_PINCTL_VREF_80;
4770 if (!get_pin_presence(codec, 0xb))
4771 pin |= AC_PINCTL_VREF_80;
4772
4773 /* toggle VREF state based on mic + hp pin
4774 * status
4775 */
4776 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4777 }
4778 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004779 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004780 case STAC_VREF_EVENT:
4781 data = snd_hda_codec_read(codec, codec->afg, 0,
4782 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004783 /* toggle VREF state based on GPIOx status */
4784 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004785 !!(data & (1 << event->data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004786 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004787 }
4788}
4789
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304790static int hp_blike_system(u32 subsystem_id);
4791
4792static void set_hp_led_gpio(struct hda_codec *codec)
4793{
4794 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004795 unsigned int gpio;
4796
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004797 if (spec->gpio_led)
4798 return;
4799
Takashi Iwai07f80442010-02-08 15:06:13 +01004800 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4801 gpio &= AC_GPIO_IO_COUNT;
4802 if (gpio > 3)
4803 spec->gpio_led = 0x08; /* GPIO 3 */
4804 else
4805 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304806}
4807
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004808/*
4809 * This method searches for the mute LED GPIO configuration
4810 * provided as OEM string in SMBIOS. The format of that string
4811 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4812 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4813 * that corresponds to the NOT muted state of the master volume
4814 * and G is the index of the GPIO to use as the mute LED control (0..9)
4815 * If _G portion is missing it is assigned based on the codec ID
4816 *
4817 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4818 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304819 *
4820 *
4821 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4822 * SMBIOS - at least the ones I have seen do not have them - which include
4823 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4824 * HP Pavilion dv9500t CTO.
4825 * Need more information on whether it is true across the entire series.
4826 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004827 */
Takashi Iwaidce17d42010-02-09 09:25:26 +01004828static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004829{
4830 struct sigmatel_spec *spec = codec->spec;
4831 const struct dmi_device *dev = NULL;
4832
4833 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4834 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4835 NULL, dev))) {
4836 if (sscanf(dev->name, "HP_Mute_LED_%d_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304837 &spec->gpio_led_polarity,
4838 &spec->gpio_led) == 2) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004839 spec->gpio_led = 1 << spec->gpio_led;
4840 return 1;
4841 }
4842 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304843 &spec->gpio_led_polarity) == 1) {
4844 set_hp_led_gpio(codec);
4845 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004846 }
4847 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304848
4849 /*
4850 * Fallback case - if we don't find the DMI strings,
4851 * we statically set the GPIO - if not a B-series system.
4852 */
4853 if (!hp_blike_system(codec->subsystem_id)) {
4854 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004855 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304856 return 1;
4857 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004858 }
4859 return 0;
4860}
4861
4862static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004863{
4864 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004865 case 0x103c1520:
4866 case 0x103c1521:
4867 case 0x103c1523:
4868 case 0x103c1524:
4869 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004870 case 0x103c1722:
4871 case 0x103c1723:
4872 case 0x103c1724:
4873 case 0x103c1725:
4874 case 0x103c1726:
4875 case 0x103c1727:
4876 case 0x103c1728:
4877 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004878 case 0x103c172a:
4879 case 0x103c172b:
4880 case 0x103c307e:
4881 case 0x103c307f:
4882 case 0x103c3080:
4883 case 0x103c3081:
4884 case 0x103c7007:
4885 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004886 return 1;
4887 }
4888 return 0;
4889}
4890
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004891#ifdef CONFIG_PROC_FS
4892static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4893 struct hda_codec *codec, hda_nid_t nid)
4894{
4895 if (nid == codec->afg)
4896 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4897 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4898}
4899
4900static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4901 struct hda_codec *codec,
4902 unsigned int verb)
4903{
4904 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4905 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4906}
4907
4908/* stac92hd71bxx, stac92hd73xx */
4909static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4910 struct hda_codec *codec, hda_nid_t nid)
4911{
4912 stac92hd_proc_hook(buffer, codec, nid);
4913 if (nid == codec->afg)
4914 analog_loop_proc_hook(buffer, codec, 0xfa0);
4915}
4916
4917static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4918 struct hda_codec *codec, hda_nid_t nid)
4919{
4920 if (nid == codec->afg)
4921 analog_loop_proc_hook(buffer, codec, 0xfe0);
4922}
4923
4924static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4925 struct hda_codec *codec, hda_nid_t nid)
4926{
4927 if (nid == codec->afg)
4928 analog_loop_proc_hook(buffer, codec, 0xfeb);
4929}
4930#else
4931#define stac92hd_proc_hook NULL
4932#define stac92hd7x_proc_hook NULL
4933#define stac9205_proc_hook NULL
4934#define stac927x_proc_hook NULL
4935#endif
4936
Takashi Iwaicb53c622007-08-10 17:21:45 +02004937#ifdef SND_HDA_NEEDS_RESUME
Vitaliy Kulikovd02667e2011-07-22 18:18:15 -05004938static int stac92xx_pre_resume(struct hda_codec *codec)
4939{
4940 struct sigmatel_spec *spec = codec->spec;
4941
4942 /* sync mute LED */
4943 if (spec->gpio_led)
4944 stac_gpio_set(codec, spec->gpio_mask,
4945 spec->gpio_dir, spec->gpio_data);
4946 return 0;
4947}
4948
Mattff6fdc32005-06-27 15:06:52 +02004949static int stac92xx_resume(struct hda_codec *codec)
4950{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004951 struct sigmatel_spec *spec = codec->spec;
4952
Takashi Iwai2c885872008-11-18 09:36:55 +01004953 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004954 snd_hda_codec_resume_amp(codec);
4955 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004956 /* fake event to set up pins again to override cached values */
Takashi Iwai5f380eb2009-09-14 15:36:14 +02004957 if (spec->hp_detect) {
4958 if (spec->autocfg.hp_pins[0])
4959 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4960 else if (spec->autocfg.line_out_pins[0])
4961 stac_issue_unsol_event(codec,
4962 spec->autocfg.line_out_pins[0]);
4963 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004964 /* sync mute LED */
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004965 if (spec->gpio_led)
4966 hda_call_check_power_status(codec, 0x01);
Mattff6fdc32005-06-27 15:06:52 +02004967 return 0;
4968}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004969
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004970/*
James Gardiner514bf542009-05-03 04:00:44 -04004971 * using power check for controlling mute led of HP notebooks
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004972 * check for mute state only on Speakers (nid = 0x10)
4973 *
4974 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4975 * the LED is NOT working properly !
James Gardiner514bf542009-05-03 04:00:44 -04004976 *
4977 * Changed name to reflect that it now works for any designated
4978 * model, not just HP HDX.
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004979 */
4980
4981#ifdef CONFIG_SND_HDA_POWER_SAVE
James Gardiner514bf542009-05-03 04:00:44 -04004982static int stac92xx_hp_check_power_status(struct hda_codec *codec,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004983 hda_nid_t nid)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01004984{
4985 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21bd022010-02-08 15:16:08 +01004986 int i, muted = 1;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01004987
Takashi Iwaic21bd022010-02-08 15:16:08 +01004988 for (i = 0; i < spec->multiout.num_dacs; i++) {
4989 nid = spec->multiout.dac_nids[i];
4990 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4991 HDA_AMP_MUTE)) {
4992 muted = 0; /* something heard */
4993 break;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01004994 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004995 }
4996 if (muted)
4997 spec->gpio_data &= ~spec->gpio_led; /* orange */
4998 else
4999 spec->gpio_data |= spec->gpio_led; /* white */
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005000
Takashi Iwaic21bd022010-02-08 15:16:08 +01005001 if (!spec->gpio_led_polarity) {
5002 /* LED state is inverted on these systems */
5003 spec->gpio_data ^= spec->gpio_led;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005004 }
5005
Takashi Iwaib4e81872009-11-18 17:20:24 +01005006 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
Takashi Iwaib4e81872009-11-18 17:20:24 +01005007 return 0;
5008}
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005009#endif
5010
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005011static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5012{
Takashi Iwai167eae52009-11-06 15:47:50 +01005013 stac92xx_shutup(codec);
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005014 return 0;
5015}
Mattff6fdc32005-06-27 15:06:52 +02005016#endif
5017
Takashi Iwai2b635362011-05-02 12:33:43 +02005018static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005019 .build_controls = stac92xx_build_controls,
5020 .build_pcms = stac92xx_build_pcms,
5021 .init = stac92xx_init,
5022 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02005023 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005024#ifdef SND_HDA_NEEDS_RESUME
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005025 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005026 .resume = stac92xx_resume,
Vitaliy Kulikovd02667e2011-07-22 18:18:15 -05005027 .pre_resume = stac92xx_pre_resume,
Mattff6fdc32005-06-27 15:06:52 +02005028#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005029 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005030};
5031
5032static int patch_stac9200(struct hda_codec *codec)
5033{
5034 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005035 int err;
Matt2f2f4252005-04-13 14:45:30 +02005036
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005037 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005038 if (spec == NULL)
5039 return -ENOMEM;
5040
Takashi Iwaia252c812009-12-25 22:56:20 +01005041 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005042 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005043 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005044 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005045 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005046 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5047 stac9200_models,
5048 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005049 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005050 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5051 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005052 else
5053 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005054 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005055
5056 spec->multiout.max_channels = 2;
5057 spec->multiout.num_dacs = 1;
5058 spec->multiout.dac_nids = stac9200_dac_nids;
5059 spec->adc_nids = stac9200_adc_nids;
5060 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005061 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005062 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005063 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005064 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005065
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005066 if (spec->board_config == STAC_9200_M4 ||
5067 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005068 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005069 spec->init = stac9200_eapd_init;
5070 else
5071 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005072 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005073
Takashi Iwai117f2572008-03-18 09:53:23 +01005074 if (spec->board_config == STAC_9200_PANASONIC) {
5075 spec->gpio_mask = spec->gpio_dir = 0x09;
5076 spec->gpio_data = 0x00;
5077 }
5078
Mattc7d4b2f2005-06-27 14:59:41 +02005079 err = stac9200_parse_auto_config(codec);
5080 if (err < 0) {
5081 stac92xx_free(codec);
5082 return err;
5083 }
Matt2f2f4252005-04-13 14:45:30 +02005084
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005085 /* CF-74 has no headphone detection, and the driver should *NOT*
5086 * do detection and HP/speaker toggle because the hardware does it.
5087 */
5088 if (spec->board_config == STAC_9200_PANASONIC)
5089 spec->hp_detect = 0;
5090
Matt2f2f4252005-04-13 14:45:30 +02005091 codec->patch_ops = stac92xx_patch_ops;
5092
5093 return 0;
5094}
5095
Tobin Davis8e21c342007-01-08 11:04:17 +01005096static int patch_stac925x(struct hda_codec *codec)
5097{
5098 struct sigmatel_spec *spec;
5099 int err;
5100
5101 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5102 if (spec == NULL)
5103 return -ENOMEM;
5104
Takashi Iwaia252c812009-12-25 22:56:20 +01005105 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005106 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005107 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005108 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005109 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005110
5111 /* Check first for codec ID */
5112 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5113 STAC_925x_MODELS,
5114 stac925x_models,
5115 stac925x_codec_id_cfg_tbl);
5116
5117 /* Now checks for PCI ID, if codec ID is not found */
5118 if (spec->board_config < 0)
5119 spec->board_config = snd_hda_check_board_config(codec,
5120 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005121 stac925x_models,
5122 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005123 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005124 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005125 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5126 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005127 else
5128 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005129 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005130
5131 spec->multiout.max_channels = 2;
5132 spec->multiout.num_dacs = 1;
5133 spec->multiout.dac_nids = stac925x_dac_nids;
5134 spec->adc_nids = stac925x_adc_nids;
5135 spec->mux_nids = stac925x_mux_nids;
5136 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005137 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005138 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005139 switch (codec->vendor_id) {
5140 case 0x83847632: /* STAC9202 */
5141 case 0x83847633: /* STAC9202D */
5142 case 0x83847636: /* STAC9251 */
5143 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005144 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005145 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005146 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5147 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005148 break;
5149 default:
5150 spec->num_dmics = 0;
5151 break;
5152 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005153
5154 spec->init = stac925x_core_init;
5155 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005156 spec->num_caps = 1;
5157 spec->capvols = stac925x_capvols;
5158 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005159
5160 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005161 if (!err) {
5162 if (spec->board_config < 0) {
5163 printk(KERN_WARNING "hda_codec: No auto-config is "
5164 "available, default to model=ref\n");
5165 spec->board_config = STAC_925x_REF;
5166 goto again;
5167 }
5168 err = -EINVAL;
5169 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005170 if (err < 0) {
5171 stac92xx_free(codec);
5172 return err;
5173 }
5174
5175 codec->patch_ops = stac92xx_patch_ops;
5176
5177 return 0;
5178}
5179
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005180static int patch_stac92hd73xx(struct hda_codec *codec)
5181{
5182 struct sigmatel_spec *spec;
5183 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5184 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005185 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005186
5187 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5188 if (spec == NULL)
5189 return -ENOMEM;
5190
Takashi Iwaia252c812009-12-25 22:56:20 +01005191 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005192 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005193 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005194 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005195 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5196 spec->pin_nids = stac92hd73xx_pin_nids;
5197 spec->board_config = snd_hda_check_board_config(codec,
5198 STAC_92HD73XX_MODELS,
5199 stac92hd73xx_models,
5200 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005201 /* check codec subsystem id if not found */
5202 if (spec->board_config < 0)
5203 spec->board_config =
5204 snd_hda_check_board_codec_sid_config(codec,
5205 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5206 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005207again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005208 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005209 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5210 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005211 else
5212 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005213 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005214
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005215 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005216 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5217
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005218 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005219 printk(KERN_WARNING "hda_codec: Could not determine "
5220 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005221 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005222 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005223 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005224 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005225 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005226 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005227 break;
5228 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005229 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005230 break;
5231 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005232 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5233 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005234 }
5235 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005236
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005237 spec->aloopback_mask = 0x01;
5238 spec->aloopback_shift = 8;
5239
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005240 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005241 spec->mux_nids = stac92hd73xx_mux_nids;
5242 spec->adc_nids = stac92hd73xx_adc_nids;
5243 spec->dmic_nids = stac92hd73xx_dmic_nids;
5244 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005245 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005246
5247 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5248 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005249 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005250
Takashi Iwai6479c632009-07-28 18:20:25 +02005251 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5252 spec->capvols = stac92hd73xx_capvols;
5253 spec->capsws = stac92hd73xx_capsws;
5254
Matthew Ranostaya7662642008-02-21 07:51:14 +01005255 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005256 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005257 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005258 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005259 case STAC_DELL_M6_AMIC:
5260 case STAC_DELL_M6_DMIC:
5261 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005262 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005263 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005264
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005265 switch (spec->board_config) {
5266 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005267 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005268 spec->num_dmics = 0;
5269 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005270 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005271 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005272 spec->num_dmics = 1;
5273 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005274 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005275 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5276 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005277 spec->num_dmics = 1;
5278 break;
5279 }
5280 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005281 case STAC_ALIENWARE_M17X:
5282 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5283 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5284 spec->eapd_switch = 0;
5285 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005286 default:
5287 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005288 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005289 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005290 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005291 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005292 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005293 /* GPIO0 High = Enable EAPD */
5294 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5295 spec->gpio_data = 0x01;
5296 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005297
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005298 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5299 spec->pwr_nids = stac92hd73xx_pwr_nids;
5300
Matthew Ranostayd9737752008-09-07 12:03:41 +02005301 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005302
5303 if (!err) {
5304 if (spec->board_config < 0) {
5305 printk(KERN_WARNING "hda_codec: No auto-config is "
5306 "available, default to model=ref\n");
5307 spec->board_config = STAC_92HD73XX_REF;
5308 goto again;
5309 }
5310 err = -EINVAL;
5311 }
5312
5313 if (err < 0) {
5314 stac92xx_free(codec);
5315 return err;
5316 }
5317
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005318 if (spec->board_config == STAC_92HD73XX_NO_JD)
5319 spec->hp_detect = 0;
5320
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005321 codec->patch_ops = stac92xx_patch_ops;
5322
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005323 codec->proc_widget_hook = stac92hd7x_proc_hook;
5324
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005325 return 0;
5326}
5327
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005328static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005329{
5330 if (codec->vendor_id != 0x111d7605 &&
5331 codec->vendor_id != 0x111d76d1)
5332 return 0;
5333
5334 switch (codec->subsystem_id) {
5335 case 0x103c1618:
5336 case 0x103c1619:
5337 case 0x103c161a:
5338 case 0x103c161b:
5339 case 0x103c161c:
5340 case 0x103c161d:
5341 case 0x103c161e:
5342 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005343
5344 case 0x103c162a:
5345 case 0x103c162b:
5346
5347 case 0x103c1630:
5348 case 0x103c1631:
5349
5350 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005351 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005352 case 0x103c1635:
5353
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005354 case 0x103c3587:
5355 case 0x103c3588:
5356 case 0x103c3589:
5357 case 0x103c358a:
5358
5359 case 0x103c3667:
5360 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005361 case 0x103c3669:
5362
5363 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005364 }
5365 return 0;
5366}
5367
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005368static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5369{
5370 struct sigmatel_spec *spec = codec->spec;
5371 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5372 int i;
5373
5374 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5375 spec->auto_pin_cnt++;
5376
5377 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5378 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5379 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5380 if (nid == stac92hd83xxx_dmic_nids[i]) {
5381 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5382 spec->auto_dmic_cnt++;
5383 }
5384 }
5385 }
5386}
5387
5388static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5389{
5390 struct sigmatel_spec *spec = codec->spec;
5391
5392 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5393 spec->auto_adc_cnt++;
5394}
5395
5396static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5397{
5398 int i, j;
5399 struct sigmatel_spec *spec = codec->spec;
5400
5401 for (i = 0; i < spec->auto_adc_cnt; i++) {
5402 if (get_connection_index(codec,
5403 spec->auto_adc_nids[i], nid) >= 0) {
5404 /* mux and volume for adc_nids[i] */
5405 if (!spec->auto_mux_nids[i]) {
5406 spec->auto_mux_nids[i] = nid;
5407 /* 92hd codecs capture volume is in mux */
5408 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5409 3, 0, HDA_OUTPUT);
5410 }
5411 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5412 if (get_connection_index(codec, nid,
5413 spec->auto_dmic_nids[j]) >= 0) {
5414 /* dmux for adc_nids[i] */
5415 if (!spec->auto_dmux_nids[i])
5416 spec->auto_dmux_nids[i] = nid;
5417 break;
5418 }
5419 }
5420 break;
5421 }
5422 }
5423}
5424
5425static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5426{
5427 hda_nid_t nid, end_nid;
5428 unsigned int wid_caps, wid_type;
5429 struct sigmatel_spec *spec = codec->spec;
5430
5431 end_nid = codec->start_nid + codec->num_nodes;
5432
5433 for (nid = codec->start_nid; nid < end_nid; nid++) {
5434 wid_caps = get_wcaps(codec, nid);
5435 wid_type = get_wcaps_type(wid_caps);
5436
5437 if (wid_type == AC_WID_PIN)
5438 stac92hd8x_add_pin(codec, nid);
5439
5440 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5441 stac92hd8x_add_adc(codec, nid);
5442 }
5443
5444 for (nid = codec->start_nid; nid < end_nid; nid++) {
5445 wid_caps = get_wcaps(codec, nid);
5446 wid_type = get_wcaps_type(wid_caps);
5447
5448 if (wid_type == AC_WID_AUD_SEL)
5449 stac92hd8x_add_mux(codec, nid);
5450 }
5451
5452 spec->pin_nids = spec->auto_pin_nids;
5453 spec->num_pins = spec->auto_pin_cnt;
5454 spec->adc_nids = spec->auto_adc_nids;
5455 spec->num_adcs = spec->auto_adc_cnt;
5456 spec->capvols = spec->auto_capvols;
5457 spec->capsws = spec->auto_capvols;
5458 spec->num_caps = spec->auto_adc_cnt;
5459 spec->mux_nids = spec->auto_mux_nids;
5460 spec->num_muxes = spec->auto_adc_cnt;
5461 spec->dmux_nids = spec->auto_dmux_nids;
5462 spec->num_dmuxes = spec->auto_adc_cnt;
5463 spec->dmic_nids = spec->auto_dmic_nids;
5464 spec->num_dmics = spec->auto_dmic_cnt;
5465}
5466
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005467static int patch_stac92hd83xxx(struct hda_codec *codec)
5468{
5469 struct sigmatel_spec *spec;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005470 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005471 int err;
Matthew Ranostay65557f32009-01-20 16:50:25 -05005472 int num_dacs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005473
5474 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5475 if (spec == NULL)
5476 return -ENOMEM;
5477
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005478 if (hp_bnb2011_with_dock(codec)) {
5479 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5480 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5481 }
5482
Charles1cc9e8f4c2010-10-18 16:22:00 +08005483 /* reset pin power-down; Windows may leave these bits after reboot */
5484 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7EC, 0);
5485 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7ED, 0);
Takashi Iwaia252c812009-12-25 22:56:20 +01005486 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005487 codec->spec = spec;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005488
5489 stac92hd8x_fill_auto_spec(codec);
5490
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01005491 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005492 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005493 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005494 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5495 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5496 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005497 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005498 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005499
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005500 spec->board_config = snd_hda_check_board_config(codec,
5501 STAC_92HD83XXX_MODELS,
5502 stac92hd83xxx_models,
5503 stac92hd83xxx_cfg_tbl);
5504again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005505 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005506 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5507 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005508 else
5509 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005510 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005511
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005512 switch (codec->vendor_id) {
David Henningsson89feca12010-10-13 15:48:24 +02005513 case 0x111d76d1:
5514 case 0x111d76d9:
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06005515 case 0x111d76e5:
Charles Chin36706002010-01-29 12:05:51 +01005516 case 0x111d7666:
5517 case 0x111d7667:
5518 case 0x111d7668:
5519 case 0x111d7669:
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06005520 case 0x111d76e3:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005521 case 0x111d7604:
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01005522 case 0x111d76d4:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005523 case 0x111d7605:
Matthew Ranostayff2e7332009-04-01 14:49:48 -04005524 case 0x111d76d5:
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005525 case 0x111d76e7:
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05005526 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5527 break;
5528 spec->num_pwrs = 0;
5529 break;
5530 }
5531
Takashi Iwaib4e81872009-11-18 17:20:24 +01005532 codec->patch_ops = stac92xx_patch_ops;
5533
Takashi Iwaidce17d42010-02-09 09:25:26 +01005534 if (find_mute_led_gpio(codec, 0))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005535 snd_printd("mute LED gpio %d polarity %d\n",
5536 spec->gpio_led,
5537 spec->gpio_led_polarity);
5538
Takashi Iwaib4e81872009-11-18 17:20:24 +01005539#ifdef CONFIG_SND_HDA_POWER_SAVE
5540 if (spec->gpio_led) {
5541 spec->gpio_mask |= spec->gpio_led;
5542 spec->gpio_dir |= spec->gpio_led;
5543 spec->gpio_data |= spec->gpio_led;
5544 /* register check_power_status callback. */
5545 codec->patch_ops.check_power_status =
Takashi Iwaic21bd022010-02-08 15:16:08 +01005546 stac92xx_hp_check_power_status;
Takashi Iwaib4e81872009-11-18 17:20:24 +01005547 }
5548#endif
5549
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005550 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5551 if (!err) {
5552 if (spec->board_config < 0) {
5553 printk(KERN_WARNING "hda_codec: No auto-config is "
5554 "available, default to model=ref\n");
5555 spec->board_config = STAC_92HD83XXX_REF;
5556 goto again;
5557 }
5558 err = -EINVAL;
5559 }
5560
5561 if (err < 0) {
5562 stac92xx_free(codec);
5563 return err;
5564 }
5565
Charles Chin04b5efe2010-02-04 10:28:02 +01005566 /* docking output support */
5567 num_dacs = snd_hda_get_connections(codec, 0xF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005568 conn, STAC92HD83_DAC_COUNT + 1) - 1;
Charles Chin04b5efe2010-02-04 10:28:02 +01005569 /* skip non-DAC connections */
5570 while (num_dacs >= 0 &&
5571 (get_wcaps_type(get_wcaps(codec, conn[num_dacs]))
5572 != AC_WID_AUD_OUT))
5573 num_dacs--;
5574 /* set port E and F to select the last DAC */
5575 if (num_dacs >= 0) {
5576 snd_hda_codec_write_cache(codec, 0xE, 0,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005577 AC_VERB_SET_CONNECT_SEL, num_dacs);
Charles Chin04b5efe2010-02-04 10:28:02 +01005578 snd_hda_codec_write_cache(codec, 0xF, 0,
5579 AC_VERB_SET_CONNECT_SEL, num_dacs);
5580 }
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05005581
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005582 codec->proc_widget_hook = stac92hd_proc_hook;
5583
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005584 return 0;
5585}
5586
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005587static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5588 hda_nid_t dig0pin)
5589{
5590 struct sigmatel_spec *spec = codec->spec;
5591 int idx;
5592
5593 for (idx = 0; idx < spec->num_pins; idx++)
5594 if (spec->pin_nids[idx] == dig0pin)
5595 break;
5596 if ((idx + 2) >= spec->num_pins)
5597 return 0;
5598
5599 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005600 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005601 return 2;
5602
5603 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005604 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005605 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005606 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005607 return 1;
5608 else
5609 return 0;
5610}
5611
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005612/* HP dv7 bass switch - GPIO5 */
5613#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5614static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5615 struct snd_ctl_elem_value *ucontrol)
5616{
5617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5618 struct sigmatel_spec *spec = codec->spec;
5619 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5620 return 0;
5621}
5622
5623static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5624 struct snd_ctl_elem_value *ucontrol)
5625{
5626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5627 struct sigmatel_spec *spec = codec->spec;
5628 unsigned int gpio_data;
5629
5630 gpio_data = (spec->gpio_data & ~0x20) |
5631 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5632 if (gpio_data == spec->gpio_data)
5633 return 0;
5634 spec->gpio_data = gpio_data;
5635 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5636 return 1;
5637}
5638
Takashi Iwai2b635362011-05-02 12:33:43 +02005639static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5641 .info = stac_hp_bass_gpio_info,
5642 .get = stac_hp_bass_gpio_get,
5643 .put = stac_hp_bass_gpio_put,
5644};
5645
5646static int stac_add_hp_bass_switch(struct hda_codec *codec)
5647{
5648 struct sigmatel_spec *spec = codec->spec;
5649
5650 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5651 "Bass Speaker Playback Switch", 0))
5652 return -ENOMEM;
5653
5654 spec->gpio_mask |= 0x20;
5655 spec->gpio_dir |= 0x20;
5656 spec->gpio_data |= 0x20;
5657 return 0;
5658}
5659
Matthew Ranostaye035b842007-11-06 11:53:55 +01005660static int patch_stac92hd71bxx(struct hda_codec *codec)
5661{
5662 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02005663 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005664 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005665 int err = 0;
5666
5667 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5668 if (spec == NULL)
5669 return -ENOMEM;
5670
Takashi Iwaia252c812009-12-25 22:56:20 +01005671 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005672 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005673 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005674 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005675 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5676 switch (codec->vendor_id) {
5677 case 0x111d76b6:
5678 case 0x111d76b7:
5679 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5680 break;
5681 case 0x111d7603:
5682 case 0x111d7608:
5683 /* On 92HD75Bx 0x27 isn't a pin nid */
5684 spec->num_pins--;
5685 /* fallthrough */
5686 default:
5687 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5688 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005689 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005690 spec->board_config = snd_hda_check_board_config(codec,
5691 STAC_92HD71BXX_MODELS,
5692 stac92hd71bxx_models,
5693 stac92hd71bxx_cfg_tbl);
5694again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005695 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005696 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5697 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005698 else
5699 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005700 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005701
Takashi Iwaifc64b262009-09-14 15:33:01 +02005702 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005703 /* GPIO0 = EAPD */
5704 spec->gpio_mask = 0x01;
5705 spec->gpio_dir = 0x01;
5706 spec->gpio_data = 0x01;
5707 }
5708
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005709 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5710 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5711
Takashi Iwai6479c632009-07-28 18:20:25 +02005712 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5713 spec->capvols = stac92hd71bxx_capvols;
5714 spec->capsws = stac92hd71bxx_capsws;
5715
Matthew Ranostay541eee82007-12-14 12:08:04 +01005716 switch (codec->vendor_id) {
5717 case 0x111d76b6: /* 4 Port without Analog Mixer */
5718 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005719 unmute_init++;
5720 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005721 case 0x111d76b4: /* 6 Port without Analog Mixer */
5722 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005723 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005724 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005725 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005726 stac92hd71bxx_dmic_nids,
5727 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005728 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005729 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005730 switch (spec->board_config) {
5731 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005732 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005733 err = stac_add_event(spec, codec->afg,
5734 STAC_VREF_EVENT, 0x02);
5735 if (err < 0)
5736 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005737 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005738 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5739 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005740 AC_VERB_SET_UNSOLICITED_ENABLE,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005741 AC_USRSP_EN | err);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005742 spec->gpio_mask |= 0x02;
5743 break;
5744 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005745 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005746 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005747 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005748
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005749 /* no output amps */
5750 spec->num_pwrs = 0;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005751 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005752 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005753 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005754 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5755 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02005756 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005757 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005758 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005759 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005760 break;
5761 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005762 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005763 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005764
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005765 /* no output amps */
5766 spec->num_pwrs = 0;
5767 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005768 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005769 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005770 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005771 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005772 stac92hd71bxx_dmic_nids,
5773 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005774 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005775 }
5776
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005777 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5778 snd_hda_sequence_write_cache(codec, unmute_init);
5779
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005780 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005781 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005782 spec->aloopback_shift = 0;
5783
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005784 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005785 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005786 spec->mux_nids = stac92hd71bxx_mux_nids;
5787 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005788 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005789 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005790
5791 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5792 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005793 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005794 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005795
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305796 snd_printdd("Found board config: %d\n", spec->board_config);
5797
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005798 switch (spec->board_config) {
5799 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005800 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005801 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea7152008-10-09 08:37:28 -04005802 stac92xx_auto_set_pinctl(codec, 0x0e,
5803 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005804 /* fallthru */
5805 case STAC_DELL_M4_2:
5806 spec->num_dmics = 0;
5807 spec->num_smuxes = 0;
5808 spec->num_dmuxes = 0;
5809 break;
5810 case STAC_DELL_M4_1:
5811 case STAC_DELL_M4_3:
5812 spec->num_dmics = 1;
5813 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005814 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005815 break;
James Gardiner514bf542009-05-03 04:00:44 -04005816 case STAC_HP_DV4_1222NR:
5817 spec->num_dmics = 1;
5818 /* I don't know if it needs 1 or 2 smuxes - will wait for
5819 * bug reports to fix if needed
5820 */
5821 spec->num_smuxes = 1;
5822 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005823 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005824 case STAC_HP_DV4:
5825 spec->gpio_led = 0x01;
5826 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005827 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005828 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005829 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005830 /* HP dv6 gives the headphone pin as a line-out. Thus we
5831 * need to set hp_detect flag here to force to enable HP
5832 * detection.
5833 */
5834 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005835 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005836 case STAC_HP_HDX:
5837 spec->num_dmics = 1;
5838 spec->num_dmuxes = 1;
5839 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005840 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005841 break;
5842 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005843
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005844 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005845 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5846 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5847 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5848 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5849 /* It was changed in the BIOS to just satisfy MS DTM.
5850 * Lets turn it back into slaved HP
5851 */
5852 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5853 | (AC_JACK_HP_OUT <<
5854 AC_DEFCFG_DEVICE_SHIFT);
5855 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5856 | AC_DEFCFG_SEQUENCE)))
5857 | 0x1f;
5858 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5859 }
5860 }
5861
Takashi Iwaidce17d42010-02-09 09:25:26 +01005862 if (find_mute_led_gpio(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005863 snd_printd("mute LED gpio %d polarity %d\n",
5864 spec->gpio_led,
5865 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005866
Takashi Iwai86d190e2009-05-26 15:18:58 +02005867#ifdef CONFIG_SND_HDA_POWER_SAVE
5868 if (spec->gpio_led) {
5869 spec->gpio_mask |= spec->gpio_led;
5870 spec->gpio_dir |= spec->gpio_led;
5871 spec->gpio_data |= spec->gpio_led;
Christoph Plattner443e26d2009-03-10 00:05:56 +01005872 /* register check_power_status callback. */
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005873 codec->patch_ops.check_power_status =
Takashi Iwai86d190e2009-05-26 15:18:58 +02005874 stac92xx_hp_check_power_status;
5875 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005876#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005877
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005878 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005879
Herton Ronaldo Krzesinski29d4ab42009-02-04 11:37:27 -05005880 err = stac92xx_parse_auto_config(codec, 0x21, 0);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005881 if (!err) {
5882 if (spec->board_config < 0) {
5883 printk(KERN_WARNING "hda_codec: No auto-config is "
5884 "available, default to model=ref\n");
5885 spec->board_config = STAC_92HD71BXX_REF;
5886 goto again;
5887 }
5888 err = -EINVAL;
5889 }
5890
5891 if (err < 0) {
5892 stac92xx_free(codec);
5893 return err;
5894 }
5895
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005896 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005897 if (spec->board_config == STAC_HP_DV4 ||
5898 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005899 unsigned int cap;
5900 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5901 cap &= AC_GPIO_IO_COUNT;
5902 if (cap >= 6)
5903 stac_add_hp_bass_switch(codec);
5904 }
5905
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005906 codec->proc_widget_hook = stac92hd7x_proc_hook;
5907
Matthew Ranostaye035b842007-11-06 11:53:55 +01005908 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005909}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005910
Matt2f2f4252005-04-13 14:45:30 +02005911static int patch_stac922x(struct hda_codec *codec)
5912{
5913 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005914 int err;
Matt2f2f4252005-04-13 14:45:30 +02005915
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005916 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005917 if (spec == NULL)
5918 return -ENOMEM;
5919
Takashi Iwaia252c812009-12-25 22:56:20 +01005920 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005921 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005922 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005923 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005924 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005925 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5926 stac922x_models,
5927 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005928 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01005929 spec->gpio_mask = spec->gpio_dir = 0x03;
5930 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005931 /* Intel Macs have all same PCI SSID, so we need to check
5932 * codec SSID to distinguish the exact models
5933 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005934 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005935 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005936
5937 case 0x106b0800:
5938 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005939 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005940 case 0x106b0600:
5941 case 0x106b0700:
5942 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005943 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005944 case 0x106b0e00:
5945 case 0x106b0f00:
5946 case 0x106b1600:
5947 case 0x106b1700:
5948 case 0x106b0200:
5949 case 0x106b1e00:
5950 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005951 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005952 case 0x106b1a00:
5953 case 0x00000100:
5954 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005955 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005956 case 0x106b0a00:
5957 case 0x106b2200:
5958 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005959 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005960 default:
5961 spec->board_config = STAC_INTEL_MAC_V3;
5962 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005963 }
5964 }
5965
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005966 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005967 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005968 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5969 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005970 else
5971 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01005972 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005973
Matt2f2f4252005-04-13 14:45:30 +02005974 spec->adc_nids = stac922x_adc_nids;
5975 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005976 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005977 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005978 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005979 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005980
5981 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005982
5983 spec->num_caps = STAC922X_NUM_CAPS;
5984 spec->capvols = stac922x_capvols;
5985 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005986
5987 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005988
Matt Porter3cc08dc2006-01-23 15:27:49 +01005989 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005990 if (!err) {
5991 if (spec->board_config < 0) {
5992 printk(KERN_WARNING "hda_codec: No auto-config is "
5993 "available, default to model=ref\n");
5994 spec->board_config = STAC_D945_REF;
5995 goto again;
5996 }
5997 err = -EINVAL;
5998 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01005999 if (err < 0) {
6000 stac92xx_free(codec);
6001 return err;
6002 }
6003
6004 codec->patch_ops = stac92xx_patch_ops;
6005
Takashi Iwai807a46362007-05-29 19:01:37 +02006006 /* Fix Mux capture level; max to 2 */
6007 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6008 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6009 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6010 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6011 (0 << AC_AMPCAP_MUTE_SHIFT));
6012
Matt Porter3cc08dc2006-01-23 15:27:49 +01006013 return 0;
6014}
6015
6016static int patch_stac927x(struct hda_codec *codec)
6017{
6018 struct sigmatel_spec *spec;
6019 int err;
6020
6021 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6022 if (spec == NULL)
6023 return -ENOMEM;
6024
Takashi Iwaia252c812009-12-25 22:56:20 +01006025 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006026 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006027 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006028 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006029 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006030 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006031 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6032 stac927x_models,
6033 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006034 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006035 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006036 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6037 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006038 else
6039 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01006040 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006041
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006042 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006043 spec->adc_nids = stac927x_adc_nids;
6044 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6045 spec->mux_nids = stac927x_mux_nids;
6046 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006047 spec->smux_nids = stac927x_smux_nids;
6048 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006049 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006050 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006051 spec->multiout.dac_nids = spec->dac_nids;
6052
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006053 if (spec->board_config != STAC_D965_REF) {
6054 /* GPIO0 High = Enable EAPD */
6055 spec->eapd_mask = spec->gpio_mask = 0x01;
6056 spec->gpio_dir = spec->gpio_data = 0x01;
6057 }
6058
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006059 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02006060 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006061 case STAC_D965_5ST:
6062 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006063 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02006064 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006065 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006066 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006067 switch (codec->subsystem_id) {
6068 case 0x10280209:
6069 case 0x1028022e:
6070 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006071 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006072 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006073 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01006074 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01006075 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01006076 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006077 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006078 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01006079 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006080 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006081 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006082 if (codec->subsystem_id != 0x1028022f) {
6083 /* GPIO2 High = Enable EAPD */
6084 spec->eapd_mask = spec->gpio_mask = 0x04;
6085 spec->gpio_dir = spec->gpio_data = 0x04;
6086 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006087 spec->dmic_nids = stac927x_dmic_nids;
6088 spec->num_dmics = STAC927X_NUM_DMICS;
6089
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02006090 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006091 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006092 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006093 break;
Takashi Iwai54930532009-10-11 17:38:29 +02006094 case STAC_927X_VOLKNOB:
6095 spec->num_dmics = 0;
6096 spec->init = stac927x_volknob_core_init;
6097 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006098 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006099 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006100 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006101 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006102 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006103
Takashi Iwai6479c632009-07-28 18:20:25 +02006104 spec->num_caps = STAC927X_NUM_CAPS;
6105 spec->capvols = stac927x_capvols;
6106 spec->capsws = stac927x_capsws;
6107
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006108 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006109 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006110 spec->aloopback_mask = 0x40;
6111 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006112 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006113
Matt Porter3cc08dc2006-01-23 15:27:49 +01006114 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006115 if (!err) {
6116 if (spec->board_config < 0) {
6117 printk(KERN_WARNING "hda_codec: No auto-config is "
6118 "available, default to model=ref\n");
6119 spec->board_config = STAC_D965_REF;
6120 goto again;
6121 }
6122 err = -EINVAL;
6123 }
Mattc7d4b2f2005-06-27 14:59:41 +02006124 if (err < 0) {
6125 stac92xx_free(codec);
6126 return err;
6127 }
Matt2f2f4252005-04-13 14:45:30 +02006128
6129 codec->patch_ops = stac92xx_patch_ops;
6130
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006131 codec->proc_widget_hook = stac927x_proc_hook;
6132
Takashi Iwai52987652008-01-16 16:09:47 +01006133 /*
6134 * !!FIXME!!
6135 * The STAC927x seem to require fairly long delays for certain
6136 * command sequences. With too short delays (even if the answer
6137 * is set to RIRB properly), it results in the silence output
6138 * on some hardwares like Dell.
6139 *
6140 * The below flag enables the longer delay (see get_response
6141 * in hda_intel.c).
6142 */
6143 codec->bus->needs_damn_long_delay = 1;
6144
Takashi Iwaie28d8322008-12-17 13:48:29 +01006145 /* no jack detecion for ref-no-jd model */
6146 if (spec->board_config == STAC_D965_REF_NO_JD)
6147 spec->hp_detect = 0;
6148
Matt2f2f4252005-04-13 14:45:30 +02006149 return 0;
6150}
6151
Matt Porterf3302a52006-07-31 12:49:34 +02006152static int patch_stac9205(struct hda_codec *codec)
6153{
6154 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006155 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006156
6157 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6158 if (spec == NULL)
6159 return -ENOMEM;
6160
Takashi Iwaia252c812009-12-25 22:56:20 +01006161 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006162 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006163 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006164 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006165 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006166 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6167 stac9205_models,
6168 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006169 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006170 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006171 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6172 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006173 else
6174 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f341a2008-11-18 10:38:56 +01006175 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006176
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006177 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006178 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006179 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006180 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006181 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006182 spec->smux_nids = stac9205_smux_nids;
6183 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006184 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006185 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006186 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006187 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006188 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006189
6190 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006191 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006192
Takashi Iwai6479c632009-07-28 18:20:25 +02006193 spec->num_caps = STAC9205_NUM_CAPS;
6194 spec->capvols = stac9205_capvols;
6195 spec->capsws = stac9205_capsws;
6196
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006197 spec->aloopback_mask = 0x40;
6198 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006199 /* Turn on/off EAPD per HP plugging */
6200 if (spec->board_config != STAC_9205_EAPD)
6201 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006202 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006203
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006204 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006205 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006206 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006207 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6208 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006209
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006210 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006211 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6212 if (err < 0)
6213 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006214 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006215 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6216 snd_hda_codec_write_cache(codec, codec->afg, 0,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006217 AC_VERB_SET_UNSOLICITED_ENABLE,
6218 AC_USRSP_EN | err);
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006219
6220 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006221 spec->eapd_mask = 0x01;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006222 spec->gpio_mask = 0x1b;
6223 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006224 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006225 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006226 */
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006227 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006228 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006229 case STAC_9205_REF:
6230 /* SPDIF-In enabled */
6231 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006232 default:
6233 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006234 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe5195c2008-01-29 15:28:44 +01006235 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006236 break;
6237 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006238
Matt Porterf3302a52006-07-31 12:49:34 +02006239 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006240 if (!err) {
6241 if (spec->board_config < 0) {
6242 printk(KERN_WARNING "hda_codec: No auto-config is "
6243 "available, default to model=ref\n");
6244 spec->board_config = STAC_9205_REF;
6245 goto again;
6246 }
6247 err = -EINVAL;
6248 }
Matt Porterf3302a52006-07-31 12:49:34 +02006249 if (err < 0) {
6250 stac92xx_free(codec);
6251 return err;
6252 }
6253
6254 codec->patch_ops = stac92xx_patch_ops;
6255
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006256 codec->proc_widget_hook = stac9205_proc_hook;
6257
Matt Porterf3302a52006-07-31 12:49:34 +02006258 return 0;
6259}
6260
Matt2f2f4252005-04-13 14:45:30 +02006261/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006262 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006263 */
6264
Takashi Iwai2b635362011-05-02 12:33:43 +02006265static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6268 {}
6269};
6270
Takashi Iwai2b635362011-05-02 12:33:43 +02006271static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006272 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6273 0x11, 0x13, 0x14,
6274};
6275
Takashi Iwai2b635362011-05-02 12:33:43 +02006276static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006277 0x8 /*,0x6*/
6278};
6279
Takashi Iwai2b635362011-05-02 12:33:43 +02006280static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006281 0x15
6282};
6283
Takashi Iwai2b635362011-05-02 12:33:43 +02006284static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006285 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6286};
6287#define stac9872_capsws stac9872_capvols
6288
Takashi Iwai2b635362011-05-02 12:33:43 +02006289static const unsigned int stac9872_vaio_pin_configs[9] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006290 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6291 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6292 0x90a7013e
6293};
6294
Takashi Iwaiea734962011-01-17 11:29:34 +01006295static const char * const stac9872_models[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006296 [STAC_9872_AUTO] = "auto",
6297 [STAC_9872_VAIO] = "vaio",
6298};
6299
Takashi Iwai2b635362011-05-02 12:33:43 +02006300static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006301 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6302};
6303
Takashi Iwai2b635362011-05-02 12:33:43 +02006304static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006305 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6306 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006307 {} /* terminator */
6308};
6309
Guillaume Munch6d859062006-08-22 17:15:47 +02006310static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006311{
6312 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006313 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006314
Takashi Iwaidb064e52006-03-16 16:04:58 +01006315 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6316 if (spec == NULL)
6317 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006318 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006319 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006320 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006321 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6322 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006323
6324 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6325 stac9872_models,
6326 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006327 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006328 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6329 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006330 else
6331 stac92xx_set_config_regs(codec,
6332 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006333
Takashi Iwai1e137f92009-01-21 07:41:22 +01006334 spec->multiout.dac_nids = spec->dac_nids;
6335 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6336 spec->adc_nids = stac9872_adc_nids;
6337 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6338 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006339 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006340 spec->num_caps = 1;
6341 spec->capvols = stac9872_capvols;
6342 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006343
Takashi Iwai1e137f92009-01-21 07:41:22 +01006344 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
6345 if (err < 0) {
6346 stac92xx_free(codec);
6347 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006348 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006349 spec->input_mux = &spec->private_imux;
6350 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006351 return 0;
6352}
6353
6354
6355/*
Matt2f2f4252005-04-13 14:45:30 +02006356 * patch entries
6357 */
Takashi Iwai2b635362011-05-02 12:33:43 +02006358static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006359 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6360 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6361 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6362 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6363 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6364 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6365 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006366 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6367 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6368 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6369 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6370 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6371 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006372 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6373 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6374 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6375 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6376 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6377 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6378 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6379 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6380 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6381 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006382 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6383 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6384 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6385 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6386 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6387 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006388 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6389 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006390 /* The following does not take into account .id=0x83847661 when subsys =
6391 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6392 * currently not fully supported.
6393 */
6394 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6395 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6396 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006397 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006398 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6399 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6400 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6401 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6402 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6403 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6404 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6405 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006406 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006407 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006408 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006409 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006410 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02006411 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6412 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006413 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6414 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6415 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6416 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006417 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006418 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6419 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006420 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006421 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6422 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6423 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6424 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6425 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6426 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6427 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6428 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02006429 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6430 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6431 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6432 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6433 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6434 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6435 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6436 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6437 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6438 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6439 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6440 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6441 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6442 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6443 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006444 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06006445 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6446 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006447 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02006448 {} /* terminator */
6449};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006450
6451MODULE_ALIAS("snd-hda-codec-id:8384*");
6452MODULE_ALIAS("snd-hda-codec-id:111d*");
6453
6454MODULE_LICENSE("GPL");
6455MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6456
6457static struct hda_codec_preset_list sigmatel_list = {
6458 .preset = snd_hda_preset_sigmatel,
6459 .owner = THIS_MODULE,
6460};
6461
6462static int __init patch_sigmatel_init(void)
6463{
6464 return snd_hda_add_codec_preset(&sigmatel_list);
6465}
6466
6467static void __exit patch_sigmatel_exit(void)
6468{
6469 snd_hda_delete_codec_preset(&sigmatel_list);
6470}
6471
6472module_init(patch_sigmatel_init)
6473module_exit(patch_sigmatel_exit)