blob: 6e926497b2308e3304a38e516f0f52e81fac43ec [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
314 struct snd_kcontrol *vmaster_sw_kctl;
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
Wang Shaoyan96b63592011-08-10 16:01:04 +0800668#ifdef CONFIG_SND_HDA_POWER_SAVE
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500669static int stac_vrefout_set(struct hda_codec *codec,
670 hda_nid_t nid, unsigned int new_vref)
671{
672 int error, pinctl;
673
674 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
675 pinctl = snd_hda_codec_read(codec, nid, 0,
676 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
677
678 if (pinctl < 0)
679 return pinctl;
680
681 pinctl &= 0xff;
682 pinctl &= ~AC_PINCTL_VREFEN;
683 pinctl |= (new_vref & AC_PINCTL_VREFEN);
684
685 error = snd_hda_codec_write_cache(codec, nid, 0,
686 AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
687 if (error < 0)
688 return error;
689
690 return 1;
691}
Wang Shaoyan96b63592011-08-10 16:01:04 +0800692#endif
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500693
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200694static unsigned int stac92xx_vref_set(struct hda_codec *codec,
695 hda_nid_t nid, unsigned int new_vref)
696{
Takashi Iwaib8621512009-06-22 08:00:10 +0200697 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200698 unsigned int pincfg;
699 pincfg = snd_hda_codec_read(codec, nid, 0,
700 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
701
702 pincfg &= 0xff;
703 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
704 pincfg |= new_vref;
705
706 if (new_vref == AC_PINCTL_VREF_HIZ)
707 pincfg |= AC_PINCTL_OUT_EN;
708 else
709 pincfg |= AC_PINCTL_IN_EN;
710
711 error = snd_hda_codec_write_cache(codec, nid, 0,
712 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
713 if (error < 0)
714 return error;
715 else
716 return 1;
717}
718
719static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
720{
721 unsigned int vref;
722 vref = snd_hda_codec_read(codec, nid, 0,
723 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
724 vref &= AC_PINCTL_VREFEN;
725 return vref;
726}
727
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100728static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200729{
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200732 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200733}
734
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100735static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200736{
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
740
741 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
742 return 0;
743}
744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100745static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200746{
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 struct sigmatel_spec *spec = codec->spec;
749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200750 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600751 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200752
Takashi Iwai5207e102009-07-30 13:09:08 +0200753 idx = ucontrol->value.enumerated.item[0];
754 if (idx >= imux->num_items)
755 idx = imux->num_items - 1;
756 prev_idx = spec->cur_mux[adc_idx];
757 if (prev_idx == idx)
758 return 0;
759 if (idx < spec->num_analog_muxes) {
760 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
761 AC_VERB_SET_CONNECT_SEL,
762 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600763 if (prev_idx >= spec->num_analog_muxes &&
764 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200765 imux = spec->dinput_mux;
766 /* 0 = analog */
767 snd_hda_codec_write_cache(codec,
768 spec->dmux_nids[adc_idx], 0,
769 AC_VERB_SET_CONNECT_SEL,
770 imux->items[0].index);
771 }
772 } else {
773 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600774 /* first dimux item is hardcoded to select analog imux,
775 * so lets skip it
776 */
777 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200778 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
779 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600780 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200781 }
782 spec->cur_mux[adc_idx] = idx;
783 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200784}
785
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100786static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
787 struct snd_ctl_elem_info *uinfo)
788{
789 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
790 struct sigmatel_spec *spec = codec->spec;
791 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
792}
793
794static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
796{
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 struct sigmatel_spec *spec = codec->spec;
799
800 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
801 return 0;
802}
803
804static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
806{
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 struct sigmatel_spec *spec = codec->spec;
809
810 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
811 spec->mono_nid, &spec->cur_mmux);
812}
813
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200814#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
815
816static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
817 struct snd_ctl_elem_value *ucontrol)
818{
819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100820 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200821 struct sigmatel_spec *spec = codec->spec;
822
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100823 ucontrol->value.integer.value[0] = !!(spec->aloopback &
824 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200825 return 0;
826}
827
828static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
829 struct snd_ctl_elem_value *ucontrol)
830{
831 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
832 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200834 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100835 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200836
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 idx_val = spec->aloopback_mask << idx;
838 if (ucontrol->value.integer.value[0])
839 val = spec->aloopback | idx_val;
840 else
841 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100842 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200843 return 0;
844
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100845 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200846
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100847 /* Only return the bits defined by the shift value of the
848 * first two bytes of the mask
849 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200850 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100851 kcontrol->private_value & 0xFFFF, 0x0);
852 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100854 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200855 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100856 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200857 } else {
858 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100859 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200860 }
861
862 snd_hda_codec_write_cache(codec, codec->afg, 0,
863 kcontrol->private_value >> 16, dac_mode);
864
865 return 1;
866}
867
Takashi Iwai2b635362011-05-02 12:33:43 +0200868static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200869 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200870 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200871 {}
872};
873
Takashi Iwai2b635362011-05-02 12:33:43 +0200874static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200875 /* set dac0mux for dac converter */
876 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
877 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
878 {}
879};
880
Takashi Iwai2b635362011-05-02 12:33:43 +0200881static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100882 /* set master volume to max value without distortion
883 * and direct control */
884 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100885 {}
886};
887
Takashi Iwai2b635362011-05-02 12:33:43 +0200888static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100889 /* set master volume and direct control */
890 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100891 {}
892};
893
Takashi Iwai2b635362011-05-02 12:33:43 +0200894static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200895 /* power state controls amps */
896 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200897 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200898};
899
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600900static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
901 { 0x22, 0x785, 0x43 },
902 { 0x22, 0x782, 0xe0 },
903 { 0x22, 0x795, 0x00 },
904 {}
905};
906
Takashi Iwai2b635362011-05-02 12:33:43 +0200907static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100908 /* set master volume and direct control */
909 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200910 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100911};
912
Takashi Iwai2b635362011-05-02 12:33:43 +0200913static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500914 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
915 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100916 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
917 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100918 {}
919};
920
Takashi Iwai2b635362011-05-02 12:33:43 +0200921static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100922 /* set dac0mux for dac converter */
923 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100924 /* mute the master volume */
925 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100926 {}
927};
928
Takashi Iwai2b635362011-05-02 12:33:43 +0200929static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200930 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200931 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200932 {}
933};
934
Takashi Iwai2b635362011-05-02 12:33:43 +0200935static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200936 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200937 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200938 /* unmute node 0x1b */
939 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
940 /* select node 0x03 as DAC */
941 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
942 {}
943};
944
Takashi Iwai2b635362011-05-02 12:33:43 +0200945static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200946 /* don't set delta bit */
947 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
948 /* unmute node 0x1b */
949 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
950 /* select node 0x03 as DAC */
951 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
952 {}
953};
954
Takashi Iwai2b635362011-05-02 12:33:43 +0200955static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100956 /* set master volume and direct control */
957 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200958 /* enable analog pc beep path */
959 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100960 {}
961};
962
Takashi Iwai2b635362011-05-02 12:33:43 +0200963static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200964 /* don't set delta bit */
965 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
966 /* enable analog pc beep path */
967 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
968 {}
969};
970
Takashi Iwai2b635362011-05-02 12:33:43 +0200971static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200972 /* set master volume and direct control */
973 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200974 /* enable analog pc beep path */
975 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200976 {}
977};
978
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100979#define STAC_MONO_MUX \
980 { \
981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
982 .name = "Mono Mux", \
983 .count = 1, \
984 .info = stac92xx_mono_mux_enum_info, \
985 .get = stac92xx_mono_mux_enum_get, \
986 .put = stac92xx_mono_mux_enum_put, \
987 }
988
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100989#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200990 { \
991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
992 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100993 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200994 .info = stac92xx_aloopback_info, \
995 .get = stac92xx_aloopback_get, \
996 .put = stac92xx_aloopback_put, \
997 .private_value = verb_read | (verb_write << 16), \
998 }
999
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001000#define DC_BIAS(xname, idx, nid) \
1001 { \
1002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1003 .name = xname, \
1004 .index = idx, \
1005 .info = stac92xx_dc_bias_info, \
1006 .get = stac92xx_dc_bias_get, \
1007 .put = stac92xx_dc_bias_put, \
1008 .private_value = nid, \
1009 }
1010
Takashi Iwai2b635362011-05-02 12:33:43 +02001011static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001012 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001014 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1015 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001016 { } /* end */
1017};
1018
Takashi Iwai2b635362011-05-02 12:33:43 +02001019static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001020 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1021 {}
1022};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001023
Takashi Iwai2b635362011-05-02 12:33:43 +02001024static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001025 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1026 {}
1027};
1028
Takashi Iwai2b635362011-05-02 12:33:43 +02001029static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001030 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1031 {}
1032};
1033
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001034
Takashi Iwai2b635362011-05-02 12:33:43 +02001035static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001036 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1037};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001038
Takashi Iwai2b635362011-05-02 12:33:43 +02001039static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001040 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1041 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001042 { } /* end */
1043};
1044
Takashi Iwai2b635362011-05-02 12:33:43 +02001045static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001046 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1047 {}
1048};
1049
Takashi Iwai2b635362011-05-02 12:33:43 +02001050static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001051 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1052 {}
1053};
1054
Takashi Iwai1697055e2007-12-18 18:05:52 +01001055static struct snd_kcontrol_new stac_dmux_mixer = {
1056 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1057 .name = "Digital Input Source",
1058 /* count set later */
1059 .info = stac92xx_dmux_enum_info,
1060 .get = stac92xx_dmux_enum_get,
1061 .put = stac92xx_dmux_enum_put,
1062};
1063
Matthew Ranostayd9737752008-09-07 12:03:41 +02001064static struct snd_kcontrol_new stac_smux_mixer = {
1065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001066 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001067 /* count set later */
1068 .info = stac92xx_smux_enum_info,
1069 .get = stac92xx_smux_enum_get,
1070 .put = stac92xx_smux_enum_put,
1071};
1072
Takashi Iwai9322ca52012-02-03 14:28:01 +01001073static const char * const slave_pfxs[] = {
1074 "Front", "Surround", "Center", "LFE", "Side",
1075 "Headphone", "Speaker", "IEC958",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001076 NULL
1077};
1078
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001079static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1080
1081static void stac92xx_vmaster_hook(void *private_data, int val)
1082{
1083 stac92xx_update_led_status(private_data, val);
1084}
1085
Takashi Iwai603c4012008-07-30 15:01:44 +02001086static void stac92xx_free_kctls(struct hda_codec *codec);
1087
Matt2f2f4252005-04-13 14:45:30 +02001088static int stac92xx_build_controls(struct hda_codec *codec)
1089{
1090 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001091 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001092 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001093 int i;
Matt2f2f4252005-04-13 14:45:30 +02001094
Takashi Iwai6479c632009-07-28 18:20:25 +02001095 if (spec->mixer) {
1096 err = snd_hda_add_new_ctls(codec, spec->mixer);
1097 if (err < 0)
1098 return err;
1099 }
Mattc7d4b2f2005-06-27 14:59:41 +02001100
1101 for (i = 0; i < spec->num_mixers; i++) {
1102 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1103 if (err < 0)
1104 return err;
1105 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001106 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1107 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001108 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001109 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001110 snd_ctl_new1(&stac_dmux_mixer, codec));
1111 if (err < 0)
1112 return err;
1113 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001114 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001115 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1116 struct hda_input_mux *smux = &spec->private_smux;
1117 /* check for mute support on SPDIF out */
1118 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001119 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001120 spec->spdif_mute = 1;
1121 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001122 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001123 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001124 snd_ctl_new1(&stac_smux_mixer, codec));
1125 if (err < 0)
1126 return err;
1127 }
Mattc7d4b2f2005-06-27 14:59:41 +02001128
Mattdabbed62005-06-14 10:19:34 +02001129 if (spec->multiout.dig_out_nid) {
Stephen Warren74b654c2011-06-01 11:14:18 -06001130 err = snd_hda_create_spdif_out_ctls(codec,
1131 spec->multiout.dig_out_nid,
1132 spec->multiout.dig_out_nid);
Mattdabbed62005-06-14 10:19:34 +02001133 if (err < 0)
1134 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001135 err = snd_hda_create_spdif_share_sw(codec,
1136 &spec->multiout);
1137 if (err < 0)
1138 return err;
1139 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001140 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001141 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001142 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1143 if (err < 0)
1144 return err;
1145 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001146
1147 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001148 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1149 HDA_OUTPUT, vmaster_tlv);
1150 /* correct volume offset */
1151 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1152 /* minimum value is actually mute */
1153 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1154 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1155 vmaster_tlv, slave_pfxs,
1156 "Playback Volume");
1157 if (err < 0)
1158 return err;
1159
1160 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1161 NULL, slave_pfxs,
1162 "Playback Switch", true,
1163 &spec->vmaster_sw_kctl);
1164 if (err < 0)
1165 return err;
1166
1167 if (spec->gpio_led) {
1168 snd_ctl_add_vmaster_hook(spec->vmaster_sw_kctl,
1169 stac92xx_vmaster_hook, codec);
1170 snd_ctl_sync_vmaster_hook(spec->vmaster_sw_kctl);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001171 }
1172
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001173 if (spec->aloopback_ctl &&
1174 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1175 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1176 if (err < 0)
1177 return err;
1178 }
1179
Takashi Iwai603c4012008-07-30 15:01:44 +02001180 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001181
Takashi Iwai01a61e12011-10-28 00:03:22 +02001182 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1183 if (err < 0)
1184 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001185
Mattdabbed62005-06-14 10:19:34 +02001186 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001187}
1188
Takashi Iwai2b635362011-05-02 12:33:43 +02001189static const unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001190 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001191 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1192};
1193
Takashi Iwai2b635362011-05-02 12:33:43 +02001194static const unsigned int gateway9200_m4_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001195 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1196 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1197};
Takashi Iwai2b635362011-05-02 12:33:43 +02001198static const unsigned int gateway9200_m4_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001199 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1200 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1201};
1202
1203/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001204 STAC 9200 pin configs for
1205 102801A8
1206 102801DE
1207 102801E8
1208*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001209static const unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001210 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1211 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001212};
1213
1214/*
1215 STAC 9200 pin configs for
1216 102801C0
1217 102801C1
1218*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001219static const unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001220 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1221 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001222};
1223
1224/*
1225 STAC 9200 pin configs for
1226 102801C4 (Dell Dimension E310)
1227 102801C5
1228 102801C7
1229 102801D9
1230 102801DA
1231 102801E3
1232*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001233static const unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001234 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1235 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001236};
1237
1238
1239/*
1240 STAC 9200-32 pin configs for
1241 102801B5 (Dell Inspiron 630m)
1242 102801D8 (Dell Inspiron 640m)
1243*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001244static const unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001245 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1246 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001247};
1248
1249/*
1250 STAC 9200-32 pin configs for
1251 102801C2 (Dell Latitude D620)
1252 102801C8
1253 102801CC (Dell Latitude D820)
1254 102801D4
1255 102801D6
1256*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001257static const unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001258 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1259 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001260};
1261
1262/*
1263 STAC 9200-32 pin configs for
1264 102801CE (Dell XPS M1710)
1265 102801CF (Dell Precision M90)
1266*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001267static const unsigned int dell9200_m23_pin_configs[8] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001268 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1269 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1270};
1271
1272/*
1273 STAC 9200-32 pin configs for
1274 102801C9
1275 102801CA
1276 102801CB (Dell Latitude 120L)
1277 102801D3
1278*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001279static const unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001280 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1281 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001282};
1283
1284/*
1285 STAC 9200-32 pin configs for
1286 102801BD (Dell Inspiron E1505n)
1287 102801EE
1288 102801EF
1289*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001290static const unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001291 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1292 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001293};
1294
1295/*
1296 STAC 9200-32 pin configs for
1297 102801F5 (Dell Inspiron 1501)
1298 102801F6
1299*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001300static const unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001301 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1302 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001303};
1304
1305/*
1306 STAC 9200-32
1307 102801CD (Dell Inspiron E1705/9400)
1308*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001309static const unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001310 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1311 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001312};
1313
Takashi Iwai2b635362011-05-02 12:33:43 +02001314static const unsigned int oqo9200_pin_configs[8] = {
Tobin Davisbf277782008-02-03 20:31:47 +01001315 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1316 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1317};
1318
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001319
Takashi Iwai2b635362011-05-02 12:33:43 +02001320static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001321 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001322 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001323 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1324 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1325 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1326 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1327 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1328 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1329 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1330 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1331 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1332 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001333 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1334 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001335 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001336};
1337
Takashi Iwaiea734962011-01-17 11:29:34 +01001338static const char * const stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001339 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001340 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001341 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001342 [STAC_9200_DELL_D21] = "dell-d21",
1343 [STAC_9200_DELL_D22] = "dell-d22",
1344 [STAC_9200_DELL_D23] = "dell-d23",
1345 [STAC_9200_DELL_M21] = "dell-m21",
1346 [STAC_9200_DELL_M22] = "dell-m22",
1347 [STAC_9200_DELL_M23] = "dell-m23",
1348 [STAC_9200_DELL_M24] = "dell-m24",
1349 [STAC_9200_DELL_M25] = "dell-m25",
1350 [STAC_9200_DELL_M26] = "dell-m26",
1351 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001352 [STAC_9200_M4] = "gateway-m4",
1353 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001354 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001355};
1356
Takashi Iwai2b635362011-05-02 12:33:43 +02001357static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001358 /* SigmaTel reference board */
1359 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1360 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001361 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1362 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001363 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1365 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001367 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1369 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1371 "unknown Dell", STAC_9200_DELL_D22),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1373 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001375 "Dell Latitude D620", STAC_9200_DELL_M22),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1377 "unknown Dell", STAC_9200_DELL_D23),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1379 "unknown Dell", STAC_9200_DELL_D23),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1381 "unknown Dell", STAC_9200_DELL_M22),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1383 "unknown Dell", STAC_9200_DELL_M24),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1385 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001387 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001389 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001391 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001393 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001395 "Dell Precision M90", STAC_9200_DELL_M23),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1397 "unknown Dell", STAC_9200_DELL_M22),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1399 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001401 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001403 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1405 "unknown Dell", STAC_9200_DELL_D23),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1407 "unknown Dell", STAC_9200_DELL_D23),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1409 "unknown Dell", STAC_9200_DELL_D21),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1411 "unknown Dell", STAC_9200_DELL_D23),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1413 "unknown Dell", STAC_9200_DELL_D21),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1415 "unknown Dell", STAC_9200_DELL_M25),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1417 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001419 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1421 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001422 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001423 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001424 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001425 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1426 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1427 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001428 /* OQO Mobile */
1429 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001430 {} /* terminator */
1431};
1432
Takashi Iwai2b635362011-05-02 12:33:43 +02001433static const unsigned int ref925x_pin_configs[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001434 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001435 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001436};
1437
Takashi Iwai2b635362011-05-02 12:33:43 +02001438static const unsigned int stac925xM1_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001439 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1440 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001441};
1442
Takashi Iwai2b635362011-05-02 12:33:43 +02001443static const unsigned int stac925xM1_2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001444 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1445 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1446};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001447
Takashi Iwai2b635362011-05-02 12:33:43 +02001448static const unsigned int stac925xM2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001449 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1450 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001451};
1452
Takashi Iwai2b635362011-05-02 12:33:43 +02001453static const unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001454 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1455 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1456};
1457
Takashi Iwai2b635362011-05-02 12:33:43 +02001458static const unsigned int stac925xM3_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001459 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1460 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1461};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001462
Takashi Iwai2b635362011-05-02 12:33:43 +02001463static const unsigned int stac925xM5_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001464 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1465 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1466};
1467
Takashi Iwai2b635362011-05-02 12:33:43 +02001468static const unsigned int stac925xM6_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001469 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1470 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001471};
1472
Takashi Iwai2b635362011-05-02 12:33:43 +02001473static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001474 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001475 [STAC_M1] = stac925xM1_pin_configs,
1476 [STAC_M1_2] = stac925xM1_2_pin_configs,
1477 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001478 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001479 [STAC_M3] = stac925xM3_pin_configs,
1480 [STAC_M5] = stac925xM5_pin_configs,
1481 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001482};
1483
Takashi Iwaiea734962011-01-17 11:29:34 +01001484static const char * const stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001485 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001486 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001487 [STAC_M1] = "m1",
1488 [STAC_M1_2] = "m1-2",
1489 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001490 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001491 [STAC_M3] = "m3",
1492 [STAC_M5] = "m5",
1493 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001494};
1495
Takashi Iwai2b635362011-05-02 12:33:43 +02001496static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001497 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1498 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1499 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1500 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001501 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001502 /* Not sure about the brand name for those */
1503 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1504 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1505 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1506 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001507 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001508};
1509
Takashi Iwai2b635362011-05-02 12:33:43 +02001510static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001511 /* SigmaTel reference board */
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001513 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001514 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001515
1516 /* Default table for unknown ID */
1517 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1518
Tobin Davis8e21c342007-01-08 11:04:17 +01001519 {} /* terminator */
1520};
1521
Takashi Iwai2b635362011-05-02 12:33:43 +02001522static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001523 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1524 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1525 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001526 0x01452050,
1527};
1528
Takashi Iwai2b635362011-05-02 12:33:43 +02001529static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001530 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001531 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001532 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1533 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001534};
1535
Takashi Iwai2b635362011-05-02 12:33:43 +02001536static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001537 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1538 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1539 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1540 0x904601b0,
1541};
1542
Takashi Iwai2b635362011-05-02 12:33:43 +02001543static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001544 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001545 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001546};
1547
Takashi Iwai2b635362011-05-02 12:33:43 +02001548static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001549 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001550 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1551 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1552 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001553 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001554 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001555 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001556};
1557
Takashi Iwaiea734962011-01-17 11:29:34 +01001558static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001559 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001560 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001561 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001562 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001563 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1564 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1565 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001566 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001567 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001568};
1569
Takashi Iwai2b635362011-05-02 12:33:43 +02001570static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001571 /* SigmaTel reference board */
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001573 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001574 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1575 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1577 "Intel DG45ID", STAC_92HD73XX_INTEL),
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1579 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001581 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001583 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001585 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001587 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001589 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001591 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001593 "unknown Dell", STAC_DELL_M6_DMIC),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1595 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001597 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1599 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1601 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1603 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001605 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001607 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001608 {} /* terminator */
1609};
1610
Takashi Iwai2b635362011-05-02 12:33:43 +02001611static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1613 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1615 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001617 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001618 {} /* terminator */
1619};
1620
Takashi Iwai2b635362011-05-02 12:33:43 +02001621static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001622 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1623 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001624 0x01451160, 0x98560170,
1625};
1626
Takashi Iwai2b635362011-05-02 12:33:43 +02001627static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001628 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1629 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001630 0x40f000f0, 0x40f000f0,
1631};
1632
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001633static const unsigned int dell_vostro_3500_pin_configs[10] = {
1634 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1635 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1636 0x400000f4, 0x400000f5,
1637};
1638
Takashi Iwai2b635362011-05-02 12:33:43 +02001639static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001640 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1641 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1642 0x40f000f0, 0x40f000f0,
1643};
1644
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001645static const unsigned int hp_zephyr_pin_configs[10] = {
1646 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1647 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1648 0, 0,
1649};
1650
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001651static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1652 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1653 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1654 0x40f000f0, 0x40f000f0,
1655};
1656
Takashi Iwai2b635362011-05-02 12:33:43 +02001657static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001658 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001659 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001660 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001661 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001662 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001663 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001664 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001665};
1666
Takashi Iwaiea734962011-01-17 11:29:34 +01001667static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001668 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001669 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001670 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001671 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001672 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001673 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001674 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001675 [STAC_HP_ZEPHYR] = "hp-zephyr",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001676};
1677
Takashi Iwai2b635362011-05-02 12:33:43 +02001678static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001679 /* SigmaTel reference board */
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001681 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001682 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1683 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1685 "unknown Dell", STAC_DELL_S14),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001686 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1687 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001688 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1689 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1691 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1693 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1695 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1697 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1699 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1701 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1703 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1705 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1707 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1709 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1711 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1715 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1717 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1719 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1721 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1723 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1725 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1727 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001728 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1729 "HP", STAC_HP_ZEPHYR),
1730 {} /* terminator */
1731};
1732
1733static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1735 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001736 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001737};
1738
Takashi Iwai2b635362011-05-02 12:33:43 +02001739static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001740 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001741 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001742 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1743 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001744};
1745
Takashi Iwai2b635362011-05-02 12:33:43 +02001746static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001747 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001748 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001749 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1750 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001751};
1752
Takashi Iwai2b635362011-05-02 12:33:43 +02001753static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001754 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1755 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001756 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1757 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001758};
1759
Takashi Iwai2b635362011-05-02 12:33:43 +02001760static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001761 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1762 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001763 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1764 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001765};
1766
Takashi Iwai2b635362011-05-02 12:33:43 +02001767static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001768 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001769 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1770 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001771 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001772 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001773 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001774 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001775 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001776 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001777};
1778
Takashi Iwaiea734962011-01-17 11:29:34 +01001779static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001780 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001781 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001782 [STAC_DELL_M4_1] = "dell-m4-1",
1783 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001784 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001785 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001786 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001787 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001788 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001789 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001790};
1791
Takashi Iwai2b635362011-05-02 12:33:43 +02001792static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001793 /* SigmaTel reference board */
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1795 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001796 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1797 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001798 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1799 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001800 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1801 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001802 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1803 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001804 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001805 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001806 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1807 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001808 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1809 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001810 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001811 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001812 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001813 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001814 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1815 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301816 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1817 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11001818 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1819 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001820 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1821 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001822 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1823 "unknown Dell", STAC_DELL_M4_1),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1825 "unknown Dell", STAC_DELL_M4_1),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1827 "unknown Dell", STAC_DELL_M4_1),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1829 "unknown Dell", STAC_DELL_M4_1),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1831 "unknown Dell", STAC_DELL_M4_1),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1833 "unknown Dell", STAC_DELL_M4_1),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1835 "unknown Dell", STAC_DELL_M4_1),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1837 "unknown Dell", STAC_DELL_M4_2),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1839 "unknown Dell", STAC_DELL_M4_2),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1841 "unknown Dell", STAC_DELL_M4_2),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1843 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1845 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001846 {} /* terminator */
1847};
1848
Takashi Iwai2b635362011-05-02 12:33:43 +02001849static const unsigned int ref922x_pin_configs[10] = {
Matt Porter403d1942005-11-29 15:00:51 +01001850 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1851 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001852 0x40000100, 0x40000100,
1853};
1854
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001855/*
1856 STAC 922X pin configs for
1857 102801A7
1858 102801AB
1859 102801A9
1860 102801D1
1861 102801D2
1862*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001863static const unsigned int dell_922x_d81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001864 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1865 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1866 0x01813122, 0x400001f2,
1867};
1868
1869/*
1870 STAC 922X pin configs for
1871 102801AC
1872 102801D0
1873*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001874static const unsigned int dell_922x_d82_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001875 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1876 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1877 0x01813122, 0x400001f1,
1878};
1879
1880/*
1881 STAC 922X pin configs for
1882 102801BF
1883*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001884static const unsigned int dell_922x_m81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001885 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1886 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1887 0x40C003f1, 0x405003f0,
1888};
1889
1890/*
1891 STAC 9221 A1 pin configs for
1892 102801D7 (Dell XPS M1210)
1893*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001894static const unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001895 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1896 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001897 0x508003f3, 0x405003f4,
1898};
1899
Takashi Iwai2b635362011-05-02 12:33:43 +02001900static const unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001901 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001902 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1903 0x02a19120, 0x40000100,
1904};
1905
Takashi Iwai2b635362011-05-02 12:33:43 +02001906static const unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001907 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1908 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001909 0x02a19320, 0x40000100,
1910};
1911
Takashi Iwai2b635362011-05-02 12:33:43 +02001912static const unsigned int intel_mac_v1_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001913 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1914 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001915 0x400000fc, 0x400000fb,
1916};
1917
Takashi Iwai2b635362011-05-02 12:33:43 +02001918static const unsigned int intel_mac_v2_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001919 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1920 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001921 0x400000fc, 0x400000fb,
1922};
1923
Takashi Iwai2b635362011-05-02 12:33:43 +02001924static const unsigned int intel_mac_v3_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001925 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1926 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1927 0x400000fc, 0x400000fb,
1928};
1929
Takashi Iwai2b635362011-05-02 12:33:43 +02001930static const unsigned int intel_mac_v4_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001931 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1932 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1933 0x400000fc, 0x400000fb,
1934};
1935
Takashi Iwai2b635362011-05-02 12:33:43 +02001936static const unsigned int intel_mac_v5_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001937 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1938 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1939 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001940};
1941
Takashi Iwai2b635362011-05-02 12:33:43 +02001942static const unsigned int ecs202_pin_configs[10] = {
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001943 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1944 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1945 0x9037012e, 0x40e000f2,
1946};
Takashi Iwai76c08822007-06-19 12:17:42 +02001947
Takashi Iwai2b635362011-05-02 12:33:43 +02001948static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001949 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001950 [STAC_D945GTP3] = d945gtp3_pin_configs,
1951 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001952 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1953 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1954 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1955 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1956 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001957 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001958 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001959 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1960 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1961 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1962 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1963 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1964 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001965 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001966 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1967 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1968 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1969 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001970};
1971
Takashi Iwaiea734962011-01-17 11:29:34 +01001972static const char * const stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001973 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001974 [STAC_D945_REF] = "ref",
1975 [STAC_D945GTP5] = "5stack",
1976 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001977 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1978 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1979 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1980 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1981 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001982 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001983 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001984 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001985 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001986 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1987 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001988 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001989 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001990 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001991 [STAC_922X_DELL_D81] = "dell-d81",
1992 [STAC_922X_DELL_D82] = "dell-d82",
1993 [STAC_922X_DELL_M81] = "dell-m81",
1994 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001995};
1996
Takashi Iwai2b635362011-05-02 12:33:43 +02001997static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001998 /* SigmaTel reference board */
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2000 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002001 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2002 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002003 /* Intel 945G based systems */
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2033 "Intel D945G", STAC_D945GTP3),
2034 /* Intel D945G 5-stack systems */
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2036 "Intel D945G", STAC_D945GTP5),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2038 "Intel D945G", STAC_D945GTP5),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2040 "Intel D945G", STAC_D945GTP5),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2042 "Intel D945G", STAC_D945GTP5),
2043 /* Intel 945P based systems */
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2045 "Intel D945P", STAC_D945GTP3),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2047 "Intel D945P", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2049 "Intel D945P", STAC_D945GTP3),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2051 "Intel D945P", STAC_D945GTP3),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2053 "Intel D945P", STAC_D945GTP3),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2055 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002056 /* other intel */
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2058 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002059 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002060 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002061 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002062 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002063 /* Dell systems */
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2065 "unknown Dell", STAC_922X_DELL_D81),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2067 "unknown Dell", STAC_922X_DELL_D81),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2069 "unknown Dell", STAC_922X_DELL_D81),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2071 "unknown Dell", STAC_922X_DELL_D82),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2073 "unknown Dell", STAC_922X_DELL_M81),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2075 "unknown Dell", STAC_922X_DELL_D82),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2077 "unknown Dell", STAC_922X_DELL_D81),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2079 "unknown Dell", STAC_922X_DELL_D81),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2081 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002082 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002083 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002084 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002085 {} /* terminator */
2086};
2087
Takashi Iwai2b635362011-05-02 12:33:43 +02002088static const unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002089 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2090 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2091 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2092 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002093};
2094
Takashi Iwai2b635362011-05-02 12:33:43 +02002095static const unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002096 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2097 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2098 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2099 0x40000100, 0x40000100
2100};
2101
Takashi Iwai2b635362011-05-02 12:33:43 +02002102static const unsigned int d965_5st_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002103 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2104 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2105 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2106 0x40000100, 0x40000100
2107};
2108
Takashi Iwai2b635362011-05-02 12:33:43 +02002109static const unsigned int d965_5st_no_fp_pin_configs[14] = {
Takashi Iwai679d92e2009-05-24 19:00:08 +02002110 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2111 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2112 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2113 0x40000100, 0x40000100
2114};
2115
Takashi Iwai2b635362011-05-02 12:33:43 +02002116static const unsigned int dell_3st_pin_configs[14] = {
Tobin Davis4ff076e2007-08-07 11:48:12 +02002117 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2118 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002119 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002120 0x40c003fc, 0x40000100
2121};
2122
Takashi Iwai2b635362011-05-02 12:33:43 +02002123static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002124 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002125 [STAC_D965_REF] = ref927x_pin_configs,
2126 [STAC_D965_3ST] = d965_3st_pin_configs,
2127 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002128 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002129 [STAC_DELL_3ST] = dell_3st_pin_configs,
2130 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002131 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002132};
2133
Takashi Iwaiea734962011-01-17 11:29:34 +01002134static const char * const stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002135 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002136 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002137 [STAC_D965_REF] = "ref",
2138 [STAC_D965_3ST] = "3stack",
2139 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002140 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002141 [STAC_DELL_3ST] = "dell-3stack",
2142 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002143 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002144};
2145
Takashi Iwai2b635362011-05-02 12:33:43 +02002146static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002147 /* SigmaTel reference board */
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2149 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002150 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2151 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002152 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002155 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002156 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2157 "Intel D965", STAC_D965_3ST),
2158 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2159 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002160 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002164 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002174 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002175 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2176 "Intel D965", STAC_D965_5ST),
2177 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2178 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002179 /* volume-knob fixes */
2180 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002181 {} /* terminator */
2182};
2183
Takashi Iwai2b635362011-05-02 12:33:43 +02002184static const unsigned int ref9205_pin_configs[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +02002185 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002186 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002187 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002188};
2189
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002190/*
2191 STAC 9205 pin configs for
2192 102801F1
2193 102801F2
2194 102801FC
2195 102801FD
2196 10280204
2197 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002198 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002199 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002200*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002201static const unsigned int dell_9205_m42_pin_configs[12] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002202 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2203 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2204 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2205};
2206
2207/*
2208 STAC 9205 pin configs for
2209 102801F9
2210 102801FA
2211 102801FE
2212 102801FF (Dell Precision M4300)
2213 10280206
2214 10280200
2215 10280201
2216*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002217static const unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002218 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2219 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2220 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2221};
2222
Takashi Iwai2b635362011-05-02 12:33:43 +02002223static const unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002224 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2225 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2226 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2227};
2228
Takashi Iwai2b635362011-05-02 12:33:43 +02002229static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002230 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002231 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2232 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2233 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002234 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002235};
2236
Takashi Iwaiea734962011-01-17 11:29:34 +01002237static const char * const stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002238 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002239 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002240 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002241 [STAC_9205_DELL_M43] = "dell-m43",
2242 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002243 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002244};
2245
Takashi Iwai2b635362011-05-02 12:33:43 +02002246static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002247 /* SigmaTel reference board */
2248 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2249 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002250 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2251 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002252 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2253 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002254 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2256 "unknown Dell", STAC_9205_DELL_M42),
2257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2258 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002260 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2262 "Dell Precision", STAC_9205_DELL_M43),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2264 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2266 "unknown Dell", STAC_9205_DELL_M42),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2268 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2270 "Dell Precision", STAC_9205_DELL_M43),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002272 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2274 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2276 "Dell Precision", STAC_9205_DELL_M43),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2278 "Dell Precision", STAC_9205_DELL_M43),
2279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2280 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2282 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2284 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2286 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002287 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002288 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002289 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002290 {} /* terminator */
2291};
2292
Takashi Iwai330ee992009-02-20 14:33:36 +01002293static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002294 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002295{
2296 int i;
2297 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002298
Takashi Iwai330ee992009-02-20 14:33:36 +01002299 if (!pincfgs)
2300 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002301
Matthew Ranostay87d48362007-07-17 11:52:24 +02002302 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002303 if (spec->pin_nids[i] && pincfgs[i])
2304 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2305 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002306}
2307
Matt2f2f4252005-04-13 14:45:30 +02002308/*
2309 * Analog playback callbacks
2310 */
2311static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002313 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002314{
2315 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002316 if (spec->stream_delay)
2317 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002318 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2319 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002320}
2321
2322static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2323 struct hda_codec *codec,
2324 unsigned int stream_tag,
2325 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002326 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002327{
2328 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002329 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002330}
2331
2332static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2333 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002334 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002335{
2336 struct sigmatel_spec *spec = codec->spec;
2337 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2338}
2339
2340/*
Mattdabbed62005-06-14 10:19:34 +02002341 * Digital playback callbacks
2342 */
2343static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2344 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002345 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002346{
2347 struct sigmatel_spec *spec = codec->spec;
2348 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2349}
2350
2351static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002353 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002354{
2355 struct sigmatel_spec *spec = codec->spec;
2356 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2357}
2358
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002359static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2360 struct hda_codec *codec,
2361 unsigned int stream_tag,
2362 unsigned int format,
2363 struct snd_pcm_substream *substream)
2364{
2365 struct sigmatel_spec *spec = codec->spec;
2366 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2367 stream_tag, format, substream);
2368}
2369
Takashi Iwai9411e212009-02-13 11:32:28 +01002370static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2371 struct hda_codec *codec,
2372 struct snd_pcm_substream *substream)
2373{
2374 struct sigmatel_spec *spec = codec->spec;
2375 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2376}
2377
Mattdabbed62005-06-14 10:19:34 +02002378
2379/*
Matt2f2f4252005-04-13 14:45:30 +02002380 * Analog capture callbacks
2381 */
2382static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2383 struct hda_codec *codec,
2384 unsigned int stream_tag,
2385 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002386 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002387{
2388 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002389 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002390
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002391 if (spec->powerdown_adcs) {
2392 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002393 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002394 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2395 }
2396 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002397 return 0;
2398}
2399
2400static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2401 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002402 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002403{
2404 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002405 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002406
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002407 snd_hda_codec_cleanup_stream(codec, nid);
2408 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002409 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002410 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002411 return 0;
2412}
2413
Takashi Iwai2b635362011-05-02 12:33:43 +02002414static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02002415 .substreams = 1,
2416 .channels_min = 2,
2417 .channels_max = 2,
2418 /* NID is set in stac92xx_build_pcms */
2419 .ops = {
2420 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002421 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002422 .prepare = stac92xx_dig_playback_pcm_prepare,
2423 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002424 },
2425};
2426
Takashi Iwai2b635362011-05-02 12:33:43 +02002427static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02002428 .substreams = 1,
2429 .channels_min = 2,
2430 .channels_max = 2,
2431 /* NID is set in stac92xx_build_pcms */
2432};
2433
Takashi Iwai2b635362011-05-02 12:33:43 +02002434static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02002435 .substreams = 1,
2436 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002437 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002438 .nid = 0x02, /* NID to query formats and rates */
2439 .ops = {
2440 .open = stac92xx_playback_pcm_open,
2441 .prepare = stac92xx_playback_pcm_prepare,
2442 .cleanup = stac92xx_playback_pcm_cleanup
2443 },
2444};
2445
Takashi Iwai2b635362011-05-02 12:33:43 +02002446static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002447 .substreams = 1,
2448 .channels_min = 2,
2449 .channels_max = 2,
2450 .nid = 0x06, /* NID to query formats and rates */
2451 .ops = {
2452 .open = stac92xx_playback_pcm_open,
2453 .prepare = stac92xx_playback_pcm_prepare,
2454 .cleanup = stac92xx_playback_pcm_cleanup
2455 },
2456};
2457
Takashi Iwai2b635362011-05-02 12:33:43 +02002458static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002459 .channels_min = 2,
2460 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002461 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002462 .ops = {
2463 .prepare = stac92xx_capture_pcm_prepare,
2464 .cleanup = stac92xx_capture_pcm_cleanup
2465 },
2466};
2467
2468static int stac92xx_build_pcms(struct hda_codec *codec)
2469{
2470 struct sigmatel_spec *spec = codec->spec;
2471 struct hda_pcm *info = spec->pcm_rec;
2472
2473 codec->num_pcms = 1;
2474 codec->pcm_info = info;
2475
Mattc7d4b2f2005-06-27 14:59:41 +02002476 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002477 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002478 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2479 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002480 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002481 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002482 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002483
2484 if (spec->alt_switch) {
2485 codec->num_pcms++;
2486 info++;
2487 info->name = "STAC92xx Analog Alt";
2488 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2489 }
Matt2f2f4252005-04-13 14:45:30 +02002490
Mattdabbed62005-06-14 10:19:34 +02002491 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2492 codec->num_pcms++;
2493 info++;
2494 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002495 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002496 if (spec->multiout.dig_out_nid) {
2497 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2498 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2499 }
2500 if (spec->dig_in_nid) {
2501 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2502 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2503 }
2504 }
2505
Matt2f2f4252005-04-13 14:45:30 +02002506 return 0;
2507}
2508
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002509static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2510 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002511{
Takashi Iwai1327a322009-03-23 13:07:47 +01002512 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002513 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2514 if (pincap & AC_PINCAP_VREF_100)
2515 return AC_PINCTL_VREF_100;
2516 if (pincap & AC_PINCAP_VREF_80)
2517 return AC_PINCTL_VREF_80;
2518 if (pincap & AC_PINCAP_VREF_50)
2519 return AC_PINCTL_VREF_50;
2520 if (pincap & AC_PINCAP_VREF_GRD)
2521 return AC_PINCTL_VREF_GRD;
2522 return 0;
2523}
2524
Matt Porter403d1942005-11-29 15:00:51 +01002525static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2526
2527{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002528 snd_hda_codec_write_cache(codec, nid, 0,
2529 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002530}
2531
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002532#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2533
2534static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2535 struct snd_ctl_elem_value *ucontrol)
2536{
2537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2538 struct sigmatel_spec *spec = codec->spec;
2539
Takashi Iwaid7a89432008-11-12 09:48:04 +01002540 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002541 return 0;
2542}
2543
Takashi Iwai62558ce2009-07-29 14:23:09 +02002544static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002545
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002546static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2547 struct snd_ctl_elem_value *ucontrol)
2548{
2549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2550 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002551 int nid = kcontrol->private_value;
2552
2553 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002554
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002555 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002556 * switch changes
2557 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002558 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002559
2560 return 1;
2561}
2562
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002563static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2564 struct snd_ctl_elem_info *uinfo)
2565{
2566 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02002567 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002568 "Mic In", "Line In", "Line Out"
2569 };
2570
2571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2572 struct sigmatel_spec *spec = codec->spec;
2573 hda_nid_t nid = kcontrol->private_value;
2574
2575 if (nid == spec->mic_switch || nid == spec->line_switch)
2576 i = 3;
2577 else
2578 i = 2;
2579
2580 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2581 uinfo->value.enumerated.items = i;
2582 uinfo->count = 1;
2583 if (uinfo->value.enumerated.item >= i)
2584 uinfo->value.enumerated.item = i-1;
2585 strcpy(uinfo->value.enumerated.name,
2586 texts[uinfo->value.enumerated.item]);
2587
2588 return 0;
2589}
2590
2591static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2592 struct snd_ctl_elem_value *ucontrol)
2593{
2594 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2595 hda_nid_t nid = kcontrol->private_value;
2596 unsigned int vref = stac92xx_vref_get(codec, nid);
2597
2598 if (vref == stac92xx_get_default_vref(codec, nid))
2599 ucontrol->value.enumerated.item[0] = 0;
2600 else if (vref == AC_PINCTL_VREF_GRD)
2601 ucontrol->value.enumerated.item[0] = 1;
2602 else if (vref == AC_PINCTL_VREF_HIZ)
2603 ucontrol->value.enumerated.item[0] = 2;
2604
2605 return 0;
2606}
2607
2608static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2609 struct snd_ctl_elem_value *ucontrol)
2610{
2611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2612 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002613 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002614 hda_nid_t nid = kcontrol->private_value;
2615
2616 if (ucontrol->value.enumerated.item[0] == 0)
2617 new_vref = stac92xx_get_default_vref(codec, nid);
2618 else if (ucontrol->value.enumerated.item[0] == 1)
2619 new_vref = AC_PINCTL_VREF_GRD;
2620 else if (ucontrol->value.enumerated.item[0] == 2)
2621 new_vref = AC_PINCTL_VREF_HIZ;
2622 else
2623 return 0;
2624
2625 if (new_vref != stac92xx_vref_get(codec, nid)) {
2626 error = stac92xx_vref_set(codec, nid, new_vref);
2627 return error;
2628 }
2629
2630 return 0;
2631}
2632
2633static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2634 struct snd_ctl_elem_info *uinfo)
2635{
Takashi Iwai2b635362011-05-02 12:33:43 +02002636 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2638 struct sigmatel_spec *spec = codec->spec;
2639
2640 if (kcontrol->private_value == spec->line_switch)
2641 texts[0] = "Line In";
2642 else
2643 texts[0] = "Mic In";
2644 texts[1] = "Line Out";
2645 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2646 uinfo->value.enumerated.items = 2;
2647 uinfo->count = 1;
2648
2649 if (uinfo->value.enumerated.item >= 2)
2650 uinfo->value.enumerated.item = 1;
2651 strcpy(uinfo->value.enumerated.name,
2652 texts[uinfo->value.enumerated.item]);
2653
2654 return 0;
2655}
Matt Porter403d1942005-11-29 15:00:51 +01002656
2657static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2658{
2659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2660 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002661 hda_nid_t nid = kcontrol->private_value;
2662 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002663
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002664 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002665 return 0;
2666}
2667
2668static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2669{
2670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2671 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002672 hda_nid_t nid = kcontrol->private_value;
2673 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2674 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002675
2676 spec->io_switch[io_idx] = val;
2677
2678 if (val)
2679 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002680 else {
2681 unsigned int pinctl = AC_PINCTL_IN_EN;
2682 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002683 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002684 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2685 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002686
2687 /* check the auto-mute again: we need to mute/unmute the speaker
2688 * appropriately according to the pin direction
2689 */
2690 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002691 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002692
Matt Porter403d1942005-11-29 15:00:51 +01002693 return 1;
2694}
2695
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002696#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2697
2698static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2699 struct snd_ctl_elem_value *ucontrol)
2700{
2701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2702 struct sigmatel_spec *spec = codec->spec;
2703
2704 ucontrol->value.integer.value[0] = spec->clfe_swap;
2705 return 0;
2706}
2707
2708static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2709 struct snd_ctl_elem_value *ucontrol)
2710{
2711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2712 struct sigmatel_spec *spec = codec->spec;
2713 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002714 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002715
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002716 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002717 return 0;
2718
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002719 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002720
2721 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2722 spec->clfe_swap ? 0x4 : 0x0);
2723
2724 return 1;
2725}
2726
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002727#define STAC_CODEC_HP_SWITCH(xname) \
2728 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2729 .name = xname, \
2730 .index = 0, \
2731 .info = stac92xx_hp_switch_info, \
2732 .get = stac92xx_hp_switch_get, \
2733 .put = stac92xx_hp_switch_put, \
2734 }
2735
Matt Porter403d1942005-11-29 15:00:51 +01002736#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2737 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2738 .name = xname, \
2739 .index = 0, \
2740 .info = stac92xx_io_switch_info, \
2741 .get = stac92xx_io_switch_get, \
2742 .put = stac92xx_io_switch_put, \
2743 .private_value = xpval, \
2744 }
2745
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002746#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2747 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2748 .name = xname, \
2749 .index = 0, \
2750 .info = stac92xx_clfe_switch_info, \
2751 .get = stac92xx_clfe_switch_get, \
2752 .put = stac92xx_clfe_switch_put, \
2753 .private_value = xpval, \
2754 }
Matt Porter403d1942005-11-29 15:00:51 +01002755
Mattc7d4b2f2005-06-27 14:59:41 +02002756enum {
2757 STAC_CTL_WIDGET_VOL,
2758 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002759 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002760 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002761 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002762 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002763 STAC_CTL_WIDGET_CLFE_SWITCH,
2764 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002765};
2766
Takashi Iwai2b635362011-05-02 12:33:43 +02002767static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002768 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2769 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002770 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002771 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002772 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002773 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002774 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002775 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002776};
2777
2778/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002779static struct snd_kcontrol_new *
2780stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002781 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002782 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002783 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002784{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002785 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002786
Takashi Iwai603c4012008-07-30 15:01:44 +02002787 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2788 knew = snd_array_new(&spec->kctls);
2789 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002790 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002791 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002792 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002793 if (!knew->name) {
2794 /* roolback */
2795 memset(knew, 0, sizeof(*knew));
2796 spec->kctls.alloced--;
2797 return NULL;
2798 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002799 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002800 return knew;
2801}
2802
2803static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002804 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01002805 int idx, const char *name,
2806 unsigned long val)
2807{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002808 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002809 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002810 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002811 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002812 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002813 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002814 return 0;
2815}
2816
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002817static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2818 int type, int idx, const char *name,
2819 unsigned long val)
2820{
2821 return stac92xx_add_control_temp(spec,
2822 &stac92xx_control_templates[type],
2823 idx, name, val);
2824}
2825
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002826
2827/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002828static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2829 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002830{
2831 return stac92xx_add_control_idx(spec, type, 0, name, val);
2832}
2833
Takashi Iwai2b635362011-05-02 12:33:43 +02002834static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01002835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2836 .name = "Input Source",
2837 .info = stac92xx_mux_enum_info,
2838 .get = stac92xx_mux_enum_get,
2839 .put = stac92xx_mux_enum_put,
2840};
2841
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002842static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2843 hda_nid_t nid, int idx)
2844{
2845 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2846 int control = 0;
2847 struct sigmatel_spec *spec = codec->spec;
2848 char name[22];
2849
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002850 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002851 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2852 && nid == spec->line_switch)
2853 control = STAC_CTL_WIDGET_IO_SWITCH;
2854 else if (snd_hda_query_pin_caps(codec, nid)
2855 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2856 control = STAC_CTL_WIDGET_DC_BIAS;
2857 else if (nid == spec->mic_switch)
2858 control = STAC_CTL_WIDGET_IO_SWITCH;
2859 }
2860
2861 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01002862 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
2863 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002864 return stac92xx_add_control(codec->spec, control,
2865 strcat(name, " Jack Mode"), nid);
2866 }
2867
2868 return 0;
2869}
2870
Takashi Iwaie3c75962009-01-23 11:57:22 +01002871static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2872{
2873 struct snd_kcontrol_new *knew;
2874 struct hda_input_mux *imux = &spec->private_imux;
2875
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002876 if (spec->auto_mic)
2877 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002878 if (!spec->num_adcs || imux->num_items <= 1)
2879 return 0; /* no need for input source control */
2880 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002881 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002882 if (!knew)
2883 return -ENOMEM;
2884 knew->count = spec->num_adcs;
2885 return 0;
2886}
2887
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002888/* check whether the line-input can be used as line-out */
2889static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002890{
2891 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002892 struct auto_pin_cfg *cfg = &spec->autocfg;
2893 hda_nid_t nid;
2894 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002895 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002896
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002897 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2898 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002899 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02002900 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002901 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01002902 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002903 if (pincap & AC_PINCAP_OUT)
2904 return nid;
2905 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002906 }
Matt Porter403d1942005-11-29 15:00:51 +01002907 return 0;
2908}
2909
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002910static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2911
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002912/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002913static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002914{
2915 struct sigmatel_spec *spec = codec->spec;
2916 struct auto_pin_cfg *cfg = &spec->autocfg;
2917 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02002918 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002919
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002920 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002921 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2922 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002923 for (i = 0; i < cfg->num_inputs; i++) {
2924 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02002925 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002926 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002927 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2928 /* some laptops have an internal analog microphone
2929 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002930 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002931 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002932 if (pincap & AC_PINCAP_OUT) {
2933 *dac = get_unassigned_dac(codec, nid);
2934 if (*dac)
2935 return nid;
2936 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002937 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002938 }
2939 return 0;
2940}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002941
2942static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2943{
2944 int i;
2945
2946 for (i = 0; i < spec->multiout.num_dacs; i++) {
2947 if (spec->multiout.dac_nids[i] == nid)
2948 return 1;
2949 }
2950
2951 return 0;
2952}
2953
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002954static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2955{
2956 int i;
2957 if (is_in_dac_nids(spec, nid))
2958 return 1;
2959 for (i = 0; i < spec->autocfg.hp_outs; i++)
2960 if (spec->hp_dacs[i] == nid)
2961 return 1;
2962 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2963 if (spec->speaker_dacs[i] == nid)
2964 return 1;
2965 return 0;
2966}
2967
2968static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2969{
2970 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02002971 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002972 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02002973 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002974 unsigned int wcaps, wtype;
2975
2976 conn_len = snd_hda_get_connections(codec, nid, conn,
2977 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002978 /* 92HD88: trace back up the link of nids to find the DAC */
2979 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2980 != AC_WID_AUD_OUT)) {
2981 nid = conn[0];
2982 conn_len = snd_hda_get_connections(codec, nid, conn,
2983 HDA_MAX_CONNECTIONS);
2984 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002985 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002986 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002987 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002988 /* we check only analog outputs */
2989 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2990 continue;
2991 /* if this route has a free DAC, assign it */
2992 if (!check_all_dac_nids(spec, conn[j])) {
2993 if (conn_len > 1) {
2994 /* select this DAC in the pin's input mux */
2995 snd_hda_codec_write_cache(codec, nid, 0,
2996 AC_VERB_SET_CONNECT_SEL, j);
2997 }
2998 return conn[j];
2999 }
3000 }
David Henningsson48718ea2011-10-05 09:49:05 +02003001
3002 /* if all DACs are already assigned, connect to the primary DAC,
3003 unless we're assigning a secondary headphone */
3004 fallback_dac = spec->multiout.dac_nids[0];
3005 if (spec->multiout.hp_nid) {
3006 for (j = 0; j < cfg->hp_outs; j++)
3007 if (cfg->hp_pins[j] == nid) {
3008 fallback_dac = spec->multiout.hp_nid;
3009 break;
3010 }
3011 }
3012
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003013 if (conn_len > 1) {
3014 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02003015 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003016 snd_hda_codec_write_cache(codec, nid, 0,
3017 AC_VERB_SET_CONNECT_SEL, j);
3018 break;
3019 }
3020 }
3021 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003022 return 0;
3023}
3024
3025static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3026static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3027
Matt Porter3cc08dc2006-01-23 15:27:49 +01003028/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003029 * Fill in the dac_nids table from the parsed pin configuration
3030 * This function only works when every pin in line_out_pins[]
3031 * contains atleast one DAC in its connection list. Some 92xx
3032 * codecs are not connected directly to a DAC, such as the 9200
3033 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003034 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003035static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003036{
3037 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003038 struct auto_pin_cfg *cfg = &spec->autocfg;
3039 int i;
3040 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003041
Mattc7d4b2f2005-06-27 14:59:41 +02003042 for (i = 0; i < cfg->line_outs; i++) {
3043 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003044 dac = get_unassigned_dac(codec, nid);
3045 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003046 if (spec->multiout.num_dacs > 0) {
3047 /* we have already working output pins,
3048 * so let's drop the broken ones again
3049 */
3050 cfg->line_outs = spec->multiout.num_dacs;
3051 break;
3052 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003053 /* error out, no available DAC found */
3054 snd_printk(KERN_ERR
3055 "%s: No available DAC for pin 0x%x\n",
3056 __func__, nid);
3057 return -ENODEV;
3058 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003059 add_spec_dacs(spec, dac);
3060 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003061
Takashi Iwai139e0712009-03-06 12:10:41 +01003062 for (i = 0; i < cfg->hp_outs; i++) {
3063 nid = cfg->hp_pins[i];
3064 dac = get_unassigned_dac(codec, nid);
3065 if (dac) {
3066 if (!spec->multiout.hp_nid)
3067 spec->multiout.hp_nid = dac;
3068 else
3069 add_spec_extra_dacs(spec, dac);
3070 }
3071 spec->hp_dacs[i] = dac;
3072 }
3073
3074 for (i = 0; i < cfg->speaker_outs; i++) {
3075 nid = cfg->speaker_pins[i];
3076 dac = get_unassigned_dac(codec, nid);
3077 if (dac)
3078 add_spec_extra_dacs(spec, dac);
3079 spec->speaker_dacs[i] = dac;
3080 }
3081
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003082 /* add line-in as output */
3083 nid = check_line_out_switch(codec);
3084 if (nid) {
3085 dac = get_unassigned_dac(codec, nid);
3086 if (dac) {
3087 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3088 nid, cfg->line_outs);
3089 cfg->line_out_pins[cfg->line_outs] = nid;
3090 cfg->line_outs++;
3091 spec->line_switch = nid;
3092 add_spec_dacs(spec, dac);
3093 }
3094 }
3095 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003096 nid = check_mic_out_switch(codec, &dac);
3097 if (nid && dac) {
3098 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3099 nid, cfg->line_outs);
3100 cfg->line_out_pins[cfg->line_outs] = nid;
3101 cfg->line_outs++;
3102 spec->mic_switch = nid;
3103 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003104 }
3105
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003106 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003107 spec->multiout.num_dacs,
3108 spec->multiout.dac_nids[0],
3109 spec->multiout.dac_nids[1],
3110 spec->multiout.dac_nids[2],
3111 spec->multiout.dac_nids[3],
3112 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003113
Mattc7d4b2f2005-06-27 14:59:41 +02003114 return 0;
3115}
3116
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003117/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003118static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3119 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003120{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003121 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003122 char name[32];
3123 int err;
3124
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003125 if (!spec->check_volume_offset) {
3126 unsigned int caps, step, nums, db_scale;
3127 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3128 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3129 AC_AMPCAP_STEP_SIZE_SHIFT;
3130 step = (step + 1) * 25; /* in .01dB unit */
3131 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3132 AC_AMPCAP_NUM_STEPS_SHIFT;
3133 db_scale = nums * step;
3134 /* if dB scale is over -64dB, and finer enough,
3135 * let's reduce it to half
3136 */
3137 if (db_scale > 6400 && nums >= 0x1f)
3138 spec->volume_offset = nums / 2;
3139 spec->check_volume_offset = 1;
3140 }
3141
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003142 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003143 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003144 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3145 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003146 if (err < 0)
3147 return err;
3148 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003149 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003150 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3151 if (err < 0)
3152 return err;
3153 return 0;
3154}
3155
Takashi Iwai668b9652009-03-06 10:13:24 +01003156#define create_controls(codec, pfx, nid, chs) \
3157 create_controls_idx(codec, pfx, 0, nid, chs)
3158
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003159static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3160{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003161 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003162 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3163 return 1;
3164 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003165 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3166 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003167 spec->multiout.num_dacs++;
3168 }
3169 return 0;
3170}
3171
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003172static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003173{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003174 int i;
3175 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3176 if (!spec->multiout.extra_out_nid[i]) {
3177 spec->multiout.extra_out_nid[i] = nid;
3178 return 0;
3179 }
3180 }
3181 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3182 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003183}
3184
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003185/* Create output controls
3186 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3187 */
3188static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3189 const hda_nid_t *pins,
3190 const hda_nid_t *dac_nids,
3191 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003192{
Takashi Iwai76624532008-12-19 10:09:47 +01003193 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003194 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003195 "Front", "Surround", NULL /*CLFE*/, "Side"
3196 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003197 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003198 int i, err;
3199 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003200
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003201 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003202 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003203 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003204 spec->hp_detect = 1;
3205 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003206 nid = dac_nids[i];
3207 if (!nid)
3208 continue;
3209 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003210 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003211 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003212 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003213 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003214 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003215 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003216 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003217
3218 wid_caps = get_wcaps(codec, nid);
3219
3220 if (wid_caps & AC_WCAP_LR_SWAP) {
3221 err = stac92xx_add_control(spec,
3222 STAC_CTL_WIDGET_CLFE_SWITCH,
3223 "Swap Center/LFE Playback Switch", nid);
3224
3225 if (err < 0)
3226 return err;
3227 }
3228
Mattc7d4b2f2005-06-27 14:59:41 +02003229 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003230 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003231 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003232 switch (type) {
3233 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003234 name = "Headphone";
3235 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003236 break;
3237 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003238 name = "Speaker";
3239 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003240 break;
3241 default:
3242 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003243 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003244 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003245 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003246 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003247 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003248 return err;
3249 }
3250 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003251 return 0;
3252}
3253
Takashi Iwai6479c632009-07-28 18:20:25 +02003254static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3255 unsigned long sw, int idx)
3256{
3257 int err;
3258 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003259 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003260 if (err < 0)
3261 return err;
3262 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003263 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003264 if (err < 0)
3265 return err;
3266 return 0;
3267}
3268
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003269/* add playback controls from the parsed DAC table */
3270static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3271 const struct auto_pin_cfg *cfg)
3272{
3273 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003274 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003275 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003276 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003277
3278 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3279 spec->multiout.dac_nids,
3280 cfg->line_out_type);
3281 if (err < 0)
3282 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003283
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003284 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003285 err = stac92xx_add_control(spec,
3286 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003287 "Headphone as Line Out Switch",
3288 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003289 if (err < 0)
3290 return err;
3291 }
3292
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003293 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003294 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003295 break;
3296 nid = cfg->inputs[idx].pin;
3297 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3298 if (err < 0)
3299 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003300 }
Matt Porter403d1942005-11-29 15:00:51 +01003301
Mattc7d4b2f2005-06-27 14:59:41 +02003302 return 0;
3303}
3304
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003305/* add playback controls for Speaker and HP outputs */
3306static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3307 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003308{
3309 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003310 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003311
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003312 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3313 spec->hp_dacs, AUTO_PIN_HP_OUT);
3314 if (err < 0)
3315 return err;
3316
3317 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3318 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3319 if (err < 0)
3320 return err;
3321
Mattc7d4b2f2005-06-27 14:59:41 +02003322 return 0;
3323}
3324
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003325/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003326static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003327 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003328};
3329
3330/* create mono mux for mono out on capable codecs */
3331static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3332{
3333 struct sigmatel_spec *spec = codec->spec;
3334 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3335 int i, num_cons;
3336 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3337
3338 num_cons = snd_hda_get_connections(codec,
3339 spec->mono_nid,
3340 con_lst,
3341 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003342 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003343 return -EINVAL;
3344
Takashi Iwai10a20af2010-09-09 16:28:02 +02003345 for (i = 0; i < num_cons; i++)
3346 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3347 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003348
3349 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3350 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003351}
3352
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003353/* create PC beep volume controls */
3354static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3355 hda_nid_t nid)
3356{
3357 struct sigmatel_spec *spec = codec->spec;
3358 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003359 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3360
3361 if (spec->anabeep_nid == nid)
3362 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003363
3364 /* check for mute support for the the amp */
3365 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003366 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003367 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003368 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3369 if (err < 0)
3370 return err;
3371 }
3372
3373 /* check to see if there is volume support for the amp */
3374 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3375 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003376 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003377 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3378 if (err < 0)
3379 return err;
3380 }
3381 return 0;
3382}
3383
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003384#ifdef CONFIG_SND_HDA_INPUT_BEEP
3385#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3386
3387static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3388 struct snd_ctl_elem_value *ucontrol)
3389{
3390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3391 ucontrol->value.integer.value[0] = codec->beep->enabled;
3392 return 0;
3393}
3394
3395static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3396 struct snd_ctl_elem_value *ucontrol)
3397{
3398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003399 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003400}
3401
Takashi Iwai2b635362011-05-02 12:33:43 +02003402static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3404 .info = stac92xx_dig_beep_switch_info,
3405 .get = stac92xx_dig_beep_switch_get,
3406 .put = stac92xx_dig_beep_switch_put,
3407};
3408
3409static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3410{
3411 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003412 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003413}
3414#endif
3415
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003416static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3417{
3418 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003419 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003420
3421 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003422 hda_nid_t nid;
3423 unsigned int wcaps;
3424 unsigned long val;
3425
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003426 nid = spec->mux_nids[i];
3427 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003428 if (!(wcaps & AC_WCAP_OUT_AMP))
3429 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003430
Takashi Iwai667067d2009-08-13 18:14:42 +02003431 /* check whether already the same control was created as
3432 * normal Capture Volume.
3433 */
3434 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3435 for (j = 0; j < spec->num_caps; j++) {
3436 if (spec->capvols[j] == val)
3437 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003438 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003439 if (j < spec->num_caps)
3440 continue;
3441
3442 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3443 "Mux Capture Volume", val);
3444 if (err < 0)
3445 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003446 }
3447 return 0;
3448};
3449
Takashi Iwaiea734962011-01-17 11:29:34 +01003450static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003451 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003452};
3453
3454static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3455{
3456 struct sigmatel_spec *spec = codec->spec;
3457 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01003458 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003459 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003460 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003461
3462 num_cons = snd_hda_get_connections(codec,
3463 spec->smux_nids[0],
3464 con_lst,
3465 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003466 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003467 return -EINVAL;
3468
Matthew Ranostay65973632008-09-16 10:39:37 -04003469 if (!labels)
3470 labels = stac92xx_spdif_labels;
3471
Takashi Iwai10a20af2010-09-09 16:28:02 +02003472 for (i = 0; i < num_cons; i++)
3473 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02003474
3475 return 0;
3476}
3477
Matt Porter8b657272006-10-26 17:12:59 +02003478/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003479static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003480 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3481 "Digital Mic 3", "Digital Mic 4"
3482};
3483
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003484static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3485 int idx)
3486{
3487 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3488 int nums;
3489 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3490 if (idx >= 0 && idx < nums)
3491 return conn[idx];
3492 return 0;
3493}
3494
Takashi Iwai8d087c72011-06-28 12:45:47 +02003495/* look for NID recursively */
3496#define get_connection_index(codec, mux, nid) \
3497 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003498
Takashi Iwai667067d2009-08-13 18:14:42 +02003499/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003500/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003501static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003502 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003503{
3504 unsigned int caps, nums;
3505 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003506 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003507
Takashi Iwai96f845d2009-08-29 00:49:36 +02003508 if (direction == HDA_OUTPUT)
3509 caps = AC_WCAP_OUT_AMP;
3510 else
3511 caps = AC_WCAP_IN_AMP;
3512 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003513 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003514 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003515 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3516 if (!nums)
3517 return 0;
3518 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003519 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3520 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02003521 if (err < 0)
3522 return err;
3523 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003524}
3525
Matt Porter8b657272006-10-26 17:12:59 +02003526/* create playback/capture controls for input pins on dmic capable codecs */
3527static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3528 const struct auto_pin_cfg *cfg)
3529{
3530 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003531 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003532 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003533 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02003534 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003535
Takashi Iwai10a20af2010-09-09 16:28:02 +02003536 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02003537
Matt Porter8b657272006-10-26 17:12:59 +02003538 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003539 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003540 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01003541 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02003542
Takashi Iwai667067d2009-08-13 18:14:42 +02003543 nid = spec->dmic_nids[i];
3544 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3545 continue;
3546 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003547 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3548 continue;
3549
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003550 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3551 if (index < 0)
3552 continue;
3553
Takashi Iwai201e06f2011-11-16 15:33:26 +01003554 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3555 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02003556 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01003557 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3558 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02003559
Takashi Iwai10a20af2010-09-09 16:28:02 +02003560 err = create_elem_capture_vol(codec, nid, label, type_idx,
3561 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003562 if (err < 0)
3563 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003564 if (!err) {
3565 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02003566 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003567 if (err < 0)
3568 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003569 if (!err) {
3570 nid = get_connected_node(codec,
3571 spec->dmux_nids[0], index);
3572 if (nid)
3573 err = create_elem_capture_vol(codec,
3574 nid, label,
3575 type_idx, HDA_INPUT);
3576 if (err < 0)
3577 return err;
3578 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02003579 }
Matt Porter8b657272006-10-26 17:12:59 +02003580 }
3581
3582 return 0;
3583}
3584
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003585static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02003586 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003587{
3588 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003589 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003590
3591 if (!nid)
3592 return 0;
3593 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003594 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003595 switch (snd_hda_get_input_pin_attr(cfg)) {
3596 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003597 if (*fixed)
3598 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003599 if (type != AC_JACK_MIC_IN)
3600 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003601 *fixed = nid;
3602 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003603 case INPUT_PIN_ATTR_UNUSED:
3604 break;
3605 case INPUT_PIN_ATTR_DOCK:
3606 if (*dock)
3607 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003608 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3609 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003610 *dock = nid;
3611 break;
3612 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003613 if (*ext)
3614 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003615 if (type != AC_JACK_MIC_IN)
3616 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003617 *ext = nid;
3618 break;
3619 }
3620 return 0;
3621}
3622
3623static int set_mic_route(struct hda_codec *codec,
3624 struct sigmatel_mic_route *mic,
3625 hda_nid_t pin)
3626{
3627 struct sigmatel_spec *spec = codec->spec;
3628 struct auto_pin_cfg *cfg = &spec->autocfg;
3629 int i;
3630
3631 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02003632 if (pin == 0)
3633 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003634 for (i = 0; i < cfg->num_inputs; i++) {
3635 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003636 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003637 }
Takashi Iwai86e29592010-09-09 14:50:17 +02003638 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003639 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003640 i = get_connection_index(codec, spec->mux_nids[0], pin);
3641 if (i < 0)
3642 return -1;
3643 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003644 mic->dmux_idx = -1;
3645 if (spec->dmux_nids)
3646 mic->dmux_idx = get_connection_index(codec,
3647 spec->dmux_nids[0],
3648 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003649 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003650 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003651 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3652 if (i < 0)
3653 return -1;
3654 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003655 mic->mux_idx = -1;
3656 if (spec->mux_nids)
3657 mic->mux_idx = get_connection_index(codec,
3658 spec->mux_nids[0],
3659 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003660 }
3661 return 0;
3662}
3663
3664/* return non-zero if the device is for automatic mic switch */
3665static int stac_check_auto_mic(struct hda_codec *codec)
3666{
3667 struct sigmatel_spec *spec = codec->spec;
3668 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02003669 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003670 int i;
3671
Charles Chin99077902010-09-17 10:22:32 +02003672 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003673 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02003674 if (check_mic_pin(codec, cfg->inputs[i].pin,
3675 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003676 return 0;
3677 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02003678 if (check_mic_pin(codec, spec->dmic_nids[i],
3679 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003680 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01003681 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02003682 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003683 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003684 return 0; /* no unsol support */
3685 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02003686 set_mic_route(codec, &spec->int_mic, fixed) ||
3687 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003688 return 0; /* something is wrong */
3689 return 1;
3690}
3691
Mattc7d4b2f2005-06-27 14:59:41 +02003692/* create playback/capture controls for input pins */
3693static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3694{
3695 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003696 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003697 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003698 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02003699
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003700 for (i = 0; i < cfg->num_inputs; i++) {
3701 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003702 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02003703
Takashi Iwai314634b2006-09-21 11:56:18 +02003704 index = -1;
3705 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003706 index = get_connection_index(codec, spec->mux_nids[j],
3707 nid);
3708 if (index >= 0)
3709 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003710 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003711 if (index < 0)
3712 continue;
3713
Takashi Iwai10a20af2010-09-09 16:28:02 +02003714 label = hda_get_autocfg_input_label(codec, cfg, i);
3715 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003716
Takashi Iwai667067d2009-08-13 18:14:42 +02003717 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003718 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003719 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003720 if (err < 0)
3721 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003722 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003723 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003724
Steve Longerbeam7b043892007-05-03 20:50:03 +02003725 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003726 /*
3727 * Set the current input for the muxes.
3728 * The STAC9221 has two input muxes with identical source
3729 * NID lists. Hopefully this won't get confused.
3730 */
3731 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003732 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3733 AC_VERB_SET_CONNECT_SEL,
3734 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003735 }
3736 }
3737
Mattc7d4b2f2005-06-27 14:59:41 +02003738 return 0;
3739}
3740
Mattc7d4b2f2005-06-27 14:59:41 +02003741static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3742{
3743 struct sigmatel_spec *spec = codec->spec;
3744 int i;
3745
3746 for (i = 0; i < spec->autocfg.line_outs; i++) {
3747 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3748 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3749 }
3750}
3751
3752static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3753{
3754 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003755 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003756
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003757 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3758 hda_nid_t pin;
3759 pin = spec->autocfg.hp_pins[i];
3760 if (pin) /* connect to front */
3761 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3762 }
3763 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3764 hda_nid_t pin;
3765 pin = spec->autocfg.speaker_pins[i];
3766 if (pin) /* connect to front */
3767 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3768 }
Mattc7d4b2f2005-06-27 14:59:41 +02003769}
3770
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003771static int is_dual_headphones(struct hda_codec *codec)
3772{
3773 struct sigmatel_spec *spec = codec->spec;
3774 int i, valid_hps;
3775
3776 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3777 spec->autocfg.hp_outs <= 1)
3778 return 0;
3779 valid_hps = 0;
3780 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3781 hda_nid_t nid = spec->autocfg.hp_pins[i];
3782 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3783 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3784 continue;
3785 valid_hps++;
3786 }
3787 return (valid_hps > 1);
3788}
3789
3790
Charles Chin9009b0e2011-11-03 10:27:27 +01003791static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003792{
3793 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01003794 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003795 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003796 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003797
Matt Porter8b657272006-10-26 17:12:59 +02003798 if ((err = snd_hda_parse_pin_def_config(codec,
3799 &spec->autocfg,
3800 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003801 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003802 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003803 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003804
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003805 /* If we have no real line-out pin and multiple hp-outs, HPs should
3806 * be set up as multi-channel outputs.
3807 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003808 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003809 /* Copy hp_outs to line_outs, backup line_outs in
3810 * speaker_outs so that the following routines can handle
3811 * HP pins as primary outputs.
3812 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003813 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003814 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3815 sizeof(spec->autocfg.line_out_pins));
3816 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3817 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3818 sizeof(spec->autocfg.hp_pins));
3819 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003820 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3821 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003822 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003823 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003824 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003825 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3826 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003827 u32 caps = query_amp_caps(codec,
3828 spec->autocfg.mono_out_pin, dir);
3829 hda_nid_t conn_list[1];
3830
3831 /* get the mixer node and then the mono mux if it exists */
3832 if (snd_hda_get_connections(codec,
3833 spec->autocfg.mono_out_pin, conn_list, 1) &&
3834 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003835 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003836
3837 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003838 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003839 /* LR swap check, some stac925x have a mux that
3840 * changes the DACs output path instead of the
3841 * mono-mux path.
3842 */
3843 if (wid_type == AC_WID_AUD_SEL &&
3844 !(wcaps & AC_WCAP_LR_SWAP))
3845 spec->mono_nid = conn_list[0];
3846 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003847 if (dir) {
3848 hda_nid_t nid = spec->autocfg.mono_out_pin;
3849
3850 /* most mono outs have a least a mute/unmute switch */
3851 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3852 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3853 "Mono Playback Switch",
3854 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003855 if (err < 0)
3856 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003857 /* check for volume support for the amp */
3858 if ((caps & AC_AMPCAP_NUM_STEPS)
3859 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3860 err = stac92xx_add_control(spec,
3861 STAC_CTL_WIDGET_VOL,
3862 "Mono Playback Volume",
3863 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3864 if (err < 0)
3865 return err;
3866 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003867 }
3868
3869 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3870 AC_PINCTL_OUT_EN);
3871 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003872
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003873 if (!spec->multiout.num_dacs) {
3874 err = stac92xx_auto_fill_dac_nids(codec);
3875 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003876 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003877 err = stac92xx_auto_create_multi_out_ctls(codec,
3878 &spec->autocfg);
3879 if (err < 0)
3880 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003881 }
Mattc7d4b2f2005-06-27 14:59:41 +02003882
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003883 /* setup analog beep controls */
3884 if (spec->anabeep_nid > 0) {
3885 err = stac92xx_auto_create_beep_ctls(codec,
3886 spec->anabeep_nid);
3887 if (err < 0)
3888 return err;
3889 }
3890
3891 /* setup digital beep controls and input device */
3892#ifdef CONFIG_SND_HDA_INPUT_BEEP
3893 if (spec->digbeep_nid > 0) {
3894 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003895 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003896
3897 err = stac92xx_auto_create_beep_ctls(codec, nid);
3898 if (err < 0)
3899 return err;
3900 err = snd_hda_attach_beep_device(codec, nid);
3901 if (err < 0)
3902 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003903 if (codec->beep) {
3904 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003905 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003906 /* if no beep switch is available, make its own one */
3907 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3908 if (!(caps & AC_AMPCAP_MUTE)) {
3909 err = stac92xx_beep_switch_ctl(codec);
3910 if (err < 0)
3911 return err;
3912 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003913 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003914 }
3915#endif
3916
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003917 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003918 if (err < 0)
3919 return err;
3920
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003921 /* All output parsing done, now restore the swapped hp pins */
3922 if (hp_swap) {
3923 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3924 sizeof(spec->autocfg.hp_pins));
3925 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3926 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3927 spec->autocfg.line_outs = 0;
3928 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003929
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003930 if (stac_check_auto_mic(codec)) {
3931 spec->auto_mic = 1;
3932 /* only one capture for auto-mic */
3933 spec->num_adcs = 1;
3934 spec->num_caps = 1;
3935 spec->num_muxes = 1;
3936 }
3937
Takashi Iwai6479c632009-07-28 18:20:25 +02003938 for (i = 0; i < spec->num_caps; i++) {
3939 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3940 spec->capsws[i], i);
3941 if (err < 0)
3942 return err;
3943 }
3944
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003945 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003946 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003947 return err;
3948
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003949 if (spec->mono_nid > 0) {
3950 err = stac92xx_auto_create_mono_output_ctls(codec);
3951 if (err < 0)
3952 return err;
3953 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003954 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003955 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3956 &spec->autocfg)) < 0)
3957 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003958 if (spec->num_muxes > 0) {
3959 err = stac92xx_auto_create_mux_input_ctls(codec);
3960 if (err < 0)
3961 return err;
3962 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003963 if (spec->num_smuxes > 0) {
3964 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3965 if (err < 0)
3966 return err;
3967 }
Matt Porter8b657272006-10-26 17:12:59 +02003968
Takashi Iwaie3c75962009-01-23 11:57:22 +01003969 err = stac92xx_add_input_source(spec);
3970 if (err < 0)
3971 return err;
3972
Mattc7d4b2f2005-06-27 14:59:41 +02003973 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003974 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003975 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003976
Charles Chin9009b0e2011-11-03 10:27:27 +01003977 /* find digital out and in converters */
3978 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3979 unsigned int wid_caps = get_wcaps(codec, i);
3980 if (wid_caps & AC_WCAP_DIGITAL) {
3981 switch (get_wcaps_type(wid_caps)) {
3982 case AC_WID_AUD_OUT:
3983 if (!dig_out)
3984 dig_out = i;
3985 break;
3986 case AC_WID_AUD_IN:
3987 if (!dig_in)
3988 dig_in = i;
3989 break;
3990 }
3991 }
3992 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003993 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003994 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003995 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003996 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003997
Takashi Iwai603c4012008-07-30 15:01:44 +02003998 if (spec->kctls.list)
3999 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004000
4001 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05004002 if (!spec->dinput_mux)
4003 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004004 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004005 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02004006 return 1;
4007}
4008
Takashi Iwai82bc9552006-03-21 11:24:42 +01004009/* add playback controls for HP output */
4010static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4011 struct auto_pin_cfg *cfg)
4012{
4013 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004014 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01004015
4016 if (! pin)
4017 return 0;
4018
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004019 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01004020 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004021
4022 return 0;
4023}
4024
Richard Fish160ea0d2006-09-06 13:58:25 +02004025/* add playback controls for LFE output */
4026static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4027 struct auto_pin_cfg *cfg)
4028{
4029 struct sigmatel_spec *spec = codec->spec;
4030 int err;
4031 hda_nid_t lfe_pin = 0x0;
4032 int i;
4033
4034 /*
4035 * search speaker outs and line outs for a mono speaker pin
4036 * with an amp. If one is found, add LFE controls
4037 * for it.
4038 */
4039 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4040 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004041 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004042 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4043 if (wcaps == AC_WCAP_OUT_AMP)
4044 /* found a mono speaker with an amp, must be lfe */
4045 lfe_pin = pin;
4046 }
4047
4048 /* if speaker_outs is 0, then speakers may be in line_outs */
4049 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4050 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4051 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004052 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004053 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004054 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004055 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004056 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4057 if (wcaps == AC_WCAP_OUT_AMP)
4058 /* found a mono speaker with an amp,
4059 must be lfe */
4060 lfe_pin = pin;
4061 }
4062 }
4063 }
4064
4065 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004066 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004067 if (err < 0)
4068 return err;
4069 }
4070
4071 return 0;
4072}
4073
Mattc7d4b2f2005-06-27 14:59:41 +02004074static int stac9200_parse_auto_config(struct hda_codec *codec)
4075{
4076 struct sigmatel_spec *spec = codec->spec;
4077 int err;
4078
Kailang Yangdf694da2005-12-05 19:42:22 +01004079 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004080 return err;
4081
4082 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4083 return err;
4084
Takashi Iwai82bc9552006-03-21 11:24:42 +01004085 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4086 return err;
4087
Richard Fish160ea0d2006-09-06 13:58:25 +02004088 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4089 return err;
4090
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004091 if (spec->num_muxes > 0) {
4092 err = stac92xx_auto_create_mux_input_ctls(codec);
4093 if (err < 0)
4094 return err;
4095 }
4096
Takashi Iwaie3c75962009-01-23 11:57:22 +01004097 err = stac92xx_add_input_source(spec);
4098 if (err < 0)
4099 return err;
4100
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004101 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004102 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004103 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004104 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004105
Takashi Iwai603c4012008-07-30 15:01:44 +02004106 if (spec->kctls.list)
4107 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004108
4109 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004110 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004111
4112 return 1;
4113}
4114
Sam Revitch62fe78e2006-05-10 15:09:17 +02004115/*
4116 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4117 * funky external mute control using GPIO pins.
4118 */
4119
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004120static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004121 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004122{
4123 unsigned int gpiostate, gpiomask, gpiodir;
4124
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004125 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4126
Sam Revitch62fe78e2006-05-10 15:09:17 +02004127 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4128 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004129 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004130
4131 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4132 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004133 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004134
4135 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4136 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004137 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004138
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004139 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004140 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4141
4142 snd_hda_codec_write(codec, codec->afg, 0,
4143 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004144 snd_hda_codec_read(codec, codec->afg, 0,
4145 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004146
4147 msleep(1);
4148
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004149 snd_hda_codec_read(codec, codec->afg, 0,
4150 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004151}
4152
Takashi Iwai3a938972011-10-28 01:16:55 +02004153static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004154 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004155{
Takashi Iwai3a938972011-10-28 01:16:55 +02004156 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004157
Takashi Iwai3a938972011-10-28 01:16:55 +02004158 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004159 if (!event)
4160 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02004161 event->action = type;
4162 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004163
Takashi Iwai3a938972011-10-28 01:16:55 +02004164 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004165}
4166
Takashi Iwai62558ce2009-07-29 14:23:09 +02004167/* check if given nid is a valid pin and no other events are assigned
4168 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4169 * Otherwise, returns zero.
4170 */
4171static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4172 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004173{
Takashi Iwai3a938972011-10-28 01:16:55 +02004174 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004175
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004176 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004177 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02004178 event = snd_hda_jack_tbl_new(codec, nid);
4179 if (!event)
4180 return -ENOMEM;
4181 if (event->action && event->action != type)
4182 return 0;
4183 event->action = type;
4184 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004185 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004186}
4187
Takashi Iwaib4ead012012-01-23 18:23:36 +01004188static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004189{
4190 int i;
4191 for (i = 0; i < cfg->hp_outs; i++)
4192 if (cfg->hp_pins[i] == nid)
4193 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01004194 for (i = 0; i < cfg->line_outs; i++)
4195 if (cfg->line_out_pins[i] == nid)
4196 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004197 return 0; /* nid is not a HP-Out */
4198};
4199
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004200static void stac92xx_power_down(struct hda_codec *codec)
4201{
4202 struct sigmatel_spec *spec = codec->spec;
4203
4204 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02004205 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004206 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004207 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004208 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004209 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4210}
4211
Takashi Iwaif73d3582008-11-25 08:21:51 +01004212static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4213 int enable);
4214
Takashi Iwai014c41f2009-12-27 13:53:24 +01004215static inline int get_int_hint(struct hda_codec *codec, const char *key,
4216 int *valp)
4217{
4218 const char *p;
4219 p = snd_hda_get_hint(codec, key);
4220 if (p) {
4221 unsigned long val;
4222 if (!strict_strtoul(p, 0, &val)) {
4223 *valp = val;
4224 return 1;
4225 }
4226 }
4227 return 0;
4228}
4229
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004230/* override some hints from the hwdep entry */
4231static void stac_store_hints(struct hda_codec *codec)
4232{
4233 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004234 int val;
4235
4236 val = snd_hda_get_bool_hint(codec, "hp_detect");
4237 if (val >= 0)
4238 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004239 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004240 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4241 spec->gpio_mask;
4242 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004243 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4244 spec->gpio_mask &= spec->gpio_mask;
4245 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4246 spec->gpio_dir &= spec->gpio_mask;
4247 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4248 spec->eapd_mask &= spec->gpio_mask;
4249 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4250 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004251 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4252 if (val >= 0)
4253 spec->eapd_switch = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004254 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4255 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004256 spec->gpio_mask |= spec->gpio_led;
4257 spec->gpio_dir |= spec->gpio_led;
4258 if (spec->gpio_led_polarity)
4259 spec->gpio_data |= spec->gpio_led;
Takashi Iwai043958e2009-12-26 10:36:12 +01004260 }
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004261}
4262
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004263static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4264 const hda_nid_t *pins)
4265{
4266 while (num_pins--)
4267 stac_issue_unsol_event(codec, *pins++);
4268}
4269
4270/* fake event to set up pins */
4271static void stac_fake_hp_events(struct hda_codec *codec)
4272{
4273 struct sigmatel_spec *spec = codec->spec;
4274
4275 if (spec->autocfg.hp_outs)
4276 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4277 spec->autocfg.hp_pins);
4278 if (spec->autocfg.line_outs &&
4279 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4280 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4281 spec->autocfg.line_out_pins);
4282}
4283
Mattc7d4b2f2005-06-27 14:59:41 +02004284static int stac92xx_init(struct hda_codec *codec)
4285{
4286 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004287 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004288 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004289 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004290
Mattc7d4b2f2005-06-27 14:59:41 +02004291 snd_hda_sequence_write(codec, spec->init);
4292
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004293 /* power down adcs initially */
4294 if (spec->powerdown_adcs)
4295 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004296 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004297 spec->adc_nids[i], 0,
4298 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004299
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004300 /* override some hints */
4301 stac_store_hints(codec);
4302
Takashi Iwaif73d3582008-11-25 08:21:51 +01004303 /* set up GPIO */
4304 gpio = spec->gpio_data;
4305 /* turn on EAPD statically when spec->eapd_switch isn't set.
4306 * otherwise, unsol event will turn it on/off dynamically
4307 */
4308 if (!spec->eapd_switch)
4309 gpio |= spec->eapd_mask;
4310 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4311
Takashi Iwai82bc9552006-03-21 11:24:42 +01004312 /* set up pins */
4313 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004314 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004315 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004316 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004317 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004318 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004319 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4320 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004321 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004322 for (i = 0; i < cfg->line_outs; i++) {
4323 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004324 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4325 }
4326 }
4327
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004328 /* force to enable the first line-out; the others are set up
4329 * in unsol_event
4330 */
4331 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004332 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004333 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004334 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004335 } else {
4336 stac92xx_auto_init_multi_out(codec);
4337 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004338 for (i = 0; i < cfg->hp_outs; i++)
4339 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004340 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004341 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004342 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004343 if (spec->dmux_nids)
4344 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004345 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004346 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4347 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02004348 if (enable_pin_detect(codec, spec->dock_mic.pin,
4349 STAC_MIC_EVENT))
4350 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004351 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004352 for (i = 0; i < cfg->num_inputs; i++) {
4353 hda_nid_t nid = cfg->inputs[i].pin;
4354 int type = cfg->inputs[i].type;
4355 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02004356 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004357 /* for mic pins, force to initialize */
4358 pinctl = stac92xx_get_default_vref(codec, nid);
4359 pinctl |= AC_PINCTL_IN_EN;
4360 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4361 } else {
4362 pinctl = snd_hda_codec_read(codec, nid, 0,
4363 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4364 /* if PINCTL already set then skip */
4365 /* Also, if both INPUT and OUTPUT are set,
4366 * it must be a BIOS bug; need to override, too
4367 */
4368 if (!(pinctl & AC_PINCTL_IN_EN) ||
4369 (pinctl & AC_PINCTL_OUT_EN)) {
4370 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004371 pinctl |= AC_PINCTL_IN_EN;
4372 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004373 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004374 }
4375 conf = snd_hda_codec_get_pincfg(codec, nid);
4376 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4377 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4378 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01004379 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004380 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004381 for (i = 0; i < spec->num_dmics; i++)
4382 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4383 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004384 if (cfg->dig_out_pins[0])
4385 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004386 AC_PINCTL_OUT_EN);
4387 if (cfg->dig_in_pin)
4388 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4389 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004390 for (i = 0; i < spec->num_pwrs; i++) {
4391 hda_nid_t nid = spec->pwr_nids[i];
4392 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004393
Takashi Iwaieb632122008-12-19 16:39:48 +01004394 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01004395 /* or when the VREF is used for controlling LED */
4396 if (!spec->hp_detect ||
Takashi Iwaia0204282011-12-06 13:17:23 +01004397 spec->vref_mute_led_nid == nid) {
Takashi Iwaieb632122008-12-19 16:39:48 +01004398 stac_toggle_power_map(codec, nid, 1);
4399 continue;
4400 }
4401
Takashi Iwaib4ead012012-01-23 18:23:36 +01004402 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004403 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004404
Takashi Iwaif73d3582008-11-25 08:21:51 +01004405 pinctl = snd_hda_codec_read(codec, nid, 0,
4406 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4407 /* outputs are only ports capable of power management
4408 * any attempts on powering down a input port cause the
4409 * referenced VREF to act quirky.
4410 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004411 if (pinctl & AC_PINCTL_IN_EN) {
4412 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004413 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004414 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004415 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004416 def_conf = get_defcfg_connect(def_conf);
4417 /* skip any ports that don't have jacks since presence
4418 * detection is useless */
4419 if (def_conf != AC_JACK_PORT_COMPLEX) {
4420 if (def_conf != AC_JACK_PORT_NONE)
4421 stac_toggle_power_map(codec, nid, 1);
4422 continue;
4423 }
Charles Chinafef2cf2011-11-11 08:05:28 +01004424 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004425 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01004426 continue;
4427 }
4428 /* none of the above, turn the port OFF */
4429 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004430 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004431
Takashi Iwai01a61e12011-10-28 00:03:22 +02004432 snd_hda_jack_report_sync(codec);
4433
Takashi Iwaic21bd022010-02-08 15:16:08 +01004434 /* sync mute LED */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01004435 snd_ctl_sync_vmaster_hook(spec->vmaster_sw_kctl);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004436 if (spec->dac_list)
4437 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004438 return 0;
4439}
4440
Takashi Iwai603c4012008-07-30 15:01:44 +02004441static void stac92xx_free_kctls(struct hda_codec *codec)
4442{
4443 struct sigmatel_spec *spec = codec->spec;
4444
4445 if (spec->kctls.list) {
4446 struct snd_kcontrol_new *kctl = spec->kctls.list;
4447 int i;
4448 for (i = 0; i < spec->kctls.used; i++)
4449 kfree(kctl[i].name);
4450 }
4451 snd_array_free(&spec->kctls);
4452}
4453
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004454static void stac92xx_shutup_pins(struct hda_codec *codec)
4455{
4456 unsigned int i, def_conf;
4457
4458 if (codec->bus->shutdown)
4459 return;
4460 for (i = 0; i < codec->init_pins.used; i++) {
4461 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4462 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4463 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
4464 snd_hda_codec_write(codec, pin->nid, 0,
4465 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4466 }
4467}
4468
Takashi Iwai167eae52009-11-06 15:47:50 +01004469static void stac92xx_shutup(struct hda_codec *codec)
4470{
4471 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004472
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004473 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004474
4475 if (spec->eapd_mask)
4476 stac_gpio_set(codec, spec->gpio_mask,
4477 spec->gpio_dir, spec->gpio_data &
4478 ~spec->eapd_mask);
4479}
4480
Matt2f2f4252005-04-13 14:45:30 +02004481static void stac92xx_free(struct hda_codec *codec)
4482{
Mattc7d4b2f2005-06-27 14:59:41 +02004483 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004484
4485 if (! spec)
4486 return;
4487
Takashi Iwai167eae52009-11-06 15:47:50 +01004488 stac92xx_shutup(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02004489
Mattc7d4b2f2005-06-27 14:59:41 +02004490 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004491 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004492}
4493
Matt4e550962005-07-04 17:51:39 +02004494static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4495 unsigned int flag)
4496{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004497 unsigned int old_ctl, pin_ctl;
4498
4499 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004500 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004501
Takashi Iwaif9acba42007-05-29 18:01:06 +02004502 if (pin_ctl & AC_PINCTL_IN_EN) {
4503 /*
4504 * we need to check the current set-up direction of
4505 * shared input pins since they can be switched via
4506 * "xxx as Output" mixer switch
4507 */
4508 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004509 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004510 return;
4511 }
4512
Takashi Iwai8ce84192009-01-22 16:59:20 +01004513 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004514 /* if setting pin direction bits, clear the current
4515 direction bits first */
4516 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4517 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4518
Takashi Iwai8ce84192009-01-22 16:59:20 +01004519 pin_ctl |= flag;
4520 if (old_ctl != pin_ctl)
4521 snd_hda_codec_write_cache(codec, nid, 0,
4522 AC_VERB_SET_PIN_WIDGET_CONTROL,
4523 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004524}
4525
4526static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4527 unsigned int flag)
4528{
4529 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4530 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004531 if (pin_ctl & flag)
4532 snd_hda_codec_write_cache(codec, nid, 0,
4533 AC_VERB_SET_PIN_WIDGET_CONTROL,
4534 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004535}
4536
Takashi Iwaid56757a2009-11-18 08:00:14 +01004537static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004538{
4539 if (!nid)
4540 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004541 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004542}
4543
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004544static void stac92xx_line_out_detect(struct hda_codec *codec,
4545 int presence)
4546{
4547 struct sigmatel_spec *spec = codec->spec;
4548 struct auto_pin_cfg *cfg = &spec->autocfg;
4549 int i;
4550
4551 for (i = 0; i < cfg->line_outs; i++) {
4552 if (presence)
4553 break;
4554 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4555 if (presence) {
4556 unsigned int pinctl;
4557 pinctl = snd_hda_codec_read(codec,
4558 cfg->line_out_pins[i], 0,
4559 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4560 if (pinctl & AC_PINCTL_IN_EN)
4561 presence = 0; /* mic- or line-input */
4562 }
4563 }
4564
4565 if (presence) {
4566 /* disable speakers */
4567 for (i = 0; i < cfg->speaker_outs; i++)
4568 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4569 AC_PINCTL_OUT_EN);
4570 if (spec->eapd_mask && spec->eapd_switch)
4571 stac_gpio_set(codec, spec->gpio_mask,
4572 spec->gpio_dir, spec->gpio_data &
4573 ~spec->eapd_mask);
4574 } else {
4575 /* enable speakers */
4576 for (i = 0; i < cfg->speaker_outs; i++)
4577 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4578 AC_PINCTL_OUT_EN);
4579 if (spec->eapd_mask && spec->eapd_switch)
4580 stac_gpio_set(codec, spec->gpio_mask,
4581 spec->gpio_dir, spec->gpio_data |
4582 spec->eapd_mask);
4583 }
4584}
4585
Takashi Iwaid7a89432008-11-12 09:48:04 +01004586/* return non-zero if the hp-pin of the given array index isn't
4587 * a jack-detection target
4588 */
4589static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4590{
4591 struct auto_pin_cfg *cfg = &spec->autocfg;
4592
4593 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004594 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004595 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004596 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004597 return 1;
4598 /* ignore if the pin is set as line-out */
4599 if (cfg->hp_pins[i] == spec->hp_switch)
4600 return 1;
4601 return 0;
4602}
4603
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004604static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004605{
4606 struct sigmatel_spec *spec = codec->spec;
4607 struct auto_pin_cfg *cfg = &spec->autocfg;
4608 int i, presence;
4609
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004610 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004611 if (spec->gpio_mute)
4612 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4613 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4614
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004615 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004616 if (presence)
4617 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004618 if (no_hp_sensing(spec, i))
4619 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004620 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4621 if (presence) {
4622 unsigned int pinctl;
4623 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4624 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4625 if (pinctl & AC_PINCTL_IN_EN)
4626 presence = 0; /* mic- or line-input */
4627 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004628 }
Matt4e550962005-07-04 17:51:39 +02004629
4630 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004631 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004632 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004633 stac92xx_reset_pinctl(codec, spec->hp_switch,
4634 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004635 for (i = 0; i < cfg->line_outs; i++)
4636 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4637 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004638 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004639 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004640 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004641 stac92xx_set_pinctl(codec, spec->hp_switch,
4642 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004643 for (i = 0; i < cfg->line_outs; i++)
4644 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4645 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004646 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004647 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004648 /* toggle hp outs */
4649 for (i = 0; i < cfg->hp_outs; i++) {
4650 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4651 if (no_hp_sensing(spec, i))
4652 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01004653 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004654 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004655#if 0 /* FIXME */
4656/* Resetting the pinctl like below may lead to (a sort of) regressions
4657 * on some devices since they use the HP pin actually for line/speaker
4658 * outs although the default pin config shows a different pin (that is
4659 * wrong and useless).
4660 *
4661 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4662 * But, disabling the code below just works around it, and I'm too tired of
4663 * bug reports with such devices...
4664 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004665 else
4666 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004667#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004668 }
Matt4e550962005-07-04 17:51:39 +02004669}
4670
Takashi Iwaif73d3582008-11-25 08:21:51 +01004671static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4672 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004673{
4674 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004675 unsigned int idx, val;
4676
4677 for (idx = 0; idx < spec->num_pwrs; idx++) {
4678 if (spec->pwr_nids[idx] == nid)
4679 break;
4680 }
4681 if (idx >= spec->num_pwrs)
4682 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004683
Charles Chinafef2cf2011-11-11 08:05:28 +01004684 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004685
Takashi Iwaif73d3582008-11-25 08:21:51 +01004686 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4687 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004688 val &= ~idx;
4689 else
4690 val |= idx;
4691
4692 /* power down unused output ports */
4693 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004694}
4695
Takashi Iwaif73d3582008-11-25 08:21:51 +01004696static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4697{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004698 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004699}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004700
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004701/* get the pin connection (fixed, none, etc) */
4702static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4703{
4704 struct sigmatel_spec *spec = codec->spec;
4705 unsigned int cfg;
4706
4707 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4708 return get_defcfg_connect(cfg);
4709}
4710
4711static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004712 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004713{
4714 struct sigmatel_spec *spec = codec->spec;
4715 int idx, num;
4716 unsigned int def_conf;
4717
4718 for (num = 0; num < num_nids; num++) {
4719 for (idx = 0; idx < spec->num_pins; idx++)
4720 if (spec->pin_nids[idx] == nids[num])
4721 break;
4722 if (idx >= spec->num_pins)
4723 break;
4724 def_conf = stac_get_defcfg_connect(codec, idx);
4725 if (def_conf == AC_JACK_PORT_NONE)
4726 break;
4727 }
4728 return num;
4729}
4730
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004731static void stac92xx_mic_detect(struct hda_codec *codec)
4732{
4733 struct sigmatel_spec *spec = codec->spec;
4734 struct sigmatel_mic_route *mic;
4735
4736 if (get_pin_presence(codec, spec->ext_mic.pin))
4737 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02004738 else if (get_pin_presence(codec, spec->dock_mic.pin))
4739 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004740 else
4741 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004742 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004743 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4744 AC_VERB_SET_CONNECT_SEL,
4745 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004746 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004747 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4748 AC_VERB_SET_CONNECT_SEL,
4749 mic->mux_idx);
4750}
4751
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004752static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02004753 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02004754{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004755 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004756 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004757
Takashi Iwai3a938972011-10-28 01:16:55 +02004758 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004759 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004760 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004761 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004762 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004763 case STAC_MIC_EVENT:
4764 stac92xx_mic_detect(codec);
4765 break;
4766 }
4767
Takashi Iwai3a938972011-10-28 01:16:55 +02004768 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004769 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004770 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004771 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004772 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004773 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004774 if (spec->num_pwrs > 0)
4775 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004776
4777 switch (codec->subsystem_id) {
4778 case 0x103c308f:
4779 if (event->nid == 0xb) {
4780 int pin = AC_PINCTL_IN_EN;
4781
4782 if (get_pin_presence(codec, 0xa)
4783 && get_pin_presence(codec, 0xb))
4784 pin |= AC_PINCTL_VREF_80;
4785 if (!get_pin_presence(codec, 0xb))
4786 pin |= AC_PINCTL_VREF_80;
4787
4788 /* toggle VREF state based on mic + hp pin
4789 * status
4790 */
4791 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4792 }
4793 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004794 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004795 case STAC_VREF_EVENT:
4796 data = snd_hda_codec_read(codec, codec->afg, 0,
4797 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004798 /* toggle VREF state based on GPIOx status */
4799 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02004800 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004801 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004802 }
4803}
4804
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004805static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4806{
Takashi Iwai3a938972011-10-28 01:16:55 +02004807 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004808 if (!event)
4809 return;
4810 handle_unsol_event(codec, event);
4811}
4812
4813static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4814{
Takashi Iwai3a938972011-10-28 01:16:55 +02004815 struct hda_jack_tbl *event;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004816 int tag;
4817
4818 tag = (res >> 26) & 0x7f;
Takashi Iwai3a938972011-10-28 01:16:55 +02004819 event = snd_hda_jack_tbl_get_from_tag(codec, tag);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004820 if (!event)
4821 return;
Takashi Iwai3a938972011-10-28 01:16:55 +02004822 event->jack_dirty = 1;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004823 handle_unsol_event(codec, event);
Takashi Iwai01a61e12011-10-28 00:03:22 +02004824 snd_hda_jack_report_sync(codec);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004825}
4826
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304827static int hp_blike_system(u32 subsystem_id);
4828
4829static void set_hp_led_gpio(struct hda_codec *codec)
4830{
4831 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004832 unsigned int gpio;
4833
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004834 if (spec->gpio_led)
4835 return;
4836
Takashi Iwai07f80442010-02-08 15:06:13 +01004837 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4838 gpio &= AC_GPIO_IO_COUNT;
4839 if (gpio > 3)
4840 spec->gpio_led = 0x08; /* GPIO 3 */
4841 else
4842 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304843}
4844
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004845/*
4846 * This method searches for the mute LED GPIO configuration
4847 * provided as OEM string in SMBIOS. The format of that string
4848 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4849 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4850 * that corresponds to the NOT muted state of the master volume
4851 * and G is the index of the GPIO to use as the mute LED control (0..9)
4852 * If _G portion is missing it is assigned based on the codec ID
4853 *
4854 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4855 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304856 *
4857 *
4858 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4859 * SMBIOS - at least the ones I have seen do not have them - which include
4860 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4861 * HP Pavilion dv9500t CTO.
4862 * Need more information on whether it is true across the entire series.
4863 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004864 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004865static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004866{
4867 struct sigmatel_spec *spec = codec->spec;
4868 const struct dmi_device *dev = NULL;
4869
4870 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4871 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4872 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004873 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304874 &spec->gpio_led_polarity,
4875 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004876 unsigned int max_gpio;
4877 max_gpio = snd_hda_param_read(codec, codec->afg,
4878 AC_PAR_GPIO_CAP);
4879 max_gpio &= AC_GPIO_IO_COUNT;
4880 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004881 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01004882 else
4883 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004884 return 1;
4885 }
4886 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304887 &spec->gpio_led_polarity) == 1) {
4888 set_hp_led_gpio(codec);
4889 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004890 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004891 /* BIOS bug: unfilled OEM string */
4892 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4893 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02004894 switch (codec->subsystem_id) {
4895 case 0x103c148a:
4896 spec->gpio_led_polarity = 0;
4897 break;
4898 default:
4899 spec->gpio_led_polarity = 1;
4900 break;
4901 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004902 return 1;
4903 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004904 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304905
4906 /*
4907 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004908 * we statically set the GPIO - if not a B-series system
4909 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304910 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004911 if (!hp_blike_system(codec->subsystem_id) &&
4912 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304913 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004914 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304915 return 1;
4916 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004917 }
4918 return 0;
4919}
4920
4921static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004922{
4923 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004924 case 0x103c1520:
4925 case 0x103c1521:
4926 case 0x103c1523:
4927 case 0x103c1524:
4928 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004929 case 0x103c1722:
4930 case 0x103c1723:
4931 case 0x103c1724:
4932 case 0x103c1725:
4933 case 0x103c1726:
4934 case 0x103c1727:
4935 case 0x103c1728:
4936 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004937 case 0x103c172a:
4938 case 0x103c172b:
4939 case 0x103c307e:
4940 case 0x103c307f:
4941 case 0x103c3080:
4942 case 0x103c3081:
4943 case 0x103c7007:
4944 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004945 return 1;
4946 }
4947 return 0;
4948}
4949
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004950#ifdef CONFIG_PROC_FS
4951static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4952 struct hda_codec *codec, hda_nid_t nid)
4953{
4954 if (nid == codec->afg)
4955 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4956 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4957}
4958
4959static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4960 struct hda_codec *codec,
4961 unsigned int verb)
4962{
4963 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4964 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4965}
4966
4967/* stac92hd71bxx, stac92hd73xx */
4968static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4969 struct hda_codec *codec, hda_nid_t nid)
4970{
4971 stac92hd_proc_hook(buffer, codec, nid);
4972 if (nid == codec->afg)
4973 analog_loop_proc_hook(buffer, codec, 0xfa0);
4974}
4975
4976static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4977 struct hda_codec *codec, hda_nid_t nid)
4978{
4979 if (nid == codec->afg)
4980 analog_loop_proc_hook(buffer, codec, 0xfe0);
4981}
4982
4983static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4984 struct hda_codec *codec, hda_nid_t nid)
4985{
4986 if (nid == codec->afg)
4987 analog_loop_proc_hook(buffer, codec, 0xfeb);
4988}
4989#else
4990#define stac92hd_proc_hook NULL
4991#define stac92hd7x_proc_hook NULL
4992#define stac9205_proc_hook NULL
4993#define stac927x_proc_hook NULL
4994#endif
4995
Takashi Iwai2a439522011-07-26 09:52:50 +02004996#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02004997static int stac92xx_resume(struct hda_codec *codec)
4998{
Takashi Iwai2c885872008-11-18 09:36:55 +01004999 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005000 snd_hda_codec_resume_amp(codec);
5001 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01005002 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005003 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02005004 return 0;
5005}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005006
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005007static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5008{
5009 stac92xx_shutup(codec);
5010 return 0;
5011}
5012
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005013#ifdef CONFIG_SND_HDA_POWER_SAVE
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005014static int stac92xx_pre_resume(struct hda_codec *codec)
5015{
5016 struct sigmatel_spec *spec = codec->spec;
5017
5018 /* sync mute LED */
Takashi Iwaif1a73742011-12-04 13:44:06 +01005019 if (spec->vref_mute_led_nid)
5020 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5021 spec->vref_led);
5022 else if (spec->gpio_led)
5023 stac_gpio_set(codec, spec->gpio_mask,
5024 spec->gpio_dir, spec->gpio_data);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005025 return 0;
5026}
5027
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005028static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5029 unsigned int power_state)
5030{
5031 unsigned int afg_power_state = power_state;
5032 struct sigmatel_spec *spec = codec->spec;
5033
5034 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005035 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005036 /* with vref-out pin used for mute led control
5037 * codec AFG is prevented from D3 state
5038 */
5039 afg_power_state = AC_PWRST_D1;
5040 }
5041 /* this delay seems necessary to avoid click noise at power-down */
5042 msleep(100);
5043 }
5044 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5045 afg_power_state);
5046 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5047}
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005048#endif /* CONFIG_SND_HDA_POWER_SAVE */
5049#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005050
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005051/* update mute-LED accoring to the master switch */
5052static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005053{
5054 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005055 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005056
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005057 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005058 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005059
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005060 /* LED state is inverted on these systems */
5061 if (spec->gpio_led_polarity)
5062 muted = !muted;
5063
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005064 /*polarity defines *not* muted state level*/
Takashi Iwaif1a73742011-12-04 13:44:06 +01005065 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005066 if (muted)
5067 spec->gpio_data &= ~spec->gpio_led; /* orange */
5068 else
5069 spec->gpio_data |= spec->gpio_led; /* white */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005070 stac_gpio_set(codec, spec->gpio_mask,
5071 spec->gpio_dir, spec->gpio_data);
5072 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005073 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005074 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5075 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005076 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005077}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05005078
Takashi Iwai2b635362011-05-02 12:33:43 +02005079static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005080 .build_controls = stac92xx_build_controls,
5081 .build_pcms = stac92xx_build_pcms,
5082 .init = stac92xx_init,
5083 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02005084 .unsol_event = stac92xx_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02005085#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005086 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005087 .resume = stac92xx_resume,
5088#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005089 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005090};
5091
5092static int patch_stac9200(struct hda_codec *codec)
5093{
5094 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005095 int err;
Matt2f2f4252005-04-13 14:45:30 +02005096
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005097 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005098 if (spec == NULL)
5099 return -ENOMEM;
5100
Takashi Iwaia252c812009-12-25 22:56:20 +01005101 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005102 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005103 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005104 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005105 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005106 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5107 stac9200_models,
5108 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005109 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005110 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5111 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005112 else
5113 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005114 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005115
5116 spec->multiout.max_channels = 2;
5117 spec->multiout.num_dacs = 1;
5118 spec->multiout.dac_nids = stac9200_dac_nids;
5119 spec->adc_nids = stac9200_adc_nids;
5120 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005121 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005122 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005123 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005124 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005125
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005126 if (spec->board_config == STAC_9200_M4 ||
5127 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005128 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005129 spec->init = stac9200_eapd_init;
5130 else
5131 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005132 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005133
Takashi Iwai117f2572008-03-18 09:53:23 +01005134 if (spec->board_config == STAC_9200_PANASONIC) {
5135 spec->gpio_mask = spec->gpio_dir = 0x09;
5136 spec->gpio_data = 0x00;
5137 }
5138
Mattc7d4b2f2005-06-27 14:59:41 +02005139 err = stac9200_parse_auto_config(codec);
5140 if (err < 0) {
5141 stac92xx_free(codec);
5142 return err;
5143 }
Matt2f2f4252005-04-13 14:45:30 +02005144
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005145 /* CF-74 has no headphone detection, and the driver should *NOT*
5146 * do detection and HP/speaker toggle because the hardware does it.
5147 */
5148 if (spec->board_config == STAC_9200_PANASONIC)
5149 spec->hp_detect = 0;
5150
Matt2f2f4252005-04-13 14:45:30 +02005151 codec->patch_ops = stac92xx_patch_ops;
5152
5153 return 0;
5154}
5155
Tobin Davis8e21c342007-01-08 11:04:17 +01005156static int patch_stac925x(struct hda_codec *codec)
5157{
5158 struct sigmatel_spec *spec;
5159 int err;
5160
5161 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5162 if (spec == NULL)
5163 return -ENOMEM;
5164
Takashi Iwaia252c812009-12-25 22:56:20 +01005165 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005166 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005167 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005168 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005169 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005170
5171 /* Check first for codec ID */
5172 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5173 STAC_925x_MODELS,
5174 stac925x_models,
5175 stac925x_codec_id_cfg_tbl);
5176
5177 /* Now checks for PCI ID, if codec ID is not found */
5178 if (spec->board_config < 0)
5179 spec->board_config = snd_hda_check_board_config(codec,
5180 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005181 stac925x_models,
5182 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005183 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005184 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005185 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5186 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005187 else
5188 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005189 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005190
5191 spec->multiout.max_channels = 2;
5192 spec->multiout.num_dacs = 1;
5193 spec->multiout.dac_nids = stac925x_dac_nids;
5194 spec->adc_nids = stac925x_adc_nids;
5195 spec->mux_nids = stac925x_mux_nids;
5196 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005197 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005198 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005199 switch (codec->vendor_id) {
5200 case 0x83847632: /* STAC9202 */
5201 case 0x83847633: /* STAC9202D */
5202 case 0x83847636: /* STAC9251 */
5203 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005204 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005205 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005206 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5207 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005208 break;
5209 default:
5210 spec->num_dmics = 0;
5211 break;
5212 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005213
5214 spec->init = stac925x_core_init;
5215 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005216 spec->num_caps = 1;
5217 spec->capvols = stac925x_capvols;
5218 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005219
Charles Chin9009b0e2011-11-03 10:27:27 +01005220 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005221 if (!err) {
5222 if (spec->board_config < 0) {
5223 printk(KERN_WARNING "hda_codec: No auto-config is "
5224 "available, default to model=ref\n");
5225 spec->board_config = STAC_925x_REF;
5226 goto again;
5227 }
5228 err = -EINVAL;
5229 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005230 if (err < 0) {
5231 stac92xx_free(codec);
5232 return err;
5233 }
5234
5235 codec->patch_ops = stac92xx_patch_ops;
5236
5237 return 0;
5238}
5239
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005240static int patch_stac92hd73xx(struct hda_codec *codec)
5241{
5242 struct sigmatel_spec *spec;
5243 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5244 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005245 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005246
5247 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5248 if (spec == NULL)
5249 return -ENOMEM;
5250
Takashi Iwaia252c812009-12-25 22:56:20 +01005251 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005252 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005253 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005254 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005255 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5256 spec->pin_nids = stac92hd73xx_pin_nids;
5257 spec->board_config = snd_hda_check_board_config(codec,
5258 STAC_92HD73XX_MODELS,
5259 stac92hd73xx_models,
5260 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005261 /* check codec subsystem id if not found */
5262 if (spec->board_config < 0)
5263 spec->board_config =
5264 snd_hda_check_board_codec_sid_config(codec,
5265 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5266 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005267again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005268 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005269 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5270 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005271 else
5272 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005273 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005274
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005275 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005276 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5277
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005278 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005279 printk(KERN_WARNING "hda_codec: Could not determine "
5280 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005281 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005282 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005283 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005284 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005285 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005286 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005287 break;
5288 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005289 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005290 break;
5291 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005292 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5293 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005294 }
5295 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005296
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005297 spec->aloopback_mask = 0x01;
5298 spec->aloopback_shift = 8;
5299
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005300 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005301 spec->mux_nids = stac92hd73xx_mux_nids;
5302 spec->adc_nids = stac92hd73xx_adc_nids;
5303 spec->dmic_nids = stac92hd73xx_dmic_nids;
5304 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005305 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005306
5307 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5308 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005309 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005310
Takashi Iwai6479c632009-07-28 18:20:25 +02005311 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5312 spec->capvols = stac92hd73xx_capvols;
5313 spec->capsws = stac92hd73xx_capsws;
5314
Matthew Ranostaya7662642008-02-21 07:51:14 +01005315 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005316 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005317 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005318 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005319 case STAC_DELL_M6_AMIC:
5320 case STAC_DELL_M6_DMIC:
5321 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005322 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005323 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005324
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005325 switch (spec->board_config) {
5326 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005327 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005328 spec->num_dmics = 0;
5329 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005330 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005331 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005332 spec->num_dmics = 1;
5333 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005334 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005335 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5336 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005337 spec->num_dmics = 1;
5338 break;
5339 }
5340 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005341 case STAC_ALIENWARE_M17X:
5342 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5343 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5344 spec->eapd_switch = 0;
5345 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005346 default:
5347 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005348 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005349 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005350 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005351 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005352 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005353 /* GPIO0 High = Enable EAPD */
5354 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5355 spec->gpio_data = 0x01;
5356 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005357
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005358 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5359 spec->pwr_nids = stac92hd73xx_pwr_nids;
5360
Charles Chin9009b0e2011-11-03 10:27:27 +01005361 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005362
5363 if (!err) {
5364 if (spec->board_config < 0) {
5365 printk(KERN_WARNING "hda_codec: No auto-config is "
5366 "available, default to model=ref\n");
5367 spec->board_config = STAC_92HD73XX_REF;
5368 goto again;
5369 }
5370 err = -EINVAL;
5371 }
5372
5373 if (err < 0) {
5374 stac92xx_free(codec);
5375 return err;
5376 }
5377
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005378 if (spec->board_config == STAC_92HD73XX_NO_JD)
5379 spec->hp_detect = 0;
5380
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005381 codec->patch_ops = stac92xx_patch_ops;
5382
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005383 codec->proc_widget_hook = stac92hd7x_proc_hook;
5384
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005385 return 0;
5386}
5387
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005388static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005389{
5390 if (codec->vendor_id != 0x111d7605 &&
5391 codec->vendor_id != 0x111d76d1)
5392 return 0;
5393
5394 switch (codec->subsystem_id) {
5395 case 0x103c1618:
5396 case 0x103c1619:
5397 case 0x103c161a:
5398 case 0x103c161b:
5399 case 0x103c161c:
5400 case 0x103c161d:
5401 case 0x103c161e:
5402 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005403
5404 case 0x103c162a:
5405 case 0x103c162b:
5406
5407 case 0x103c1630:
5408 case 0x103c1631:
5409
5410 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005411 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005412 case 0x103c1635:
5413
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005414 case 0x103c3587:
5415 case 0x103c3588:
5416 case 0x103c3589:
5417 case 0x103c358a:
5418
5419 case 0x103c3667:
5420 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005421 case 0x103c3669:
5422
5423 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005424 }
5425 return 0;
5426}
5427
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005428static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5429{
5430 struct sigmatel_spec *spec = codec->spec;
5431 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5432 int i;
5433
5434 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5435 spec->auto_pin_cnt++;
5436
5437 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5438 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5439 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5440 if (nid == stac92hd83xxx_dmic_nids[i]) {
5441 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5442 spec->auto_dmic_cnt++;
5443 }
5444 }
5445 }
5446}
5447
5448static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5449{
5450 struct sigmatel_spec *spec = codec->spec;
5451
5452 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5453 spec->auto_adc_cnt++;
5454}
5455
5456static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5457{
5458 int i, j;
5459 struct sigmatel_spec *spec = codec->spec;
5460
5461 for (i = 0; i < spec->auto_adc_cnt; i++) {
5462 if (get_connection_index(codec,
5463 spec->auto_adc_nids[i], nid) >= 0) {
5464 /* mux and volume for adc_nids[i] */
5465 if (!spec->auto_mux_nids[i]) {
5466 spec->auto_mux_nids[i] = nid;
5467 /* 92hd codecs capture volume is in mux */
5468 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5469 3, 0, HDA_OUTPUT);
5470 }
5471 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5472 if (get_connection_index(codec, nid,
5473 spec->auto_dmic_nids[j]) >= 0) {
5474 /* dmux for adc_nids[i] */
5475 if (!spec->auto_dmux_nids[i])
5476 spec->auto_dmux_nids[i] = nid;
5477 break;
5478 }
5479 }
5480 break;
5481 }
5482 }
5483}
5484
5485static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5486{
5487 hda_nid_t nid, end_nid;
5488 unsigned int wid_caps, wid_type;
5489 struct sigmatel_spec *spec = codec->spec;
5490
5491 end_nid = codec->start_nid + codec->num_nodes;
5492
5493 for (nid = codec->start_nid; nid < end_nid; nid++) {
5494 wid_caps = get_wcaps(codec, nid);
5495 wid_type = get_wcaps_type(wid_caps);
5496
5497 if (wid_type == AC_WID_PIN)
5498 stac92hd8x_add_pin(codec, nid);
5499
5500 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5501 stac92hd8x_add_adc(codec, nid);
5502 }
5503
5504 for (nid = codec->start_nid; nid < end_nid; nid++) {
5505 wid_caps = get_wcaps(codec, nid);
5506 wid_type = get_wcaps_type(wid_caps);
5507
5508 if (wid_type == AC_WID_AUD_SEL)
5509 stac92hd8x_add_mux(codec, nid);
5510 }
5511
5512 spec->pin_nids = spec->auto_pin_nids;
5513 spec->num_pins = spec->auto_pin_cnt;
5514 spec->adc_nids = spec->auto_adc_nids;
5515 spec->num_adcs = spec->auto_adc_cnt;
5516 spec->capvols = spec->auto_capvols;
5517 spec->capsws = spec->auto_capvols;
5518 spec->num_caps = spec->auto_adc_cnt;
5519 spec->mux_nids = spec->auto_mux_nids;
5520 spec->num_muxes = spec->auto_adc_cnt;
5521 spec->dmux_nids = spec->auto_dmux_nids;
5522 spec->num_dmuxes = spec->auto_adc_cnt;
5523 spec->dmic_nids = spec->auto_dmic_nids;
5524 spec->num_dmics = spec->auto_dmic_cnt;
5525}
5526
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005527static int patch_stac92hd83xxx(struct hda_codec *codec)
5528{
5529 struct sigmatel_spec *spec;
5530 int err;
5531
5532 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5533 if (spec == NULL)
5534 return -ENOMEM;
5535
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005536 if (hp_bnb2011_with_dock(codec)) {
5537 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5538 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5539 }
5540
Takashi Iwaia252c812009-12-25 22:56:20 +01005541 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005542 codec->spec = spec;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005543
5544 stac92hd8x_fill_auto_spec(codec);
5545
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01005546 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005547 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005548 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005549 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005550 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005551 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005552 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005553
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005554 spec->board_config = snd_hda_check_board_config(codec,
5555 STAC_92HD83XXX_MODELS,
5556 stac92hd83xxx_models,
5557 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005558 /* check codec subsystem id if not found */
5559 if (spec->board_config < 0)
5560 spec->board_config =
5561 snd_hda_check_board_codec_sid_config(codec,
5562 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
5563 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005564again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005565 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005566 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5567 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005568 else
5569 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005570 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005571
Takashi Iwaib4e81872009-11-18 17:20:24 +01005572 codec->patch_ops = stac92xx_patch_ops;
5573
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005574 switch (spec->board_config) {
5575 case STAC_HP_ZEPHYR:
5576 spec->init = stac92hd83xxx_hp_zephyr_init;
5577 break;
5578 }
5579
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005580 if (find_mute_led_cfg(codec, -1/*no default cfg*/))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005581 snd_printd("mute LED gpio %d polarity %d\n",
5582 spec->gpio_led,
5583 spec->gpio_led_polarity);
5584
Takashi Iwaib4e81872009-11-18 17:20:24 +01005585#ifdef CONFIG_SND_HDA_POWER_SAVE
5586 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005587 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005588 spec->gpio_mask |= spec->gpio_led;
5589 spec->gpio_dir |= spec->gpio_led;
5590 spec->gpio_data |= spec->gpio_led;
5591 } else {
5592 codec->patch_ops.set_power_state =
5593 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005594 }
5595 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwaib4e81872009-11-18 17:20:24 +01005596 }
5597#endif
5598
Charles Chin9009b0e2011-11-03 10:27:27 +01005599 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005600 if (!err) {
5601 if (spec->board_config < 0) {
5602 printk(KERN_WARNING "hda_codec: No auto-config is "
5603 "available, default to model=ref\n");
5604 spec->board_config = STAC_92HD83XXX_REF;
5605 goto again;
5606 }
5607 err = -EINVAL;
5608 }
5609
5610 if (err < 0) {
5611 stac92xx_free(codec);
5612 return err;
5613 }
5614
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005615 codec->proc_widget_hook = stac92hd_proc_hook;
5616
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005617 return 0;
5618}
5619
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005620static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5621 hda_nid_t dig0pin)
5622{
5623 struct sigmatel_spec *spec = codec->spec;
5624 int idx;
5625
5626 for (idx = 0; idx < spec->num_pins; idx++)
5627 if (spec->pin_nids[idx] == dig0pin)
5628 break;
5629 if ((idx + 2) >= spec->num_pins)
5630 return 0;
5631
5632 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005633 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005634 return 2;
5635
5636 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005637 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005638 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005639 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005640 return 1;
5641 else
5642 return 0;
5643}
5644
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005645/* HP dv7 bass switch - GPIO5 */
5646#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5647static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5648 struct snd_ctl_elem_value *ucontrol)
5649{
5650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5651 struct sigmatel_spec *spec = codec->spec;
5652 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5653 return 0;
5654}
5655
5656static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5657 struct snd_ctl_elem_value *ucontrol)
5658{
5659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5660 struct sigmatel_spec *spec = codec->spec;
5661 unsigned int gpio_data;
5662
5663 gpio_data = (spec->gpio_data & ~0x20) |
5664 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5665 if (gpio_data == spec->gpio_data)
5666 return 0;
5667 spec->gpio_data = gpio_data;
5668 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5669 return 1;
5670}
5671
Takashi Iwai2b635362011-05-02 12:33:43 +02005672static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5674 .info = stac_hp_bass_gpio_info,
5675 .get = stac_hp_bass_gpio_get,
5676 .put = stac_hp_bass_gpio_put,
5677};
5678
5679static int stac_add_hp_bass_switch(struct hda_codec *codec)
5680{
5681 struct sigmatel_spec *spec = codec->spec;
5682
5683 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5684 "Bass Speaker Playback Switch", 0))
5685 return -ENOMEM;
5686
5687 spec->gpio_mask |= 0x20;
5688 spec->gpio_dir |= 0x20;
5689 spec->gpio_data |= 0x20;
5690 return 0;
5691}
5692
Matthew Ranostaye035b842007-11-06 11:53:55 +01005693static int patch_stac92hd71bxx(struct hda_codec *codec)
5694{
5695 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02005696 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005697 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005698 int err = 0;
5699
5700 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5701 if (spec == NULL)
5702 return -ENOMEM;
5703
Takashi Iwaia252c812009-12-25 22:56:20 +01005704 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005705 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005706 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005707 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005708 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5709 switch (codec->vendor_id) {
5710 case 0x111d76b6:
5711 case 0x111d76b7:
5712 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5713 break;
5714 case 0x111d7603:
5715 case 0x111d7608:
5716 /* On 92HD75Bx 0x27 isn't a pin nid */
5717 spec->num_pins--;
5718 /* fallthrough */
5719 default:
5720 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5721 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005722 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005723 spec->board_config = snd_hda_check_board_config(codec,
5724 STAC_92HD71BXX_MODELS,
5725 stac92hd71bxx_models,
5726 stac92hd71bxx_cfg_tbl);
5727again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005728 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005729 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5730 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005731 else
5732 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005733 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005734
Takashi Iwaifc64b262009-09-14 15:33:01 +02005735 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005736 /* GPIO0 = EAPD */
5737 spec->gpio_mask = 0x01;
5738 spec->gpio_dir = 0x01;
5739 spec->gpio_data = 0x01;
5740 }
5741
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005742 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5743 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5744
Takashi Iwai6479c632009-07-28 18:20:25 +02005745 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5746 spec->capvols = stac92hd71bxx_capvols;
5747 spec->capsws = stac92hd71bxx_capsws;
5748
Matthew Ranostay541eee82007-12-14 12:08:04 +01005749 switch (codec->vendor_id) {
5750 case 0x111d76b6: /* 4 Port without Analog Mixer */
5751 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005752 unmute_init++;
5753 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005754 case 0x111d76b4: /* 6 Port without Analog Mixer */
5755 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005756 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005757 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005758 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005759 stac92hd71bxx_dmic_nids,
5760 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005761 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005762 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005763 switch (spec->board_config) {
5764 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005765 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai3a938972011-10-28 01:16:55 +02005766 err = stac_add_event(codec, codec->afg,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005767 STAC_VREF_EVENT, 0x02);
5768 if (err < 0)
5769 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005770 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005771 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai3a938972011-10-28 01:16:55 +02005772 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005773 spec->gpio_mask |= 0x02;
5774 break;
5775 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005776 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005777 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005778 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005779
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005780 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005781 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005782 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005783 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5784 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02005785 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005786 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005787 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005788 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005789 break;
5790 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005791 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005792 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005793
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005794 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005795 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005796 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005797 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005798 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005799 stac92hd71bxx_dmic_nids,
5800 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005801 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005802 }
5803
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005804 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5805 snd_hda_sequence_write_cache(codec, unmute_init);
5806
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005807 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005808 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005809 spec->aloopback_shift = 0;
5810
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005811 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005812 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005813 spec->mux_nids = stac92hd71bxx_mux_nids;
5814 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005815 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005816 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005817
5818 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5819 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005820 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005821 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005822
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305823 snd_printdd("Found board config: %d\n", spec->board_config);
5824
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005825 switch (spec->board_config) {
5826 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005827 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005828 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005829 stac92xx_auto_set_pinctl(codec, 0x0e,
5830 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005831 /* fallthru */
5832 case STAC_DELL_M4_2:
5833 spec->num_dmics = 0;
5834 spec->num_smuxes = 0;
5835 spec->num_dmuxes = 0;
5836 break;
5837 case STAC_DELL_M4_1:
5838 case STAC_DELL_M4_3:
5839 spec->num_dmics = 1;
5840 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005841 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005842 break;
James Gardiner514bf542009-05-03 04:00:44 -04005843 case STAC_HP_DV4_1222NR:
5844 spec->num_dmics = 1;
5845 /* I don't know if it needs 1 or 2 smuxes - will wait for
5846 * bug reports to fix if needed
5847 */
5848 spec->num_smuxes = 1;
5849 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005850 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005851 case STAC_HP_DV4:
5852 spec->gpio_led = 0x01;
5853 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005854 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005855 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005856 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005857 /* HP dv6 gives the headphone pin as a line-out. Thus we
5858 * need to set hp_detect flag here to force to enable HP
5859 * detection.
5860 */
5861 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005862 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005863 case STAC_HP_HDX:
5864 spec->num_dmics = 1;
5865 spec->num_dmuxes = 1;
5866 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005867 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005868 break;
5869 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005870
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005871 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005872 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5873 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5874 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5875 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5876 /* It was changed in the BIOS to just satisfy MS DTM.
5877 * Lets turn it back into slaved HP
5878 */
5879 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5880 | (AC_JACK_HP_OUT <<
5881 AC_DEFCFG_DEVICE_SHIFT);
5882 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5883 | AC_DEFCFG_SEQUENCE)))
5884 | 0x1f;
5885 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5886 }
5887 }
5888
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005889 if (find_mute_led_cfg(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005890 snd_printd("mute LED gpio %d polarity %d\n",
5891 spec->gpio_led,
5892 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005893
Takashi Iwai86d190e2009-05-26 15:18:58 +02005894#ifdef CONFIG_SND_HDA_POWER_SAVE
5895 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005896 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005897 spec->gpio_mask |= spec->gpio_led;
5898 spec->gpio_dir |= spec->gpio_led;
5899 spec->gpio_data |= spec->gpio_led;
5900 } else {
5901 codec->patch_ops.set_power_state =
5902 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005903 }
5904 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005905 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005906#endif
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005907
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005908 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005909
Charles Chin9009b0e2011-11-03 10:27:27 +01005910 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005911 if (!err) {
5912 if (spec->board_config < 0) {
5913 printk(KERN_WARNING "hda_codec: No auto-config is "
5914 "available, default to model=ref\n");
5915 spec->board_config = STAC_92HD71BXX_REF;
5916 goto again;
5917 }
5918 err = -EINVAL;
5919 }
5920
5921 if (err < 0) {
5922 stac92xx_free(codec);
5923 return err;
5924 }
5925
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005926 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005927 if (spec->board_config == STAC_HP_DV4 ||
5928 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005929 unsigned int cap;
5930 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5931 cap &= AC_GPIO_IO_COUNT;
5932 if (cap >= 6)
5933 stac_add_hp_bass_switch(codec);
5934 }
5935
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005936 codec->proc_widget_hook = stac92hd7x_proc_hook;
5937
Matthew Ranostaye035b842007-11-06 11:53:55 +01005938 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005939}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005940
Matt2f2f4252005-04-13 14:45:30 +02005941static int patch_stac922x(struct hda_codec *codec)
5942{
5943 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005944 int err;
Matt2f2f4252005-04-13 14:45:30 +02005945
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005946 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005947 if (spec == NULL)
5948 return -ENOMEM;
5949
Takashi Iwaia252c812009-12-25 22:56:20 +01005950 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005951 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005952 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005953 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005954 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005955 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5956 stac922x_models,
5957 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005958 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005959 spec->gpio_mask = spec->gpio_dir = 0x03;
5960 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005961 /* Intel Macs have all same PCI SSID, so we need to check
5962 * codec SSID to distinguish the exact models
5963 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005964 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005965 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005966
5967 case 0x106b0800:
5968 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005969 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005970 case 0x106b0600:
5971 case 0x106b0700:
5972 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005973 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005974 case 0x106b0e00:
5975 case 0x106b0f00:
5976 case 0x106b1600:
5977 case 0x106b1700:
5978 case 0x106b0200:
5979 case 0x106b1e00:
5980 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005981 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005982 case 0x106b1a00:
5983 case 0x00000100:
5984 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005985 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005986 case 0x106b0a00:
5987 case 0x106b2200:
5988 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005989 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005990 default:
5991 spec->board_config = STAC_INTEL_MAC_V3;
5992 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005993 }
5994 }
5995
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005996 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005997 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005998 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5999 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006000 else
6001 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006002 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02006003
Matt2f2f4252005-04-13 14:45:30 +02006004 spec->adc_nids = stac922x_adc_nids;
6005 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006006 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006007 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006008 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006009 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02006010
6011 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006012
6013 spec->num_caps = STAC922X_NUM_CAPS;
6014 spec->capvols = stac922x_capvols;
6015 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02006016
6017 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02006018
Charles Chin9009b0e2011-11-03 10:27:27 +01006019 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006020 if (!err) {
6021 if (spec->board_config < 0) {
6022 printk(KERN_WARNING "hda_codec: No auto-config is "
6023 "available, default to model=ref\n");
6024 spec->board_config = STAC_D945_REF;
6025 goto again;
6026 }
6027 err = -EINVAL;
6028 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006029 if (err < 0) {
6030 stac92xx_free(codec);
6031 return err;
6032 }
6033
6034 codec->patch_ops = stac92xx_patch_ops;
6035
Takashi Iwai807a46362007-05-29 19:01:37 +02006036 /* Fix Mux capture level; max to 2 */
6037 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6038 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6039 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6040 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6041 (0 << AC_AMPCAP_MUTE_SHIFT));
6042
Matt Porter3cc08dc2006-01-23 15:27:49 +01006043 return 0;
6044}
6045
6046static int patch_stac927x(struct hda_codec *codec)
6047{
6048 struct sigmatel_spec *spec;
6049 int err;
6050
6051 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6052 if (spec == NULL)
6053 return -ENOMEM;
6054
Takashi Iwaia252c812009-12-25 22:56:20 +01006055 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006056 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006057 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006058 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006059 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006060 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006061 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6062 stac927x_models,
6063 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006064 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006065 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006066 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6067 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006068 else
6069 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006070 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006071
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006072 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006073 spec->adc_nids = stac927x_adc_nids;
6074 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6075 spec->mux_nids = stac927x_mux_nids;
6076 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006077 spec->smux_nids = stac927x_smux_nids;
6078 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006079 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006080 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006081 spec->multiout.dac_nids = spec->dac_nids;
6082
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006083 if (spec->board_config != STAC_D965_REF) {
6084 /* GPIO0 High = Enable EAPD */
6085 spec->eapd_mask = spec->gpio_mask = 0x01;
6086 spec->gpio_dir = spec->gpio_data = 0x01;
6087 }
6088
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006089 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02006090 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006091 case STAC_D965_5ST:
6092 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006093 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02006094 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006095 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006096 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006097 switch (codec->subsystem_id) {
6098 case 0x10280209:
6099 case 0x1028022e:
6100 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006101 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006102 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006103 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01006104 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01006105 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01006106 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006107 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006108 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01006109 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006110 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006111 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006112 if (codec->subsystem_id != 0x1028022f) {
6113 /* GPIO2 High = Enable EAPD */
6114 spec->eapd_mask = spec->gpio_mask = 0x04;
6115 spec->gpio_dir = spec->gpio_data = 0x04;
6116 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006117 spec->dmic_nids = stac927x_dmic_nids;
6118 spec->num_dmics = STAC927X_NUM_DMICS;
6119
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02006120 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006121 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006122 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006123 break;
Takashi Iwai54930532009-10-11 17:38:29 +02006124 case STAC_927X_VOLKNOB:
6125 spec->num_dmics = 0;
6126 spec->init = stac927x_volknob_core_init;
6127 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006128 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006129 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006130 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006131 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006132 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006133
Takashi Iwai6479c632009-07-28 18:20:25 +02006134 spec->num_caps = STAC927X_NUM_CAPS;
6135 spec->capvols = stac927x_capvols;
6136 spec->capsws = stac927x_capsws;
6137
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006138 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006139 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006140 spec->aloopback_mask = 0x40;
6141 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006142 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006143
Charles Chin9009b0e2011-11-03 10:27:27 +01006144 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006145 if (!err) {
6146 if (spec->board_config < 0) {
6147 printk(KERN_WARNING "hda_codec: No auto-config is "
6148 "available, default to model=ref\n");
6149 spec->board_config = STAC_D965_REF;
6150 goto again;
6151 }
6152 err = -EINVAL;
6153 }
Mattc7d4b2f2005-06-27 14:59:41 +02006154 if (err < 0) {
6155 stac92xx_free(codec);
6156 return err;
6157 }
Matt2f2f4252005-04-13 14:45:30 +02006158
6159 codec->patch_ops = stac92xx_patch_ops;
6160
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006161 codec->proc_widget_hook = stac927x_proc_hook;
6162
Takashi Iwai52987652008-01-16 16:09:47 +01006163 /*
6164 * !!FIXME!!
6165 * The STAC927x seem to require fairly long delays for certain
6166 * command sequences. With too short delays (even if the answer
6167 * is set to RIRB properly), it results in the silence output
6168 * on some hardwares like Dell.
6169 *
6170 * The below flag enables the longer delay (see get_response
6171 * in hda_intel.c).
6172 */
6173 codec->bus->needs_damn_long_delay = 1;
6174
Takashi Iwaie28d8322008-12-17 13:48:29 +01006175 /* no jack detecion for ref-no-jd model */
6176 if (spec->board_config == STAC_D965_REF_NO_JD)
6177 spec->hp_detect = 0;
6178
Matt2f2f4252005-04-13 14:45:30 +02006179 return 0;
6180}
6181
Matt Porterf3302a52006-07-31 12:49:34 +02006182static int patch_stac9205(struct hda_codec *codec)
6183{
6184 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006185 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006186
6187 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6188 if (spec == NULL)
6189 return -ENOMEM;
6190
Takashi Iwaia252c812009-12-25 22:56:20 +01006191 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006192 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006193 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006194 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006195 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006196 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6197 stac9205_models,
6198 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006199 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006200 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006201 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6202 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006203 else
6204 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006205 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006206
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006207 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006208 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006209 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006210 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006211 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006212 spec->smux_nids = stac9205_smux_nids;
6213 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006214 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006215 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006216 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006217 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006218 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006219
6220 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006221 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006222
Takashi Iwai6479c632009-07-28 18:20:25 +02006223 spec->num_caps = STAC9205_NUM_CAPS;
6224 spec->capvols = stac9205_capvols;
6225 spec->capsws = stac9205_capsws;
6226
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006227 spec->aloopback_mask = 0x40;
6228 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006229 /* Turn on/off EAPD per HP plugging */
6230 if (spec->board_config != STAC_9205_EAPD)
6231 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006232 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006233
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006234 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006235 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006236 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006237 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6238 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006239
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006240 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwai3a938972011-10-28 01:16:55 +02006241 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006242 if (err < 0)
6243 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006244 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006245 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
Takashi Iwai3a938972011-10-28 01:16:55 +02006246 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006247
6248 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006249 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006250 spec->gpio_mask = 0x1b;
6251 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006252 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006253 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006254 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006255 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006256 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006257 case STAC_9205_REF:
6258 /* SPDIF-In enabled */
6259 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006260 default:
6261 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006262 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006263 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006264 break;
6265 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006266
Charles Chin9009b0e2011-11-03 10:27:27 +01006267 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006268 if (!err) {
6269 if (spec->board_config < 0) {
6270 printk(KERN_WARNING "hda_codec: No auto-config is "
6271 "available, default to model=ref\n");
6272 spec->board_config = STAC_9205_REF;
6273 goto again;
6274 }
6275 err = -EINVAL;
6276 }
Matt Porterf3302a52006-07-31 12:49:34 +02006277 if (err < 0) {
6278 stac92xx_free(codec);
6279 return err;
6280 }
6281
6282 codec->patch_ops = stac92xx_patch_ops;
6283
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006284 codec->proc_widget_hook = stac9205_proc_hook;
6285
Matt Porterf3302a52006-07-31 12:49:34 +02006286 return 0;
6287}
6288
Matt2f2f4252005-04-13 14:45:30 +02006289/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006290 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006291 */
6292
Takashi Iwai2b635362011-05-02 12:33:43 +02006293static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6296 {}
6297};
6298
Takashi Iwai2b635362011-05-02 12:33:43 +02006299static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006300 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6301 0x11, 0x13, 0x14,
6302};
6303
Takashi Iwai2b635362011-05-02 12:33:43 +02006304static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006305 0x8 /*,0x6*/
6306};
6307
Takashi Iwai2b635362011-05-02 12:33:43 +02006308static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006309 0x15
6310};
6311
Takashi Iwai2b635362011-05-02 12:33:43 +02006312static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006313 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6314};
6315#define stac9872_capsws stac9872_capvols
6316
Takashi Iwai2b635362011-05-02 12:33:43 +02006317static const unsigned int stac9872_vaio_pin_configs[9] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006318 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6319 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6320 0x90a7013e
6321};
6322
Takashi Iwaiea734962011-01-17 11:29:34 +01006323static const char * const stac9872_models[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006324 [STAC_9872_AUTO] = "auto",
6325 [STAC_9872_VAIO] = "vaio",
6326};
6327
Takashi Iwai2b635362011-05-02 12:33:43 +02006328static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006329 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6330};
6331
Takashi Iwai2b635362011-05-02 12:33:43 +02006332static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006333 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6334 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006335 {} /* terminator */
6336};
6337
Guillaume Munch6d859062006-08-22 17:15:47 +02006338static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006339{
6340 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006341 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006342
Takashi Iwaidb064e52006-03-16 16:04:58 +01006343 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6344 if (spec == NULL)
6345 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006346 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006347 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006348 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006349 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6350 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006351
6352 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6353 stac9872_models,
6354 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006355 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006356 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6357 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006358 else
6359 stac92xx_set_config_regs(codec,
6360 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006361
Takashi Iwai1e137f92009-01-21 07:41:22 +01006362 spec->multiout.dac_nids = spec->dac_nids;
6363 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6364 spec->adc_nids = stac9872_adc_nids;
6365 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6366 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006367 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006368 spec->num_caps = 1;
6369 spec->capvols = stac9872_capvols;
6370 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006371
Charles Chin9009b0e2011-11-03 10:27:27 +01006372 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01006373 if (err < 0) {
6374 stac92xx_free(codec);
6375 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006376 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006377 spec->input_mux = &spec->private_imux;
6378 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006379 return 0;
6380}
6381
6382
6383/*
Matt2f2f4252005-04-13 14:45:30 +02006384 * patch entries
6385 */
Takashi Iwai2b635362011-05-02 12:33:43 +02006386static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006387 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6388 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6389 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6390 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6391 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6392 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6393 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006394 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6395 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6396 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6397 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6398 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6399 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006400 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6401 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6402 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6403 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6404 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6405 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6406 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6407 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6408 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6409 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006410 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6411 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6412 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6413 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6414 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6415 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006416 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6417 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006418 /* The following does not take into account .id=0x83847661 when subsys =
6419 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6420 * currently not fully supported.
6421 */
6422 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6423 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6424 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006425 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006426 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6427 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6428 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6429 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6430 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6431 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6432 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6433 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006434 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006435 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006436 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006437 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006438 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02006439 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6440 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006441 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6442 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6443 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6444 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006445 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006446 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6447 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006448 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006449 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6450 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6451 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6452 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6453 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6454 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6455 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6456 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02006457 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6458 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6459 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6460 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6461 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6462 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6463 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6464 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6465 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6466 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6467 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6468 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6469 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6470 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6471 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02006472 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006473 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06006474 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6475 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006476 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01006477 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6478 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6479 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6480 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6481 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6482 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6483 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6484 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6485 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6486 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6487 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6488 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02006489 {} /* terminator */
6490};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006491
6492MODULE_ALIAS("snd-hda-codec-id:8384*");
6493MODULE_ALIAS("snd-hda-codec-id:111d*");
6494
6495MODULE_LICENSE("GPL");
6496MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6497
6498static struct hda_codec_preset_list sigmatel_list = {
6499 .preset = snd_hda_preset_sigmatel,
6500 .owner = THIS_MODULE,
6501};
6502
6503static int __init patch_sigmatel_init(void)
6504{
6505 return snd_hda_add_codec_preset(&sigmatel_list);
6506}
6507
6508static void __exit patch_sigmatel_exit(void)
6509{
6510 snd_hda_delete_codec_preset(&sigmatel_list);
6511}
6512
6513module_init(patch_sigmatel_init)
6514module_exit(patch_sigmatel_exit)