blob: 33a9946b492cb333184b1a9405c11f553fc55566 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +010031#include <linux/dmi.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040032#include <linux/module.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020034#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040035#include <sound/jack.h>
Clemens Ladischa74ccea2010-10-22 15:52:34 +020036#include <sound/tlv.h>
Matt2f2f4252005-04-13 14:45:30 +020037#include "hda_codec.h"
38#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020039#include "hda_beep.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020040#include "hda_jack.h"
Matt2f2f4252005-04-13 14:45:30 +020041
Takashi Iwaic6e4c662008-11-25 11:58:19 +010042enum {
43 STAC_VREF_EVENT = 1,
44 STAC_INSERT_EVENT,
45 STAC_PWR_EVENT,
46 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020047 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020048 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010049};
Matt4e550962005-07-04 17:51:39 +020050
Takashi Iwaif5fcc132006-11-24 17:07:44 +010051enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010052 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010053 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010054 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020055 STAC_9200_DELL_D21,
56 STAC_9200_DELL_D22,
57 STAC_9200_DELL_D23,
58 STAC_9200_DELL_M21,
59 STAC_9200_DELL_M22,
60 STAC_9200_DELL_M23,
61 STAC_9200_DELL_M24,
62 STAC_9200_DELL_M25,
63 STAC_9200_DELL_M26,
64 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020065 STAC_9200_M4,
66 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010067 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_9200_MODELS
69};
70
71enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010072 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010073 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020074 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020075 STAC_9205_DELL_M43,
76 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010077 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010078 STAC_9205_MODELS
79};
80
81enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010082 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010083 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010084 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080085 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010086 STAC_DELL_M6_AMIC,
87 STAC_DELL_M6_DMIC,
88 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050089 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020090 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010091 STAC_92HD73XX_MODELS
92};
93
94enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010095 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020096 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050097 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050098 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010099 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -0500100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -0600101 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600102 STAC_HP_ZEPHYR,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200103 STAC_92HD83XXX_MODELS
104};
105
106enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100107 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100108 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100109 STAC_DELL_M4_1,
110 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500111 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400112 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200113 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100114 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100115 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400116 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100117 STAC_92HD71BXX_MODELS
118};
119
120enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100121 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100122 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200123 STAC_M1,
124 STAC_M1_2,
125 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100126 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200127 STAC_M3,
128 STAC_M5,
129 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100130 STAC_925x_MODELS
131};
132
133enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100134 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100135 STAC_D945_REF,
136 STAC_D945GTP3,
137 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200138 STAC_INTEL_MAC_V1,
139 STAC_INTEL_MAC_V2,
140 STAC_INTEL_MAC_V3,
141 STAC_INTEL_MAC_V4,
142 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800143 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
144 * is given, one of the above models will be
145 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200146 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100147 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100148 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100149 STAC_MACBOOK_PRO_V1,
150 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200151 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200152 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300153 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200154 STAC_922X_DELL_D81,
155 STAC_922X_DELL_D82,
156 STAC_922X_DELL_M81,
157 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100158 STAC_922X_MODELS
159};
160
161enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100162 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100163 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100164 STAC_D965_REF,
165 STAC_D965_3ST,
166 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200167 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200168 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100169 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200170 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100171 STAC_927X_MODELS
172};
Matt Porter403d1942005-11-29 15:00:51 +0100173
Takashi Iwai307282c2009-03-12 18:17:58 +0100174enum {
175 STAC_9872_AUTO,
176 STAC_9872_VAIO,
177 STAC_9872_MODELS
178};
179
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200180struct sigmatel_mic_route {
181 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200182 signed char mux_idx;
183 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200184};
185
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600186#define MAX_PINS_NUM 16
187#define MAX_ADCS_NUM 4
188#define MAX_DMICS_NUM 4
189
Matt2f2f4252005-04-13 14:45:30 +0200190struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100191 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200192 unsigned int num_mixers;
193
Matt Porter403d1942005-11-29 15:00:51 +0100194 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500195 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200196 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100197 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100198 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400199 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100200 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200201 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100202 unsigned int linear_tone_beep:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200203
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100204 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200205 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100206 unsigned int gpio_mask;
207 unsigned int gpio_dir;
208 unsigned int gpio_data;
209 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200210 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100211 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100212 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500213 unsigned int vref_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100214
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200215 /* stream */
216 unsigned int stream_delay;
217
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100218 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200219 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100220 unsigned char aloopback_mask;
221 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200222
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100223 /* power management */
224 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200225 const hda_nid_t *pwr_nids;
226 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227
Matt2f2f4252005-04-13 14:45:30 +0200228 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100229 struct hda_input_mux *mono_mux;
230 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200231 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100232 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100233 hda_nid_t hp_dacs[5];
234 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200235
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100236 int volume_offset;
237
Matt2f2f4252005-04-13 14:45:30 +0200238 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200239 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200240 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200241 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200242 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200243 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200244 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200245 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100246 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200247 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200248 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200249 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200250
Takashi Iwai2b635362011-05-02 12:33:43 +0200251 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
252 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200253 unsigned int num_caps; /* number of capture volume/switch elements */
254
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200255 struct sigmatel_mic_route ext_mic;
256 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200257 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200258
Takashi Iwaiea734962011-01-17 11:29:34 +0100259 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200260
Mattdabbed62005-06-14 10:19:34 +0200261 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100262 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200263 hda_nid_t anabeep_nid;
264 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200265
Matt2f2f4252005-04-13 14:45:30 +0200266 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200267 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200268 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200269
270 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200271 const struct hda_verb *init;
272 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200273
274 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200275 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100276 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200277 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100278 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200279 struct hda_input_mux *sinput_mux;
280 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400281 unsigned int cur_amux;
282 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200283 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200284
Matt Porter403d1942005-11-29 15:00:51 +0100285 /* i/o switches */
286 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200287 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100288 hda_nid_t line_switch; /* shared line-in for input and output */
289 hda_nid_t mic_switch; /* shared mic-in for input and output */
290 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200291 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200292
Mattc7d4b2f2005-06-27 14:59:41 +0200293 struct hda_pcm pcm_rec[2]; /* PCM information */
294
295 /* dynamic controls and input_mux */
296 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200297 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200298 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200299 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200300 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100301 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600302
303 /* auto spec */
304 unsigned auto_pin_cnt;
305 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
306 unsigned auto_adc_cnt;
307 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
308 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
309 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
310 unsigned long auto_capvols[MAX_ADCS_NUM];
311 unsigned auto_dmic_cnt;
312 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100313
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100314 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200315};
316
Takashi Iwai2b635362011-05-02 12:33:43 +0200317static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200318 0x03,
319};
320
Takashi Iwai2b635362011-05-02 12:33:43 +0200321static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200322 0x0c,
323};
324
Takashi Iwai2b635362011-05-02 12:33:43 +0200325static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200326 0x02,
327};
328
Takashi Iwai2b635362011-05-02 12:33:43 +0200329static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100330 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
331 0x0f, 0x10, 0x11
332};
333
Takashi Iwai2b635362011-05-02 12:33:43 +0200334static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400335 0x26, 0,
336};
337
Takashi Iwai2b635362011-05-02 12:33:43 +0200338static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100339 0x1a, 0x1b
340};
341
342#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200343static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100344 0x13, 0x14, 0
345};
346
347#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100348
Takashi Iwai2b635362011-05-02 12:33:43 +0200349static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200350 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100351};
352
Takashi Iwai2b635362011-05-02 12:33:43 +0200353static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100354 0x20, 0x21,
355};
356
Takashi Iwai2b635362011-05-02 12:33:43 +0200357static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200358 0x22, 0x23,
359};
360
Takashi Iwai6479c632009-07-28 18:20:25 +0200361#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200362static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200363 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
364 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
365};
366#define stac92hd73xx_capsws stac92hd73xx_capvols
367
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200368#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200369
Charles Chinafef2cf2011-11-11 08:05:28 +0100370static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
371 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
372 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200373};
374
Takashi Iwai2b635362011-05-02 12:33:43 +0200375static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400376 0x1e, 0,
377};
378
Takashi Iwai2b635362011-05-02 12:33:43 +0200379static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600380 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200381};
382
Takashi Iwai2b635362011-05-02 12:33:43 +0200383static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100384 0x0a, 0x0d, 0x0f
385};
386
Takashi Iwai2b635362011-05-02 12:33:43 +0200387static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100388 0x12, 0x13,
389};
390
Takashi Iwai2b635362011-05-02 12:33:43 +0200391static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100392 0x1a, 0x1b
393};
394
Takashi Iwai2b635362011-05-02 12:33:43 +0200395static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400396 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100397};
398
Takashi Iwai2b635362011-05-02 12:33:43 +0200399static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200400 0x24, 0x25,
401};
402
Matthew Ranostaye035b842007-11-06 11:53:55 +0100403#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200404static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100405 0x18, 0x19, 0
406};
407
Takashi Iwai2b635362011-05-02 12:33:43 +0200408static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
409 0x18, 0
410};
411
412static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400413 0x22, 0
414};
415
Takashi Iwai6479c632009-07-28 18:20:25 +0200416#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200417static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200418 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
419 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
420};
421#define stac92hd71bxx_capsws stac92hd71bxx_capvols
422
Takashi Iwai2b635362011-05-02 12:33:43 +0200423static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100424 0x03,
425};
426
Takashi Iwai2b635362011-05-02 12:33:43 +0200427static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100428 0x0f,
429};
430
Takashi Iwai2b635362011-05-02 12:33:43 +0200431static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100432 0x02,
433};
434
Takashi Iwaif6e98522007-10-16 14:27:04 +0200435#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200436static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200437 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200438};
439
Takashi Iwai2b635362011-05-02 12:33:43 +0200440static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100441 0x14,
442};
443
Takashi Iwai2b635362011-05-02 12:33:43 +0200444static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200445 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
446};
Takashi Iwai2b635362011-05-02 12:33:43 +0200447static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
449};
450
Takashi Iwai2b635362011-05-02 12:33:43 +0200451static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200452 0x06, 0x07,
453};
454
Takashi Iwai2b635362011-05-02 12:33:43 +0200455static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200456 0x12, 0x13,
457};
458
Takashi Iwai6479c632009-07-28 18:20:25 +0200459#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200460static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200461 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
462 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
463};
464#define stac922x_capsws stac922x_capvols
465
Takashi Iwai2b635362011-05-02 12:33:43 +0200466static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500467 0x1f, 0,
468};
469
Takashi Iwai2b635362011-05-02 12:33:43 +0200470static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100471 0x07, 0x08, 0x09
472};
473
Takashi Iwai2b635362011-05-02 12:33:43 +0200474static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100475 0x15, 0x16, 0x17
476};
477
Takashi Iwai2b635362011-05-02 12:33:43 +0200478static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200479 0x21,
480};
481
Takashi Iwai2b635362011-05-02 12:33:43 +0200482static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100483 0x02, 0x03, 0x04, 0x05, 0x06, 0
484};
485
Takashi Iwai2b635362011-05-02 12:33:43 +0200486static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100487 0x1b,
488};
489
Matthew Ranostay7f168592007-10-18 17:38:17 +0200490#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200491static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200492 0x13, 0x14, 0
493};
494
Takashi Iwai6479c632009-07-28 18:20:25 +0200495#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200496static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200497 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
500};
Takashi Iwai2b635362011-05-02 12:33:43 +0200501static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200502 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
505};
506
Takashi Iwaiea734962011-01-17 11:29:34 +0100507static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400508 "Digital Playback", "ADAT", "Analog Mux 1",
509 "Analog Mux 2", "Analog Mux 3"
510};
511
Takashi Iwai2b635362011-05-02 12:33:43 +0200512static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200513 0x12, 0x13
514};
515
Takashi Iwai2b635362011-05-02 12:33:43 +0200516static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200517 0x19, 0x1a
518};
519
Takashi Iwai2b635362011-05-02 12:33:43 +0200520static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100521 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522};
523
Takashi Iwai2b635362011-05-02 12:33:43 +0200524static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200525 0x21,
526};
527
Takashi Iwaif6e98522007-10-16 14:27:04 +0200528#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200529static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200530 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200531};
532
Takashi Iwai6479c632009-07-28 18:20:25 +0200533#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200534static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200535 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
536 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
537};
Takashi Iwai2b635362011-05-02 12:33:43 +0200538static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200539 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
541};
542
Takashi Iwai2b635362011-05-02 12:33:43 +0200543static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200544 0x08, 0x09, 0x0d, 0x0e,
545 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200546};
547
Takashi Iwai2b635362011-05-02 12:33:43 +0200548static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100549 0x07, 0x08, 0x0a, 0x0b,
550 0x0c, 0x0d, 0x10, 0x11,
551};
552
Takashi Iwai2b635362011-05-02 12:33:43 +0200553static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200554 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
555 0x0f, 0x10, 0x11, 0x15, 0x1b,
556};
557
Takashi Iwai2b635362011-05-02 12:33:43 +0200558static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100562};
563
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500564#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200565static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500566 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
567 0x00, 0x14, 0x18, 0x19, 0x1e,
568 0x1f, 0x20, 0x27
569};
Takashi Iwai2b635362011-05-02 12:33:43 +0200570static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100571 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
572 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500573 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100574};
575
Takashi Iwai2b635362011-05-02 12:33:43 +0200576static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x10, 0x11, 0x12, 0x13,
579 0x14, 0x21, 0x22, 0x23,
580};
581
Takashi Iwai2b635362011-05-02 12:33:43 +0200582static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x14, 0x16, 0x17, 0x18,
585 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200586};
587
Matt Porter8b657272006-10-26 17:12:59 +0200588static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
590{
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct sigmatel_spec *spec = codec->spec;
593 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
594}
595
596static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100601 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200602
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100603 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200604 return 0;
605}
606
607static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol)
609{
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100612 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200613
614 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100615 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200616}
617
Matthew Ranostayd9737752008-09-07 12:03:41 +0200618static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_info *uinfo)
620{
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 struct sigmatel_spec *spec = codec->spec;
623 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
624}
625
626static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
632
633 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
634 return 0;
635}
636
637static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *ucontrol)
639{
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400642 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200643 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400644 int err, val;
645 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200646
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400647 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200648 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400649 if (err < 0)
650 return err;
651
652 if (spec->spdif_mute) {
653 if (smux_idx == 0)
654 nid = spec->multiout.dig_out_nid;
655 else
656 nid = codec->slave_dig_outs[smux_idx - 1];
657 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100658 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400659 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100660 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400661 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100662 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
663 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400664 }
665 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200666}
667
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500668static int stac_vrefout_set(struct hda_codec *codec,
669 hda_nid_t nid, unsigned int new_vref)
670{
671 int error, pinctl;
672
673 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
674 pinctl = snd_hda_codec_read(codec, nid, 0,
675 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
676
677 if (pinctl < 0)
678 return pinctl;
679
680 pinctl &= 0xff;
681 pinctl &= ~AC_PINCTL_VREFEN;
682 pinctl |= (new_vref & AC_PINCTL_VREFEN);
683
684 error = snd_hda_codec_write_cache(codec, nid, 0,
685 AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
686 if (error < 0)
687 return error;
688
689 return 1;
690}
691
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200692static unsigned int stac92xx_vref_set(struct hda_codec *codec,
693 hda_nid_t nid, unsigned int new_vref)
694{
Takashi Iwaib8621512009-06-22 08:00:10 +0200695 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200696 unsigned int pincfg;
697 pincfg = snd_hda_codec_read(codec, nid, 0,
698 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
699
700 pincfg &= 0xff;
701 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
702 pincfg |= new_vref;
703
704 if (new_vref == AC_PINCTL_VREF_HIZ)
705 pincfg |= AC_PINCTL_OUT_EN;
706 else
707 pincfg |= AC_PINCTL_IN_EN;
708
709 error = snd_hda_codec_write_cache(codec, nid, 0,
710 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
711 if (error < 0)
712 return error;
713 else
714 return 1;
715}
716
717static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
718{
719 unsigned int vref;
720 vref = snd_hda_codec_read(codec, nid, 0,
721 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
722 vref &= AC_PINCTL_VREFEN;
723 return vref;
724}
725
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100726static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200727{
728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
729 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200730 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200731}
732
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100733static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200734{
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 struct sigmatel_spec *spec = codec->spec;
737 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
738
739 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
740 return 0;
741}
742
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100743static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200744{
745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
746 struct sigmatel_spec *spec = codec->spec;
747 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200748 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600749 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200750
Takashi Iwai5207e102009-07-30 13:09:08 +0200751 idx = ucontrol->value.enumerated.item[0];
752 if (idx >= imux->num_items)
753 idx = imux->num_items - 1;
754 prev_idx = spec->cur_mux[adc_idx];
755 if (prev_idx == idx)
756 return 0;
757 if (idx < spec->num_analog_muxes) {
758 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
759 AC_VERB_SET_CONNECT_SEL,
760 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600761 if (prev_idx >= spec->num_analog_muxes &&
762 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200763 imux = spec->dinput_mux;
764 /* 0 = analog */
765 snd_hda_codec_write_cache(codec,
766 spec->dmux_nids[adc_idx], 0,
767 AC_VERB_SET_CONNECT_SEL,
768 imux->items[0].index);
769 }
770 } else {
771 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600772 /* first dimux item is hardcoded to select analog imux,
773 * so lets skip it
774 */
775 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200776 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
777 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600778 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200779 }
780 spec->cur_mux[adc_idx] = idx;
781 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200782}
783
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100784static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
785 struct snd_ctl_elem_info *uinfo)
786{
787 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
788 struct sigmatel_spec *spec = codec->spec;
789 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
790}
791
792static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
793 struct snd_ctl_elem_value *ucontrol)
794{
795 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
796 struct sigmatel_spec *spec = codec->spec;
797
798 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
799 return 0;
800}
801
802static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
803 struct snd_ctl_elem_value *ucontrol)
804{
805 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
806 struct sigmatel_spec *spec = codec->spec;
807
808 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
809 spec->mono_nid, &spec->cur_mmux);
810}
811
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200812#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
813
814static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
815 struct snd_ctl_elem_value *ucontrol)
816{
817 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100818 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200819 struct sigmatel_spec *spec = codec->spec;
820
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100821 ucontrol->value.integer.value[0] = !!(spec->aloopback &
822 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200823 return 0;
824}
825
826static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
827 struct snd_ctl_elem_value *ucontrol)
828{
829 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
830 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100831 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200832 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200834
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100835 idx_val = spec->aloopback_mask << idx;
836 if (ucontrol->value.integer.value[0])
837 val = spec->aloopback | idx_val;
838 else
839 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100840 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200841 return 0;
842
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100843 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200844
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100845 /* Only return the bits defined by the shift value of the
846 * first two bytes of the mask
847 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200848 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100849 kcontrol->private_value & 0xFFFF, 0x0);
850 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200851
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100852 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100854 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200855 } else {
856 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100857 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200858 }
859
860 snd_hda_codec_write_cache(codec, codec->afg, 0,
861 kcontrol->private_value >> 16, dac_mode);
862
863 return 1;
864}
865
Takashi Iwai2b635362011-05-02 12:33:43 +0200866static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200867 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200868 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200869 {}
870};
871
Takashi Iwai2b635362011-05-02 12:33:43 +0200872static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200873 /* set dac0mux for dac converter */
874 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
875 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
876 {}
877};
878
Takashi Iwai2b635362011-05-02 12:33:43 +0200879static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100880 /* set master volume to max value without distortion
881 * and direct control */
882 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100883 {}
884};
885
Takashi Iwai2b635362011-05-02 12:33:43 +0200886static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100887 /* set master volume and direct control */
888 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100889 {}
890};
891
Takashi Iwai2b635362011-05-02 12:33:43 +0200892static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200893 /* power state controls amps */
894 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200895 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200896};
897
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600898static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
899 { 0x22, 0x785, 0x43 },
900 { 0x22, 0x782, 0xe0 },
901 { 0x22, 0x795, 0x00 },
902 {}
903};
904
Takashi Iwai2b635362011-05-02 12:33:43 +0200905static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100906 /* set master volume and direct control */
907 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200908 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100909};
910
Takashi Iwai2b635362011-05-02 12:33:43 +0200911static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500912 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
913 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100914 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
915 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100916 {}
917};
918
Takashi Iwai2b635362011-05-02 12:33:43 +0200919static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100920 /* set dac0mux for dac converter */
921 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100922 /* mute the master volume */
923 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100924 {}
925};
926
Takashi Iwai2b635362011-05-02 12:33:43 +0200927static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200928 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200929 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200930 {}
931};
932
Takashi Iwai2b635362011-05-02 12:33:43 +0200933static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200934 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200935 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200936 /* unmute node 0x1b */
937 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
938 /* select node 0x03 as DAC */
939 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
940 {}
941};
942
Takashi Iwai2b635362011-05-02 12:33:43 +0200943static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200944 /* don't set delta bit */
945 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
946 /* unmute node 0x1b */
947 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
948 /* select node 0x03 as DAC */
949 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
950 {}
951};
952
Takashi Iwai2b635362011-05-02 12:33:43 +0200953static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100954 /* set master volume and direct control */
955 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200956 /* enable analog pc beep path */
957 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100958 {}
959};
960
Takashi Iwai2b635362011-05-02 12:33:43 +0200961static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200962 /* don't set delta bit */
963 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
964 /* enable analog pc beep path */
965 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
966 {}
967};
968
Takashi Iwai2b635362011-05-02 12:33:43 +0200969static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200970 /* set master volume and direct control */
971 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200972 /* enable analog pc beep path */
973 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200974 {}
975};
976
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100977#define STAC_MONO_MUX \
978 { \
979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
980 .name = "Mono Mux", \
981 .count = 1, \
982 .info = stac92xx_mono_mux_enum_info, \
983 .get = stac92xx_mono_mux_enum_get, \
984 .put = stac92xx_mono_mux_enum_put, \
985 }
986
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100987#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200988 { \
989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
990 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100991 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200992 .info = stac92xx_aloopback_info, \
993 .get = stac92xx_aloopback_get, \
994 .put = stac92xx_aloopback_put, \
995 .private_value = verb_read | (verb_write << 16), \
996 }
997
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200998#define DC_BIAS(xname, idx, nid) \
999 { \
1000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1001 .name = xname, \
1002 .index = idx, \
1003 .info = stac92xx_dc_bias_info, \
1004 .get = stac92xx_dc_bias_get, \
1005 .put = stac92xx_dc_bias_put, \
1006 .private_value = nid, \
1007 }
1008
Takashi Iwai2b635362011-05-02 12:33:43 +02001009static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001010 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001012 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001014 { } /* end */
1015};
1016
Takashi Iwai2b635362011-05-02 12:33:43 +02001017static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001018 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1019 {}
1020};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001021
Takashi Iwai2b635362011-05-02 12:33:43 +02001022static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001023 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1024 {}
1025};
1026
Takashi Iwai2b635362011-05-02 12:33:43 +02001027static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1029 {}
1030};
1031
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001032
Takashi Iwai2b635362011-05-02 12:33:43 +02001033static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001034 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1035};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001036
Takashi Iwai2b635362011-05-02 12:33:43 +02001037static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001038 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1039 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001040 { } /* end */
1041};
1042
Takashi Iwai2b635362011-05-02 12:33:43 +02001043static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001044 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1045 {}
1046};
1047
Takashi Iwai2b635362011-05-02 12:33:43 +02001048static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001049 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1050 {}
1051};
1052
Takashi Iwai1697055e2007-12-18 18:05:52 +01001053static struct snd_kcontrol_new stac_dmux_mixer = {
1054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1055 .name = "Digital Input Source",
1056 /* count set later */
1057 .info = stac92xx_dmux_enum_info,
1058 .get = stac92xx_dmux_enum_get,
1059 .put = stac92xx_dmux_enum_put,
1060};
1061
Matthew Ranostayd9737752008-09-07 12:03:41 +02001062static struct snd_kcontrol_new stac_smux_mixer = {
1063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001064 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001065 /* count set later */
1066 .info = stac92xx_smux_enum_info,
1067 .get = stac92xx_smux_enum_get,
1068 .put = stac92xx_smux_enum_put,
1069};
1070
Takashi Iwai9322ca52012-02-03 14:28:01 +01001071static const char * const slave_pfxs[] = {
1072 "Front", "Surround", "Center", "LFE", "Side",
1073 "Headphone", "Speaker", "IEC958",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001074 NULL
1075};
1076
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001077static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1078
1079static void stac92xx_vmaster_hook(void *private_data, int val)
1080{
1081 stac92xx_update_led_status(private_data, val);
1082}
1083
Takashi Iwai603c4012008-07-30 15:01:44 +02001084static void stac92xx_free_kctls(struct hda_codec *codec);
1085
Matt2f2f4252005-04-13 14:45:30 +02001086static int stac92xx_build_controls(struct hda_codec *codec)
1087{
1088 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001089 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001090 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001091 int i;
Matt2f2f4252005-04-13 14:45:30 +02001092
Takashi Iwai6479c632009-07-28 18:20:25 +02001093 if (spec->mixer) {
1094 err = snd_hda_add_new_ctls(codec, spec->mixer);
1095 if (err < 0)
1096 return err;
1097 }
Mattc7d4b2f2005-06-27 14:59:41 +02001098
1099 for (i = 0; i < spec->num_mixers; i++) {
1100 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1101 if (err < 0)
1102 return err;
1103 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001104 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1105 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001106 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001107 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001108 snd_ctl_new1(&stac_dmux_mixer, codec));
1109 if (err < 0)
1110 return err;
1111 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001112 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001113 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1114 struct hda_input_mux *smux = &spec->private_smux;
1115 /* check for mute support on SPDIF out */
1116 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001117 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001118 spec->spdif_mute = 1;
1119 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001120 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001121 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001122 snd_ctl_new1(&stac_smux_mixer, codec));
1123 if (err < 0)
1124 return err;
1125 }
Mattc7d4b2f2005-06-27 14:59:41 +02001126
Mattdabbed62005-06-14 10:19:34 +02001127 if (spec->multiout.dig_out_nid) {
Stephen Warren74b654c2011-06-01 11:14:18 -06001128 err = snd_hda_create_spdif_out_ctls(codec,
1129 spec->multiout.dig_out_nid,
1130 spec->multiout.dig_out_nid);
Mattdabbed62005-06-14 10:19:34 +02001131 if (err < 0)
1132 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001133 err = snd_hda_create_spdif_share_sw(codec,
1134 &spec->multiout);
1135 if (err < 0)
1136 return err;
1137 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001138 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001139 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001140 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1141 if (err < 0)
1142 return err;
1143 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001144
1145 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001146 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1147 HDA_OUTPUT, vmaster_tlv);
1148 /* correct volume offset */
1149 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1150 /* minimum value is actually mute */
1151 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1152 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1153 vmaster_tlv, slave_pfxs,
1154 "Playback Volume");
1155 if (err < 0)
1156 return err;
1157
1158 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1159 NULL, slave_pfxs,
1160 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001161 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001162 if (err < 0)
1163 return err;
1164
1165 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001166 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001167 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001168 if (err < 0)
1169 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001170 }
1171
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001172 if (spec->aloopback_ctl &&
1173 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1174 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1175 if (err < 0)
1176 return err;
1177 }
1178
Takashi Iwai603c4012008-07-30 15:01:44 +02001179 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001180
Takashi Iwai01a61e12011-10-28 00:03:22 +02001181 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1182 if (err < 0)
1183 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001184
Mattdabbed62005-06-14 10:19:34 +02001185 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001186}
1187
Takashi Iwai2b635362011-05-02 12:33:43 +02001188static const unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001189 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001190 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1191};
1192
Takashi Iwai2b635362011-05-02 12:33:43 +02001193static const unsigned int gateway9200_m4_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001194 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1195 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1196};
Takashi Iwai2b635362011-05-02 12:33:43 +02001197static const unsigned int gateway9200_m4_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001198 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1199 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1200};
1201
1202/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001203 STAC 9200 pin configs for
1204 102801A8
1205 102801DE
1206 102801E8
1207*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001208static const unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001209 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1210 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001211};
1212
1213/*
1214 STAC 9200 pin configs for
1215 102801C0
1216 102801C1
1217*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001218static const unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001219 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1220 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001221};
1222
1223/*
1224 STAC 9200 pin configs for
1225 102801C4 (Dell Dimension E310)
1226 102801C5
1227 102801C7
1228 102801D9
1229 102801DA
1230 102801E3
1231*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001232static const unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001233 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1234 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001235};
1236
1237
1238/*
1239 STAC 9200-32 pin configs for
1240 102801B5 (Dell Inspiron 630m)
1241 102801D8 (Dell Inspiron 640m)
1242*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001243static const unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001244 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1245 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001246};
1247
1248/*
1249 STAC 9200-32 pin configs for
1250 102801C2 (Dell Latitude D620)
1251 102801C8
1252 102801CC (Dell Latitude D820)
1253 102801D4
1254 102801D6
1255*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001256static const unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001257 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1258 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001259};
1260
1261/*
1262 STAC 9200-32 pin configs for
1263 102801CE (Dell XPS M1710)
1264 102801CF (Dell Precision M90)
1265*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001266static const unsigned int dell9200_m23_pin_configs[8] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001267 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1268 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1269};
1270
1271/*
1272 STAC 9200-32 pin configs for
1273 102801C9
1274 102801CA
1275 102801CB (Dell Latitude 120L)
1276 102801D3
1277*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001278static const unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001279 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1280 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001281};
1282
1283/*
1284 STAC 9200-32 pin configs for
1285 102801BD (Dell Inspiron E1505n)
1286 102801EE
1287 102801EF
1288*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001289static const unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001290 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1291 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001292};
1293
1294/*
1295 STAC 9200-32 pin configs for
1296 102801F5 (Dell Inspiron 1501)
1297 102801F6
1298*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001299static const unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001300 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1301 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001302};
1303
1304/*
1305 STAC 9200-32
1306 102801CD (Dell Inspiron E1705/9400)
1307*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001308static const unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001309 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1310 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001311};
1312
Takashi Iwai2b635362011-05-02 12:33:43 +02001313static const unsigned int oqo9200_pin_configs[8] = {
Tobin Davisbf277782008-02-03 20:31:47 +01001314 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1315 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1316};
1317
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001318
Takashi Iwai2b635362011-05-02 12:33:43 +02001319static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001320 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001321 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001322 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1323 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1324 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1325 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1326 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1327 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1328 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1329 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1330 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1331 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001332 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1333 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001334 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001335};
1336
Takashi Iwaiea734962011-01-17 11:29:34 +01001337static const char * const stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001338 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001339 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001340 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001341 [STAC_9200_DELL_D21] = "dell-d21",
1342 [STAC_9200_DELL_D22] = "dell-d22",
1343 [STAC_9200_DELL_D23] = "dell-d23",
1344 [STAC_9200_DELL_M21] = "dell-m21",
1345 [STAC_9200_DELL_M22] = "dell-m22",
1346 [STAC_9200_DELL_M23] = "dell-m23",
1347 [STAC_9200_DELL_M24] = "dell-m24",
1348 [STAC_9200_DELL_M25] = "dell-m25",
1349 [STAC_9200_DELL_M26] = "dell-m26",
1350 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001351 [STAC_9200_M4] = "gateway-m4",
1352 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001353 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001354};
1355
Takashi Iwai2b635362011-05-02 12:33:43 +02001356static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001357 /* SigmaTel reference board */
1358 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1359 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001360 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1361 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001362 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1364 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001366 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1368 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1370 "unknown Dell", STAC_9200_DELL_D22),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1372 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001374 "Dell Latitude D620", STAC_9200_DELL_M22),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1376 "unknown Dell", STAC_9200_DELL_D23),
1377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1378 "unknown Dell", STAC_9200_DELL_D23),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1380 "unknown Dell", STAC_9200_DELL_M22),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1382 "unknown Dell", STAC_9200_DELL_M24),
1383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1384 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001386 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001388 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001392 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001394 "Dell Precision M90", STAC_9200_DELL_M23),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1396 "unknown Dell", STAC_9200_DELL_M22),
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1398 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001400 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001402 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1404 "unknown Dell", STAC_9200_DELL_D23),
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1406 "unknown Dell", STAC_9200_DELL_D23),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1408 "unknown Dell", STAC_9200_DELL_D21),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1410 "unknown Dell", STAC_9200_DELL_D23),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1412 "unknown Dell", STAC_9200_DELL_D21),
1413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1414 "unknown Dell", STAC_9200_DELL_M25),
1415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1416 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001418 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1420 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001421 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001422 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001423 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001424 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1425 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1426 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001427 /* OQO Mobile */
1428 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001429 {} /* terminator */
1430};
1431
Takashi Iwai2b635362011-05-02 12:33:43 +02001432static const unsigned int ref925x_pin_configs[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001433 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001434 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001435};
1436
Takashi Iwai2b635362011-05-02 12:33:43 +02001437static const unsigned int stac925xM1_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001438 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1439 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001440};
1441
Takashi Iwai2b635362011-05-02 12:33:43 +02001442static const unsigned int stac925xM1_2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001443 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1444 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1445};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001446
Takashi Iwai2b635362011-05-02 12:33:43 +02001447static const unsigned int stac925xM2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001448 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1449 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001450};
1451
Takashi Iwai2b635362011-05-02 12:33:43 +02001452static const unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001453 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1454 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1455};
1456
Takashi Iwai2b635362011-05-02 12:33:43 +02001457static const unsigned int stac925xM3_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001458 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1459 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1460};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001461
Takashi Iwai2b635362011-05-02 12:33:43 +02001462static const unsigned int stac925xM5_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001463 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1464 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1465};
1466
Takashi Iwai2b635362011-05-02 12:33:43 +02001467static const unsigned int stac925xM6_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001468 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1469 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001470};
1471
Takashi Iwai2b635362011-05-02 12:33:43 +02001472static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001473 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001474 [STAC_M1] = stac925xM1_pin_configs,
1475 [STAC_M1_2] = stac925xM1_2_pin_configs,
1476 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001477 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001478 [STAC_M3] = stac925xM3_pin_configs,
1479 [STAC_M5] = stac925xM5_pin_configs,
1480 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001481};
1482
Takashi Iwaiea734962011-01-17 11:29:34 +01001483static const char * const stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001484 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001485 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001486 [STAC_M1] = "m1",
1487 [STAC_M1_2] = "m1-2",
1488 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001489 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001490 [STAC_M3] = "m3",
1491 [STAC_M5] = "m5",
1492 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001493};
1494
Takashi Iwai2b635362011-05-02 12:33:43 +02001495static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001496 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1497 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1498 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1499 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001500 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001501 /* Not sure about the brand name for those */
1502 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1503 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1504 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1505 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001506 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001507};
1508
Takashi Iwai2b635362011-05-02 12:33:43 +02001509static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001510 /* SigmaTel reference board */
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001512 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001513 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001514
1515 /* Default table for unknown ID */
1516 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1517
Tobin Davis8e21c342007-01-08 11:04:17 +01001518 {} /* terminator */
1519};
1520
Takashi Iwai2b635362011-05-02 12:33:43 +02001521static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001522 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1523 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1524 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001525 0x01452050,
1526};
1527
Takashi Iwai2b635362011-05-02 12:33:43 +02001528static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001529 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001530 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001531 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1532 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001533};
1534
Takashi Iwai2b635362011-05-02 12:33:43 +02001535static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001536 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1537 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1538 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1539 0x904601b0,
1540};
1541
Takashi Iwai2b635362011-05-02 12:33:43 +02001542static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001543 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001544 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001545};
1546
Takashi Iwai2b635362011-05-02 12:33:43 +02001547static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001548 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001549 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1550 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1551 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001552 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001553 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001554 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001555};
1556
Takashi Iwaiea734962011-01-17 11:29:34 +01001557static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001558 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001559 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001560 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001561 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001562 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1563 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1564 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001565 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001566 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001567};
1568
Takashi Iwai2b635362011-05-02 12:33:43 +02001569static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001570 /* SigmaTel reference board */
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001572 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001573 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1574 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1576 "Intel DG45ID", STAC_92HD73XX_INTEL),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1578 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001580 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001582 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001584 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001586 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001588 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001590 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001592 "unknown Dell", STAC_DELL_M6_DMIC),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1594 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001596 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1598 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1600 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1602 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001604 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001606 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001607 {} /* terminator */
1608};
1609
Takashi Iwai2b635362011-05-02 12:33:43 +02001610static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1612 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1614 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001616 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001617 {} /* terminator */
1618};
1619
Takashi Iwai2b635362011-05-02 12:33:43 +02001620static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001621 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1622 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001623 0x01451160, 0x98560170,
1624};
1625
Takashi Iwai2b635362011-05-02 12:33:43 +02001626static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001627 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1628 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001629 0x40f000f0, 0x40f000f0,
1630};
1631
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001632static const unsigned int dell_vostro_3500_pin_configs[10] = {
1633 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1634 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1635 0x400000f4, 0x400000f5,
1636};
1637
Takashi Iwai2b635362011-05-02 12:33:43 +02001638static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001639 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1640 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1641 0x40f000f0, 0x40f000f0,
1642};
1643
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001644static const unsigned int hp_zephyr_pin_configs[10] = {
1645 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1646 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1647 0, 0,
1648};
1649
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001650static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1651 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1652 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1653 0x40f000f0, 0x40f000f0,
1654};
1655
Takashi Iwai2b635362011-05-02 12:33:43 +02001656static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001657 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001658 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001659 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001660 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001661 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001662 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001663 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001664};
1665
Takashi Iwaiea734962011-01-17 11:29:34 +01001666static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001667 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001668 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001669 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001670 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001671 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001672 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001673 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001674 [STAC_HP_ZEPHYR] = "hp-zephyr",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001675};
1676
Takashi Iwai2b635362011-05-02 12:33:43 +02001677static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001678 /* SigmaTel reference board */
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001680 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001681 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1682 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1684 "unknown Dell", STAC_DELL_S14),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1686 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001687 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1688 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1690 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1692 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1694 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1696 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1698 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1700 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1702 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1704 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1706 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1708 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1710 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1712 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1714 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1716 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1718 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1720 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1722 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1724 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1726 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001727 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1728 "HP", STAC_HP_ZEPHYR),
1729 {} /* terminator */
1730};
1731
1732static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1734 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001735 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001736};
1737
Takashi Iwai2b635362011-05-02 12:33:43 +02001738static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001739 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001740 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001741 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1742 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001743};
1744
Takashi Iwai2b635362011-05-02 12:33:43 +02001745static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001746 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001747 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001748 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1749 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001750};
1751
Takashi Iwai2b635362011-05-02 12:33:43 +02001752static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001753 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1754 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001755 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1756 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001757};
1758
Takashi Iwai2b635362011-05-02 12:33:43 +02001759static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001760 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1761 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001762 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1763 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001764};
1765
Takashi Iwai2b635362011-05-02 12:33:43 +02001766static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001767 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001768 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1769 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001770 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001771 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001772 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001773 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001774 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001775 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001776};
1777
Takashi Iwaiea734962011-01-17 11:29:34 +01001778static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001779 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001780 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001781 [STAC_DELL_M4_1] = "dell-m4-1",
1782 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001783 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001784 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001785 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001786 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001787 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001788 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001789};
1790
Takashi Iwai2b635362011-05-02 12:33:43 +02001791static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001792 /* SigmaTel reference board */
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1794 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001795 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1796 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001797 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1798 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001799 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1800 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001801 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1802 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001803 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001804 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001805 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1806 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1808 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001810 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001811 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001812 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001813 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1814 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301815 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1816 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11001817 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1818 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001819 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1820 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1822 "unknown Dell", STAC_DELL_M4_1),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1824 "unknown Dell", STAC_DELL_M4_1),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1830 "unknown Dell", STAC_DELL_M4_1),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1832 "unknown Dell", STAC_DELL_M4_1),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1834 "unknown Dell", STAC_DELL_M4_1),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1836 "unknown Dell", STAC_DELL_M4_2),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1838 "unknown Dell", STAC_DELL_M4_2),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1840 "unknown Dell", STAC_DELL_M4_2),
1841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1842 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001843 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1844 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001845 {} /* terminator */
1846};
1847
Takashi Iwai2b635362011-05-02 12:33:43 +02001848static const unsigned int ref922x_pin_configs[10] = {
Matt Porter403d1942005-11-29 15:00:51 +01001849 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1850 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001851 0x40000100, 0x40000100,
1852};
1853
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001854/*
1855 STAC 922X pin configs for
1856 102801A7
1857 102801AB
1858 102801A9
1859 102801D1
1860 102801D2
1861*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001862static const unsigned int dell_922x_d81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001863 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1864 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1865 0x01813122, 0x400001f2,
1866};
1867
1868/*
1869 STAC 922X pin configs for
1870 102801AC
1871 102801D0
1872*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001873static const unsigned int dell_922x_d82_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001874 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1875 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1876 0x01813122, 0x400001f1,
1877};
1878
1879/*
1880 STAC 922X pin configs for
1881 102801BF
1882*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001883static const unsigned int dell_922x_m81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001884 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1885 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1886 0x40C003f1, 0x405003f0,
1887};
1888
1889/*
1890 STAC 9221 A1 pin configs for
1891 102801D7 (Dell XPS M1210)
1892*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001893static const unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001894 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1895 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001896 0x508003f3, 0x405003f4,
1897};
1898
Takashi Iwai2b635362011-05-02 12:33:43 +02001899static const unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001900 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001901 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1902 0x02a19120, 0x40000100,
1903};
1904
Takashi Iwai2b635362011-05-02 12:33:43 +02001905static const unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001906 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1907 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001908 0x02a19320, 0x40000100,
1909};
1910
Takashi Iwai2b635362011-05-02 12:33:43 +02001911static const unsigned int intel_mac_v1_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001912 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1913 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001914 0x400000fc, 0x400000fb,
1915};
1916
Takashi Iwai2b635362011-05-02 12:33:43 +02001917static const unsigned int intel_mac_v2_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001918 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1919 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001920 0x400000fc, 0x400000fb,
1921};
1922
Takashi Iwai2b635362011-05-02 12:33:43 +02001923static const unsigned int intel_mac_v3_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001924 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1925 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1926 0x400000fc, 0x400000fb,
1927};
1928
Takashi Iwai2b635362011-05-02 12:33:43 +02001929static const unsigned int intel_mac_v4_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001930 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1931 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1932 0x400000fc, 0x400000fb,
1933};
1934
Takashi Iwai2b635362011-05-02 12:33:43 +02001935static const unsigned int intel_mac_v5_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001936 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1937 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1938 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001939};
1940
Takashi Iwai2b635362011-05-02 12:33:43 +02001941static const unsigned int ecs202_pin_configs[10] = {
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001942 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1943 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1944 0x9037012e, 0x40e000f2,
1945};
Takashi Iwai76c08822007-06-19 12:17:42 +02001946
Takashi Iwai2b635362011-05-02 12:33:43 +02001947static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001948 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001949 [STAC_D945GTP3] = d945gtp3_pin_configs,
1950 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001951 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1952 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1953 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1954 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1955 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001956 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001957 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001958 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1959 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1960 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1961 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1962 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1963 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001964 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001965 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1966 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1967 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1968 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001969};
1970
Takashi Iwaiea734962011-01-17 11:29:34 +01001971static const char * const stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001972 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001973 [STAC_D945_REF] = "ref",
1974 [STAC_D945GTP5] = "5stack",
1975 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001976 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1977 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1978 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1979 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1980 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001981 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001982 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001983 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001984 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001985 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1986 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001987 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001988 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001989 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001990 [STAC_922X_DELL_D81] = "dell-d81",
1991 [STAC_922X_DELL_D82] = "dell-d82",
1992 [STAC_922X_DELL_M81] = "dell-m81",
1993 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001994};
1995
Takashi Iwai2b635362011-05-02 12:33:43 +02001996static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001997 /* SigmaTel reference board */
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1999 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002000 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2001 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002002 /* Intel 945G based systems */
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2004 "Intel D945G", STAC_D945GTP3),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2006 "Intel D945G", STAC_D945GTP3),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2008 "Intel D945G", STAC_D945GTP3),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2010 "Intel D945G", STAC_D945GTP3),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2012 "Intel D945G", STAC_D945GTP3),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2014 "Intel D945G", STAC_D945GTP3),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2016 "Intel D945G", STAC_D945GTP3),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2018 "Intel D945G", STAC_D945GTP3),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2020 "Intel D945G", STAC_D945GTP3),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2022 "Intel D945G", STAC_D945GTP3),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2024 "Intel D945G", STAC_D945GTP3),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2026 "Intel D945G", STAC_D945GTP3),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2028 "Intel D945G", STAC_D945GTP3),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2030 "Intel D945G", STAC_D945GTP3),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2032 "Intel D945G", STAC_D945GTP3),
2033 /* Intel D945G 5-stack systems */
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2035 "Intel D945G", STAC_D945GTP5),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2037 "Intel D945G", STAC_D945GTP5),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2039 "Intel D945G", STAC_D945GTP5),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2041 "Intel D945G", STAC_D945GTP5),
2042 /* Intel 945P based systems */
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2044 "Intel D945P", STAC_D945GTP3),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2046 "Intel D945P", STAC_D945GTP3),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2048 "Intel D945P", STAC_D945GTP3),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2050 "Intel D945P", STAC_D945GTP3),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2052 "Intel D945P", STAC_D945GTP3),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2054 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002055 /* other intel */
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2057 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002058 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002059 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002060 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002061 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002062 /* Dell systems */
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2064 "unknown Dell", STAC_922X_DELL_D81),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2066 "unknown Dell", STAC_922X_DELL_D81),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2068 "unknown Dell", STAC_922X_DELL_D81),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2070 "unknown Dell", STAC_922X_DELL_D82),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2072 "unknown Dell", STAC_922X_DELL_M81),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2074 "unknown Dell", STAC_922X_DELL_D82),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2076 "unknown Dell", STAC_922X_DELL_D81),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2078 "unknown Dell", STAC_922X_DELL_D81),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2080 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002081 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002082 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002083 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002084 {} /* terminator */
2085};
2086
Takashi Iwai2b635362011-05-02 12:33:43 +02002087static const unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002088 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2089 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2090 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2091 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002092};
2093
Takashi Iwai2b635362011-05-02 12:33:43 +02002094static const unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002095 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2096 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2097 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2098 0x40000100, 0x40000100
2099};
2100
Takashi Iwai2b635362011-05-02 12:33:43 +02002101static const unsigned int d965_5st_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002102 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2103 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2104 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2105 0x40000100, 0x40000100
2106};
2107
Takashi Iwai2b635362011-05-02 12:33:43 +02002108static const unsigned int d965_5st_no_fp_pin_configs[14] = {
Takashi Iwai679d92e2009-05-24 19:00:08 +02002109 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2110 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2111 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2112 0x40000100, 0x40000100
2113};
2114
Takashi Iwai2b635362011-05-02 12:33:43 +02002115static const unsigned int dell_3st_pin_configs[14] = {
Tobin Davis4ff076e2007-08-07 11:48:12 +02002116 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2117 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002118 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002119 0x40c003fc, 0x40000100
2120};
2121
Takashi Iwai2b635362011-05-02 12:33:43 +02002122static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002123 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002124 [STAC_D965_REF] = ref927x_pin_configs,
2125 [STAC_D965_3ST] = d965_3st_pin_configs,
2126 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002127 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002128 [STAC_DELL_3ST] = dell_3st_pin_configs,
2129 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002130 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002131};
2132
Takashi Iwaiea734962011-01-17 11:29:34 +01002133static const char * const stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002134 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002135 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002136 [STAC_D965_REF] = "ref",
2137 [STAC_D965_3ST] = "3stack",
2138 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002139 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002140 [STAC_DELL_3ST] = "dell-3stack",
2141 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002142 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002143};
2144
Takashi Iwai2b635362011-05-02 12:33:43 +02002145static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002146 /* SigmaTel reference board */
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2148 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002149 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2150 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002151 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002154 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002155 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2156 "Intel D965", STAC_D965_3ST),
2157 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2158 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002159 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002163 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002173 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002174 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2175 "Intel D965", STAC_D965_5ST),
2176 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2177 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002178 /* volume-knob fixes */
2179 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002180 {} /* terminator */
2181};
2182
Takashi Iwai2b635362011-05-02 12:33:43 +02002183static const unsigned int ref9205_pin_configs[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +02002184 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002185 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002186 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002187};
2188
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002189/*
2190 STAC 9205 pin configs for
2191 102801F1
2192 102801F2
2193 102801FC
2194 102801FD
2195 10280204
2196 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002197 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002198 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002199*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002200static const unsigned int dell_9205_m42_pin_configs[12] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002201 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2202 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2203 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2204};
2205
2206/*
2207 STAC 9205 pin configs for
2208 102801F9
2209 102801FA
2210 102801FE
2211 102801FF (Dell Precision M4300)
2212 10280206
2213 10280200
2214 10280201
2215*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002216static const unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002217 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2218 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2219 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2220};
2221
Takashi Iwai2b635362011-05-02 12:33:43 +02002222static const unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002223 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2224 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2225 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2226};
2227
Takashi Iwai2b635362011-05-02 12:33:43 +02002228static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002229 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002230 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2231 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2232 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002233 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002234};
2235
Takashi Iwaiea734962011-01-17 11:29:34 +01002236static const char * const stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002237 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002238 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002239 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002240 [STAC_9205_DELL_M43] = "dell-m43",
2241 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002242 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002243};
2244
Takashi Iwai2b635362011-05-02 12:33:43 +02002245static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002246 /* SigmaTel reference board */
2247 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2248 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002249 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2250 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002251 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2252 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002253 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2255 "unknown Dell", STAC_9205_DELL_M42),
2256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2257 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002259 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2261 "Dell Precision", STAC_9205_DELL_M43),
2262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2263 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2265 "unknown Dell", STAC_9205_DELL_M42),
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2267 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2269 "Dell Precision", STAC_9205_DELL_M43),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002271 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2273 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2275 "Dell Precision", STAC_9205_DELL_M43),
2276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2277 "Dell Precision", STAC_9205_DELL_M43),
2278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2279 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2281 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2283 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2285 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002286 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002287 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002288 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002289 {} /* terminator */
2290};
2291
Takashi Iwai330ee992009-02-20 14:33:36 +01002292static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002293 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002294{
2295 int i;
2296 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002297
Takashi Iwai330ee992009-02-20 14:33:36 +01002298 if (!pincfgs)
2299 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002300
Matthew Ranostay87d48362007-07-17 11:52:24 +02002301 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002302 if (spec->pin_nids[i] && pincfgs[i])
2303 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2304 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002305}
2306
Matt2f2f4252005-04-13 14:45:30 +02002307/*
2308 * Analog playback callbacks
2309 */
2310static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2311 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002312 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002313{
2314 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002315 if (spec->stream_delay)
2316 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002317 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2318 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002319}
2320
2321static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2322 struct hda_codec *codec,
2323 unsigned int stream_tag,
2324 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002325 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002326{
2327 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002328 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002329}
2330
2331static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2332 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002333 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002334{
2335 struct sigmatel_spec *spec = codec->spec;
2336 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2337}
2338
2339/*
Mattdabbed62005-06-14 10:19:34 +02002340 * Digital playback callbacks
2341 */
2342static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2343 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002344 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002345{
2346 struct sigmatel_spec *spec = codec->spec;
2347 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2348}
2349
2350static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2351 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002352 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002353{
2354 struct sigmatel_spec *spec = codec->spec;
2355 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2356}
2357
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002358static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2359 struct hda_codec *codec,
2360 unsigned int stream_tag,
2361 unsigned int format,
2362 struct snd_pcm_substream *substream)
2363{
2364 struct sigmatel_spec *spec = codec->spec;
2365 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2366 stream_tag, format, substream);
2367}
2368
Takashi Iwai9411e212009-02-13 11:32:28 +01002369static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2370 struct hda_codec *codec,
2371 struct snd_pcm_substream *substream)
2372{
2373 struct sigmatel_spec *spec = codec->spec;
2374 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2375}
2376
Mattdabbed62005-06-14 10:19:34 +02002377
2378/*
Matt2f2f4252005-04-13 14:45:30 +02002379 * Analog capture callbacks
2380 */
2381static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2382 struct hda_codec *codec,
2383 unsigned int stream_tag,
2384 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002385 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002386{
2387 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002388 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002389
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002390 if (spec->powerdown_adcs) {
2391 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002392 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002393 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2394 }
2395 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002396 return 0;
2397}
2398
2399static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2400 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002401 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002402{
2403 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002404 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002405
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002406 snd_hda_codec_cleanup_stream(codec, nid);
2407 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002408 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002409 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002410 return 0;
2411}
2412
Takashi Iwai2b635362011-05-02 12:33:43 +02002413static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02002414 .substreams = 1,
2415 .channels_min = 2,
2416 .channels_max = 2,
2417 /* NID is set in stac92xx_build_pcms */
2418 .ops = {
2419 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002420 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002421 .prepare = stac92xx_dig_playback_pcm_prepare,
2422 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002423 },
2424};
2425
Takashi Iwai2b635362011-05-02 12:33:43 +02002426static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02002427 .substreams = 1,
2428 .channels_min = 2,
2429 .channels_max = 2,
2430 /* NID is set in stac92xx_build_pcms */
2431};
2432
Takashi Iwai2b635362011-05-02 12:33:43 +02002433static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02002434 .substreams = 1,
2435 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002436 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002437 .nid = 0x02, /* NID to query formats and rates */
2438 .ops = {
2439 .open = stac92xx_playback_pcm_open,
2440 .prepare = stac92xx_playback_pcm_prepare,
2441 .cleanup = stac92xx_playback_pcm_cleanup
2442 },
2443};
2444
Takashi Iwai2b635362011-05-02 12:33:43 +02002445static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002446 .substreams = 1,
2447 .channels_min = 2,
2448 .channels_max = 2,
2449 .nid = 0x06, /* NID to query formats and rates */
2450 .ops = {
2451 .open = stac92xx_playback_pcm_open,
2452 .prepare = stac92xx_playback_pcm_prepare,
2453 .cleanup = stac92xx_playback_pcm_cleanup
2454 },
2455};
2456
Takashi Iwai2b635362011-05-02 12:33:43 +02002457static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002458 .channels_min = 2,
2459 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002460 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002461 .ops = {
2462 .prepare = stac92xx_capture_pcm_prepare,
2463 .cleanup = stac92xx_capture_pcm_cleanup
2464 },
2465};
2466
2467static int stac92xx_build_pcms(struct hda_codec *codec)
2468{
2469 struct sigmatel_spec *spec = codec->spec;
2470 struct hda_pcm *info = spec->pcm_rec;
2471
2472 codec->num_pcms = 1;
2473 codec->pcm_info = info;
2474
Mattc7d4b2f2005-06-27 14:59:41 +02002475 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002476 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002477 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2478 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002479 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002480 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002481 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002482
2483 if (spec->alt_switch) {
2484 codec->num_pcms++;
2485 info++;
2486 info->name = "STAC92xx Analog Alt";
2487 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2488 }
Matt2f2f4252005-04-13 14:45:30 +02002489
Mattdabbed62005-06-14 10:19:34 +02002490 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2491 codec->num_pcms++;
2492 info++;
2493 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002494 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002495 if (spec->multiout.dig_out_nid) {
2496 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2497 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2498 }
2499 if (spec->dig_in_nid) {
2500 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2501 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2502 }
2503 }
2504
Matt2f2f4252005-04-13 14:45:30 +02002505 return 0;
2506}
2507
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002508static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2509 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002510{
Takashi Iwai1327a322009-03-23 13:07:47 +01002511 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002512 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2513 if (pincap & AC_PINCAP_VREF_100)
2514 return AC_PINCTL_VREF_100;
2515 if (pincap & AC_PINCAP_VREF_80)
2516 return AC_PINCTL_VREF_80;
2517 if (pincap & AC_PINCAP_VREF_50)
2518 return AC_PINCTL_VREF_50;
2519 if (pincap & AC_PINCAP_VREF_GRD)
2520 return AC_PINCTL_VREF_GRD;
2521 return 0;
2522}
2523
Matt Porter403d1942005-11-29 15:00:51 +01002524static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2525
2526{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002527 snd_hda_codec_write_cache(codec, nid, 0,
2528 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002529}
2530
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002531#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2532
2533static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2534 struct snd_ctl_elem_value *ucontrol)
2535{
2536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2537 struct sigmatel_spec *spec = codec->spec;
2538
Takashi Iwaid7a89432008-11-12 09:48:04 +01002539 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002540 return 0;
2541}
2542
Takashi Iwai62558ce2009-07-29 14:23:09 +02002543static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002544
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002545static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2546 struct snd_ctl_elem_value *ucontrol)
2547{
2548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2549 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002550 int nid = kcontrol->private_value;
2551
2552 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002553
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002554 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002555 * switch changes
2556 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002557 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002558
2559 return 1;
2560}
2561
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002562static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2563 struct snd_ctl_elem_info *uinfo)
2564{
2565 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02002566 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002567 "Mic In", "Line In", "Line Out"
2568 };
2569
2570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2571 struct sigmatel_spec *spec = codec->spec;
2572 hda_nid_t nid = kcontrol->private_value;
2573
2574 if (nid == spec->mic_switch || nid == spec->line_switch)
2575 i = 3;
2576 else
2577 i = 2;
2578
2579 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2580 uinfo->value.enumerated.items = i;
2581 uinfo->count = 1;
2582 if (uinfo->value.enumerated.item >= i)
2583 uinfo->value.enumerated.item = i-1;
2584 strcpy(uinfo->value.enumerated.name,
2585 texts[uinfo->value.enumerated.item]);
2586
2587 return 0;
2588}
2589
2590static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2591 struct snd_ctl_elem_value *ucontrol)
2592{
2593 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2594 hda_nid_t nid = kcontrol->private_value;
2595 unsigned int vref = stac92xx_vref_get(codec, nid);
2596
2597 if (vref == stac92xx_get_default_vref(codec, nid))
2598 ucontrol->value.enumerated.item[0] = 0;
2599 else if (vref == AC_PINCTL_VREF_GRD)
2600 ucontrol->value.enumerated.item[0] = 1;
2601 else if (vref == AC_PINCTL_VREF_HIZ)
2602 ucontrol->value.enumerated.item[0] = 2;
2603
2604 return 0;
2605}
2606
2607static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2608 struct snd_ctl_elem_value *ucontrol)
2609{
2610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2611 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002612 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002613 hda_nid_t nid = kcontrol->private_value;
2614
2615 if (ucontrol->value.enumerated.item[0] == 0)
2616 new_vref = stac92xx_get_default_vref(codec, nid);
2617 else if (ucontrol->value.enumerated.item[0] == 1)
2618 new_vref = AC_PINCTL_VREF_GRD;
2619 else if (ucontrol->value.enumerated.item[0] == 2)
2620 new_vref = AC_PINCTL_VREF_HIZ;
2621 else
2622 return 0;
2623
2624 if (new_vref != stac92xx_vref_get(codec, nid)) {
2625 error = stac92xx_vref_set(codec, nid, new_vref);
2626 return error;
2627 }
2628
2629 return 0;
2630}
2631
2632static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2633 struct snd_ctl_elem_info *uinfo)
2634{
Takashi Iwai2b635362011-05-02 12:33:43 +02002635 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2637 struct sigmatel_spec *spec = codec->spec;
2638
2639 if (kcontrol->private_value == spec->line_switch)
2640 texts[0] = "Line In";
2641 else
2642 texts[0] = "Mic In";
2643 texts[1] = "Line Out";
2644 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2645 uinfo->value.enumerated.items = 2;
2646 uinfo->count = 1;
2647
2648 if (uinfo->value.enumerated.item >= 2)
2649 uinfo->value.enumerated.item = 1;
2650 strcpy(uinfo->value.enumerated.name,
2651 texts[uinfo->value.enumerated.item]);
2652
2653 return 0;
2654}
Matt Porter403d1942005-11-29 15:00:51 +01002655
2656static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2657{
2658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2659 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002660 hda_nid_t nid = kcontrol->private_value;
2661 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002662
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002663 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002664 return 0;
2665}
2666
2667static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2668{
2669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2670 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002671 hda_nid_t nid = kcontrol->private_value;
2672 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2673 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002674
2675 spec->io_switch[io_idx] = val;
2676
2677 if (val)
2678 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002679 else {
2680 unsigned int pinctl = AC_PINCTL_IN_EN;
2681 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002682 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002683 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2684 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002685
2686 /* check the auto-mute again: we need to mute/unmute the speaker
2687 * appropriately according to the pin direction
2688 */
2689 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002690 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002691
Matt Porter403d1942005-11-29 15:00:51 +01002692 return 1;
2693}
2694
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002695#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2696
2697static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2698 struct snd_ctl_elem_value *ucontrol)
2699{
2700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2701 struct sigmatel_spec *spec = codec->spec;
2702
2703 ucontrol->value.integer.value[0] = spec->clfe_swap;
2704 return 0;
2705}
2706
2707static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2708 struct snd_ctl_elem_value *ucontrol)
2709{
2710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2711 struct sigmatel_spec *spec = codec->spec;
2712 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002713 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002714
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002715 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002716 return 0;
2717
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002718 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002719
2720 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2721 spec->clfe_swap ? 0x4 : 0x0);
2722
2723 return 1;
2724}
2725
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002726#define STAC_CODEC_HP_SWITCH(xname) \
2727 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2728 .name = xname, \
2729 .index = 0, \
2730 .info = stac92xx_hp_switch_info, \
2731 .get = stac92xx_hp_switch_get, \
2732 .put = stac92xx_hp_switch_put, \
2733 }
2734
Matt Porter403d1942005-11-29 15:00:51 +01002735#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2737 .name = xname, \
2738 .index = 0, \
2739 .info = stac92xx_io_switch_info, \
2740 .get = stac92xx_io_switch_get, \
2741 .put = stac92xx_io_switch_put, \
2742 .private_value = xpval, \
2743 }
2744
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002745#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2746 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2747 .name = xname, \
2748 .index = 0, \
2749 .info = stac92xx_clfe_switch_info, \
2750 .get = stac92xx_clfe_switch_get, \
2751 .put = stac92xx_clfe_switch_put, \
2752 .private_value = xpval, \
2753 }
Matt Porter403d1942005-11-29 15:00:51 +01002754
Mattc7d4b2f2005-06-27 14:59:41 +02002755enum {
2756 STAC_CTL_WIDGET_VOL,
2757 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002758 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002759 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002760 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002761 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002762 STAC_CTL_WIDGET_CLFE_SWITCH,
2763 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002764};
2765
Takashi Iwai2b635362011-05-02 12:33:43 +02002766static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002767 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2768 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002769 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002770 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002771 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002772 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002773 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002774 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002775};
2776
2777/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002778static struct snd_kcontrol_new *
2779stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002780 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002781 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002782 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002783{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002784 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002785
Takashi Iwai603c4012008-07-30 15:01:44 +02002786 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2787 knew = snd_array_new(&spec->kctls);
2788 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002789 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002790 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002791 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002792 if (!knew->name) {
2793 /* roolback */
2794 memset(knew, 0, sizeof(*knew));
2795 spec->kctls.alloced--;
2796 return NULL;
2797 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002798 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002799 return knew;
2800}
2801
2802static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002803 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01002804 int idx, const char *name,
2805 unsigned long val)
2806{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002807 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002808 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002809 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002810 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002811 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002812 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002813 return 0;
2814}
2815
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002816static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2817 int type, int idx, const char *name,
2818 unsigned long val)
2819{
2820 return stac92xx_add_control_temp(spec,
2821 &stac92xx_control_templates[type],
2822 idx, name, val);
2823}
2824
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002825
2826/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002827static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2828 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002829{
2830 return stac92xx_add_control_idx(spec, type, 0, name, val);
2831}
2832
Takashi Iwai2b635362011-05-02 12:33:43 +02002833static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01002834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2835 .name = "Input Source",
2836 .info = stac92xx_mux_enum_info,
2837 .get = stac92xx_mux_enum_get,
2838 .put = stac92xx_mux_enum_put,
2839};
2840
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002841static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2842 hda_nid_t nid, int idx)
2843{
2844 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2845 int control = 0;
2846 struct sigmatel_spec *spec = codec->spec;
2847 char name[22];
2848
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002849 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002850 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2851 && nid == spec->line_switch)
2852 control = STAC_CTL_WIDGET_IO_SWITCH;
2853 else if (snd_hda_query_pin_caps(codec, nid)
2854 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2855 control = STAC_CTL_WIDGET_DC_BIAS;
2856 else if (nid == spec->mic_switch)
2857 control = STAC_CTL_WIDGET_IO_SWITCH;
2858 }
2859
2860 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01002861 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
2862 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002863 return stac92xx_add_control(codec->spec, control,
2864 strcat(name, " Jack Mode"), nid);
2865 }
2866
2867 return 0;
2868}
2869
Takashi Iwaie3c75962009-01-23 11:57:22 +01002870static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2871{
2872 struct snd_kcontrol_new *knew;
2873 struct hda_input_mux *imux = &spec->private_imux;
2874
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002875 if (spec->auto_mic)
2876 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002877 if (!spec->num_adcs || imux->num_items <= 1)
2878 return 0; /* no need for input source control */
2879 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002880 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002881 if (!knew)
2882 return -ENOMEM;
2883 knew->count = spec->num_adcs;
2884 return 0;
2885}
2886
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002887/* check whether the line-input can be used as line-out */
2888static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002889{
2890 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002891 struct auto_pin_cfg *cfg = &spec->autocfg;
2892 hda_nid_t nid;
2893 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002894 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002895
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002896 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2897 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002898 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02002899 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002900 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01002901 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002902 if (pincap & AC_PINCAP_OUT)
2903 return nid;
2904 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002905 }
Matt Porter403d1942005-11-29 15:00:51 +01002906 return 0;
2907}
2908
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002909static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2910
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002911/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002912static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002913{
2914 struct sigmatel_spec *spec = codec->spec;
2915 struct auto_pin_cfg *cfg = &spec->autocfg;
2916 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02002917 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002918
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002919 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002920 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2921 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002922 for (i = 0; i < cfg->num_inputs; i++) {
2923 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02002924 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002925 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002926 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2927 /* some laptops have an internal analog microphone
2928 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002929 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002930 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002931 if (pincap & AC_PINCAP_OUT) {
2932 *dac = get_unassigned_dac(codec, nid);
2933 if (*dac)
2934 return nid;
2935 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002936 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002937 }
2938 return 0;
2939}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002940
2941static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2942{
2943 int i;
2944
2945 for (i = 0; i < spec->multiout.num_dacs; i++) {
2946 if (spec->multiout.dac_nids[i] == nid)
2947 return 1;
2948 }
2949
2950 return 0;
2951}
2952
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002953static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2954{
2955 int i;
2956 if (is_in_dac_nids(spec, nid))
2957 return 1;
2958 for (i = 0; i < spec->autocfg.hp_outs; i++)
2959 if (spec->hp_dacs[i] == nid)
2960 return 1;
2961 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2962 if (spec->speaker_dacs[i] == nid)
2963 return 1;
2964 return 0;
2965}
2966
2967static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2968{
2969 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02002970 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002971 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02002972 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002973 unsigned int wcaps, wtype;
2974
2975 conn_len = snd_hda_get_connections(codec, nid, conn,
2976 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002977 /* 92HD88: trace back up the link of nids to find the DAC */
2978 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2979 != AC_WID_AUD_OUT)) {
2980 nid = conn[0];
2981 conn_len = snd_hda_get_connections(codec, nid, conn,
2982 HDA_MAX_CONNECTIONS);
2983 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002984 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002985 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002986 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002987 /* we check only analog outputs */
2988 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2989 continue;
2990 /* if this route has a free DAC, assign it */
2991 if (!check_all_dac_nids(spec, conn[j])) {
2992 if (conn_len > 1) {
2993 /* select this DAC in the pin's input mux */
2994 snd_hda_codec_write_cache(codec, nid, 0,
2995 AC_VERB_SET_CONNECT_SEL, j);
2996 }
2997 return conn[j];
2998 }
2999 }
David Henningsson48718ea2011-10-05 09:49:05 +02003000
3001 /* if all DACs are already assigned, connect to the primary DAC,
3002 unless we're assigning a secondary headphone */
3003 fallback_dac = spec->multiout.dac_nids[0];
3004 if (spec->multiout.hp_nid) {
3005 for (j = 0; j < cfg->hp_outs; j++)
3006 if (cfg->hp_pins[j] == nid) {
3007 fallback_dac = spec->multiout.hp_nid;
3008 break;
3009 }
3010 }
3011
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003012 if (conn_len > 1) {
3013 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02003014 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003015 snd_hda_codec_write_cache(codec, nid, 0,
3016 AC_VERB_SET_CONNECT_SEL, j);
3017 break;
3018 }
3019 }
3020 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003021 return 0;
3022}
3023
3024static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3025static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3026
Matt Porter3cc08dc2006-01-23 15:27:49 +01003027/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003028 * Fill in the dac_nids table from the parsed pin configuration
3029 * This function only works when every pin in line_out_pins[]
3030 * contains atleast one DAC in its connection list. Some 92xx
3031 * codecs are not connected directly to a DAC, such as the 9200
3032 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003033 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003034static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003035{
3036 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003037 struct auto_pin_cfg *cfg = &spec->autocfg;
3038 int i;
3039 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003040
Mattc7d4b2f2005-06-27 14:59:41 +02003041 for (i = 0; i < cfg->line_outs; i++) {
3042 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003043 dac = get_unassigned_dac(codec, nid);
3044 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003045 if (spec->multiout.num_dacs > 0) {
3046 /* we have already working output pins,
3047 * so let's drop the broken ones again
3048 */
3049 cfg->line_outs = spec->multiout.num_dacs;
3050 break;
3051 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003052 /* error out, no available DAC found */
3053 snd_printk(KERN_ERR
3054 "%s: No available DAC for pin 0x%x\n",
3055 __func__, nid);
3056 return -ENODEV;
3057 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003058 add_spec_dacs(spec, dac);
3059 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003060
Takashi Iwai139e0712009-03-06 12:10:41 +01003061 for (i = 0; i < cfg->hp_outs; i++) {
3062 nid = cfg->hp_pins[i];
3063 dac = get_unassigned_dac(codec, nid);
3064 if (dac) {
3065 if (!spec->multiout.hp_nid)
3066 spec->multiout.hp_nid = dac;
3067 else
3068 add_spec_extra_dacs(spec, dac);
3069 }
3070 spec->hp_dacs[i] = dac;
3071 }
3072
3073 for (i = 0; i < cfg->speaker_outs; i++) {
3074 nid = cfg->speaker_pins[i];
3075 dac = get_unassigned_dac(codec, nid);
3076 if (dac)
3077 add_spec_extra_dacs(spec, dac);
3078 spec->speaker_dacs[i] = dac;
3079 }
3080
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003081 /* add line-in as output */
3082 nid = check_line_out_switch(codec);
3083 if (nid) {
3084 dac = get_unassigned_dac(codec, nid);
3085 if (dac) {
3086 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3087 nid, cfg->line_outs);
3088 cfg->line_out_pins[cfg->line_outs] = nid;
3089 cfg->line_outs++;
3090 spec->line_switch = nid;
3091 add_spec_dacs(spec, dac);
3092 }
3093 }
3094 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003095 nid = check_mic_out_switch(codec, &dac);
3096 if (nid && dac) {
3097 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3098 nid, cfg->line_outs);
3099 cfg->line_out_pins[cfg->line_outs] = nid;
3100 cfg->line_outs++;
3101 spec->mic_switch = nid;
3102 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003103 }
3104
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003105 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003106 spec->multiout.num_dacs,
3107 spec->multiout.dac_nids[0],
3108 spec->multiout.dac_nids[1],
3109 spec->multiout.dac_nids[2],
3110 spec->multiout.dac_nids[3],
3111 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003112
Mattc7d4b2f2005-06-27 14:59:41 +02003113 return 0;
3114}
3115
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003116/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003117static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3118 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003119{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003120 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003121 char name[32];
3122 int err;
3123
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003124 if (!spec->check_volume_offset) {
3125 unsigned int caps, step, nums, db_scale;
3126 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3127 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3128 AC_AMPCAP_STEP_SIZE_SHIFT;
3129 step = (step + 1) * 25; /* in .01dB unit */
3130 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3131 AC_AMPCAP_NUM_STEPS_SHIFT;
3132 db_scale = nums * step;
3133 /* if dB scale is over -64dB, and finer enough,
3134 * let's reduce it to half
3135 */
3136 if (db_scale > 6400 && nums >= 0x1f)
3137 spec->volume_offset = nums / 2;
3138 spec->check_volume_offset = 1;
3139 }
3140
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003141 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003142 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003143 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3144 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003145 if (err < 0)
3146 return err;
3147 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003148 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003149 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3150 if (err < 0)
3151 return err;
3152 return 0;
3153}
3154
Takashi Iwai668b9652009-03-06 10:13:24 +01003155#define create_controls(codec, pfx, nid, chs) \
3156 create_controls_idx(codec, pfx, 0, nid, chs)
3157
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003158static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3159{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003160 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003161 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3162 return 1;
3163 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003164 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3165 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003166 spec->multiout.num_dacs++;
3167 }
3168 return 0;
3169}
3170
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003171static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003172{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003173 int i;
3174 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3175 if (!spec->multiout.extra_out_nid[i]) {
3176 spec->multiout.extra_out_nid[i] = nid;
3177 return 0;
3178 }
3179 }
3180 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3181 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003182}
3183
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003184/* Create output controls
3185 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3186 */
3187static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3188 const hda_nid_t *pins,
3189 const hda_nid_t *dac_nids,
3190 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003191{
Takashi Iwai76624532008-12-19 10:09:47 +01003192 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003193 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003194 "Front", "Surround", NULL /*CLFE*/, "Side"
3195 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003196 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003197 int i, err;
3198 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003199
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003200 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003201 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003202 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003203 spec->hp_detect = 1;
3204 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003205 nid = dac_nids[i];
3206 if (!nid)
3207 continue;
3208 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003209 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003210 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003211 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003212 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003213 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003214 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003215 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003216
3217 wid_caps = get_wcaps(codec, nid);
3218
3219 if (wid_caps & AC_WCAP_LR_SWAP) {
3220 err = stac92xx_add_control(spec,
3221 STAC_CTL_WIDGET_CLFE_SWITCH,
3222 "Swap Center/LFE Playback Switch", nid);
3223
3224 if (err < 0)
3225 return err;
3226 }
3227
Mattc7d4b2f2005-06-27 14:59:41 +02003228 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003229 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003230 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003231 switch (type) {
3232 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003233 name = "Headphone";
3234 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003235 break;
3236 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003237 name = "Speaker";
3238 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003239 break;
3240 default:
3241 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003242 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003243 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003244 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003245 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003246 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003247 return err;
3248 }
3249 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003250 return 0;
3251}
3252
Takashi Iwai6479c632009-07-28 18:20:25 +02003253static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3254 unsigned long sw, int idx)
3255{
3256 int err;
3257 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003258 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003259 if (err < 0)
3260 return err;
3261 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003262 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003263 if (err < 0)
3264 return err;
3265 return 0;
3266}
3267
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003268/* add playback controls from the parsed DAC table */
3269static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3270 const struct auto_pin_cfg *cfg)
3271{
3272 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003273 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003274 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003275 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003276
3277 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3278 spec->multiout.dac_nids,
3279 cfg->line_out_type);
3280 if (err < 0)
3281 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003282
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003283 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003284 err = stac92xx_add_control(spec,
3285 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003286 "Headphone as Line Out Switch",
3287 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003288 if (err < 0)
3289 return err;
3290 }
3291
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003292 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003293 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003294 break;
3295 nid = cfg->inputs[idx].pin;
3296 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3297 if (err < 0)
3298 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003299 }
Matt Porter403d1942005-11-29 15:00:51 +01003300
Mattc7d4b2f2005-06-27 14:59:41 +02003301 return 0;
3302}
3303
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003304/* add playback controls for Speaker and HP outputs */
3305static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3306 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003307{
3308 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003309 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003310
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003311 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3312 spec->hp_dacs, AUTO_PIN_HP_OUT);
3313 if (err < 0)
3314 return err;
3315
3316 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3317 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3318 if (err < 0)
3319 return err;
3320
Mattc7d4b2f2005-06-27 14:59:41 +02003321 return 0;
3322}
3323
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003324/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003325static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003326 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003327};
3328
3329/* create mono mux for mono out on capable codecs */
3330static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3331{
3332 struct sigmatel_spec *spec = codec->spec;
3333 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3334 int i, num_cons;
3335 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3336
3337 num_cons = snd_hda_get_connections(codec,
3338 spec->mono_nid,
3339 con_lst,
3340 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003341 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003342 return -EINVAL;
3343
Takashi Iwai10a20af2010-09-09 16:28:02 +02003344 for (i = 0; i < num_cons; i++)
3345 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3346 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003347
3348 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3349 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003350}
3351
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003352/* create PC beep volume controls */
3353static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3354 hda_nid_t nid)
3355{
3356 struct sigmatel_spec *spec = codec->spec;
3357 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003358 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3359
3360 if (spec->anabeep_nid == nid)
3361 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003362
3363 /* check for mute support for the the amp */
3364 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003365 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003366 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003367 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3368 if (err < 0)
3369 return err;
3370 }
3371
3372 /* check to see if there is volume support for the amp */
3373 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3374 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003375 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003376 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3377 if (err < 0)
3378 return err;
3379 }
3380 return 0;
3381}
3382
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003383#ifdef CONFIG_SND_HDA_INPUT_BEEP
3384#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3385
3386static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3387 struct snd_ctl_elem_value *ucontrol)
3388{
3389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3390 ucontrol->value.integer.value[0] = codec->beep->enabled;
3391 return 0;
3392}
3393
3394static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3395 struct snd_ctl_elem_value *ucontrol)
3396{
3397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003398 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003399}
3400
Takashi Iwai2b635362011-05-02 12:33:43 +02003401static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3403 .info = stac92xx_dig_beep_switch_info,
3404 .get = stac92xx_dig_beep_switch_get,
3405 .put = stac92xx_dig_beep_switch_put,
3406};
3407
3408static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3409{
3410 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003411 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003412}
3413#endif
3414
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003415static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3416{
3417 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003418 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003419
3420 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003421 hda_nid_t nid;
3422 unsigned int wcaps;
3423 unsigned long val;
3424
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003425 nid = spec->mux_nids[i];
3426 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003427 if (!(wcaps & AC_WCAP_OUT_AMP))
3428 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003429
Takashi Iwai667067d2009-08-13 18:14:42 +02003430 /* check whether already the same control was created as
3431 * normal Capture Volume.
3432 */
3433 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3434 for (j = 0; j < spec->num_caps; j++) {
3435 if (spec->capvols[j] == val)
3436 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003437 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003438 if (j < spec->num_caps)
3439 continue;
3440
3441 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3442 "Mux Capture Volume", val);
3443 if (err < 0)
3444 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003445 }
3446 return 0;
3447};
3448
Takashi Iwaiea734962011-01-17 11:29:34 +01003449static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003450 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003451};
3452
3453static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3454{
3455 struct sigmatel_spec *spec = codec->spec;
3456 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01003457 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003458 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003459 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003460
3461 num_cons = snd_hda_get_connections(codec,
3462 spec->smux_nids[0],
3463 con_lst,
3464 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003465 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003466 return -EINVAL;
3467
Matthew Ranostay65973632008-09-16 10:39:37 -04003468 if (!labels)
3469 labels = stac92xx_spdif_labels;
3470
Takashi Iwai10a20af2010-09-09 16:28:02 +02003471 for (i = 0; i < num_cons; i++)
3472 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02003473
3474 return 0;
3475}
3476
Matt Porter8b657272006-10-26 17:12:59 +02003477/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003478static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003479 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3480 "Digital Mic 3", "Digital Mic 4"
3481};
3482
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003483static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3484 int idx)
3485{
3486 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3487 int nums;
3488 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3489 if (idx >= 0 && idx < nums)
3490 return conn[idx];
3491 return 0;
3492}
3493
Takashi Iwai8d087c72011-06-28 12:45:47 +02003494/* look for NID recursively */
3495#define get_connection_index(codec, mux, nid) \
3496 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003497
Takashi Iwai667067d2009-08-13 18:14:42 +02003498/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003499/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003500static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003501 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003502{
3503 unsigned int caps, nums;
3504 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003505 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003506
Takashi Iwai96f845d2009-08-29 00:49:36 +02003507 if (direction == HDA_OUTPUT)
3508 caps = AC_WCAP_OUT_AMP;
3509 else
3510 caps = AC_WCAP_IN_AMP;
3511 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003512 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003513 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003514 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3515 if (!nums)
3516 return 0;
3517 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003518 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3519 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02003520 if (err < 0)
3521 return err;
3522 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003523}
3524
Matt Porter8b657272006-10-26 17:12:59 +02003525/* create playback/capture controls for input pins on dmic capable codecs */
3526static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3527 const struct auto_pin_cfg *cfg)
3528{
3529 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003530 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003531 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003532 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02003533 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003534
Takashi Iwai10a20af2010-09-09 16:28:02 +02003535 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02003536
Matt Porter8b657272006-10-26 17:12:59 +02003537 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003538 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003539 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01003540 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02003541
Takashi Iwai667067d2009-08-13 18:14:42 +02003542 nid = spec->dmic_nids[i];
3543 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3544 continue;
3545 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003546 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3547 continue;
3548
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003549 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3550 if (index < 0)
3551 continue;
3552
Takashi Iwai201e06f2011-11-16 15:33:26 +01003553 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3554 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02003555 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01003556 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3557 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02003558
Takashi Iwai10a20af2010-09-09 16:28:02 +02003559 err = create_elem_capture_vol(codec, nid, label, type_idx,
3560 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003561 if (err < 0)
3562 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003563 if (!err) {
3564 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02003565 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003566 if (err < 0)
3567 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003568 if (!err) {
3569 nid = get_connected_node(codec,
3570 spec->dmux_nids[0], index);
3571 if (nid)
3572 err = create_elem_capture_vol(codec,
3573 nid, label,
3574 type_idx, HDA_INPUT);
3575 if (err < 0)
3576 return err;
3577 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02003578 }
Matt Porter8b657272006-10-26 17:12:59 +02003579 }
3580
3581 return 0;
3582}
3583
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003584static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02003585 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003586{
3587 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003588 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003589
3590 if (!nid)
3591 return 0;
3592 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003593 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003594 switch (snd_hda_get_input_pin_attr(cfg)) {
3595 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003596 if (*fixed)
3597 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003598 if (type != AC_JACK_MIC_IN)
3599 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003600 *fixed = nid;
3601 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003602 case INPUT_PIN_ATTR_UNUSED:
3603 break;
3604 case INPUT_PIN_ATTR_DOCK:
3605 if (*dock)
3606 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003607 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3608 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003609 *dock = nid;
3610 break;
3611 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003612 if (*ext)
3613 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003614 if (type != AC_JACK_MIC_IN)
3615 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003616 *ext = nid;
3617 break;
3618 }
3619 return 0;
3620}
3621
3622static int set_mic_route(struct hda_codec *codec,
3623 struct sigmatel_mic_route *mic,
3624 hda_nid_t pin)
3625{
3626 struct sigmatel_spec *spec = codec->spec;
3627 struct auto_pin_cfg *cfg = &spec->autocfg;
3628 int i;
3629
3630 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02003631 if (pin == 0)
3632 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003633 for (i = 0; i < cfg->num_inputs; i++) {
3634 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003635 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003636 }
Takashi Iwai86e29592010-09-09 14:50:17 +02003637 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003638 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003639 i = get_connection_index(codec, spec->mux_nids[0], pin);
3640 if (i < 0)
3641 return -1;
3642 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003643 mic->dmux_idx = -1;
3644 if (spec->dmux_nids)
3645 mic->dmux_idx = get_connection_index(codec,
3646 spec->dmux_nids[0],
3647 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003648 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003649 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003650 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3651 if (i < 0)
3652 return -1;
3653 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003654 mic->mux_idx = -1;
3655 if (spec->mux_nids)
3656 mic->mux_idx = get_connection_index(codec,
3657 spec->mux_nids[0],
3658 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003659 }
3660 return 0;
3661}
3662
3663/* return non-zero if the device is for automatic mic switch */
3664static int stac_check_auto_mic(struct hda_codec *codec)
3665{
3666 struct sigmatel_spec *spec = codec->spec;
3667 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02003668 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003669 int i;
3670
Charles Chin99077902010-09-17 10:22:32 +02003671 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003672 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02003673 if (check_mic_pin(codec, cfg->inputs[i].pin,
3674 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003675 return 0;
3676 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02003677 if (check_mic_pin(codec, spec->dmic_nids[i],
3678 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003679 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01003680 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02003681 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003682 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003683 return 0; /* no unsol support */
3684 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02003685 set_mic_route(codec, &spec->int_mic, fixed) ||
3686 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003687 return 0; /* something is wrong */
3688 return 1;
3689}
3690
Mattc7d4b2f2005-06-27 14:59:41 +02003691/* create playback/capture controls for input pins */
3692static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3693{
3694 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003695 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003696 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003697 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02003698
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003699 for (i = 0; i < cfg->num_inputs; i++) {
3700 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003701 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02003702
Takashi Iwai314634b2006-09-21 11:56:18 +02003703 index = -1;
3704 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003705 index = get_connection_index(codec, spec->mux_nids[j],
3706 nid);
3707 if (index >= 0)
3708 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003709 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003710 if (index < 0)
3711 continue;
3712
Takashi Iwai10a20af2010-09-09 16:28:02 +02003713 label = hda_get_autocfg_input_label(codec, cfg, i);
3714 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003715
Takashi Iwai667067d2009-08-13 18:14:42 +02003716 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003717 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003718 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003719 if (err < 0)
3720 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003721 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003722 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003723
Steve Longerbeam7b043892007-05-03 20:50:03 +02003724 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003725 /*
3726 * Set the current input for the muxes.
3727 * The STAC9221 has two input muxes with identical source
3728 * NID lists. Hopefully this won't get confused.
3729 */
3730 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003731 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3732 AC_VERB_SET_CONNECT_SEL,
3733 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003734 }
3735 }
3736
Mattc7d4b2f2005-06-27 14:59:41 +02003737 return 0;
3738}
3739
Mattc7d4b2f2005-06-27 14:59:41 +02003740static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3741{
3742 struct sigmatel_spec *spec = codec->spec;
3743 int i;
3744
3745 for (i = 0; i < spec->autocfg.line_outs; i++) {
3746 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3747 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3748 }
3749}
3750
3751static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3752{
3753 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003754 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003755
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003756 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3757 hda_nid_t pin;
3758 pin = spec->autocfg.hp_pins[i];
3759 if (pin) /* connect to front */
3760 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3761 }
3762 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3763 hda_nid_t pin;
3764 pin = spec->autocfg.speaker_pins[i];
3765 if (pin) /* connect to front */
3766 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3767 }
Mattc7d4b2f2005-06-27 14:59:41 +02003768}
3769
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003770static int is_dual_headphones(struct hda_codec *codec)
3771{
3772 struct sigmatel_spec *spec = codec->spec;
3773 int i, valid_hps;
3774
3775 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3776 spec->autocfg.hp_outs <= 1)
3777 return 0;
3778 valid_hps = 0;
3779 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3780 hda_nid_t nid = spec->autocfg.hp_pins[i];
3781 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3782 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3783 continue;
3784 valid_hps++;
3785 }
3786 return (valid_hps > 1);
3787}
3788
3789
Charles Chin9009b0e2011-11-03 10:27:27 +01003790static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003791{
3792 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01003793 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003794 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003795 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003796
Matt Porter8b657272006-10-26 17:12:59 +02003797 if ((err = snd_hda_parse_pin_def_config(codec,
3798 &spec->autocfg,
3799 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003800 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003801 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003802 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003803
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003804 /* If we have no real line-out pin and multiple hp-outs, HPs should
3805 * be set up as multi-channel outputs.
3806 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003807 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003808 /* Copy hp_outs to line_outs, backup line_outs in
3809 * speaker_outs so that the following routines can handle
3810 * HP pins as primary outputs.
3811 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003812 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003813 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3814 sizeof(spec->autocfg.line_out_pins));
3815 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3816 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3817 sizeof(spec->autocfg.hp_pins));
3818 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003819 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3820 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003821 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003822 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003823 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003824 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3825 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003826 u32 caps = query_amp_caps(codec,
3827 spec->autocfg.mono_out_pin, dir);
3828 hda_nid_t conn_list[1];
3829
3830 /* get the mixer node and then the mono mux if it exists */
3831 if (snd_hda_get_connections(codec,
3832 spec->autocfg.mono_out_pin, conn_list, 1) &&
3833 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003834 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003835
3836 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003837 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003838 /* LR swap check, some stac925x have a mux that
3839 * changes the DACs output path instead of the
3840 * mono-mux path.
3841 */
3842 if (wid_type == AC_WID_AUD_SEL &&
3843 !(wcaps & AC_WCAP_LR_SWAP))
3844 spec->mono_nid = conn_list[0];
3845 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003846 if (dir) {
3847 hda_nid_t nid = spec->autocfg.mono_out_pin;
3848
3849 /* most mono outs have a least a mute/unmute switch */
3850 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3851 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3852 "Mono Playback Switch",
3853 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003854 if (err < 0)
3855 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003856 /* check for volume support for the amp */
3857 if ((caps & AC_AMPCAP_NUM_STEPS)
3858 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3859 err = stac92xx_add_control(spec,
3860 STAC_CTL_WIDGET_VOL,
3861 "Mono Playback Volume",
3862 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3863 if (err < 0)
3864 return err;
3865 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003866 }
3867
3868 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3869 AC_PINCTL_OUT_EN);
3870 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003871
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003872 if (!spec->multiout.num_dacs) {
3873 err = stac92xx_auto_fill_dac_nids(codec);
3874 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003875 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003876 err = stac92xx_auto_create_multi_out_ctls(codec,
3877 &spec->autocfg);
3878 if (err < 0)
3879 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003880 }
Mattc7d4b2f2005-06-27 14:59:41 +02003881
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003882 /* setup analog beep controls */
3883 if (spec->anabeep_nid > 0) {
3884 err = stac92xx_auto_create_beep_ctls(codec,
3885 spec->anabeep_nid);
3886 if (err < 0)
3887 return err;
3888 }
3889
3890 /* setup digital beep controls and input device */
3891#ifdef CONFIG_SND_HDA_INPUT_BEEP
3892 if (spec->digbeep_nid > 0) {
3893 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003894 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003895
3896 err = stac92xx_auto_create_beep_ctls(codec, nid);
3897 if (err < 0)
3898 return err;
3899 err = snd_hda_attach_beep_device(codec, nid);
3900 if (err < 0)
3901 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003902 if (codec->beep) {
3903 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003904 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003905 /* if no beep switch is available, make its own one */
3906 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3907 if (!(caps & AC_AMPCAP_MUTE)) {
3908 err = stac92xx_beep_switch_ctl(codec);
3909 if (err < 0)
3910 return err;
3911 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003912 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003913 }
3914#endif
3915
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003916 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003917 if (err < 0)
3918 return err;
3919
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003920 /* All output parsing done, now restore the swapped hp pins */
3921 if (hp_swap) {
3922 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3923 sizeof(spec->autocfg.hp_pins));
3924 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3925 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3926 spec->autocfg.line_outs = 0;
3927 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003928
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003929 if (stac_check_auto_mic(codec)) {
3930 spec->auto_mic = 1;
3931 /* only one capture for auto-mic */
3932 spec->num_adcs = 1;
3933 spec->num_caps = 1;
3934 spec->num_muxes = 1;
3935 }
3936
Takashi Iwai6479c632009-07-28 18:20:25 +02003937 for (i = 0; i < spec->num_caps; i++) {
3938 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3939 spec->capsws[i], i);
3940 if (err < 0)
3941 return err;
3942 }
3943
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003944 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003945 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003946 return err;
3947
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003948 if (spec->mono_nid > 0) {
3949 err = stac92xx_auto_create_mono_output_ctls(codec);
3950 if (err < 0)
3951 return err;
3952 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003953 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003954 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3955 &spec->autocfg)) < 0)
3956 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003957 if (spec->num_muxes > 0) {
3958 err = stac92xx_auto_create_mux_input_ctls(codec);
3959 if (err < 0)
3960 return err;
3961 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003962 if (spec->num_smuxes > 0) {
3963 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3964 if (err < 0)
3965 return err;
3966 }
Matt Porter8b657272006-10-26 17:12:59 +02003967
Takashi Iwaie3c75962009-01-23 11:57:22 +01003968 err = stac92xx_add_input_source(spec);
3969 if (err < 0)
3970 return err;
3971
Mattc7d4b2f2005-06-27 14:59:41 +02003972 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003973 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003974 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003975
Charles Chin9009b0e2011-11-03 10:27:27 +01003976 /* find digital out and in converters */
3977 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3978 unsigned int wid_caps = get_wcaps(codec, i);
3979 if (wid_caps & AC_WCAP_DIGITAL) {
3980 switch (get_wcaps_type(wid_caps)) {
3981 case AC_WID_AUD_OUT:
3982 if (!dig_out)
3983 dig_out = i;
3984 break;
3985 case AC_WID_AUD_IN:
3986 if (!dig_in)
3987 dig_in = i;
3988 break;
3989 }
3990 }
3991 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003992 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003993 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003994 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003995 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003996
Takashi Iwai603c4012008-07-30 15:01:44 +02003997 if (spec->kctls.list)
3998 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003999
4000 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05004001 if (!spec->dinput_mux)
4002 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004003 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004004 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02004005 return 1;
4006}
4007
Takashi Iwai82bc9552006-03-21 11:24:42 +01004008/* add playback controls for HP output */
4009static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4010 struct auto_pin_cfg *cfg)
4011{
4012 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004013 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01004014
4015 if (! pin)
4016 return 0;
4017
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004018 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01004019 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004020
4021 return 0;
4022}
4023
Richard Fish160ea0d2006-09-06 13:58:25 +02004024/* add playback controls for LFE output */
4025static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4026 struct auto_pin_cfg *cfg)
4027{
4028 struct sigmatel_spec *spec = codec->spec;
4029 int err;
4030 hda_nid_t lfe_pin = 0x0;
4031 int i;
4032
4033 /*
4034 * search speaker outs and line outs for a mono speaker pin
4035 * with an amp. If one is found, add LFE controls
4036 * for it.
4037 */
4038 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4039 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004040 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004041 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4042 if (wcaps == AC_WCAP_OUT_AMP)
4043 /* found a mono speaker with an amp, must be lfe */
4044 lfe_pin = pin;
4045 }
4046
4047 /* if speaker_outs is 0, then speakers may be in line_outs */
4048 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4049 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4050 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004051 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004052 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004053 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004054 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004055 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4056 if (wcaps == AC_WCAP_OUT_AMP)
4057 /* found a mono speaker with an amp,
4058 must be lfe */
4059 lfe_pin = pin;
4060 }
4061 }
4062 }
4063
4064 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004065 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004066 if (err < 0)
4067 return err;
4068 }
4069
4070 return 0;
4071}
4072
Mattc7d4b2f2005-06-27 14:59:41 +02004073static int stac9200_parse_auto_config(struct hda_codec *codec)
4074{
4075 struct sigmatel_spec *spec = codec->spec;
4076 int err;
4077
Kailang Yangdf694da2005-12-05 19:42:22 +01004078 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004079 return err;
4080
4081 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4082 return err;
4083
Takashi Iwai82bc9552006-03-21 11:24:42 +01004084 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4085 return err;
4086
Richard Fish160ea0d2006-09-06 13:58:25 +02004087 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4088 return err;
4089
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004090 if (spec->num_muxes > 0) {
4091 err = stac92xx_auto_create_mux_input_ctls(codec);
4092 if (err < 0)
4093 return err;
4094 }
4095
Takashi Iwaie3c75962009-01-23 11:57:22 +01004096 err = stac92xx_add_input_source(spec);
4097 if (err < 0)
4098 return err;
4099
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004100 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004101 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004102 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004103 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004104
Takashi Iwai603c4012008-07-30 15:01:44 +02004105 if (spec->kctls.list)
4106 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004107
4108 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004109 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004110
4111 return 1;
4112}
4113
Sam Revitch62fe78e2006-05-10 15:09:17 +02004114/*
4115 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4116 * funky external mute control using GPIO pins.
4117 */
4118
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004119static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004120 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004121{
4122 unsigned int gpiostate, gpiomask, gpiodir;
4123
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004124 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4125
Sam Revitch62fe78e2006-05-10 15:09:17 +02004126 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4127 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004128 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004129
4130 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4131 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004132 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004133
4134 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4135 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004136 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004137
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004138 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004139 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4140
4141 snd_hda_codec_write(codec, codec->afg, 0,
4142 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004143 snd_hda_codec_read(codec, codec->afg, 0,
4144 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004145
4146 msleep(1);
4147
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004148 snd_hda_codec_read(codec, codec->afg, 0,
4149 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004150}
4151
Takashi Iwai3a938972011-10-28 01:16:55 +02004152static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004153 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004154{
Takashi Iwai3a938972011-10-28 01:16:55 +02004155 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004156
Takashi Iwai3a938972011-10-28 01:16:55 +02004157 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004158 if (!event)
4159 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02004160 event->action = type;
4161 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004162
Takashi Iwai3a938972011-10-28 01:16:55 +02004163 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004164}
4165
Takashi Iwai62558ce2009-07-29 14:23:09 +02004166/* check if given nid is a valid pin and no other events are assigned
4167 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4168 * Otherwise, returns zero.
4169 */
4170static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4171 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004172{
Takashi Iwai3a938972011-10-28 01:16:55 +02004173 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004174
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004175 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004176 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02004177 event = snd_hda_jack_tbl_new(codec, nid);
4178 if (!event)
4179 return -ENOMEM;
4180 if (event->action && event->action != type)
4181 return 0;
4182 event->action = type;
4183 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004184 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004185}
4186
Takashi Iwaib4ead012012-01-23 18:23:36 +01004187static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004188{
4189 int i;
4190 for (i = 0; i < cfg->hp_outs; i++)
4191 if (cfg->hp_pins[i] == nid)
4192 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01004193 for (i = 0; i < cfg->line_outs; i++)
4194 if (cfg->line_out_pins[i] == nid)
4195 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004196 return 0; /* nid is not a HP-Out */
4197};
4198
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004199static void stac92xx_power_down(struct hda_codec *codec)
4200{
4201 struct sigmatel_spec *spec = codec->spec;
4202
4203 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02004204 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004205 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004206 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004207 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004208 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4209}
4210
Takashi Iwaif73d3582008-11-25 08:21:51 +01004211static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4212 int enable);
4213
Takashi Iwai014c41f2009-12-27 13:53:24 +01004214static inline int get_int_hint(struct hda_codec *codec, const char *key,
4215 int *valp)
4216{
4217 const char *p;
4218 p = snd_hda_get_hint(codec, key);
4219 if (p) {
4220 unsigned long val;
4221 if (!strict_strtoul(p, 0, &val)) {
4222 *valp = val;
4223 return 1;
4224 }
4225 }
4226 return 0;
4227}
4228
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004229/* override some hints from the hwdep entry */
4230static void stac_store_hints(struct hda_codec *codec)
4231{
4232 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004233 int val;
4234
4235 val = snd_hda_get_bool_hint(codec, "hp_detect");
4236 if (val >= 0)
4237 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004238 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004239 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4240 spec->gpio_mask;
4241 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004242 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4243 spec->gpio_mask &= spec->gpio_mask;
4244 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4245 spec->gpio_dir &= spec->gpio_mask;
4246 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4247 spec->eapd_mask &= spec->gpio_mask;
4248 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4249 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004250 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4251 if (val >= 0)
4252 spec->eapd_switch = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004253 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4254 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004255 spec->gpio_mask |= spec->gpio_led;
4256 spec->gpio_dir |= spec->gpio_led;
4257 if (spec->gpio_led_polarity)
4258 spec->gpio_data |= spec->gpio_led;
Takashi Iwai043958e2009-12-26 10:36:12 +01004259 }
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004260}
4261
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004262static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4263 const hda_nid_t *pins)
4264{
4265 while (num_pins--)
4266 stac_issue_unsol_event(codec, *pins++);
4267}
4268
4269/* fake event to set up pins */
4270static void stac_fake_hp_events(struct hda_codec *codec)
4271{
4272 struct sigmatel_spec *spec = codec->spec;
4273
4274 if (spec->autocfg.hp_outs)
4275 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4276 spec->autocfg.hp_pins);
4277 if (spec->autocfg.line_outs &&
4278 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4279 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4280 spec->autocfg.line_out_pins);
4281}
4282
Mattc7d4b2f2005-06-27 14:59:41 +02004283static int stac92xx_init(struct hda_codec *codec)
4284{
4285 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004286 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004287 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004288 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004289
Mattc7d4b2f2005-06-27 14:59:41 +02004290 snd_hda_sequence_write(codec, spec->init);
4291
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004292 /* power down adcs initially */
4293 if (spec->powerdown_adcs)
4294 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004295 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004296 spec->adc_nids[i], 0,
4297 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004298
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004299 /* override some hints */
4300 stac_store_hints(codec);
4301
Takashi Iwaif73d3582008-11-25 08:21:51 +01004302 /* set up GPIO */
4303 gpio = spec->gpio_data;
4304 /* turn on EAPD statically when spec->eapd_switch isn't set.
4305 * otherwise, unsol event will turn it on/off dynamically
4306 */
4307 if (!spec->eapd_switch)
4308 gpio |= spec->eapd_mask;
4309 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4310
Takashi Iwai82bc9552006-03-21 11:24:42 +01004311 /* set up pins */
4312 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004313 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004314 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004315 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004316 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004317 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004318 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4319 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004320 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004321 for (i = 0; i < cfg->line_outs; i++) {
4322 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004323 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4324 }
4325 }
4326
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004327 /* force to enable the first line-out; the others are set up
4328 * in unsol_event
4329 */
4330 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004331 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004332 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004333 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004334 } else {
4335 stac92xx_auto_init_multi_out(codec);
4336 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004337 for (i = 0; i < cfg->hp_outs; i++)
4338 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004339 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004340 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004341 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004342 if (spec->dmux_nids)
4343 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004344 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004345 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4346 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02004347 if (enable_pin_detect(codec, spec->dock_mic.pin,
4348 STAC_MIC_EVENT))
4349 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004350 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004351 for (i = 0; i < cfg->num_inputs; i++) {
4352 hda_nid_t nid = cfg->inputs[i].pin;
4353 int type = cfg->inputs[i].type;
4354 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02004355 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004356 /* for mic pins, force to initialize */
4357 pinctl = stac92xx_get_default_vref(codec, nid);
4358 pinctl |= AC_PINCTL_IN_EN;
4359 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4360 } else {
4361 pinctl = snd_hda_codec_read(codec, nid, 0,
4362 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4363 /* if PINCTL already set then skip */
4364 /* Also, if both INPUT and OUTPUT are set,
4365 * it must be a BIOS bug; need to override, too
4366 */
4367 if (!(pinctl & AC_PINCTL_IN_EN) ||
4368 (pinctl & AC_PINCTL_OUT_EN)) {
4369 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004370 pinctl |= AC_PINCTL_IN_EN;
4371 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004372 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004373 }
4374 conf = snd_hda_codec_get_pincfg(codec, nid);
4375 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4376 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4377 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01004378 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004379 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004380 for (i = 0; i < spec->num_dmics; i++)
4381 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4382 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004383 if (cfg->dig_out_pins[0])
4384 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004385 AC_PINCTL_OUT_EN);
4386 if (cfg->dig_in_pin)
4387 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4388 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004389 for (i = 0; i < spec->num_pwrs; i++) {
4390 hda_nid_t nid = spec->pwr_nids[i];
4391 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004392
Takashi Iwaieb632122008-12-19 16:39:48 +01004393 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01004394 /* or when the VREF is used for controlling LED */
4395 if (!spec->hp_detect ||
Takashi Iwaia0204282011-12-06 13:17:23 +01004396 spec->vref_mute_led_nid == nid) {
Takashi Iwaieb632122008-12-19 16:39:48 +01004397 stac_toggle_power_map(codec, nid, 1);
4398 continue;
4399 }
4400
Takashi Iwaib4ead012012-01-23 18:23:36 +01004401 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004402 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004403
Takashi Iwaif73d3582008-11-25 08:21:51 +01004404 pinctl = snd_hda_codec_read(codec, nid, 0,
4405 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4406 /* outputs are only ports capable of power management
4407 * any attempts on powering down a input port cause the
4408 * referenced VREF to act quirky.
4409 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004410 if (pinctl & AC_PINCTL_IN_EN) {
4411 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004412 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004413 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004414 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004415 def_conf = get_defcfg_connect(def_conf);
4416 /* skip any ports that don't have jacks since presence
4417 * detection is useless */
4418 if (def_conf != AC_JACK_PORT_COMPLEX) {
4419 if (def_conf != AC_JACK_PORT_NONE)
4420 stac_toggle_power_map(codec, nid, 1);
4421 continue;
4422 }
Charles Chinafef2cf2011-11-11 08:05:28 +01004423 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004424 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01004425 continue;
4426 }
4427 /* none of the above, turn the port OFF */
4428 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004429 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004430
Takashi Iwai01a61e12011-10-28 00:03:22 +02004431 snd_hda_jack_report_sync(codec);
4432
Takashi Iwaic21bd022010-02-08 15:16:08 +01004433 /* sync mute LED */
Takashi Iwaid2f344b2012-03-12 16:59:58 +01004434 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004435 if (spec->dac_list)
4436 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004437 return 0;
4438}
4439
Takashi Iwai603c4012008-07-30 15:01:44 +02004440static void stac92xx_free_kctls(struct hda_codec *codec)
4441{
4442 struct sigmatel_spec *spec = codec->spec;
4443
4444 if (spec->kctls.list) {
4445 struct snd_kcontrol_new *kctl = spec->kctls.list;
4446 int i;
4447 for (i = 0; i < spec->kctls.used; i++)
4448 kfree(kctl[i].name);
4449 }
4450 snd_array_free(&spec->kctls);
4451}
4452
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004453static void stac92xx_shutup_pins(struct hda_codec *codec)
4454{
4455 unsigned int i, def_conf;
4456
4457 if (codec->bus->shutdown)
4458 return;
4459 for (i = 0; i < codec->init_pins.used; i++) {
4460 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4461 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4462 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
4463 snd_hda_codec_write(codec, pin->nid, 0,
4464 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4465 }
4466}
4467
Takashi Iwai167eae52009-11-06 15:47:50 +01004468static void stac92xx_shutup(struct hda_codec *codec)
4469{
4470 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004471
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004472 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004473
4474 if (spec->eapd_mask)
4475 stac_gpio_set(codec, spec->gpio_mask,
4476 spec->gpio_dir, spec->gpio_data &
4477 ~spec->eapd_mask);
4478}
4479
Matt2f2f4252005-04-13 14:45:30 +02004480static void stac92xx_free(struct hda_codec *codec)
4481{
Mattc7d4b2f2005-06-27 14:59:41 +02004482 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004483
4484 if (! spec)
4485 return;
4486
Takashi Iwai167eae52009-11-06 15:47:50 +01004487 stac92xx_shutup(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02004488
Mattc7d4b2f2005-06-27 14:59:41 +02004489 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004490 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004491}
4492
Matt4e550962005-07-04 17:51:39 +02004493static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4494 unsigned int flag)
4495{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004496 unsigned int old_ctl, pin_ctl;
4497
4498 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004499 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004500
Takashi Iwaif9acba42007-05-29 18:01:06 +02004501 if (pin_ctl & AC_PINCTL_IN_EN) {
4502 /*
4503 * we need to check the current set-up direction of
4504 * shared input pins since they can be switched via
4505 * "xxx as Output" mixer switch
4506 */
4507 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004508 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004509 return;
4510 }
4511
Takashi Iwai8ce84192009-01-22 16:59:20 +01004512 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004513 /* if setting pin direction bits, clear the current
4514 direction bits first */
4515 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4516 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4517
Takashi Iwai8ce84192009-01-22 16:59:20 +01004518 pin_ctl |= flag;
4519 if (old_ctl != pin_ctl)
4520 snd_hda_codec_write_cache(codec, nid, 0,
4521 AC_VERB_SET_PIN_WIDGET_CONTROL,
4522 pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004523}
4524
4525static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4526 unsigned int flag)
4527{
4528 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4529 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004530 if (pin_ctl & flag)
4531 snd_hda_codec_write_cache(codec, nid, 0,
4532 AC_VERB_SET_PIN_WIDGET_CONTROL,
4533 pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004534}
4535
Takashi Iwaid56757a2009-11-18 08:00:14 +01004536static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004537{
4538 if (!nid)
4539 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004540 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004541}
4542
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004543static void stac92xx_line_out_detect(struct hda_codec *codec,
4544 int presence)
4545{
4546 struct sigmatel_spec *spec = codec->spec;
4547 struct auto_pin_cfg *cfg = &spec->autocfg;
4548 int i;
4549
4550 for (i = 0; i < cfg->line_outs; i++) {
4551 if (presence)
4552 break;
4553 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4554 if (presence) {
4555 unsigned int pinctl;
4556 pinctl = snd_hda_codec_read(codec,
4557 cfg->line_out_pins[i], 0,
4558 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4559 if (pinctl & AC_PINCTL_IN_EN)
4560 presence = 0; /* mic- or line-input */
4561 }
4562 }
4563
4564 if (presence) {
4565 /* disable speakers */
4566 for (i = 0; i < cfg->speaker_outs; i++)
4567 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4568 AC_PINCTL_OUT_EN);
4569 if (spec->eapd_mask && spec->eapd_switch)
4570 stac_gpio_set(codec, spec->gpio_mask,
4571 spec->gpio_dir, spec->gpio_data &
4572 ~spec->eapd_mask);
4573 } else {
4574 /* enable speakers */
4575 for (i = 0; i < cfg->speaker_outs; i++)
4576 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4577 AC_PINCTL_OUT_EN);
4578 if (spec->eapd_mask && spec->eapd_switch)
4579 stac_gpio_set(codec, spec->gpio_mask,
4580 spec->gpio_dir, spec->gpio_data |
4581 spec->eapd_mask);
4582 }
4583}
4584
Takashi Iwaid7a89432008-11-12 09:48:04 +01004585/* return non-zero if the hp-pin of the given array index isn't
4586 * a jack-detection target
4587 */
4588static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4589{
4590 struct auto_pin_cfg *cfg = &spec->autocfg;
4591
4592 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004593 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004594 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004595 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004596 return 1;
4597 /* ignore if the pin is set as line-out */
4598 if (cfg->hp_pins[i] == spec->hp_switch)
4599 return 1;
4600 return 0;
4601}
4602
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004603static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004604{
4605 struct sigmatel_spec *spec = codec->spec;
4606 struct auto_pin_cfg *cfg = &spec->autocfg;
4607 int i, presence;
4608
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004609 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004610 if (spec->gpio_mute)
4611 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4612 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4613
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004614 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004615 if (presence)
4616 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004617 if (no_hp_sensing(spec, i))
4618 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004619 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4620 if (presence) {
4621 unsigned int pinctl;
4622 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4623 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4624 if (pinctl & AC_PINCTL_IN_EN)
4625 presence = 0; /* mic- or line-input */
4626 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004627 }
Matt4e550962005-07-04 17:51:39 +02004628
4629 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004630 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004631 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004632 stac92xx_reset_pinctl(codec, spec->hp_switch,
4633 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004634 for (i = 0; i < cfg->line_outs; i++)
4635 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4636 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004637 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004638 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004639 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004640 stac92xx_set_pinctl(codec, spec->hp_switch,
4641 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004642 for (i = 0; i < cfg->line_outs; i++)
4643 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4644 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004645 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004646 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004647 /* toggle hp outs */
4648 for (i = 0; i < cfg->hp_outs; i++) {
4649 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4650 if (no_hp_sensing(spec, i))
4651 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01004652 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004653 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004654#if 0 /* FIXME */
4655/* Resetting the pinctl like below may lead to (a sort of) regressions
4656 * on some devices since they use the HP pin actually for line/speaker
4657 * outs although the default pin config shows a different pin (that is
4658 * wrong and useless).
4659 *
4660 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4661 * But, disabling the code below just works around it, and I'm too tired of
4662 * bug reports with such devices...
4663 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004664 else
4665 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004666#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004667 }
Matt4e550962005-07-04 17:51:39 +02004668}
4669
Takashi Iwaif73d3582008-11-25 08:21:51 +01004670static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4671 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004672{
4673 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004674 unsigned int idx, val;
4675
4676 for (idx = 0; idx < spec->num_pwrs; idx++) {
4677 if (spec->pwr_nids[idx] == nid)
4678 break;
4679 }
4680 if (idx >= spec->num_pwrs)
4681 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004682
Charles Chinafef2cf2011-11-11 08:05:28 +01004683 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004684
Takashi Iwaif73d3582008-11-25 08:21:51 +01004685 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4686 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004687 val &= ~idx;
4688 else
4689 val |= idx;
4690
4691 /* power down unused output ports */
4692 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004693}
4694
Takashi Iwaif73d3582008-11-25 08:21:51 +01004695static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4696{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004697 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004698}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004699
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004700/* get the pin connection (fixed, none, etc) */
4701static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4702{
4703 struct sigmatel_spec *spec = codec->spec;
4704 unsigned int cfg;
4705
4706 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4707 return get_defcfg_connect(cfg);
4708}
4709
4710static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004711 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004712{
4713 struct sigmatel_spec *spec = codec->spec;
4714 int idx, num;
4715 unsigned int def_conf;
4716
4717 for (num = 0; num < num_nids; num++) {
4718 for (idx = 0; idx < spec->num_pins; idx++)
4719 if (spec->pin_nids[idx] == nids[num])
4720 break;
4721 if (idx >= spec->num_pins)
4722 break;
4723 def_conf = stac_get_defcfg_connect(codec, idx);
4724 if (def_conf == AC_JACK_PORT_NONE)
4725 break;
4726 }
4727 return num;
4728}
4729
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004730static void stac92xx_mic_detect(struct hda_codec *codec)
4731{
4732 struct sigmatel_spec *spec = codec->spec;
4733 struct sigmatel_mic_route *mic;
4734
4735 if (get_pin_presence(codec, spec->ext_mic.pin))
4736 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02004737 else if (get_pin_presence(codec, spec->dock_mic.pin))
4738 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004739 else
4740 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004741 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004742 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4743 AC_VERB_SET_CONNECT_SEL,
4744 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004745 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004746 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4747 AC_VERB_SET_CONNECT_SEL,
4748 mic->mux_idx);
4749}
4750
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004751static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02004752 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02004753{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004754 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004755 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004756
Takashi Iwai3a938972011-10-28 01:16:55 +02004757 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004758 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004759 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004760 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004761 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004762 case STAC_MIC_EVENT:
4763 stac92xx_mic_detect(codec);
4764 break;
4765 }
4766
Takashi Iwai3a938972011-10-28 01:16:55 +02004767 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004768 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004769 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004770 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004771 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004772 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004773 if (spec->num_pwrs > 0)
4774 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004775
4776 switch (codec->subsystem_id) {
4777 case 0x103c308f:
4778 if (event->nid == 0xb) {
4779 int pin = AC_PINCTL_IN_EN;
4780
4781 if (get_pin_presence(codec, 0xa)
4782 && get_pin_presence(codec, 0xb))
4783 pin |= AC_PINCTL_VREF_80;
4784 if (!get_pin_presence(codec, 0xb))
4785 pin |= AC_PINCTL_VREF_80;
4786
4787 /* toggle VREF state based on mic + hp pin
4788 * status
4789 */
4790 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4791 }
4792 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004793 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004794 case STAC_VREF_EVENT:
4795 data = snd_hda_codec_read(codec, codec->afg, 0,
4796 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004797 /* toggle VREF state based on GPIOx status */
4798 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02004799 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004800 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004801 }
4802}
4803
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004804static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4805{
Takashi Iwai3a938972011-10-28 01:16:55 +02004806 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004807 if (!event)
4808 return;
4809 handle_unsol_event(codec, event);
4810}
4811
4812static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4813{
Takashi Iwai3a938972011-10-28 01:16:55 +02004814 struct hda_jack_tbl *event;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004815 int tag;
4816
4817 tag = (res >> 26) & 0x7f;
Takashi Iwai3a938972011-10-28 01:16:55 +02004818 event = snd_hda_jack_tbl_get_from_tag(codec, tag);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004819 if (!event)
4820 return;
Takashi Iwai3a938972011-10-28 01:16:55 +02004821 event->jack_dirty = 1;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004822 handle_unsol_event(codec, event);
Takashi Iwai01a61e12011-10-28 00:03:22 +02004823 snd_hda_jack_report_sync(codec);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004824}
4825
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304826static int hp_blike_system(u32 subsystem_id);
4827
4828static void set_hp_led_gpio(struct hda_codec *codec)
4829{
4830 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004831 unsigned int gpio;
4832
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004833 if (spec->gpio_led)
4834 return;
4835
Takashi Iwai07f80442010-02-08 15:06:13 +01004836 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4837 gpio &= AC_GPIO_IO_COUNT;
4838 if (gpio > 3)
4839 spec->gpio_led = 0x08; /* GPIO 3 */
4840 else
4841 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304842}
4843
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004844/*
4845 * This method searches for the mute LED GPIO configuration
4846 * provided as OEM string in SMBIOS. The format of that string
4847 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4848 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4849 * that corresponds to the NOT muted state of the master volume
4850 * and G is the index of the GPIO to use as the mute LED control (0..9)
4851 * If _G portion is missing it is assigned based on the codec ID
4852 *
4853 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4854 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304855 *
4856 *
4857 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4858 * SMBIOS - at least the ones I have seen do not have them - which include
4859 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4860 * HP Pavilion dv9500t CTO.
4861 * Need more information on whether it is true across the entire series.
4862 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004863 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004864static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004865{
4866 struct sigmatel_spec *spec = codec->spec;
4867 const struct dmi_device *dev = NULL;
4868
4869 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4870 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4871 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004872 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304873 &spec->gpio_led_polarity,
4874 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004875 unsigned int max_gpio;
4876 max_gpio = snd_hda_param_read(codec, codec->afg,
4877 AC_PAR_GPIO_CAP);
4878 max_gpio &= AC_GPIO_IO_COUNT;
4879 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004880 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01004881 else
4882 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004883 return 1;
4884 }
4885 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304886 &spec->gpio_led_polarity) == 1) {
4887 set_hp_led_gpio(codec);
4888 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004889 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004890 /* BIOS bug: unfilled OEM string */
4891 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4892 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02004893 switch (codec->subsystem_id) {
4894 case 0x103c148a:
4895 spec->gpio_led_polarity = 0;
4896 break;
4897 default:
4898 spec->gpio_led_polarity = 1;
4899 break;
4900 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004901 return 1;
4902 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004903 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304904
4905 /*
4906 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004907 * we statically set the GPIO - if not a B-series system
4908 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304909 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004910 if (!hp_blike_system(codec->subsystem_id) &&
4911 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304912 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004913 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304914 return 1;
4915 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004916 }
4917 return 0;
4918}
4919
4920static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004921{
4922 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004923 case 0x103c1520:
4924 case 0x103c1521:
4925 case 0x103c1523:
4926 case 0x103c1524:
4927 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004928 case 0x103c1722:
4929 case 0x103c1723:
4930 case 0x103c1724:
4931 case 0x103c1725:
4932 case 0x103c1726:
4933 case 0x103c1727:
4934 case 0x103c1728:
4935 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004936 case 0x103c172a:
4937 case 0x103c172b:
4938 case 0x103c307e:
4939 case 0x103c307f:
4940 case 0x103c3080:
4941 case 0x103c3081:
4942 case 0x103c7007:
4943 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004944 return 1;
4945 }
4946 return 0;
4947}
4948
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004949#ifdef CONFIG_PROC_FS
4950static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4951 struct hda_codec *codec, hda_nid_t nid)
4952{
4953 if (nid == codec->afg)
4954 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4955 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4956}
4957
4958static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4959 struct hda_codec *codec,
4960 unsigned int verb)
4961{
4962 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4963 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4964}
4965
4966/* stac92hd71bxx, stac92hd73xx */
4967static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4968 struct hda_codec *codec, hda_nid_t nid)
4969{
4970 stac92hd_proc_hook(buffer, codec, nid);
4971 if (nid == codec->afg)
4972 analog_loop_proc_hook(buffer, codec, 0xfa0);
4973}
4974
4975static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4976 struct hda_codec *codec, hda_nid_t nid)
4977{
4978 if (nid == codec->afg)
4979 analog_loop_proc_hook(buffer, codec, 0xfe0);
4980}
4981
4982static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4983 struct hda_codec *codec, hda_nid_t nid)
4984{
4985 if (nid == codec->afg)
4986 analog_loop_proc_hook(buffer, codec, 0xfeb);
4987}
4988#else
4989#define stac92hd_proc_hook NULL
4990#define stac92hd7x_proc_hook NULL
4991#define stac9205_proc_hook NULL
4992#define stac927x_proc_hook NULL
4993#endif
4994
Takashi Iwai2a439522011-07-26 09:52:50 +02004995#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02004996static int stac92xx_resume(struct hda_codec *codec)
4997{
Takashi Iwai2c885872008-11-18 09:36:55 +01004998 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004999 snd_hda_codec_resume_amp(codec);
5000 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01005001 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005002 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02005003 return 0;
5004}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005005
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005006static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5007{
5008 stac92xx_shutup(codec);
5009 return 0;
5010}
5011
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005012static int stac92xx_pre_resume(struct hda_codec *codec)
5013{
5014 struct sigmatel_spec *spec = codec->spec;
5015
5016 /* sync mute LED */
Takashi Iwaif1a73742011-12-04 13:44:06 +01005017 if (spec->vref_mute_led_nid)
5018 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5019 spec->vref_led);
5020 else if (spec->gpio_led)
5021 stac_gpio_set(codec, spec->gpio_mask,
5022 spec->gpio_dir, spec->gpio_data);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005023 return 0;
5024}
5025
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005026static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5027 unsigned int power_state)
5028{
5029 unsigned int afg_power_state = power_state;
5030 struct sigmatel_spec *spec = codec->spec;
5031
5032 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005033 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005034 /* with vref-out pin used for mute led control
5035 * codec AFG is prevented from D3 state
5036 */
5037 afg_power_state = AC_PWRST_D1;
5038 }
5039 /* this delay seems necessary to avoid click noise at power-down */
5040 msleep(100);
5041 }
5042 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5043 afg_power_state);
5044 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5045}
Takashi Iwai350eba432012-03-16 16:09:03 +01005046#else
5047#define stac92xx_suspend NULL
5048#define stac92xx_resume NULL
5049#define stac92xx_pre_resume NULL
5050#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005051#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005052
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005053/* update mute-LED accoring to the master switch */
5054static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005055{
5056 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005057 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005058
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005059 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005060 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005061
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005062 /* LED state is inverted on these systems */
5063 if (spec->gpio_led_polarity)
5064 muted = !muted;
5065
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005066 /*polarity defines *not* muted state level*/
Takashi Iwaif1a73742011-12-04 13:44:06 +01005067 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005068 if (muted)
5069 spec->gpio_data &= ~spec->gpio_led; /* orange */
5070 else
5071 spec->gpio_data |= spec->gpio_led; /* white */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005072 stac_gpio_set(codec, spec->gpio_mask,
5073 spec->gpio_dir, spec->gpio_data);
5074 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005075 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005076 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5077 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005078 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005079}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05005080
Takashi Iwai2b635362011-05-02 12:33:43 +02005081static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005082 .build_controls = stac92xx_build_controls,
5083 .build_pcms = stac92xx_build_pcms,
5084 .init = stac92xx_init,
5085 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02005086 .unsol_event = stac92xx_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02005087#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005088 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005089 .resume = stac92xx_resume,
5090#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005091 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005092};
5093
5094static int patch_stac9200(struct hda_codec *codec)
5095{
5096 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005097 int err;
Matt2f2f4252005-04-13 14:45:30 +02005098
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005099 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005100 if (spec == NULL)
5101 return -ENOMEM;
5102
Takashi Iwaia252c812009-12-25 22:56:20 +01005103 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005104 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005105 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005106 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005107 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005108 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5109 stac9200_models,
5110 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005111 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005112 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5113 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005114 else
5115 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005116 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005117
5118 spec->multiout.max_channels = 2;
5119 spec->multiout.num_dacs = 1;
5120 spec->multiout.dac_nids = stac9200_dac_nids;
5121 spec->adc_nids = stac9200_adc_nids;
5122 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005123 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005124 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005125 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005126 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005127
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005128 if (spec->board_config == STAC_9200_M4 ||
5129 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005130 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005131 spec->init = stac9200_eapd_init;
5132 else
5133 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005134 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005135
Takashi Iwai117f2572008-03-18 09:53:23 +01005136 if (spec->board_config == STAC_9200_PANASONIC) {
5137 spec->gpio_mask = spec->gpio_dir = 0x09;
5138 spec->gpio_data = 0x00;
5139 }
5140
Mattc7d4b2f2005-06-27 14:59:41 +02005141 err = stac9200_parse_auto_config(codec);
5142 if (err < 0) {
5143 stac92xx_free(codec);
5144 return err;
5145 }
Matt2f2f4252005-04-13 14:45:30 +02005146
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005147 /* CF-74 has no headphone detection, and the driver should *NOT*
5148 * do detection and HP/speaker toggle because the hardware does it.
5149 */
5150 if (spec->board_config == STAC_9200_PANASONIC)
5151 spec->hp_detect = 0;
5152
Matt2f2f4252005-04-13 14:45:30 +02005153 codec->patch_ops = stac92xx_patch_ops;
5154
5155 return 0;
5156}
5157
Tobin Davis8e21c342007-01-08 11:04:17 +01005158static int patch_stac925x(struct hda_codec *codec)
5159{
5160 struct sigmatel_spec *spec;
5161 int err;
5162
5163 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5164 if (spec == NULL)
5165 return -ENOMEM;
5166
Takashi Iwaia252c812009-12-25 22:56:20 +01005167 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005168 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005169 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005170 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005171 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005172
5173 /* Check first for codec ID */
5174 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5175 STAC_925x_MODELS,
5176 stac925x_models,
5177 stac925x_codec_id_cfg_tbl);
5178
5179 /* Now checks for PCI ID, if codec ID is not found */
5180 if (spec->board_config < 0)
5181 spec->board_config = snd_hda_check_board_config(codec,
5182 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005183 stac925x_models,
5184 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005185 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005186 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005187 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5188 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005189 else
5190 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005191 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005192
5193 spec->multiout.max_channels = 2;
5194 spec->multiout.num_dacs = 1;
5195 spec->multiout.dac_nids = stac925x_dac_nids;
5196 spec->adc_nids = stac925x_adc_nids;
5197 spec->mux_nids = stac925x_mux_nids;
5198 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005199 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005200 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005201 switch (codec->vendor_id) {
5202 case 0x83847632: /* STAC9202 */
5203 case 0x83847633: /* STAC9202D */
5204 case 0x83847636: /* STAC9251 */
5205 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005206 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005207 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005208 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5209 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005210 break;
5211 default:
5212 spec->num_dmics = 0;
5213 break;
5214 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005215
5216 spec->init = stac925x_core_init;
5217 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005218 spec->num_caps = 1;
5219 spec->capvols = stac925x_capvols;
5220 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005221
Charles Chin9009b0e2011-11-03 10:27:27 +01005222 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005223 if (!err) {
5224 if (spec->board_config < 0) {
5225 printk(KERN_WARNING "hda_codec: No auto-config is "
5226 "available, default to model=ref\n");
5227 spec->board_config = STAC_925x_REF;
5228 goto again;
5229 }
5230 err = -EINVAL;
5231 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005232 if (err < 0) {
5233 stac92xx_free(codec);
5234 return err;
5235 }
5236
5237 codec->patch_ops = stac92xx_patch_ops;
5238
5239 return 0;
5240}
5241
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005242static int patch_stac92hd73xx(struct hda_codec *codec)
5243{
5244 struct sigmatel_spec *spec;
5245 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5246 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005247 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005248
5249 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5250 if (spec == NULL)
5251 return -ENOMEM;
5252
Takashi Iwaia252c812009-12-25 22:56:20 +01005253 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005254 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005255 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005256 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005257 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5258 spec->pin_nids = stac92hd73xx_pin_nids;
5259 spec->board_config = snd_hda_check_board_config(codec,
5260 STAC_92HD73XX_MODELS,
5261 stac92hd73xx_models,
5262 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005263 /* check codec subsystem id if not found */
5264 if (spec->board_config < 0)
5265 spec->board_config =
5266 snd_hda_check_board_codec_sid_config(codec,
5267 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5268 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005269again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005270 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005271 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5272 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005273 else
5274 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005275 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005276
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005277 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005278 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5279
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005280 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005281 printk(KERN_WARNING "hda_codec: Could not determine "
5282 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005283 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005284 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005285 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005286 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005287 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005288 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005289 break;
5290 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005291 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005292 break;
5293 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005294 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5295 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005296 }
5297 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005298
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005299 spec->aloopback_mask = 0x01;
5300 spec->aloopback_shift = 8;
5301
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005302 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005303 spec->mux_nids = stac92hd73xx_mux_nids;
5304 spec->adc_nids = stac92hd73xx_adc_nids;
5305 spec->dmic_nids = stac92hd73xx_dmic_nids;
5306 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005307 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005308
5309 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5310 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005311 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005312
Takashi Iwai6479c632009-07-28 18:20:25 +02005313 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5314 spec->capvols = stac92hd73xx_capvols;
5315 spec->capsws = stac92hd73xx_capsws;
5316
Matthew Ranostaya7662642008-02-21 07:51:14 +01005317 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005318 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005319 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005320 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005321 case STAC_DELL_M6_AMIC:
5322 case STAC_DELL_M6_DMIC:
5323 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005324 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005325 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005326
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005327 switch (spec->board_config) {
5328 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005329 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005330 spec->num_dmics = 0;
5331 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005332 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005333 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005334 spec->num_dmics = 1;
5335 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005336 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005337 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5338 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005339 spec->num_dmics = 1;
5340 break;
5341 }
5342 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005343 case STAC_ALIENWARE_M17X:
5344 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5345 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5346 spec->eapd_switch = 0;
5347 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005348 default:
5349 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005350 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005351 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005352 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005353 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005354 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005355 /* GPIO0 High = Enable EAPD */
5356 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5357 spec->gpio_data = 0x01;
5358 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005359
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005360 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5361 spec->pwr_nids = stac92hd73xx_pwr_nids;
5362
Charles Chin9009b0e2011-11-03 10:27:27 +01005363 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005364
5365 if (!err) {
5366 if (spec->board_config < 0) {
5367 printk(KERN_WARNING "hda_codec: No auto-config is "
5368 "available, default to model=ref\n");
5369 spec->board_config = STAC_92HD73XX_REF;
5370 goto again;
5371 }
5372 err = -EINVAL;
5373 }
5374
5375 if (err < 0) {
5376 stac92xx_free(codec);
5377 return err;
5378 }
5379
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005380 if (spec->board_config == STAC_92HD73XX_NO_JD)
5381 spec->hp_detect = 0;
5382
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005383 codec->patch_ops = stac92xx_patch_ops;
5384
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005385 codec->proc_widget_hook = stac92hd7x_proc_hook;
5386
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005387 return 0;
5388}
5389
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005390static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005391{
5392 if (codec->vendor_id != 0x111d7605 &&
5393 codec->vendor_id != 0x111d76d1)
5394 return 0;
5395
5396 switch (codec->subsystem_id) {
5397 case 0x103c1618:
5398 case 0x103c1619:
5399 case 0x103c161a:
5400 case 0x103c161b:
5401 case 0x103c161c:
5402 case 0x103c161d:
5403 case 0x103c161e:
5404 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005405
5406 case 0x103c162a:
5407 case 0x103c162b:
5408
5409 case 0x103c1630:
5410 case 0x103c1631:
5411
5412 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005413 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005414 case 0x103c1635:
5415
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005416 case 0x103c3587:
5417 case 0x103c3588:
5418 case 0x103c3589:
5419 case 0x103c358a:
5420
5421 case 0x103c3667:
5422 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005423 case 0x103c3669:
5424
5425 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005426 }
5427 return 0;
5428}
5429
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005430static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5431{
5432 struct sigmatel_spec *spec = codec->spec;
5433 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5434 int i;
5435
5436 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5437 spec->auto_pin_cnt++;
5438
5439 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5440 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5441 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5442 if (nid == stac92hd83xxx_dmic_nids[i]) {
5443 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5444 spec->auto_dmic_cnt++;
5445 }
5446 }
5447 }
5448}
5449
5450static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5451{
5452 struct sigmatel_spec *spec = codec->spec;
5453
5454 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5455 spec->auto_adc_cnt++;
5456}
5457
5458static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5459{
5460 int i, j;
5461 struct sigmatel_spec *spec = codec->spec;
5462
5463 for (i = 0; i < spec->auto_adc_cnt; i++) {
5464 if (get_connection_index(codec,
5465 spec->auto_adc_nids[i], nid) >= 0) {
5466 /* mux and volume for adc_nids[i] */
5467 if (!spec->auto_mux_nids[i]) {
5468 spec->auto_mux_nids[i] = nid;
5469 /* 92hd codecs capture volume is in mux */
5470 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5471 3, 0, HDA_OUTPUT);
5472 }
5473 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5474 if (get_connection_index(codec, nid,
5475 spec->auto_dmic_nids[j]) >= 0) {
5476 /* dmux for adc_nids[i] */
5477 if (!spec->auto_dmux_nids[i])
5478 spec->auto_dmux_nids[i] = nid;
5479 break;
5480 }
5481 }
5482 break;
5483 }
5484 }
5485}
5486
5487static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5488{
5489 hda_nid_t nid, end_nid;
5490 unsigned int wid_caps, wid_type;
5491 struct sigmatel_spec *spec = codec->spec;
5492
5493 end_nid = codec->start_nid + codec->num_nodes;
5494
5495 for (nid = codec->start_nid; nid < end_nid; nid++) {
5496 wid_caps = get_wcaps(codec, nid);
5497 wid_type = get_wcaps_type(wid_caps);
5498
5499 if (wid_type == AC_WID_PIN)
5500 stac92hd8x_add_pin(codec, nid);
5501
5502 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5503 stac92hd8x_add_adc(codec, nid);
5504 }
5505
5506 for (nid = codec->start_nid; nid < end_nid; nid++) {
5507 wid_caps = get_wcaps(codec, nid);
5508 wid_type = get_wcaps_type(wid_caps);
5509
5510 if (wid_type == AC_WID_AUD_SEL)
5511 stac92hd8x_add_mux(codec, nid);
5512 }
5513
5514 spec->pin_nids = spec->auto_pin_nids;
5515 spec->num_pins = spec->auto_pin_cnt;
5516 spec->adc_nids = spec->auto_adc_nids;
5517 spec->num_adcs = spec->auto_adc_cnt;
5518 spec->capvols = spec->auto_capvols;
5519 spec->capsws = spec->auto_capvols;
5520 spec->num_caps = spec->auto_adc_cnt;
5521 spec->mux_nids = spec->auto_mux_nids;
5522 spec->num_muxes = spec->auto_adc_cnt;
5523 spec->dmux_nids = spec->auto_dmux_nids;
5524 spec->num_dmuxes = spec->auto_adc_cnt;
5525 spec->dmic_nids = spec->auto_dmic_nids;
5526 spec->num_dmics = spec->auto_dmic_cnt;
5527}
5528
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005529static int patch_stac92hd83xxx(struct hda_codec *codec)
5530{
5531 struct sigmatel_spec *spec;
5532 int err;
5533
5534 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5535 if (spec == NULL)
5536 return -ENOMEM;
5537
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005538 if (hp_bnb2011_with_dock(codec)) {
5539 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5540 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5541 }
5542
Takashi Iwaia252c812009-12-25 22:56:20 +01005543 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005544 codec->spec = spec;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005545
5546 stac92hd8x_fill_auto_spec(codec);
5547
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01005548 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005549 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005550 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005551 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005552 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005553 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005554 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005555
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005556 spec->board_config = snd_hda_check_board_config(codec,
5557 STAC_92HD83XXX_MODELS,
5558 stac92hd83xxx_models,
5559 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005560 /* check codec subsystem id if not found */
5561 if (spec->board_config < 0)
5562 spec->board_config =
5563 snd_hda_check_board_codec_sid_config(codec,
5564 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
5565 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005566again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005567 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005568 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5569 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005570 else
5571 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005572 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005573
Takashi Iwaib4e81872009-11-18 17:20:24 +01005574 codec->patch_ops = stac92xx_patch_ops;
5575
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005576 switch (spec->board_config) {
5577 case STAC_HP_ZEPHYR:
5578 spec->init = stac92hd83xxx_hp_zephyr_init;
5579 break;
5580 }
5581
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005582 if (find_mute_led_cfg(codec, -1/*no default cfg*/))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005583 snd_printd("mute LED gpio %d polarity %d\n",
5584 spec->gpio_led,
5585 spec->gpio_led_polarity);
5586
Takashi Iwaib4e81872009-11-18 17:20:24 +01005587 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005588 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005589 spec->gpio_mask |= spec->gpio_led;
5590 spec->gpio_dir |= spec->gpio_led;
5591 spec->gpio_data |= spec->gpio_led;
5592 } else {
5593 codec->patch_ops.set_power_state =
5594 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005595 }
Takashi Iwai350eba432012-03-16 16:09:03 +01005596#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005597 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba432012-03-16 16:09:03 +01005598#endif
Takashi Iwaib4e81872009-11-18 17:20:24 +01005599 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005600
Charles Chin9009b0e2011-11-03 10:27:27 +01005601 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005602 if (!err) {
5603 if (spec->board_config < 0) {
5604 printk(KERN_WARNING "hda_codec: No auto-config is "
5605 "available, default to model=ref\n");
5606 spec->board_config = STAC_92HD83XXX_REF;
5607 goto again;
5608 }
5609 err = -EINVAL;
5610 }
5611
5612 if (err < 0) {
5613 stac92xx_free(codec);
5614 return err;
5615 }
5616
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005617 codec->proc_widget_hook = stac92hd_proc_hook;
5618
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005619 return 0;
5620}
5621
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005622static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5623 hda_nid_t dig0pin)
5624{
5625 struct sigmatel_spec *spec = codec->spec;
5626 int idx;
5627
5628 for (idx = 0; idx < spec->num_pins; idx++)
5629 if (spec->pin_nids[idx] == dig0pin)
5630 break;
5631 if ((idx + 2) >= spec->num_pins)
5632 return 0;
5633
5634 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005635 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005636 return 2;
5637
5638 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005639 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005640 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005641 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005642 return 1;
5643 else
5644 return 0;
5645}
5646
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005647/* HP dv7 bass switch - GPIO5 */
5648#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5649static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5650 struct snd_ctl_elem_value *ucontrol)
5651{
5652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5653 struct sigmatel_spec *spec = codec->spec;
5654 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5655 return 0;
5656}
5657
5658static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5659 struct snd_ctl_elem_value *ucontrol)
5660{
5661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5662 struct sigmatel_spec *spec = codec->spec;
5663 unsigned int gpio_data;
5664
5665 gpio_data = (spec->gpio_data & ~0x20) |
5666 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5667 if (gpio_data == spec->gpio_data)
5668 return 0;
5669 spec->gpio_data = gpio_data;
5670 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5671 return 1;
5672}
5673
Takashi Iwai2b635362011-05-02 12:33:43 +02005674static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5676 .info = stac_hp_bass_gpio_info,
5677 .get = stac_hp_bass_gpio_get,
5678 .put = stac_hp_bass_gpio_put,
5679};
5680
5681static int stac_add_hp_bass_switch(struct hda_codec *codec)
5682{
5683 struct sigmatel_spec *spec = codec->spec;
5684
5685 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5686 "Bass Speaker Playback Switch", 0))
5687 return -ENOMEM;
5688
5689 spec->gpio_mask |= 0x20;
5690 spec->gpio_dir |= 0x20;
5691 spec->gpio_data |= 0x20;
5692 return 0;
5693}
5694
Matthew Ranostaye035b842007-11-06 11:53:55 +01005695static int patch_stac92hd71bxx(struct hda_codec *codec)
5696{
5697 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02005698 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005699 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005700 int err = 0;
5701
5702 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5703 if (spec == NULL)
5704 return -ENOMEM;
5705
Takashi Iwaia252c812009-12-25 22:56:20 +01005706 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005707 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005708 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005709 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005710 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5711 switch (codec->vendor_id) {
5712 case 0x111d76b6:
5713 case 0x111d76b7:
5714 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5715 break;
5716 case 0x111d7603:
5717 case 0x111d7608:
5718 /* On 92HD75Bx 0x27 isn't a pin nid */
5719 spec->num_pins--;
5720 /* fallthrough */
5721 default:
5722 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5723 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005724 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005725 spec->board_config = snd_hda_check_board_config(codec,
5726 STAC_92HD71BXX_MODELS,
5727 stac92hd71bxx_models,
5728 stac92hd71bxx_cfg_tbl);
5729again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005730 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005731 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5732 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005733 else
5734 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005735 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005736
Takashi Iwaifc64b262009-09-14 15:33:01 +02005737 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005738 /* GPIO0 = EAPD */
5739 spec->gpio_mask = 0x01;
5740 spec->gpio_dir = 0x01;
5741 spec->gpio_data = 0x01;
5742 }
5743
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005744 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5745 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5746
Takashi Iwai6479c632009-07-28 18:20:25 +02005747 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5748 spec->capvols = stac92hd71bxx_capvols;
5749 spec->capsws = stac92hd71bxx_capsws;
5750
Matthew Ranostay541eee82007-12-14 12:08:04 +01005751 switch (codec->vendor_id) {
5752 case 0x111d76b6: /* 4 Port without Analog Mixer */
5753 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005754 unmute_init++;
5755 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005756 case 0x111d76b4: /* 6 Port without Analog Mixer */
5757 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005758 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005759 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005760 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005761 stac92hd71bxx_dmic_nids,
5762 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005763 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005764 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005765 switch (spec->board_config) {
5766 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005767 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai3a938972011-10-28 01:16:55 +02005768 err = stac_add_event(codec, codec->afg,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005769 STAC_VREF_EVENT, 0x02);
5770 if (err < 0)
5771 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005772 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005773 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai3a938972011-10-28 01:16:55 +02005774 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005775 spec->gpio_mask |= 0x02;
5776 break;
5777 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005778 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005779 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005780 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005781
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005782 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005783 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005784 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005785 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5786 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02005787 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005788 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005789 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005790 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005791 break;
5792 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005793 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005794 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005795
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005796 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005797 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005798 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005799 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005800 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005801 stac92hd71bxx_dmic_nids,
5802 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005803 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005804 }
5805
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005806 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5807 snd_hda_sequence_write_cache(codec, unmute_init);
5808
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005809 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005810 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005811 spec->aloopback_shift = 0;
5812
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005813 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005814 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005815 spec->mux_nids = stac92hd71bxx_mux_nids;
5816 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005817 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005818 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005819
5820 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5821 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005822 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005823 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005824
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305825 snd_printdd("Found board config: %d\n", spec->board_config);
5826
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005827 switch (spec->board_config) {
5828 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005829 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005830 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005831 stac92xx_auto_set_pinctl(codec, 0x0e,
5832 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005833 /* fallthru */
5834 case STAC_DELL_M4_2:
5835 spec->num_dmics = 0;
5836 spec->num_smuxes = 0;
5837 spec->num_dmuxes = 0;
5838 break;
5839 case STAC_DELL_M4_1:
5840 case STAC_DELL_M4_3:
5841 spec->num_dmics = 1;
5842 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005843 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005844 break;
James Gardiner514bf542009-05-03 04:00:44 -04005845 case STAC_HP_DV4_1222NR:
5846 spec->num_dmics = 1;
5847 /* I don't know if it needs 1 or 2 smuxes - will wait for
5848 * bug reports to fix if needed
5849 */
5850 spec->num_smuxes = 1;
5851 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005852 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005853 case STAC_HP_DV4:
5854 spec->gpio_led = 0x01;
5855 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005856 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005857 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005858 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005859 /* HP dv6 gives the headphone pin as a line-out. Thus we
5860 * need to set hp_detect flag here to force to enable HP
5861 * detection.
5862 */
5863 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005864 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005865 case STAC_HP_HDX:
5866 spec->num_dmics = 1;
5867 spec->num_dmuxes = 1;
5868 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005869 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005870 break;
5871 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005872
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005873 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005874 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5875 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5876 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5877 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5878 /* It was changed in the BIOS to just satisfy MS DTM.
5879 * Lets turn it back into slaved HP
5880 */
5881 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5882 | (AC_JACK_HP_OUT <<
5883 AC_DEFCFG_DEVICE_SHIFT);
5884 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5885 | AC_DEFCFG_SEQUENCE)))
5886 | 0x1f;
5887 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5888 }
5889 }
5890
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005891 if (find_mute_led_cfg(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005892 snd_printd("mute LED gpio %d polarity %d\n",
5893 spec->gpio_led,
5894 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005895
Takashi Iwai86d190e2009-05-26 15:18:58 +02005896 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005897 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005898 spec->gpio_mask |= spec->gpio_led;
5899 spec->gpio_dir |= spec->gpio_led;
5900 spec->gpio_data |= spec->gpio_led;
5901 } else {
5902 codec->patch_ops.set_power_state =
5903 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005904 }
Takashi Iwai350eba432012-03-16 16:09:03 +01005905#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005906 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba432012-03-16 16:09:03 +01005907#endif
Takashi Iwai86d190e2009-05-26 15:18:58 +02005908 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005909
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005910 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005911
Charles Chin9009b0e2011-11-03 10:27:27 +01005912 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005913 if (!err) {
5914 if (spec->board_config < 0) {
5915 printk(KERN_WARNING "hda_codec: No auto-config is "
5916 "available, default to model=ref\n");
5917 spec->board_config = STAC_92HD71BXX_REF;
5918 goto again;
5919 }
5920 err = -EINVAL;
5921 }
5922
5923 if (err < 0) {
5924 stac92xx_free(codec);
5925 return err;
5926 }
5927
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005928 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005929 if (spec->board_config == STAC_HP_DV4 ||
5930 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005931 unsigned int cap;
5932 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5933 cap &= AC_GPIO_IO_COUNT;
5934 if (cap >= 6)
5935 stac_add_hp_bass_switch(codec);
5936 }
5937
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005938 codec->proc_widget_hook = stac92hd7x_proc_hook;
5939
Matthew Ranostaye035b842007-11-06 11:53:55 +01005940 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005941}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005942
Matt2f2f4252005-04-13 14:45:30 +02005943static int patch_stac922x(struct hda_codec *codec)
5944{
5945 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005946 int err;
Matt2f2f4252005-04-13 14:45:30 +02005947
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005948 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005949 if (spec == NULL)
5950 return -ENOMEM;
5951
Takashi Iwaia252c812009-12-25 22:56:20 +01005952 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005953 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005954 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005955 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005956 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005957 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5958 stac922x_models,
5959 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005960 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005961 spec->gpio_mask = spec->gpio_dir = 0x03;
5962 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005963 /* Intel Macs have all same PCI SSID, so we need to check
5964 * codec SSID to distinguish the exact models
5965 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005966 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005967 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005968
5969 case 0x106b0800:
5970 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005971 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005972 case 0x106b0600:
5973 case 0x106b0700:
5974 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005975 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005976 case 0x106b0e00:
5977 case 0x106b0f00:
5978 case 0x106b1600:
5979 case 0x106b1700:
5980 case 0x106b0200:
5981 case 0x106b1e00:
5982 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005983 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005984 case 0x106b1a00:
5985 case 0x00000100:
5986 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005987 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005988 case 0x106b0a00:
5989 case 0x106b2200:
5990 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005991 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005992 default:
5993 spec->board_config = STAC_INTEL_MAC_V3;
5994 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005995 }
5996 }
5997
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005998 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005999 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006000 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6001 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006002 else
6003 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006004 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02006005
Matt2f2f4252005-04-13 14:45:30 +02006006 spec->adc_nids = stac922x_adc_nids;
6007 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006008 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006009 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006010 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006011 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02006012
6013 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006014
6015 spec->num_caps = STAC922X_NUM_CAPS;
6016 spec->capvols = stac922x_capvols;
6017 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02006018
6019 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02006020
Charles Chin9009b0e2011-11-03 10:27:27 +01006021 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006022 if (!err) {
6023 if (spec->board_config < 0) {
6024 printk(KERN_WARNING "hda_codec: No auto-config is "
6025 "available, default to model=ref\n");
6026 spec->board_config = STAC_D945_REF;
6027 goto again;
6028 }
6029 err = -EINVAL;
6030 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006031 if (err < 0) {
6032 stac92xx_free(codec);
6033 return err;
6034 }
6035
6036 codec->patch_ops = stac92xx_patch_ops;
6037
Takashi Iwai807a46362007-05-29 19:01:37 +02006038 /* Fix Mux capture level; max to 2 */
6039 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6040 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6041 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6042 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6043 (0 << AC_AMPCAP_MUTE_SHIFT));
6044
Matt Porter3cc08dc2006-01-23 15:27:49 +01006045 return 0;
6046}
6047
6048static int patch_stac927x(struct hda_codec *codec)
6049{
6050 struct sigmatel_spec *spec;
6051 int err;
6052
6053 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6054 if (spec == NULL)
6055 return -ENOMEM;
6056
Takashi Iwaia252c812009-12-25 22:56:20 +01006057 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006058 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006059 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006060 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006061 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006062 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006063 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6064 stac927x_models,
6065 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006066 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006067 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006068 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6069 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006070 else
6071 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006072 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006073
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006074 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006075 spec->adc_nids = stac927x_adc_nids;
6076 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6077 spec->mux_nids = stac927x_mux_nids;
6078 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006079 spec->smux_nids = stac927x_smux_nids;
6080 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006081 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006082 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006083 spec->multiout.dac_nids = spec->dac_nids;
6084
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006085 if (spec->board_config != STAC_D965_REF) {
6086 /* GPIO0 High = Enable EAPD */
6087 spec->eapd_mask = spec->gpio_mask = 0x01;
6088 spec->gpio_dir = spec->gpio_data = 0x01;
6089 }
6090
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006091 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02006092 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006093 case STAC_D965_5ST:
6094 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006095 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02006096 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006097 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006098 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006099 switch (codec->subsystem_id) {
6100 case 0x10280209:
6101 case 0x1028022e:
6102 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006103 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006104 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006105 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01006106 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01006107 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01006108 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006109 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006110 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01006111 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006112 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006113 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006114 if (codec->subsystem_id != 0x1028022f) {
6115 /* GPIO2 High = Enable EAPD */
6116 spec->eapd_mask = spec->gpio_mask = 0x04;
6117 spec->gpio_dir = spec->gpio_data = 0x04;
6118 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006119 spec->dmic_nids = stac927x_dmic_nids;
6120 spec->num_dmics = STAC927X_NUM_DMICS;
6121
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02006122 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006123 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006124 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006125 break;
Takashi Iwai54930532009-10-11 17:38:29 +02006126 case STAC_927X_VOLKNOB:
6127 spec->num_dmics = 0;
6128 spec->init = stac927x_volknob_core_init;
6129 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006130 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006131 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006132 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006133 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006134 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006135
Takashi Iwai6479c632009-07-28 18:20:25 +02006136 spec->num_caps = STAC927X_NUM_CAPS;
6137 spec->capvols = stac927x_capvols;
6138 spec->capsws = stac927x_capsws;
6139
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006140 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006141 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006142 spec->aloopback_mask = 0x40;
6143 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006144 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006145
Charles Chin9009b0e2011-11-03 10:27:27 +01006146 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006147 if (!err) {
6148 if (spec->board_config < 0) {
6149 printk(KERN_WARNING "hda_codec: No auto-config is "
6150 "available, default to model=ref\n");
6151 spec->board_config = STAC_D965_REF;
6152 goto again;
6153 }
6154 err = -EINVAL;
6155 }
Mattc7d4b2f2005-06-27 14:59:41 +02006156 if (err < 0) {
6157 stac92xx_free(codec);
6158 return err;
6159 }
Matt2f2f4252005-04-13 14:45:30 +02006160
6161 codec->patch_ops = stac92xx_patch_ops;
6162
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006163 codec->proc_widget_hook = stac927x_proc_hook;
6164
Takashi Iwai52987652008-01-16 16:09:47 +01006165 /*
6166 * !!FIXME!!
6167 * The STAC927x seem to require fairly long delays for certain
6168 * command sequences. With too short delays (even if the answer
6169 * is set to RIRB properly), it results in the silence output
6170 * on some hardwares like Dell.
6171 *
6172 * The below flag enables the longer delay (see get_response
6173 * in hda_intel.c).
6174 */
6175 codec->bus->needs_damn_long_delay = 1;
6176
Takashi Iwaie28d8322008-12-17 13:48:29 +01006177 /* no jack detecion for ref-no-jd model */
6178 if (spec->board_config == STAC_D965_REF_NO_JD)
6179 spec->hp_detect = 0;
6180
Matt2f2f4252005-04-13 14:45:30 +02006181 return 0;
6182}
6183
Matt Porterf3302a52006-07-31 12:49:34 +02006184static int patch_stac9205(struct hda_codec *codec)
6185{
6186 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006187 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006188
6189 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6190 if (spec == NULL)
6191 return -ENOMEM;
6192
Takashi Iwaia252c812009-12-25 22:56:20 +01006193 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006194 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006195 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006196 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006197 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006198 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6199 stac9205_models,
6200 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006201 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006202 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006203 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6204 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006205 else
6206 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006207 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006208
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006209 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006210 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006211 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006212 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006213 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006214 spec->smux_nids = stac9205_smux_nids;
6215 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006216 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006217 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006218 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006219 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006220 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006221
6222 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006223 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006224
Takashi Iwai6479c632009-07-28 18:20:25 +02006225 spec->num_caps = STAC9205_NUM_CAPS;
6226 spec->capvols = stac9205_capvols;
6227 spec->capsws = stac9205_capsws;
6228
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006229 spec->aloopback_mask = 0x40;
6230 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006231 /* Turn on/off EAPD per HP plugging */
6232 if (spec->board_config != STAC_9205_EAPD)
6233 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006234 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006235
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006236 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006237 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006238 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006239 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6240 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006241
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006242 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwai3a938972011-10-28 01:16:55 +02006243 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006244 if (err < 0)
6245 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006246 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006247 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
Takashi Iwai3a938972011-10-28 01:16:55 +02006248 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006249
6250 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006251 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006252 spec->gpio_mask = 0x1b;
6253 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006254 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006255 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006256 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006257 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006258 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006259 case STAC_9205_REF:
6260 /* SPDIF-In enabled */
6261 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006262 default:
6263 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006264 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006265 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006266 break;
6267 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006268
Charles Chin9009b0e2011-11-03 10:27:27 +01006269 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006270 if (!err) {
6271 if (spec->board_config < 0) {
6272 printk(KERN_WARNING "hda_codec: No auto-config is "
6273 "available, default to model=ref\n");
6274 spec->board_config = STAC_9205_REF;
6275 goto again;
6276 }
6277 err = -EINVAL;
6278 }
Matt Porterf3302a52006-07-31 12:49:34 +02006279 if (err < 0) {
6280 stac92xx_free(codec);
6281 return err;
6282 }
6283
6284 codec->patch_ops = stac92xx_patch_ops;
6285
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006286 codec->proc_widget_hook = stac9205_proc_hook;
6287
Matt Porterf3302a52006-07-31 12:49:34 +02006288 return 0;
6289}
6290
Matt2f2f4252005-04-13 14:45:30 +02006291/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006292 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006293 */
6294
Takashi Iwai2b635362011-05-02 12:33:43 +02006295static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006296 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6298 {}
6299};
6300
Takashi Iwai2b635362011-05-02 12:33:43 +02006301static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006302 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6303 0x11, 0x13, 0x14,
6304};
6305
Takashi Iwai2b635362011-05-02 12:33:43 +02006306static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006307 0x8 /*,0x6*/
6308};
6309
Takashi Iwai2b635362011-05-02 12:33:43 +02006310static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006311 0x15
6312};
6313
Takashi Iwai2b635362011-05-02 12:33:43 +02006314static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006315 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6316};
6317#define stac9872_capsws stac9872_capvols
6318
Takashi Iwai2b635362011-05-02 12:33:43 +02006319static const unsigned int stac9872_vaio_pin_configs[9] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006320 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6321 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6322 0x90a7013e
6323};
6324
Takashi Iwaiea734962011-01-17 11:29:34 +01006325static const char * const stac9872_models[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006326 [STAC_9872_AUTO] = "auto",
6327 [STAC_9872_VAIO] = "vaio",
6328};
6329
Takashi Iwai2b635362011-05-02 12:33:43 +02006330static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006331 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6332};
6333
Takashi Iwai2b635362011-05-02 12:33:43 +02006334static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006335 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6336 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006337 {} /* terminator */
6338};
6339
Guillaume Munch6d859062006-08-22 17:15:47 +02006340static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006341{
6342 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006343 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006344
Takashi Iwaidb064e52006-03-16 16:04:58 +01006345 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6346 if (spec == NULL)
6347 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006348 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006349 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006350 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006351 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6352 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006353
6354 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6355 stac9872_models,
6356 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006357 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006358 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6359 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006360 else
6361 stac92xx_set_config_regs(codec,
6362 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006363
Takashi Iwai1e137f92009-01-21 07:41:22 +01006364 spec->multiout.dac_nids = spec->dac_nids;
6365 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6366 spec->adc_nids = stac9872_adc_nids;
6367 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6368 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006369 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006370 spec->num_caps = 1;
6371 spec->capvols = stac9872_capvols;
6372 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006373
Charles Chin9009b0e2011-11-03 10:27:27 +01006374 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01006375 if (err < 0) {
6376 stac92xx_free(codec);
6377 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006378 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006379 spec->input_mux = &spec->private_imux;
6380 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006381 return 0;
6382}
6383
6384
6385/*
Matt2f2f4252005-04-13 14:45:30 +02006386 * patch entries
6387 */
Takashi Iwai2b635362011-05-02 12:33:43 +02006388static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006389 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6390 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6391 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6392 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6393 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6394 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6395 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006396 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6397 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6398 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6399 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6400 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6401 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006402 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6403 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6404 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6405 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6406 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6407 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6408 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6409 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6410 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6411 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006412 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6413 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6414 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6415 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6416 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6417 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006418 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6419 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006420 /* The following does not take into account .id=0x83847661 when subsys =
6421 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6422 * currently not fully supported.
6423 */
6424 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6425 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6426 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006427 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006428 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6429 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6430 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6431 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6432 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6433 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6434 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6435 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006436 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006437 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006438 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006439 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006440 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02006441 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6442 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006443 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6444 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6445 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6446 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006447 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006448 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6449 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006450 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006451 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6452 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6453 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6454 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6455 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6456 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6457 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6458 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02006459 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6460 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6461 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6462 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6463 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6464 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6465 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6466 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6467 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6468 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6469 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6470 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6471 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6472 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6473 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02006474 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006475 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06006476 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6477 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006478 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01006479 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6480 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6481 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6482 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6483 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6484 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6485 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6486 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6487 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6488 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6489 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6490 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02006491 {} /* terminator */
6492};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006493
6494MODULE_ALIAS("snd-hda-codec-id:8384*");
6495MODULE_ALIAS("snd-hda-codec-id:111d*");
6496
6497MODULE_LICENSE("GPL");
6498MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6499
6500static struct hda_codec_preset_list sigmatel_list = {
6501 .preset = snd_hda_preset_sigmatel,
6502 .owner = THIS_MODULE,
6503};
6504
6505static int __init patch_sigmatel_init(void)
6506{
6507 return snd_hda_add_codec_preset(&sigmatel_list);
6508}
6509
6510static void __exit patch_sigmatel_exit(void)
6511{
6512 snd_hda_delete_codec_preset(&sigmatel_list);
6513}
6514
6515module_init(patch_sigmatel_init)
6516module_exit(patch_sigmatel_exit)