blob: 21de62b7c991ddf25b9499b77ff7dec9b82cf7b8 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +010031#include <linux/dmi.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040032#include <linux/module.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020034#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040035#include <sound/jack.h>
Clemens Ladischa74ccea2010-10-22 15:52:34 +020036#include <sound/tlv.h>
Matt2f2f4252005-04-13 14:45:30 +020037#include "hda_codec.h"
38#include "hda_local.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020039#include "hda_beep.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020040#include "hda_jack.h"
Matt2f2f4252005-04-13 14:45:30 +020041
Takashi Iwaic6e4c662008-11-25 11:58:19 +010042enum {
43 STAC_VREF_EVENT = 1,
44 STAC_INSERT_EVENT,
45 STAC_PWR_EVENT,
46 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020047 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020048 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010049};
Matt4e550962005-07-04 17:51:39 +020050
Takashi Iwaif5fcc132006-11-24 17:07:44 +010051enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010052 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010053 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010054 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020055 STAC_9200_DELL_D21,
56 STAC_9200_DELL_D22,
57 STAC_9200_DELL_D23,
58 STAC_9200_DELL_M21,
59 STAC_9200_DELL_M22,
60 STAC_9200_DELL_M23,
61 STAC_9200_DELL_M24,
62 STAC_9200_DELL_M25,
63 STAC_9200_DELL_M26,
64 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020065 STAC_9200_M4,
66 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010067 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_9200_MODELS
69};
70
71enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010072 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010073 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020074 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020075 STAC_9205_DELL_M43,
76 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010077 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010078 STAC_9205_MODELS
79};
80
81enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010082 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010083 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010084 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080085 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010086 STAC_DELL_M6_AMIC,
87 STAC_DELL_M6_DMIC,
88 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050089 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020090 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010091 STAC_92HD73XX_MODELS
92};
93
94enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010095 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020096 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050097 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050098 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010099 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -0500100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -0600101 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600102 STAC_HP_ZEPHYR,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200103 STAC_92HD83XXX_MODELS
104};
105
106enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100107 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100108 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100109 STAC_DELL_M4_1,
110 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500111 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400112 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200113 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100114 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100115 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400116 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100117 STAC_92HD71BXX_MODELS
118};
119
120enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100121 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100122 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200123 STAC_M1,
124 STAC_M1_2,
125 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100126 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200127 STAC_M3,
128 STAC_M5,
129 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100130 STAC_925x_MODELS
131};
132
133enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100134 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100135 STAC_D945_REF,
136 STAC_D945GTP3,
137 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200138 STAC_INTEL_MAC_V1,
139 STAC_INTEL_MAC_V2,
140 STAC_INTEL_MAC_V3,
141 STAC_INTEL_MAC_V4,
142 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800143 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
144 * is given, one of the above models will be
145 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200146 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100147 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100148 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100149 STAC_MACBOOK_PRO_V1,
150 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200151 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200152 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300153 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200154 STAC_922X_DELL_D81,
155 STAC_922X_DELL_D82,
156 STAC_922X_DELL_M81,
157 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100158 STAC_922X_MODELS
159};
160
161enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100162 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100163 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100164 STAC_D965_REF,
165 STAC_D965_3ST,
166 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200167 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200168 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100169 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200170 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100171 STAC_927X_MODELS
172};
Matt Porter403d1942005-11-29 15:00:51 +0100173
Takashi Iwai307282c2009-03-12 18:17:58 +0100174enum {
175 STAC_9872_AUTO,
176 STAC_9872_VAIO,
177 STAC_9872_MODELS
178};
179
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200180struct sigmatel_mic_route {
181 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200182 signed char mux_idx;
183 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200184};
185
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600186#define MAX_PINS_NUM 16
187#define MAX_ADCS_NUM 4
188#define MAX_DMICS_NUM 4
189
Matt2f2f4252005-04-13 14:45:30 +0200190struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100191 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200192 unsigned int num_mixers;
193
Matt Porter403d1942005-11-29 15:00:51 +0100194 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500195 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200196 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100197 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100198 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400199 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100200 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200201 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100202 unsigned int linear_tone_beep:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200203
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100204 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200205 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100206 unsigned int gpio_mask;
207 unsigned int gpio_dir;
208 unsigned int gpio_data;
209 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200210 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100211 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100212 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500213 unsigned int vref_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100214
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200215 /* stream */
216 unsigned int stream_delay;
217
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100218 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200219 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100220 unsigned char aloopback_mask;
221 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200222
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100223 /* power management */
224 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200225 const hda_nid_t *pwr_nids;
226 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227
Matt2f2f4252005-04-13 14:45:30 +0200228 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100229 struct hda_input_mux *mono_mux;
230 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200231 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100232 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100233 hda_nid_t hp_dacs[5];
234 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200235
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100236 int volume_offset;
237
Matt2f2f4252005-04-13 14:45:30 +0200238 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200239 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200240 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200241 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200242 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200243 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200244 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200245 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100246 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200247 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200248 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200249 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200250
Takashi Iwai2b635362011-05-02 12:33:43 +0200251 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
252 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200253 unsigned int num_caps; /* number of capture volume/switch elements */
254
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200255 struct sigmatel_mic_route ext_mic;
256 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200257 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200258
Takashi Iwaiea734962011-01-17 11:29:34 +0100259 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200260
Mattdabbed62005-06-14 10:19:34 +0200261 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100262 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200263 hda_nid_t anabeep_nid;
264 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200265
Matt2f2f4252005-04-13 14:45:30 +0200266 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200267 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200268 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200269
270 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200271 const struct hda_verb *init;
272 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200273
274 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200275 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100276 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200277 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100278 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200279 struct hda_input_mux *sinput_mux;
280 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400281 unsigned int cur_amux;
282 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200283 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200284
Matt Porter403d1942005-11-29 15:00:51 +0100285 /* i/o switches */
286 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200287 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100288 hda_nid_t line_switch; /* shared line-in for input and output */
289 hda_nid_t mic_switch; /* shared mic-in for input and output */
290 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200291 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200292
Mattc7d4b2f2005-06-27 14:59:41 +0200293 struct hda_pcm pcm_rec[2]; /* PCM information */
294
295 /* dynamic controls and input_mux */
296 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200297 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200298 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200299 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200300 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100301 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600302
303 /* auto spec */
304 unsigned auto_pin_cnt;
305 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
306 unsigned auto_adc_cnt;
307 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
308 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
309 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
310 unsigned long auto_capvols[MAX_ADCS_NUM];
311 unsigned auto_dmic_cnt;
312 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100313
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100314 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200315};
316
Takashi Iwai2b635362011-05-02 12:33:43 +0200317static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200318 0x03,
319};
320
Takashi Iwai2b635362011-05-02 12:33:43 +0200321static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200322 0x0c,
323};
324
Takashi Iwai2b635362011-05-02 12:33:43 +0200325static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200326 0x02,
327};
328
Takashi Iwai2b635362011-05-02 12:33:43 +0200329static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100330 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
331 0x0f, 0x10, 0x11
332};
333
Takashi Iwai2b635362011-05-02 12:33:43 +0200334static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400335 0x26, 0,
336};
337
Takashi Iwai2b635362011-05-02 12:33:43 +0200338static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100339 0x1a, 0x1b
340};
341
342#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200343static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100344 0x13, 0x14, 0
345};
346
347#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100348
Takashi Iwai2b635362011-05-02 12:33:43 +0200349static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200350 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100351};
352
Takashi Iwai2b635362011-05-02 12:33:43 +0200353static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100354 0x20, 0x21,
355};
356
Takashi Iwai2b635362011-05-02 12:33:43 +0200357static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200358 0x22, 0x23,
359};
360
Takashi Iwai6479c632009-07-28 18:20:25 +0200361#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200362static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200363 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
364 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
365};
366#define stac92hd73xx_capsws stac92hd73xx_capvols
367
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200368#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200369
Charles Chinafef2cf2011-11-11 08:05:28 +0100370static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
371 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
372 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200373};
374
Takashi Iwai2b635362011-05-02 12:33:43 +0200375static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400376 0x1e, 0,
377};
378
Takashi Iwai2b635362011-05-02 12:33:43 +0200379static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600380 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200381};
382
Takashi Iwai2b635362011-05-02 12:33:43 +0200383static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100384 0x0a, 0x0d, 0x0f
385};
386
Takashi Iwai2b635362011-05-02 12:33:43 +0200387static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100388 0x12, 0x13,
389};
390
Takashi Iwai2b635362011-05-02 12:33:43 +0200391static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100392 0x1a, 0x1b
393};
394
Takashi Iwai2b635362011-05-02 12:33:43 +0200395static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400396 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100397};
398
Takashi Iwai2b635362011-05-02 12:33:43 +0200399static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200400 0x24, 0x25,
401};
402
Matthew Ranostaye035b842007-11-06 11:53:55 +0100403#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200404static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100405 0x18, 0x19, 0
406};
407
Takashi Iwai2b635362011-05-02 12:33:43 +0200408static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
409 0x18, 0
410};
411
412static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400413 0x22, 0
414};
415
Takashi Iwai6479c632009-07-28 18:20:25 +0200416#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200417static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200418 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
419 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
420};
421#define stac92hd71bxx_capsws stac92hd71bxx_capvols
422
Takashi Iwai2b635362011-05-02 12:33:43 +0200423static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100424 0x03,
425};
426
Takashi Iwai2b635362011-05-02 12:33:43 +0200427static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100428 0x0f,
429};
430
Takashi Iwai2b635362011-05-02 12:33:43 +0200431static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100432 0x02,
433};
434
Takashi Iwaif6e98522007-10-16 14:27:04 +0200435#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200436static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200437 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200438};
439
Takashi Iwai2b635362011-05-02 12:33:43 +0200440static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100441 0x14,
442};
443
Takashi Iwai2b635362011-05-02 12:33:43 +0200444static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200445 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
446};
Takashi Iwai2b635362011-05-02 12:33:43 +0200447static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
449};
450
Takashi Iwai2b635362011-05-02 12:33:43 +0200451static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200452 0x06, 0x07,
453};
454
Takashi Iwai2b635362011-05-02 12:33:43 +0200455static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200456 0x12, 0x13,
457};
458
Takashi Iwai6479c632009-07-28 18:20:25 +0200459#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200460static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200461 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
462 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
463};
464#define stac922x_capsws stac922x_capvols
465
Takashi Iwai2b635362011-05-02 12:33:43 +0200466static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500467 0x1f, 0,
468};
469
Takashi Iwai2b635362011-05-02 12:33:43 +0200470static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100471 0x07, 0x08, 0x09
472};
473
Takashi Iwai2b635362011-05-02 12:33:43 +0200474static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100475 0x15, 0x16, 0x17
476};
477
Takashi Iwai2b635362011-05-02 12:33:43 +0200478static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200479 0x21,
480};
481
Takashi Iwai2b635362011-05-02 12:33:43 +0200482static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100483 0x02, 0x03, 0x04, 0x05, 0x06, 0
484};
485
Takashi Iwai2b635362011-05-02 12:33:43 +0200486static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100487 0x1b,
488};
489
Matthew Ranostay7f168592007-10-18 17:38:17 +0200490#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200491static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200492 0x13, 0x14, 0
493};
494
Takashi Iwai6479c632009-07-28 18:20:25 +0200495#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200496static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200497 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
500};
Takashi Iwai2b635362011-05-02 12:33:43 +0200501static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200502 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
505};
506
Takashi Iwaiea734962011-01-17 11:29:34 +0100507static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400508 "Digital Playback", "ADAT", "Analog Mux 1",
509 "Analog Mux 2", "Analog Mux 3"
510};
511
Takashi Iwai2b635362011-05-02 12:33:43 +0200512static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200513 0x12, 0x13
514};
515
Takashi Iwai2b635362011-05-02 12:33:43 +0200516static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200517 0x19, 0x1a
518};
519
Takashi Iwai2b635362011-05-02 12:33:43 +0200520static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100521 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522};
523
Takashi Iwai2b635362011-05-02 12:33:43 +0200524static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200525 0x21,
526};
527
Takashi Iwaif6e98522007-10-16 14:27:04 +0200528#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200529static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200530 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200531};
532
Takashi Iwai6479c632009-07-28 18:20:25 +0200533#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200534static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200535 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
536 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
537};
Takashi Iwai2b635362011-05-02 12:33:43 +0200538static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200539 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
541};
542
Takashi Iwai2b635362011-05-02 12:33:43 +0200543static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200544 0x08, 0x09, 0x0d, 0x0e,
545 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200546};
547
Takashi Iwai2b635362011-05-02 12:33:43 +0200548static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100549 0x07, 0x08, 0x0a, 0x0b,
550 0x0c, 0x0d, 0x10, 0x11,
551};
552
Takashi Iwai2b635362011-05-02 12:33:43 +0200553static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200554 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
555 0x0f, 0x10, 0x11, 0x15, 0x1b,
556};
557
Takashi Iwai2b635362011-05-02 12:33:43 +0200558static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100562};
563
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500564#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200565static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500566 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
567 0x00, 0x14, 0x18, 0x19, 0x1e,
568 0x1f, 0x20, 0x27
569};
Takashi Iwai2b635362011-05-02 12:33:43 +0200570static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100571 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
572 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500573 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100574};
575
Takashi Iwai2b635362011-05-02 12:33:43 +0200576static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x10, 0x11, 0x12, 0x13,
579 0x14, 0x21, 0x22, 0x23,
580};
581
Takashi Iwai2b635362011-05-02 12:33:43 +0200582static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x14, 0x16, 0x17, 0x18,
585 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200586};
587
Matt Porter8b657272006-10-26 17:12:59 +0200588static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
590{
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct sigmatel_spec *spec = codec->spec;
593 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
594}
595
596static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
598{
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100601 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200602
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100603 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200604 return 0;
605}
606
607static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol)
609{
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100612 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200613
614 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100615 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200616}
617
Matthew Ranostayd9737752008-09-07 12:03:41 +0200618static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_info *uinfo)
620{
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 struct sigmatel_spec *spec = codec->spec;
623 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
624}
625
626static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
632
633 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
634 return 0;
635}
636
637static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_value *ucontrol)
639{
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400642 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200643 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400644 int err, val;
645 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200646
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400647 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200648 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400649 if (err < 0)
650 return err;
651
652 if (spec->spdif_mute) {
653 if (smux_idx == 0)
654 nid = spec->multiout.dig_out_nid;
655 else
656 nid = codec->slave_dig_outs[smux_idx - 1];
657 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100658 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400659 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100660 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400661 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100662 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
663 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400664 }
665 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200666}
667
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500668static int stac_vrefout_set(struct hda_codec *codec,
669 hda_nid_t nid, unsigned int new_vref)
670{
671 int error, pinctl;
672
673 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
674 pinctl = snd_hda_codec_read(codec, nid, 0,
675 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
676
677 if (pinctl < 0)
678 return pinctl;
679
680 pinctl &= 0xff;
681 pinctl &= ~AC_PINCTL_VREFEN;
682 pinctl |= (new_vref & AC_PINCTL_VREFEN);
683
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200684 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500685 if (error < 0)
686 return error;
687
688 return 1;
689}
690
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200691static unsigned int stac92xx_vref_set(struct hda_codec *codec,
692 hda_nid_t nid, unsigned int new_vref)
693{
Takashi Iwaib8621512009-06-22 08:00:10 +0200694 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200695 unsigned int pincfg;
696 pincfg = snd_hda_codec_read(codec, nid, 0,
697 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
698
699 pincfg &= 0xff;
700 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
701 pincfg |= new_vref;
702
703 if (new_vref == AC_PINCTL_VREF_HIZ)
704 pincfg |= AC_PINCTL_OUT_EN;
705 else
706 pincfg |= AC_PINCTL_IN_EN;
707
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200708 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200709 if (error < 0)
710 return error;
711 else
712 return 1;
713}
714
715static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
716{
717 unsigned int vref;
718 vref = snd_hda_codec_read(codec, nid, 0,
719 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
720 vref &= AC_PINCTL_VREFEN;
721 return vref;
722}
723
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100724static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200725{
726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
727 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200728 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200729}
730
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100731static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200732{
733 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
734 struct sigmatel_spec *spec = codec->spec;
735 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
736
737 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
738 return 0;
739}
740
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100741static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200742{
743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
744 struct sigmatel_spec *spec = codec->spec;
745 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200746 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600747 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200748
Takashi Iwai5207e102009-07-30 13:09:08 +0200749 idx = ucontrol->value.enumerated.item[0];
750 if (idx >= imux->num_items)
751 idx = imux->num_items - 1;
752 prev_idx = spec->cur_mux[adc_idx];
753 if (prev_idx == idx)
754 return 0;
755 if (idx < spec->num_analog_muxes) {
756 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
757 AC_VERB_SET_CONNECT_SEL,
758 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600759 if (prev_idx >= spec->num_analog_muxes &&
760 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200761 imux = spec->dinput_mux;
762 /* 0 = analog */
763 snd_hda_codec_write_cache(codec,
764 spec->dmux_nids[adc_idx], 0,
765 AC_VERB_SET_CONNECT_SEL,
766 imux->items[0].index);
767 }
768 } else {
769 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600770 /* first dimux item is hardcoded to select analog imux,
771 * so lets skip it
772 */
773 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200774 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
775 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600776 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200777 }
778 spec->cur_mux[adc_idx] = idx;
779 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200780}
781
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100782static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
783 struct snd_ctl_elem_info *uinfo)
784{
785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
786 struct sigmatel_spec *spec = codec->spec;
787 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
788}
789
790static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_value *ucontrol)
792{
793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
794 struct sigmatel_spec *spec = codec->spec;
795
796 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
797 return 0;
798}
799
800static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
801 struct snd_ctl_elem_value *ucontrol)
802{
803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
804 struct sigmatel_spec *spec = codec->spec;
805
806 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
807 spec->mono_nid, &spec->cur_mmux);
808}
809
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200810#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
811
812static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
813 struct snd_ctl_elem_value *ucontrol)
814{
815 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100816 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200817 struct sigmatel_spec *spec = codec->spec;
818
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100819 ucontrol->value.integer.value[0] = !!(spec->aloopback &
820 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200821 return 0;
822}
823
824static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
825 struct snd_ctl_elem_value *ucontrol)
826{
827 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
828 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100829 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200830 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100831 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200832
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 idx_val = spec->aloopback_mask << idx;
834 if (ucontrol->value.integer.value[0])
835 val = spec->aloopback | idx_val;
836 else
837 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100838 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200839 return 0;
840
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100841 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200842
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100843 /* Only return the bits defined by the shift value of the
844 * first two bytes of the mask
845 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200846 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100847 kcontrol->private_value & 0xFFFF, 0x0);
848 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200849
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100850 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200851 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100852 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853 } else {
854 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100855 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200856 }
857
858 snd_hda_codec_write_cache(codec, codec->afg, 0,
859 kcontrol->private_value >> 16, dac_mode);
860
861 return 1;
862}
863
Takashi Iwai2b635362011-05-02 12:33:43 +0200864static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200865 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200866 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200867 {}
868};
869
Takashi Iwai2b635362011-05-02 12:33:43 +0200870static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200871 /* set dac0mux for dac converter */
872 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
873 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
874 {}
875};
876
Takashi Iwai2b635362011-05-02 12:33:43 +0200877static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100878 /* set master volume to max value without distortion
879 * and direct control */
880 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100881 {}
882};
883
Takashi Iwai2b635362011-05-02 12:33:43 +0200884static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100885 /* set master volume and direct control */
886 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100887 {}
888};
889
Takashi Iwai2b635362011-05-02 12:33:43 +0200890static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200891 /* power state controls amps */
892 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200893 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200894};
895
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600896static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
897 { 0x22, 0x785, 0x43 },
898 { 0x22, 0x782, 0xe0 },
899 { 0x22, 0x795, 0x00 },
900 {}
901};
902
Takashi Iwai2b635362011-05-02 12:33:43 +0200903static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100904 /* set master volume and direct control */
905 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200906 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100907};
908
Takashi Iwai2b635362011-05-02 12:33:43 +0200909static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500910 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
911 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100912 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
913 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100914 {}
915};
916
Takashi Iwai2b635362011-05-02 12:33:43 +0200917static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100918 /* set dac0mux for dac converter */
919 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100920 /* mute the master volume */
921 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100922 {}
923};
924
Takashi Iwai2b635362011-05-02 12:33:43 +0200925static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200926 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200927 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200928 {}
929};
930
Takashi Iwai2b635362011-05-02 12:33:43 +0200931static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200932 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200933 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200934 /* unmute node 0x1b */
935 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
936 /* select node 0x03 as DAC */
937 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
938 {}
939};
940
Takashi Iwai2b635362011-05-02 12:33:43 +0200941static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200942 /* don't set delta bit */
943 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
944 /* unmute node 0x1b */
945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
946 /* select node 0x03 as DAC */
947 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
948 {}
949};
950
Takashi Iwai2b635362011-05-02 12:33:43 +0200951static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100952 /* set master volume and direct control */
953 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200954 /* enable analog pc beep path */
955 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100956 {}
957};
958
Takashi Iwai2b635362011-05-02 12:33:43 +0200959static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200960 /* don't set delta bit */
961 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
962 /* enable analog pc beep path */
963 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
964 {}
965};
966
Takashi Iwai2b635362011-05-02 12:33:43 +0200967static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200968 /* set master volume and direct control */
969 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200970 /* enable analog pc beep path */
971 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200972 {}
973};
974
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100975#define STAC_MONO_MUX \
976 { \
977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
978 .name = "Mono Mux", \
979 .count = 1, \
980 .info = stac92xx_mono_mux_enum_info, \
981 .get = stac92xx_mono_mux_enum_get, \
982 .put = stac92xx_mono_mux_enum_put, \
983 }
984
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100985#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200986 { \
987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
988 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100989 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200990 .info = stac92xx_aloopback_info, \
991 .get = stac92xx_aloopback_get, \
992 .put = stac92xx_aloopback_put, \
993 .private_value = verb_read | (verb_write << 16), \
994 }
995
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200996#define DC_BIAS(xname, idx, nid) \
997 { \
998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
999 .name = xname, \
1000 .index = idx, \
1001 .info = stac92xx_dc_bias_info, \
1002 .get = stac92xx_dc_bias_get, \
1003 .put = stac92xx_dc_bias_put, \
1004 .private_value = nid, \
1005 }
1006
Takashi Iwai2b635362011-05-02 12:33:43 +02001007static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001008 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1009 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001010 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001012 { } /* end */
1013};
1014
Takashi Iwai2b635362011-05-02 12:33:43 +02001015static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001016 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1017 {}
1018};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001019
Takashi Iwai2b635362011-05-02 12:33:43 +02001020static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001021 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1022 {}
1023};
1024
Takashi Iwai2b635362011-05-02 12:33:43 +02001025static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001026 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1027 {}
1028};
1029
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001030
Takashi Iwai2b635362011-05-02 12:33:43 +02001031static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001032 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1033};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001034
Takashi Iwai2b635362011-05-02 12:33:43 +02001035static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001036 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1037 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001038 { } /* end */
1039};
1040
Takashi Iwai2b635362011-05-02 12:33:43 +02001041static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001042 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1043 {}
1044};
1045
Takashi Iwai2b635362011-05-02 12:33:43 +02001046static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001047 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1048 {}
1049};
1050
Takashi Iwai1697055e2007-12-18 18:05:52 +01001051static struct snd_kcontrol_new stac_dmux_mixer = {
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1053 .name = "Digital Input Source",
1054 /* count set later */
1055 .info = stac92xx_dmux_enum_info,
1056 .get = stac92xx_dmux_enum_get,
1057 .put = stac92xx_dmux_enum_put,
1058};
1059
Matthew Ranostayd9737752008-09-07 12:03:41 +02001060static struct snd_kcontrol_new stac_smux_mixer = {
1061 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001062 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001063 /* count set later */
1064 .info = stac92xx_smux_enum_info,
1065 .get = stac92xx_smux_enum_get,
1066 .put = stac92xx_smux_enum_put,
1067};
1068
Takashi Iwai9322ca52012-02-03 14:28:01 +01001069static const char * const slave_pfxs[] = {
1070 "Front", "Surround", "Center", "LFE", "Side",
1071 "Headphone", "Speaker", "IEC958",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001072 NULL
1073};
1074
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001075static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1076
1077static void stac92xx_vmaster_hook(void *private_data, int val)
1078{
1079 stac92xx_update_led_status(private_data, val);
1080}
1081
Takashi Iwai603c4012008-07-30 15:01:44 +02001082static void stac92xx_free_kctls(struct hda_codec *codec);
1083
Matt2f2f4252005-04-13 14:45:30 +02001084static int stac92xx_build_controls(struct hda_codec *codec)
1085{
1086 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001087 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001088 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001089 int i;
Matt2f2f4252005-04-13 14:45:30 +02001090
Takashi Iwai6479c632009-07-28 18:20:25 +02001091 if (spec->mixer) {
1092 err = snd_hda_add_new_ctls(codec, spec->mixer);
1093 if (err < 0)
1094 return err;
1095 }
Mattc7d4b2f2005-06-27 14:59:41 +02001096
1097 for (i = 0; i < spec->num_mixers; i++) {
1098 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1099 if (err < 0)
1100 return err;
1101 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001102 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1103 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001104 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001105 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001106 snd_ctl_new1(&stac_dmux_mixer, codec));
1107 if (err < 0)
1108 return err;
1109 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001110 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001111 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1112 struct hda_input_mux *smux = &spec->private_smux;
1113 /* check for mute support on SPDIF out */
1114 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001115 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001116 spec->spdif_mute = 1;
1117 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001118 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001119 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001120 snd_ctl_new1(&stac_smux_mixer, codec));
1121 if (err < 0)
1122 return err;
1123 }
Mattc7d4b2f2005-06-27 14:59:41 +02001124
Mattdabbed62005-06-14 10:19:34 +02001125 if (spec->multiout.dig_out_nid) {
Stephen Warren74b654c2011-06-01 11:14:18 -06001126 err = snd_hda_create_spdif_out_ctls(codec,
1127 spec->multiout.dig_out_nid,
1128 spec->multiout.dig_out_nid);
Mattdabbed62005-06-14 10:19:34 +02001129 if (err < 0)
1130 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001131 err = snd_hda_create_spdif_share_sw(codec,
1132 &spec->multiout);
1133 if (err < 0)
1134 return err;
1135 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001136 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001137 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001138 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1139 if (err < 0)
1140 return err;
1141 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001142
1143 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001144 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1145 HDA_OUTPUT, vmaster_tlv);
1146 /* correct volume offset */
1147 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1148 /* minimum value is actually mute */
1149 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1150 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1151 vmaster_tlv, slave_pfxs,
1152 "Playback Volume");
1153 if (err < 0)
1154 return err;
1155
1156 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1157 NULL, slave_pfxs,
1158 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001159 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001160 if (err < 0)
1161 return err;
1162
1163 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001164 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001165 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001166 if (err < 0)
1167 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001168 }
1169
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001170 if (spec->aloopback_ctl &&
1171 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1172 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1173 if (err < 0)
1174 return err;
1175 }
1176
Takashi Iwai603c4012008-07-30 15:01:44 +02001177 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001178
Takashi Iwai01a61e12011-10-28 00:03:22 +02001179 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1180 if (err < 0)
1181 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001182
Mattdabbed62005-06-14 10:19:34 +02001183 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001184}
1185
Takashi Iwai2b635362011-05-02 12:33:43 +02001186static const unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001187 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001188 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1189};
1190
Takashi Iwai2b635362011-05-02 12:33:43 +02001191static const unsigned int gateway9200_m4_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001192 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1193 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1194};
Takashi Iwai2b635362011-05-02 12:33:43 +02001195static const unsigned int gateway9200_m4_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001196 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1197 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1198};
1199
1200/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001201 STAC 9200 pin configs for
1202 102801A8
1203 102801DE
1204 102801E8
1205*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001206static const unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001207 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1208 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001209};
1210
1211/*
1212 STAC 9200 pin configs for
1213 102801C0
1214 102801C1
1215*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001216static const unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001217 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1218 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001219};
1220
1221/*
1222 STAC 9200 pin configs for
1223 102801C4 (Dell Dimension E310)
1224 102801C5
1225 102801C7
1226 102801D9
1227 102801DA
1228 102801E3
1229*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001230static const unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001231 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1232 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001233};
1234
1235
1236/*
1237 STAC 9200-32 pin configs for
1238 102801B5 (Dell Inspiron 630m)
1239 102801D8 (Dell Inspiron 640m)
1240*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001241static const unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001242 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1243 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001244};
1245
1246/*
1247 STAC 9200-32 pin configs for
1248 102801C2 (Dell Latitude D620)
1249 102801C8
1250 102801CC (Dell Latitude D820)
1251 102801D4
1252 102801D6
1253*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001254static const unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001255 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1256 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001257};
1258
1259/*
1260 STAC 9200-32 pin configs for
1261 102801CE (Dell XPS M1710)
1262 102801CF (Dell Precision M90)
1263*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001264static const unsigned int dell9200_m23_pin_configs[8] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001265 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1266 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1267};
1268
1269/*
1270 STAC 9200-32 pin configs for
1271 102801C9
1272 102801CA
1273 102801CB (Dell Latitude 120L)
1274 102801D3
1275*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001276static const unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001277 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1278 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001279};
1280
1281/*
1282 STAC 9200-32 pin configs for
1283 102801BD (Dell Inspiron E1505n)
1284 102801EE
1285 102801EF
1286*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001287static const unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001288 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1289 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001290};
1291
1292/*
1293 STAC 9200-32 pin configs for
1294 102801F5 (Dell Inspiron 1501)
1295 102801F6
1296*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001297static const unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001298 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1299 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001300};
1301
1302/*
1303 STAC 9200-32
1304 102801CD (Dell Inspiron E1705/9400)
1305*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001306static const unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001307 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1308 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001309};
1310
Takashi Iwai2b635362011-05-02 12:33:43 +02001311static const unsigned int oqo9200_pin_configs[8] = {
Tobin Davisbf277782008-02-03 20:31:47 +01001312 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1313 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1314};
1315
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001316
Takashi Iwai2b635362011-05-02 12:33:43 +02001317static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001318 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001319 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001320 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1321 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1322 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1323 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1324 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1325 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1326 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1327 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1328 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1329 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001330 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1331 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001332 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001333};
1334
Takashi Iwaiea734962011-01-17 11:29:34 +01001335static const char * const stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001336 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001337 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001338 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001339 [STAC_9200_DELL_D21] = "dell-d21",
1340 [STAC_9200_DELL_D22] = "dell-d22",
1341 [STAC_9200_DELL_D23] = "dell-d23",
1342 [STAC_9200_DELL_M21] = "dell-m21",
1343 [STAC_9200_DELL_M22] = "dell-m22",
1344 [STAC_9200_DELL_M23] = "dell-m23",
1345 [STAC_9200_DELL_M24] = "dell-m24",
1346 [STAC_9200_DELL_M25] = "dell-m25",
1347 [STAC_9200_DELL_M26] = "dell-m26",
1348 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001349 [STAC_9200_M4] = "gateway-m4",
1350 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001351 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001352};
1353
Takashi Iwai2b635362011-05-02 12:33:43 +02001354static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001355 /* SigmaTel reference board */
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1357 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001358 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1359 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001360 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1362 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1366 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1368 "unknown Dell", STAC_9200_DELL_D22),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1370 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001372 "Dell Latitude D620", STAC_9200_DELL_M22),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1374 "unknown Dell", STAC_9200_DELL_D23),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1376 "unknown Dell", STAC_9200_DELL_D23),
1377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1378 "unknown Dell", STAC_9200_DELL_M22),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1380 "unknown Dell", STAC_9200_DELL_M24),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1382 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001384 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001386 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001388 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001392 "Dell Precision M90", STAC_9200_DELL_M23),
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1394 "unknown Dell", STAC_9200_DELL_M22),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1396 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001400 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1402 "unknown Dell", STAC_9200_DELL_D23),
1403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1404 "unknown Dell", STAC_9200_DELL_D23),
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1406 "unknown Dell", STAC_9200_DELL_D21),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1408 "unknown Dell", STAC_9200_DELL_D23),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1410 "unknown Dell", STAC_9200_DELL_D21),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1412 "unknown Dell", STAC_9200_DELL_M25),
1413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1414 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001416 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1418 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001419 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001420 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001421 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001422 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1423 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1424 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001425 /* OQO Mobile */
1426 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001427 {} /* terminator */
1428};
1429
Takashi Iwai2b635362011-05-02 12:33:43 +02001430static const unsigned int ref925x_pin_configs[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001431 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001432 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001433};
1434
Takashi Iwai2b635362011-05-02 12:33:43 +02001435static const unsigned int stac925xM1_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001436 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1437 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001438};
1439
Takashi Iwai2b635362011-05-02 12:33:43 +02001440static const unsigned int stac925xM1_2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001441 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1442 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1443};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001444
Takashi Iwai2b635362011-05-02 12:33:43 +02001445static const unsigned int stac925xM2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001446 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1447 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001448};
1449
Takashi Iwai2b635362011-05-02 12:33:43 +02001450static const unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001451 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1452 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1453};
1454
Takashi Iwai2b635362011-05-02 12:33:43 +02001455static const unsigned int stac925xM3_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001456 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1457 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1458};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001459
Takashi Iwai2b635362011-05-02 12:33:43 +02001460static const unsigned int stac925xM5_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001461 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1462 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1463};
1464
Takashi Iwai2b635362011-05-02 12:33:43 +02001465static const unsigned int stac925xM6_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001466 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1467 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001468};
1469
Takashi Iwai2b635362011-05-02 12:33:43 +02001470static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001471 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001472 [STAC_M1] = stac925xM1_pin_configs,
1473 [STAC_M1_2] = stac925xM1_2_pin_configs,
1474 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001475 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001476 [STAC_M3] = stac925xM3_pin_configs,
1477 [STAC_M5] = stac925xM5_pin_configs,
1478 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001479};
1480
Takashi Iwaiea734962011-01-17 11:29:34 +01001481static const char * const stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001482 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001483 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001484 [STAC_M1] = "m1",
1485 [STAC_M1_2] = "m1-2",
1486 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001487 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001488 [STAC_M3] = "m3",
1489 [STAC_M5] = "m5",
1490 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001491};
1492
Takashi Iwai2b635362011-05-02 12:33:43 +02001493static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001494 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1495 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1496 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1497 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001498 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001499 /* Not sure about the brand name for those */
1500 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1501 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1502 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1503 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001504 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001505};
1506
Takashi Iwai2b635362011-05-02 12:33:43 +02001507static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001508 /* SigmaTel reference board */
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001510 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001511 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001512
1513 /* Default table for unknown ID */
1514 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1515
Tobin Davis8e21c342007-01-08 11:04:17 +01001516 {} /* terminator */
1517};
1518
Takashi Iwai2b635362011-05-02 12:33:43 +02001519static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001520 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1521 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1522 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001523 0x01452050,
1524};
1525
Takashi Iwai2b635362011-05-02 12:33:43 +02001526static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001527 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001528 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001529 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1530 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001531};
1532
Takashi Iwai2b635362011-05-02 12:33:43 +02001533static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001534 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1535 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1536 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1537 0x904601b0,
1538};
1539
Takashi Iwai2b635362011-05-02 12:33:43 +02001540static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001541 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001542 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001543};
1544
Takashi Iwai2b635362011-05-02 12:33:43 +02001545static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001546 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001547 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1548 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1549 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001550 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001551 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001552 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001553};
1554
Takashi Iwaiea734962011-01-17 11:29:34 +01001555static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001556 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001557 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001558 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001559 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001560 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1561 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1562 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001563 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001564 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001565};
1566
Takashi Iwai2b635362011-05-02 12:33:43 +02001567static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001568 /* SigmaTel reference board */
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001570 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001571 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1572 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1574 "Intel DG45ID", STAC_92HD73XX_INTEL),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1576 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001578 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001580 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001582 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001584 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001586 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001588 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001590 "unknown Dell", STAC_DELL_M6_DMIC),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1592 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001594 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1596 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1598 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1600 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001602 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001604 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001605 {} /* terminator */
1606};
1607
Takashi Iwai2b635362011-05-02 12:33:43 +02001608static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1610 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1612 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001614 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001615 {} /* terminator */
1616};
1617
Takashi Iwai2b635362011-05-02 12:33:43 +02001618static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001619 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1620 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001621 0x01451160, 0x98560170,
1622};
1623
Takashi Iwai2b635362011-05-02 12:33:43 +02001624static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001625 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1626 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001627 0x40f000f0, 0x40f000f0,
1628};
1629
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001630static const unsigned int dell_vostro_3500_pin_configs[10] = {
1631 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1632 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1633 0x400000f4, 0x400000f5,
1634};
1635
Takashi Iwai2b635362011-05-02 12:33:43 +02001636static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001637 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1638 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1639 0x40f000f0, 0x40f000f0,
1640};
1641
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001642static const unsigned int hp_zephyr_pin_configs[10] = {
1643 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1644 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1645 0, 0,
1646};
1647
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001648static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1649 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1650 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1651 0x40f000f0, 0x40f000f0,
1652};
1653
Takashi Iwai2b635362011-05-02 12:33:43 +02001654static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001655 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001656 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001657 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001658 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001659 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001660 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001661 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001662};
1663
Takashi Iwaiea734962011-01-17 11:29:34 +01001664static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001665 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001666 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001667 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001668 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001669 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001670 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001671 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001672 [STAC_HP_ZEPHYR] = "hp-zephyr",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001673};
1674
Takashi Iwai2b635362011-05-02 12:33:43 +02001675static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001676 /* SigmaTel reference board */
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001678 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001679 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1680 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1682 "unknown Dell", STAC_DELL_S14),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1684 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001685 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1686 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1688 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1690 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1692 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1694 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1696 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1698 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1700 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1702 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1704 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1706 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1708 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1710 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1712 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1714 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1716 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1718 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1720 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1722 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1724 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001725 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1726 "HP", STAC_HP_ZEPHYR),
1727 {} /* terminator */
1728};
1729
1730static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1732 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001733 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001734};
1735
Takashi Iwai2b635362011-05-02 12:33:43 +02001736static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001737 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001738 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001739 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1740 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001741};
1742
Takashi Iwai2b635362011-05-02 12:33:43 +02001743static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001744 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001745 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001746 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1747 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001748};
1749
Takashi Iwai2b635362011-05-02 12:33:43 +02001750static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001751 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1752 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001753 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1754 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001755};
1756
Takashi Iwai2b635362011-05-02 12:33:43 +02001757static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001758 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1759 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001760 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1761 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001762};
1763
Takashi Iwai2b635362011-05-02 12:33:43 +02001764static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001765 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001766 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1767 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001768 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001769 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001770 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001771 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001772 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001773 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001774};
1775
Takashi Iwaiea734962011-01-17 11:29:34 +01001776static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001777 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001778 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001779 [STAC_DELL_M4_1] = "dell-m4-1",
1780 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001781 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001782 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001783 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001784 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001785 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001786 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001787};
1788
Takashi Iwai2b635362011-05-02 12:33:43 +02001789static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001790 /* SigmaTel reference board */
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1792 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001793 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1794 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001795 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1796 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001797 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1798 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001799 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1800 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001801 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001802 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001803 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1804 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001805 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1806 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001808 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001810 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001811 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1812 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301813 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1814 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11001815 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1816 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001817 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1818 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1820 "unknown Dell", STAC_DELL_M4_1),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1822 "unknown Dell", STAC_DELL_M4_1),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1824 "unknown Dell", STAC_DELL_M4_1),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1830 "unknown Dell", STAC_DELL_M4_1),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1832 "unknown Dell", STAC_DELL_M4_1),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1834 "unknown Dell", STAC_DELL_M4_2),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1836 "unknown Dell", STAC_DELL_M4_2),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1838 "unknown Dell", STAC_DELL_M4_2),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1840 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1842 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001843 {} /* terminator */
1844};
1845
Takashi Iwai2b635362011-05-02 12:33:43 +02001846static const unsigned int ref922x_pin_configs[10] = {
Matt Porter403d1942005-11-29 15:00:51 +01001847 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1848 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001849 0x40000100, 0x40000100,
1850};
1851
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001852/*
1853 STAC 922X pin configs for
1854 102801A7
1855 102801AB
1856 102801A9
1857 102801D1
1858 102801D2
1859*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001860static const unsigned int dell_922x_d81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001861 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1862 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1863 0x01813122, 0x400001f2,
1864};
1865
1866/*
1867 STAC 922X pin configs for
1868 102801AC
1869 102801D0
1870*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001871static const unsigned int dell_922x_d82_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001872 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1873 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1874 0x01813122, 0x400001f1,
1875};
1876
1877/*
1878 STAC 922X pin configs for
1879 102801BF
1880*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001881static const unsigned int dell_922x_m81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001882 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1883 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1884 0x40C003f1, 0x405003f0,
1885};
1886
1887/*
1888 STAC 9221 A1 pin configs for
1889 102801D7 (Dell XPS M1210)
1890*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001891static const unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001892 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1893 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001894 0x508003f3, 0x405003f4,
1895};
1896
Takashi Iwai2b635362011-05-02 12:33:43 +02001897static const unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001898 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001899 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1900 0x02a19120, 0x40000100,
1901};
1902
Takashi Iwai2b635362011-05-02 12:33:43 +02001903static const unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001904 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1905 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001906 0x02a19320, 0x40000100,
1907};
1908
Takashi Iwai2b635362011-05-02 12:33:43 +02001909static const unsigned int intel_mac_v1_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001910 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1911 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001912 0x400000fc, 0x400000fb,
1913};
1914
Takashi Iwai2b635362011-05-02 12:33:43 +02001915static const unsigned int intel_mac_v2_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001916 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1917 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001918 0x400000fc, 0x400000fb,
1919};
1920
Takashi Iwai2b635362011-05-02 12:33:43 +02001921static const unsigned int intel_mac_v3_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001922 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1923 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1924 0x400000fc, 0x400000fb,
1925};
1926
Takashi Iwai2b635362011-05-02 12:33:43 +02001927static const unsigned int intel_mac_v4_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001928 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1929 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1930 0x400000fc, 0x400000fb,
1931};
1932
Takashi Iwai2b635362011-05-02 12:33:43 +02001933static const unsigned int intel_mac_v5_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001934 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1935 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1936 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001937};
1938
Takashi Iwai2b635362011-05-02 12:33:43 +02001939static const unsigned int ecs202_pin_configs[10] = {
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001940 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1941 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1942 0x9037012e, 0x40e000f2,
1943};
Takashi Iwai76c08822007-06-19 12:17:42 +02001944
Takashi Iwai2b635362011-05-02 12:33:43 +02001945static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001946 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001947 [STAC_D945GTP3] = d945gtp3_pin_configs,
1948 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001949 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1950 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1951 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1952 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1953 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001954 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001955 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001956 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1957 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1958 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1959 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1960 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1961 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001962 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001963 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1964 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1965 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1966 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001967};
1968
Takashi Iwaiea734962011-01-17 11:29:34 +01001969static const char * const stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001970 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001971 [STAC_D945_REF] = "ref",
1972 [STAC_D945GTP5] = "5stack",
1973 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001974 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1975 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1976 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1977 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1978 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001979 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001980 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001981 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001982 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001983 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1984 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001985 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001986 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001987 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001988 [STAC_922X_DELL_D81] = "dell-d81",
1989 [STAC_922X_DELL_D82] = "dell-d82",
1990 [STAC_922X_DELL_M81] = "dell-m81",
1991 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001992};
1993
Takashi Iwai2b635362011-05-02 12:33:43 +02001994static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001995 /* SigmaTel reference board */
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1997 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001998 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1999 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002000 /* Intel 945G based systems */
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2002 "Intel D945G", STAC_D945GTP3),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2004 "Intel D945G", STAC_D945GTP3),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2006 "Intel D945G", STAC_D945GTP3),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2008 "Intel D945G", STAC_D945GTP3),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2010 "Intel D945G", STAC_D945GTP3),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2012 "Intel D945G", STAC_D945GTP3),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2014 "Intel D945G", STAC_D945GTP3),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2016 "Intel D945G", STAC_D945GTP3),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2018 "Intel D945G", STAC_D945GTP3),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2020 "Intel D945G", STAC_D945GTP3),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2022 "Intel D945G", STAC_D945GTP3),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2024 "Intel D945G", STAC_D945GTP3),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2026 "Intel D945G", STAC_D945GTP3),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2028 "Intel D945G", STAC_D945GTP3),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2030 "Intel D945G", STAC_D945GTP3),
2031 /* Intel D945G 5-stack systems */
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2033 "Intel D945G", STAC_D945GTP5),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2035 "Intel D945G", STAC_D945GTP5),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2037 "Intel D945G", STAC_D945GTP5),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2039 "Intel D945G", STAC_D945GTP5),
2040 /* Intel 945P based systems */
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2042 "Intel D945P", STAC_D945GTP3),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2044 "Intel D945P", STAC_D945GTP3),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2046 "Intel D945P", STAC_D945GTP3),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2048 "Intel D945P", STAC_D945GTP3),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2050 "Intel D945P", STAC_D945GTP3),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2052 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002053 /* other intel */
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2055 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002056 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002057 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002058 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002059 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002060 /* Dell systems */
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2062 "unknown Dell", STAC_922X_DELL_D81),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2064 "unknown Dell", STAC_922X_DELL_D81),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2066 "unknown Dell", STAC_922X_DELL_D81),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2068 "unknown Dell", STAC_922X_DELL_D82),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2070 "unknown Dell", STAC_922X_DELL_M81),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2072 "unknown Dell", STAC_922X_DELL_D82),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2074 "unknown Dell", STAC_922X_DELL_D81),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2076 "unknown Dell", STAC_922X_DELL_D81),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2078 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002079 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002080 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002081 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002082 {} /* terminator */
2083};
2084
Takashi Iwai2b635362011-05-02 12:33:43 +02002085static const unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002086 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2087 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2088 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2089 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002090};
2091
Takashi Iwai2b635362011-05-02 12:33:43 +02002092static const unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002093 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2094 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2095 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2096 0x40000100, 0x40000100
2097};
2098
Takashi Iwai2b635362011-05-02 12:33:43 +02002099static const unsigned int d965_5st_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002100 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2101 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2102 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2103 0x40000100, 0x40000100
2104};
2105
Takashi Iwai2b635362011-05-02 12:33:43 +02002106static const unsigned int d965_5st_no_fp_pin_configs[14] = {
Takashi Iwai679d92e2009-05-24 19:00:08 +02002107 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2108 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2109 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2110 0x40000100, 0x40000100
2111};
2112
Takashi Iwai2b635362011-05-02 12:33:43 +02002113static const unsigned int dell_3st_pin_configs[14] = {
Tobin Davis4ff076e2007-08-07 11:48:12 +02002114 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2115 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002116 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002117 0x40c003fc, 0x40000100
2118};
2119
Takashi Iwai2b635362011-05-02 12:33:43 +02002120static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002121 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002122 [STAC_D965_REF] = ref927x_pin_configs,
2123 [STAC_D965_3ST] = d965_3st_pin_configs,
2124 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002125 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002126 [STAC_DELL_3ST] = dell_3st_pin_configs,
2127 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002128 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002129};
2130
Takashi Iwaiea734962011-01-17 11:29:34 +01002131static const char * const stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002132 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002133 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002134 [STAC_D965_REF] = "ref",
2135 [STAC_D965_3ST] = "3stack",
2136 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002137 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002138 [STAC_DELL_3ST] = "dell-3stack",
2139 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002140 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002141};
2142
Takashi Iwai2b635362011-05-02 12:33:43 +02002143static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002144 /* SigmaTel reference board */
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2146 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002147 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2148 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002149 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002152 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002153 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2154 "Intel D965", STAC_D965_3ST),
2155 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2156 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002157 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002161 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002171 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002172 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2173 "Intel D965", STAC_D965_5ST),
2174 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2175 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002176 /* volume-knob fixes */
2177 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002178 {} /* terminator */
2179};
2180
Takashi Iwai2b635362011-05-02 12:33:43 +02002181static const unsigned int ref9205_pin_configs[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +02002182 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002183 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002184 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002185};
2186
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002187/*
2188 STAC 9205 pin configs for
2189 102801F1
2190 102801F2
2191 102801FC
2192 102801FD
2193 10280204
2194 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002195 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002196 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002197*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002198static const unsigned int dell_9205_m42_pin_configs[12] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002199 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2200 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2201 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2202};
2203
2204/*
2205 STAC 9205 pin configs for
2206 102801F9
2207 102801FA
2208 102801FE
2209 102801FF (Dell Precision M4300)
2210 10280206
2211 10280200
2212 10280201
2213*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002214static const unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002215 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2216 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2217 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2218};
2219
Takashi Iwai2b635362011-05-02 12:33:43 +02002220static const unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002221 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2222 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2223 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2224};
2225
Takashi Iwai2b635362011-05-02 12:33:43 +02002226static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002227 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002228 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2229 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2230 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002231 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002232};
2233
Takashi Iwaiea734962011-01-17 11:29:34 +01002234static const char * const stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002235 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002236 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002237 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002238 [STAC_9205_DELL_M43] = "dell-m43",
2239 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002240 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002241};
2242
Takashi Iwai2b635362011-05-02 12:33:43 +02002243static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002244 /* SigmaTel reference board */
2245 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2246 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002247 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2248 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002249 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2250 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002251 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2253 "unknown Dell", STAC_9205_DELL_M42),
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2255 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002257 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2259 "Dell Precision", STAC_9205_DELL_M43),
2260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2261 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2263 "unknown Dell", STAC_9205_DELL_M42),
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2265 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2267 "Dell Precision", STAC_9205_DELL_M43),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002269 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2271 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2273 "Dell Precision", STAC_9205_DELL_M43),
2274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2275 "Dell Precision", STAC_9205_DELL_M43),
2276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2277 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2279 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2281 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2283 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002284 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002285 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002286 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002287 {} /* terminator */
2288};
2289
Takashi Iwai330ee992009-02-20 14:33:36 +01002290static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002291 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002292{
2293 int i;
2294 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002295
Takashi Iwai330ee992009-02-20 14:33:36 +01002296 if (!pincfgs)
2297 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002298
Matthew Ranostay87d48362007-07-17 11:52:24 +02002299 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002300 if (spec->pin_nids[i] && pincfgs[i])
2301 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2302 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002303}
2304
Matt2f2f4252005-04-13 14:45:30 +02002305/*
2306 * Analog playback callbacks
2307 */
2308static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2309 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002310 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002311{
2312 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002313 if (spec->stream_delay)
2314 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002315 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2316 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002317}
2318
2319static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2320 struct hda_codec *codec,
2321 unsigned int stream_tag,
2322 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002323 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002324{
2325 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002326 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002327}
2328
2329static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002331 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002332{
2333 struct sigmatel_spec *spec = codec->spec;
2334 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2335}
2336
2337/*
Mattdabbed62005-06-14 10:19:34 +02002338 * Digital playback callbacks
2339 */
2340static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002342 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002343{
2344 struct sigmatel_spec *spec = codec->spec;
2345 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2346}
2347
2348static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002350 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002351{
2352 struct sigmatel_spec *spec = codec->spec;
2353 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2354}
2355
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002356static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2357 struct hda_codec *codec,
2358 unsigned int stream_tag,
2359 unsigned int format,
2360 struct snd_pcm_substream *substream)
2361{
2362 struct sigmatel_spec *spec = codec->spec;
2363 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2364 stream_tag, format, substream);
2365}
2366
Takashi Iwai9411e212009-02-13 11:32:28 +01002367static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2368 struct hda_codec *codec,
2369 struct snd_pcm_substream *substream)
2370{
2371 struct sigmatel_spec *spec = codec->spec;
2372 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2373}
2374
Mattdabbed62005-06-14 10:19:34 +02002375
2376/*
Matt2f2f4252005-04-13 14:45:30 +02002377 * Analog capture callbacks
2378 */
2379static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2380 struct hda_codec *codec,
2381 unsigned int stream_tag,
2382 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002383 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002384{
2385 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002386 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002387
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002388 if (spec->powerdown_adcs) {
2389 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002390 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002391 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2392 }
2393 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002394 return 0;
2395}
2396
2397static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2398 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002399 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002400{
2401 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002402 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002403
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002404 snd_hda_codec_cleanup_stream(codec, nid);
2405 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002406 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002407 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002408 return 0;
2409}
2410
Takashi Iwai2b635362011-05-02 12:33:43 +02002411static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02002412 .substreams = 1,
2413 .channels_min = 2,
2414 .channels_max = 2,
2415 /* NID is set in stac92xx_build_pcms */
2416 .ops = {
2417 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002418 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002419 .prepare = stac92xx_dig_playback_pcm_prepare,
2420 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002421 },
2422};
2423
Takashi Iwai2b635362011-05-02 12:33:43 +02002424static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02002425 .substreams = 1,
2426 .channels_min = 2,
2427 .channels_max = 2,
2428 /* NID is set in stac92xx_build_pcms */
2429};
2430
Takashi Iwai2b635362011-05-02 12:33:43 +02002431static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02002432 .substreams = 1,
2433 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002434 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002435 .nid = 0x02, /* NID to query formats and rates */
2436 .ops = {
2437 .open = stac92xx_playback_pcm_open,
2438 .prepare = stac92xx_playback_pcm_prepare,
2439 .cleanup = stac92xx_playback_pcm_cleanup
2440 },
2441};
2442
Takashi Iwai2b635362011-05-02 12:33:43 +02002443static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002444 .substreams = 1,
2445 .channels_min = 2,
2446 .channels_max = 2,
2447 .nid = 0x06, /* NID to query formats and rates */
2448 .ops = {
2449 .open = stac92xx_playback_pcm_open,
2450 .prepare = stac92xx_playback_pcm_prepare,
2451 .cleanup = stac92xx_playback_pcm_cleanup
2452 },
2453};
2454
Takashi Iwai2b635362011-05-02 12:33:43 +02002455static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002456 .channels_min = 2,
2457 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002458 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002459 .ops = {
2460 .prepare = stac92xx_capture_pcm_prepare,
2461 .cleanup = stac92xx_capture_pcm_cleanup
2462 },
2463};
2464
2465static int stac92xx_build_pcms(struct hda_codec *codec)
2466{
2467 struct sigmatel_spec *spec = codec->spec;
2468 struct hda_pcm *info = spec->pcm_rec;
2469
2470 codec->num_pcms = 1;
2471 codec->pcm_info = info;
2472
Mattc7d4b2f2005-06-27 14:59:41 +02002473 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002474 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002475 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2476 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002477 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002478 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002479 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002480
2481 if (spec->alt_switch) {
2482 codec->num_pcms++;
2483 info++;
2484 info->name = "STAC92xx Analog Alt";
2485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2486 }
Matt2f2f4252005-04-13 14:45:30 +02002487
Mattdabbed62005-06-14 10:19:34 +02002488 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2489 codec->num_pcms++;
2490 info++;
2491 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002492 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002493 if (spec->multiout.dig_out_nid) {
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2496 }
2497 if (spec->dig_in_nid) {
2498 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2499 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2500 }
2501 }
2502
Matt2f2f4252005-04-13 14:45:30 +02002503 return 0;
2504}
2505
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002506static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2507 hda_nid_t nid)
Takashi Iwaic960a032006-03-23 17:06:28 +01002508{
Takashi Iwai1327a322009-03-23 13:07:47 +01002509 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002510 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2511 if (pincap & AC_PINCAP_VREF_100)
2512 return AC_PINCTL_VREF_100;
2513 if (pincap & AC_PINCAP_VREF_80)
2514 return AC_PINCTL_VREF_80;
2515 if (pincap & AC_PINCAP_VREF_50)
2516 return AC_PINCTL_VREF_50;
2517 if (pincap & AC_PINCAP_VREF_GRD)
2518 return AC_PINCTL_VREF_GRD;
2519 return 0;
2520}
2521
Matt Porter403d1942005-11-29 15:00:51 +01002522static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2523
2524{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02002525 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002526}
2527
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002528#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2529
2530static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2531 struct snd_ctl_elem_value *ucontrol)
2532{
2533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2534 struct sigmatel_spec *spec = codec->spec;
2535
Takashi Iwaid7a89432008-11-12 09:48:04 +01002536 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002537 return 0;
2538}
2539
Takashi Iwai62558ce2009-07-29 14:23:09 +02002540static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002541
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002542static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2543 struct snd_ctl_elem_value *ucontrol)
2544{
2545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2546 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002547 int nid = kcontrol->private_value;
2548
2549 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002550
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002551 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002552 * switch changes
2553 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002554 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002555
2556 return 1;
2557}
2558
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002559static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2560 struct snd_ctl_elem_info *uinfo)
2561{
2562 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02002563 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002564 "Mic In", "Line In", "Line Out"
2565 };
2566
2567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2568 struct sigmatel_spec *spec = codec->spec;
2569 hda_nid_t nid = kcontrol->private_value;
2570
2571 if (nid == spec->mic_switch || nid == spec->line_switch)
2572 i = 3;
2573 else
2574 i = 2;
2575
2576 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2577 uinfo->value.enumerated.items = i;
2578 uinfo->count = 1;
2579 if (uinfo->value.enumerated.item >= i)
2580 uinfo->value.enumerated.item = i-1;
2581 strcpy(uinfo->value.enumerated.name,
2582 texts[uinfo->value.enumerated.item]);
2583
2584 return 0;
2585}
2586
2587static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2588 struct snd_ctl_elem_value *ucontrol)
2589{
2590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2591 hda_nid_t nid = kcontrol->private_value;
2592 unsigned int vref = stac92xx_vref_get(codec, nid);
2593
2594 if (vref == stac92xx_get_default_vref(codec, nid))
2595 ucontrol->value.enumerated.item[0] = 0;
2596 else if (vref == AC_PINCTL_VREF_GRD)
2597 ucontrol->value.enumerated.item[0] = 1;
2598 else if (vref == AC_PINCTL_VREF_HIZ)
2599 ucontrol->value.enumerated.item[0] = 2;
2600
2601 return 0;
2602}
2603
2604static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2605 struct snd_ctl_elem_value *ucontrol)
2606{
2607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2608 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002609 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002610 hda_nid_t nid = kcontrol->private_value;
2611
2612 if (ucontrol->value.enumerated.item[0] == 0)
2613 new_vref = stac92xx_get_default_vref(codec, nid);
2614 else if (ucontrol->value.enumerated.item[0] == 1)
2615 new_vref = AC_PINCTL_VREF_GRD;
2616 else if (ucontrol->value.enumerated.item[0] == 2)
2617 new_vref = AC_PINCTL_VREF_HIZ;
2618 else
2619 return 0;
2620
2621 if (new_vref != stac92xx_vref_get(codec, nid)) {
2622 error = stac92xx_vref_set(codec, nid, new_vref);
2623 return error;
2624 }
2625
2626 return 0;
2627}
2628
2629static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2630 struct snd_ctl_elem_info *uinfo)
2631{
Takashi Iwai2b635362011-05-02 12:33:43 +02002632 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2634 struct sigmatel_spec *spec = codec->spec;
2635
2636 if (kcontrol->private_value == spec->line_switch)
2637 texts[0] = "Line In";
2638 else
2639 texts[0] = "Mic In";
2640 texts[1] = "Line Out";
2641 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2642 uinfo->value.enumerated.items = 2;
2643 uinfo->count = 1;
2644
2645 if (uinfo->value.enumerated.item >= 2)
2646 uinfo->value.enumerated.item = 1;
2647 strcpy(uinfo->value.enumerated.name,
2648 texts[uinfo->value.enumerated.item]);
2649
2650 return 0;
2651}
Matt Porter403d1942005-11-29 15:00:51 +01002652
2653static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2654{
2655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2656 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002657 hda_nid_t nid = kcontrol->private_value;
2658 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002659
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002660 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002661 return 0;
2662}
2663
2664static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2665{
2666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2667 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002668 hda_nid_t nid = kcontrol->private_value;
2669 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2670 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002671
2672 spec->io_switch[io_idx] = val;
2673
2674 if (val)
2675 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002676 else {
2677 unsigned int pinctl = AC_PINCTL_IN_EN;
2678 if (io_idx) /* set VREF for mic */
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002679 pinctl |= stac92xx_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002680 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2681 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002682
2683 /* check the auto-mute again: we need to mute/unmute the speaker
2684 * appropriately according to the pin direction
2685 */
2686 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002687 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002688
Matt Porter403d1942005-11-29 15:00:51 +01002689 return 1;
2690}
2691
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002692#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2693
2694static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2695 struct snd_ctl_elem_value *ucontrol)
2696{
2697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2698 struct sigmatel_spec *spec = codec->spec;
2699
2700 ucontrol->value.integer.value[0] = spec->clfe_swap;
2701 return 0;
2702}
2703
2704static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2705 struct snd_ctl_elem_value *ucontrol)
2706{
2707 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2708 struct sigmatel_spec *spec = codec->spec;
2709 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002710 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002711
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002712 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002713 return 0;
2714
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002715 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002716
2717 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2718 spec->clfe_swap ? 0x4 : 0x0);
2719
2720 return 1;
2721}
2722
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002723#define STAC_CODEC_HP_SWITCH(xname) \
2724 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2725 .name = xname, \
2726 .index = 0, \
2727 .info = stac92xx_hp_switch_info, \
2728 .get = stac92xx_hp_switch_get, \
2729 .put = stac92xx_hp_switch_put, \
2730 }
2731
Matt Porter403d1942005-11-29 15:00:51 +01002732#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2734 .name = xname, \
2735 .index = 0, \
2736 .info = stac92xx_io_switch_info, \
2737 .get = stac92xx_io_switch_get, \
2738 .put = stac92xx_io_switch_put, \
2739 .private_value = xpval, \
2740 }
2741
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002742#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2743 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2744 .name = xname, \
2745 .index = 0, \
2746 .info = stac92xx_clfe_switch_info, \
2747 .get = stac92xx_clfe_switch_get, \
2748 .put = stac92xx_clfe_switch_put, \
2749 .private_value = xpval, \
2750 }
Matt Porter403d1942005-11-29 15:00:51 +01002751
Mattc7d4b2f2005-06-27 14:59:41 +02002752enum {
2753 STAC_CTL_WIDGET_VOL,
2754 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002755 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002756 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002757 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002758 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002759 STAC_CTL_WIDGET_CLFE_SWITCH,
2760 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002761};
2762
Takashi Iwai2b635362011-05-02 12:33:43 +02002763static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002764 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2765 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002766 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002767 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002768 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002769 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002770 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002771 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002772};
2773
2774/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002775static struct snd_kcontrol_new *
2776stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002777 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002778 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002779 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002780{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002781 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002782
Takashi Iwai603c4012008-07-30 15:01:44 +02002783 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2784 knew = snd_array_new(&spec->kctls);
2785 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002786 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002787 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002788 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002789 if (!knew->name) {
2790 /* roolback */
2791 memset(knew, 0, sizeof(*knew));
2792 spec->kctls.alloced--;
2793 return NULL;
2794 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002795 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002796 return knew;
2797}
2798
2799static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002800 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01002801 int idx, const char *name,
2802 unsigned long val)
2803{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002804 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002805 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002806 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002807 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002808 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002809 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002810 return 0;
2811}
2812
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002813static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2814 int type, int idx, const char *name,
2815 unsigned long val)
2816{
2817 return stac92xx_add_control_temp(spec,
2818 &stac92xx_control_templates[type],
2819 idx, name, val);
2820}
2821
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002822
2823/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002824static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2825 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002826{
2827 return stac92xx_add_control_idx(spec, type, 0, name, val);
2828}
2829
Takashi Iwai2b635362011-05-02 12:33:43 +02002830static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01002831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2832 .name = "Input Source",
2833 .info = stac92xx_mux_enum_info,
2834 .get = stac92xx_mux_enum_get,
2835 .put = stac92xx_mux_enum_put,
2836};
2837
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002838static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2839 hda_nid_t nid, int idx)
2840{
2841 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2842 int control = 0;
2843 struct sigmatel_spec *spec = codec->spec;
2844 char name[22];
2845
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002846 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002847 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2848 && nid == spec->line_switch)
2849 control = STAC_CTL_WIDGET_IO_SWITCH;
2850 else if (snd_hda_query_pin_caps(codec, nid)
2851 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2852 control = STAC_CTL_WIDGET_DC_BIAS;
2853 else if (nid == spec->mic_switch)
2854 control = STAC_CTL_WIDGET_IO_SWITCH;
2855 }
2856
2857 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01002858 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
2859 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002860 return stac92xx_add_control(codec->spec, control,
2861 strcat(name, " Jack Mode"), nid);
2862 }
2863
2864 return 0;
2865}
2866
Takashi Iwaie3c75962009-01-23 11:57:22 +01002867static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2868{
2869 struct snd_kcontrol_new *knew;
2870 struct hda_input_mux *imux = &spec->private_imux;
2871
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002872 if (spec->auto_mic)
2873 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002874 if (!spec->num_adcs || imux->num_items <= 1)
2875 return 0; /* no need for input source control */
2876 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002877 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002878 if (!knew)
2879 return -ENOMEM;
2880 knew->count = spec->num_adcs;
2881 return 0;
2882}
2883
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002884/* check whether the line-input can be used as line-out */
2885static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002886{
2887 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002888 struct auto_pin_cfg *cfg = &spec->autocfg;
2889 hda_nid_t nid;
2890 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002891 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002892
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002893 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2894 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002895 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02002896 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002897 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01002898 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002899 if (pincap & AC_PINCAP_OUT)
2900 return nid;
2901 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002902 }
Matt Porter403d1942005-11-29 15:00:51 +01002903 return 0;
2904}
2905
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002906static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2907
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002908/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002909static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002910{
2911 struct sigmatel_spec *spec = codec->spec;
2912 struct auto_pin_cfg *cfg = &spec->autocfg;
2913 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02002914 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002915
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002916 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002917 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2918 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002919 for (i = 0; i < cfg->num_inputs; i++) {
2920 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02002921 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002922 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002923 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2924 /* some laptops have an internal analog microphone
2925 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002926 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002927 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002928 if (pincap & AC_PINCAP_OUT) {
2929 *dac = get_unassigned_dac(codec, nid);
2930 if (*dac)
2931 return nid;
2932 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002933 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002934 }
2935 return 0;
2936}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002937
2938static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2939{
2940 int i;
2941
2942 for (i = 0; i < spec->multiout.num_dacs; i++) {
2943 if (spec->multiout.dac_nids[i] == nid)
2944 return 1;
2945 }
2946
2947 return 0;
2948}
2949
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002950static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2951{
2952 int i;
2953 if (is_in_dac_nids(spec, nid))
2954 return 1;
2955 for (i = 0; i < spec->autocfg.hp_outs; i++)
2956 if (spec->hp_dacs[i] == nid)
2957 return 1;
2958 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2959 if (spec->speaker_dacs[i] == nid)
2960 return 1;
2961 return 0;
2962}
2963
2964static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2965{
2966 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02002967 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002968 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02002969 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002970 unsigned int wcaps, wtype;
2971
2972 conn_len = snd_hda_get_connections(codec, nid, conn,
2973 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002974 /* 92HD88: trace back up the link of nids to find the DAC */
2975 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2976 != AC_WID_AUD_OUT)) {
2977 nid = conn[0];
2978 conn_len = snd_hda_get_connections(codec, nid, conn,
2979 HDA_MAX_CONNECTIONS);
2980 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002981 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002982 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002983 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002984 /* we check only analog outputs */
2985 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2986 continue;
2987 /* if this route has a free DAC, assign it */
2988 if (!check_all_dac_nids(spec, conn[j])) {
2989 if (conn_len > 1) {
2990 /* select this DAC in the pin's input mux */
2991 snd_hda_codec_write_cache(codec, nid, 0,
2992 AC_VERB_SET_CONNECT_SEL, j);
2993 }
2994 return conn[j];
2995 }
2996 }
David Henningsson48718ea2011-10-05 09:49:05 +02002997
2998 /* if all DACs are already assigned, connect to the primary DAC,
2999 unless we're assigning a secondary headphone */
3000 fallback_dac = spec->multiout.dac_nids[0];
3001 if (spec->multiout.hp_nid) {
3002 for (j = 0; j < cfg->hp_outs; j++)
3003 if (cfg->hp_pins[j] == nid) {
3004 fallback_dac = spec->multiout.hp_nid;
3005 break;
3006 }
3007 }
3008
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003009 if (conn_len > 1) {
3010 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02003011 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003012 snd_hda_codec_write_cache(codec, nid, 0,
3013 AC_VERB_SET_CONNECT_SEL, j);
3014 break;
3015 }
3016 }
3017 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003018 return 0;
3019}
3020
3021static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3022static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3023
Matt Porter3cc08dc2006-01-23 15:27:49 +01003024/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003025 * Fill in the dac_nids table from the parsed pin configuration
3026 * This function only works when every pin in line_out_pins[]
3027 * contains atleast one DAC in its connection list. Some 92xx
3028 * codecs are not connected directly to a DAC, such as the 9200
3029 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003030 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003031static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003032{
3033 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003034 struct auto_pin_cfg *cfg = &spec->autocfg;
3035 int i;
3036 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003037
Mattc7d4b2f2005-06-27 14:59:41 +02003038 for (i = 0; i < cfg->line_outs; i++) {
3039 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003040 dac = get_unassigned_dac(codec, nid);
3041 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003042 if (spec->multiout.num_dacs > 0) {
3043 /* we have already working output pins,
3044 * so let's drop the broken ones again
3045 */
3046 cfg->line_outs = spec->multiout.num_dacs;
3047 break;
3048 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003049 /* error out, no available DAC found */
3050 snd_printk(KERN_ERR
3051 "%s: No available DAC for pin 0x%x\n",
3052 __func__, nid);
3053 return -ENODEV;
3054 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003055 add_spec_dacs(spec, dac);
3056 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003057
Takashi Iwai139e0712009-03-06 12:10:41 +01003058 for (i = 0; i < cfg->hp_outs; i++) {
3059 nid = cfg->hp_pins[i];
3060 dac = get_unassigned_dac(codec, nid);
3061 if (dac) {
3062 if (!spec->multiout.hp_nid)
3063 spec->multiout.hp_nid = dac;
3064 else
3065 add_spec_extra_dacs(spec, dac);
3066 }
3067 spec->hp_dacs[i] = dac;
3068 }
3069
3070 for (i = 0; i < cfg->speaker_outs; i++) {
3071 nid = cfg->speaker_pins[i];
3072 dac = get_unassigned_dac(codec, nid);
3073 if (dac)
3074 add_spec_extra_dacs(spec, dac);
3075 spec->speaker_dacs[i] = dac;
3076 }
3077
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003078 /* add line-in as output */
3079 nid = check_line_out_switch(codec);
3080 if (nid) {
3081 dac = get_unassigned_dac(codec, nid);
3082 if (dac) {
3083 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3084 nid, cfg->line_outs);
3085 cfg->line_out_pins[cfg->line_outs] = nid;
3086 cfg->line_outs++;
3087 spec->line_switch = nid;
3088 add_spec_dacs(spec, dac);
3089 }
3090 }
3091 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003092 nid = check_mic_out_switch(codec, &dac);
3093 if (nid && dac) {
3094 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3095 nid, cfg->line_outs);
3096 cfg->line_out_pins[cfg->line_outs] = nid;
3097 cfg->line_outs++;
3098 spec->mic_switch = nid;
3099 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003100 }
3101
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003102 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003103 spec->multiout.num_dacs,
3104 spec->multiout.dac_nids[0],
3105 spec->multiout.dac_nids[1],
3106 spec->multiout.dac_nids[2],
3107 spec->multiout.dac_nids[3],
3108 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003109
Mattc7d4b2f2005-06-27 14:59:41 +02003110 return 0;
3111}
3112
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003113/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003114static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3115 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003116{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003117 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003118 char name[32];
3119 int err;
3120
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003121 if (!spec->check_volume_offset) {
3122 unsigned int caps, step, nums, db_scale;
3123 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3124 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3125 AC_AMPCAP_STEP_SIZE_SHIFT;
3126 step = (step + 1) * 25; /* in .01dB unit */
3127 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3128 AC_AMPCAP_NUM_STEPS_SHIFT;
3129 db_scale = nums * step;
3130 /* if dB scale is over -64dB, and finer enough,
3131 * let's reduce it to half
3132 */
3133 if (db_scale > 6400 && nums >= 0x1f)
3134 spec->volume_offset = nums / 2;
3135 spec->check_volume_offset = 1;
3136 }
3137
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003138 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003139 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003140 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3141 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003142 if (err < 0)
3143 return err;
3144 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003145 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003146 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3147 if (err < 0)
3148 return err;
3149 return 0;
3150}
3151
Takashi Iwai668b9652009-03-06 10:13:24 +01003152#define create_controls(codec, pfx, nid, chs) \
3153 create_controls_idx(codec, pfx, 0, nid, chs)
3154
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003155static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3156{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003157 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003158 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3159 return 1;
3160 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003161 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3162 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003163 spec->multiout.num_dacs++;
3164 }
3165 return 0;
3166}
3167
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003168static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003169{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003170 int i;
3171 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3172 if (!spec->multiout.extra_out_nid[i]) {
3173 spec->multiout.extra_out_nid[i] = nid;
3174 return 0;
3175 }
3176 }
3177 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3178 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003179}
3180
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003181/* Create output controls
3182 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3183 */
3184static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3185 const hda_nid_t *pins,
3186 const hda_nid_t *dac_nids,
3187 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003188{
Takashi Iwai76624532008-12-19 10:09:47 +01003189 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003190 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003191 "Front", "Surround", NULL /*CLFE*/, "Side"
3192 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003193 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003194 int i, err;
3195 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003196
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003197 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003198 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003199 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003200 spec->hp_detect = 1;
3201 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003202 nid = dac_nids[i];
3203 if (!nid)
3204 continue;
3205 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003206 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003207 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003208 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003209 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003210 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003211 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003212 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003213
3214 wid_caps = get_wcaps(codec, nid);
3215
3216 if (wid_caps & AC_WCAP_LR_SWAP) {
3217 err = stac92xx_add_control(spec,
3218 STAC_CTL_WIDGET_CLFE_SWITCH,
3219 "Swap Center/LFE Playback Switch", nid);
3220
3221 if (err < 0)
3222 return err;
3223 }
3224
Mattc7d4b2f2005-06-27 14:59:41 +02003225 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003226 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003227 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003228 switch (type) {
3229 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003230 name = "Headphone";
3231 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003232 break;
3233 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003234 name = "Speaker";
3235 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003236 break;
3237 default:
3238 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003239 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003240 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003241 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003242 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003243 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003244 return err;
3245 }
3246 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003247 return 0;
3248}
3249
Takashi Iwai6479c632009-07-28 18:20:25 +02003250static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3251 unsigned long sw, int idx)
3252{
3253 int err;
3254 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003255 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003256 if (err < 0)
3257 return err;
3258 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003259 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003260 if (err < 0)
3261 return err;
3262 return 0;
3263}
3264
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003265/* add playback controls from the parsed DAC table */
3266static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3267 const struct auto_pin_cfg *cfg)
3268{
3269 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003270 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003271 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003272 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003273
3274 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3275 spec->multiout.dac_nids,
3276 cfg->line_out_type);
3277 if (err < 0)
3278 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003279
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003280 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003281 err = stac92xx_add_control(spec,
3282 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003283 "Headphone as Line Out Switch",
3284 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003285 if (err < 0)
3286 return err;
3287 }
3288
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003289 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003290 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003291 break;
3292 nid = cfg->inputs[idx].pin;
3293 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3294 if (err < 0)
3295 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003296 }
Matt Porter403d1942005-11-29 15:00:51 +01003297
Mattc7d4b2f2005-06-27 14:59:41 +02003298 return 0;
3299}
3300
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003301/* add playback controls for Speaker and HP outputs */
3302static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3303 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003304{
3305 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003306 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003307
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003308 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3309 spec->hp_dacs, AUTO_PIN_HP_OUT);
3310 if (err < 0)
3311 return err;
3312
3313 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3314 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3315 if (err < 0)
3316 return err;
3317
Mattc7d4b2f2005-06-27 14:59:41 +02003318 return 0;
3319}
3320
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003321/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003322static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003323 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003324};
3325
3326/* create mono mux for mono out on capable codecs */
3327static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3328{
3329 struct sigmatel_spec *spec = codec->spec;
3330 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3331 int i, num_cons;
3332 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3333
3334 num_cons = snd_hda_get_connections(codec,
3335 spec->mono_nid,
3336 con_lst,
3337 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003338 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003339 return -EINVAL;
3340
Takashi Iwai10a20af2010-09-09 16:28:02 +02003341 for (i = 0; i < num_cons; i++)
3342 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3343 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003344
3345 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3346 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003347}
3348
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003349/* create PC beep volume controls */
3350static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3351 hda_nid_t nid)
3352{
3353 struct sigmatel_spec *spec = codec->spec;
3354 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003355 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3356
3357 if (spec->anabeep_nid == nid)
3358 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003359
3360 /* check for mute support for the the amp */
3361 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003362 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003363 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003364 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3365 if (err < 0)
3366 return err;
3367 }
3368
3369 /* check to see if there is volume support for the amp */
3370 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3371 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003372 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003373 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3374 if (err < 0)
3375 return err;
3376 }
3377 return 0;
3378}
3379
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003380#ifdef CONFIG_SND_HDA_INPUT_BEEP
3381#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3382
3383static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3384 struct snd_ctl_elem_value *ucontrol)
3385{
3386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3387 ucontrol->value.integer.value[0] = codec->beep->enabled;
3388 return 0;
3389}
3390
3391static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3392 struct snd_ctl_elem_value *ucontrol)
3393{
3394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003395 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003396}
3397
Takashi Iwai2b635362011-05-02 12:33:43 +02003398static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003399 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3400 .info = stac92xx_dig_beep_switch_info,
3401 .get = stac92xx_dig_beep_switch_get,
3402 .put = stac92xx_dig_beep_switch_put,
3403};
3404
3405static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3406{
3407 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003408 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003409}
3410#endif
3411
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003412static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3413{
3414 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003415 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003416
3417 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003418 hda_nid_t nid;
3419 unsigned int wcaps;
3420 unsigned long val;
3421
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003422 nid = spec->mux_nids[i];
3423 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003424 if (!(wcaps & AC_WCAP_OUT_AMP))
3425 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003426
Takashi Iwai667067d2009-08-13 18:14:42 +02003427 /* check whether already the same control was created as
3428 * normal Capture Volume.
3429 */
3430 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3431 for (j = 0; j < spec->num_caps; j++) {
3432 if (spec->capvols[j] == val)
3433 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003434 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003435 if (j < spec->num_caps)
3436 continue;
3437
3438 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3439 "Mux Capture Volume", val);
3440 if (err < 0)
3441 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003442 }
3443 return 0;
3444};
3445
Takashi Iwaiea734962011-01-17 11:29:34 +01003446static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003447 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003448};
3449
3450static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3451{
3452 struct sigmatel_spec *spec = codec->spec;
3453 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01003454 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003455 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003456 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003457
3458 num_cons = snd_hda_get_connections(codec,
3459 spec->smux_nids[0],
3460 con_lst,
3461 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003462 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003463 return -EINVAL;
3464
Matthew Ranostay65973632008-09-16 10:39:37 -04003465 if (!labels)
3466 labels = stac92xx_spdif_labels;
3467
Takashi Iwai10a20af2010-09-09 16:28:02 +02003468 for (i = 0; i < num_cons; i++)
3469 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02003470
3471 return 0;
3472}
3473
Matt Porter8b657272006-10-26 17:12:59 +02003474/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003475static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003476 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3477 "Digital Mic 3", "Digital Mic 4"
3478};
3479
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003480static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3481 int idx)
3482{
3483 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3484 int nums;
3485 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3486 if (idx >= 0 && idx < nums)
3487 return conn[idx];
3488 return 0;
3489}
3490
Takashi Iwai8d087c72011-06-28 12:45:47 +02003491/* look for NID recursively */
3492#define get_connection_index(codec, mux, nid) \
3493 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003494
Takashi Iwai667067d2009-08-13 18:14:42 +02003495/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003496/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003497static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003498 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003499{
3500 unsigned int caps, nums;
3501 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003502 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003503
Takashi Iwai96f845d2009-08-29 00:49:36 +02003504 if (direction == HDA_OUTPUT)
3505 caps = AC_WCAP_OUT_AMP;
3506 else
3507 caps = AC_WCAP_IN_AMP;
3508 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003509 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003510 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003511 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3512 if (!nums)
3513 return 0;
3514 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003515 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3516 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02003517 if (err < 0)
3518 return err;
3519 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003520}
3521
Matt Porter8b657272006-10-26 17:12:59 +02003522/* create playback/capture controls for input pins on dmic capable codecs */
3523static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3524 const struct auto_pin_cfg *cfg)
3525{
3526 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003527 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003528 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003529 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02003530 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003531
Takashi Iwai10a20af2010-09-09 16:28:02 +02003532 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02003533
Matt Porter8b657272006-10-26 17:12:59 +02003534 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003535 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003536 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01003537 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02003538
Takashi Iwai667067d2009-08-13 18:14:42 +02003539 nid = spec->dmic_nids[i];
3540 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3541 continue;
3542 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003543 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3544 continue;
3545
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003546 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3547 if (index < 0)
3548 continue;
3549
Takashi Iwai201e06f2011-11-16 15:33:26 +01003550 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3551 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02003552 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01003553 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3554 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02003555
Takashi Iwai10a20af2010-09-09 16:28:02 +02003556 err = create_elem_capture_vol(codec, nid, label, type_idx,
3557 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003558 if (err < 0)
3559 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003560 if (!err) {
3561 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02003562 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003563 if (err < 0)
3564 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003565 if (!err) {
3566 nid = get_connected_node(codec,
3567 spec->dmux_nids[0], index);
3568 if (nid)
3569 err = create_elem_capture_vol(codec,
3570 nid, label,
3571 type_idx, HDA_INPUT);
3572 if (err < 0)
3573 return err;
3574 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02003575 }
Matt Porter8b657272006-10-26 17:12:59 +02003576 }
3577
3578 return 0;
3579}
3580
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003581static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02003582 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003583{
3584 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003585 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003586
3587 if (!nid)
3588 return 0;
3589 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003590 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003591 switch (snd_hda_get_input_pin_attr(cfg)) {
3592 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003593 if (*fixed)
3594 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003595 if (type != AC_JACK_MIC_IN)
3596 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003597 *fixed = nid;
3598 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003599 case INPUT_PIN_ATTR_UNUSED:
3600 break;
3601 case INPUT_PIN_ATTR_DOCK:
3602 if (*dock)
3603 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003604 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3605 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003606 *dock = nid;
3607 break;
3608 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003609 if (*ext)
3610 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003611 if (type != AC_JACK_MIC_IN)
3612 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003613 *ext = nid;
3614 break;
3615 }
3616 return 0;
3617}
3618
3619static int set_mic_route(struct hda_codec *codec,
3620 struct sigmatel_mic_route *mic,
3621 hda_nid_t pin)
3622{
3623 struct sigmatel_spec *spec = codec->spec;
3624 struct auto_pin_cfg *cfg = &spec->autocfg;
3625 int i;
3626
3627 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02003628 if (pin == 0)
3629 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003630 for (i = 0; i < cfg->num_inputs; i++) {
3631 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003632 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003633 }
Takashi Iwai86e29592010-09-09 14:50:17 +02003634 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003635 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003636 i = get_connection_index(codec, spec->mux_nids[0], pin);
3637 if (i < 0)
3638 return -1;
3639 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003640 mic->dmux_idx = -1;
3641 if (spec->dmux_nids)
3642 mic->dmux_idx = get_connection_index(codec,
3643 spec->dmux_nids[0],
3644 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003645 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003646 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003647 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3648 if (i < 0)
3649 return -1;
3650 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003651 mic->mux_idx = -1;
3652 if (spec->mux_nids)
3653 mic->mux_idx = get_connection_index(codec,
3654 spec->mux_nids[0],
3655 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003656 }
3657 return 0;
3658}
3659
3660/* return non-zero if the device is for automatic mic switch */
3661static int stac_check_auto_mic(struct hda_codec *codec)
3662{
3663 struct sigmatel_spec *spec = codec->spec;
3664 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02003665 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003666 int i;
3667
Charles Chin99077902010-09-17 10:22:32 +02003668 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003669 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02003670 if (check_mic_pin(codec, cfg->inputs[i].pin,
3671 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003672 return 0;
3673 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02003674 if (check_mic_pin(codec, spec->dmic_nids[i],
3675 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003676 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01003677 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02003678 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003679 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003680 return 0; /* no unsol support */
3681 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02003682 set_mic_route(codec, &spec->int_mic, fixed) ||
3683 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003684 return 0; /* something is wrong */
3685 return 1;
3686}
3687
Mattc7d4b2f2005-06-27 14:59:41 +02003688/* create playback/capture controls for input pins */
3689static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3690{
3691 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003692 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003693 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003694 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02003695
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003696 for (i = 0; i < cfg->num_inputs; i++) {
3697 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003698 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02003699
Takashi Iwai314634b2006-09-21 11:56:18 +02003700 index = -1;
3701 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003702 index = get_connection_index(codec, spec->mux_nids[j],
3703 nid);
3704 if (index >= 0)
3705 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003706 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003707 if (index < 0)
3708 continue;
3709
Takashi Iwai10a20af2010-09-09 16:28:02 +02003710 label = hda_get_autocfg_input_label(codec, cfg, i);
3711 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003712
Takashi Iwai667067d2009-08-13 18:14:42 +02003713 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003714 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003715 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003716 if (err < 0)
3717 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003718 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003719 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003720
Steve Longerbeam7b043892007-05-03 20:50:03 +02003721 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003722 /*
3723 * Set the current input for the muxes.
3724 * The STAC9221 has two input muxes with identical source
3725 * NID lists. Hopefully this won't get confused.
3726 */
3727 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003728 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3729 AC_VERB_SET_CONNECT_SEL,
3730 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003731 }
3732 }
3733
Mattc7d4b2f2005-06-27 14:59:41 +02003734 return 0;
3735}
3736
Mattc7d4b2f2005-06-27 14:59:41 +02003737static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3738{
3739 struct sigmatel_spec *spec = codec->spec;
3740 int i;
3741
3742 for (i = 0; i < spec->autocfg.line_outs; i++) {
3743 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3744 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3745 }
3746}
3747
3748static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3749{
3750 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003751 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003752
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003753 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3754 hda_nid_t pin;
3755 pin = spec->autocfg.hp_pins[i];
3756 if (pin) /* connect to front */
3757 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3758 }
3759 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3760 hda_nid_t pin;
3761 pin = spec->autocfg.speaker_pins[i];
3762 if (pin) /* connect to front */
3763 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3764 }
Mattc7d4b2f2005-06-27 14:59:41 +02003765}
3766
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003767static int is_dual_headphones(struct hda_codec *codec)
3768{
3769 struct sigmatel_spec *spec = codec->spec;
3770 int i, valid_hps;
3771
3772 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3773 spec->autocfg.hp_outs <= 1)
3774 return 0;
3775 valid_hps = 0;
3776 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3777 hda_nid_t nid = spec->autocfg.hp_pins[i];
3778 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3779 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3780 continue;
3781 valid_hps++;
3782 }
3783 return (valid_hps > 1);
3784}
3785
3786
Charles Chin9009b0e2011-11-03 10:27:27 +01003787static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003788{
3789 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01003790 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003791 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003792 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003793
Matt Porter8b657272006-10-26 17:12:59 +02003794 if ((err = snd_hda_parse_pin_def_config(codec,
3795 &spec->autocfg,
3796 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003797 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003798 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003799 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003800
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003801 /* If we have no real line-out pin and multiple hp-outs, HPs should
3802 * be set up as multi-channel outputs.
3803 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003804 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003805 /* Copy hp_outs to line_outs, backup line_outs in
3806 * speaker_outs so that the following routines can handle
3807 * HP pins as primary outputs.
3808 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003809 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003810 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3811 sizeof(spec->autocfg.line_out_pins));
3812 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3813 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3814 sizeof(spec->autocfg.hp_pins));
3815 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003816 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3817 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003818 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003819 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003820 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003821 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3822 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003823 u32 caps = query_amp_caps(codec,
3824 spec->autocfg.mono_out_pin, dir);
3825 hda_nid_t conn_list[1];
3826
3827 /* get the mixer node and then the mono mux if it exists */
3828 if (snd_hda_get_connections(codec,
3829 spec->autocfg.mono_out_pin, conn_list, 1) &&
3830 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003831 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003832
3833 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003834 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003835 /* LR swap check, some stac925x have a mux that
3836 * changes the DACs output path instead of the
3837 * mono-mux path.
3838 */
3839 if (wid_type == AC_WID_AUD_SEL &&
3840 !(wcaps & AC_WCAP_LR_SWAP))
3841 spec->mono_nid = conn_list[0];
3842 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003843 if (dir) {
3844 hda_nid_t nid = spec->autocfg.mono_out_pin;
3845
3846 /* most mono outs have a least a mute/unmute switch */
3847 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3848 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3849 "Mono Playback Switch",
3850 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003851 if (err < 0)
3852 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003853 /* check for volume support for the amp */
3854 if ((caps & AC_AMPCAP_NUM_STEPS)
3855 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3856 err = stac92xx_add_control(spec,
3857 STAC_CTL_WIDGET_VOL,
3858 "Mono Playback Volume",
3859 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3860 if (err < 0)
3861 return err;
3862 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003863 }
3864
3865 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3866 AC_PINCTL_OUT_EN);
3867 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003868
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003869 if (!spec->multiout.num_dacs) {
3870 err = stac92xx_auto_fill_dac_nids(codec);
3871 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003872 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003873 err = stac92xx_auto_create_multi_out_ctls(codec,
3874 &spec->autocfg);
3875 if (err < 0)
3876 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003877 }
Mattc7d4b2f2005-06-27 14:59:41 +02003878
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003879 /* setup analog beep controls */
3880 if (spec->anabeep_nid > 0) {
3881 err = stac92xx_auto_create_beep_ctls(codec,
3882 spec->anabeep_nid);
3883 if (err < 0)
3884 return err;
3885 }
3886
3887 /* setup digital beep controls and input device */
3888#ifdef CONFIG_SND_HDA_INPUT_BEEP
3889 if (spec->digbeep_nid > 0) {
3890 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003891 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003892
3893 err = stac92xx_auto_create_beep_ctls(codec, nid);
3894 if (err < 0)
3895 return err;
3896 err = snd_hda_attach_beep_device(codec, nid);
3897 if (err < 0)
3898 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003899 if (codec->beep) {
3900 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003901 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003902 /* if no beep switch is available, make its own one */
3903 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3904 if (!(caps & AC_AMPCAP_MUTE)) {
3905 err = stac92xx_beep_switch_ctl(codec);
3906 if (err < 0)
3907 return err;
3908 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003909 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003910 }
3911#endif
3912
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003913 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003914 if (err < 0)
3915 return err;
3916
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003917 /* All output parsing done, now restore the swapped hp pins */
3918 if (hp_swap) {
3919 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3920 sizeof(spec->autocfg.hp_pins));
3921 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3922 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3923 spec->autocfg.line_outs = 0;
3924 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003925
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003926 if (stac_check_auto_mic(codec)) {
3927 spec->auto_mic = 1;
3928 /* only one capture for auto-mic */
3929 spec->num_adcs = 1;
3930 spec->num_caps = 1;
3931 spec->num_muxes = 1;
3932 }
3933
Takashi Iwai6479c632009-07-28 18:20:25 +02003934 for (i = 0; i < spec->num_caps; i++) {
3935 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3936 spec->capsws[i], i);
3937 if (err < 0)
3938 return err;
3939 }
3940
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003941 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003942 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003943 return err;
3944
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003945 if (spec->mono_nid > 0) {
3946 err = stac92xx_auto_create_mono_output_ctls(codec);
3947 if (err < 0)
3948 return err;
3949 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003950 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003951 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3952 &spec->autocfg)) < 0)
3953 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003954 if (spec->num_muxes > 0) {
3955 err = stac92xx_auto_create_mux_input_ctls(codec);
3956 if (err < 0)
3957 return err;
3958 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003959 if (spec->num_smuxes > 0) {
3960 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3961 if (err < 0)
3962 return err;
3963 }
Matt Porter8b657272006-10-26 17:12:59 +02003964
Takashi Iwaie3c75962009-01-23 11:57:22 +01003965 err = stac92xx_add_input_source(spec);
3966 if (err < 0)
3967 return err;
3968
Mattc7d4b2f2005-06-27 14:59:41 +02003969 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003970 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003971 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003972
Charles Chin9009b0e2011-11-03 10:27:27 +01003973 /* find digital out and in converters */
3974 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3975 unsigned int wid_caps = get_wcaps(codec, i);
3976 if (wid_caps & AC_WCAP_DIGITAL) {
3977 switch (get_wcaps_type(wid_caps)) {
3978 case AC_WID_AUD_OUT:
3979 if (!dig_out)
3980 dig_out = i;
3981 break;
3982 case AC_WID_AUD_IN:
3983 if (!dig_in)
3984 dig_in = i;
3985 break;
3986 }
3987 }
3988 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003989 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003990 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003991 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003992 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003993
Takashi Iwai603c4012008-07-30 15:01:44 +02003994 if (spec->kctls.list)
3995 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003996
3997 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003998 if (!spec->dinput_mux)
3999 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004000 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004001 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02004002 return 1;
4003}
4004
Takashi Iwai82bc9552006-03-21 11:24:42 +01004005/* add playback controls for HP output */
4006static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4007 struct auto_pin_cfg *cfg)
4008{
4009 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004010 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01004011
4012 if (! pin)
4013 return 0;
4014
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004015 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01004016 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004017
4018 return 0;
4019}
4020
Richard Fish160ea0d2006-09-06 13:58:25 +02004021/* add playback controls for LFE output */
4022static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4023 struct auto_pin_cfg *cfg)
4024{
4025 struct sigmatel_spec *spec = codec->spec;
4026 int err;
4027 hda_nid_t lfe_pin = 0x0;
4028 int i;
4029
4030 /*
4031 * search speaker outs and line outs for a mono speaker pin
4032 * with an amp. If one is found, add LFE controls
4033 * for it.
4034 */
4035 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4036 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004037 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004038 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4039 if (wcaps == AC_WCAP_OUT_AMP)
4040 /* found a mono speaker with an amp, must be lfe */
4041 lfe_pin = pin;
4042 }
4043
4044 /* if speaker_outs is 0, then speakers may be in line_outs */
4045 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4046 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4047 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004048 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004049 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004050 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004051 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004052 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4053 if (wcaps == AC_WCAP_OUT_AMP)
4054 /* found a mono speaker with an amp,
4055 must be lfe */
4056 lfe_pin = pin;
4057 }
4058 }
4059 }
4060
4061 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004062 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004063 if (err < 0)
4064 return err;
4065 }
4066
4067 return 0;
4068}
4069
Mattc7d4b2f2005-06-27 14:59:41 +02004070static int stac9200_parse_auto_config(struct hda_codec *codec)
4071{
4072 struct sigmatel_spec *spec = codec->spec;
4073 int err;
4074
Kailang Yangdf694da2005-12-05 19:42:22 +01004075 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004076 return err;
4077
4078 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4079 return err;
4080
Takashi Iwai82bc9552006-03-21 11:24:42 +01004081 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4082 return err;
4083
Richard Fish160ea0d2006-09-06 13:58:25 +02004084 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4085 return err;
4086
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004087 if (spec->num_muxes > 0) {
4088 err = stac92xx_auto_create_mux_input_ctls(codec);
4089 if (err < 0)
4090 return err;
4091 }
4092
Takashi Iwaie3c75962009-01-23 11:57:22 +01004093 err = stac92xx_add_input_source(spec);
4094 if (err < 0)
4095 return err;
4096
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004097 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004098 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004099 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004100 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004101
Takashi Iwai603c4012008-07-30 15:01:44 +02004102 if (spec->kctls.list)
4103 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004104
4105 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004106 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004107
4108 return 1;
4109}
4110
Sam Revitch62fe78e2006-05-10 15:09:17 +02004111/*
4112 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4113 * funky external mute control using GPIO pins.
4114 */
4115
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004116static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004117 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004118{
4119 unsigned int gpiostate, gpiomask, gpiodir;
4120
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004121 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4122
Sam Revitch62fe78e2006-05-10 15:09:17 +02004123 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4124 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004125 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004126
4127 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4128 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004129 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004130
4131 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4132 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004133 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004134
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004135 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004136 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4137
4138 snd_hda_codec_write(codec, codec->afg, 0,
4139 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004140 snd_hda_codec_read(codec, codec->afg, 0,
4141 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004142
4143 msleep(1);
4144
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004145 snd_hda_codec_read(codec, codec->afg, 0,
4146 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004147}
4148
Takashi Iwai3a938972011-10-28 01:16:55 +02004149static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004150 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004151{
Takashi Iwai3a938972011-10-28 01:16:55 +02004152 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004153
Takashi Iwai3a938972011-10-28 01:16:55 +02004154 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004155 if (!event)
4156 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02004157 event->action = type;
4158 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004159
Takashi Iwai3a938972011-10-28 01:16:55 +02004160 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004161}
4162
Takashi Iwai62558ce2009-07-29 14:23:09 +02004163/* check if given nid is a valid pin and no other events are assigned
4164 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4165 * Otherwise, returns zero.
4166 */
4167static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4168 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004169{
Takashi Iwai3a938972011-10-28 01:16:55 +02004170 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004171
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004172 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004173 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02004174 event = snd_hda_jack_tbl_new(codec, nid);
4175 if (!event)
4176 return -ENOMEM;
4177 if (event->action && event->action != type)
4178 return 0;
4179 event->action = type;
4180 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004181 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004182}
4183
Takashi Iwaib4ead012012-01-23 18:23:36 +01004184static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004185{
4186 int i;
4187 for (i = 0; i < cfg->hp_outs; i++)
4188 if (cfg->hp_pins[i] == nid)
4189 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01004190 for (i = 0; i < cfg->line_outs; i++)
4191 if (cfg->line_out_pins[i] == nid)
4192 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004193 return 0; /* nid is not a HP-Out */
4194};
4195
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004196static void stac92xx_power_down(struct hda_codec *codec)
4197{
4198 struct sigmatel_spec *spec = codec->spec;
4199
4200 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02004201 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004202 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004203 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004204 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004205 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4206}
4207
Takashi Iwaif73d3582008-11-25 08:21:51 +01004208static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4209 int enable);
4210
Takashi Iwai014c41f2009-12-27 13:53:24 +01004211static inline int get_int_hint(struct hda_codec *codec, const char *key,
4212 int *valp)
4213{
4214 const char *p;
4215 p = snd_hda_get_hint(codec, key);
4216 if (p) {
4217 unsigned long val;
4218 if (!strict_strtoul(p, 0, &val)) {
4219 *valp = val;
4220 return 1;
4221 }
4222 }
4223 return 0;
4224}
4225
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004226/* override some hints from the hwdep entry */
4227static void stac_store_hints(struct hda_codec *codec)
4228{
4229 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004230 int val;
4231
4232 val = snd_hda_get_bool_hint(codec, "hp_detect");
4233 if (val >= 0)
4234 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004235 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004236 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4237 spec->gpio_mask;
4238 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004239 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4240 spec->gpio_mask &= spec->gpio_mask;
4241 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4242 spec->gpio_dir &= spec->gpio_mask;
4243 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4244 spec->eapd_mask &= spec->gpio_mask;
4245 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4246 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004247 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4248 if (val >= 0)
4249 spec->eapd_switch = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004250 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4251 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004252 spec->gpio_mask |= spec->gpio_led;
4253 spec->gpio_dir |= spec->gpio_led;
4254 if (spec->gpio_led_polarity)
4255 spec->gpio_data |= spec->gpio_led;
Takashi Iwai043958e2009-12-26 10:36:12 +01004256 }
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004257}
4258
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004259static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4260 const hda_nid_t *pins)
4261{
4262 while (num_pins--)
4263 stac_issue_unsol_event(codec, *pins++);
4264}
4265
4266/* fake event to set up pins */
4267static void stac_fake_hp_events(struct hda_codec *codec)
4268{
4269 struct sigmatel_spec *spec = codec->spec;
4270
4271 if (spec->autocfg.hp_outs)
4272 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4273 spec->autocfg.hp_pins);
4274 if (spec->autocfg.line_outs &&
4275 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4276 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4277 spec->autocfg.line_out_pins);
4278}
4279
Mattc7d4b2f2005-06-27 14:59:41 +02004280static int stac92xx_init(struct hda_codec *codec)
4281{
4282 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004283 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004284 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004285 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004286
Mattc7d4b2f2005-06-27 14:59:41 +02004287 snd_hda_sequence_write(codec, spec->init);
4288
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004289 /* power down adcs initially */
4290 if (spec->powerdown_adcs)
4291 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004292 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004293 spec->adc_nids[i], 0,
4294 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004295
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004296 /* override some hints */
4297 stac_store_hints(codec);
4298
Takashi Iwaif73d3582008-11-25 08:21:51 +01004299 /* set up GPIO */
4300 gpio = spec->gpio_data;
4301 /* turn on EAPD statically when spec->eapd_switch isn't set.
4302 * otherwise, unsol event will turn it on/off dynamically
4303 */
4304 if (!spec->eapd_switch)
4305 gpio |= spec->eapd_mask;
4306 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4307
Takashi Iwai82bc9552006-03-21 11:24:42 +01004308 /* set up pins */
4309 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004310 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004311 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004312 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004313 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004314 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004315 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4316 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004317 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004318 for (i = 0; i < cfg->line_outs; i++) {
4319 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004320 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4321 }
4322 }
4323
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004324 /* force to enable the first line-out; the others are set up
4325 * in unsol_event
4326 */
4327 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004328 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004329 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004330 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004331 } else {
4332 stac92xx_auto_init_multi_out(codec);
4333 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004334 for (i = 0; i < cfg->hp_outs; i++)
4335 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004336 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004337 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004338 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004339 if (spec->dmux_nids)
4340 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004341 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004342 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4343 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02004344 if (enable_pin_detect(codec, spec->dock_mic.pin,
4345 STAC_MIC_EVENT))
4346 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004347 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004348 for (i = 0; i < cfg->num_inputs; i++) {
4349 hda_nid_t nid = cfg->inputs[i].pin;
4350 int type = cfg->inputs[i].type;
4351 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02004352 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004353 /* for mic pins, force to initialize */
4354 pinctl = stac92xx_get_default_vref(codec, nid);
4355 pinctl |= AC_PINCTL_IN_EN;
4356 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4357 } else {
4358 pinctl = snd_hda_codec_read(codec, nid, 0,
4359 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4360 /* if PINCTL already set then skip */
4361 /* Also, if both INPUT and OUTPUT are set,
4362 * it must be a BIOS bug; need to override, too
4363 */
4364 if (!(pinctl & AC_PINCTL_IN_EN) ||
4365 (pinctl & AC_PINCTL_OUT_EN)) {
4366 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004367 pinctl |= AC_PINCTL_IN_EN;
4368 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004369 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004370 }
4371 conf = snd_hda_codec_get_pincfg(codec, nid);
4372 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4373 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4374 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01004375 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004376 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004377 for (i = 0; i < spec->num_dmics; i++)
4378 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4379 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004380 if (cfg->dig_out_pins[0])
4381 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004382 AC_PINCTL_OUT_EN);
4383 if (cfg->dig_in_pin)
4384 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4385 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004386 for (i = 0; i < spec->num_pwrs; i++) {
4387 hda_nid_t nid = spec->pwr_nids[i];
4388 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004389
Takashi Iwaieb632122008-12-19 16:39:48 +01004390 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01004391 /* or when the VREF is used for controlling LED */
4392 if (!spec->hp_detect ||
Takashi Iwaia0204282011-12-06 13:17:23 +01004393 spec->vref_mute_led_nid == nid) {
Takashi Iwaieb632122008-12-19 16:39:48 +01004394 stac_toggle_power_map(codec, nid, 1);
4395 continue;
4396 }
4397
Takashi Iwaib4ead012012-01-23 18:23:36 +01004398 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004399 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004400
Takashi Iwaif73d3582008-11-25 08:21:51 +01004401 pinctl = snd_hda_codec_read(codec, nid, 0,
4402 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4403 /* outputs are only ports capable of power management
4404 * any attempts on powering down a input port cause the
4405 * referenced VREF to act quirky.
4406 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004407 if (pinctl & AC_PINCTL_IN_EN) {
4408 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004409 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004410 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004411 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004412 def_conf = get_defcfg_connect(def_conf);
4413 /* skip any ports that don't have jacks since presence
4414 * detection is useless */
4415 if (def_conf != AC_JACK_PORT_COMPLEX) {
4416 if (def_conf != AC_JACK_PORT_NONE)
4417 stac_toggle_power_map(codec, nid, 1);
4418 continue;
4419 }
Charles Chinafef2cf2011-11-11 08:05:28 +01004420 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004421 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01004422 continue;
4423 }
4424 /* none of the above, turn the port OFF */
4425 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004426 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004427
Takashi Iwai01a61e12011-10-28 00:03:22 +02004428 snd_hda_jack_report_sync(codec);
4429
Takashi Iwaic21bd022010-02-08 15:16:08 +01004430 /* sync mute LED */
Takashi Iwaid2f344b2012-03-12 16:59:58 +01004431 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004432 if (spec->dac_list)
4433 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004434 return 0;
4435}
4436
Takashi Iwai603c4012008-07-30 15:01:44 +02004437static void stac92xx_free_kctls(struct hda_codec *codec)
4438{
4439 struct sigmatel_spec *spec = codec->spec;
4440
4441 if (spec->kctls.list) {
4442 struct snd_kcontrol_new *kctl = spec->kctls.list;
4443 int i;
4444 for (i = 0; i < spec->kctls.used; i++)
4445 kfree(kctl[i].name);
4446 }
4447 snd_array_free(&spec->kctls);
4448}
4449
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004450static void stac92xx_shutup_pins(struct hda_codec *codec)
4451{
4452 unsigned int i, def_conf;
4453
4454 if (codec->bus->shutdown)
4455 return;
4456 for (i = 0; i < codec->init_pins.used; i++) {
4457 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4458 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4459 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004460 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004461 }
4462}
4463
Takashi Iwai167eae52009-11-06 15:47:50 +01004464static void stac92xx_shutup(struct hda_codec *codec)
4465{
4466 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004467
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004468 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004469
4470 if (spec->eapd_mask)
4471 stac_gpio_set(codec, spec->gpio_mask,
4472 spec->gpio_dir, spec->gpio_data &
4473 ~spec->eapd_mask);
4474}
4475
Matt2f2f4252005-04-13 14:45:30 +02004476static void stac92xx_free(struct hda_codec *codec)
4477{
Mattc7d4b2f2005-06-27 14:59:41 +02004478 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004479
4480 if (! spec)
4481 return;
4482
Takashi Iwai167eae52009-11-06 15:47:50 +01004483 stac92xx_shutup(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02004484
Mattc7d4b2f2005-06-27 14:59:41 +02004485 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004486 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004487}
4488
Matt4e550962005-07-04 17:51:39 +02004489static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4490 unsigned int flag)
4491{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004492 unsigned int old_ctl, pin_ctl;
4493
4494 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004495 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004496
Takashi Iwaif9acba42007-05-29 18:01:06 +02004497 if (pin_ctl & AC_PINCTL_IN_EN) {
4498 /*
4499 * we need to check the current set-up direction of
4500 * shared input pins since they can be switched via
4501 * "xxx as Output" mixer switch
4502 */
4503 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004504 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004505 return;
4506 }
4507
Takashi Iwai8ce84192009-01-22 16:59:20 +01004508 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004509 /* if setting pin direction bits, clear the current
4510 direction bits first */
4511 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4512 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4513
Takashi Iwai8ce84192009-01-22 16:59:20 +01004514 pin_ctl |= flag;
4515 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004516 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004517}
4518
4519static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4520 unsigned int flag)
4521{
4522 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4523 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004524 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004525 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004526}
4527
Takashi Iwaid56757a2009-11-18 08:00:14 +01004528static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004529{
4530 if (!nid)
4531 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004532 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004533}
4534
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004535static void stac92xx_line_out_detect(struct hda_codec *codec,
4536 int presence)
4537{
4538 struct sigmatel_spec *spec = codec->spec;
4539 struct auto_pin_cfg *cfg = &spec->autocfg;
4540 int i;
4541
4542 for (i = 0; i < cfg->line_outs; i++) {
4543 if (presence)
4544 break;
4545 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4546 if (presence) {
4547 unsigned int pinctl;
4548 pinctl = snd_hda_codec_read(codec,
4549 cfg->line_out_pins[i], 0,
4550 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4551 if (pinctl & AC_PINCTL_IN_EN)
4552 presence = 0; /* mic- or line-input */
4553 }
4554 }
4555
4556 if (presence) {
4557 /* disable speakers */
4558 for (i = 0; i < cfg->speaker_outs; i++)
4559 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4560 AC_PINCTL_OUT_EN);
4561 if (spec->eapd_mask && spec->eapd_switch)
4562 stac_gpio_set(codec, spec->gpio_mask,
4563 spec->gpio_dir, spec->gpio_data &
4564 ~spec->eapd_mask);
4565 } else {
4566 /* enable speakers */
4567 for (i = 0; i < cfg->speaker_outs; i++)
4568 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4569 AC_PINCTL_OUT_EN);
4570 if (spec->eapd_mask && spec->eapd_switch)
4571 stac_gpio_set(codec, spec->gpio_mask,
4572 spec->gpio_dir, spec->gpio_data |
4573 spec->eapd_mask);
4574 }
4575}
4576
Takashi Iwaid7a89432008-11-12 09:48:04 +01004577/* return non-zero if the hp-pin of the given array index isn't
4578 * a jack-detection target
4579 */
4580static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4581{
4582 struct auto_pin_cfg *cfg = &spec->autocfg;
4583
4584 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004585 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004586 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004587 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004588 return 1;
4589 /* ignore if the pin is set as line-out */
4590 if (cfg->hp_pins[i] == spec->hp_switch)
4591 return 1;
4592 return 0;
4593}
4594
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004595static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004596{
4597 struct sigmatel_spec *spec = codec->spec;
4598 struct auto_pin_cfg *cfg = &spec->autocfg;
4599 int i, presence;
4600
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004601 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004602 if (spec->gpio_mute)
4603 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4604 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4605
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004606 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004607 if (presence)
4608 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004609 if (no_hp_sensing(spec, i))
4610 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004611 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4612 if (presence) {
4613 unsigned int pinctl;
4614 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4615 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4616 if (pinctl & AC_PINCTL_IN_EN)
4617 presence = 0; /* mic- or line-input */
4618 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004619 }
Matt4e550962005-07-04 17:51:39 +02004620
4621 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004622 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004623 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004624 stac92xx_reset_pinctl(codec, spec->hp_switch,
4625 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004626 for (i = 0; i < cfg->line_outs; i++)
4627 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4628 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004629 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004630 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004631 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004632 stac92xx_set_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_set_pinctl(codec, cfg->line_out_pins[i],
4636 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004637 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004638 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004639 /* toggle hp outs */
4640 for (i = 0; i < cfg->hp_outs; i++) {
4641 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4642 if (no_hp_sensing(spec, i))
4643 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01004644 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004645 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004646#if 0 /* FIXME */
4647/* Resetting the pinctl like below may lead to (a sort of) regressions
4648 * on some devices since they use the HP pin actually for line/speaker
4649 * outs although the default pin config shows a different pin (that is
4650 * wrong and useless).
4651 *
4652 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4653 * But, disabling the code below just works around it, and I'm too tired of
4654 * bug reports with such devices...
4655 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004656 else
4657 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004658#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004659 }
Matt4e550962005-07-04 17:51:39 +02004660}
4661
Takashi Iwaif73d3582008-11-25 08:21:51 +01004662static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4663 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004664{
4665 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004666 unsigned int idx, val;
4667
4668 for (idx = 0; idx < spec->num_pwrs; idx++) {
4669 if (spec->pwr_nids[idx] == nid)
4670 break;
4671 }
4672 if (idx >= spec->num_pwrs)
4673 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004674
Charles Chinafef2cf2011-11-11 08:05:28 +01004675 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004676
Takashi Iwaif73d3582008-11-25 08:21:51 +01004677 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4678 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004679 val &= ~idx;
4680 else
4681 val |= idx;
4682
4683 /* power down unused output ports */
4684 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004685}
4686
Takashi Iwaif73d3582008-11-25 08:21:51 +01004687static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4688{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004689 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004690}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004691
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004692/* get the pin connection (fixed, none, etc) */
4693static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4694{
4695 struct sigmatel_spec *spec = codec->spec;
4696 unsigned int cfg;
4697
4698 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4699 return get_defcfg_connect(cfg);
4700}
4701
4702static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004703 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004704{
4705 struct sigmatel_spec *spec = codec->spec;
4706 int idx, num;
4707 unsigned int def_conf;
4708
4709 for (num = 0; num < num_nids; num++) {
4710 for (idx = 0; idx < spec->num_pins; idx++)
4711 if (spec->pin_nids[idx] == nids[num])
4712 break;
4713 if (idx >= spec->num_pins)
4714 break;
4715 def_conf = stac_get_defcfg_connect(codec, idx);
4716 if (def_conf == AC_JACK_PORT_NONE)
4717 break;
4718 }
4719 return num;
4720}
4721
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004722static void stac92xx_mic_detect(struct hda_codec *codec)
4723{
4724 struct sigmatel_spec *spec = codec->spec;
4725 struct sigmatel_mic_route *mic;
4726
4727 if (get_pin_presence(codec, spec->ext_mic.pin))
4728 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02004729 else if (get_pin_presence(codec, spec->dock_mic.pin))
4730 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004731 else
4732 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004733 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004734 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4735 AC_VERB_SET_CONNECT_SEL,
4736 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004737 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004738 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4739 AC_VERB_SET_CONNECT_SEL,
4740 mic->mux_idx);
4741}
4742
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004743static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02004744 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02004745{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004746 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004747 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004748
Takashi Iwai3a938972011-10-28 01:16:55 +02004749 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004750 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004751 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004752 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004753 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004754 case STAC_MIC_EVENT:
4755 stac92xx_mic_detect(codec);
4756 break;
4757 }
4758
Takashi Iwai3a938972011-10-28 01:16:55 +02004759 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004760 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004761 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004762 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004763 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004764 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004765 if (spec->num_pwrs > 0)
4766 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004767
4768 switch (codec->subsystem_id) {
4769 case 0x103c308f:
4770 if (event->nid == 0xb) {
4771 int pin = AC_PINCTL_IN_EN;
4772
4773 if (get_pin_presence(codec, 0xa)
4774 && get_pin_presence(codec, 0xb))
4775 pin |= AC_PINCTL_VREF_80;
4776 if (!get_pin_presence(codec, 0xb))
4777 pin |= AC_PINCTL_VREF_80;
4778
4779 /* toggle VREF state based on mic + hp pin
4780 * status
4781 */
4782 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4783 }
4784 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004785 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004786 case STAC_VREF_EVENT:
4787 data = snd_hda_codec_read(codec, codec->afg, 0,
4788 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004789 /* toggle VREF state based on GPIOx status */
4790 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02004791 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004792 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004793 }
4794}
4795
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004796static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4797{
Takashi Iwai3a938972011-10-28 01:16:55 +02004798 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004799 if (!event)
4800 return;
4801 handle_unsol_event(codec, event);
4802}
4803
4804static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4805{
Takashi Iwai3a938972011-10-28 01:16:55 +02004806 struct hda_jack_tbl *event;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004807 int tag;
4808
4809 tag = (res >> 26) & 0x7f;
Takashi Iwai3a938972011-10-28 01:16:55 +02004810 event = snd_hda_jack_tbl_get_from_tag(codec, tag);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004811 if (!event)
4812 return;
Takashi Iwai3a938972011-10-28 01:16:55 +02004813 event->jack_dirty = 1;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004814 handle_unsol_event(codec, event);
Takashi Iwai01a61e12011-10-28 00:03:22 +02004815 snd_hda_jack_report_sync(codec);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004816}
4817
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304818static int hp_blike_system(u32 subsystem_id);
4819
4820static void set_hp_led_gpio(struct hda_codec *codec)
4821{
4822 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004823 unsigned int gpio;
4824
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004825 if (spec->gpio_led)
4826 return;
4827
Takashi Iwai07f80442010-02-08 15:06:13 +01004828 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4829 gpio &= AC_GPIO_IO_COUNT;
4830 if (gpio > 3)
4831 spec->gpio_led = 0x08; /* GPIO 3 */
4832 else
4833 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304834}
4835
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004836/*
4837 * This method searches for the mute LED GPIO configuration
4838 * provided as OEM string in SMBIOS. The format of that string
4839 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4840 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4841 * that corresponds to the NOT muted state of the master volume
4842 * and G is the index of the GPIO to use as the mute LED control (0..9)
4843 * If _G portion is missing it is assigned based on the codec ID
4844 *
4845 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4846 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304847 *
4848 *
4849 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4850 * SMBIOS - at least the ones I have seen do not have them - which include
4851 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4852 * HP Pavilion dv9500t CTO.
4853 * Need more information on whether it is true across the entire series.
4854 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004855 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004856static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004857{
4858 struct sigmatel_spec *spec = codec->spec;
4859 const struct dmi_device *dev = NULL;
4860
4861 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4862 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4863 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004864 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304865 &spec->gpio_led_polarity,
4866 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004867 unsigned int max_gpio;
4868 max_gpio = snd_hda_param_read(codec, codec->afg,
4869 AC_PAR_GPIO_CAP);
4870 max_gpio &= AC_GPIO_IO_COUNT;
4871 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004872 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01004873 else
4874 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004875 return 1;
4876 }
4877 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304878 &spec->gpio_led_polarity) == 1) {
4879 set_hp_led_gpio(codec);
4880 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004881 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004882 /* BIOS bug: unfilled OEM string */
4883 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4884 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02004885 switch (codec->subsystem_id) {
4886 case 0x103c148a:
4887 spec->gpio_led_polarity = 0;
4888 break;
4889 default:
4890 spec->gpio_led_polarity = 1;
4891 break;
4892 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004893 return 1;
4894 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004895 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304896
4897 /*
4898 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004899 * we statically set the GPIO - if not a B-series system
4900 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304901 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004902 if (!hp_blike_system(codec->subsystem_id) &&
4903 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304904 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004905 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304906 return 1;
4907 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004908 }
4909 return 0;
4910}
4911
4912static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004913{
4914 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004915 case 0x103c1520:
4916 case 0x103c1521:
4917 case 0x103c1523:
4918 case 0x103c1524:
4919 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004920 case 0x103c1722:
4921 case 0x103c1723:
4922 case 0x103c1724:
4923 case 0x103c1725:
4924 case 0x103c1726:
4925 case 0x103c1727:
4926 case 0x103c1728:
4927 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004928 case 0x103c172a:
4929 case 0x103c172b:
4930 case 0x103c307e:
4931 case 0x103c307f:
4932 case 0x103c3080:
4933 case 0x103c3081:
4934 case 0x103c7007:
4935 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004936 return 1;
4937 }
4938 return 0;
4939}
4940
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004941#ifdef CONFIG_PROC_FS
4942static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4943 struct hda_codec *codec, hda_nid_t nid)
4944{
4945 if (nid == codec->afg)
4946 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4947 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4948}
4949
4950static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4951 struct hda_codec *codec,
4952 unsigned int verb)
4953{
4954 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4955 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4956}
4957
4958/* stac92hd71bxx, stac92hd73xx */
4959static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4960 struct hda_codec *codec, hda_nid_t nid)
4961{
4962 stac92hd_proc_hook(buffer, codec, nid);
4963 if (nid == codec->afg)
4964 analog_loop_proc_hook(buffer, codec, 0xfa0);
4965}
4966
4967static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4968 struct hda_codec *codec, hda_nid_t nid)
4969{
4970 if (nid == codec->afg)
4971 analog_loop_proc_hook(buffer, codec, 0xfe0);
4972}
4973
4974static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4975 struct hda_codec *codec, hda_nid_t nid)
4976{
4977 if (nid == codec->afg)
4978 analog_loop_proc_hook(buffer, codec, 0xfeb);
4979}
4980#else
4981#define stac92hd_proc_hook NULL
4982#define stac92hd7x_proc_hook NULL
4983#define stac9205_proc_hook NULL
4984#define stac927x_proc_hook NULL
4985#endif
4986
Takashi Iwai2a439522011-07-26 09:52:50 +02004987#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02004988static int stac92xx_resume(struct hda_codec *codec)
4989{
Takashi Iwai2c885872008-11-18 09:36:55 +01004990 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004991 snd_hda_codec_resume_amp(codec);
4992 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004993 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004994 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02004995 return 0;
4996}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004997
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004998static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4999{
5000 stac92xx_shutup(codec);
5001 return 0;
5002}
5003
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005004static int stac92xx_pre_resume(struct hda_codec *codec)
5005{
5006 struct sigmatel_spec *spec = codec->spec;
5007
5008 /* sync mute LED */
Takashi Iwaif1a73742011-12-04 13:44:06 +01005009 if (spec->vref_mute_led_nid)
5010 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5011 spec->vref_led);
5012 else if (spec->gpio_led)
5013 stac_gpio_set(codec, spec->gpio_mask,
5014 spec->gpio_dir, spec->gpio_data);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005015 return 0;
5016}
5017
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005018static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5019 unsigned int power_state)
5020{
5021 unsigned int afg_power_state = power_state;
5022 struct sigmatel_spec *spec = codec->spec;
5023
5024 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005025 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005026 /* with vref-out pin used for mute led control
5027 * codec AFG is prevented from D3 state
5028 */
5029 afg_power_state = AC_PWRST_D1;
5030 }
5031 /* this delay seems necessary to avoid click noise at power-down */
5032 msleep(100);
5033 }
5034 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5035 afg_power_state);
5036 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5037}
Takashi Iwai350eba432012-03-16 16:09:03 +01005038#else
5039#define stac92xx_suspend NULL
5040#define stac92xx_resume NULL
5041#define stac92xx_pre_resume NULL
5042#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005043#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005044
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005045/* update mute-LED accoring to the master switch */
5046static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005047{
5048 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005049 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005050
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005051 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005052 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005053
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005054 /* LED state is inverted on these systems */
5055 if (spec->gpio_led_polarity)
5056 muted = !muted;
5057
Takashi Iwaif1a73742011-12-04 13:44:06 +01005058 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005059 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02005060 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005061 else
Takashi Iwai3e843192012-04-19 12:04:03 +02005062 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005063 stac_gpio_set(codec, spec->gpio_mask,
5064 spec->gpio_dir, spec->gpio_data);
5065 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005066 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005067 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5068 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005069 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005070}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05005071
Takashi Iwai2b635362011-05-02 12:33:43 +02005072static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005073 .build_controls = stac92xx_build_controls,
5074 .build_pcms = stac92xx_build_pcms,
5075 .init = stac92xx_init,
5076 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02005077 .unsol_event = stac92xx_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02005078#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005079 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005080 .resume = stac92xx_resume,
5081#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005082 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005083};
5084
5085static int patch_stac9200(struct hda_codec *codec)
5086{
5087 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005088 int err;
Matt2f2f4252005-04-13 14:45:30 +02005089
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005090 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005091 if (spec == NULL)
5092 return -ENOMEM;
5093
Takashi Iwaia252c812009-12-25 22:56:20 +01005094 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005095 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005096 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005097 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005098 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005099 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5100 stac9200_models,
5101 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005102 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005103 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5104 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005105 else
5106 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005107 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005108
5109 spec->multiout.max_channels = 2;
5110 spec->multiout.num_dacs = 1;
5111 spec->multiout.dac_nids = stac9200_dac_nids;
5112 spec->adc_nids = stac9200_adc_nids;
5113 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005114 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005115 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005116 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005117 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005118
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005119 if (spec->board_config == STAC_9200_M4 ||
5120 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005121 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005122 spec->init = stac9200_eapd_init;
5123 else
5124 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005125 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005126
Takashi Iwai117f2572008-03-18 09:53:23 +01005127 if (spec->board_config == STAC_9200_PANASONIC) {
5128 spec->gpio_mask = spec->gpio_dir = 0x09;
5129 spec->gpio_data = 0x00;
5130 }
5131
Mattc7d4b2f2005-06-27 14:59:41 +02005132 err = stac9200_parse_auto_config(codec);
5133 if (err < 0) {
5134 stac92xx_free(codec);
5135 return err;
5136 }
Matt2f2f4252005-04-13 14:45:30 +02005137
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005138 /* CF-74 has no headphone detection, and the driver should *NOT*
5139 * do detection and HP/speaker toggle because the hardware does it.
5140 */
5141 if (spec->board_config == STAC_9200_PANASONIC)
5142 spec->hp_detect = 0;
5143
Matt2f2f4252005-04-13 14:45:30 +02005144 codec->patch_ops = stac92xx_patch_ops;
5145
5146 return 0;
5147}
5148
Tobin Davis8e21c342007-01-08 11:04:17 +01005149static int patch_stac925x(struct hda_codec *codec)
5150{
5151 struct sigmatel_spec *spec;
5152 int err;
5153
5154 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5155 if (spec == NULL)
5156 return -ENOMEM;
5157
Takashi Iwaia252c812009-12-25 22:56:20 +01005158 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005159 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005160 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005161 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005162 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005163
5164 /* Check first for codec ID */
5165 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5166 STAC_925x_MODELS,
5167 stac925x_models,
5168 stac925x_codec_id_cfg_tbl);
5169
5170 /* Now checks for PCI ID, if codec ID is not found */
5171 if (spec->board_config < 0)
5172 spec->board_config = snd_hda_check_board_config(codec,
5173 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005174 stac925x_models,
5175 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005176 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005177 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005178 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5179 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005180 else
5181 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005182 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005183
5184 spec->multiout.max_channels = 2;
5185 spec->multiout.num_dacs = 1;
5186 spec->multiout.dac_nids = stac925x_dac_nids;
5187 spec->adc_nids = stac925x_adc_nids;
5188 spec->mux_nids = stac925x_mux_nids;
5189 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005190 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005191 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005192 switch (codec->vendor_id) {
5193 case 0x83847632: /* STAC9202 */
5194 case 0x83847633: /* STAC9202D */
5195 case 0x83847636: /* STAC9251 */
5196 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005197 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005198 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005199 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5200 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005201 break;
5202 default:
5203 spec->num_dmics = 0;
5204 break;
5205 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005206
5207 spec->init = stac925x_core_init;
5208 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005209 spec->num_caps = 1;
5210 spec->capvols = stac925x_capvols;
5211 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005212
Charles Chin9009b0e2011-11-03 10:27:27 +01005213 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005214 if (!err) {
5215 if (spec->board_config < 0) {
5216 printk(KERN_WARNING "hda_codec: No auto-config is "
5217 "available, default to model=ref\n");
5218 spec->board_config = STAC_925x_REF;
5219 goto again;
5220 }
5221 err = -EINVAL;
5222 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005223 if (err < 0) {
5224 stac92xx_free(codec);
5225 return err;
5226 }
5227
5228 codec->patch_ops = stac92xx_patch_ops;
5229
5230 return 0;
5231}
5232
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005233static int patch_stac92hd73xx(struct hda_codec *codec)
5234{
5235 struct sigmatel_spec *spec;
5236 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5237 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005238 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005239
5240 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5241 if (spec == NULL)
5242 return -ENOMEM;
5243
Takashi Iwaia252c812009-12-25 22:56:20 +01005244 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005245 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005246 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005247 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005248 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5249 spec->pin_nids = stac92hd73xx_pin_nids;
5250 spec->board_config = snd_hda_check_board_config(codec,
5251 STAC_92HD73XX_MODELS,
5252 stac92hd73xx_models,
5253 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005254 /* check codec subsystem id if not found */
5255 if (spec->board_config < 0)
5256 spec->board_config =
5257 snd_hda_check_board_codec_sid_config(codec,
5258 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5259 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005260again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005261 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005262 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5263 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005264 else
5265 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005266 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005267
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005268 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005269 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5270
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005271 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005272 printk(KERN_WARNING "hda_codec: Could not determine "
5273 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005274 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005275 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005276 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005277 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005278 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005279 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005280 break;
5281 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005282 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005283 break;
5284 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005285 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5286 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005287 }
5288 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005289
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005290 spec->aloopback_mask = 0x01;
5291 spec->aloopback_shift = 8;
5292
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005293 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005294 spec->mux_nids = stac92hd73xx_mux_nids;
5295 spec->adc_nids = stac92hd73xx_adc_nids;
5296 spec->dmic_nids = stac92hd73xx_dmic_nids;
5297 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005298 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005299
5300 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5301 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005302 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005303
Takashi Iwai6479c632009-07-28 18:20:25 +02005304 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5305 spec->capvols = stac92hd73xx_capvols;
5306 spec->capsws = stac92hd73xx_capsws;
5307
Matthew Ranostaya7662642008-02-21 07:51:14 +01005308 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005309 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005310 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005311 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005312 case STAC_DELL_M6_AMIC:
5313 case STAC_DELL_M6_DMIC:
5314 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005315 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005316 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005317
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005318 switch (spec->board_config) {
5319 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005320 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005321 spec->num_dmics = 0;
5322 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005323 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005324 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005325 spec->num_dmics = 1;
5326 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005327 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005328 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5329 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005330 spec->num_dmics = 1;
5331 break;
5332 }
5333 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005334 case STAC_ALIENWARE_M17X:
5335 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5336 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5337 spec->eapd_switch = 0;
5338 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005339 default:
5340 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005341 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005342 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005343 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005344 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005345 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005346 /* GPIO0 High = Enable EAPD */
5347 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5348 spec->gpio_data = 0x01;
5349 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005350
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005351 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5352 spec->pwr_nids = stac92hd73xx_pwr_nids;
5353
Charles Chin9009b0e2011-11-03 10:27:27 +01005354 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005355
5356 if (!err) {
5357 if (spec->board_config < 0) {
5358 printk(KERN_WARNING "hda_codec: No auto-config is "
5359 "available, default to model=ref\n");
5360 spec->board_config = STAC_92HD73XX_REF;
5361 goto again;
5362 }
5363 err = -EINVAL;
5364 }
5365
5366 if (err < 0) {
5367 stac92xx_free(codec);
5368 return err;
5369 }
5370
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005371 if (spec->board_config == STAC_92HD73XX_NO_JD)
5372 spec->hp_detect = 0;
5373
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005374 codec->patch_ops = stac92xx_patch_ops;
5375
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005376 codec->proc_widget_hook = stac92hd7x_proc_hook;
5377
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005378 return 0;
5379}
5380
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005381static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005382{
5383 if (codec->vendor_id != 0x111d7605 &&
5384 codec->vendor_id != 0x111d76d1)
5385 return 0;
5386
5387 switch (codec->subsystem_id) {
5388 case 0x103c1618:
5389 case 0x103c1619:
5390 case 0x103c161a:
5391 case 0x103c161b:
5392 case 0x103c161c:
5393 case 0x103c161d:
5394 case 0x103c161e:
5395 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005396
5397 case 0x103c162a:
5398 case 0x103c162b:
5399
5400 case 0x103c1630:
5401 case 0x103c1631:
5402
5403 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005404 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005405 case 0x103c1635:
5406
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005407 case 0x103c3587:
5408 case 0x103c3588:
5409 case 0x103c3589:
5410 case 0x103c358a:
5411
5412 case 0x103c3667:
5413 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005414 case 0x103c3669:
5415
5416 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005417 }
5418 return 0;
5419}
5420
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005421static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5422{
5423 struct sigmatel_spec *spec = codec->spec;
5424 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5425 int i;
5426
5427 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5428 spec->auto_pin_cnt++;
5429
5430 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5431 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5432 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5433 if (nid == stac92hd83xxx_dmic_nids[i]) {
5434 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5435 spec->auto_dmic_cnt++;
5436 }
5437 }
5438 }
5439}
5440
5441static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5442{
5443 struct sigmatel_spec *spec = codec->spec;
5444
5445 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5446 spec->auto_adc_cnt++;
5447}
5448
5449static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5450{
5451 int i, j;
5452 struct sigmatel_spec *spec = codec->spec;
5453
5454 for (i = 0; i < spec->auto_adc_cnt; i++) {
5455 if (get_connection_index(codec,
5456 spec->auto_adc_nids[i], nid) >= 0) {
5457 /* mux and volume for adc_nids[i] */
5458 if (!spec->auto_mux_nids[i]) {
5459 spec->auto_mux_nids[i] = nid;
5460 /* 92hd codecs capture volume is in mux */
5461 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5462 3, 0, HDA_OUTPUT);
5463 }
5464 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5465 if (get_connection_index(codec, nid,
5466 spec->auto_dmic_nids[j]) >= 0) {
5467 /* dmux for adc_nids[i] */
5468 if (!spec->auto_dmux_nids[i])
5469 spec->auto_dmux_nids[i] = nid;
5470 break;
5471 }
5472 }
5473 break;
5474 }
5475 }
5476}
5477
5478static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5479{
5480 hda_nid_t nid, end_nid;
5481 unsigned int wid_caps, wid_type;
5482 struct sigmatel_spec *spec = codec->spec;
5483
5484 end_nid = codec->start_nid + codec->num_nodes;
5485
5486 for (nid = codec->start_nid; nid < end_nid; nid++) {
5487 wid_caps = get_wcaps(codec, nid);
5488 wid_type = get_wcaps_type(wid_caps);
5489
5490 if (wid_type == AC_WID_PIN)
5491 stac92hd8x_add_pin(codec, nid);
5492
5493 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5494 stac92hd8x_add_adc(codec, nid);
5495 }
5496
5497 for (nid = codec->start_nid; nid < end_nid; nid++) {
5498 wid_caps = get_wcaps(codec, nid);
5499 wid_type = get_wcaps_type(wid_caps);
5500
5501 if (wid_type == AC_WID_AUD_SEL)
5502 stac92hd8x_add_mux(codec, nid);
5503 }
5504
5505 spec->pin_nids = spec->auto_pin_nids;
5506 spec->num_pins = spec->auto_pin_cnt;
5507 spec->adc_nids = spec->auto_adc_nids;
5508 spec->num_adcs = spec->auto_adc_cnt;
5509 spec->capvols = spec->auto_capvols;
5510 spec->capsws = spec->auto_capvols;
5511 spec->num_caps = spec->auto_adc_cnt;
5512 spec->mux_nids = spec->auto_mux_nids;
5513 spec->num_muxes = spec->auto_adc_cnt;
5514 spec->dmux_nids = spec->auto_dmux_nids;
5515 spec->num_dmuxes = spec->auto_adc_cnt;
5516 spec->dmic_nids = spec->auto_dmic_nids;
5517 spec->num_dmics = spec->auto_dmic_cnt;
5518}
5519
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005520static int patch_stac92hd83xxx(struct hda_codec *codec)
5521{
5522 struct sigmatel_spec *spec;
5523 int err;
5524
5525 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5526 if (spec == NULL)
5527 return -ENOMEM;
5528
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005529 if (hp_bnb2011_with_dock(codec)) {
5530 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5531 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5532 }
5533
Takashi Iwaia252c812009-12-25 22:56:20 +01005534 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005535 codec->spec = spec;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005536
5537 stac92hd8x_fill_auto_spec(codec);
5538
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01005539 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005540 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005541 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005542 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005543 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005544 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005545 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005546
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005547 spec->board_config = snd_hda_check_board_config(codec,
5548 STAC_92HD83XXX_MODELS,
5549 stac92hd83xxx_models,
5550 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005551 /* check codec subsystem id if not found */
5552 if (spec->board_config < 0)
5553 spec->board_config =
5554 snd_hda_check_board_codec_sid_config(codec,
5555 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
5556 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005557again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005558 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005559 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5560 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005561 else
5562 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005563 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005564
Takashi Iwaib4e81872009-11-18 17:20:24 +01005565 codec->patch_ops = stac92xx_patch_ops;
5566
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005567 switch (spec->board_config) {
5568 case STAC_HP_ZEPHYR:
5569 spec->init = stac92hd83xxx_hp_zephyr_init;
5570 break;
5571 }
5572
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005573 if (find_mute_led_cfg(codec, -1/*no default cfg*/))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005574 snd_printd("mute LED gpio %d polarity %d\n",
5575 spec->gpio_led,
5576 spec->gpio_led_polarity);
5577
Takashi Iwaib4e81872009-11-18 17:20:24 +01005578 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005579 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005580 spec->gpio_mask |= spec->gpio_led;
5581 spec->gpio_dir |= spec->gpio_led;
5582 spec->gpio_data |= spec->gpio_led;
5583 } else {
5584 codec->patch_ops.set_power_state =
5585 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005586 }
Takashi Iwai350eba432012-03-16 16:09:03 +01005587#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005588 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba432012-03-16 16:09:03 +01005589#endif
Takashi Iwaib4e81872009-11-18 17:20:24 +01005590 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005591
Charles Chin9009b0e2011-11-03 10:27:27 +01005592 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005593 if (!err) {
5594 if (spec->board_config < 0) {
5595 printk(KERN_WARNING "hda_codec: No auto-config is "
5596 "available, default to model=ref\n");
5597 spec->board_config = STAC_92HD83XXX_REF;
5598 goto again;
5599 }
5600 err = -EINVAL;
5601 }
5602
5603 if (err < 0) {
5604 stac92xx_free(codec);
5605 return err;
5606 }
5607
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005608 codec->proc_widget_hook = stac92hd_proc_hook;
5609
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005610 return 0;
5611}
5612
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005613static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5614 hda_nid_t dig0pin)
5615{
5616 struct sigmatel_spec *spec = codec->spec;
5617 int idx;
5618
5619 for (idx = 0; idx < spec->num_pins; idx++)
5620 if (spec->pin_nids[idx] == dig0pin)
5621 break;
5622 if ((idx + 2) >= spec->num_pins)
5623 return 0;
5624
5625 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005626 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005627 return 2;
5628
5629 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005630 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005631 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005632 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005633 return 1;
5634 else
5635 return 0;
5636}
5637
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005638/* HP dv7 bass switch - GPIO5 */
5639#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5640static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5641 struct snd_ctl_elem_value *ucontrol)
5642{
5643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5644 struct sigmatel_spec *spec = codec->spec;
5645 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5646 return 0;
5647}
5648
5649static int stac_hp_bass_gpio_put(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 unsigned int gpio_data;
5655
5656 gpio_data = (spec->gpio_data & ~0x20) |
5657 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5658 if (gpio_data == spec->gpio_data)
5659 return 0;
5660 spec->gpio_data = gpio_data;
5661 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5662 return 1;
5663}
5664
Takashi Iwai2b635362011-05-02 12:33:43 +02005665static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5667 .info = stac_hp_bass_gpio_info,
5668 .get = stac_hp_bass_gpio_get,
5669 .put = stac_hp_bass_gpio_put,
5670};
5671
5672static int stac_add_hp_bass_switch(struct hda_codec *codec)
5673{
5674 struct sigmatel_spec *spec = codec->spec;
5675
5676 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5677 "Bass Speaker Playback Switch", 0))
5678 return -ENOMEM;
5679
5680 spec->gpio_mask |= 0x20;
5681 spec->gpio_dir |= 0x20;
5682 spec->gpio_data |= 0x20;
5683 return 0;
5684}
5685
Matthew Ranostaye035b842007-11-06 11:53:55 +01005686static int patch_stac92hd71bxx(struct hda_codec *codec)
5687{
5688 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02005689 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005690 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005691 int err = 0;
5692
5693 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5694 if (spec == NULL)
5695 return -ENOMEM;
5696
Takashi Iwaia252c812009-12-25 22:56:20 +01005697 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005698 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005699 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005700 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005701 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5702 switch (codec->vendor_id) {
5703 case 0x111d76b6:
5704 case 0x111d76b7:
5705 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5706 break;
5707 case 0x111d7603:
5708 case 0x111d7608:
5709 /* On 92HD75Bx 0x27 isn't a pin nid */
5710 spec->num_pins--;
5711 /* fallthrough */
5712 default:
5713 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5714 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005715 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005716 spec->board_config = snd_hda_check_board_config(codec,
5717 STAC_92HD71BXX_MODELS,
5718 stac92hd71bxx_models,
5719 stac92hd71bxx_cfg_tbl);
5720again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005721 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005722 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5723 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005724 else
5725 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005726 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005727
Takashi Iwaifc64b262009-09-14 15:33:01 +02005728 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005729 /* GPIO0 = EAPD */
5730 spec->gpio_mask = 0x01;
5731 spec->gpio_dir = 0x01;
5732 spec->gpio_data = 0x01;
5733 }
5734
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005735 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5736 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5737
Takashi Iwai6479c632009-07-28 18:20:25 +02005738 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5739 spec->capvols = stac92hd71bxx_capvols;
5740 spec->capsws = stac92hd71bxx_capsws;
5741
Matthew Ranostay541eee82007-12-14 12:08:04 +01005742 switch (codec->vendor_id) {
5743 case 0x111d76b6: /* 4 Port without Analog Mixer */
5744 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005745 unmute_init++;
5746 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005747 case 0x111d76b4: /* 6 Port without Analog Mixer */
5748 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005749 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005750 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005751 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005752 stac92hd71bxx_dmic_nids,
5753 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005754 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005755 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005756 switch (spec->board_config) {
5757 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005758 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai3a938972011-10-28 01:16:55 +02005759 err = stac_add_event(codec, codec->afg,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005760 STAC_VREF_EVENT, 0x02);
5761 if (err < 0)
5762 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005763 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005764 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai3a938972011-10-28 01:16:55 +02005765 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005766 spec->gpio_mask |= 0x02;
5767 break;
5768 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005769 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005770 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005771 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005772
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005773 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005774 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005775 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005776 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5777 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02005778 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005779 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005780 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005781 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005782 break;
5783 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005784 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005785 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005786
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005787 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005788 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005789 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005790 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005791 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005792 stac92hd71bxx_dmic_nids,
5793 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005794 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005795 }
5796
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005797 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5798 snd_hda_sequence_write_cache(codec, unmute_init);
5799
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005800 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005801 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005802 spec->aloopback_shift = 0;
5803
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005804 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005805 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005806 spec->mux_nids = stac92hd71bxx_mux_nids;
5807 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005808 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005809 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005810
5811 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5812 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005813 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005814 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005815
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305816 snd_printdd("Found board config: %d\n", spec->board_config);
5817
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005818 switch (spec->board_config) {
5819 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005820 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005821 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005822 stac92xx_auto_set_pinctl(codec, 0x0e,
5823 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005824 /* fallthru */
5825 case STAC_DELL_M4_2:
5826 spec->num_dmics = 0;
5827 spec->num_smuxes = 0;
5828 spec->num_dmuxes = 0;
5829 break;
5830 case STAC_DELL_M4_1:
5831 case STAC_DELL_M4_3:
5832 spec->num_dmics = 1;
5833 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005834 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005835 break;
James Gardiner514bf542009-05-03 04:00:44 -04005836 case STAC_HP_DV4_1222NR:
5837 spec->num_dmics = 1;
5838 /* I don't know if it needs 1 or 2 smuxes - will wait for
5839 * bug reports to fix if needed
5840 */
5841 spec->num_smuxes = 1;
5842 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005843 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005844 case STAC_HP_DV4:
5845 spec->gpio_led = 0x01;
5846 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005847 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005848 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005849 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005850 /* HP dv6 gives the headphone pin as a line-out. Thus we
5851 * need to set hp_detect flag here to force to enable HP
5852 * detection.
5853 */
5854 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005855 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005856 case STAC_HP_HDX:
5857 spec->num_dmics = 1;
5858 spec->num_dmuxes = 1;
5859 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005860 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005861 break;
5862 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005863
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005864 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005865 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5866 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5867 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5868 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5869 /* It was changed in the BIOS to just satisfy MS DTM.
5870 * Lets turn it back into slaved HP
5871 */
5872 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5873 | (AC_JACK_HP_OUT <<
5874 AC_DEFCFG_DEVICE_SHIFT);
5875 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5876 | AC_DEFCFG_SEQUENCE)))
5877 | 0x1f;
5878 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5879 }
5880 }
5881
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005882 if (find_mute_led_cfg(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005883 snd_printd("mute LED gpio %d polarity %d\n",
5884 spec->gpio_led,
5885 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005886
Takashi Iwai86d190e2009-05-26 15:18:58 +02005887 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005888 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005889 spec->gpio_mask |= spec->gpio_led;
5890 spec->gpio_dir |= spec->gpio_led;
5891 spec->gpio_data |= spec->gpio_led;
5892 } else {
5893 codec->patch_ops.set_power_state =
5894 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005895 }
Takashi Iwai350eba432012-03-16 16:09:03 +01005896#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005897 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba432012-03-16 16:09:03 +01005898#endif
Takashi Iwai86d190e2009-05-26 15:18:58 +02005899 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005900
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005901 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005902
Charles Chin9009b0e2011-11-03 10:27:27 +01005903 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005904 if (!err) {
5905 if (spec->board_config < 0) {
5906 printk(KERN_WARNING "hda_codec: No auto-config is "
5907 "available, default to model=ref\n");
5908 spec->board_config = STAC_92HD71BXX_REF;
5909 goto again;
5910 }
5911 err = -EINVAL;
5912 }
5913
5914 if (err < 0) {
5915 stac92xx_free(codec);
5916 return err;
5917 }
5918
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005919 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005920 if (spec->board_config == STAC_HP_DV4 ||
5921 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005922 unsigned int cap;
5923 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5924 cap &= AC_GPIO_IO_COUNT;
5925 if (cap >= 6)
5926 stac_add_hp_bass_switch(codec);
5927 }
5928
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005929 codec->proc_widget_hook = stac92hd7x_proc_hook;
5930
Matthew Ranostaye035b842007-11-06 11:53:55 +01005931 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005932}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005933
Matt2f2f4252005-04-13 14:45:30 +02005934static int patch_stac922x(struct hda_codec *codec)
5935{
5936 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005937 int err;
Matt2f2f4252005-04-13 14:45:30 +02005938
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005939 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005940 if (spec == NULL)
5941 return -ENOMEM;
5942
Takashi Iwaia252c812009-12-25 22:56:20 +01005943 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005944 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005945 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005946 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005947 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005948 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5949 stac922x_models,
5950 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005951 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005952 spec->gpio_mask = spec->gpio_dir = 0x03;
5953 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005954 /* Intel Macs have all same PCI SSID, so we need to check
5955 * codec SSID to distinguish the exact models
5956 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005957 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005958 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005959
5960 case 0x106b0800:
5961 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005962 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005963 case 0x106b0600:
5964 case 0x106b0700:
5965 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005966 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005967 case 0x106b0e00:
5968 case 0x106b0f00:
5969 case 0x106b1600:
5970 case 0x106b1700:
5971 case 0x106b0200:
5972 case 0x106b1e00:
5973 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005974 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005975 case 0x106b1a00:
5976 case 0x00000100:
5977 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005978 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005979 case 0x106b0a00:
5980 case 0x106b2200:
5981 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005982 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005983 default:
5984 spec->board_config = STAC_INTEL_MAC_V3;
5985 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005986 }
5987 }
5988
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005989 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005990 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005991 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5992 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005993 else
5994 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005995 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005996
Matt2f2f4252005-04-13 14:45:30 +02005997 spec->adc_nids = stac922x_adc_nids;
5998 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005999 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006000 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006001 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006002 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02006003
6004 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006005
6006 spec->num_caps = STAC922X_NUM_CAPS;
6007 spec->capvols = stac922x_capvols;
6008 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02006009
6010 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02006011
Charles Chin9009b0e2011-11-03 10:27:27 +01006012 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006013 if (!err) {
6014 if (spec->board_config < 0) {
6015 printk(KERN_WARNING "hda_codec: No auto-config is "
6016 "available, default to model=ref\n");
6017 spec->board_config = STAC_D945_REF;
6018 goto again;
6019 }
6020 err = -EINVAL;
6021 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006022 if (err < 0) {
6023 stac92xx_free(codec);
6024 return err;
6025 }
6026
6027 codec->patch_ops = stac92xx_patch_ops;
6028
Takashi Iwai807a46362007-05-29 19:01:37 +02006029 /* Fix Mux capture level; max to 2 */
6030 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6031 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6032 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6033 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6034 (0 << AC_AMPCAP_MUTE_SHIFT));
6035
Matt Porter3cc08dc2006-01-23 15:27:49 +01006036 return 0;
6037}
6038
6039static int patch_stac927x(struct hda_codec *codec)
6040{
6041 struct sigmatel_spec *spec;
6042 int err;
6043
6044 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6045 if (spec == NULL)
6046 return -ENOMEM;
6047
Takashi Iwaia252c812009-12-25 22:56:20 +01006048 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006049 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006050 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006051 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006052 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006053 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006054 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6055 stac927x_models,
6056 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006057 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006058 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006059 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6060 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006061 else
6062 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006063 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006064
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006065 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006066 spec->adc_nids = stac927x_adc_nids;
6067 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6068 spec->mux_nids = stac927x_mux_nids;
6069 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006070 spec->smux_nids = stac927x_smux_nids;
6071 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006072 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006073 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006074 spec->multiout.dac_nids = spec->dac_nids;
6075
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006076 if (spec->board_config != STAC_D965_REF) {
6077 /* GPIO0 High = Enable EAPD */
6078 spec->eapd_mask = spec->gpio_mask = 0x01;
6079 spec->gpio_dir = spec->gpio_data = 0x01;
6080 }
6081
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006082 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02006083 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006084 case STAC_D965_5ST:
6085 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006086 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02006087 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006088 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006089 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006090 switch (codec->subsystem_id) {
6091 case 0x10280209:
6092 case 0x1028022e:
6093 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006094 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006095 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006096 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01006097 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01006098 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01006099 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006100 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006101 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01006102 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006103 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006104 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006105 if (codec->subsystem_id != 0x1028022f) {
6106 /* GPIO2 High = Enable EAPD */
6107 spec->eapd_mask = spec->gpio_mask = 0x04;
6108 spec->gpio_dir = spec->gpio_data = 0x04;
6109 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006110 spec->dmic_nids = stac927x_dmic_nids;
6111 spec->num_dmics = STAC927X_NUM_DMICS;
6112
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02006113 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006114 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006115 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006116 break;
Takashi Iwai54930532009-10-11 17:38:29 +02006117 case STAC_927X_VOLKNOB:
6118 spec->num_dmics = 0;
6119 spec->init = stac927x_volknob_core_init;
6120 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006121 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006122 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006123 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006124 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006125 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006126
Takashi Iwai6479c632009-07-28 18:20:25 +02006127 spec->num_caps = STAC927X_NUM_CAPS;
6128 spec->capvols = stac927x_capvols;
6129 spec->capsws = stac927x_capsws;
6130
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006131 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006132 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006133 spec->aloopback_mask = 0x40;
6134 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006135 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006136
Charles Chin9009b0e2011-11-03 10:27:27 +01006137 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006138 if (!err) {
6139 if (spec->board_config < 0) {
6140 printk(KERN_WARNING "hda_codec: No auto-config is "
6141 "available, default to model=ref\n");
6142 spec->board_config = STAC_D965_REF;
6143 goto again;
6144 }
6145 err = -EINVAL;
6146 }
Mattc7d4b2f2005-06-27 14:59:41 +02006147 if (err < 0) {
6148 stac92xx_free(codec);
6149 return err;
6150 }
Matt2f2f4252005-04-13 14:45:30 +02006151
6152 codec->patch_ops = stac92xx_patch_ops;
6153
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006154 codec->proc_widget_hook = stac927x_proc_hook;
6155
Takashi Iwai52987652008-01-16 16:09:47 +01006156 /*
6157 * !!FIXME!!
6158 * The STAC927x seem to require fairly long delays for certain
6159 * command sequences. With too short delays (even if the answer
6160 * is set to RIRB properly), it results in the silence output
6161 * on some hardwares like Dell.
6162 *
6163 * The below flag enables the longer delay (see get_response
6164 * in hda_intel.c).
6165 */
6166 codec->bus->needs_damn_long_delay = 1;
6167
Takashi Iwaie28d8322008-12-17 13:48:29 +01006168 /* no jack detecion for ref-no-jd model */
6169 if (spec->board_config == STAC_D965_REF_NO_JD)
6170 spec->hp_detect = 0;
6171
Matt2f2f4252005-04-13 14:45:30 +02006172 return 0;
6173}
6174
Matt Porterf3302a52006-07-31 12:49:34 +02006175static int patch_stac9205(struct hda_codec *codec)
6176{
6177 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006178 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006179
6180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6181 if (spec == NULL)
6182 return -ENOMEM;
6183
Takashi Iwaia252c812009-12-25 22:56:20 +01006184 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006185 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006186 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006187 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006188 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006189 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6190 stac9205_models,
6191 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006192 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006193 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006194 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6195 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006196 else
6197 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006198 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006199
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006200 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006201 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006202 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006203 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006204 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006205 spec->smux_nids = stac9205_smux_nids;
6206 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006207 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006208 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006209 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006210 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006211 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006212
6213 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006214 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006215
Takashi Iwai6479c632009-07-28 18:20:25 +02006216 spec->num_caps = STAC9205_NUM_CAPS;
6217 spec->capvols = stac9205_capvols;
6218 spec->capsws = stac9205_capsws;
6219
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006220 spec->aloopback_mask = 0x40;
6221 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006222 /* Turn on/off EAPD per HP plugging */
6223 if (spec->board_config != STAC_9205_EAPD)
6224 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006225 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006226
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006227 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006228 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006229 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006230 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6231 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006232
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006233 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwai3a938972011-10-28 01:16:55 +02006234 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006235 if (err < 0)
6236 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006237 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006238 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
Takashi Iwai3a938972011-10-28 01:16:55 +02006239 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006240
6241 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006242 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006243 spec->gpio_mask = 0x1b;
6244 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006245 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006246 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006247 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006248 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006249 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006250 case STAC_9205_REF:
6251 /* SPDIF-In enabled */
6252 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006253 default:
6254 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006255 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006256 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006257 break;
6258 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006259
Charles Chin9009b0e2011-11-03 10:27:27 +01006260 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006261 if (!err) {
6262 if (spec->board_config < 0) {
6263 printk(KERN_WARNING "hda_codec: No auto-config is "
6264 "available, default to model=ref\n");
6265 spec->board_config = STAC_9205_REF;
6266 goto again;
6267 }
6268 err = -EINVAL;
6269 }
Matt Porterf3302a52006-07-31 12:49:34 +02006270 if (err < 0) {
6271 stac92xx_free(codec);
6272 return err;
6273 }
6274
6275 codec->patch_ops = stac92xx_patch_ops;
6276
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006277 codec->proc_widget_hook = stac9205_proc_hook;
6278
Matt Porterf3302a52006-07-31 12:49:34 +02006279 return 0;
6280}
6281
Matt2f2f4252005-04-13 14:45:30 +02006282/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006283 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006284 */
6285
Takashi Iwai2b635362011-05-02 12:33:43 +02006286static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6289 {}
6290};
6291
Takashi Iwai2b635362011-05-02 12:33:43 +02006292static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006293 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6294 0x11, 0x13, 0x14,
6295};
6296
Takashi Iwai2b635362011-05-02 12:33:43 +02006297static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006298 0x8 /*,0x6*/
6299};
6300
Takashi Iwai2b635362011-05-02 12:33:43 +02006301static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006302 0x15
6303};
6304
Takashi Iwai2b635362011-05-02 12:33:43 +02006305static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006306 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6307};
6308#define stac9872_capsws stac9872_capvols
6309
Takashi Iwai2b635362011-05-02 12:33:43 +02006310static const unsigned int stac9872_vaio_pin_configs[9] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006311 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6312 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6313 0x90a7013e
6314};
6315
Takashi Iwaiea734962011-01-17 11:29:34 +01006316static const char * const stac9872_models[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006317 [STAC_9872_AUTO] = "auto",
6318 [STAC_9872_VAIO] = "vaio",
6319};
6320
Takashi Iwai2b635362011-05-02 12:33:43 +02006321static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006322 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6323};
6324
Takashi Iwai2b635362011-05-02 12:33:43 +02006325static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006326 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6327 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006328 {} /* terminator */
6329};
6330
Guillaume Munch6d859062006-08-22 17:15:47 +02006331static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006332{
6333 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006334 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006335
Takashi Iwaidb064e52006-03-16 16:04:58 +01006336 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6337 if (spec == NULL)
6338 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006339 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006340 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006341 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006342 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6343 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006344
6345 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6346 stac9872_models,
6347 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006348 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006349 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6350 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006351 else
6352 stac92xx_set_config_regs(codec,
6353 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006354
Takashi Iwai1e137f92009-01-21 07:41:22 +01006355 spec->multiout.dac_nids = spec->dac_nids;
6356 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6357 spec->adc_nids = stac9872_adc_nids;
6358 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6359 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006360 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006361 spec->num_caps = 1;
6362 spec->capvols = stac9872_capvols;
6363 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006364
Charles Chin9009b0e2011-11-03 10:27:27 +01006365 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01006366 if (err < 0) {
6367 stac92xx_free(codec);
6368 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006369 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006370 spec->input_mux = &spec->private_imux;
6371 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006372 return 0;
6373}
6374
6375
6376/*
Matt2f2f4252005-04-13 14:45:30 +02006377 * patch entries
6378 */
Takashi Iwai2b635362011-05-02 12:33:43 +02006379static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006380 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6381 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6382 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6383 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6384 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6385 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6386 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006387 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6388 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6389 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6390 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6391 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6392 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006393 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6394 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6395 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6396 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6397 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6398 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6399 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6400 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6401 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6402 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006403 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6404 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6405 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6406 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6407 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6408 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006409 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6410 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006411 /* The following does not take into account .id=0x83847661 when subsys =
6412 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6413 * currently not fully supported.
6414 */
6415 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6416 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6417 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006418 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006419 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6420 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6421 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6422 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6423 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6424 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6425 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6426 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006427 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006428 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006429 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006430 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006431 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02006432 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6433 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006434 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6435 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6436 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6437 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006438 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006439 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6440 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006441 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006442 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6443 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6444 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6445 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6446 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6447 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6448 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6449 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02006450 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6451 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6452 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6453 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6454 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6455 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6456 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6457 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6458 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6459 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6460 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6461 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6462 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6463 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6464 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02006465 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006466 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06006467 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6468 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006469 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01006470 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6471 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6472 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6473 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6474 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6475 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6476 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6477 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6478 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6479 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6480 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6481 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02006482 {} /* terminator */
6483};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006484
6485MODULE_ALIAS("snd-hda-codec-id:8384*");
6486MODULE_ALIAS("snd-hda-codec-id:111d*");
6487
6488MODULE_LICENSE("GPL");
6489MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6490
6491static struct hda_codec_preset_list sigmatel_list = {
6492 .preset = snd_hda_preset_sigmatel,
6493 .owner = THIS_MODULE,
6494};
6495
6496static int __init patch_sigmatel_init(void)
6497{
6498 return snd_hda_add_codec_preset(&sigmatel_list);
6499}
6500
6501static void __exit patch_sigmatel_exit(void)
6502{
6503 snd_hda_delete_codec_preset(&sigmatel_list);
6504}
6505
6506module_init(patch_sigmatel_init)
6507module_exit(patch_sigmatel_exit)