blob: 884f8ad351fd713510125bf023921cad030db492 [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>
Paul Gortmakerda155d52011-07-15 12:38:28 -040032#include <linux/module.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020034#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040035#include <sound/jack.h>
Clemens Ladischa74ccea2010-10-22 15:52:34 +020036#include <sound/tlv.h>
Matt2f2f4252005-04-13 14:45:30 +020037#include "hda_codec.h"
38#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020039#include "hda_beep.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020040#include "hda_jack.h"
Matt2f2f4252005-04-13 14:45:30 +020041
Takashi Iwaic6e4c662008-11-25 11:58:19 +010042enum {
43 STAC_VREF_EVENT = 1,
44 STAC_INSERT_EVENT,
45 STAC_PWR_EVENT,
46 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020047 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020048 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010049};
Matt4e550962005-07-04 17:51:39 +020050
Takashi Iwaif5fcc132006-11-24 17:07:44 +010051enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010052 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010053 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010054 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020055 STAC_9200_DELL_D21,
56 STAC_9200_DELL_D22,
57 STAC_9200_DELL_D23,
58 STAC_9200_DELL_M21,
59 STAC_9200_DELL_M22,
60 STAC_9200_DELL_M23,
61 STAC_9200_DELL_M24,
62 STAC_9200_DELL_M25,
63 STAC_9200_DELL_M26,
64 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020065 STAC_9200_M4,
66 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010067 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_9200_MODELS
69};
70
71enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010072 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010073 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020074 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020075 STAC_9205_DELL_M43,
76 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010077 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010078 STAC_9205_MODELS
79};
80
81enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010082 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010083 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010084 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080085 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010086 STAC_DELL_M6_AMIC,
87 STAC_DELL_M6_DMIC,
88 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050089 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020090 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010091 STAC_92HD73XX_MODELS
92};
93
94enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010095 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020096 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050097 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050098 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010099 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -0500100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -0600101 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600102 STAC_HP_ZEPHYR,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200103 STAC_92HD83XXX_MODELS
104};
105
106enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100107 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100108 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100109 STAC_DELL_M4_1,
110 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500111 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400112 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200113 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100114 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100115 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400116 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100117 STAC_92HD71BXX_MODELS
118};
119
120enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100121 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100122 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200123 STAC_M1,
124 STAC_M1_2,
125 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100126 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200127 STAC_M3,
128 STAC_M5,
129 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100130 STAC_925x_MODELS
131};
132
133enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100134 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100135 STAC_D945_REF,
136 STAC_D945GTP3,
137 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200138 STAC_INTEL_MAC_V1,
139 STAC_INTEL_MAC_V2,
140 STAC_INTEL_MAC_V3,
141 STAC_INTEL_MAC_V4,
142 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800143 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
144 * is given, one of the above models will be
145 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200146 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100147 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100148 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100149 STAC_MACBOOK_PRO_V1,
150 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200151 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200152 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300153 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200154 STAC_922X_DELL_D81,
155 STAC_922X_DELL_D82,
156 STAC_922X_DELL_M81,
157 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100158 STAC_922X_MODELS
159};
160
161enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100162 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100163 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100164 STAC_D965_REF,
165 STAC_D965_3ST,
166 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200167 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200168 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100169 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200170 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100171 STAC_927X_MODELS
172};
Matt Porter403d1942005-11-29 15:00:51 +0100173
Takashi Iwai307282c2009-03-12 18:17:58 +0100174enum {
175 STAC_9872_AUTO,
176 STAC_9872_VAIO,
177 STAC_9872_MODELS
178};
179
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200180struct sigmatel_mic_route {
181 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200182 signed char mux_idx;
183 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200184};
185
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600186#define MAX_PINS_NUM 16
187#define MAX_ADCS_NUM 4
188#define MAX_DMICS_NUM 4
189
Matt2f2f4252005-04-13 14:45:30 +0200190struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100191 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200192 unsigned int num_mixers;
193
Matt Porter403d1942005-11-29 15:00:51 +0100194 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500195 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200196 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100197 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100198 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400199 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100200 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200201 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100202 unsigned int linear_tone_beep:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200203
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100204 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200205 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100206 unsigned int gpio_mask;
207 unsigned int gpio_dir;
208 unsigned int gpio_data;
209 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200210 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100211 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100212 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500213 unsigned int vref_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100214
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200215 /* stream */
216 unsigned int stream_delay;
217
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100218 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200219 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100220 unsigned char aloopback_mask;
221 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200222
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100223 /* power management */
224 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200225 const hda_nid_t *pwr_nids;
226 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227
Matt2f2f4252005-04-13 14:45:30 +0200228 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100229 struct hda_input_mux *mono_mux;
230 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200231 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100232 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100233 hda_nid_t hp_dacs[5];
234 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200235
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100236 int volume_offset;
237
Matt2f2f4252005-04-13 14:45:30 +0200238 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200239 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200240 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200241 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200242 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200243 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200244 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200245 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100246 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200247 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200248 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200249 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200250
Takashi Iwai2b635362011-05-02 12:33:43 +0200251 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
252 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200253 unsigned int num_caps; /* number of capture volume/switch elements */
254
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200255 struct sigmatel_mic_route ext_mic;
256 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200257 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200258
Takashi Iwaiea734962011-01-17 11:29:34 +0100259 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200260
Mattdabbed62005-06-14 10:19:34 +0200261 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100262 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200263 hda_nid_t anabeep_nid;
264 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200265
Matt2f2f4252005-04-13 14:45:30 +0200266 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200267 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200268 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200269
270 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200271 const struct hda_verb *init;
272 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200273
274 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200275 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100276 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200277 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100278 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200279 struct hda_input_mux *sinput_mux;
280 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400281 unsigned int cur_amux;
282 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200283 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200284
Matt Porter403d1942005-11-29 15:00:51 +0100285 /* i/o switches */
286 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200287 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100288 hda_nid_t line_switch; /* shared line-in for input and output */
289 hda_nid_t mic_switch; /* shared mic-in for input and output */
290 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200291 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200292
Mattc7d4b2f2005-06-27 14:59:41 +0200293 struct hda_pcm pcm_rec[2]; /* PCM information */
294
295 /* dynamic controls and input_mux */
296 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200297 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200298 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200299 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200300 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100301 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600302
303 /* auto spec */
304 unsigned auto_pin_cnt;
305 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
306 unsigned auto_adc_cnt;
307 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
308 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
309 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
310 unsigned long auto_capvols[MAX_ADCS_NUM];
311 unsigned auto_dmic_cnt;
312 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100313
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100314 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200315};
316
Takashi Iwai2b635362011-05-02 12:33:43 +0200317static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200318 0x03,
319};
320
Takashi Iwai2b635362011-05-02 12:33:43 +0200321static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200322 0x0c,
323};
324
Takashi Iwai2b635362011-05-02 12:33:43 +0200325static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200326 0x02,
327};
328
Takashi Iwai2b635362011-05-02 12:33:43 +0200329static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100330 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
331 0x0f, 0x10, 0x11
332};
333
Takashi Iwai2b635362011-05-02 12:33:43 +0200334static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400335 0x26, 0,
336};
337
Takashi Iwai2b635362011-05-02 12:33:43 +0200338static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100339 0x1a, 0x1b
340};
341
342#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200343static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100344 0x13, 0x14, 0
345};
346
347#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100348
Takashi Iwai2b635362011-05-02 12:33:43 +0200349static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200350 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100351};
352
Takashi Iwai2b635362011-05-02 12:33:43 +0200353static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100354 0x20, 0x21,
355};
356
Takashi Iwai2b635362011-05-02 12:33:43 +0200357static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200358 0x22, 0x23,
359};
360
Takashi Iwai6479c632009-07-28 18:20:25 +0200361#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200362static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200363 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
364 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
365};
366#define stac92hd73xx_capsws stac92hd73xx_capvols
367
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200368#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200369
Charles Chinafef2cf2011-11-11 08:05:28 +0100370static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
371 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
372 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200373};
374
Takashi Iwai2b635362011-05-02 12:33:43 +0200375static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400376 0x1e, 0,
377};
378
Takashi Iwai2b635362011-05-02 12:33:43 +0200379static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600380 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200381};
382
Takashi Iwai2b635362011-05-02 12:33:43 +0200383static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100384 0x0a, 0x0d, 0x0f
385};
386
Takashi Iwai2b635362011-05-02 12:33:43 +0200387static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100388 0x12, 0x13,
389};
390
Takashi Iwai2b635362011-05-02 12:33:43 +0200391static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100392 0x1a, 0x1b
393};
394
Takashi Iwai2b635362011-05-02 12:33:43 +0200395static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400396 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100397};
398
Takashi Iwai2b635362011-05-02 12:33:43 +0200399static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200400 0x24, 0x25,
401};
402
Matthew Ranostaye035b842007-11-06 11:53:55 +0100403#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200404static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100405 0x18, 0x19, 0
406};
407
Takashi Iwai2b635362011-05-02 12:33:43 +0200408static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
409 0x18, 0
410};
411
412static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400413 0x22, 0
414};
415
Takashi Iwai6479c632009-07-28 18:20:25 +0200416#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200417static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200418 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
419 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
420};
421#define stac92hd71bxx_capsws stac92hd71bxx_capvols
422
Takashi Iwai2b635362011-05-02 12:33:43 +0200423static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100424 0x03,
425};
426
Takashi Iwai2b635362011-05-02 12:33:43 +0200427static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100428 0x0f,
429};
430
Takashi Iwai2b635362011-05-02 12:33:43 +0200431static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100432 0x02,
433};
434
Takashi Iwaif6e98522007-10-16 14:27:04 +0200435#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200436static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200437 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200438};
439
Takashi Iwai2b635362011-05-02 12:33:43 +0200440static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100441 0x14,
442};
443
Takashi Iwai2b635362011-05-02 12:33:43 +0200444static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200445 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
446};
Takashi Iwai2b635362011-05-02 12:33:43 +0200447static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
449};
450
Takashi Iwai2b635362011-05-02 12:33:43 +0200451static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200452 0x06, 0x07,
453};
454
Takashi Iwai2b635362011-05-02 12:33:43 +0200455static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200456 0x12, 0x13,
457};
458
Takashi Iwai6479c632009-07-28 18:20:25 +0200459#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200460static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200461 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
462 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
463};
464#define stac922x_capsws stac922x_capvols
465
Takashi Iwai2b635362011-05-02 12:33:43 +0200466static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500467 0x1f, 0,
468};
469
Takashi Iwai2b635362011-05-02 12:33:43 +0200470static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100471 0x07, 0x08, 0x09
472};
473
Takashi Iwai2b635362011-05-02 12:33:43 +0200474static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100475 0x15, 0x16, 0x17
476};
477
Takashi Iwai2b635362011-05-02 12:33:43 +0200478static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200479 0x21,
480};
481
Takashi Iwai2b635362011-05-02 12:33:43 +0200482static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100483 0x02, 0x03, 0x04, 0x05, 0x06, 0
484};
485
Takashi Iwai2b635362011-05-02 12:33:43 +0200486static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100487 0x1b,
488};
489
Matthew Ranostay7f168592007-10-18 17:38:17 +0200490#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200491static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200492 0x13, 0x14, 0
493};
494
Takashi Iwai6479c632009-07-28 18:20:25 +0200495#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200496static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200497 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
500};
Takashi Iwai2b635362011-05-02 12:33:43 +0200501static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200502 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
505};
506
Takashi Iwaiea734962011-01-17 11:29:34 +0100507static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400508 "Digital Playback", "ADAT", "Analog Mux 1",
509 "Analog Mux 2", "Analog Mux 3"
510};
511
Takashi Iwai2b635362011-05-02 12:33:43 +0200512static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200513 0x12, 0x13
514};
515
Takashi Iwai2b635362011-05-02 12:33:43 +0200516static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200517 0x19, 0x1a
518};
519
Takashi Iwai2b635362011-05-02 12:33:43 +0200520static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100521 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522};
523
Takashi Iwai2b635362011-05-02 12:33:43 +0200524static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200525 0x21,
526};
527
Takashi Iwaif6e98522007-10-16 14:27:04 +0200528#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200529static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200530 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200531};
532
Takashi Iwai6479c632009-07-28 18:20:25 +0200533#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200534static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200535 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
536 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
537};
Takashi Iwai2b635362011-05-02 12:33:43 +0200538static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200539 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
541};
542
Takashi Iwai2b635362011-05-02 12:33:43 +0200543static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200544 0x08, 0x09, 0x0d, 0x0e,
545 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200546};
547
Takashi Iwai2b635362011-05-02 12:33:43 +0200548static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100549 0x07, 0x08, 0x0a, 0x0b,
550 0x0c, 0x0d, 0x10, 0x11,
551};
552
Takashi Iwai2b635362011-05-02 12:33:43 +0200553static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200554 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
555 0x0f, 0x10, 0x11, 0x15, 0x1b,
556};
557
Takashi Iwai2b635362011-05-02 12:33:43 +0200558static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100562};
563
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500564#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200565static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500566 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
567 0x00, 0x14, 0x18, 0x19, 0x1e,
568 0x1f, 0x20, 0x27
569};
Takashi Iwai2b635362011-05-02 12:33:43 +0200570static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100571 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
572 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500573 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100574};
575
Takashi Iwai2b635362011-05-02 12:33:43 +0200576static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x10, 0x11, 0x12, 0x13,
579 0x14, 0x21, 0x22, 0x23,
580};
581
Takashi Iwai2b635362011-05-02 12:33:43 +0200582static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x14, 0x16, 0x17, 0x18,
585 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200586};
587
Matt Porter8b657272006-10-26 17:12:59 +0200588static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
590{
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct sigmatel_spec *spec = codec->spec;
593 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
594}
595
596static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100601 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200602
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100603 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200604 return 0;
605}
606
607static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol)
609{
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100612 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200613
614 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100615 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200616}
617
Matthew Ranostayd9737752008-09-07 12:03:41 +0200618static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_info *uinfo)
620{
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 struct sigmatel_spec *spec = codec->spec;
623 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
624}
625
626static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
632
633 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
634 return 0;
635}
636
637static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *ucontrol)
639{
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400642 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200643 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400644 int err, val;
645 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200646
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400647 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200648 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400649 if (err < 0)
650 return err;
651
652 if (spec->spdif_mute) {
653 if (smux_idx == 0)
654 nid = spec->multiout.dig_out_nid;
655 else
656 nid = codec->slave_dig_outs[smux_idx - 1];
657 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100658 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400659 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100660 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400661 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100662 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
663 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400664 }
665 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200666}
667
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500668static int stac_vrefout_set(struct hda_codec *codec,
669 hda_nid_t nid, unsigned int new_vref)
670{
671 int error, pinctl;
672
673 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
674 pinctl = snd_hda_codec_read(codec, nid, 0,
675 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
676
677 if (pinctl < 0)
678 return pinctl;
679
680 pinctl &= 0xff;
681 pinctl &= ~AC_PINCTL_VREFEN;
682 pinctl |= (new_vref & AC_PINCTL_VREFEN);
683
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200684 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500685 if (error < 0)
686 return error;
687
688 return 1;
689}
690
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200691static unsigned int stac92xx_vref_set(struct hda_codec *codec,
692 hda_nid_t nid, unsigned int new_vref)
693{
Takashi Iwaib8621512009-06-22 08:00:10 +0200694 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200695 unsigned int pincfg;
696 pincfg = snd_hda_codec_read(codec, nid, 0,
697 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
698
699 pincfg &= 0xff;
700 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
701 pincfg |= new_vref;
702
703 if (new_vref == AC_PINCTL_VREF_HIZ)
704 pincfg |= AC_PINCTL_OUT_EN;
705 else
706 pincfg |= AC_PINCTL_IN_EN;
707
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200708 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200709 if (error < 0)
710 return error;
711 else
712 return 1;
713}
714
715static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
716{
717 unsigned int vref;
718 vref = snd_hda_codec_read(codec, nid, 0,
719 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
720 vref &= AC_PINCTL_VREFEN;
721 return vref;
722}
723
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100724static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200725{
726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
727 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200728 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200729}
730
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100731static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200732{
733 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
734 struct sigmatel_spec *spec = codec->spec;
735 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
736
737 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
738 return 0;
739}
740
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100741static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200742{
743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
744 struct sigmatel_spec *spec = codec->spec;
745 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200746 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600747 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200748
Takashi Iwai5207e102009-07-30 13:09:08 +0200749 idx = ucontrol->value.enumerated.item[0];
750 if (idx >= imux->num_items)
751 idx = imux->num_items - 1;
752 prev_idx = spec->cur_mux[adc_idx];
753 if (prev_idx == idx)
754 return 0;
755 if (idx < spec->num_analog_muxes) {
756 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
757 AC_VERB_SET_CONNECT_SEL,
758 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600759 if (prev_idx >= spec->num_analog_muxes &&
760 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200761 imux = spec->dinput_mux;
762 /* 0 = analog */
763 snd_hda_codec_write_cache(codec,
764 spec->dmux_nids[adc_idx], 0,
765 AC_VERB_SET_CONNECT_SEL,
766 imux->items[0].index);
767 }
768 } else {
769 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600770 /* first dimux item is hardcoded to select analog imux,
771 * so lets skip it
772 */
773 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200774 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
775 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600776 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200777 }
778 spec->cur_mux[adc_idx] = idx;
779 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200780}
781
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100782static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
783 struct snd_ctl_elem_info *uinfo)
784{
785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
786 struct sigmatel_spec *spec = codec->spec;
787 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
788}
789
790static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_value *ucontrol)
792{
793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
794 struct sigmatel_spec *spec = codec->spec;
795
796 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
797 return 0;
798}
799
800static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
801 struct snd_ctl_elem_value *ucontrol)
802{
803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
804 struct sigmatel_spec *spec = codec->spec;
805
806 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
807 spec->mono_nid, &spec->cur_mmux);
808}
809
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200810#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
811
812static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
813 struct snd_ctl_elem_value *ucontrol)
814{
815 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100816 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200817 struct sigmatel_spec *spec = codec->spec;
818
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100819 ucontrol->value.integer.value[0] = !!(spec->aloopback &
820 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200821 return 0;
822}
823
824static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
825 struct snd_ctl_elem_value *ucontrol)
826{
827 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
828 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100829 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200830 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100831 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200832
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 idx_val = spec->aloopback_mask << idx;
834 if (ucontrol->value.integer.value[0])
835 val = spec->aloopback | idx_val;
836 else
837 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100838 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200839 return 0;
840
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100841 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200842
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100843 /* Only return the bits defined by the shift value of the
844 * first two bytes of the mask
845 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200846 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100847 kcontrol->private_value & 0xFFFF, 0x0);
848 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200849
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100850 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200851 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100852 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853 } else {
854 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100855 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200856 }
857
858 snd_hda_codec_write_cache(codec, codec->afg, 0,
859 kcontrol->private_value >> 16, dac_mode);
860
861 return 1;
862}
863
Takashi Iwai2b635362011-05-02 12:33:43 +0200864static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200865 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200866 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200867 {}
868};
869
Takashi Iwai2b635362011-05-02 12:33:43 +0200870static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200871 /* set dac0mux for dac converter */
872 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
873 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
874 {}
875};
876
Takashi Iwai2b635362011-05-02 12:33:43 +0200877static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100878 /* set master volume to max value without distortion
879 * and direct control */
880 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100881 {}
882};
883
Takashi Iwai2b635362011-05-02 12:33:43 +0200884static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100885 /* set master volume and direct control */
886 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100887 {}
888};
889
Takashi Iwai2b635362011-05-02 12:33:43 +0200890static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200891 /* power state controls amps */
892 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200893 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200894};
895
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600896static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
897 { 0x22, 0x785, 0x43 },
898 { 0x22, 0x782, 0xe0 },
899 { 0x22, 0x795, 0x00 },
900 {}
901};
902
Takashi Iwai2b635362011-05-02 12:33:43 +0200903static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100904 /* set master volume and direct control */
905 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200906 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100907};
908
Takashi Iwai2b635362011-05-02 12:33:43 +0200909static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500910 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
911 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100912 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
913 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100914 {}
915};
916
Takashi Iwai2b635362011-05-02 12:33:43 +0200917static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100918 /* set dac0mux for dac converter */
919 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100920 /* mute the master volume */
921 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100922 {}
923};
924
Takashi Iwai2b635362011-05-02 12:33:43 +0200925static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200926 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200927 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200928 {}
929};
930
Takashi Iwai2b635362011-05-02 12:33:43 +0200931static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200932 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200933 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200934 /* unmute node 0x1b */
935 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
936 /* select node 0x03 as DAC */
937 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
938 {}
939};
940
Takashi Iwai2b635362011-05-02 12:33:43 +0200941static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200942 /* don't set delta bit */
943 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
944 /* unmute node 0x1b */
945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
946 /* select node 0x03 as DAC */
947 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
948 {}
949};
950
Takashi Iwai2b635362011-05-02 12:33:43 +0200951static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100952 /* set master volume and direct control */
953 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200954 /* enable analog pc beep path */
955 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100956 {}
957};
958
Takashi Iwai2b635362011-05-02 12:33:43 +0200959static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200960 /* don't set delta bit */
961 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
962 /* enable analog pc beep path */
963 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
964 {}
965};
966
Takashi Iwai2b635362011-05-02 12:33:43 +0200967static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200968 /* set master volume and direct control */
969 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200970 /* enable analog pc beep path */
971 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200972 {}
973};
974
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100975#define STAC_MONO_MUX \
976 { \
977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
978 .name = "Mono Mux", \
979 .count = 1, \
980 .info = stac92xx_mono_mux_enum_info, \
981 .get = stac92xx_mono_mux_enum_get, \
982 .put = stac92xx_mono_mux_enum_put, \
983 }
984
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100985#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200986 { \
987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
988 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100989 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200990 .info = stac92xx_aloopback_info, \
991 .get = stac92xx_aloopback_get, \
992 .put = stac92xx_aloopback_put, \
993 .private_value = verb_read | (verb_write << 16), \
994 }
995
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200996#define DC_BIAS(xname, idx, nid) \
997 { \
998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
999 .name = xname, \
1000 .index = idx, \
1001 .info = stac92xx_dc_bias_info, \
1002 .get = stac92xx_dc_bias_get, \
1003 .put = stac92xx_dc_bias_put, \
1004 .private_value = nid, \
1005 }
1006
Takashi Iwai2b635362011-05-02 12:33:43 +02001007static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001008 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1009 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001010 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001012 { } /* end */
1013};
1014
Takashi Iwai2b635362011-05-02 12:33:43 +02001015static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001016 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1017 {}
1018};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001019
Takashi Iwai2b635362011-05-02 12:33:43 +02001020static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001021 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1022 {}
1023};
1024
Takashi Iwai2b635362011-05-02 12:33:43 +02001025static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001026 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1027 {}
1028};
1029
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001030
Takashi Iwai2b635362011-05-02 12:33:43 +02001031static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001032 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1033};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001034
Takashi Iwai2b635362011-05-02 12:33:43 +02001035static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001036 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1037 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001038 { } /* end */
1039};
1040
Takashi Iwai2b635362011-05-02 12:33:43 +02001041static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001042 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1043 {}
1044};
1045
Takashi Iwai2b635362011-05-02 12:33:43 +02001046static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001047 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1048 {}
1049};
1050
Takashi Iwai1697055e2007-12-18 18:05:52 +01001051static struct snd_kcontrol_new stac_dmux_mixer = {
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1053 .name = "Digital Input Source",
1054 /* count set later */
1055 .info = stac92xx_dmux_enum_info,
1056 .get = stac92xx_dmux_enum_get,
1057 .put = stac92xx_dmux_enum_put,
1058};
1059
Matthew Ranostayd9737752008-09-07 12:03:41 +02001060static struct snd_kcontrol_new stac_smux_mixer = {
1061 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001062 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001063 /* count set later */
1064 .info = stac92xx_smux_enum_info,
1065 .get = stac92xx_smux_enum_get,
1066 .put = stac92xx_smux_enum_put,
1067};
1068
Takashi Iwai9322ca52012-02-03 14:28:01 +01001069static const char * const slave_pfxs[] = {
1070 "Front", "Surround", "Center", "LFE", "Side",
1071 "Headphone", "Speaker", "IEC958",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001072 NULL
1073};
1074
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001075static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1076
1077static void stac92xx_vmaster_hook(void *private_data, int val)
1078{
1079 stac92xx_update_led_status(private_data, val);
1080}
1081
Takashi Iwai603c4012008-07-30 15:01:44 +02001082static void stac92xx_free_kctls(struct hda_codec *codec);
1083
Matt2f2f4252005-04-13 14:45:30 +02001084static int stac92xx_build_controls(struct hda_codec *codec)
1085{
1086 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001087 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001088 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001089 int i;
Matt2f2f4252005-04-13 14:45:30 +02001090
Takashi Iwai6479c632009-07-28 18:20:25 +02001091 if (spec->mixer) {
1092 err = snd_hda_add_new_ctls(codec, spec->mixer);
1093 if (err < 0)
1094 return err;
1095 }
Mattc7d4b2f2005-06-27 14:59:41 +02001096
1097 for (i = 0; i < spec->num_mixers; i++) {
1098 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1099 if (err < 0)
1100 return err;
1101 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001102 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1103 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001104 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001105 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001106 snd_ctl_new1(&stac_dmux_mixer, codec));
1107 if (err < 0)
1108 return err;
1109 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001110 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001111 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1112 struct hda_input_mux *smux = &spec->private_smux;
1113 /* check for mute support on SPDIF out */
1114 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001115 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001116 spec->spdif_mute = 1;
1117 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001118 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001119 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001120 snd_ctl_new1(&stac_smux_mixer, codec));
1121 if (err < 0)
1122 return err;
1123 }
Mattc7d4b2f2005-06-27 14:59:41 +02001124
Mattdabbed62005-06-14 10:19:34 +02001125 if (spec->multiout.dig_out_nid) {
Stephen Warren74b654c2011-06-01 11:14:18 -06001126 err = snd_hda_create_spdif_out_ctls(codec,
1127 spec->multiout.dig_out_nid,
1128 spec->multiout.dig_out_nid);
Mattdabbed62005-06-14 10:19:34 +02001129 if (err < 0)
1130 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001131 err = snd_hda_create_spdif_share_sw(codec,
1132 &spec->multiout);
1133 if (err < 0)
1134 return err;
1135 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001136 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001137 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001138 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1139 if (err < 0)
1140 return err;
1141 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001142
1143 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001144 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1145 HDA_OUTPUT, vmaster_tlv);
1146 /* correct volume offset */
1147 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1148 /* minimum value is actually mute */
1149 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1150 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1151 vmaster_tlv, slave_pfxs,
1152 "Playback Volume");
1153 if (err < 0)
1154 return err;
1155
1156 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1157 NULL, slave_pfxs,
1158 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001159 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001160 if (err < 0)
1161 return err;
1162
1163 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001164 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001165 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001166 if (err < 0)
1167 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001168 }
1169
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001170 if (spec->aloopback_ctl &&
1171 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1172 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1173 if (err < 0)
1174 return err;
1175 }
1176
Takashi Iwai603c4012008-07-30 15:01:44 +02001177 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001178
Takashi Iwai01a61e12011-10-28 00:03:22 +02001179 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1180 if (err < 0)
1181 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001182
Mattdabbed62005-06-14 10:19:34 +02001183 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001184}
1185
Takashi Iwai2b635362011-05-02 12:33:43 +02001186static const unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001187 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001188 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1189};
1190
Takashi Iwai2b635362011-05-02 12:33:43 +02001191static const unsigned int gateway9200_m4_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001192 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1193 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1194};
Takashi Iwai2b635362011-05-02 12:33:43 +02001195static const unsigned int gateway9200_m4_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001196 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1197 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1198};
1199
1200/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001201 STAC 9200 pin configs for
1202 102801A8
1203 102801DE
1204 102801E8
1205*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001206static const unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001207 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1208 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001209};
1210
1211/*
1212 STAC 9200 pin configs for
1213 102801C0
1214 102801C1
1215*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001216static const unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001217 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1218 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001219};
1220
1221/*
1222 STAC 9200 pin configs for
1223 102801C4 (Dell Dimension E310)
1224 102801C5
1225 102801C7
1226 102801D9
1227 102801DA
1228 102801E3
1229*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001230static const unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001231 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1232 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001233};
1234
1235
1236/*
1237 STAC 9200-32 pin configs for
1238 102801B5 (Dell Inspiron 630m)
1239 102801D8 (Dell Inspiron 640m)
1240*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001241static const unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001242 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1243 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001244};
1245
1246/*
1247 STAC 9200-32 pin configs for
1248 102801C2 (Dell Latitude D620)
1249 102801C8
1250 102801CC (Dell Latitude D820)
1251 102801D4
1252 102801D6
1253*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001254static const unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001255 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1256 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001257};
1258
1259/*
1260 STAC 9200-32 pin configs for
1261 102801CE (Dell XPS M1710)
1262 102801CF (Dell Precision M90)
1263*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001264static const unsigned int dell9200_m23_pin_configs[8] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001265 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1266 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1267};
1268
1269/*
1270 STAC 9200-32 pin configs for
1271 102801C9
1272 102801CA
1273 102801CB (Dell Latitude 120L)
1274 102801D3
1275*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001276static const unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001277 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1278 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001279};
1280
1281/*
1282 STAC 9200-32 pin configs for
1283 102801BD (Dell Inspiron E1505n)
1284 102801EE
1285 102801EF
1286*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001287static const unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001288 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1289 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001290};
1291
1292/*
1293 STAC 9200-32 pin configs for
1294 102801F5 (Dell Inspiron 1501)
1295 102801F6
1296*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001297static const unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001298 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1299 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001300};
1301
1302/*
1303 STAC 9200-32
1304 102801CD (Dell Inspiron E1705/9400)
1305*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001306static const unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001307 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1308 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001309};
1310
Takashi Iwai2b635362011-05-02 12:33:43 +02001311static const unsigned int oqo9200_pin_configs[8] = {
Tobin Davisbf277782008-02-03 20:31:47 +01001312 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1313 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1314};
1315
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001316
Takashi Iwai2b635362011-05-02 12:33:43 +02001317static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001318 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001319 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001320 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1321 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1322 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1323 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1324 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1325 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1326 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1327 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1328 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1329 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001330 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1331 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001332 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001333};
1334
Takashi Iwaiea734962011-01-17 11:29:34 +01001335static const char * const stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001336 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001337 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001338 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001339 [STAC_9200_DELL_D21] = "dell-d21",
1340 [STAC_9200_DELL_D22] = "dell-d22",
1341 [STAC_9200_DELL_D23] = "dell-d23",
1342 [STAC_9200_DELL_M21] = "dell-m21",
1343 [STAC_9200_DELL_M22] = "dell-m22",
1344 [STAC_9200_DELL_M23] = "dell-m23",
1345 [STAC_9200_DELL_M24] = "dell-m24",
1346 [STAC_9200_DELL_M25] = "dell-m25",
1347 [STAC_9200_DELL_M26] = "dell-m26",
1348 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001349 [STAC_9200_M4] = "gateway-m4",
1350 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001351 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001352};
1353
Takashi Iwai2b635362011-05-02 12:33:43 +02001354static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001355 /* SigmaTel reference board */
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1357 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001358 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1359 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001360 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1362 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1366 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1368 "unknown Dell", STAC_9200_DELL_D22),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1370 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001372 "Dell Latitude D620", STAC_9200_DELL_M22),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1374 "unknown Dell", STAC_9200_DELL_D23),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1376 "unknown Dell", STAC_9200_DELL_D23),
1377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1378 "unknown Dell", STAC_9200_DELL_M22),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1380 "unknown Dell", STAC_9200_DELL_M24),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1382 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001384 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001386 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001388 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001392 "Dell Precision M90", STAC_9200_DELL_M23),
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1394 "unknown Dell", STAC_9200_DELL_M22),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1396 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001400 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1402 "unknown Dell", STAC_9200_DELL_D23),
1403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1404 "unknown Dell", STAC_9200_DELL_D23),
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1406 "unknown Dell", STAC_9200_DELL_D21),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1408 "unknown Dell", STAC_9200_DELL_D23),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1410 "unknown Dell", STAC_9200_DELL_D21),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1412 "unknown Dell", STAC_9200_DELL_M25),
1413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1414 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001416 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1418 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001419 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001420 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001421 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001422 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1423 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1424 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001425 /* OQO Mobile */
1426 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001427 {} /* terminator */
1428};
1429
Takashi Iwai2b635362011-05-02 12:33:43 +02001430static const unsigned int ref925x_pin_configs[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001431 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001432 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001433};
1434
Takashi Iwai2b635362011-05-02 12:33:43 +02001435static const unsigned int stac925xM1_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001436 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1437 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001438};
1439
Takashi Iwai2b635362011-05-02 12:33:43 +02001440static const unsigned int stac925xM1_2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001441 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1442 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1443};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001444
Takashi Iwai2b635362011-05-02 12:33:43 +02001445static const unsigned int stac925xM2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001446 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1447 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001448};
1449
Takashi Iwai2b635362011-05-02 12:33:43 +02001450static const unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001451 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1452 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1453};
1454
Takashi Iwai2b635362011-05-02 12:33:43 +02001455static const unsigned int stac925xM3_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001456 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1457 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1458};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001459
Takashi Iwai2b635362011-05-02 12:33:43 +02001460static const unsigned int stac925xM5_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001461 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1462 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1463};
1464
Takashi Iwai2b635362011-05-02 12:33:43 +02001465static const unsigned int stac925xM6_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001466 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1467 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001468};
1469
Takashi Iwai2b635362011-05-02 12:33:43 +02001470static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001471 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001472 [STAC_M1] = stac925xM1_pin_configs,
1473 [STAC_M1_2] = stac925xM1_2_pin_configs,
1474 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001475 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001476 [STAC_M3] = stac925xM3_pin_configs,
1477 [STAC_M5] = stac925xM5_pin_configs,
1478 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001479};
1480
Takashi Iwaiea734962011-01-17 11:29:34 +01001481static const char * const stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001482 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001483 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001484 [STAC_M1] = "m1",
1485 [STAC_M1_2] = "m1-2",
1486 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001487 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001488 [STAC_M3] = "m3",
1489 [STAC_M5] = "m5",
1490 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001491};
1492
Takashi Iwai2b635362011-05-02 12:33:43 +02001493static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001494 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1495 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1496 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1497 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001498 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001499 /* Not sure about the brand name for those */
1500 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1501 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1502 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1503 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001504 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001505};
1506
Takashi Iwai2b635362011-05-02 12:33:43 +02001507static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001508 /* SigmaTel reference board */
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001510 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001511 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001512
1513 /* Default table for unknown ID */
1514 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1515
Tobin Davis8e21c342007-01-08 11:04:17 +01001516 {} /* terminator */
1517};
1518
Takashi Iwai2b635362011-05-02 12:33:43 +02001519static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001520 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1521 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1522 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001523 0x01452050,
1524};
1525
Takashi Iwai2b635362011-05-02 12:33:43 +02001526static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001527 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001528 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001529 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1530 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001531};
1532
Takashi Iwai2b635362011-05-02 12:33:43 +02001533static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001534 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1535 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1536 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1537 0x904601b0,
1538};
1539
Takashi Iwai2b635362011-05-02 12:33:43 +02001540static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001541 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001542 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001543};
1544
Takashi Iwai2b635362011-05-02 12:33:43 +02001545static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001546 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001547 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1548 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1549 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001550 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001551 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001552 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001553};
1554
Takashi Iwaiea734962011-01-17 11:29:34 +01001555static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001556 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001557 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001558 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001559 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001560 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1561 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1562 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001563 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001564 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001565};
1566
Takashi Iwai2b635362011-05-02 12:33:43 +02001567static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001568 /* SigmaTel reference board */
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001570 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001571 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1572 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1574 "Intel DG45ID", STAC_92HD73XX_INTEL),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1576 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001578 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001580 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001582 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001584 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001586 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001588 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001590 "unknown Dell", STAC_DELL_M6_DMIC),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1592 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001594 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1596 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1598 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1600 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001602 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001604 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001605 {} /* terminator */
1606};
1607
Takashi Iwai2b635362011-05-02 12:33:43 +02001608static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1610 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1612 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001614 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001615 {} /* terminator */
1616};
1617
Takashi Iwai2b635362011-05-02 12:33:43 +02001618static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001619 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1620 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001621 0x01451160, 0x98560170,
1622};
1623
Takashi Iwai2b635362011-05-02 12:33:43 +02001624static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001625 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1626 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001627 0x40f000f0, 0x40f000f0,
1628};
1629
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001630static const unsigned int dell_vostro_3500_pin_configs[10] = {
1631 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1632 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1633 0x400000f4, 0x400000f5,
1634};
1635
Takashi Iwai2b635362011-05-02 12:33:43 +02001636static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001637 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1638 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1639 0x40f000f0, 0x40f000f0,
1640};
1641
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001642static const unsigned int hp_zephyr_pin_configs[10] = {
1643 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1644 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1645 0, 0,
1646};
1647
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001648static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1649 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1650 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1651 0x40f000f0, 0x40f000f0,
1652};
1653
Takashi Iwai2b635362011-05-02 12:33:43 +02001654static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001655 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001656 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001657 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001658 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001659 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001660 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001661 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001662};
1663
Takashi Iwaiea734962011-01-17 11:29:34 +01001664static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001665 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001666 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001667 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001668 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001669 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001670 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001671 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001672 [STAC_HP_ZEPHYR] = "hp-zephyr",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001673};
1674
Takashi Iwai2b635362011-05-02 12:33:43 +02001675static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001676 /* SigmaTel reference board */
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001678 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001679 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1680 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1682 "unknown Dell", STAC_DELL_S14),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1684 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001685 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1686 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1688 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1690 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1692 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1694 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1696 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1698 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1700 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1702 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1704 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1706 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1708 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1710 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1712 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1714 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1716 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1718 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1720 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1722 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1724 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001725 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1726 "HP", STAC_HP_ZEPHYR),
1727 {} /* terminator */
1728};
1729
1730static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1732 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001733 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001734};
1735
Takashi Iwai2b635362011-05-02 12:33:43 +02001736static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001737 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001738 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001739 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1740 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001741};
1742
Takashi Iwai2b635362011-05-02 12:33:43 +02001743static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001744 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001745 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001746 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1747 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001748};
1749
Takashi Iwai2b635362011-05-02 12:33:43 +02001750static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001751 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1752 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001753 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1754 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001755};
1756
Takashi Iwai2b635362011-05-02 12:33:43 +02001757static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001758 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1759 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001760 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1761 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001762};
1763
Takashi Iwai2b635362011-05-02 12:33:43 +02001764static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001765 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001766 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1767 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001768 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001769 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001770 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001771 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001772 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001773 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001774};
1775
Takashi Iwaiea734962011-01-17 11:29:34 +01001776static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001777 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001778 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001779 [STAC_DELL_M4_1] = "dell-m4-1",
1780 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001781 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001782 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001783 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001784 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001785 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001786 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001787};
1788
Takashi Iwai2b635362011-05-02 12:33:43 +02001789static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001790 /* SigmaTel reference board */
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1792 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001793 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1794 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001795 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1796 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001797 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1798 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001799 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1800 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001801 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001802 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001803 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1804 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001805 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1806 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001808 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001810 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001811 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1812 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301813 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1814 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11001815 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1816 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001817 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1818 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1820 "unknown Dell", STAC_DELL_M4_1),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1822 "unknown Dell", STAC_DELL_M4_1),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1824 "unknown Dell", STAC_DELL_M4_1),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1830 "unknown Dell", STAC_DELL_M4_1),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1832 "unknown Dell", STAC_DELL_M4_1),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1834 "unknown Dell", STAC_DELL_M4_2),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1836 "unknown Dell", STAC_DELL_M4_2),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1838 "unknown Dell", STAC_DELL_M4_2),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1840 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1842 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001843 {} /* terminator */
1844};
1845
Takashi Iwai2b635362011-05-02 12:33:43 +02001846static const unsigned int ref922x_pin_configs[10] = {
Matt Porter403d1942005-11-29 15:00:51 +01001847 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1848 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001849 0x40000100, 0x40000100,
1850};
1851
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001852/*
1853 STAC 922X pin configs for
1854 102801A7
1855 102801AB
1856 102801A9
1857 102801D1
1858 102801D2
1859*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001860static const unsigned int dell_922x_d81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001861 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1862 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1863 0x01813122, 0x400001f2,
1864};
1865
1866/*
1867 STAC 922X pin configs for
1868 102801AC
1869 102801D0
1870*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001871static const unsigned int dell_922x_d82_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001872 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1873 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1874 0x01813122, 0x400001f1,
1875};
1876
1877/*
1878 STAC 922X pin configs for
1879 102801BF
1880*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001881static const unsigned int dell_922x_m81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001882 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1883 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1884 0x40C003f1, 0x405003f0,
1885};
1886
1887/*
1888 STAC 9221 A1 pin configs for
1889 102801D7 (Dell XPS M1210)
1890*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001891static const unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001892 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1893 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001894 0x508003f3, 0x405003f4,
1895};
1896
Takashi Iwai2b635362011-05-02 12:33:43 +02001897static const unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001898 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001899 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1900 0x02a19120, 0x40000100,
1901};
1902
Takashi Iwai2b635362011-05-02 12:33:43 +02001903static const unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001904 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1905 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001906 0x02a19320, 0x40000100,
1907};
1908
Takashi Iwai2b635362011-05-02 12:33:43 +02001909static const unsigned int intel_mac_v1_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001910 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1911 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001912 0x400000fc, 0x400000fb,
1913};
1914
Takashi Iwai2b635362011-05-02 12:33:43 +02001915static const unsigned int intel_mac_v2_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001916 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1917 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001918 0x400000fc, 0x400000fb,
1919};
1920
Takashi Iwai2b635362011-05-02 12:33:43 +02001921static const unsigned int intel_mac_v3_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001922 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1923 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1924 0x400000fc, 0x400000fb,
1925};
1926
Takashi Iwai2b635362011-05-02 12:33:43 +02001927static const unsigned int intel_mac_v4_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001928 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1929 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1930 0x400000fc, 0x400000fb,
1931};
1932
Takashi Iwai2b635362011-05-02 12:33:43 +02001933static const unsigned int intel_mac_v5_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001934 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1935 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1936 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001937};
1938
Takashi Iwai2b635362011-05-02 12:33:43 +02001939static const unsigned int ecs202_pin_configs[10] = {
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001940 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1941 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1942 0x9037012e, 0x40e000f2,
1943};
Takashi Iwai76c08822007-06-19 12:17:42 +02001944
Takashi Iwai2b635362011-05-02 12:33:43 +02001945static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001946 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001947 [STAC_D945GTP3] = d945gtp3_pin_configs,
1948 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001949 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1950 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1951 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1952 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1953 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001954 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001955 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001956 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1957 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1958 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1959 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1960 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1961 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001962 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001963 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1964 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1965 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1966 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001967};
1968
Takashi Iwaiea734962011-01-17 11:29:34 +01001969static const char * const stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001970 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001971 [STAC_D945_REF] = "ref",
1972 [STAC_D945GTP5] = "5stack",
1973 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001974 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1975 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1976 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1977 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1978 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001979 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001980 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001981 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001982 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001983 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1984 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001985 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001986 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001987 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001988 [STAC_922X_DELL_D81] = "dell-d81",
1989 [STAC_922X_DELL_D82] = "dell-d82",
1990 [STAC_922X_DELL_M81] = "dell-m81",
1991 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001992};
1993
Takashi Iwai2b635362011-05-02 12:33:43 +02001994static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001995 /* SigmaTel reference board */
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1997 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001998 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1999 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002000 /* Intel 945G based systems */
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2002 "Intel D945G", STAC_D945GTP3),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2004 "Intel D945G", STAC_D945GTP3),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2006 "Intel D945G", STAC_D945GTP3),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2008 "Intel D945G", STAC_D945GTP3),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2010 "Intel D945G", STAC_D945GTP3),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2012 "Intel D945G", STAC_D945GTP3),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2014 "Intel D945G", STAC_D945GTP3),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2016 "Intel D945G", STAC_D945GTP3),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2018 "Intel D945G", STAC_D945GTP3),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2020 "Intel D945G", STAC_D945GTP3),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2022 "Intel D945G", STAC_D945GTP3),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2024 "Intel D945G", STAC_D945GTP3),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2026 "Intel D945G", STAC_D945GTP3),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2028 "Intel D945G", STAC_D945GTP3),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2030 "Intel D945G", STAC_D945GTP3),
2031 /* Intel D945G 5-stack systems */
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2033 "Intel D945G", STAC_D945GTP5),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2035 "Intel D945G", STAC_D945GTP5),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2037 "Intel D945G", STAC_D945GTP5),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2039 "Intel D945G", STAC_D945GTP5),
2040 /* Intel 945P based systems */
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2042 "Intel D945P", STAC_D945GTP3),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2044 "Intel D945P", STAC_D945GTP3),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2046 "Intel D945P", STAC_D945GTP3),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2048 "Intel D945P", STAC_D945GTP3),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2050 "Intel D945P", STAC_D945GTP3),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2052 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002053 /* other intel */
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2055 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002056 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002057 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002058 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002059 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002060 /* Dell systems */
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2062 "unknown Dell", STAC_922X_DELL_D81),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2064 "unknown Dell", STAC_922X_DELL_D81),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2066 "unknown Dell", STAC_922X_DELL_D81),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2068 "unknown Dell", STAC_922X_DELL_D82),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2070 "unknown Dell", STAC_922X_DELL_M81),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2072 "unknown Dell", STAC_922X_DELL_D82),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2074 "unknown Dell", STAC_922X_DELL_D81),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2076 "unknown Dell", STAC_922X_DELL_D81),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2078 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002079 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002080 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002081 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002082 {} /* terminator */
2083};
2084
Takashi Iwai2b635362011-05-02 12:33:43 +02002085static const unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002086 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2087 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2088 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2089 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002090};
2091
Takashi Iwai2b635362011-05-02 12:33:43 +02002092static const unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002093 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2094 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2095 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2096 0x40000100, 0x40000100
2097};
2098
Takashi Iwai2b635362011-05-02 12:33:43 +02002099static const unsigned int d965_5st_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002100 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2101 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2102 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2103 0x40000100, 0x40000100
2104};
2105
Takashi Iwai2b635362011-05-02 12:33:43 +02002106static const unsigned int d965_5st_no_fp_pin_configs[14] = {
Takashi Iwai679d92e2009-05-24 19:00:08 +02002107 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2108 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2109 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2110 0x40000100, 0x40000100
2111};
2112
Takashi Iwai2b635362011-05-02 12:33:43 +02002113static const unsigned int dell_3st_pin_configs[14] = {
Tobin Davis4ff076e2007-08-07 11:48:12 +02002114 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2115 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002116 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002117 0x40c003fc, 0x40000100
2118};
2119
Takashi Iwai2b635362011-05-02 12:33:43 +02002120static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002121 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002122 [STAC_D965_REF] = ref927x_pin_configs,
2123 [STAC_D965_3ST] = d965_3st_pin_configs,
2124 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002125 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002126 [STAC_DELL_3ST] = dell_3st_pin_configs,
2127 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002128 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002129};
2130
Takashi Iwaiea734962011-01-17 11:29:34 +01002131static const char * const stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002132 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002133 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002134 [STAC_D965_REF] = "ref",
2135 [STAC_D965_3ST] = "3stack",
2136 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002137 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002138 [STAC_DELL_3ST] = "dell-3stack",
2139 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002140 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002141};
2142
Takashi Iwai2b635362011-05-02 12:33:43 +02002143static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002144 /* SigmaTel reference board */
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2146 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002147 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2148 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002149 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002152 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002153 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2154 "Intel D965", STAC_D965_3ST),
2155 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2156 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002157 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002161 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002171 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002172 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2173 "Intel D965", STAC_D965_5ST),
2174 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2175 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002176 /* volume-knob fixes */
2177 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002178 {} /* terminator */
2179};
2180
Takashi Iwai2b635362011-05-02 12:33:43 +02002181static const unsigned int ref9205_pin_configs[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +02002182 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002183 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002184 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002185};
2186
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002187/*
2188 STAC 9205 pin configs for
2189 102801F1
2190 102801F2
2191 102801FC
2192 102801FD
2193 10280204
2194 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002195 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002196 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002197*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002198static const unsigned int dell_9205_m42_pin_configs[12] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002199 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2200 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2201 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2202};
2203
2204/*
2205 STAC 9205 pin configs for
2206 102801F9
2207 102801FA
2208 102801FE
2209 102801FF (Dell Precision M4300)
2210 10280206
2211 10280200
2212 10280201
2213*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002214static const unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002215 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2216 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2217 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2218};
2219
Takashi Iwai2b635362011-05-02 12:33:43 +02002220static const unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002221 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2222 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2223 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2224};
2225
Takashi Iwai2b635362011-05-02 12:33:43 +02002226static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002227 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002228 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2229 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2230 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002231 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002232};
2233
Takashi Iwaiea734962011-01-17 11:29:34 +01002234static const char * const stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002235 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002236 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002237 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002238 [STAC_9205_DELL_M43] = "dell-m43",
2239 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002240 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002241};
2242
Takashi Iwai2b635362011-05-02 12:33:43 +02002243static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002244 /* SigmaTel reference board */
2245 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2246 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002247 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2248 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002249 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2250 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002251 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2253 "unknown Dell", STAC_9205_DELL_M42),
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2255 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002257 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2259 "Dell Precision", STAC_9205_DELL_M43),
2260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2261 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2263 "unknown Dell", STAC_9205_DELL_M42),
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2265 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2267 "Dell Precision", STAC_9205_DELL_M43),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002269 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2271 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2273 "Dell Precision", STAC_9205_DELL_M43),
2274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2275 "Dell Precision", STAC_9205_DELL_M43),
2276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2277 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2279 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2281 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2283 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002284 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002285 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002286 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002287 {} /* terminator */
2288};
2289
Takashi Iwai330ee992009-02-20 14:33:36 +01002290static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002291 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002292{
2293 int i;
2294 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002295
Takashi Iwai330ee992009-02-20 14:33:36 +01002296 if (!pincfgs)
2297 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002298
Matthew Ranostay87d48362007-07-17 11:52:24 +02002299 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002300 if (spec->pin_nids[i] && pincfgs[i])
2301 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2302 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002303}
2304
Matt2f2f4252005-04-13 14:45:30 +02002305/*
2306 * Analog playback callbacks
2307 */
2308static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2309 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002310 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002311{
2312 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002313 if (spec->stream_delay)
2314 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002315 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2316 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002317}
2318
2319static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2320 struct hda_codec *codec,
2321 unsigned int stream_tag,
2322 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002323 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002324{
2325 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002326 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002327}
2328
2329static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002331 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002332{
2333 struct sigmatel_spec *spec = codec->spec;
2334 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2335}
2336
2337/*
Mattdabbed62005-06-14 10:19:34 +02002338 * Digital playback callbacks
2339 */
2340static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002342 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002343{
2344 struct sigmatel_spec *spec = codec->spec;
2345 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2346}
2347
2348static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002350 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002351{
2352 struct sigmatel_spec *spec = codec->spec;
2353 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2354}
2355
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002356static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2357 struct hda_codec *codec,
2358 unsigned int stream_tag,
2359 unsigned int format,
2360 struct snd_pcm_substream *substream)
2361{
2362 struct sigmatel_spec *spec = codec->spec;
2363 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2364 stream_tag, format, substream);
2365}
2366
Takashi Iwai9411e212009-02-13 11:32:28 +01002367static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2368 struct hda_codec *codec,
2369 struct snd_pcm_substream *substream)
2370{
2371 struct sigmatel_spec *spec = codec->spec;
2372 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2373}
2374
Mattdabbed62005-06-14 10:19:34 +02002375
2376/*
Matt2f2f4252005-04-13 14:45:30 +02002377 * Analog capture callbacks
2378 */
2379static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2380 struct hda_codec *codec,
2381 unsigned int stream_tag,
2382 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002383 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002384{
2385 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002386 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002387
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002388 if (spec->powerdown_adcs) {
2389 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002390 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002391 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2392 }
2393 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002394 return 0;
2395}
2396
2397static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2398 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002399 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002400{
2401 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002402 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002403
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002404 snd_hda_codec_cleanup_stream(codec, nid);
2405 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002406 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002407 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002408 return 0;
2409}
2410
Takashi Iwai2b635362011-05-02 12:33:43 +02002411static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02002412 .substreams = 1,
2413 .channels_min = 2,
2414 .channels_max = 2,
2415 /* NID is set in stac92xx_build_pcms */
2416 .ops = {
2417 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002418 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002419 .prepare = stac92xx_dig_playback_pcm_prepare,
2420 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002421 },
2422};
2423
Takashi Iwai2b635362011-05-02 12:33:43 +02002424static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02002425 .substreams = 1,
2426 .channels_min = 2,
2427 .channels_max = 2,
2428 /* NID is set in stac92xx_build_pcms */
2429};
2430
Takashi Iwai2b635362011-05-02 12:33:43 +02002431static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02002432 .substreams = 1,
2433 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002434 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002435 .nid = 0x02, /* NID to query formats and rates */
2436 .ops = {
2437 .open = stac92xx_playback_pcm_open,
2438 .prepare = stac92xx_playback_pcm_prepare,
2439 .cleanup = stac92xx_playback_pcm_cleanup
2440 },
2441};
2442
Takashi Iwai2b635362011-05-02 12:33:43 +02002443static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002444 .substreams = 1,
2445 .channels_min = 2,
2446 .channels_max = 2,
2447 .nid = 0x06, /* NID to query formats and rates */
2448 .ops = {
2449 .open = stac92xx_playback_pcm_open,
2450 .prepare = stac92xx_playback_pcm_prepare,
2451 .cleanup = stac92xx_playback_pcm_cleanup
2452 },
2453};
2454
Takashi Iwai2b635362011-05-02 12:33:43 +02002455static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002456 .channels_min = 2,
2457 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002458 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002459 .ops = {
2460 .prepare = stac92xx_capture_pcm_prepare,
2461 .cleanup = stac92xx_capture_pcm_cleanup
2462 },
2463};
2464
2465static int stac92xx_build_pcms(struct hda_codec *codec)
2466{
2467 struct sigmatel_spec *spec = codec->spec;
2468 struct hda_pcm *info = spec->pcm_rec;
2469
2470 codec->num_pcms = 1;
2471 codec->pcm_info = info;
2472
Mattc7d4b2f2005-06-27 14:59:41 +02002473 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002474 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002475 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2476 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002477 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002478 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002479 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002480
2481 if (spec->alt_switch) {
2482 codec->num_pcms++;
2483 info++;
2484 info->name = "STAC92xx Analog Alt";
2485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2486 }
Matt2f2f4252005-04-13 14:45:30 +02002487
Mattdabbed62005-06-14 10:19:34 +02002488 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2489 codec->num_pcms++;
2490 info++;
2491 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002492 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002493 if (spec->multiout.dig_out_nid) {
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2496 }
2497 if (spec->dig_in_nid) {
2498 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2499 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2500 }
2501 }
2502
Matt2f2f4252005-04-13 14:45:30 +02002503 return 0;
2504}
2505
Matt Porter403d1942005-11-29 15:00:51 +01002506static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2507
2508{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02002509 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002510}
2511
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002512#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2513
2514static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2515 struct snd_ctl_elem_value *ucontrol)
2516{
2517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2518 struct sigmatel_spec *spec = codec->spec;
2519
Takashi Iwaid7a89432008-11-12 09:48:04 +01002520 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002521 return 0;
2522}
2523
Takashi Iwai62558ce2009-07-29 14:23:09 +02002524static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002525
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002526static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2527 struct snd_ctl_elem_value *ucontrol)
2528{
2529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2530 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002531 int nid = kcontrol->private_value;
2532
2533 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002534
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002535 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002536 * switch changes
2537 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002538 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002539
2540 return 1;
2541}
2542
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002543static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2544 struct snd_ctl_elem_info *uinfo)
2545{
2546 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02002547 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002548 "Mic In", "Line In", "Line Out"
2549 };
2550
2551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2552 struct sigmatel_spec *spec = codec->spec;
2553 hda_nid_t nid = kcontrol->private_value;
2554
2555 if (nid == spec->mic_switch || nid == spec->line_switch)
2556 i = 3;
2557 else
2558 i = 2;
2559
2560 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2561 uinfo->value.enumerated.items = i;
2562 uinfo->count = 1;
2563 if (uinfo->value.enumerated.item >= i)
2564 uinfo->value.enumerated.item = i-1;
2565 strcpy(uinfo->value.enumerated.name,
2566 texts[uinfo->value.enumerated.item]);
2567
2568 return 0;
2569}
2570
2571static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2572 struct snd_ctl_elem_value *ucontrol)
2573{
2574 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2575 hda_nid_t nid = kcontrol->private_value;
2576 unsigned int vref = stac92xx_vref_get(codec, nid);
2577
Takashi Iwai47408602012-04-20 13:06:53 +02002578 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002579 ucontrol->value.enumerated.item[0] = 0;
2580 else if (vref == AC_PINCTL_VREF_GRD)
2581 ucontrol->value.enumerated.item[0] = 1;
2582 else if (vref == AC_PINCTL_VREF_HIZ)
2583 ucontrol->value.enumerated.item[0] = 2;
2584
2585 return 0;
2586}
2587
2588static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2589 struct snd_ctl_elem_value *ucontrol)
2590{
2591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2592 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002593 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002594 hda_nid_t nid = kcontrol->private_value;
2595
2596 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02002597 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002598 else if (ucontrol->value.enumerated.item[0] == 1)
2599 new_vref = AC_PINCTL_VREF_GRD;
2600 else if (ucontrol->value.enumerated.item[0] == 2)
2601 new_vref = AC_PINCTL_VREF_HIZ;
2602 else
2603 return 0;
2604
2605 if (new_vref != stac92xx_vref_get(codec, nid)) {
2606 error = stac92xx_vref_set(codec, nid, new_vref);
2607 return error;
2608 }
2609
2610 return 0;
2611}
2612
2613static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2614 struct snd_ctl_elem_info *uinfo)
2615{
Takashi Iwai2b635362011-05-02 12:33:43 +02002616 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2618 struct sigmatel_spec *spec = codec->spec;
2619
2620 if (kcontrol->private_value == spec->line_switch)
2621 texts[0] = "Line In";
2622 else
2623 texts[0] = "Mic In";
2624 texts[1] = "Line Out";
2625 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2626 uinfo->value.enumerated.items = 2;
2627 uinfo->count = 1;
2628
2629 if (uinfo->value.enumerated.item >= 2)
2630 uinfo->value.enumerated.item = 1;
2631 strcpy(uinfo->value.enumerated.name,
2632 texts[uinfo->value.enumerated.item]);
2633
2634 return 0;
2635}
Matt Porter403d1942005-11-29 15:00:51 +01002636
2637static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2638{
2639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2640 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002641 hda_nid_t nid = kcontrol->private_value;
2642 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002643
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002644 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002645 return 0;
2646}
2647
2648static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2649{
2650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2651 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002652 hda_nid_t nid = kcontrol->private_value;
2653 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2654 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002655
2656 spec->io_switch[io_idx] = val;
2657
2658 if (val)
2659 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002660 else {
2661 unsigned int pinctl = AC_PINCTL_IN_EN;
2662 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02002663 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002664 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2665 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002666
2667 /* check the auto-mute again: we need to mute/unmute the speaker
2668 * appropriately according to the pin direction
2669 */
2670 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002671 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002672
Matt Porter403d1942005-11-29 15:00:51 +01002673 return 1;
2674}
2675
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002676#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2677
2678static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2679 struct snd_ctl_elem_value *ucontrol)
2680{
2681 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2682 struct sigmatel_spec *spec = codec->spec;
2683
2684 ucontrol->value.integer.value[0] = spec->clfe_swap;
2685 return 0;
2686}
2687
2688static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2689 struct snd_ctl_elem_value *ucontrol)
2690{
2691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2692 struct sigmatel_spec *spec = codec->spec;
2693 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002694 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002695
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002696 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002697 return 0;
2698
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002699 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002700
2701 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2702 spec->clfe_swap ? 0x4 : 0x0);
2703
2704 return 1;
2705}
2706
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002707#define STAC_CODEC_HP_SWITCH(xname) \
2708 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2709 .name = xname, \
2710 .index = 0, \
2711 .info = stac92xx_hp_switch_info, \
2712 .get = stac92xx_hp_switch_get, \
2713 .put = stac92xx_hp_switch_put, \
2714 }
2715
Matt Porter403d1942005-11-29 15:00:51 +01002716#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2717 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2718 .name = xname, \
2719 .index = 0, \
2720 .info = stac92xx_io_switch_info, \
2721 .get = stac92xx_io_switch_get, \
2722 .put = stac92xx_io_switch_put, \
2723 .private_value = xpval, \
2724 }
2725
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002726#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2727 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2728 .name = xname, \
2729 .index = 0, \
2730 .info = stac92xx_clfe_switch_info, \
2731 .get = stac92xx_clfe_switch_get, \
2732 .put = stac92xx_clfe_switch_put, \
2733 .private_value = xpval, \
2734 }
Matt Porter403d1942005-11-29 15:00:51 +01002735
Mattc7d4b2f2005-06-27 14:59:41 +02002736enum {
2737 STAC_CTL_WIDGET_VOL,
2738 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002739 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002740 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002741 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002742 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002743 STAC_CTL_WIDGET_CLFE_SWITCH,
2744 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002745};
2746
Takashi Iwai2b635362011-05-02 12:33:43 +02002747static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002748 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2749 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002750 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002751 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002752 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002753 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002754 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002755 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002756};
2757
2758/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002759static struct snd_kcontrol_new *
2760stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002761 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002762 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002763 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002764{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002765 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002766
Takashi Iwai603c4012008-07-30 15:01:44 +02002767 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2768 knew = snd_array_new(&spec->kctls);
2769 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002770 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002771 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002772 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002773 if (!knew->name) {
2774 /* roolback */
2775 memset(knew, 0, sizeof(*knew));
2776 spec->kctls.alloced--;
2777 return NULL;
2778 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002779 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002780 return knew;
2781}
2782
2783static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002784 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01002785 int idx, const char *name,
2786 unsigned long val)
2787{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002788 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002789 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002790 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002791 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002792 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002793 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002794 return 0;
2795}
2796
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002797static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2798 int type, int idx, const char *name,
2799 unsigned long val)
2800{
2801 return stac92xx_add_control_temp(spec,
2802 &stac92xx_control_templates[type],
2803 idx, name, val);
2804}
2805
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002806
2807/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002808static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2809 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002810{
2811 return stac92xx_add_control_idx(spec, type, 0, name, val);
2812}
2813
Takashi Iwai2b635362011-05-02 12:33:43 +02002814static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01002815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2816 .name = "Input Source",
2817 .info = stac92xx_mux_enum_info,
2818 .get = stac92xx_mux_enum_get,
2819 .put = stac92xx_mux_enum_put,
2820};
2821
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002822static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2823 hda_nid_t nid, int idx)
2824{
2825 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2826 int control = 0;
2827 struct sigmatel_spec *spec = codec->spec;
2828 char name[22];
2829
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002830 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwai47408602012-04-20 13:06:53 +02002831 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002832 && nid == spec->line_switch)
2833 control = STAC_CTL_WIDGET_IO_SWITCH;
2834 else if (snd_hda_query_pin_caps(codec, nid)
2835 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2836 control = STAC_CTL_WIDGET_DC_BIAS;
2837 else if (nid == spec->mic_switch)
2838 control = STAC_CTL_WIDGET_IO_SWITCH;
2839 }
2840
2841 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01002842 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
2843 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002844 return stac92xx_add_control(codec->spec, control,
2845 strcat(name, " Jack Mode"), nid);
2846 }
2847
2848 return 0;
2849}
2850
Takashi Iwaie3c75962009-01-23 11:57:22 +01002851static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2852{
2853 struct snd_kcontrol_new *knew;
2854 struct hda_input_mux *imux = &spec->private_imux;
2855
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002856 if (spec->auto_mic)
2857 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002858 if (!spec->num_adcs || imux->num_items <= 1)
2859 return 0; /* no need for input source control */
2860 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002861 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002862 if (!knew)
2863 return -ENOMEM;
2864 knew->count = spec->num_adcs;
2865 return 0;
2866}
2867
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002868/* check whether the line-input can be used as line-out */
2869static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002870{
2871 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002872 struct auto_pin_cfg *cfg = &spec->autocfg;
2873 hda_nid_t nid;
2874 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002875 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002876
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002877 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2878 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002879 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02002880 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002881 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01002882 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002883 if (pincap & AC_PINCAP_OUT)
2884 return nid;
2885 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002886 }
Matt Porter403d1942005-11-29 15:00:51 +01002887 return 0;
2888}
2889
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002890static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2891
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002892/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002893static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002894{
2895 struct sigmatel_spec *spec = codec->spec;
2896 struct auto_pin_cfg *cfg = &spec->autocfg;
2897 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02002898 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002899
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002900 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002901 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2902 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002903 for (i = 0; i < cfg->num_inputs; i++) {
2904 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02002905 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002906 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002907 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2908 /* some laptops have an internal analog microphone
2909 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002910 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002911 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002912 if (pincap & AC_PINCAP_OUT) {
2913 *dac = get_unassigned_dac(codec, nid);
2914 if (*dac)
2915 return nid;
2916 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002917 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002918 }
2919 return 0;
2920}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002921
2922static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2923{
2924 int i;
2925
2926 for (i = 0; i < spec->multiout.num_dacs; i++) {
2927 if (spec->multiout.dac_nids[i] == nid)
2928 return 1;
2929 }
2930
2931 return 0;
2932}
2933
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002934static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2935{
2936 int i;
2937 if (is_in_dac_nids(spec, nid))
2938 return 1;
2939 for (i = 0; i < spec->autocfg.hp_outs; i++)
2940 if (spec->hp_dacs[i] == nid)
2941 return 1;
2942 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2943 if (spec->speaker_dacs[i] == nid)
2944 return 1;
2945 return 0;
2946}
2947
2948static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2949{
2950 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02002951 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002952 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02002953 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002954 unsigned int wcaps, wtype;
2955
2956 conn_len = snd_hda_get_connections(codec, nid, conn,
2957 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002958 /* 92HD88: trace back up the link of nids to find the DAC */
2959 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2960 != AC_WID_AUD_OUT)) {
2961 nid = conn[0];
2962 conn_len = snd_hda_get_connections(codec, nid, conn,
2963 HDA_MAX_CONNECTIONS);
2964 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002965 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002966 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002967 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002968 /* we check only analog outputs */
2969 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2970 continue;
2971 /* if this route has a free DAC, assign it */
2972 if (!check_all_dac_nids(spec, conn[j])) {
2973 if (conn_len > 1) {
2974 /* select this DAC in the pin's input mux */
2975 snd_hda_codec_write_cache(codec, nid, 0,
2976 AC_VERB_SET_CONNECT_SEL, j);
2977 }
2978 return conn[j];
2979 }
2980 }
David Henningsson48718ea2011-10-05 09:49:05 +02002981
2982 /* if all DACs are already assigned, connect to the primary DAC,
2983 unless we're assigning a secondary headphone */
2984 fallback_dac = spec->multiout.dac_nids[0];
2985 if (spec->multiout.hp_nid) {
2986 for (j = 0; j < cfg->hp_outs; j++)
2987 if (cfg->hp_pins[j] == nid) {
2988 fallback_dac = spec->multiout.hp_nid;
2989 break;
2990 }
2991 }
2992
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002993 if (conn_len > 1) {
2994 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02002995 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002996 snd_hda_codec_write_cache(codec, nid, 0,
2997 AC_VERB_SET_CONNECT_SEL, j);
2998 break;
2999 }
3000 }
3001 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003002 return 0;
3003}
3004
3005static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3006static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3007
Matt Porter3cc08dc2006-01-23 15:27:49 +01003008/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003009 * Fill in the dac_nids table from the parsed pin configuration
3010 * This function only works when every pin in line_out_pins[]
3011 * contains atleast one DAC in its connection list. Some 92xx
3012 * codecs are not connected directly to a DAC, such as the 9200
3013 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003014 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003015static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003016{
3017 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003018 struct auto_pin_cfg *cfg = &spec->autocfg;
3019 int i;
3020 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003021
Mattc7d4b2f2005-06-27 14:59:41 +02003022 for (i = 0; i < cfg->line_outs; i++) {
3023 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003024 dac = get_unassigned_dac(codec, nid);
3025 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003026 if (spec->multiout.num_dacs > 0) {
3027 /* we have already working output pins,
3028 * so let's drop the broken ones again
3029 */
3030 cfg->line_outs = spec->multiout.num_dacs;
3031 break;
3032 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003033 /* error out, no available DAC found */
3034 snd_printk(KERN_ERR
3035 "%s: No available DAC for pin 0x%x\n",
3036 __func__, nid);
3037 return -ENODEV;
3038 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003039 add_spec_dacs(spec, dac);
3040 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003041
Takashi Iwai139e0712009-03-06 12:10:41 +01003042 for (i = 0; i < cfg->hp_outs; i++) {
3043 nid = cfg->hp_pins[i];
3044 dac = get_unassigned_dac(codec, nid);
3045 if (dac) {
3046 if (!spec->multiout.hp_nid)
3047 spec->multiout.hp_nid = dac;
3048 else
3049 add_spec_extra_dacs(spec, dac);
3050 }
3051 spec->hp_dacs[i] = dac;
3052 }
3053
3054 for (i = 0; i < cfg->speaker_outs; i++) {
3055 nid = cfg->speaker_pins[i];
3056 dac = get_unassigned_dac(codec, nid);
3057 if (dac)
3058 add_spec_extra_dacs(spec, dac);
3059 spec->speaker_dacs[i] = dac;
3060 }
3061
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003062 /* add line-in as output */
3063 nid = check_line_out_switch(codec);
3064 if (nid) {
3065 dac = get_unassigned_dac(codec, nid);
3066 if (dac) {
3067 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3068 nid, cfg->line_outs);
3069 cfg->line_out_pins[cfg->line_outs] = nid;
3070 cfg->line_outs++;
3071 spec->line_switch = nid;
3072 add_spec_dacs(spec, dac);
3073 }
3074 }
3075 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003076 nid = check_mic_out_switch(codec, &dac);
3077 if (nid && dac) {
3078 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3079 nid, cfg->line_outs);
3080 cfg->line_out_pins[cfg->line_outs] = nid;
3081 cfg->line_outs++;
3082 spec->mic_switch = nid;
3083 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003084 }
3085
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003086 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003087 spec->multiout.num_dacs,
3088 spec->multiout.dac_nids[0],
3089 spec->multiout.dac_nids[1],
3090 spec->multiout.dac_nids[2],
3091 spec->multiout.dac_nids[3],
3092 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003093
Mattc7d4b2f2005-06-27 14:59:41 +02003094 return 0;
3095}
3096
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003097/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003098static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3099 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003100{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003101 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003102 char name[32];
3103 int err;
3104
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003105 if (!spec->check_volume_offset) {
3106 unsigned int caps, step, nums, db_scale;
3107 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3108 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3109 AC_AMPCAP_STEP_SIZE_SHIFT;
3110 step = (step + 1) * 25; /* in .01dB unit */
3111 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3112 AC_AMPCAP_NUM_STEPS_SHIFT;
3113 db_scale = nums * step;
3114 /* if dB scale is over -64dB, and finer enough,
3115 * let's reduce it to half
3116 */
3117 if (db_scale > 6400 && nums >= 0x1f)
3118 spec->volume_offset = nums / 2;
3119 spec->check_volume_offset = 1;
3120 }
3121
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003122 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003123 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003124 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3125 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003126 if (err < 0)
3127 return err;
3128 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003129 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003130 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3131 if (err < 0)
3132 return err;
3133 return 0;
3134}
3135
Takashi Iwai668b9652009-03-06 10:13:24 +01003136#define create_controls(codec, pfx, nid, chs) \
3137 create_controls_idx(codec, pfx, 0, nid, chs)
3138
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003139static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3140{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003141 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003142 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3143 return 1;
3144 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003145 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3146 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003147 spec->multiout.num_dacs++;
3148 }
3149 return 0;
3150}
3151
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003152static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003153{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003154 int i;
3155 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3156 if (!spec->multiout.extra_out_nid[i]) {
3157 spec->multiout.extra_out_nid[i] = nid;
3158 return 0;
3159 }
3160 }
3161 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3162 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003163}
3164
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003165/* Create output controls
3166 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3167 */
3168static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3169 const hda_nid_t *pins,
3170 const hda_nid_t *dac_nids,
3171 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003172{
Takashi Iwai76624532008-12-19 10:09:47 +01003173 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003174 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003175 "Front", "Surround", NULL /*CLFE*/, "Side"
3176 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003177 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003178 int i, err;
3179 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003180
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003181 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003182 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003183 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003184 spec->hp_detect = 1;
3185 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003186 nid = dac_nids[i];
3187 if (!nid)
3188 continue;
3189 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003190 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003191 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003192 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003193 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003194 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003195 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003196 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003197
3198 wid_caps = get_wcaps(codec, nid);
3199
3200 if (wid_caps & AC_WCAP_LR_SWAP) {
3201 err = stac92xx_add_control(spec,
3202 STAC_CTL_WIDGET_CLFE_SWITCH,
3203 "Swap Center/LFE Playback Switch", nid);
3204
3205 if (err < 0)
3206 return err;
3207 }
3208
Mattc7d4b2f2005-06-27 14:59:41 +02003209 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003210 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003211 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003212 switch (type) {
3213 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003214 name = "Headphone";
3215 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003216 break;
3217 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003218 name = "Speaker";
3219 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003220 break;
3221 default:
3222 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003223 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003224 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003225 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003226 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003227 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003228 return err;
3229 }
3230 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003231 return 0;
3232}
3233
Takashi Iwai6479c632009-07-28 18:20:25 +02003234static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3235 unsigned long sw, int idx)
3236{
3237 int err;
3238 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003239 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003240 if (err < 0)
3241 return err;
3242 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003243 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003244 if (err < 0)
3245 return err;
3246 return 0;
3247}
3248
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003249/* add playback controls from the parsed DAC table */
3250static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3251 const struct auto_pin_cfg *cfg)
3252{
3253 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003254 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003255 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003256 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003257
3258 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3259 spec->multiout.dac_nids,
3260 cfg->line_out_type);
3261 if (err < 0)
3262 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003263
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003264 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003265 err = stac92xx_add_control(spec,
3266 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003267 "Headphone as Line Out Switch",
3268 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003269 if (err < 0)
3270 return err;
3271 }
3272
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003273 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003274 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003275 break;
3276 nid = cfg->inputs[idx].pin;
3277 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3278 if (err < 0)
3279 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003280 }
Matt Porter403d1942005-11-29 15:00:51 +01003281
Mattc7d4b2f2005-06-27 14:59:41 +02003282 return 0;
3283}
3284
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003285/* add playback controls for Speaker and HP outputs */
3286static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3287 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003288{
3289 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003290 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003291
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003292 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3293 spec->hp_dacs, AUTO_PIN_HP_OUT);
3294 if (err < 0)
3295 return err;
3296
3297 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3298 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3299 if (err < 0)
3300 return err;
3301
Mattc7d4b2f2005-06-27 14:59:41 +02003302 return 0;
3303}
3304
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003305/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003306static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003307 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003308};
3309
3310/* create mono mux for mono out on capable codecs */
3311static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3312{
3313 struct sigmatel_spec *spec = codec->spec;
3314 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3315 int i, num_cons;
3316 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3317
3318 num_cons = snd_hda_get_connections(codec,
3319 spec->mono_nid,
3320 con_lst,
3321 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003322 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003323 return -EINVAL;
3324
Takashi Iwai10a20af2010-09-09 16:28:02 +02003325 for (i = 0; i < num_cons; i++)
3326 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3327 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003328
3329 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3330 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003331}
3332
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003333/* create PC beep volume controls */
3334static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3335 hda_nid_t nid)
3336{
3337 struct sigmatel_spec *spec = codec->spec;
3338 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003339 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3340
3341 if (spec->anabeep_nid == nid)
3342 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003343
3344 /* check for mute support for the the amp */
3345 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003346 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003347 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003348 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3349 if (err < 0)
3350 return err;
3351 }
3352
3353 /* check to see if there is volume support for the amp */
3354 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3355 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003356 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003357 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3358 if (err < 0)
3359 return err;
3360 }
3361 return 0;
3362}
3363
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003364#ifdef CONFIG_SND_HDA_INPUT_BEEP
3365#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3366
3367static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3368 struct snd_ctl_elem_value *ucontrol)
3369{
3370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3371 ucontrol->value.integer.value[0] = codec->beep->enabled;
3372 return 0;
3373}
3374
3375static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3376 struct snd_ctl_elem_value *ucontrol)
3377{
3378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003379 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003380}
3381
Takashi Iwai2b635362011-05-02 12:33:43 +02003382static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3384 .info = stac92xx_dig_beep_switch_info,
3385 .get = stac92xx_dig_beep_switch_get,
3386 .put = stac92xx_dig_beep_switch_put,
3387};
3388
3389static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3390{
3391 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003392 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003393}
3394#endif
3395
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003396static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3397{
3398 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003399 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003400
3401 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003402 hda_nid_t nid;
3403 unsigned int wcaps;
3404 unsigned long val;
3405
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003406 nid = spec->mux_nids[i];
3407 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003408 if (!(wcaps & AC_WCAP_OUT_AMP))
3409 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003410
Takashi Iwai667067d2009-08-13 18:14:42 +02003411 /* check whether already the same control was created as
3412 * normal Capture Volume.
3413 */
3414 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3415 for (j = 0; j < spec->num_caps; j++) {
3416 if (spec->capvols[j] == val)
3417 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003418 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003419 if (j < spec->num_caps)
3420 continue;
3421
3422 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3423 "Mux Capture Volume", val);
3424 if (err < 0)
3425 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003426 }
3427 return 0;
3428};
3429
Takashi Iwaiea734962011-01-17 11:29:34 +01003430static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003431 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003432};
3433
3434static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3435{
3436 struct sigmatel_spec *spec = codec->spec;
3437 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01003438 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003439 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003440 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003441
3442 num_cons = snd_hda_get_connections(codec,
3443 spec->smux_nids[0],
3444 con_lst,
3445 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003446 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003447 return -EINVAL;
3448
Matthew Ranostay65973632008-09-16 10:39:37 -04003449 if (!labels)
3450 labels = stac92xx_spdif_labels;
3451
Takashi Iwai10a20af2010-09-09 16:28:02 +02003452 for (i = 0; i < num_cons; i++)
3453 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02003454
3455 return 0;
3456}
3457
Matt Porter8b657272006-10-26 17:12:59 +02003458/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003459static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003460 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3461 "Digital Mic 3", "Digital Mic 4"
3462};
3463
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003464static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3465 int idx)
3466{
3467 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3468 int nums;
3469 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3470 if (idx >= 0 && idx < nums)
3471 return conn[idx];
3472 return 0;
3473}
3474
Takashi Iwai8d087c72011-06-28 12:45:47 +02003475/* look for NID recursively */
3476#define get_connection_index(codec, mux, nid) \
3477 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003478
Takashi Iwai667067d2009-08-13 18:14:42 +02003479/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003480/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003481static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003482 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003483{
3484 unsigned int caps, nums;
3485 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003486 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003487
Takashi Iwai96f845d2009-08-29 00:49:36 +02003488 if (direction == HDA_OUTPUT)
3489 caps = AC_WCAP_OUT_AMP;
3490 else
3491 caps = AC_WCAP_IN_AMP;
3492 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003493 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003494 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003495 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3496 if (!nums)
3497 return 0;
3498 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003499 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3500 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02003501 if (err < 0)
3502 return err;
3503 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003504}
3505
Matt Porter8b657272006-10-26 17:12:59 +02003506/* create playback/capture controls for input pins on dmic capable codecs */
3507static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3508 const struct auto_pin_cfg *cfg)
3509{
3510 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003511 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003512 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003513 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02003514 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003515
Takashi Iwai10a20af2010-09-09 16:28:02 +02003516 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02003517
Matt Porter8b657272006-10-26 17:12:59 +02003518 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003519 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003520 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01003521 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02003522
Takashi Iwai667067d2009-08-13 18:14:42 +02003523 nid = spec->dmic_nids[i];
3524 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3525 continue;
3526 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003527 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3528 continue;
3529
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003530 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3531 if (index < 0)
3532 continue;
3533
Takashi Iwai201e06f2011-11-16 15:33:26 +01003534 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3535 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02003536 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01003537 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3538 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02003539
Takashi Iwai10a20af2010-09-09 16:28:02 +02003540 err = create_elem_capture_vol(codec, nid, label, type_idx,
3541 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003542 if (err < 0)
3543 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003544 if (!err) {
3545 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02003546 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003547 if (err < 0)
3548 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003549 if (!err) {
3550 nid = get_connected_node(codec,
3551 spec->dmux_nids[0], index);
3552 if (nid)
3553 err = create_elem_capture_vol(codec,
3554 nid, label,
3555 type_idx, HDA_INPUT);
3556 if (err < 0)
3557 return err;
3558 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02003559 }
Matt Porter8b657272006-10-26 17:12:59 +02003560 }
3561
3562 return 0;
3563}
3564
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003565static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02003566 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003567{
3568 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003569 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003570
3571 if (!nid)
3572 return 0;
3573 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003574 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003575 switch (snd_hda_get_input_pin_attr(cfg)) {
3576 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003577 if (*fixed)
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 *fixed = nid;
3582 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003583 case INPUT_PIN_ATTR_UNUSED:
3584 break;
3585 case INPUT_PIN_ATTR_DOCK:
3586 if (*dock)
3587 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003588 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3589 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003590 *dock = nid;
3591 break;
3592 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003593 if (*ext)
3594 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003595 if (type != AC_JACK_MIC_IN)
3596 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003597 *ext = nid;
3598 break;
3599 }
3600 return 0;
3601}
3602
3603static int set_mic_route(struct hda_codec *codec,
3604 struct sigmatel_mic_route *mic,
3605 hda_nid_t pin)
3606{
3607 struct sigmatel_spec *spec = codec->spec;
3608 struct auto_pin_cfg *cfg = &spec->autocfg;
3609 int i;
3610
3611 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02003612 if (pin == 0)
3613 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003614 for (i = 0; i < cfg->num_inputs; i++) {
3615 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003616 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003617 }
Takashi Iwai86e29592010-09-09 14:50:17 +02003618 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003619 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003620 i = get_connection_index(codec, spec->mux_nids[0], pin);
3621 if (i < 0)
3622 return -1;
3623 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003624 mic->dmux_idx = -1;
3625 if (spec->dmux_nids)
3626 mic->dmux_idx = get_connection_index(codec,
3627 spec->dmux_nids[0],
3628 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003629 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003630 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003631 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3632 if (i < 0)
3633 return -1;
3634 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003635 mic->mux_idx = -1;
3636 if (spec->mux_nids)
3637 mic->mux_idx = get_connection_index(codec,
3638 spec->mux_nids[0],
3639 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003640 }
3641 return 0;
3642}
3643
3644/* return non-zero if the device is for automatic mic switch */
3645static int stac_check_auto_mic(struct hda_codec *codec)
3646{
3647 struct sigmatel_spec *spec = codec->spec;
3648 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02003649 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003650 int i;
3651
Charles Chin99077902010-09-17 10:22:32 +02003652 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003653 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02003654 if (check_mic_pin(codec, cfg->inputs[i].pin,
3655 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003656 return 0;
3657 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02003658 if (check_mic_pin(codec, spec->dmic_nids[i],
3659 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003660 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01003661 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02003662 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003663 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003664 return 0; /* no unsol support */
3665 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02003666 set_mic_route(codec, &spec->int_mic, fixed) ||
3667 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003668 return 0; /* something is wrong */
3669 return 1;
3670}
3671
Mattc7d4b2f2005-06-27 14:59:41 +02003672/* create playback/capture controls for input pins */
3673static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3674{
3675 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003676 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003677 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003678 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02003679
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003680 for (i = 0; i < cfg->num_inputs; i++) {
3681 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003682 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02003683
Takashi Iwai314634b2006-09-21 11:56:18 +02003684 index = -1;
3685 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003686 index = get_connection_index(codec, spec->mux_nids[j],
3687 nid);
3688 if (index >= 0)
3689 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003690 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003691 if (index < 0)
3692 continue;
3693
Takashi Iwai10a20af2010-09-09 16:28:02 +02003694 label = hda_get_autocfg_input_label(codec, cfg, i);
3695 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003696
Takashi Iwai667067d2009-08-13 18:14:42 +02003697 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003698 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003699 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003700 if (err < 0)
3701 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003702 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003703 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003704
Steve Longerbeam7b043892007-05-03 20:50:03 +02003705 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003706 /*
3707 * Set the current input for the muxes.
3708 * The STAC9221 has two input muxes with identical source
3709 * NID lists. Hopefully this won't get confused.
3710 */
3711 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003712 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3713 AC_VERB_SET_CONNECT_SEL,
3714 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003715 }
3716 }
3717
Mattc7d4b2f2005-06-27 14:59:41 +02003718 return 0;
3719}
3720
Mattc7d4b2f2005-06-27 14:59:41 +02003721static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3722{
3723 struct sigmatel_spec *spec = codec->spec;
3724 int i;
3725
3726 for (i = 0; i < spec->autocfg.line_outs; i++) {
3727 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3728 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3729 }
3730}
3731
3732static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3733{
3734 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003735 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003736
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003737 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3738 hda_nid_t pin;
3739 pin = spec->autocfg.hp_pins[i];
3740 if (pin) /* connect to front */
3741 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3742 }
3743 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3744 hda_nid_t pin;
3745 pin = spec->autocfg.speaker_pins[i];
3746 if (pin) /* connect to front */
3747 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3748 }
Mattc7d4b2f2005-06-27 14:59:41 +02003749}
3750
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003751static int is_dual_headphones(struct hda_codec *codec)
3752{
3753 struct sigmatel_spec *spec = codec->spec;
3754 int i, valid_hps;
3755
3756 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3757 spec->autocfg.hp_outs <= 1)
3758 return 0;
3759 valid_hps = 0;
3760 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3761 hda_nid_t nid = spec->autocfg.hp_pins[i];
3762 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3763 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3764 continue;
3765 valid_hps++;
3766 }
3767 return (valid_hps > 1);
3768}
3769
3770
Charles Chin9009b0e2011-11-03 10:27:27 +01003771static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003772{
3773 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01003774 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003775 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003776 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003777
Matt Porter8b657272006-10-26 17:12:59 +02003778 if ((err = snd_hda_parse_pin_def_config(codec,
3779 &spec->autocfg,
3780 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003781 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003782 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003783 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003784
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003785 /* If we have no real line-out pin and multiple hp-outs, HPs should
3786 * be set up as multi-channel outputs.
3787 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003788 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003789 /* Copy hp_outs to line_outs, backup line_outs in
3790 * speaker_outs so that the following routines can handle
3791 * HP pins as primary outputs.
3792 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003793 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003794 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3795 sizeof(spec->autocfg.line_out_pins));
3796 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3797 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3798 sizeof(spec->autocfg.hp_pins));
3799 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003800 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3801 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003802 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003803 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003804 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003805 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3806 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003807 u32 caps = query_amp_caps(codec,
3808 spec->autocfg.mono_out_pin, dir);
3809 hda_nid_t conn_list[1];
3810
3811 /* get the mixer node and then the mono mux if it exists */
3812 if (snd_hda_get_connections(codec,
3813 spec->autocfg.mono_out_pin, conn_list, 1) &&
3814 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003815 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003816
3817 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003818 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003819 /* LR swap check, some stac925x have a mux that
3820 * changes the DACs output path instead of the
3821 * mono-mux path.
3822 */
3823 if (wid_type == AC_WID_AUD_SEL &&
3824 !(wcaps & AC_WCAP_LR_SWAP))
3825 spec->mono_nid = conn_list[0];
3826 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003827 if (dir) {
3828 hda_nid_t nid = spec->autocfg.mono_out_pin;
3829
3830 /* most mono outs have a least a mute/unmute switch */
3831 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3832 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3833 "Mono Playback Switch",
3834 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003835 if (err < 0)
3836 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003837 /* check for volume support for the amp */
3838 if ((caps & AC_AMPCAP_NUM_STEPS)
3839 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3840 err = stac92xx_add_control(spec,
3841 STAC_CTL_WIDGET_VOL,
3842 "Mono Playback Volume",
3843 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3844 if (err < 0)
3845 return err;
3846 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003847 }
3848
3849 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3850 AC_PINCTL_OUT_EN);
3851 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003852
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003853 if (!spec->multiout.num_dacs) {
3854 err = stac92xx_auto_fill_dac_nids(codec);
3855 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003856 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003857 err = stac92xx_auto_create_multi_out_ctls(codec,
3858 &spec->autocfg);
3859 if (err < 0)
3860 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003861 }
Mattc7d4b2f2005-06-27 14:59:41 +02003862
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003863 /* setup analog beep controls */
3864 if (spec->anabeep_nid > 0) {
3865 err = stac92xx_auto_create_beep_ctls(codec,
3866 spec->anabeep_nid);
3867 if (err < 0)
3868 return err;
3869 }
3870
3871 /* setup digital beep controls and input device */
3872#ifdef CONFIG_SND_HDA_INPUT_BEEP
3873 if (spec->digbeep_nid > 0) {
3874 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003875 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003876
3877 err = stac92xx_auto_create_beep_ctls(codec, nid);
3878 if (err < 0)
3879 return err;
3880 err = snd_hda_attach_beep_device(codec, nid);
3881 if (err < 0)
3882 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003883 if (codec->beep) {
3884 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003885 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003886 /* if no beep switch is available, make its own one */
3887 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3888 if (!(caps & AC_AMPCAP_MUTE)) {
3889 err = stac92xx_beep_switch_ctl(codec);
3890 if (err < 0)
3891 return err;
3892 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003893 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003894 }
3895#endif
3896
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003897 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003898 if (err < 0)
3899 return err;
3900
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003901 /* All output parsing done, now restore the swapped hp pins */
3902 if (hp_swap) {
3903 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3904 sizeof(spec->autocfg.hp_pins));
3905 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3906 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3907 spec->autocfg.line_outs = 0;
3908 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003909
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003910 if (stac_check_auto_mic(codec)) {
3911 spec->auto_mic = 1;
3912 /* only one capture for auto-mic */
3913 spec->num_adcs = 1;
3914 spec->num_caps = 1;
3915 spec->num_muxes = 1;
3916 }
3917
Takashi Iwai6479c632009-07-28 18:20:25 +02003918 for (i = 0; i < spec->num_caps; i++) {
3919 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3920 spec->capsws[i], i);
3921 if (err < 0)
3922 return err;
3923 }
3924
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003925 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003926 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003927 return err;
3928
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003929 if (spec->mono_nid > 0) {
3930 err = stac92xx_auto_create_mono_output_ctls(codec);
3931 if (err < 0)
3932 return err;
3933 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003934 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003935 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3936 &spec->autocfg)) < 0)
3937 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003938 if (spec->num_muxes > 0) {
3939 err = stac92xx_auto_create_mux_input_ctls(codec);
3940 if (err < 0)
3941 return err;
3942 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003943 if (spec->num_smuxes > 0) {
3944 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3945 if (err < 0)
3946 return err;
3947 }
Matt Porter8b657272006-10-26 17:12:59 +02003948
Takashi Iwaie3c75962009-01-23 11:57:22 +01003949 err = stac92xx_add_input_source(spec);
3950 if (err < 0)
3951 return err;
3952
Mattc7d4b2f2005-06-27 14:59:41 +02003953 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003954 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003955 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003956
Charles Chin9009b0e2011-11-03 10:27:27 +01003957 /* find digital out and in converters */
3958 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3959 unsigned int wid_caps = get_wcaps(codec, i);
3960 if (wid_caps & AC_WCAP_DIGITAL) {
3961 switch (get_wcaps_type(wid_caps)) {
3962 case AC_WID_AUD_OUT:
3963 if (!dig_out)
3964 dig_out = i;
3965 break;
3966 case AC_WID_AUD_IN:
3967 if (!dig_in)
3968 dig_in = i;
3969 break;
3970 }
3971 }
3972 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003973 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003974 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003975 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003976 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003977
Takashi Iwai603c4012008-07-30 15:01:44 +02003978 if (spec->kctls.list)
3979 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003980
3981 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003982 if (!spec->dinput_mux)
3983 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003984 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003985 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003986 return 1;
3987}
3988
Takashi Iwai82bc9552006-03-21 11:24:42 +01003989/* add playback controls for HP output */
3990static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3991 struct auto_pin_cfg *cfg)
3992{
3993 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003994 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003995
3996 if (! pin)
3997 return 0;
3998
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003999 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01004000 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004001
4002 return 0;
4003}
4004
Richard Fish160ea0d2006-09-06 13:58:25 +02004005/* add playback controls for LFE output */
4006static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4007 struct auto_pin_cfg *cfg)
4008{
4009 struct sigmatel_spec *spec = codec->spec;
4010 int err;
4011 hda_nid_t lfe_pin = 0x0;
4012 int i;
4013
4014 /*
4015 * search speaker outs and line outs for a mono speaker pin
4016 * with an amp. If one is found, add LFE controls
4017 * for it.
4018 */
4019 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4020 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004021 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004022 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4023 if (wcaps == AC_WCAP_OUT_AMP)
4024 /* found a mono speaker with an amp, must be lfe */
4025 lfe_pin = pin;
4026 }
4027
4028 /* if speaker_outs is 0, then speakers may be in line_outs */
4029 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4030 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4031 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004032 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004033 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004034 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004035 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004036 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4037 if (wcaps == AC_WCAP_OUT_AMP)
4038 /* found a mono speaker with an amp,
4039 must be lfe */
4040 lfe_pin = pin;
4041 }
4042 }
4043 }
4044
4045 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004046 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004047 if (err < 0)
4048 return err;
4049 }
4050
4051 return 0;
4052}
4053
Mattc7d4b2f2005-06-27 14:59:41 +02004054static int stac9200_parse_auto_config(struct hda_codec *codec)
4055{
4056 struct sigmatel_spec *spec = codec->spec;
4057 int err;
4058
Kailang Yangdf694da2005-12-05 19:42:22 +01004059 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004060 return err;
4061
4062 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4063 return err;
4064
Takashi Iwai82bc9552006-03-21 11:24:42 +01004065 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4066 return err;
4067
Richard Fish160ea0d2006-09-06 13:58:25 +02004068 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4069 return err;
4070
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004071 if (spec->num_muxes > 0) {
4072 err = stac92xx_auto_create_mux_input_ctls(codec);
4073 if (err < 0)
4074 return err;
4075 }
4076
Takashi Iwaie3c75962009-01-23 11:57:22 +01004077 err = stac92xx_add_input_source(spec);
4078 if (err < 0)
4079 return err;
4080
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004081 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004082 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004083 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004084 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004085
Takashi Iwai603c4012008-07-30 15:01:44 +02004086 if (spec->kctls.list)
4087 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004088
4089 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004090 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004091
4092 return 1;
4093}
4094
Sam Revitch62fe78e2006-05-10 15:09:17 +02004095/*
4096 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4097 * funky external mute control using GPIO pins.
4098 */
4099
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004100static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004101 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004102{
4103 unsigned int gpiostate, gpiomask, gpiodir;
4104
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004105 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4106
Sam Revitch62fe78e2006-05-10 15:09:17 +02004107 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4108 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004109 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004110
4111 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4112 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004113 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004114
4115 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4116 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004117 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004118
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004119 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004120 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4121
4122 snd_hda_codec_write(codec, codec->afg, 0,
4123 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004124 snd_hda_codec_read(codec, codec->afg, 0,
4125 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004126
4127 msleep(1);
4128
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004129 snd_hda_codec_read(codec, codec->afg, 0,
4130 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004131}
4132
Takashi Iwai3a938972011-10-28 01:16:55 +02004133static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004134 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004135{
Takashi Iwai3a938972011-10-28 01:16:55 +02004136 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004137
Takashi Iwai3a938972011-10-28 01:16:55 +02004138 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004139 if (!event)
4140 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02004141 event->action = type;
4142 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004143
Takashi Iwai3a938972011-10-28 01:16:55 +02004144 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004145}
4146
Takashi Iwai62558ce2009-07-29 14:23:09 +02004147/* check if given nid is a valid pin and no other events are assigned
4148 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4149 * Otherwise, returns zero.
4150 */
4151static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4152 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004153{
Takashi Iwai3a938972011-10-28 01:16:55 +02004154 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004155
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004156 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004157 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02004158 event = snd_hda_jack_tbl_new(codec, nid);
4159 if (!event)
4160 return -ENOMEM;
4161 if (event->action && event->action != type)
4162 return 0;
4163 event->action = type;
4164 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004165 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004166}
4167
Takashi Iwaib4ead012012-01-23 18:23:36 +01004168static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004169{
4170 int i;
4171 for (i = 0; i < cfg->hp_outs; i++)
4172 if (cfg->hp_pins[i] == nid)
4173 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01004174 for (i = 0; i < cfg->line_outs; i++)
4175 if (cfg->line_out_pins[i] == nid)
4176 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004177 return 0; /* nid is not a HP-Out */
4178};
4179
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004180static void stac92xx_power_down(struct hda_codec *codec)
4181{
4182 struct sigmatel_spec *spec = codec->spec;
4183
4184 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02004185 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004186 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004187 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004188 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004189 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4190}
4191
Takashi Iwaif73d3582008-11-25 08:21:51 +01004192static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4193 int enable);
4194
Takashi Iwai014c41f2009-12-27 13:53:24 +01004195static inline int get_int_hint(struct hda_codec *codec, const char *key,
4196 int *valp)
4197{
4198 const char *p;
4199 p = snd_hda_get_hint(codec, key);
4200 if (p) {
4201 unsigned long val;
4202 if (!strict_strtoul(p, 0, &val)) {
4203 *valp = val;
4204 return 1;
4205 }
4206 }
4207 return 0;
4208}
4209
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004210/* override some hints from the hwdep entry */
4211static void stac_store_hints(struct hda_codec *codec)
4212{
4213 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004214 int val;
4215
4216 val = snd_hda_get_bool_hint(codec, "hp_detect");
4217 if (val >= 0)
4218 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004219 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004220 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4221 spec->gpio_mask;
4222 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004223 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4224 spec->gpio_mask &= spec->gpio_mask;
4225 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4226 spec->gpio_dir &= spec->gpio_mask;
4227 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4228 spec->eapd_mask &= spec->gpio_mask;
4229 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4230 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004231 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4232 if (val >= 0)
4233 spec->eapd_switch = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004234 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4235 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004236 spec->gpio_mask |= spec->gpio_led;
4237 spec->gpio_dir |= spec->gpio_led;
4238 if (spec->gpio_led_polarity)
4239 spec->gpio_data |= spec->gpio_led;
Takashi Iwai043958e2009-12-26 10:36:12 +01004240 }
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004241}
4242
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004243static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4244 const hda_nid_t *pins)
4245{
4246 while (num_pins--)
4247 stac_issue_unsol_event(codec, *pins++);
4248}
4249
4250/* fake event to set up pins */
4251static void stac_fake_hp_events(struct hda_codec *codec)
4252{
4253 struct sigmatel_spec *spec = codec->spec;
4254
4255 if (spec->autocfg.hp_outs)
4256 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4257 spec->autocfg.hp_pins);
4258 if (spec->autocfg.line_outs &&
4259 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4260 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4261 spec->autocfg.line_out_pins);
4262}
4263
Mattc7d4b2f2005-06-27 14:59:41 +02004264static int stac92xx_init(struct hda_codec *codec)
4265{
4266 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004267 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004268 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004269 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004270
Mattc7d4b2f2005-06-27 14:59:41 +02004271 snd_hda_sequence_write(codec, spec->init);
4272
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004273 /* power down adcs initially */
4274 if (spec->powerdown_adcs)
4275 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004276 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004277 spec->adc_nids[i], 0,
4278 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004279
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004280 /* override some hints */
4281 stac_store_hints(codec);
4282
Takashi Iwaif73d3582008-11-25 08:21:51 +01004283 /* set up GPIO */
4284 gpio = spec->gpio_data;
4285 /* turn on EAPD statically when spec->eapd_switch isn't set.
4286 * otherwise, unsol event will turn it on/off dynamically
4287 */
4288 if (!spec->eapd_switch)
4289 gpio |= spec->eapd_mask;
4290 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4291
Takashi Iwai82bc9552006-03-21 11:24:42 +01004292 /* set up pins */
4293 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004294 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004295 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004296 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004297 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004298 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004299 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4300 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004301 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004302 for (i = 0; i < cfg->line_outs; i++) {
4303 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004304 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4305 }
4306 }
4307
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004308 /* force to enable the first line-out; the others are set up
4309 * in unsol_event
4310 */
4311 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004312 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004313 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004314 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004315 } else {
4316 stac92xx_auto_init_multi_out(codec);
4317 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004318 for (i = 0; i < cfg->hp_outs; i++)
4319 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004320 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004321 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004322 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004323 if (spec->dmux_nids)
4324 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004325 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004326 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4327 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02004328 if (enable_pin_detect(codec, spec->dock_mic.pin,
4329 STAC_MIC_EVENT))
4330 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004331 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004332 for (i = 0; i < cfg->num_inputs; i++) {
4333 hda_nid_t nid = cfg->inputs[i].pin;
4334 int type = cfg->inputs[i].type;
4335 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02004336 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004337 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02004338 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004339 pinctl |= AC_PINCTL_IN_EN;
4340 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4341 } else {
4342 pinctl = snd_hda_codec_read(codec, nid, 0,
4343 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4344 /* if PINCTL already set then skip */
4345 /* Also, if both INPUT and OUTPUT are set,
4346 * it must be a BIOS bug; need to override, too
4347 */
4348 if (!(pinctl & AC_PINCTL_IN_EN) ||
4349 (pinctl & AC_PINCTL_OUT_EN)) {
4350 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004351 pinctl |= AC_PINCTL_IN_EN;
4352 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004353 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004354 }
4355 conf = snd_hda_codec_get_pincfg(codec, nid);
4356 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4357 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4358 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01004359 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004360 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004361 for (i = 0; i < spec->num_dmics; i++)
4362 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4363 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004364 if (cfg->dig_out_pins[0])
4365 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004366 AC_PINCTL_OUT_EN);
4367 if (cfg->dig_in_pin)
4368 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4369 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004370 for (i = 0; i < spec->num_pwrs; i++) {
4371 hda_nid_t nid = spec->pwr_nids[i];
4372 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004373
Takashi Iwaieb632122008-12-19 16:39:48 +01004374 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01004375 /* or when the VREF is used for controlling LED */
4376 if (!spec->hp_detect ||
Takashi Iwaia0204282011-12-06 13:17:23 +01004377 spec->vref_mute_led_nid == nid) {
Takashi Iwaieb632122008-12-19 16:39:48 +01004378 stac_toggle_power_map(codec, nid, 1);
4379 continue;
4380 }
4381
Takashi Iwaib4ead012012-01-23 18:23:36 +01004382 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004383 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004384
Takashi Iwaif73d3582008-11-25 08:21:51 +01004385 pinctl = snd_hda_codec_read(codec, nid, 0,
4386 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4387 /* outputs are only ports capable of power management
4388 * any attempts on powering down a input port cause the
4389 * referenced VREF to act quirky.
4390 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004391 if (pinctl & AC_PINCTL_IN_EN) {
4392 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004393 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004394 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004395 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004396 def_conf = get_defcfg_connect(def_conf);
4397 /* skip any ports that don't have jacks since presence
4398 * detection is useless */
4399 if (def_conf != AC_JACK_PORT_COMPLEX) {
4400 if (def_conf != AC_JACK_PORT_NONE)
4401 stac_toggle_power_map(codec, nid, 1);
4402 continue;
4403 }
Charles Chinafef2cf2011-11-11 08:05:28 +01004404 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004405 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01004406 continue;
4407 }
4408 /* none of the above, turn the port OFF */
4409 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004410 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004411
Takashi Iwai01a61e12011-10-28 00:03:22 +02004412 snd_hda_jack_report_sync(codec);
4413
Takashi Iwaic21bd022010-02-08 15:16:08 +01004414 /* sync mute LED */
Takashi Iwaid2f344b2012-03-12 16:59:58 +01004415 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
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
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004434static void stac92xx_shutup_pins(struct hda_codec *codec)
4435{
4436 unsigned int i, def_conf;
4437
4438 if (codec->bus->shutdown)
4439 return;
4440 for (i = 0; i < codec->init_pins.used; i++) {
4441 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4442 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4443 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004444 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004445 }
4446}
4447
Takashi Iwai167eae52009-11-06 15:47:50 +01004448static void stac92xx_shutup(struct hda_codec *codec)
4449{
4450 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004451
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004452 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004453
4454 if (spec->eapd_mask)
4455 stac_gpio_set(codec, spec->gpio_mask,
4456 spec->gpio_dir, spec->gpio_data &
4457 ~spec->eapd_mask);
4458}
4459
Matt2f2f4252005-04-13 14:45:30 +02004460static void stac92xx_free(struct hda_codec *codec)
4461{
Mattc7d4b2f2005-06-27 14:59:41 +02004462 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004463
4464 if (! spec)
4465 return;
4466
Takashi Iwai167eae52009-11-06 15:47:50 +01004467 stac92xx_shutup(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02004468
Mattc7d4b2f2005-06-27 14:59:41 +02004469 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004470 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004471}
4472
Matt4e550962005-07-04 17:51:39 +02004473static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4474 unsigned int flag)
4475{
Takashi Iwai8ce841982009-01-22 16:59:20 +01004476 unsigned int old_ctl, pin_ctl;
4477
4478 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004479 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004480
Takashi Iwaif9acba42007-05-29 18:01:06 +02004481 if (pin_ctl & AC_PINCTL_IN_EN) {
4482 /*
4483 * we need to check the current set-up direction of
4484 * shared input pins since they can be switched via
4485 * "xxx as Output" mixer switch
4486 */
4487 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004488 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004489 return;
4490 }
4491
Takashi Iwai8ce841982009-01-22 16:59:20 +01004492 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004493 /* if setting pin direction bits, clear the current
4494 direction bits first */
4495 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4496 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4497
Takashi Iwai8ce841982009-01-22 16:59:20 +01004498 pin_ctl |= flag;
4499 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004500 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004501}
4502
4503static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4504 unsigned int flag)
4505{
4506 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4507 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce841982009-01-22 16:59:20 +01004508 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004509 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004510}
4511
Takashi Iwaid56757a2009-11-18 08:00:14 +01004512static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004513{
4514 if (!nid)
4515 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004516 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004517}
4518
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004519static void stac92xx_line_out_detect(struct hda_codec *codec,
4520 int presence)
4521{
4522 struct sigmatel_spec *spec = codec->spec;
4523 struct auto_pin_cfg *cfg = &spec->autocfg;
4524 int i;
4525
4526 for (i = 0; i < cfg->line_outs; i++) {
4527 if (presence)
4528 break;
4529 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4530 if (presence) {
4531 unsigned int pinctl;
4532 pinctl = snd_hda_codec_read(codec,
4533 cfg->line_out_pins[i], 0,
4534 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4535 if (pinctl & AC_PINCTL_IN_EN)
4536 presence = 0; /* mic- or line-input */
4537 }
4538 }
4539
4540 if (presence) {
4541 /* disable speakers */
4542 for (i = 0; i < cfg->speaker_outs; i++)
4543 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4544 AC_PINCTL_OUT_EN);
4545 if (spec->eapd_mask && spec->eapd_switch)
4546 stac_gpio_set(codec, spec->gpio_mask,
4547 spec->gpio_dir, spec->gpio_data &
4548 ~spec->eapd_mask);
4549 } else {
4550 /* enable speakers */
4551 for (i = 0; i < cfg->speaker_outs; i++)
4552 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4553 AC_PINCTL_OUT_EN);
4554 if (spec->eapd_mask && spec->eapd_switch)
4555 stac_gpio_set(codec, spec->gpio_mask,
4556 spec->gpio_dir, spec->gpio_data |
4557 spec->eapd_mask);
4558 }
4559}
4560
Takashi Iwaid7a89432008-11-12 09:48:04 +01004561/* return non-zero if the hp-pin of the given array index isn't
4562 * a jack-detection target
4563 */
4564static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4565{
4566 struct auto_pin_cfg *cfg = &spec->autocfg;
4567
4568 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004569 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004570 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004571 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004572 return 1;
4573 /* ignore if the pin is set as line-out */
4574 if (cfg->hp_pins[i] == spec->hp_switch)
4575 return 1;
4576 return 0;
4577}
4578
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004579static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004580{
4581 struct sigmatel_spec *spec = codec->spec;
4582 struct auto_pin_cfg *cfg = &spec->autocfg;
4583 int i, presence;
4584
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004585 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004586 if (spec->gpio_mute)
4587 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4588 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4589
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004590 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004591 if (presence)
4592 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004593 if (no_hp_sensing(spec, i))
4594 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004595 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4596 if (presence) {
4597 unsigned int pinctl;
4598 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4599 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4600 if (pinctl & AC_PINCTL_IN_EN)
4601 presence = 0; /* mic- or line-input */
4602 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004603 }
Matt4e550962005-07-04 17:51:39 +02004604
4605 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004606 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004607 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004608 stac92xx_reset_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_reset_pinctl(codec, cfg->line_out_pins[i],
4612 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004613 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004614 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004615 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004616 stac92xx_set_pinctl(codec, spec->hp_switch,
4617 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004618 for (i = 0; i < cfg->line_outs; i++)
4619 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4620 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004621 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004622 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004623 /* toggle hp outs */
4624 for (i = 0; i < cfg->hp_outs; i++) {
4625 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4626 if (no_hp_sensing(spec, i))
4627 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01004628 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004629 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004630#if 0 /* FIXME */
4631/* Resetting the pinctl like below may lead to (a sort of) regressions
4632 * on some devices since they use the HP pin actually for line/speaker
4633 * outs although the default pin config shows a different pin (that is
4634 * wrong and useless).
4635 *
4636 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4637 * But, disabling the code below just works around it, and I'm too tired of
4638 * bug reports with such devices...
4639 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004640 else
4641 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004642#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004643 }
Matt4e550962005-07-04 17:51:39 +02004644}
4645
Takashi Iwaif73d3582008-11-25 08:21:51 +01004646static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4647 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004648{
4649 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004650 unsigned int idx, val;
4651
4652 for (idx = 0; idx < spec->num_pwrs; idx++) {
4653 if (spec->pwr_nids[idx] == nid)
4654 break;
4655 }
4656 if (idx >= spec->num_pwrs)
4657 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004658
Charles Chinafef2cf2011-11-11 08:05:28 +01004659 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004660
Takashi Iwaif73d3582008-11-25 08:21:51 +01004661 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4662 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004663 val &= ~idx;
4664 else
4665 val |= idx;
4666
4667 /* power down unused output ports */
4668 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004669}
4670
Takashi Iwaif73d3582008-11-25 08:21:51 +01004671static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4672{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004673 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004674}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004675
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004676/* get the pin connection (fixed, none, etc) */
4677static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4678{
4679 struct sigmatel_spec *spec = codec->spec;
4680 unsigned int cfg;
4681
4682 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4683 return get_defcfg_connect(cfg);
4684}
4685
4686static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004687 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004688{
4689 struct sigmatel_spec *spec = codec->spec;
4690 int idx, num;
4691 unsigned int def_conf;
4692
4693 for (num = 0; num < num_nids; num++) {
4694 for (idx = 0; idx < spec->num_pins; idx++)
4695 if (spec->pin_nids[idx] == nids[num])
4696 break;
4697 if (idx >= spec->num_pins)
4698 break;
4699 def_conf = stac_get_defcfg_connect(codec, idx);
4700 if (def_conf == AC_JACK_PORT_NONE)
4701 break;
4702 }
4703 return num;
4704}
4705
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004706static void stac92xx_mic_detect(struct hda_codec *codec)
4707{
4708 struct sigmatel_spec *spec = codec->spec;
4709 struct sigmatel_mic_route *mic;
4710
4711 if (get_pin_presence(codec, spec->ext_mic.pin))
4712 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02004713 else if (get_pin_presence(codec, spec->dock_mic.pin))
4714 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004715 else
4716 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004717 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004718 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4719 AC_VERB_SET_CONNECT_SEL,
4720 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004721 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004722 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4723 AC_VERB_SET_CONNECT_SEL,
4724 mic->mux_idx);
4725}
4726
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004727static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02004728 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02004729{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004730 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004731 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004732
Takashi Iwai3a938972011-10-28 01:16:55 +02004733 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004734 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004735 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004736 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004737 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004738 case STAC_MIC_EVENT:
4739 stac92xx_mic_detect(codec);
4740 break;
4741 }
4742
Takashi Iwai3a938972011-10-28 01:16:55 +02004743 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004744 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004745 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004746 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004747 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004748 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004749 if (spec->num_pwrs > 0)
4750 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004751
4752 switch (codec->subsystem_id) {
4753 case 0x103c308f:
4754 if (event->nid == 0xb) {
4755 int pin = AC_PINCTL_IN_EN;
4756
4757 if (get_pin_presence(codec, 0xa)
4758 && get_pin_presence(codec, 0xb))
4759 pin |= AC_PINCTL_VREF_80;
4760 if (!get_pin_presence(codec, 0xb))
4761 pin |= AC_PINCTL_VREF_80;
4762
4763 /* toggle VREF state based on mic + hp pin
4764 * status
4765 */
4766 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4767 }
4768 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004769 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004770 case STAC_VREF_EVENT:
4771 data = snd_hda_codec_read(codec, codec->afg, 0,
4772 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004773 /* toggle VREF state based on GPIOx status */
4774 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02004775 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004776 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004777 }
4778}
4779
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004780static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4781{
Takashi Iwai3a938972011-10-28 01:16:55 +02004782 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004783 if (!event)
4784 return;
4785 handle_unsol_event(codec, event);
4786}
4787
4788static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4789{
Takashi Iwai3a938972011-10-28 01:16:55 +02004790 struct hda_jack_tbl *event;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004791 int tag;
4792
4793 tag = (res >> 26) & 0x7f;
Takashi Iwai3a938972011-10-28 01:16:55 +02004794 event = snd_hda_jack_tbl_get_from_tag(codec, tag);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004795 if (!event)
4796 return;
Takashi Iwai3a938972011-10-28 01:16:55 +02004797 event->jack_dirty = 1;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004798 handle_unsol_event(codec, event);
Takashi Iwai01a61e12011-10-28 00:03:22 +02004799 snd_hda_jack_report_sync(codec);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004800}
4801
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304802static int hp_blike_system(u32 subsystem_id);
4803
4804static void set_hp_led_gpio(struct hda_codec *codec)
4805{
4806 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004807 unsigned int gpio;
4808
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004809 if (spec->gpio_led)
4810 return;
4811
Takashi Iwai07f80442010-02-08 15:06:13 +01004812 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4813 gpio &= AC_GPIO_IO_COUNT;
4814 if (gpio > 3)
4815 spec->gpio_led = 0x08; /* GPIO 3 */
4816 else
4817 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304818}
4819
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004820/*
4821 * This method searches for the mute LED GPIO configuration
4822 * provided as OEM string in SMBIOS. The format of that string
4823 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4824 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4825 * that corresponds to the NOT muted state of the master volume
4826 * and G is the index of the GPIO to use as the mute LED control (0..9)
4827 * If _G portion is missing it is assigned based on the codec ID
4828 *
4829 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4830 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304831 *
4832 *
4833 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4834 * SMBIOS - at least the ones I have seen do not have them - which include
4835 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4836 * HP Pavilion dv9500t CTO.
4837 * Need more information on whether it is true across the entire series.
4838 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004839 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004840static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004841{
4842 struct sigmatel_spec *spec = codec->spec;
4843 const struct dmi_device *dev = NULL;
4844
4845 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4846 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4847 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004848 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304849 &spec->gpio_led_polarity,
4850 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004851 unsigned int max_gpio;
4852 max_gpio = snd_hda_param_read(codec, codec->afg,
4853 AC_PAR_GPIO_CAP);
4854 max_gpio &= AC_GPIO_IO_COUNT;
4855 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004856 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01004857 else
4858 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004859 return 1;
4860 }
4861 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304862 &spec->gpio_led_polarity) == 1) {
4863 set_hp_led_gpio(codec);
4864 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004865 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004866 /* BIOS bug: unfilled OEM string */
4867 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4868 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02004869 switch (codec->subsystem_id) {
4870 case 0x103c148a:
4871 spec->gpio_led_polarity = 0;
4872 break;
4873 default:
4874 spec->gpio_led_polarity = 1;
4875 break;
4876 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004877 return 1;
4878 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004879 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304880
4881 /*
4882 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004883 * we statically set the GPIO - if not a B-series system
4884 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304885 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004886 if (!hp_blike_system(codec->subsystem_id) &&
4887 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304888 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004889 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304890 return 1;
4891 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004892 }
4893 return 0;
4894}
4895
4896static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004897{
4898 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004899 case 0x103c1520:
4900 case 0x103c1521:
4901 case 0x103c1523:
4902 case 0x103c1524:
4903 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004904 case 0x103c1722:
4905 case 0x103c1723:
4906 case 0x103c1724:
4907 case 0x103c1725:
4908 case 0x103c1726:
4909 case 0x103c1727:
4910 case 0x103c1728:
4911 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004912 case 0x103c172a:
4913 case 0x103c172b:
4914 case 0x103c307e:
4915 case 0x103c307f:
4916 case 0x103c3080:
4917 case 0x103c3081:
4918 case 0x103c7007:
4919 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004920 return 1;
4921 }
4922 return 0;
4923}
4924
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004925#ifdef CONFIG_PROC_FS
4926static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4927 struct hda_codec *codec, hda_nid_t nid)
4928{
4929 if (nid == codec->afg)
4930 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4931 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4932}
4933
4934static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4935 struct hda_codec *codec,
4936 unsigned int verb)
4937{
4938 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4939 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4940}
4941
4942/* stac92hd71bxx, stac92hd73xx */
4943static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4944 struct hda_codec *codec, hda_nid_t nid)
4945{
4946 stac92hd_proc_hook(buffer, codec, nid);
4947 if (nid == codec->afg)
4948 analog_loop_proc_hook(buffer, codec, 0xfa0);
4949}
4950
4951static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4952 struct hda_codec *codec, hda_nid_t nid)
4953{
4954 if (nid == codec->afg)
4955 analog_loop_proc_hook(buffer, codec, 0xfe0);
4956}
4957
4958static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4959 struct hda_codec *codec, hda_nid_t nid)
4960{
4961 if (nid == codec->afg)
4962 analog_loop_proc_hook(buffer, codec, 0xfeb);
4963}
4964#else
4965#define stac92hd_proc_hook NULL
4966#define stac92hd7x_proc_hook NULL
4967#define stac9205_proc_hook NULL
4968#define stac927x_proc_hook NULL
4969#endif
4970
Takashi Iwai2a439522011-07-26 09:52:50 +02004971#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02004972static int stac92xx_resume(struct hda_codec *codec)
4973{
Takashi Iwai2c885872008-11-18 09:36:55 +01004974 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004975 snd_hda_codec_resume_amp(codec);
4976 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004977 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004978 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02004979 return 0;
4980}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004981
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004982static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4983{
4984 stac92xx_shutup(codec);
4985 return 0;
4986}
4987
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004988static int stac92xx_pre_resume(struct hda_codec *codec)
4989{
4990 struct sigmatel_spec *spec = codec->spec;
4991
4992 /* sync mute LED */
Takashi Iwaif1a73742011-12-04 13:44:06 +01004993 if (spec->vref_mute_led_nid)
4994 stac_vrefout_set(codec, spec->vref_mute_led_nid,
4995 spec->vref_led);
4996 else if (spec->gpio_led)
4997 stac_gpio_set(codec, spec->gpio_mask,
4998 spec->gpio_dir, spec->gpio_data);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004999 return 0;
5000}
5001
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005002static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5003 unsigned int power_state)
5004{
5005 unsigned int afg_power_state = power_state;
5006 struct sigmatel_spec *spec = codec->spec;
5007
5008 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005009 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005010 /* with vref-out pin used for mute led control
5011 * codec AFG is prevented from D3 state
5012 */
5013 afg_power_state = AC_PWRST_D1;
5014 }
5015 /* this delay seems necessary to avoid click noise at power-down */
5016 msleep(100);
5017 }
5018 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5019 afg_power_state);
5020 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5021}
Takashi Iwai350eba42012-03-16 16:09:03 +01005022#else
5023#define stac92xx_suspend NULL
5024#define stac92xx_resume NULL
5025#define stac92xx_pre_resume NULL
5026#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005027#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005028
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005029/* update mute-LED accoring to the master switch */
5030static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005031{
5032 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005033 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005034
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005035 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005036 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005037
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005038 /* LED state is inverted on these systems */
5039 if (spec->gpio_led_polarity)
5040 muted = !muted;
5041
Takashi Iwaif1a73742011-12-04 13:44:06 +01005042 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005043 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02005044 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005045 else
Takashi Iwai3e843192012-04-19 12:04:03 +02005046 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005047 stac_gpio_set(codec, spec->gpio_mask,
5048 spec->gpio_dir, spec->gpio_data);
5049 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005050 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005051 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5052 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005053 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005054}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05005055
Takashi Iwai2b635362011-05-02 12:33:43 +02005056static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005057 .build_controls = stac92xx_build_controls,
5058 .build_pcms = stac92xx_build_pcms,
5059 .init = stac92xx_init,
5060 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02005061 .unsol_event = stac92xx_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02005062#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005063 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005064 .resume = stac92xx_resume,
5065#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005066 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005067};
5068
5069static int patch_stac9200(struct hda_codec *codec)
5070{
5071 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005072 int err;
Matt2f2f4252005-04-13 14:45:30 +02005073
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005074 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005075 if (spec == NULL)
5076 return -ENOMEM;
5077
Takashi Iwaia252c812009-12-25 22:56:20 +01005078 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005079 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005080 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005081 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005082 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005083 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5084 stac9200_models,
5085 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005086 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005087 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5088 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005089 else
5090 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005091 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005092
5093 spec->multiout.max_channels = 2;
5094 spec->multiout.num_dacs = 1;
5095 spec->multiout.dac_nids = stac9200_dac_nids;
5096 spec->adc_nids = stac9200_adc_nids;
5097 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005098 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005099 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005100 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005101 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005102
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005103 if (spec->board_config == STAC_9200_M4 ||
5104 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005105 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005106 spec->init = stac9200_eapd_init;
5107 else
5108 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005109 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005110
Takashi Iwai117f2572008-03-18 09:53:23 +01005111 if (spec->board_config == STAC_9200_PANASONIC) {
5112 spec->gpio_mask = spec->gpio_dir = 0x09;
5113 spec->gpio_data = 0x00;
5114 }
5115
Mattc7d4b2f2005-06-27 14:59:41 +02005116 err = stac9200_parse_auto_config(codec);
5117 if (err < 0) {
5118 stac92xx_free(codec);
5119 return err;
5120 }
Matt2f2f4252005-04-13 14:45:30 +02005121
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005122 /* CF-74 has no headphone detection, and the driver should *NOT*
5123 * do detection and HP/speaker toggle because the hardware does it.
5124 */
5125 if (spec->board_config == STAC_9200_PANASONIC)
5126 spec->hp_detect = 0;
5127
Matt2f2f4252005-04-13 14:45:30 +02005128 codec->patch_ops = stac92xx_patch_ops;
5129
5130 return 0;
5131}
5132
Tobin Davis8e21c342007-01-08 11:04:17 +01005133static int patch_stac925x(struct hda_codec *codec)
5134{
5135 struct sigmatel_spec *spec;
5136 int err;
5137
5138 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5139 if (spec == NULL)
5140 return -ENOMEM;
5141
Takashi Iwaia252c812009-12-25 22:56:20 +01005142 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005143 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005144 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005145 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005146 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005147
5148 /* Check first for codec ID */
5149 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5150 STAC_925x_MODELS,
5151 stac925x_models,
5152 stac925x_codec_id_cfg_tbl);
5153
5154 /* Now checks for PCI ID, if codec ID is not found */
5155 if (spec->board_config < 0)
5156 spec->board_config = snd_hda_check_board_config(codec,
5157 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005158 stac925x_models,
5159 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005160 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005161 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005162 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5163 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005164 else
5165 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005166 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005167
5168 spec->multiout.max_channels = 2;
5169 spec->multiout.num_dacs = 1;
5170 spec->multiout.dac_nids = stac925x_dac_nids;
5171 spec->adc_nids = stac925x_adc_nids;
5172 spec->mux_nids = stac925x_mux_nids;
5173 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005174 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005175 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005176 switch (codec->vendor_id) {
5177 case 0x83847632: /* STAC9202 */
5178 case 0x83847633: /* STAC9202D */
5179 case 0x83847636: /* STAC9251 */
5180 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005181 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005182 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005183 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5184 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005185 break;
5186 default:
5187 spec->num_dmics = 0;
5188 break;
5189 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005190
5191 spec->init = stac925x_core_init;
5192 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005193 spec->num_caps = 1;
5194 spec->capvols = stac925x_capvols;
5195 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005196
Charles Chin9009b0e2011-11-03 10:27:27 +01005197 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005198 if (!err) {
5199 if (spec->board_config < 0) {
5200 printk(KERN_WARNING "hda_codec: No auto-config is "
5201 "available, default to model=ref\n");
5202 spec->board_config = STAC_925x_REF;
5203 goto again;
5204 }
5205 err = -EINVAL;
5206 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005207 if (err < 0) {
5208 stac92xx_free(codec);
5209 return err;
5210 }
5211
5212 codec->patch_ops = stac92xx_patch_ops;
5213
5214 return 0;
5215}
5216
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005217static int patch_stac92hd73xx(struct hda_codec *codec)
5218{
5219 struct sigmatel_spec *spec;
5220 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5221 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005222 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005223
5224 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5225 if (spec == NULL)
5226 return -ENOMEM;
5227
Takashi Iwaia252c812009-12-25 22:56:20 +01005228 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005229 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005230 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005231 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005232 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5233 spec->pin_nids = stac92hd73xx_pin_nids;
5234 spec->board_config = snd_hda_check_board_config(codec,
5235 STAC_92HD73XX_MODELS,
5236 stac92hd73xx_models,
5237 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005238 /* check codec subsystem id if not found */
5239 if (spec->board_config < 0)
5240 spec->board_config =
5241 snd_hda_check_board_codec_sid_config(codec,
5242 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5243 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005244again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005245 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005246 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5247 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005248 else
5249 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005250 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005251
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005252 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005253 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5254
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005255 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005256 printk(KERN_WARNING "hda_codec: Could not determine "
5257 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005258 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005259 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005260 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005261 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005262 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005263 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005264 break;
5265 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005266 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005267 break;
5268 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005269 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5270 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005271 }
5272 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005273
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005274 spec->aloopback_mask = 0x01;
5275 spec->aloopback_shift = 8;
5276
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005277 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005278 spec->mux_nids = stac92hd73xx_mux_nids;
5279 spec->adc_nids = stac92hd73xx_adc_nids;
5280 spec->dmic_nids = stac92hd73xx_dmic_nids;
5281 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005282 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005283
5284 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5285 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005286 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005287
Takashi Iwai6479c632009-07-28 18:20:25 +02005288 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5289 spec->capvols = stac92hd73xx_capvols;
5290 spec->capsws = stac92hd73xx_capsws;
5291
Matthew Ranostaya7662642008-02-21 07:51:14 +01005292 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005293 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005294 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005295 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005296 case STAC_DELL_M6_AMIC:
5297 case STAC_DELL_M6_DMIC:
5298 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005299 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005300 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005301
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005302 switch (spec->board_config) {
5303 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005304 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005305 spec->num_dmics = 0;
5306 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005307 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005308 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005309 spec->num_dmics = 1;
5310 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005311 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005312 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5313 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005314 spec->num_dmics = 1;
5315 break;
5316 }
5317 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005318 case STAC_ALIENWARE_M17X:
5319 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5320 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5321 spec->eapd_switch = 0;
5322 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005323 default:
5324 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005325 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005326 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005327 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005328 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005329 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005330 /* GPIO0 High = Enable EAPD */
5331 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5332 spec->gpio_data = 0x01;
5333 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005334
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005335 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5336 spec->pwr_nids = stac92hd73xx_pwr_nids;
5337
Charles Chin9009b0e2011-11-03 10:27:27 +01005338 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005339
5340 if (!err) {
5341 if (spec->board_config < 0) {
5342 printk(KERN_WARNING "hda_codec: No auto-config is "
5343 "available, default to model=ref\n");
5344 spec->board_config = STAC_92HD73XX_REF;
5345 goto again;
5346 }
5347 err = -EINVAL;
5348 }
5349
5350 if (err < 0) {
5351 stac92xx_free(codec);
5352 return err;
5353 }
5354
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005355 if (spec->board_config == STAC_92HD73XX_NO_JD)
5356 spec->hp_detect = 0;
5357
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005358 codec->patch_ops = stac92xx_patch_ops;
5359
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005360 codec->proc_widget_hook = stac92hd7x_proc_hook;
5361
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005362 return 0;
5363}
5364
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005365static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005366{
5367 if (codec->vendor_id != 0x111d7605 &&
5368 codec->vendor_id != 0x111d76d1)
5369 return 0;
5370
5371 switch (codec->subsystem_id) {
5372 case 0x103c1618:
5373 case 0x103c1619:
5374 case 0x103c161a:
5375 case 0x103c161b:
5376 case 0x103c161c:
5377 case 0x103c161d:
5378 case 0x103c161e:
5379 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005380
5381 case 0x103c162a:
5382 case 0x103c162b:
5383
5384 case 0x103c1630:
5385 case 0x103c1631:
5386
5387 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005388 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005389 case 0x103c1635:
5390
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005391 case 0x103c3587:
5392 case 0x103c3588:
5393 case 0x103c3589:
5394 case 0x103c358a:
5395
5396 case 0x103c3667:
5397 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005398 case 0x103c3669:
5399
5400 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005401 }
5402 return 0;
5403}
5404
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005405static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5406{
5407 struct sigmatel_spec *spec = codec->spec;
5408 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5409 int i;
5410
5411 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5412 spec->auto_pin_cnt++;
5413
5414 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5415 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5416 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5417 if (nid == stac92hd83xxx_dmic_nids[i]) {
5418 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5419 spec->auto_dmic_cnt++;
5420 }
5421 }
5422 }
5423}
5424
5425static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5426{
5427 struct sigmatel_spec *spec = codec->spec;
5428
5429 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5430 spec->auto_adc_cnt++;
5431}
5432
5433static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5434{
5435 int i, j;
5436 struct sigmatel_spec *spec = codec->spec;
5437
5438 for (i = 0; i < spec->auto_adc_cnt; i++) {
5439 if (get_connection_index(codec,
5440 spec->auto_adc_nids[i], nid) >= 0) {
5441 /* mux and volume for adc_nids[i] */
5442 if (!spec->auto_mux_nids[i]) {
5443 spec->auto_mux_nids[i] = nid;
5444 /* 92hd codecs capture volume is in mux */
5445 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5446 3, 0, HDA_OUTPUT);
5447 }
5448 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5449 if (get_connection_index(codec, nid,
5450 spec->auto_dmic_nids[j]) >= 0) {
5451 /* dmux for adc_nids[i] */
5452 if (!spec->auto_dmux_nids[i])
5453 spec->auto_dmux_nids[i] = nid;
5454 break;
5455 }
5456 }
5457 break;
5458 }
5459 }
5460}
5461
5462static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5463{
5464 hda_nid_t nid, end_nid;
5465 unsigned int wid_caps, wid_type;
5466 struct sigmatel_spec *spec = codec->spec;
5467
5468 end_nid = codec->start_nid + codec->num_nodes;
5469
5470 for (nid = codec->start_nid; nid < end_nid; nid++) {
5471 wid_caps = get_wcaps(codec, nid);
5472 wid_type = get_wcaps_type(wid_caps);
5473
5474 if (wid_type == AC_WID_PIN)
5475 stac92hd8x_add_pin(codec, nid);
5476
5477 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5478 stac92hd8x_add_adc(codec, nid);
5479 }
5480
5481 for (nid = codec->start_nid; nid < end_nid; nid++) {
5482 wid_caps = get_wcaps(codec, nid);
5483 wid_type = get_wcaps_type(wid_caps);
5484
5485 if (wid_type == AC_WID_AUD_SEL)
5486 stac92hd8x_add_mux(codec, nid);
5487 }
5488
5489 spec->pin_nids = spec->auto_pin_nids;
5490 spec->num_pins = spec->auto_pin_cnt;
5491 spec->adc_nids = spec->auto_adc_nids;
5492 spec->num_adcs = spec->auto_adc_cnt;
5493 spec->capvols = spec->auto_capvols;
5494 spec->capsws = spec->auto_capvols;
5495 spec->num_caps = spec->auto_adc_cnt;
5496 spec->mux_nids = spec->auto_mux_nids;
5497 spec->num_muxes = spec->auto_adc_cnt;
5498 spec->dmux_nids = spec->auto_dmux_nids;
5499 spec->num_dmuxes = spec->auto_adc_cnt;
5500 spec->dmic_nids = spec->auto_dmic_nids;
5501 spec->num_dmics = spec->auto_dmic_cnt;
5502}
5503
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005504static int patch_stac92hd83xxx(struct hda_codec *codec)
5505{
5506 struct sigmatel_spec *spec;
5507 int err;
5508
5509 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5510 if (spec == NULL)
5511 return -ENOMEM;
5512
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005513 if (hp_bnb2011_with_dock(codec)) {
5514 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5515 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5516 }
5517
Takashi Iwaia252c812009-12-25 22:56:20 +01005518 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005519 codec->spec = spec;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005520
5521 stac92hd8x_fill_auto_spec(codec);
5522
Takashi Iwai1db7ccd2010-12-03 15:19:14 +01005523 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005524 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005525 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005526 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005527 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005528 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005529 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005530
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005531 spec->board_config = snd_hda_check_board_config(codec,
5532 STAC_92HD83XXX_MODELS,
5533 stac92hd83xxx_models,
5534 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005535 /* check codec subsystem id if not found */
5536 if (spec->board_config < 0)
5537 spec->board_config =
5538 snd_hda_check_board_codec_sid_config(codec,
5539 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
5540 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005541again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005542 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005543 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5544 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005545 else
5546 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005547 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005548
Takashi Iwaib4e81872009-11-18 17:20:24 +01005549 codec->patch_ops = stac92xx_patch_ops;
5550
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005551 switch (spec->board_config) {
5552 case STAC_HP_ZEPHYR:
5553 spec->init = stac92hd83xxx_hp_zephyr_init;
5554 break;
5555 }
5556
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005557 if (find_mute_led_cfg(codec, -1/*no default cfg*/))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005558 snd_printd("mute LED gpio %d polarity %d\n",
5559 spec->gpio_led,
5560 spec->gpio_led_polarity);
5561
Takashi Iwaib4e81872009-11-18 17:20:24 +01005562 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005563 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005564 spec->gpio_mask |= spec->gpio_led;
5565 spec->gpio_dir |= spec->gpio_led;
5566 spec->gpio_data |= spec->gpio_led;
5567 } else {
5568 codec->patch_ops.set_power_state =
5569 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005570 }
Takashi Iwai350eba42012-03-16 16:09:03 +01005571#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005572 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba42012-03-16 16:09:03 +01005573#endif
Takashi Iwaib4e81872009-11-18 17:20:24 +01005574 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005575
Charles Chin9009b0e2011-11-03 10:27:27 +01005576 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005577 if (!err) {
5578 if (spec->board_config < 0) {
5579 printk(KERN_WARNING "hda_codec: No auto-config is "
5580 "available, default to model=ref\n");
5581 spec->board_config = STAC_92HD83XXX_REF;
5582 goto again;
5583 }
5584 err = -EINVAL;
5585 }
5586
5587 if (err < 0) {
5588 stac92xx_free(codec);
5589 return err;
5590 }
5591
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005592 codec->proc_widget_hook = stac92hd_proc_hook;
5593
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005594 return 0;
5595}
5596
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005597static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5598 hda_nid_t dig0pin)
5599{
5600 struct sigmatel_spec *spec = codec->spec;
5601 int idx;
5602
5603 for (idx = 0; idx < spec->num_pins; idx++)
5604 if (spec->pin_nids[idx] == dig0pin)
5605 break;
5606 if ((idx + 2) >= spec->num_pins)
5607 return 0;
5608
5609 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005610 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005611 return 2;
5612
5613 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005614 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005615 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005616 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005617 return 1;
5618 else
5619 return 0;
5620}
5621
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005622/* HP dv7 bass switch - GPIO5 */
5623#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5624static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5625 struct snd_ctl_elem_value *ucontrol)
5626{
5627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5628 struct sigmatel_spec *spec = codec->spec;
5629 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5630 return 0;
5631}
5632
5633static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5634 struct snd_ctl_elem_value *ucontrol)
5635{
5636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5637 struct sigmatel_spec *spec = codec->spec;
5638 unsigned int gpio_data;
5639
5640 gpio_data = (spec->gpio_data & ~0x20) |
5641 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5642 if (gpio_data == spec->gpio_data)
5643 return 0;
5644 spec->gpio_data = gpio_data;
5645 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5646 return 1;
5647}
5648
Takashi Iwai2b635362011-05-02 12:33:43 +02005649static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005650 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5651 .info = stac_hp_bass_gpio_info,
5652 .get = stac_hp_bass_gpio_get,
5653 .put = stac_hp_bass_gpio_put,
5654};
5655
5656static int stac_add_hp_bass_switch(struct hda_codec *codec)
5657{
5658 struct sigmatel_spec *spec = codec->spec;
5659
5660 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5661 "Bass Speaker Playback Switch", 0))
5662 return -ENOMEM;
5663
5664 spec->gpio_mask |= 0x20;
5665 spec->gpio_dir |= 0x20;
5666 spec->gpio_data |= 0x20;
5667 return 0;
5668}
5669
Matthew Ranostaye035b842007-11-06 11:53:55 +01005670static int patch_stac92hd71bxx(struct hda_codec *codec)
5671{
5672 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02005673 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005674 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005675 int err = 0;
5676
5677 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5678 if (spec == NULL)
5679 return -ENOMEM;
5680
Takashi Iwaia252c812009-12-25 22:56:20 +01005681 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005682 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005683 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005684 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005685 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5686 switch (codec->vendor_id) {
5687 case 0x111d76b6:
5688 case 0x111d76b7:
5689 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5690 break;
5691 case 0x111d7603:
5692 case 0x111d7608:
5693 /* On 92HD75Bx 0x27 isn't a pin nid */
5694 spec->num_pins--;
5695 /* fallthrough */
5696 default:
5697 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5698 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005699 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005700 spec->board_config = snd_hda_check_board_config(codec,
5701 STAC_92HD71BXX_MODELS,
5702 stac92hd71bxx_models,
5703 stac92hd71bxx_cfg_tbl);
5704again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005705 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005706 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5707 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005708 else
5709 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005710 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005711
Takashi Iwaifc64b262009-09-14 15:33:01 +02005712 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005713 /* GPIO0 = EAPD */
5714 spec->gpio_mask = 0x01;
5715 spec->gpio_dir = 0x01;
5716 spec->gpio_data = 0x01;
5717 }
5718
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005719 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5720 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5721
Takashi Iwai6479c632009-07-28 18:20:25 +02005722 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5723 spec->capvols = stac92hd71bxx_capvols;
5724 spec->capsws = stac92hd71bxx_capsws;
5725
Matthew Ranostay541eee82007-12-14 12:08:04 +01005726 switch (codec->vendor_id) {
5727 case 0x111d76b6: /* 4 Port without Analog Mixer */
5728 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005729 unmute_init++;
5730 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005731 case 0x111d76b4: /* 6 Port without Analog Mixer */
5732 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005733 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005734 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005735 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005736 stac92hd71bxx_dmic_nids,
5737 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005738 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005739 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005740 switch (spec->board_config) {
5741 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005742 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai3a938972011-10-28 01:16:55 +02005743 err = stac_add_event(codec, codec->afg,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005744 STAC_VREF_EVENT, 0x02);
5745 if (err < 0)
5746 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005747 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005748 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai3a938972011-10-28 01:16:55 +02005749 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005750 spec->gpio_mask |= 0x02;
5751 break;
5752 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005753 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005754 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005755 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005756
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005757 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005758 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005759 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005760 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5761 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02005762 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005763 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005764 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005765 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005766 break;
5767 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005768 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005769 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005770
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005771 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005772 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005773 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005774 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005775 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005776 stac92hd71bxx_dmic_nids,
5777 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005778 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005779 }
5780
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005781 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5782 snd_hda_sequence_write_cache(codec, unmute_init);
5783
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005784 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005785 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005786 spec->aloopback_shift = 0;
5787
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005788 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005789 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005790 spec->mux_nids = stac92hd71bxx_mux_nids;
5791 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005792 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005793 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005794
5795 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5796 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005797 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005798 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005799
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305800 snd_printdd("Found board config: %d\n", spec->board_config);
5801
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005802 switch (spec->board_config) {
5803 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005804 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005805 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005806 stac92xx_auto_set_pinctl(codec, 0x0e,
5807 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005808 /* fallthru */
5809 case STAC_DELL_M4_2:
5810 spec->num_dmics = 0;
5811 spec->num_smuxes = 0;
5812 spec->num_dmuxes = 0;
5813 break;
5814 case STAC_DELL_M4_1:
5815 case STAC_DELL_M4_3:
5816 spec->num_dmics = 1;
5817 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005818 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005819 break;
James Gardiner514bf542009-05-03 04:00:44 -04005820 case STAC_HP_DV4_1222NR:
5821 spec->num_dmics = 1;
5822 /* I don't know if it needs 1 or 2 smuxes - will wait for
5823 * bug reports to fix if needed
5824 */
5825 spec->num_smuxes = 1;
5826 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005827 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005828 case STAC_HP_DV4:
5829 spec->gpio_led = 0x01;
5830 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005831 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005832 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005833 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005834 /* HP dv6 gives the headphone pin as a line-out. Thus we
5835 * need to set hp_detect flag here to force to enable HP
5836 * detection.
5837 */
5838 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005839 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005840 case STAC_HP_HDX:
5841 spec->num_dmics = 1;
5842 spec->num_dmuxes = 1;
5843 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005844 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005845 break;
5846 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005847
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005848 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005849 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5850 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5851 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5852 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5853 /* It was changed in the BIOS to just satisfy MS DTM.
5854 * Lets turn it back into slaved HP
5855 */
5856 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5857 | (AC_JACK_HP_OUT <<
5858 AC_DEFCFG_DEVICE_SHIFT);
5859 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5860 | AC_DEFCFG_SEQUENCE)))
5861 | 0x1f;
5862 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5863 }
5864 }
5865
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005866 if (find_mute_led_cfg(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005867 snd_printd("mute LED gpio %d polarity %d\n",
5868 spec->gpio_led,
5869 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005870
Takashi Iwai86d190e2009-05-26 15:18:58 +02005871 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005872 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005873 spec->gpio_mask |= spec->gpio_led;
5874 spec->gpio_dir |= spec->gpio_led;
5875 spec->gpio_data |= spec->gpio_led;
5876 } else {
5877 codec->patch_ops.set_power_state =
5878 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005879 }
Takashi Iwai350eba42012-03-16 16:09:03 +01005880#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005881 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba42012-03-16 16:09:03 +01005882#endif
Takashi Iwai86d190e2009-05-26 15:18:58 +02005883 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005884
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005885 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005886
Charles Chin9009b0e2011-11-03 10:27:27 +01005887 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005888 if (!err) {
5889 if (spec->board_config < 0) {
5890 printk(KERN_WARNING "hda_codec: No auto-config is "
5891 "available, default to model=ref\n");
5892 spec->board_config = STAC_92HD71BXX_REF;
5893 goto again;
5894 }
5895 err = -EINVAL;
5896 }
5897
5898 if (err < 0) {
5899 stac92xx_free(codec);
5900 return err;
5901 }
5902
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005903 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005904 if (spec->board_config == STAC_HP_DV4 ||
5905 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005906 unsigned int cap;
5907 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5908 cap &= AC_GPIO_IO_COUNT;
5909 if (cap >= 6)
5910 stac_add_hp_bass_switch(codec);
5911 }
5912
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005913 codec->proc_widget_hook = stac92hd7x_proc_hook;
5914
Matthew Ranostaye035b842007-11-06 11:53:55 +01005915 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005916}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005917
Matt2f2f4252005-04-13 14:45:30 +02005918static int patch_stac922x(struct hda_codec *codec)
5919{
5920 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005921 int err;
Matt2f2f4252005-04-13 14:45:30 +02005922
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005923 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005924 if (spec == NULL)
5925 return -ENOMEM;
5926
Takashi Iwaia252c812009-12-25 22:56:20 +01005927 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005928 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005929 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005930 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005931 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005932 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5933 stac922x_models,
5934 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005935 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005936 spec->gpio_mask = spec->gpio_dir = 0x03;
5937 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005938 /* Intel Macs have all same PCI SSID, so we need to check
5939 * codec SSID to distinguish the exact models
5940 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005941 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005942 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005943
5944 case 0x106b0800:
5945 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005946 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005947 case 0x106b0600:
5948 case 0x106b0700:
5949 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005950 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005951 case 0x106b0e00:
5952 case 0x106b0f00:
5953 case 0x106b1600:
5954 case 0x106b1700:
5955 case 0x106b0200:
5956 case 0x106b1e00:
5957 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005958 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005959 case 0x106b1a00:
5960 case 0x00000100:
5961 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005962 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005963 case 0x106b0a00:
5964 case 0x106b2200:
5965 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005966 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005967 default:
5968 spec->board_config = STAC_INTEL_MAC_V3;
5969 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005970 }
5971 }
5972
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005973 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005974 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005975 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5976 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005977 else
5978 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005979 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005980
Matt2f2f4252005-04-13 14:45:30 +02005981 spec->adc_nids = stac922x_adc_nids;
5982 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005983 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005984 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005985 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005986 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005987
5988 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005989
5990 spec->num_caps = STAC922X_NUM_CAPS;
5991 spec->capvols = stac922x_capvols;
5992 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005993
5994 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005995
Charles Chin9009b0e2011-11-03 10:27:27 +01005996 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005997 if (!err) {
5998 if (spec->board_config < 0) {
5999 printk(KERN_WARNING "hda_codec: No auto-config is "
6000 "available, default to model=ref\n");
6001 spec->board_config = STAC_D945_REF;
6002 goto again;
6003 }
6004 err = -EINVAL;
6005 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006006 if (err < 0) {
6007 stac92xx_free(codec);
6008 return err;
6009 }
6010
6011 codec->patch_ops = stac92xx_patch_ops;
6012
Takashi Iwai807a46362007-05-29 19:01:37 +02006013 /* Fix Mux capture level; max to 2 */
6014 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6015 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6016 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6017 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6018 (0 << AC_AMPCAP_MUTE_SHIFT));
6019
Matt Porter3cc08dc2006-01-23 15:27:49 +01006020 return 0;
6021}
6022
6023static int patch_stac927x(struct hda_codec *codec)
6024{
6025 struct sigmatel_spec *spec;
6026 int err;
6027
6028 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6029 if (spec == NULL)
6030 return -ENOMEM;
6031
Takashi Iwaia252c812009-12-25 22:56:20 +01006032 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006033 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006034 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006035 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006036 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006037 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006038 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6039 stac927x_models,
6040 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006041 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006042 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006043 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6044 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006045 else
6046 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006047 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006048
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006049 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006050 spec->adc_nids = stac927x_adc_nids;
6051 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6052 spec->mux_nids = stac927x_mux_nids;
6053 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006054 spec->smux_nids = stac927x_smux_nids;
6055 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006056 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006057 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006058 spec->multiout.dac_nids = spec->dac_nids;
6059
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006060 if (spec->board_config != STAC_D965_REF) {
6061 /* GPIO0 High = Enable EAPD */
6062 spec->eapd_mask = spec->gpio_mask = 0x01;
6063 spec->gpio_dir = spec->gpio_data = 0x01;
6064 }
6065
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006066 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02006067 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006068 case STAC_D965_5ST:
6069 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006070 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02006071 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006072 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006073 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006074 switch (codec->subsystem_id) {
6075 case 0x10280209:
6076 case 0x1028022e:
6077 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006078 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006079 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006080 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01006081 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01006082 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01006083 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006084 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006085 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01006086 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006087 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006088 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006089 if (codec->subsystem_id != 0x1028022f) {
6090 /* GPIO2 High = Enable EAPD */
6091 spec->eapd_mask = spec->gpio_mask = 0x04;
6092 spec->gpio_dir = spec->gpio_data = 0x04;
6093 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006094 spec->dmic_nids = stac927x_dmic_nids;
6095 spec->num_dmics = STAC927X_NUM_DMICS;
6096
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02006097 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006098 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006099 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006100 break;
Takashi Iwai54930532009-10-11 17:38:29 +02006101 case STAC_927X_VOLKNOB:
6102 spec->num_dmics = 0;
6103 spec->init = stac927x_volknob_core_init;
6104 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006105 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006106 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006107 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006108 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006109 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006110
Takashi Iwai6479c632009-07-28 18:20:25 +02006111 spec->num_caps = STAC927X_NUM_CAPS;
6112 spec->capvols = stac927x_capvols;
6113 spec->capsws = stac927x_capsws;
6114
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006115 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006116 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006117 spec->aloopback_mask = 0x40;
6118 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006119 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006120
Charles Chin9009b0e2011-11-03 10:27:27 +01006121 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006122 if (!err) {
6123 if (spec->board_config < 0) {
6124 printk(KERN_WARNING "hda_codec: No auto-config is "
6125 "available, default to model=ref\n");
6126 spec->board_config = STAC_D965_REF;
6127 goto again;
6128 }
6129 err = -EINVAL;
6130 }
Mattc7d4b2f2005-06-27 14:59:41 +02006131 if (err < 0) {
6132 stac92xx_free(codec);
6133 return err;
6134 }
Matt2f2f4252005-04-13 14:45:30 +02006135
6136 codec->patch_ops = stac92xx_patch_ops;
6137
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006138 codec->proc_widget_hook = stac927x_proc_hook;
6139
Takashi Iwai52987652008-01-16 16:09:47 +01006140 /*
6141 * !!FIXME!!
6142 * The STAC927x seem to require fairly long delays for certain
6143 * command sequences. With too short delays (even if the answer
6144 * is set to RIRB properly), it results in the silence output
6145 * on some hardwares like Dell.
6146 *
6147 * The below flag enables the longer delay (see get_response
6148 * in hda_intel.c).
6149 */
6150 codec->bus->needs_damn_long_delay = 1;
6151
Takashi Iwaie28d8322008-12-17 13:48:29 +01006152 /* no jack detecion for ref-no-jd model */
6153 if (spec->board_config == STAC_D965_REF_NO_JD)
6154 spec->hp_detect = 0;
6155
Matt2f2f4252005-04-13 14:45:30 +02006156 return 0;
6157}
6158
Matt Porterf3302a52006-07-31 12:49:34 +02006159static int patch_stac9205(struct hda_codec *codec)
6160{
6161 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006162 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006163
6164 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6165 if (spec == NULL)
6166 return -ENOMEM;
6167
Takashi Iwaia252c812009-12-25 22:56:20 +01006168 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006169 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006170 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006171 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006172 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006173 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6174 stac9205_models,
6175 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006176 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006177 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006178 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6179 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006180 else
6181 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006182 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006183
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006184 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006185 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006186 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006187 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006188 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006189 spec->smux_nids = stac9205_smux_nids;
6190 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006191 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006192 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006193 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006194 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006195 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006196
6197 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006198 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006199
Takashi Iwai6479c632009-07-28 18:20:25 +02006200 spec->num_caps = STAC9205_NUM_CAPS;
6201 spec->capvols = stac9205_capvols;
6202 spec->capsws = stac9205_capsws;
6203
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006204 spec->aloopback_mask = 0x40;
6205 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006206 /* Turn on/off EAPD per HP plugging */
6207 if (spec->board_config != STAC_9205_EAPD)
6208 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006209 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006210
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006211 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006212 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006213 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006214 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6215 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006216
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006217 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwai3a938972011-10-28 01:16:55 +02006218 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006219 if (err < 0)
6220 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006221 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006222 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
Takashi Iwai3a938972011-10-28 01:16:55 +02006223 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006224
6225 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006226 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006227 spec->gpio_mask = 0x1b;
6228 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006229 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006230 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006231 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006232 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006233 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006234 case STAC_9205_REF:
6235 /* SPDIF-In enabled */
6236 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006237 default:
6238 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006239 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006240 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006241 break;
6242 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006243
Charles Chin9009b0e2011-11-03 10:27:27 +01006244 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006245 if (!err) {
6246 if (spec->board_config < 0) {
6247 printk(KERN_WARNING "hda_codec: No auto-config is "
6248 "available, default to model=ref\n");
6249 spec->board_config = STAC_9205_REF;
6250 goto again;
6251 }
6252 err = -EINVAL;
6253 }
Matt Porterf3302a52006-07-31 12:49:34 +02006254 if (err < 0) {
6255 stac92xx_free(codec);
6256 return err;
6257 }
6258
6259 codec->patch_ops = stac92xx_patch_ops;
6260
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006261 codec->proc_widget_hook = stac9205_proc_hook;
6262
Matt Porterf3302a52006-07-31 12:49:34 +02006263 return 0;
6264}
6265
Matt2f2f4252005-04-13 14:45:30 +02006266/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006267 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006268 */
6269
Takashi Iwai2b635362011-05-02 12:33:43 +02006270static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006271 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6273 {}
6274};
6275
Takashi Iwai2b635362011-05-02 12:33:43 +02006276static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006277 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6278 0x11, 0x13, 0x14,
6279};
6280
Takashi Iwai2b635362011-05-02 12:33:43 +02006281static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006282 0x8 /*,0x6*/
6283};
6284
Takashi Iwai2b635362011-05-02 12:33:43 +02006285static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006286 0x15
6287};
6288
Takashi Iwai2b635362011-05-02 12:33:43 +02006289static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006290 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6291};
6292#define stac9872_capsws stac9872_capvols
6293
Takashi Iwai2b635362011-05-02 12:33:43 +02006294static const unsigned int stac9872_vaio_pin_configs[9] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006295 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6296 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6297 0x90a7013e
6298};
6299
Takashi Iwaiea734962011-01-17 11:29:34 +01006300static const char * const stac9872_models[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006301 [STAC_9872_AUTO] = "auto",
6302 [STAC_9872_VAIO] = "vaio",
6303};
6304
Takashi Iwai2b635362011-05-02 12:33:43 +02006305static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006306 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6307};
6308
Takashi Iwai2b635362011-05-02 12:33:43 +02006309static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006310 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6311 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006312 {} /* terminator */
6313};
6314
Guillaume Munch6d859062006-08-22 17:15:47 +02006315static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006316{
6317 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006318 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006319
Takashi Iwaidb064e52006-03-16 16:04:58 +01006320 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6321 if (spec == NULL)
6322 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006323 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006324 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006325 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006326 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6327 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006328
6329 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6330 stac9872_models,
6331 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006332 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006333 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6334 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006335 else
6336 stac92xx_set_config_regs(codec,
6337 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006338
Takashi Iwai1e137f92009-01-21 07:41:22 +01006339 spec->multiout.dac_nids = spec->dac_nids;
6340 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6341 spec->adc_nids = stac9872_adc_nids;
6342 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6343 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006344 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006345 spec->num_caps = 1;
6346 spec->capvols = stac9872_capvols;
6347 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006348
Charles Chin9009b0e2011-11-03 10:27:27 +01006349 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01006350 if (err < 0) {
6351 stac92xx_free(codec);
6352 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006353 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006354 spec->input_mux = &spec->private_imux;
6355 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006356 return 0;
6357}
6358
6359
6360/*
Matt2f2f4252005-04-13 14:45:30 +02006361 * patch entries
6362 */
Takashi Iwai2b635362011-05-02 12:33:43 +02006363static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006364 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6365 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6366 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6367 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6368 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6369 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6370 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006371 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6372 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6373 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6374 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6375 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6376 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006377 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6378 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6379 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6380 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6381 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6382 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6383 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6384 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6385 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6386 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006387 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6388 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6389 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6390 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6391 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6392 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006393 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6394 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006395 /* The following does not take into account .id=0x83847661 when subsys =
6396 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6397 * currently not fully supported.
6398 */
6399 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6400 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6401 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006402 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006403 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6404 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6405 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6406 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6407 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6408 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6409 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6410 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006411 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006412 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006413 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006414 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006415 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02006416 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6417 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006418 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6419 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6420 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6421 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006422 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006423 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6424 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006425 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006426 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6427 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6428 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6429 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6430 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6431 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6432 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6433 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02006434 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6435 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6436 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6437 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6438 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6439 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6440 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6441 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6442 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6443 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6444 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6445 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6446 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6447 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6448 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02006449 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006450 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06006451 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6452 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006453 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01006454 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6455 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6456 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6457 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6458 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6459 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6460 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6461 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6462 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6463 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6464 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6465 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02006466 {} /* terminator */
6467};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006468
6469MODULE_ALIAS("snd-hda-codec-id:8384*");
6470MODULE_ALIAS("snd-hda-codec-id:111d*");
6471
6472MODULE_LICENSE("GPL");
6473MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6474
6475static struct hda_codec_preset_list sigmatel_list = {
6476 .preset = snd_hda_preset_sigmatel,
6477 .owner = THIS_MODULE,
6478};
6479
6480static int __init patch_sigmatel_init(void)
6481{
6482 return snd_hda_add_codec_preset(&sigmatel_list);
6483}
6484
6485static void __exit patch_sigmatel_exit(void)
6486{
6487 snd_hda_delete_codec_preset(&sigmatel_list);
6488}
6489
6490module_init(patch_sigmatel_init)
6491module_exit(patch_sigmatel_exit)