blob: f9757356a1fe8a56165bc32b5708d4422fbaa200 [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"
Takashi Iwai128bc4b2012-05-07 17:42:31 +020039#include "hda_auto_parser.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020040#include "hda_beep.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020041#include "hda_jack.h"
Matt2f2f4252005-04-13 14:45:30 +020042
Takashi Iwaic6e4c662008-11-25 11:58:19 +010043enum {
44 STAC_VREF_EVENT = 1,
45 STAC_INSERT_EVENT,
46 STAC_PWR_EVENT,
47 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020048 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020049 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010050};
Matt4e550962005-07-04 17:51:39 +020051
Takashi Iwaif5fcc132006-11-24 17:07:44 +010052enum {
53 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 Iwaid39a3ae2013-01-14 14:06:26 +010068 STAC_9200_EAPD_INIT,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_9200_MODELS
70};
71
72enum {
73 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 Iwai9e43f0d2008-12-17 14:51:01 +010082 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010083 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080084 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010085 STAC_DELL_M6_AMIC,
86 STAC_DELL_M6_DMIC,
87 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050088 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020089 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010090 STAC_92HD73XX_MODELS
91};
92
93enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020094 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050095 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050096 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010097 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -050098 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -060099 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600100 STAC_HP_ZEPHYR,
Takashi Iwaia3e19972012-07-26 08:17:20 +0200101 STAC_92HD83XXX_HP_LED,
Takashi Iwaiff8a1e22012-07-31 10:16:59 +0200102 STAC_92HD83XXX_HP_INV_LED,
Takashi Iwai62cbde12012-09-14 11:58:54 +0200103 STAC_92HD83XXX_HP_MIC_LED,
David Henningsson8d032a82012-10-09 12:48:40 +0200104 STAC_92HD83XXX_HEADSET_JACK,
Takashi Iwai372f8c72013-01-14 18:06:34 +0100105 STAC_92HD83XXX_HP,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200106 STAC_92HD83XXX_MODELS
107};
108
109enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100110 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100111 STAC_DELL_M4_1,
112 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500113 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400114 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200115 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100116 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100117 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400118 STAC_HP_DV4_1222NR,
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100119 STAC_92HD71BXX_HP,
120 STAC_92HD71BXX_NO_DMIC,
121 STAC_92HD71BXX_NO_SMUX,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100122 STAC_92HD71BXX_MODELS
123};
124
125enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100126 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200127 STAC_M1,
128 STAC_M1_2,
129 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100130 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200131 STAC_M3,
132 STAC_M5,
133 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100134 STAC_925x_MODELS
135};
136
137enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100138 STAC_D945_REF,
139 STAC_D945GTP3,
140 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200141 STAC_INTEL_MAC_V1,
142 STAC_INTEL_MAC_V2,
143 STAC_INTEL_MAC_V3,
144 STAC_INTEL_MAC_V4,
145 STAC_INTEL_MAC_V5,
Takashi Iwai0a427842013-01-14 15:20:13 +0100146 STAC_INTEL_MAC_AUTO,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300147 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200148 STAC_922X_DELL_D81,
149 STAC_922X_DELL_D82,
150 STAC_922X_DELL_M81,
151 STAC_922X_DELL_M82,
Takashi Iwai0a427842013-01-14 15:20:13 +0100152 STAC_922X_INTEL_MAC_GPIO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100153 STAC_922X_MODELS
154};
155
156enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100157 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100158 STAC_D965_REF,
159 STAC_D965_3ST,
160 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200161 STAC_D965_5ST_NO_FP,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100162 STAC_D965_VERBS,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200163 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100164 STAC_DELL_BIOS,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100165 STAC_DELL_BIOS_SPDIF,
166 STAC_927X_DELL_DMIC,
Takashi Iwai54930532009-10-11 17:38:29 +0200167 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100168 STAC_927X_MODELS
169};
Matt Porter403d1942005-11-29 15:00:51 +0100170
Takashi Iwai307282c2009-03-12 18:17:58 +0100171enum {
Takashi Iwai307282c2009-03-12 18:17:58 +0100172 STAC_9872_VAIO,
173 STAC_9872_MODELS
174};
175
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200176struct sigmatel_mic_route {
177 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200178 signed char mux_idx;
179 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200180};
181
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600182#define MAX_PINS_NUM 16
183#define MAX_ADCS_NUM 4
184#define MAX_DMICS_NUM 4
185
Matt2f2f4252005-04-13 14:45:30 +0200186struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100187 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200188 unsigned int num_mixers;
189
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500190 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200191 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100192 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100193 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400194 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100195 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200196 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100197 unsigned int linear_tone_beep:1;
David Henningsson8d032a82012-10-09 12:48:40 +0200198 unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
Takashi Iwai29ac8362013-01-14 16:03:38 +0100199 unsigned int volknob_init:1; /* special volume-knob initialization */
Mattc7d4b2f2005-06-27 14:59:41 +0200200
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100201 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200202 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100203 unsigned int gpio_mask;
204 unsigned int gpio_dir;
205 unsigned int gpio_data;
206 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200207 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100208 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100209 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500210 unsigned int vref_led;
Takashi Iwai372f8c72013-01-14 18:06:34 +0100211 int default_polarity;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100212
Takashi Iwai62cbde12012-09-14 11:58:54 +0200213 unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
214 bool mic_mute_led_on; /* current mic mute state */
215
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200216 /* stream */
217 unsigned int stream_delay;
218
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100219 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200220 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100221 unsigned char aloopback_mask;
222 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200223
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100224 /* power management */
Takashi Iwaic8822462012-05-15 09:11:36 +0200225 unsigned int power_map_bits;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100226 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200227 const hda_nid_t *pwr_nids;
228 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100229
Matt2f2f4252005-04-13 14:45:30 +0200230 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100231 struct hda_input_mux *mono_mux;
232 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200233 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100234 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100235 hda_nid_t hp_dacs[5];
236 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200237
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100238 int volume_offset;
239
Matt2f2f4252005-04-13 14:45:30 +0200240 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200241 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200242 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200243 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200244 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200245 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200246 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200247 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100248 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200249 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200250 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200251 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200252
Takashi Iwai2b635362011-05-02 12:33:43 +0200253 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
254 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200255 unsigned int num_caps; /* number of capture volume/switch elements */
256
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200257 struct sigmatel_mic_route ext_mic;
258 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200259 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200260
Takashi Iwaiea734962011-01-17 11:29:34 +0100261 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200262
Mattdabbed62005-06-14 10:19:34 +0200263 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100264 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200265 hda_nid_t anabeep_nid;
266 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200267
Matt2f2f4252005-04-13 14:45:30 +0200268 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200269 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200270 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200271
272 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200273 const struct hda_verb *init;
274 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200275
276 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200277 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100278 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200279 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100280 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200281 struct hda_input_mux *sinput_mux;
282 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400283 unsigned int cur_amux;
284 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200285 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200286
Matt Porter403d1942005-11-29 15:00:51 +0100287 /* i/o switches */
288 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200289 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100290 hda_nid_t line_switch; /* shared line-in for input and output */
291 hda_nid_t mic_switch; /* shared mic-in for input and output */
292 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200293 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200294
Mattc7d4b2f2005-06-27 14:59:41 +0200295 struct hda_pcm pcm_rec[2]; /* PCM information */
296
297 /* dynamic controls and input_mux */
298 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200299 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200300 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200301 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200302 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100303 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600304
305 /* auto spec */
306 unsigned auto_pin_cnt;
307 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
308 unsigned auto_adc_cnt;
309 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
310 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
311 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
312 unsigned long auto_capvols[MAX_ADCS_NUM];
313 unsigned auto_dmic_cnt;
314 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100315
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100316 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200317};
318
Takashi Iwaic8822462012-05-15 09:11:36 +0200319#define AC_VERB_IDT_SET_POWER_MAP 0x7ec
320#define AC_VERB_IDT_GET_POWER_MAP 0xfec
321
Takashi Iwai2b635362011-05-02 12:33:43 +0200322static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200323 0x03,
324};
325
Takashi Iwai2b635362011-05-02 12:33:43 +0200326static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200327 0x0c,
328};
329
Takashi Iwai2b635362011-05-02 12:33:43 +0200330static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200331 0x02,
332};
333
Takashi Iwai2b635362011-05-02 12:33:43 +0200334static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100335 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
336 0x0f, 0x10, 0x11
337};
338
Takashi Iwai2b635362011-05-02 12:33:43 +0200339static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400340 0x26, 0,
341};
342
Takashi Iwai2b635362011-05-02 12:33:43 +0200343static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100344 0x1a, 0x1b
345};
346
347#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200348static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100349 0x13, 0x14, 0
350};
351
352#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100353
Takashi Iwai2b635362011-05-02 12:33:43 +0200354static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200355 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100356};
357
Takashi Iwai2b635362011-05-02 12:33:43 +0200358static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100359 0x20, 0x21,
360};
361
Takashi Iwai2b635362011-05-02 12:33:43 +0200362static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200363 0x22, 0x23,
364};
365
Takashi Iwai6479c632009-07-28 18:20:25 +0200366#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200367static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200368 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
369 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
370};
371#define stac92hd73xx_capsws stac92hd73xx_capvols
372
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200373#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200374
Charles Chinafef2cf2011-11-11 08:05:28 +0100375static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
376 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
377 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200378};
379
Takashi Iwai2b635362011-05-02 12:33:43 +0200380static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400381 0x1e, 0,
382};
383
Takashi Iwai2b635362011-05-02 12:33:43 +0200384static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600385 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200386};
387
Takashi Iwai2b635362011-05-02 12:33:43 +0200388static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100389 0x0a, 0x0d, 0x0f
390};
391
Takashi Iwai2b635362011-05-02 12:33:43 +0200392static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100393 0x12, 0x13,
394};
395
Takashi Iwai2b635362011-05-02 12:33:43 +0200396static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100397 0x1a, 0x1b
398};
399
Takashi Iwai2b635362011-05-02 12:33:43 +0200400static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400401 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100402};
403
Takashi Iwai2b635362011-05-02 12:33:43 +0200404static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200405 0x24, 0x25,
406};
407
Matthew Ranostaye035b842007-11-06 11:53:55 +0100408#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200409static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100410 0x18, 0x19, 0
411};
412
Takashi Iwai2b635362011-05-02 12:33:43 +0200413static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
414 0x18, 0
415};
416
417static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400418 0x22, 0
419};
420
Takashi Iwai6479c632009-07-28 18:20:25 +0200421#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200422static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200423 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
424 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
425};
426#define stac92hd71bxx_capsws stac92hd71bxx_capvols
427
Takashi Iwai2b635362011-05-02 12:33:43 +0200428static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100429 0x03,
430};
431
Takashi Iwai2b635362011-05-02 12:33:43 +0200432static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100433 0x0f,
434};
435
Takashi Iwai2b635362011-05-02 12:33:43 +0200436static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100437 0x02,
438};
439
Takashi Iwaif6e98522007-10-16 14:27:04 +0200440#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200441static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200442 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200443};
444
Takashi Iwai2b635362011-05-02 12:33:43 +0200445static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100446 0x14,
447};
448
Takashi Iwai2b635362011-05-02 12:33:43 +0200449static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200450 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
451};
Takashi Iwai2b635362011-05-02 12:33:43 +0200452static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200453 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
454};
455
Takashi Iwai2b635362011-05-02 12:33:43 +0200456static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200457 0x06, 0x07,
458};
459
Takashi Iwai2b635362011-05-02 12:33:43 +0200460static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200461 0x12, 0x13,
462};
463
Takashi Iwai6479c632009-07-28 18:20:25 +0200464#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200465static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200466 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
467 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
468};
469#define stac922x_capsws stac922x_capvols
470
Takashi Iwai2b635362011-05-02 12:33:43 +0200471static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500472 0x1f, 0,
473};
474
Takashi Iwai2b635362011-05-02 12:33:43 +0200475static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100476 0x07, 0x08, 0x09
477};
478
Takashi Iwai2b635362011-05-02 12:33:43 +0200479static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100480 0x15, 0x16, 0x17
481};
482
Takashi Iwai2b635362011-05-02 12:33:43 +0200483static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200484 0x21,
485};
486
Takashi Iwai2b635362011-05-02 12:33:43 +0200487static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100488 0x02, 0x03, 0x04, 0x05, 0x06, 0
489};
490
Takashi Iwai2b635362011-05-02 12:33:43 +0200491static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100492 0x1b,
493};
494
Matthew Ranostay7f168592007-10-18 17:38:17 +0200495#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200496static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200497 0x13, 0x14, 0
498};
499
Takashi Iwai6479c632009-07-28 18:20:25 +0200500#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200501static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200502 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
503 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
504 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
505};
Takashi Iwai2b635362011-05-02 12:33:43 +0200506static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200507 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
508 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
509 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
510};
511
Takashi Iwaiea734962011-01-17 11:29:34 +0100512static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400513 "Digital Playback", "ADAT", "Analog Mux 1",
514 "Analog Mux 2", "Analog Mux 3"
515};
516
Takashi Iwai2b635362011-05-02 12:33:43 +0200517static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200518 0x12, 0x13
519};
520
Takashi Iwai2b635362011-05-02 12:33:43 +0200521static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200522 0x19, 0x1a
523};
524
Takashi Iwai2b635362011-05-02 12:33:43 +0200525static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100526 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100527};
528
Takashi Iwai2b635362011-05-02 12:33:43 +0200529static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200530 0x21,
531};
532
Takashi Iwaif6e98522007-10-16 14:27:04 +0200533#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200534static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200535 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200536};
537
Takashi Iwai6479c632009-07-28 18:20:25 +0200538#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200539static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200540 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
541 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
542};
Takashi Iwai2b635362011-05-02 12:33:43 +0200543static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200544 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
545 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
546};
547
Takashi Iwai2b635362011-05-02 12:33:43 +0200548static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200549 0x08, 0x09, 0x0d, 0x0e,
550 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200551};
552
Takashi Iwai2b635362011-05-02 12:33:43 +0200553static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100554 0x07, 0x08, 0x0a, 0x0b,
555 0x0c, 0x0d, 0x10, 0x11,
556};
557
Takashi Iwai2b635362011-05-02 12:33:43 +0200558static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x15, 0x1b,
561};
562
Takashi Iwai2b635362011-05-02 12:33:43 +0200563static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100564 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
565 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200566 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100567};
568
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500569#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200570static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500571 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
572 0x00, 0x14, 0x18, 0x19, 0x1e,
573 0x1f, 0x20, 0x27
574};
Takashi Iwai2b635362011-05-02 12:33:43 +0200575static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100576 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
577 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500578 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100579};
580
Takashi Iwai2b635362011-05-02 12:33:43 +0200581static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100582 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
583 0x0f, 0x10, 0x11, 0x12, 0x13,
584 0x14, 0x21, 0x22, 0x23,
585};
586
Takashi Iwai2b635362011-05-02 12:33:43 +0200587static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200588 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
589 0x0f, 0x14, 0x16, 0x17, 0x18,
590 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200591};
592
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100593static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
594 unsigned char type, int data);
595static int stac_add_hp_bass_switch(struct hda_codec *codec);
596static void stac92xx_auto_set_pinctl(struct hda_codec *codec,
597 hda_nid_t nid, int pin_type);
Takashi Iwai372f8c72013-01-14 18:06:34 +0100598static int hp_bnb2011_with_dock(struct hda_codec *codec);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100599static int hp_blike_system(u32 subsystem_id);
600static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity);
601
Matt Porter8b657272006-10-26 17:12:59 +0200602static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_info *uinfo)
604{
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
608}
609
610static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
612{
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100615 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200616
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100617 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200618 return 0;
619}
620
621static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100626 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200627
628 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100629 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200630}
631
Matthew Ranostayd9737752008-09-07 12:03:41 +0200632static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_info *uinfo)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
638}
639
640static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
646
647 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
648 return 0;
649}
650
651static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400656 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200657 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400658 int err, val;
659 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200660
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400661 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200662 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400663 if (err < 0)
664 return err;
665
666 if (spec->spdif_mute) {
667 if (smux_idx == 0)
668 nid = spec->multiout.dig_out_nid;
669 else
670 nid = codec->slave_dig_outs[smux_idx - 1];
671 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100672 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400673 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100674 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400675 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100676 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
677 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400678 }
679 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200680}
681
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500682static int stac_vrefout_set(struct hda_codec *codec,
683 hda_nid_t nid, unsigned int new_vref)
684{
685 int error, pinctl;
686
687 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
688 pinctl = snd_hda_codec_read(codec, nid, 0,
689 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
690
691 if (pinctl < 0)
692 return pinctl;
693
694 pinctl &= 0xff;
695 pinctl &= ~AC_PINCTL_VREFEN;
696 pinctl |= (new_vref & AC_PINCTL_VREFEN);
697
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200698 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500699 if (error < 0)
700 return error;
701
702 return 1;
703}
704
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200705static unsigned int stac92xx_vref_set(struct hda_codec *codec,
706 hda_nid_t nid, unsigned int new_vref)
707{
Takashi Iwaib8621512009-06-22 08:00:10 +0200708 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200709 unsigned int pincfg;
710 pincfg = snd_hda_codec_read(codec, nid, 0,
711 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
712
713 pincfg &= 0xff;
714 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
715 pincfg |= new_vref;
716
717 if (new_vref == AC_PINCTL_VREF_HIZ)
718 pincfg |= AC_PINCTL_OUT_EN;
719 else
720 pincfg |= AC_PINCTL_IN_EN;
721
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200722 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200723 if (error < 0)
724 return error;
725 else
726 return 1;
727}
728
729static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
730{
731 unsigned int vref;
732 vref = snd_hda_codec_read(codec, nid, 0,
733 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
734 vref &= AC_PINCTL_VREFEN;
735 return vref;
736}
737
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100738static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200739{
740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
741 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200742 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200743}
744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100745static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200746{
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 struct sigmatel_spec *spec = codec->spec;
749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
750
751 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
752 return 0;
753}
754
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100755static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200756{
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 struct sigmatel_spec *spec = codec->spec;
759 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200760 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600761 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200762
Takashi Iwai5207e102009-07-30 13:09:08 +0200763 idx = ucontrol->value.enumerated.item[0];
764 if (idx >= imux->num_items)
765 idx = imux->num_items - 1;
766 prev_idx = spec->cur_mux[adc_idx];
767 if (prev_idx == idx)
768 return 0;
769 if (idx < spec->num_analog_muxes) {
770 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
771 AC_VERB_SET_CONNECT_SEL,
772 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600773 if (prev_idx >= spec->num_analog_muxes &&
774 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200775 imux = spec->dinput_mux;
776 /* 0 = analog */
777 snd_hda_codec_write_cache(codec,
778 spec->dmux_nids[adc_idx], 0,
779 AC_VERB_SET_CONNECT_SEL,
780 imux->items[0].index);
781 }
782 } else {
783 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600784 /* first dimux item is hardcoded to select analog imux,
785 * so lets skip it
786 */
787 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200788 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
789 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600790 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200791 }
792 spec->cur_mux[adc_idx] = idx;
793 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200794}
795
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100796static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
797 struct snd_ctl_elem_info *uinfo)
798{
799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
800 struct sigmatel_spec *spec = codec->spec;
801 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
802}
803
804static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
806{
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 struct sigmatel_spec *spec = codec->spec;
809
810 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
811 return 0;
812}
813
814static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
815 struct snd_ctl_elem_value *ucontrol)
816{
817 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
818 struct sigmatel_spec *spec = codec->spec;
819
820 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
821 spec->mono_nid, &spec->cur_mmux);
822}
823
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200824#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
825
826static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
827 struct snd_ctl_elem_value *ucontrol)
828{
829 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200831 struct sigmatel_spec *spec = codec->spec;
832
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 ucontrol->value.integer.value[0] = !!(spec->aloopback &
834 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200835 return 0;
836}
837
838static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
839 struct snd_ctl_elem_value *ucontrol)
840{
841 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
842 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100843 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200844 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100845 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200846
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100847 idx_val = spec->aloopback_mask << idx;
848 if (ucontrol->value.integer.value[0])
849 val = spec->aloopback | idx_val;
850 else
851 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100852 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853 return 0;
854
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100855 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200856
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100857 /* Only return the bits defined by the shift value of the
858 * first two bytes of the mask
859 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200860 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100861 kcontrol->private_value & 0xFFFF, 0x0);
862 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200863
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100864 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200865 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100866 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200867 } else {
868 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100869 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200870 }
871
872 snd_hda_codec_write_cache(codec, codec->afg, 0,
873 kcontrol->private_value >> 16, dac_mode);
874
875 return 1;
876}
877
Takashi Iwai2b635362011-05-02 12:33:43 +0200878static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200879 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200880 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200881 {}
882};
883
Takashi Iwai2b635362011-05-02 12:33:43 +0200884static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200885 /* set dac0mux for dac converter */
886 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
887 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
888 {}
889};
890
Takashi Iwai2b635362011-05-02 12:33:43 +0200891static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100892 /* set master volume to max value without distortion
893 * and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100895 {}
896};
897
Takashi Iwai2b635362011-05-02 12:33:43 +0200898static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100899 /* set master volume and direct control */
900 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100901 {}
902};
903
Takashi Iwai2b635362011-05-02 12:33:43 +0200904static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200905 /* power state controls amps */
906 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200907 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200908};
909
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600910static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
911 { 0x22, 0x785, 0x43 },
912 { 0x22, 0x782, 0xe0 },
913 { 0x22, 0x795, 0x00 },
914 {}
915};
916
Takashi Iwai2b635362011-05-02 12:33:43 +0200917static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100918 /* set master volume and direct control */
919 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200920 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100921};
922
Takashi Iwai2b635362011-05-02 12:33:43 +0200923static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500924 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
925 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100926 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
927 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100928 {}
929};
930
Takashi Iwai2b635362011-05-02 12:33:43 +0200931static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100932 /* set dac0mux for dac converter */
933 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100934 /* mute the master volume */
935 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100936 {}
937};
938
Takashi Iwai2b635362011-05-02 12:33:43 +0200939static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200940 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200941 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200942 {}
943};
944
Takashi Iwai2b635362011-05-02 12:33:43 +0200945static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200946 /* unmute node 0x1b */
947 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
948 /* select node 0x03 as DAC */
949 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
950 {}
951};
952
Takashi Iwai2b635362011-05-02 12:33:43 +0200953static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200954 /* don't set delta bit */
955 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
956 /* unmute node 0x1b */
957 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
958 /* select node 0x03 as DAC */
959 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
960 {}
961};
962
Takashi Iwai2b635362011-05-02 12:33:43 +0200963static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100964 /* set master volume and direct control */
965 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200966 /* enable analog pc beep path */
967 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100968 {}
969};
970
Takashi Iwai2b635362011-05-02 12:33:43 +0200971static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200972 /* don't set delta bit */
973 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
974 /* enable analog pc beep path */
975 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
976 {}
977};
978
Takashi Iwai2b635362011-05-02 12:33:43 +0200979static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200980 /* set master volume and direct control */
981 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200982 /* enable analog pc beep path */
983 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200984 {}
985};
986
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100987#define STAC_MONO_MUX \
988 { \
989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
990 .name = "Mono Mux", \
991 .count = 1, \
992 .info = stac92xx_mono_mux_enum_info, \
993 .get = stac92xx_mono_mux_enum_get, \
994 .put = stac92xx_mono_mux_enum_put, \
995 }
996
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100997#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200998 { \
999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1000 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001001 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001002 .info = stac92xx_aloopback_info, \
1003 .get = stac92xx_aloopback_get, \
1004 .put = stac92xx_aloopback_put, \
1005 .private_value = verb_read | (verb_write << 16), \
1006 }
1007
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001008#define DC_BIAS(xname, idx, nid) \
1009 { \
1010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1011 .name = xname, \
1012 .index = idx, \
1013 .info = stac92xx_dc_bias_info, \
1014 .get = stac92xx_dc_bias_get, \
1015 .put = stac92xx_dc_bias_put, \
1016 .private_value = nid, \
1017 }
1018
Takashi Iwai2b635362011-05-02 12:33:43 +02001019static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001020 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1021 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001022 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001024 { } /* end */
1025};
1026
Takashi Iwai2b635362011-05-02 12:33:43 +02001027static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1029 {}
1030};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001031
Takashi Iwai2b635362011-05-02 12:33:43 +02001032static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001033 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1034 {}
1035};
1036
Takashi Iwai2b635362011-05-02 12:33:43 +02001037static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001038 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1039 {}
1040};
1041
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001042
Takashi Iwai2b635362011-05-02 12:33:43 +02001043static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001044 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1045};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001046
Takashi Iwai2b635362011-05-02 12:33:43 +02001047static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001048 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001050 { } /* end */
1051};
1052
Takashi Iwai2b635362011-05-02 12:33:43 +02001053static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001054 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1055 {}
1056};
1057
Takashi Iwai2b635362011-05-02 12:33:43 +02001058static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001059 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1060 {}
1061};
1062
Takashi Iwai1697055e2007-12-18 18:05:52 +01001063static struct snd_kcontrol_new stac_dmux_mixer = {
1064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1065 .name = "Digital Input Source",
1066 /* count set later */
1067 .info = stac92xx_dmux_enum_info,
1068 .get = stac92xx_dmux_enum_get,
1069 .put = stac92xx_dmux_enum_put,
1070};
1071
Matthew Ranostayd9737752008-09-07 12:03:41 +02001072static struct snd_kcontrol_new stac_smux_mixer = {
1073 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001074 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001075 /* count set later */
1076 .info = stac92xx_smux_enum_info,
1077 .get = stac92xx_smux_enum_get,
1078 .put = stac92xx_smux_enum_put,
1079};
1080
Takashi Iwai9322ca52012-02-03 14:28:01 +01001081static const char * const slave_pfxs[] = {
1082 "Front", "Surround", "Center", "LFE", "Side",
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01001083 "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001084 NULL
1085};
1086
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001087static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1088
1089static void stac92xx_vmaster_hook(void *private_data, int val)
1090{
1091 stac92xx_update_led_status(private_data, val);
1092}
1093
Takashi Iwai603c4012008-07-30 15:01:44 +02001094static void stac92xx_free_kctls(struct hda_codec *codec);
1095
Matt2f2f4252005-04-13 14:45:30 +02001096static int stac92xx_build_controls(struct hda_codec *codec)
1097{
1098 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001099 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001100 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001101 int i;
Matt2f2f4252005-04-13 14:45:30 +02001102
Takashi Iwai6479c632009-07-28 18:20:25 +02001103 if (spec->mixer) {
1104 err = snd_hda_add_new_ctls(codec, spec->mixer);
1105 if (err < 0)
1106 return err;
1107 }
Mattc7d4b2f2005-06-27 14:59:41 +02001108
1109 for (i = 0; i < spec->num_mixers; i++) {
1110 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1111 if (err < 0)
1112 return err;
1113 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001114 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1115 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001116 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001117 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001118 snd_ctl_new1(&stac_dmux_mixer, codec));
1119 if (err < 0)
1120 return err;
1121 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001122 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001123 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1124 struct hda_input_mux *smux = &spec->private_smux;
1125 /* check for mute support on SPDIF out */
1126 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001127 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001128 spec->spdif_mute = 1;
1129 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001130 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001131 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001132 snd_ctl_new1(&stac_smux_mixer, codec));
1133 if (err < 0)
1134 return err;
1135 }
Mattc7d4b2f2005-06-27 14:59:41 +02001136
Mattdabbed62005-06-14 10:19:34 +02001137 if (spec->multiout.dig_out_nid) {
Takashi Iwaidcda5802012-10-12 17:24:51 +02001138 err = snd_hda_create_dig_out_ctls(codec,
1139 spec->multiout.dig_out_nid,
1140 spec->multiout.dig_out_nid,
1141 spec->autocfg.dig_out_type[0]);
Mattdabbed62005-06-14 10:19:34 +02001142 if (err < 0)
1143 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001144 err = snd_hda_create_spdif_share_sw(codec,
1145 &spec->multiout);
1146 if (err < 0)
1147 return err;
1148 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001149 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001150 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001151 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1152 if (err < 0)
1153 return err;
1154 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001155
1156 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001157 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1158 HDA_OUTPUT, vmaster_tlv);
1159 /* correct volume offset */
1160 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1161 /* minimum value is actually mute */
1162 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1163 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1164 vmaster_tlv, slave_pfxs,
1165 "Playback Volume");
1166 if (err < 0)
1167 return err;
1168
1169 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1170 NULL, slave_pfxs,
1171 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001172 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001173 if (err < 0)
1174 return err;
1175
1176 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001177 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001178 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001179 if (err < 0)
1180 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001181 }
1182
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001183 if (spec->aloopback_ctl &&
1184 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1185 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1186 if (err < 0)
1187 return err;
1188 }
1189
Takashi Iwai603c4012008-07-30 15:01:44 +02001190 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001191
Takashi Iwai01a61e12011-10-28 00:03:22 +02001192 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1193 if (err < 0)
1194 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001195
Mattdabbed62005-06-14 10:19:34 +02001196 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001197}
1198
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001199static const struct hda_pintbl ref9200_pin_configs[] = {
1200 { 0x08, 0x01c47010 },
1201 { 0x09, 0x01447010 },
1202 { 0x0d, 0x0221401f },
1203 { 0x0e, 0x01114010 },
1204 { 0x0f, 0x02a19020 },
1205 { 0x10, 0x01a19021 },
1206 { 0x11, 0x90100140 },
1207 { 0x12, 0x01813122 },
1208 {}
Matt2f2f4252005-04-13 14:45:30 +02001209};
1210
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001211static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1212 { 0x08, 0x400000fe },
1213 { 0x09, 0x404500f4 },
1214 { 0x0d, 0x400100f0 },
1215 { 0x0e, 0x90110010 },
1216 { 0x0f, 0x400100f1 },
1217 { 0x10, 0x02a1902e },
1218 { 0x11, 0x500000f2 },
1219 { 0x12, 0x500000f3 },
1220 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001221};
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001222
1223static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1224 { 0x08, 0x400000fe },
1225 { 0x09, 0x404500f4 },
1226 { 0x0d, 0x400100f0 },
1227 { 0x0e, 0x90110010 },
1228 { 0x0f, 0x400100f1 },
1229 { 0x10, 0x02a1902e },
1230 { 0x11, 0x500000f2 },
1231 { 0x12, 0x500000f3 },
1232 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001233};
1234
1235/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001236 STAC 9200 pin configs for
1237 102801A8
1238 102801DE
1239 102801E8
1240*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001241static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1242 { 0x08, 0x400001f0 },
1243 { 0x09, 0x400001f1 },
1244 { 0x0d, 0x02214030 },
1245 { 0x0e, 0x01014010 },
1246 { 0x0f, 0x02a19020 },
1247 { 0x10, 0x01a19021 },
1248 { 0x11, 0x90100140 },
1249 { 0x12, 0x01813122 },
1250 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001251};
1252
1253/*
1254 STAC 9200 pin configs for
1255 102801C0
1256 102801C1
1257*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001258static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1259 { 0x08, 0x400001f0 },
1260 { 0x09, 0x400001f1 },
1261 { 0x0d, 0x0221401f },
1262 { 0x0e, 0x01014010 },
1263 { 0x0f, 0x01813020 },
1264 { 0x10, 0x02a19021 },
1265 { 0x11, 0x90100140 },
1266 { 0x12, 0x400001f2 },
1267 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001268};
1269
1270/*
1271 STAC 9200 pin configs for
1272 102801C4 (Dell Dimension E310)
1273 102801C5
1274 102801C7
1275 102801D9
1276 102801DA
1277 102801E3
1278*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001279static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1280 { 0x08, 0x400001f0 },
1281 { 0x09, 0x400001f1 },
1282 { 0x0d, 0x0221401f },
1283 { 0x0e, 0x01014010 },
1284 { 0x0f, 0x01813020 },
1285 { 0x10, 0x01a19021 },
1286 { 0x11, 0x90100140 },
1287 { 0x12, 0x400001f2 },
1288 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001289};
1290
1291
1292/*
1293 STAC 9200-32 pin configs for
1294 102801B5 (Dell Inspiron 630m)
1295 102801D8 (Dell Inspiron 640m)
1296*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001297static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1298 { 0x08, 0x40c003fa },
1299 { 0x09, 0x03441340 },
1300 { 0x0d, 0x0321121f },
1301 { 0x0e, 0x90170310 },
1302 { 0x0f, 0x408003fb },
1303 { 0x10, 0x03a11020 },
1304 { 0x11, 0x401003fc },
1305 { 0x12, 0x403003fd },
1306 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001307};
1308
1309/*
1310 STAC 9200-32 pin configs for
1311 102801C2 (Dell Latitude D620)
1312 102801C8
1313 102801CC (Dell Latitude D820)
1314 102801D4
1315 102801D6
1316*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001317static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1318 { 0x08, 0x40c003fa },
1319 { 0x09, 0x0144131f },
1320 { 0x0d, 0x0321121f },
1321 { 0x0e, 0x90170310 },
1322 { 0x0f, 0x90a70321 },
1323 { 0x10, 0x03a11020 },
1324 { 0x11, 0x401003fb },
1325 { 0x12, 0x40f000fc },
1326 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001327};
1328
1329/*
1330 STAC 9200-32 pin configs for
1331 102801CE (Dell XPS M1710)
1332 102801CF (Dell Precision M90)
1333*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001334static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1335 { 0x08, 0x40c003fa },
1336 { 0x09, 0x01441340 },
1337 { 0x0d, 0x0421421f },
1338 { 0x0e, 0x90170310 },
1339 { 0x0f, 0x408003fb },
1340 { 0x10, 0x04a1102e },
1341 { 0x11, 0x90170311 },
1342 { 0x12, 0x403003fc },
1343 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001344};
1345
1346/*
1347 STAC 9200-32 pin configs for
1348 102801C9
1349 102801CA
1350 102801CB (Dell Latitude 120L)
1351 102801D3
1352*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001353static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1354 { 0x08, 0x40c003fa },
1355 { 0x09, 0x404003fb },
1356 { 0x0d, 0x0321121f },
1357 { 0x0e, 0x90170310 },
1358 { 0x0f, 0x408003fc },
1359 { 0x10, 0x03a11020 },
1360 { 0x11, 0x401003fd },
1361 { 0x12, 0x403003fe },
1362 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001363};
1364
1365/*
1366 STAC 9200-32 pin configs for
1367 102801BD (Dell Inspiron E1505n)
1368 102801EE
1369 102801EF
1370*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001371static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1372 { 0x08, 0x40c003fa },
1373 { 0x09, 0x01441340 },
1374 { 0x0d, 0x0421121f },
1375 { 0x0e, 0x90170310 },
1376 { 0x0f, 0x408003fb },
1377 { 0x10, 0x04a11020 },
1378 { 0x11, 0x401003fc },
1379 { 0x12, 0x403003fd },
1380 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001381};
1382
1383/*
1384 STAC 9200-32 pin configs for
1385 102801F5 (Dell Inspiron 1501)
1386 102801F6
1387*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001388static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1389 { 0x08, 0x40c003fa },
1390 { 0x09, 0x404003fb },
1391 { 0x0d, 0x0421121f },
1392 { 0x0e, 0x90170310 },
1393 { 0x0f, 0x408003fc },
1394 { 0x10, 0x04a11020 },
1395 { 0x11, 0x401003fd },
1396 { 0x12, 0x403003fe },
1397 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398};
1399
1400/*
1401 STAC 9200-32
1402 102801CD (Dell Inspiron E1705/9400)
1403*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001404static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1405 { 0x08, 0x40c003fa },
1406 { 0x09, 0x01441340 },
1407 { 0x0d, 0x0421121f },
1408 { 0x0e, 0x90170310 },
1409 { 0x0f, 0x90170310 },
1410 { 0x10, 0x04a11020 },
1411 { 0x11, 0x90170310 },
1412 { 0x12, 0x40f003fc },
1413 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001414};
1415
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001416static const struct hda_pintbl oqo9200_pin_configs[] = {
1417 { 0x08, 0x40c000f0 },
1418 { 0x09, 0x404000f1 },
1419 { 0x0d, 0x0221121f },
1420 { 0x0e, 0x02211210 },
1421 { 0x0f, 0x90170111 },
1422 { 0x10, 0x90a70120 },
1423 { 0x11, 0x400000f2 },
1424 { 0x12, 0x400000f3 },
1425 {}
Tobin Davisbf277782008-02-03 20:31:47 +01001426};
1427
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001428
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001429static void stac9200_fixup_panasonic(struct hda_codec *codec,
1430 const struct hda_fixup *fix, int action)
1431{
1432 struct sigmatel_spec *spec = codec->spec;
1433
1434 switch (action) {
1435 case HDA_FIXUP_ACT_PRE_PROBE:
1436 spec->gpio_mask = spec->gpio_dir = 0x09;
1437 spec->gpio_data = 0x00;
1438 break;
1439 case HDA_FIXUP_ACT_PROBE:
1440 /* CF-74 has no headphone detection, and the driver should *NOT*
1441 * do detection and HP/speaker toggle because the hardware does it.
1442 */
1443 spec->hp_detect = 0;
1444 break;
1445 }
1446}
1447
1448
1449static const struct hda_fixup stac9200_fixups[] = {
1450 [STAC_REF] = {
1451 .type = HDA_FIXUP_PINS,
1452 .v.pins = ref9200_pin_configs,
1453 },
1454 [STAC_9200_OQO] = {
1455 .type = HDA_FIXUP_PINS,
1456 .v.pins = oqo9200_pin_configs,
1457 .chained = true,
1458 .chain_id = STAC_9200_EAPD_INIT,
1459 },
1460 [STAC_9200_DELL_D21] = {
1461 .type = HDA_FIXUP_PINS,
1462 .v.pins = dell9200_d21_pin_configs,
1463 },
1464 [STAC_9200_DELL_D22] = {
1465 .type = HDA_FIXUP_PINS,
1466 .v.pins = dell9200_d22_pin_configs,
1467 },
1468 [STAC_9200_DELL_D23] = {
1469 .type = HDA_FIXUP_PINS,
1470 .v.pins = dell9200_d23_pin_configs,
1471 },
1472 [STAC_9200_DELL_M21] = {
1473 .type = HDA_FIXUP_PINS,
1474 .v.pins = dell9200_m21_pin_configs,
1475 },
1476 [STAC_9200_DELL_M22] = {
1477 .type = HDA_FIXUP_PINS,
1478 .v.pins = dell9200_m22_pin_configs,
1479 },
1480 [STAC_9200_DELL_M23] = {
1481 .type = HDA_FIXUP_PINS,
1482 .v.pins = dell9200_m23_pin_configs,
1483 },
1484 [STAC_9200_DELL_M24] = {
1485 .type = HDA_FIXUP_PINS,
1486 .v.pins = dell9200_m24_pin_configs,
1487 },
1488 [STAC_9200_DELL_M25] = {
1489 .type = HDA_FIXUP_PINS,
1490 .v.pins = dell9200_m25_pin_configs,
1491 },
1492 [STAC_9200_DELL_M26] = {
1493 .type = HDA_FIXUP_PINS,
1494 .v.pins = dell9200_m26_pin_configs,
1495 },
1496 [STAC_9200_DELL_M27] = {
1497 .type = HDA_FIXUP_PINS,
1498 .v.pins = dell9200_m27_pin_configs,
1499 },
1500 [STAC_9200_M4] = {
1501 .type = HDA_FIXUP_PINS,
1502 .v.pins = gateway9200_m4_pin_configs,
1503 .chained = true,
1504 .chain_id = STAC_9200_EAPD_INIT,
1505 },
1506 [STAC_9200_M4_2] = {
1507 .type = HDA_FIXUP_PINS,
1508 .v.pins = gateway9200_m4_2_pin_configs,
1509 .chained = true,
1510 .chain_id = STAC_9200_EAPD_INIT,
1511 },
1512 [STAC_9200_PANASONIC] = {
1513 .type = HDA_FIXUP_FUNC,
1514 .v.func = stac9200_fixup_panasonic,
1515 },
1516 [STAC_9200_EAPD_INIT] = {
1517 .type = HDA_FIXUP_VERBS,
1518 .v.verbs = (const struct hda_verb[]) {
1519 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1520 {}
1521 },
1522 },
Matt Porter403d1942005-11-29 15:00:51 +01001523};
1524
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001525static const struct hda_model_fixup stac9200_models[] = {
1526 { .id = STAC_REF, .name = "ref" },
1527 { .id = STAC_9200_OQO, .name = "oqo" },
1528 { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1529 { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1530 { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1531 { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1532 { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1533 { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1534 { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1535 { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1536 { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1537 { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1538 { .id = STAC_9200_M4, .name = "gateway-m4" },
1539 { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1540 { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1541 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001542};
1543
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001544static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001545 /* SigmaTel reference board */
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1547 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001548 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1549 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001550 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1552 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001554 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1556 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1558 "unknown Dell", STAC_9200_DELL_D22),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1560 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001562 "Dell Latitude D620", STAC_9200_DELL_M22),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1564 "unknown Dell", STAC_9200_DELL_D23),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1566 "unknown Dell", STAC_9200_DELL_D23),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1568 "unknown Dell", STAC_9200_DELL_M22),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1570 "unknown Dell", STAC_9200_DELL_M24),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1572 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001574 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001576 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001578 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001580 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001582 "Dell Precision M90", STAC_9200_DELL_M23),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1584 "unknown Dell", STAC_9200_DELL_M22),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1586 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001588 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001590 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1592 "unknown Dell", STAC_9200_DELL_D23),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1594 "unknown Dell", STAC_9200_DELL_D23),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1596 "unknown Dell", STAC_9200_DELL_D21),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1598 "unknown Dell", STAC_9200_DELL_D23),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1600 "unknown Dell", STAC_9200_DELL_D21),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1602 "unknown Dell", STAC_9200_DELL_M25),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1604 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001606 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1608 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001609 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001610 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001611 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001612 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1613 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1614 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001615 /* OQO Mobile */
1616 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001617 {} /* terminator */
1618};
1619
Takashi Iwaid2077d42013-01-14 14:20:16 +01001620static const struct hda_pintbl ref925x_pin_configs[] = {
1621 { 0x07, 0x40c003f0 },
1622 { 0x08, 0x424503f2 },
1623 { 0x0a, 0x01813022 },
1624 { 0x0b, 0x02a19021 },
1625 { 0x0c, 0x90a70320 },
1626 { 0x0d, 0x02214210 },
1627 { 0x10, 0x01019020 },
1628 { 0x11, 0x9033032e },
1629 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001630};
1631
Takashi Iwaid2077d42013-01-14 14:20:16 +01001632static const struct hda_pintbl stac925xM1_pin_configs[] = {
1633 { 0x07, 0x40c003f4 },
1634 { 0x08, 0x424503f2 },
1635 { 0x0a, 0x400000f3 },
1636 { 0x0b, 0x02a19020 },
1637 { 0x0c, 0x40a000f0 },
1638 { 0x0d, 0x90100210 },
1639 { 0x10, 0x400003f1 },
1640 { 0x11, 0x9033032e },
1641 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001642};
1643
Takashi Iwaid2077d42013-01-14 14:20:16 +01001644static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1645 { 0x07, 0x40c003f4 },
1646 { 0x08, 0x424503f2 },
1647 { 0x0a, 0x400000f3 },
1648 { 0x0b, 0x02a19020 },
1649 { 0x0c, 0x40a000f0 },
1650 { 0x0d, 0x90100210 },
1651 { 0x10, 0x400003f1 },
1652 { 0x11, 0x9033032e },
1653 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001654};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001655
Takashi Iwaid2077d42013-01-14 14:20:16 +01001656static const struct hda_pintbl stac925xM2_pin_configs[] = {
1657 { 0x07, 0x40c003f4 },
1658 { 0x08, 0x424503f2 },
1659 { 0x0a, 0x400000f3 },
1660 { 0x0b, 0x02a19020 },
1661 { 0x0c, 0x40a000f0 },
1662 { 0x0d, 0x90100210 },
1663 { 0x10, 0x400003f1 },
1664 { 0x11, 0x9033032e },
1665 {}
Tobin Davis2c11f952007-05-17 09:36:34 +02001666};
1667
Takashi Iwaid2077d42013-01-14 14:20:16 +01001668static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1669 { 0x07, 0x40c003f4 },
1670 { 0x08, 0x424503f2 },
1671 { 0x0a, 0x400000f3 },
1672 { 0x0b, 0x02a19020 },
1673 { 0x0c, 0x40a000f0 },
1674 { 0x0d, 0x90100210 },
1675 { 0x10, 0x400003f1 },
1676 { 0x11, 0x9033032e },
1677 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001678};
1679
Takashi Iwaid2077d42013-01-14 14:20:16 +01001680static const struct hda_pintbl stac925xM3_pin_configs[] = {
1681 { 0x07, 0x40c003f4 },
1682 { 0x08, 0x424503f2 },
1683 { 0x0a, 0x400000f3 },
1684 { 0x0b, 0x02a19020 },
1685 { 0x0c, 0x40a000f0 },
1686 { 0x0d, 0x90100210 },
1687 { 0x10, 0x400003f1 },
1688 { 0x11, 0x503303f3 },
1689 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001690};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001691
Takashi Iwaid2077d42013-01-14 14:20:16 +01001692static const struct hda_pintbl stac925xM5_pin_configs[] = {
1693 { 0x07, 0x40c003f4 },
1694 { 0x08, 0x424503f2 },
1695 { 0x0a, 0x400000f3 },
1696 { 0x0b, 0x02a19020 },
1697 { 0x0c, 0x40a000f0 },
1698 { 0x0d, 0x90100210 },
1699 { 0x10, 0x400003f1 },
1700 { 0x11, 0x9033032e },
1701 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001702};
1703
Takashi Iwaid2077d42013-01-14 14:20:16 +01001704static const struct hda_pintbl stac925xM6_pin_configs[] = {
1705 { 0x07, 0x40c003f4 },
1706 { 0x08, 0x424503f2 },
1707 { 0x0a, 0x400000f3 },
1708 { 0x0b, 0x02a19020 },
1709 { 0x0c, 0x40a000f0 },
1710 { 0x0d, 0x90100210 },
1711 { 0x10, 0x400003f1 },
1712 { 0x11, 0x90330320 },
1713 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001714};
1715
Takashi Iwaid2077d42013-01-14 14:20:16 +01001716static const struct hda_fixup stac925x_fixups[] = {
1717 [STAC_REF] = {
1718 .type = HDA_FIXUP_PINS,
1719 .v.pins = ref925x_pin_configs,
1720 },
1721 [STAC_M1] = {
1722 .type = HDA_FIXUP_PINS,
1723 .v.pins = stac925xM1_pin_configs,
1724 },
1725 [STAC_M1_2] = {
1726 .type = HDA_FIXUP_PINS,
1727 .v.pins = stac925xM1_2_pin_configs,
1728 },
1729 [STAC_M2] = {
1730 .type = HDA_FIXUP_PINS,
1731 .v.pins = stac925xM2_pin_configs,
1732 },
1733 [STAC_M2_2] = {
1734 .type = HDA_FIXUP_PINS,
1735 .v.pins = stac925xM2_2_pin_configs,
1736 },
1737 [STAC_M3] = {
1738 .type = HDA_FIXUP_PINS,
1739 .v.pins = stac925xM3_pin_configs,
1740 },
1741 [STAC_M5] = {
1742 .type = HDA_FIXUP_PINS,
1743 .v.pins = stac925xM5_pin_configs,
1744 },
1745 [STAC_M6] = {
1746 .type = HDA_FIXUP_PINS,
1747 .v.pins = stac925xM6_pin_configs,
1748 },
Tobin Davis8e21c342007-01-08 11:04:17 +01001749};
1750
Takashi Iwaid2077d42013-01-14 14:20:16 +01001751static const struct hda_model_fixup stac925x_models[] = {
1752 { .id = STAC_REF, .name = "ref" },
1753 { .id = STAC_M1, .name = "m1" },
1754 { .id = STAC_M1_2, .name = "m1-2" },
1755 { .id = STAC_M2, .name = "m2" },
1756 { .id = STAC_M2_2, .name = "m2-2" },
1757 { .id = STAC_M3, .name = "m3" },
1758 { .id = STAC_M5, .name = "m5" },
1759 { .id = STAC_M6, .name = "m6" },
1760 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001761};
1762
Takashi Iwaid2077d42013-01-14 14:20:16 +01001763static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1764 /* SigmaTel reference board */
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1767 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1768
1769 /* Default table for unknown ID */
1770 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1771
1772 /* gateway machines are checked via codec ssid */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001773 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1774 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1775 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1776 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001777 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001778 /* Not sure about the brand name for those */
1779 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1780 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1781 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1782 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001783 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001784};
1785
Takashi Iwai55e30142013-01-14 17:30:04 +01001786static const struct hda_pintbl ref92hd73xx_pin_configs[] = {
1787 { 0x0a, 0x02214030 },
1788 { 0x0b, 0x02a19040 },
1789 { 0x0c, 0x01a19020 },
1790 { 0x0d, 0x02214030 },
1791 { 0x0e, 0x0181302e },
1792 { 0x0f, 0x01014010 },
1793 { 0x10, 0x01014020 },
1794 { 0x11, 0x01014030 },
1795 { 0x12, 0x02319040 },
1796 { 0x13, 0x90a000f0 },
1797 { 0x14, 0x90a000f0 },
1798 { 0x22, 0x01452050 },
1799 { 0x23, 0x01452050 },
1800 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01001801};
1802
Takashi Iwai55e30142013-01-14 17:30:04 +01001803static const struct hda_pintbl dell_m6_pin_configs[] = {
1804 { 0x0a, 0x0321101f },
1805 { 0x0b, 0x4f00000f },
1806 { 0x0c, 0x4f0000f0 },
1807 { 0x0d, 0x90170110 },
1808 { 0x0e, 0x03a11020 },
1809 { 0x0f, 0x0321101f },
1810 { 0x10, 0x4f0000f0 },
1811 { 0x11, 0x4f0000f0 },
1812 { 0x12, 0x4f0000f0 },
1813 { 0x13, 0x90a60160 },
1814 { 0x14, 0x4f0000f0 },
1815 { 0x22, 0x4f0000f0 },
1816 { 0x23, 0x4f0000f0 },
1817 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001818};
1819
Takashi Iwai55e30142013-01-14 17:30:04 +01001820static const struct hda_pintbl alienware_m17x_pin_configs[] = {
1821 { 0x0a, 0x0321101f },
1822 { 0x0b, 0x0321101f },
1823 { 0x0c, 0x03a11020 },
1824 { 0x0d, 0x03014020 },
1825 { 0x0e, 0x90170110 },
1826 { 0x0f, 0x4f0000f0 },
1827 { 0x10, 0x4f0000f0 },
1828 { 0x11, 0x4f0000f0 },
1829 { 0x12, 0x4f0000f0 },
1830 { 0x13, 0x90a60160 },
1831 { 0x14, 0x4f0000f0 },
1832 { 0x22, 0x4f0000f0 },
1833 { 0x23, 0x904601b0 },
1834 {}
Takashi Iwai842ae632009-09-02 07:43:08 +02001835};
1836
Takashi Iwai55e30142013-01-14 17:30:04 +01001837static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1838 { 0x0a, 0x02214230 },
1839 { 0x0b, 0x02A19240 },
1840 { 0x0c, 0x01013214 },
1841 { 0x0d, 0x01014210 },
1842 { 0x0e, 0x01A19250 },
1843 { 0x0f, 0x01011212 },
1844 { 0x10, 0x01016211 },
1845 {}
Alexey Fisher52dc4382009-12-12 11:16:41 +02001846};
1847
Takashi Iwai55e30142013-01-14 17:30:04 +01001848static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
1849 const struct hda_fixup *fix, int action)
1850{
1851 struct sigmatel_spec *spec = codec->spec;
1852
1853 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1854 return;
1855
1856 snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs);
1857 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
1858}
1859
1860static void stac92hd73xx_fixup_dell(struct hda_codec *codec)
1861{
1862 struct sigmatel_spec *spec = codec->spec;
1863
1864 snd_hda_apply_pincfgs(codec, dell_m6_pin_configs);
1865 spec->num_smuxes = 0;
1866 spec->eapd_switch = 0;
1867}
1868
1869static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec,
1870 const struct hda_fixup *fix, int action)
1871{
1872 struct sigmatel_spec *spec = codec->spec;
1873
1874 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1875 return;
1876
1877 stac92hd73xx_fixup_dell(codec);
1878 snd_hda_add_verbs(codec, dell_eq_core_init);
1879 spec->volknob_init = 1;
1880}
1881
1882/* Analog Mics */
1883static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec,
1884 const struct hda_fixup *fix, int action)
1885{
1886 struct sigmatel_spec *spec = codec->spec;
1887
1888 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1889 return;
1890
1891 stac92hd73xx_fixup_dell(codec);
1892 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1893 spec->num_dmics = 0;
1894}
1895
1896/* Digital Mics */
1897static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec,
1898 const struct hda_fixup *fix, int action)
1899{
1900 struct sigmatel_spec *spec = codec->spec;
1901
1902 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1903 return;
1904
1905 stac92hd73xx_fixup_dell(codec);
1906 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1907 spec->num_dmics = 1;
1908}
1909
1910/* Both */
1911static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec,
1912 const struct hda_fixup *fix, int action)
1913{
1914 struct sigmatel_spec *spec = codec->spec;
1915
1916 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1917 return;
1918
1919 stac92hd73xx_fixup_dell(codec);
1920 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1921 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1922 spec->num_dmics = 1;
1923}
1924
1925static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec,
1926 const struct hda_fixup *fix, int action)
1927{
1928 struct sigmatel_spec *spec = codec->spec;
1929
1930 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1931 return;
1932
1933 snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs);
1934 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
1935 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
1936 spec->eapd_switch = 0;
1937}
1938
1939static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec,
1940 const struct hda_fixup *fix, int action)
1941{
1942 struct sigmatel_spec *spec = codec->spec;
1943
Takashi Iwaif6655d52013-01-17 08:49:01 +01001944 if (action != HDA_FIXUP_ACT_PROBE)
Takashi Iwai55e30142013-01-14 17:30:04 +01001945 return;
1946 spec->hp_detect = 0;
1947}
1948
1949static const struct hda_fixup stac92hd73xx_fixups[] = {
1950 [STAC_92HD73XX_REF] = {
1951 .type = HDA_FIXUP_FUNC,
1952 .v.func = stac92hd73xx_fixup_ref,
1953 },
1954 [STAC_DELL_M6_AMIC] = {
1955 .type = HDA_FIXUP_FUNC,
1956 .v.func = stac92hd73xx_fixup_dell_m6_amic,
1957 },
1958 [STAC_DELL_M6_DMIC] = {
1959 .type = HDA_FIXUP_FUNC,
1960 .v.func = stac92hd73xx_fixup_dell_m6_dmic,
1961 },
1962 [STAC_DELL_M6_BOTH] = {
1963 .type = HDA_FIXUP_FUNC,
1964 .v.func = stac92hd73xx_fixup_dell_m6_both,
1965 },
1966 [STAC_DELL_EQ] = {
1967 .type = HDA_FIXUP_FUNC,
1968 .v.func = stac92hd73xx_fixup_dell_eq,
1969 },
1970 [STAC_ALIENWARE_M17X] = {
1971 .type = HDA_FIXUP_FUNC,
1972 .v.func = stac92hd73xx_fixup_alienware_m17x,
1973 },
1974 [STAC_92HD73XX_INTEL] = {
1975 .type = HDA_FIXUP_PINS,
1976 .v.pins = intel_dg45id_pin_configs,
1977 },
1978 [STAC_92HD73XX_NO_JD] = {
1979 .type = HDA_FIXUP_FUNC,
1980 .v.func = stac92hd73xx_fixup_no_jd,
1981 }
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001982};
1983
Takashi Iwai55e30142013-01-14 17:30:04 +01001984static const struct hda_model_fixup stac92hd73xx_models[] = {
1985 { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" },
1986 { .id = STAC_92HD73XX_REF, .name = "ref" },
1987 { .id = STAC_92HD73XX_INTEL, .name = "intel" },
1988 { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" },
1989 { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" },
1990 { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" },
1991 { .id = STAC_DELL_EQ, .name = "dell-eq" },
1992 { .id = STAC_ALIENWARE_M17X, .name = "alienware" },
1993 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001994};
1995
Takashi Iwai55e30142013-01-14 17:30:04 +01001996static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001997 /* SigmaTel reference board */
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001999 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002000 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2001 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08002002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
2003 "Intel DG45ID", STAC_92HD73XX_INTEL),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
2005 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002006 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002007 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002008 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002009 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002010 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002011 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002012 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002013 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002014 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002015 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002017 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002019 "unknown Dell", STAC_DELL_M6_DMIC),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
2021 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01002022 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002023 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01002024 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
2025 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02002026 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
2027 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00002028 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
2029 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04002030 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01002031 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04002032 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02002033 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Takashi Iwai55e30142013-01-14 17:30:04 +01002034 /* codec SSID matching */
Takashi Iwai842ae632009-09-02 07:43:08 +02002035 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
2036 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05002037 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
2038 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01002039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01002040 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02002041 {} /* terminator */
2042};
2043
Takashi Iwai372f8c72013-01-14 18:06:34 +01002044static const struct hda_pintbl ref92hd83xxx_pin_configs[] = {
2045 { 0x0a, 0x02214030 },
2046 { 0x0b, 0x02211010 },
2047 { 0x0c, 0x02a19020 },
2048 { 0x0d, 0x02170130 },
2049 { 0x0e, 0x01014050 },
2050 { 0x0f, 0x01819040 },
2051 { 0x10, 0x01014020 },
2052 { 0x11, 0x90a3014e },
2053 { 0x1f, 0x01451160 },
2054 { 0x20, 0x98560170 },
2055 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002056};
2057
Takashi Iwai372f8c72013-01-14 18:06:34 +01002058static const struct hda_pintbl dell_s14_pin_configs[] = {
2059 { 0x0a, 0x0221403f },
2060 { 0x0b, 0x0221101f },
2061 { 0x0c, 0x02a19020 },
2062 { 0x0d, 0x90170110 },
2063 { 0x0e, 0x40f000f0 },
2064 { 0x0f, 0x40f000f0 },
2065 { 0x10, 0x40f000f0 },
2066 { 0x11, 0x90a60160 },
2067 { 0x1f, 0x40f000f0 },
2068 { 0x20, 0x40f000f0 },
2069 {}
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002070};
2071
Takashi Iwai372f8c72013-01-14 18:06:34 +01002072static const struct hda_pintbl dell_vostro_3500_pin_configs[] = {
2073 { 0x0a, 0x02a11020 },
2074 { 0x0b, 0x0221101f },
2075 { 0x0c, 0x400000f0 },
2076 { 0x0d, 0x90170110 },
2077 { 0x0e, 0x400000f1 },
2078 { 0x0f, 0x400000f2 },
2079 { 0x10, 0x400000f3 },
2080 { 0x11, 0x90a60160 },
2081 { 0x1f, 0x400000f4 },
2082 { 0x20, 0x400000f5 },
2083 {}
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002084};
2085
Takashi Iwai372f8c72013-01-14 18:06:34 +01002086static const struct hda_pintbl hp_dv7_4000_pin_configs[] = {
2087 { 0x0a, 0x03a12050 },
2088 { 0x0b, 0x0321201f },
2089 { 0x0c, 0x40f000f0 },
2090 { 0x0d, 0x90170110 },
2091 { 0x0e, 0x40f000f0 },
2092 { 0x0f, 0x40f000f0 },
2093 { 0x10, 0x90170110 },
2094 { 0x11, 0xd5a30140 },
2095 { 0x1f, 0x40f000f0 },
2096 { 0x20, 0x40f000f0 },
2097 {}
Steven Eastland48315592010-08-06 15:07:35 -06002098};
2099
Takashi Iwai372f8c72013-01-14 18:06:34 +01002100static const struct hda_pintbl hp_zephyr_pin_configs[] = {
2101 { 0x0a, 0x01813050 },
2102 { 0x0b, 0x0421201f },
2103 { 0x0c, 0x04a1205e },
2104 { 0x0d, 0x96130310 },
2105 { 0x0e, 0x96130310 },
2106 { 0x0f, 0x0101401f },
2107 { 0x10, 0x1111611f },
2108 { 0x11, 0xd5a30130 },
2109 {}
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002110};
2111
Takashi Iwai372f8c72013-01-14 18:06:34 +01002112static const struct hda_pintbl hp_cNB11_intquad_pin_configs[] = {
2113 { 0x0a, 0x40f000f0 },
2114 { 0x0b, 0x0221101f },
2115 { 0x0c, 0x02a11020 },
2116 { 0x0d, 0x92170110 },
2117 { 0x0e, 0x40f000f0 },
2118 { 0x0f, 0x92170110 },
2119 { 0x10, 0x40f000f0 },
2120 { 0x11, 0xd5a30130 },
2121 { 0x1f, 0x40f000f0 },
2122 { 0x20, 0x40f000f0 },
2123 {}
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002124};
2125
Takashi Iwai372f8c72013-01-14 18:06:34 +01002126static void stac92hd83xxx_fixup_hp(struct hda_codec *codec,
2127 const struct hda_fixup *fix, int action)
2128{
2129 struct sigmatel_spec *spec = codec->spec;
2130
2131 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2132 return;
2133
2134 if (hp_bnb2011_with_dock(codec)) {
2135 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
2136 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
2137 }
2138
2139 if (find_mute_led_cfg(codec, spec->default_polarity))
2140 snd_printd("mute LED gpio %d polarity %d\n",
2141 spec->gpio_led,
2142 spec->gpio_led_polarity);
2143}
2144
2145static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec,
2146 const struct hda_fixup *fix, int action)
2147{
2148 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2149 return;
2150
2151 snd_hda_apply_pincfgs(codec, hp_zephyr_pin_configs);
2152 snd_hda_add_verbs(codec, stac92hd83xxx_hp_zephyr_init);
2153}
2154
2155static void stac92hd83xxx_fixup_hp_led(struct hda_codec *codec,
2156 const struct hda_fixup *fix, int action)
2157{
2158 struct sigmatel_spec *spec = codec->spec;
2159
2160 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2161 spec->default_polarity = 0;
2162}
2163
2164static void stac92hd83xxx_fixup_hp_inv_led(struct hda_codec *codec,
2165 const struct hda_fixup *fix, int action)
2166{
2167 struct sigmatel_spec *spec = codec->spec;
2168
2169 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2170 spec->default_polarity = 1;
2171}
2172
2173static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
2174 const struct hda_fixup *fix, int action)
2175{
2176 struct sigmatel_spec *spec = codec->spec;
2177
2178 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2179 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
2180}
2181
2182static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
2183 const struct hda_fixup *fix, int action)
2184{
2185 struct sigmatel_spec *spec = codec->spec;
2186
2187 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2188 spec->headset_jack = 1;
2189}
2190
2191static const struct hda_fixup stac92hd83xxx_fixups[] = {
2192 [STAC_92HD83XXX_REF] = {
2193 .type = HDA_FIXUP_PINS,
2194 .v.pins = ref92hd83xxx_pin_configs,
2195 },
2196 [STAC_92HD83XXX_PWR_REF] = {
2197 .type = HDA_FIXUP_PINS,
2198 .v.pins = ref92hd83xxx_pin_configs,
2199 },
2200 [STAC_DELL_S14] = {
2201 .type = HDA_FIXUP_PINS,
2202 .v.pins = dell_s14_pin_configs,
2203 },
2204 [STAC_DELL_VOSTRO_3500] = {
2205 .type = HDA_FIXUP_PINS,
2206 .v.pins = dell_vostro_3500_pin_configs,
2207 },
2208 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = {
2209 .type = HDA_FIXUP_PINS,
2210 .v.pins = hp_cNB11_intquad_pin_configs,
2211 .chained = true,
2212 .chain_id = STAC_92HD83XXX_HP,
2213 },
2214 [STAC_92HD83XXX_HP] = {
2215 .type = HDA_FIXUP_FUNC,
2216 .v.func = stac92hd83xxx_fixup_hp,
2217 },
2218 [STAC_HP_DV7_4000] = {
2219 .type = HDA_FIXUP_PINS,
2220 .v.pins = hp_dv7_4000_pin_configs,
2221 .chained = true,
2222 .chain_id = STAC_92HD83XXX_HP,
2223 },
2224 [STAC_HP_ZEPHYR] = {
2225 .type = HDA_FIXUP_FUNC,
2226 .v.func = stac92hd83xxx_fixup_hp_zephyr,
2227 .chained = true,
2228 .chain_id = STAC_92HD83XXX_HP,
2229 },
2230 [STAC_92HD83XXX_HP_LED] = {
2231 .type = HDA_FIXUP_FUNC,
2232 .v.func = stac92hd83xxx_fixup_hp_led,
2233 .chained = true,
2234 .chain_id = STAC_92HD83XXX_HP,
2235 },
2236 [STAC_92HD83XXX_HP_INV_LED] = {
2237 .type = HDA_FIXUP_FUNC,
2238 .v.func = stac92hd83xxx_fixup_hp_inv_led,
2239 .chained = true,
2240 .chain_id = STAC_92HD83XXX_HP,
2241 },
2242 [STAC_92HD83XXX_HP_MIC_LED] = {
2243 .type = HDA_FIXUP_FUNC,
2244 .v.func = stac92hd83xxx_fixup_hp_mic_led,
2245 .chained = true,
2246 .chain_id = STAC_92HD83XXX_HP,
2247 },
2248 [STAC_92HD83XXX_HEADSET_JACK] = {
2249 .type = HDA_FIXUP_FUNC,
2250 .v.func = stac92hd83xxx_fixup_headset_jack,
2251 },
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002252};
2253
Takashi Iwai372f8c72013-01-14 18:06:34 +01002254static const struct hda_model_fixup stac92hd83xxx_models[] = {
2255 { .id = STAC_92HD83XXX_REF, .name = "ref" },
2256 { .id = STAC_92HD83XXX_PWR_REF, .name = "mic-ref" },
2257 { .id = STAC_DELL_S14, .name = "dell-s14" },
2258 { .id = STAC_DELL_VOSTRO_3500, .name = "dell-vostro-3500" },
2259 { .id = STAC_92HD83XXX_HP_cNB11_INTQUAD, .name = "hp_cNB11_intquad" },
2260 { .id = STAC_HP_DV7_4000, .name = "hp-dv7-4000" },
2261 { .id = STAC_HP_ZEPHYR, .name = "hp-zephyr" },
2262 { .id = STAC_92HD83XXX_HP_LED, .name = "hp-led" },
2263 { .id = STAC_92HD83XXX_HP_INV_LED, .name = "hp-inv-led" },
2264 { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" },
2265 { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" },
2266 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002267};
2268
Takashi Iwai372f8c72013-01-14 18:06:34 +01002269static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002270 /* SigmaTel reference board */
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01002272 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002273 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2274 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
2276 "unknown Dell", STAC_DELL_S14),
David Henningsson8d032a82012-10-09 12:48:40 +02002277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
2278 "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
2279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
2280 "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
2281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
2282 "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
2283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
2284 "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
2285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
2286 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
2288 "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
2290 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
2292 "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
2293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
2294 "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
2296 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002297 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
2298 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2299 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
2300 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2301 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
2302 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2303 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
Takashi Iwai8ae58652012-12-13 14:33:42 +01002304 "HP Pavilion dv7", STAC_HP_DV7_4000),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002305 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
2306 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2307 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
2308 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Takashi Iwai62cbde12012-09-14 11:58:54 +02002309 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
2310 "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002311 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
2312 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2313 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
2314 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2315 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
2316 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2317 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
2318 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2319 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
2320 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2321 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
2322 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2323 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
2324 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2325 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
2326 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2327 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
2328 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2329 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
2330 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2331 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
2332 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2333 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2334 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2335 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2336 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2337 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2338 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002339 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2340 "HP", STAC_HP_ZEPHYR),
Takashi Iwaia3e19972012-07-26 08:17:20 +02002341 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2342 "HP Mini", STAC_92HD83XXX_HP_LED),
Gustavo Maciel Dias Vieira5afc13a2012-10-26 12:51:53 -02002343 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2344 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
Takashi Iwai8c698fe2013-01-15 11:20:50 +01002345 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a,
2346 "HP Mini", STAC_92HD83XXX_HP_LED),
Takashi Iwai372f8c72013-01-14 18:06:34 +01002347 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02002348 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002349};
2350
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002351static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2352 { 0x0a, 0x02214030 },
2353 { 0x0b, 0x02a19040 },
2354 { 0x0c, 0x01a19020 },
2355 { 0x0d, 0x01014010 },
2356 { 0x0e, 0x0181302e },
2357 { 0x0f, 0x01014010 },
2358 { 0x14, 0x01019020 },
2359 { 0x18, 0x90a000f0 },
2360 { 0x19, 0x90a000f0 },
2361 { 0x1e, 0x01452050 },
2362 { 0x1f, 0x01452050 },
2363 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002364};
2365
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002366static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2367 { 0x0a, 0x0421101f },
2368 { 0x0b, 0x04a11221 },
2369 { 0x0c, 0x40f000f0 },
2370 { 0x0d, 0x90170110 },
2371 { 0x0e, 0x23a1902e },
2372 { 0x0f, 0x23014250 },
2373 { 0x14, 0x40f000f0 },
2374 { 0x18, 0x90a000f0 },
2375 { 0x19, 0x40f000f0 },
2376 { 0x1e, 0x4f0000f0 },
2377 { 0x1f, 0x4f0000f0 },
2378 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002379};
2380
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002381static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2382 { 0x0a, 0x0421101f },
2383 { 0x0b, 0x04a11221 },
2384 { 0x0c, 0x90a70330 },
2385 { 0x0d, 0x90170110 },
2386 { 0x0e, 0x23a1902e },
2387 { 0x0f, 0x23014250 },
2388 { 0x14, 0x40f000f0 },
2389 { 0x18, 0x40f000f0 },
2390 { 0x19, 0x40f000f0 },
2391 { 0x1e, 0x044413b0 },
2392 { 0x1f, 0x044413b0 },
2393 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002394};
2395
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002396static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2397 { 0x0a, 0x0421101f },
2398 { 0x0b, 0x04a11221 },
2399 { 0x0c, 0x90a70330 },
2400 { 0x0d, 0x90170110 },
2401 { 0x0e, 0x40f000f0 },
2402 { 0x0f, 0x40f000f0 },
2403 { 0x14, 0x40f000f0 },
2404 { 0x18, 0x90a000f0 },
2405 { 0x19, 0x40f000f0 },
2406 { 0x1e, 0x044413b0 },
2407 { 0x1f, 0x044413b0 },
2408 {}
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002409};
2410
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002411static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2412 const struct hda_fixup *fix, int action)
2413{
2414 struct sigmatel_spec *spec = codec->spec;
2415
2416 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2417 return;
2418
2419 snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2420 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2421}
2422
2423static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec,
2424 const struct hda_fixup *fix, int action)
2425{
2426 struct sigmatel_spec *spec = codec->spec;
2427
2428 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2429 return;
2430 spec->num_dmics = 0;
2431 spec->num_smuxes = 0;
2432 spec->num_dmuxes = 0;
2433}
2434
2435static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec,
2436 const struct hda_fixup *fix, int action)
2437{
2438 struct sigmatel_spec *spec = codec->spec;
2439
2440 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2441 return;
2442 spec->num_dmics = 1;
2443 spec->num_smuxes = 0;
2444 spec->num_dmuxes = 1;
2445}
2446
2447static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2448 const struct hda_fixup *fix, int action)
2449{
2450 struct sigmatel_spec *spec = codec->spec;
2451
2452 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2453 return;
2454
2455 /* Enable VREF power saving on GPIO1 detect */
2456 stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02);
2457 snd_hda_codec_write_cache(codec, codec->afg, 0,
2458 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
2459 snd_hda_jack_detect_enable(codec, codec->afg, 0);
2460 spec->gpio_mask |= 0x02;
2461
2462 /* enable internal microphone */
2463 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2464 stac92xx_auto_set_pinctl(codec, 0x0e,
2465 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2466
2467 stac92hd71bxx_fixup_no_dmic(codec, fix, action);
2468}
2469
2470static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec,
2471 const struct hda_fixup *fix, int action)
2472{
2473 struct sigmatel_spec *spec = codec->spec;
2474
2475 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2476 return;
2477 spec->num_dmics = 1;
2478 /* I don't know if it needs 1 or 2 smuxes - will wait for
2479 * bug reports to fix if needed
2480 */
2481 spec->num_smuxes = 1;
2482 spec->num_dmuxes = 1;
2483}
2484
2485static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2486 const struct hda_fixup *fix, int action)
2487{
2488 struct sigmatel_spec *spec = codec->spec;
2489
2490 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2491 return;
2492 spec->gpio_led = 0x01;
2493}
2494
2495static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2496 const struct hda_fixup *fix, int action)
2497{
2498 struct sigmatel_spec *spec = codec->spec;
2499 unsigned int cap;
2500
2501 switch (action) {
2502 case HDA_FIXUP_ACT_PRE_PROBE:
2503 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2504 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwaif6655d52013-01-17 08:49:01 +01002505 break;
2506
2507 case HDA_FIXUP_ACT_PROBE:
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002508 /* HP dv6 gives the headphone pin as a line-out. Thus we
2509 * need to set hp_detect flag here to force to enable HP
2510 * detection.
2511 */
2512 spec->hp_detect = 1;
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002513 /* enable bass on HP dv7 */
2514 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2515 cap &= AC_GPIO_IO_COUNT;
2516 if (cap >= 6)
2517 stac_add_hp_bass_switch(codec);
2518 break;
2519 }
2520}
2521
2522static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
2523 const struct hda_fixup *fix, int action)
2524{
2525 struct sigmatel_spec *spec = codec->spec;
2526
2527 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2528 return;
2529 spec->gpio_led = 0x08;
2530 spec->num_dmics = 1;
2531 spec->num_smuxes = 1;
2532 spec->num_dmuxes = 1;
2533}
2534
2535
2536static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
2537 const struct hda_fixup *fix, int action)
2538{
2539 struct sigmatel_spec *spec = codec->spec;
2540
2541 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2542 return;
2543
2544 if (hp_blike_system(codec->subsystem_id)) {
2545 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
2546 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
2547 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
2548 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
2549 /* It was changed in the BIOS to just satisfy MS DTM.
2550 * Lets turn it back into slaved HP
2551 */
2552 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
2553 | (AC_JACK_HP_OUT <<
2554 AC_DEFCFG_DEVICE_SHIFT);
2555 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
2556 | AC_DEFCFG_SEQUENCE)))
2557 | 0x1f;
2558 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
2559 }
2560 }
2561
Takashi Iwaif6655d52013-01-17 08:49:01 +01002562 if (find_mute_led_cfg(codec, spec->default_polarity))
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002563 snd_printd("mute LED gpio %d polarity %d\n",
2564 spec->gpio_led,
2565 spec->gpio_led_polarity);
2566
2567}
2568
2569static const struct hda_fixup stac92hd71bxx_fixups[] = {
2570 [STAC_92HD71BXX_REF] = {
2571 .type = HDA_FIXUP_FUNC,
2572 .v.func = stac92hd71bxx_fixup_ref,
2573 },
2574 [STAC_DELL_M4_1] = {
2575 .type = HDA_FIXUP_PINS,
2576 .v.pins = dell_m4_1_pin_configs,
2577 .chained = true,
2578 .chain_id = STAC_92HD71BXX_NO_SMUX,
2579 },
2580 [STAC_DELL_M4_2] = {
2581 .type = HDA_FIXUP_PINS,
2582 .v.pins = dell_m4_2_pin_configs,
2583 .chained = true,
2584 .chain_id = STAC_92HD71BXX_NO_DMIC,
2585 },
2586 [STAC_DELL_M4_3] = {
2587 .type = HDA_FIXUP_PINS,
2588 .v.pins = dell_m4_3_pin_configs,
2589 .chained = true,
2590 .chain_id = STAC_92HD71BXX_NO_SMUX,
2591 },
2592 [STAC_HP_M4] = {
2593 .type = HDA_FIXUP_FUNC,
2594 .v.func = stac92hd71bxx_fixup_hp_m4,
2595 .chained = true,
2596 .chain_id = STAC_92HD71BXX_HP,
2597 },
2598 [STAC_HP_DV4] = {
2599 .type = HDA_FIXUP_FUNC,
2600 .v.func = stac92hd71bxx_fixup_hp_dv4,
2601 .chained = true,
2602 .chain_id = STAC_HP_DV5,
2603 },
2604 [STAC_HP_DV5] = {
2605 .type = HDA_FIXUP_FUNC,
2606 .v.func = stac92hd71bxx_fixup_hp_dv5,
2607 .chained = true,
2608 .chain_id = STAC_92HD71BXX_HP,
2609 },
2610 [STAC_HP_HDX] = {
2611 .type = HDA_FIXUP_FUNC,
2612 .v.func = stac92hd71bxx_fixup_hp_hdx,
2613 .chained = true,
2614 .chain_id = STAC_92HD71BXX_HP,
2615 },
2616 [STAC_HP_DV4_1222NR] = {
2617 .type = HDA_FIXUP_FUNC,
2618 .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr,
2619 .chained = true,
2620 .chain_id = STAC_HP_DV4,
2621 },
2622 [STAC_92HD71BXX_NO_DMIC] = {
2623 .type = HDA_FIXUP_FUNC,
2624 .v.func = stac92hd71bxx_fixup_no_dmic,
2625 },
2626 [STAC_92HD71BXX_NO_SMUX] = {
2627 .type = HDA_FIXUP_FUNC,
2628 .v.func = stac92hd71bxx_fixup_no_smux,
2629 },
2630 [STAC_92HD71BXX_HP] = {
2631 .type = HDA_FIXUP_FUNC,
2632 .v.func = stac92hd71bxx_fixup_hp,
2633 },
Matthew Ranostaye035b842007-11-06 11:53:55 +01002634};
2635
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002636static const struct hda_model_fixup stac92hd71bxx_models[] = {
2637 { .id = STAC_92HD71BXX_REF, .name = "ref" },
2638 { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
2639 { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
2640 { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
2641 { .id = STAC_HP_M4, .name = "hp-m4" },
2642 { .id = STAC_HP_DV4, .name = "hp-dv4" },
2643 { .id = STAC_HP_DV5, .name = "hp-dv5" },
2644 { .id = STAC_HP_HDX, .name = "hp-hdx" },
2645 { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" },
2646 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002647};
2648
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002649static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002650 /* SigmaTel reference board */
2651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2652 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002653 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2654 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04002655 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
2656 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01002657 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2658 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01002659 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2660 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002661 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002662 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002663 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2664 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002665 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2666 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04002667 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002668 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002669 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002670 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02002671 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2672 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05302673 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2674 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11002675 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2676 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02002677 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2678 "HP", STAC_HP_DV5),
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002679 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2681 "unknown Dell", STAC_DELL_M4_1),
2682 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2683 "unknown Dell", STAC_DELL_M4_1),
2684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2685 "unknown Dell", STAC_DELL_M4_1),
2686 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2687 "unknown Dell", STAC_DELL_M4_1),
2688 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2689 "unknown Dell", STAC_DELL_M4_1),
2690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2691 "unknown Dell", STAC_DELL_M4_1),
2692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2693 "unknown Dell", STAC_DELL_M4_1),
2694 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2695 "unknown Dell", STAC_DELL_M4_2),
2696 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2697 "unknown Dell", STAC_DELL_M4_2),
2698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2699 "unknown Dell", STAC_DELL_M4_2),
2700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2701 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2703 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002704 {} /* terminator */
2705};
2706
Takashi Iwai0a427842013-01-14 15:20:13 +01002707static const struct hda_pintbl ref922x_pin_configs[] = {
2708 { 0x0a, 0x01014010 },
2709 { 0x0b, 0x01016011 },
2710 { 0x0c, 0x01012012 },
2711 { 0x0d, 0x0221401f },
2712 { 0x0e, 0x01813122 },
2713 { 0x0f, 0x01011014 },
2714 { 0x10, 0x01441030 },
2715 { 0x11, 0x01c41030 },
2716 { 0x15, 0x40000100 },
2717 { 0x1b, 0x40000100 },
2718 {}
Matt2f2f4252005-04-13 14:45:30 +02002719};
2720
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002721/*
2722 STAC 922X pin configs for
2723 102801A7
2724 102801AB
2725 102801A9
2726 102801D1
2727 102801D2
2728*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002729static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2730 { 0x0a, 0x02214030 },
2731 { 0x0b, 0x01a19021 },
2732 { 0x0c, 0x01111012 },
2733 { 0x0d, 0x01114010 },
2734 { 0x0e, 0x02a19020 },
2735 { 0x0f, 0x01117011 },
2736 { 0x10, 0x400001f0 },
2737 { 0x11, 0x400001f1 },
2738 { 0x15, 0x01813122 },
2739 { 0x1b, 0x400001f2 },
2740 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002741};
2742
2743/*
2744 STAC 922X pin configs for
2745 102801AC
2746 102801D0
2747*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002748static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2749 { 0x0a, 0x02214030 },
2750 { 0x0b, 0x01a19021 },
2751 { 0x0c, 0x01111012 },
2752 { 0x0d, 0x01114010 },
2753 { 0x0e, 0x02a19020 },
2754 { 0x0f, 0x01117011 },
2755 { 0x10, 0x01451140 },
2756 { 0x11, 0x400001f0 },
2757 { 0x15, 0x01813122 },
2758 { 0x1b, 0x400001f1 },
2759 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002760};
2761
2762/*
2763 STAC 922X pin configs for
2764 102801BF
2765*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002766static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2767 { 0x0a, 0x0321101f },
2768 { 0x0b, 0x01112024 },
2769 { 0x0c, 0x01111222 },
2770 { 0x0d, 0x91174220 },
2771 { 0x0e, 0x03a11050 },
2772 { 0x0f, 0x01116221 },
2773 { 0x10, 0x90a70330 },
2774 { 0x11, 0x01452340 },
2775 { 0x15, 0x40C003f1 },
2776 { 0x1b, 0x405003f0 },
2777 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002778};
2779
2780/*
2781 STAC 9221 A1 pin configs for
2782 102801D7 (Dell XPS M1210)
2783*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002784static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2785 { 0x0a, 0x02211211 },
2786 { 0x0b, 0x408103ff },
2787 { 0x0c, 0x02a1123e },
2788 { 0x0d, 0x90100310 },
2789 { 0x0e, 0x408003f1 },
2790 { 0x0f, 0x0221121f },
2791 { 0x10, 0x03451340 },
2792 { 0x11, 0x40c003f2 },
2793 { 0x15, 0x508003f3 },
2794 { 0x1b, 0x405003f4 },
2795 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002796};
2797
Takashi Iwai0a427842013-01-14 15:20:13 +01002798static const struct hda_pintbl d945gtp3_pin_configs[] = {
2799 { 0x0a, 0x0221401f },
2800 { 0x0b, 0x01a19022 },
2801 { 0x0c, 0x01813021 },
2802 { 0x0d, 0x01014010 },
2803 { 0x0e, 0x40000100 },
2804 { 0x0f, 0x40000100 },
2805 { 0x10, 0x40000100 },
2806 { 0x11, 0x40000100 },
2807 { 0x15, 0x02a19120 },
2808 { 0x1b, 0x40000100 },
2809 {}
Matt Porter403d1942005-11-29 15:00:51 +01002810};
2811
Takashi Iwai0a427842013-01-14 15:20:13 +01002812static const struct hda_pintbl d945gtp5_pin_configs[] = {
2813 { 0x0a, 0x0221401f },
2814 { 0x0b, 0x01011012 },
2815 { 0x0c, 0x01813024 },
2816 { 0x0d, 0x01014010 },
2817 { 0x0e, 0x01a19021 },
2818 { 0x0f, 0x01016011 },
2819 { 0x10, 0x01452130 },
2820 { 0x11, 0x40000100 },
2821 { 0x15, 0x02a19320 },
2822 { 0x1b, 0x40000100 },
2823 {}
Matt Porter403d1942005-11-29 15:00:51 +01002824};
2825
Takashi Iwai0a427842013-01-14 15:20:13 +01002826static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2827 { 0x0a, 0x0121e21f },
2828 { 0x0b, 0x400000ff },
2829 { 0x0c, 0x9017e110 },
2830 { 0x0d, 0x400000fd },
2831 { 0x0e, 0x400000fe },
2832 { 0x0f, 0x0181e020 },
2833 { 0x10, 0x1145e030 },
2834 { 0x11, 0x11c5e240 },
2835 { 0x15, 0x400000fc },
2836 { 0x1b, 0x400000fb },
2837 {}
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002838};
2839
Takashi Iwai0a427842013-01-14 15:20:13 +01002840static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2841 { 0x0a, 0x0121e21f },
2842 { 0x0b, 0x90a7012e },
2843 { 0x0c, 0x9017e110 },
2844 { 0x0d, 0x400000fd },
2845 { 0x0e, 0x400000fe },
2846 { 0x0f, 0x0181e020 },
2847 { 0x10, 0x1145e230 },
2848 { 0x11, 0x500000fa },
2849 { 0x15, 0x400000fc },
2850 { 0x1b, 0x400000fb },
2851 {}
Sylvain FORETf16928f2007-04-27 14:22:36 +02002852};
2853
Takashi Iwai0a427842013-01-14 15:20:13 +01002854static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2855 { 0x0a, 0x0121e21f },
2856 { 0x0b, 0x90a7012e },
2857 { 0x0c, 0x9017e110 },
2858 { 0x0d, 0x400000fd },
2859 { 0x0e, 0x400000fe },
2860 { 0x0f, 0x0181e020 },
2861 { 0x10, 0x1145e230 },
2862 { 0x11, 0x11c5e240 },
2863 { 0x15, 0x400000fc },
2864 { 0x1b, 0x400000fb },
2865 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002866};
2867
Takashi Iwai0a427842013-01-14 15:20:13 +01002868static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2869 { 0x0a, 0x0321e21f },
2870 { 0x0b, 0x03a1e02e },
2871 { 0x0c, 0x9017e110 },
2872 { 0x0d, 0x9017e11f },
2873 { 0x0e, 0x400000fe },
2874 { 0x0f, 0x0381e020 },
2875 { 0x10, 0x1345e230 },
2876 { 0x11, 0x13c5e240 },
2877 { 0x15, 0x400000fc },
2878 { 0x1b, 0x400000fb },
2879 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002880};
2881
Takashi Iwai0a427842013-01-14 15:20:13 +01002882static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2883 { 0x0a, 0x0321e21f },
2884 { 0x0b, 0x03a1e02e },
2885 { 0x0c, 0x9017e110 },
2886 { 0x0d, 0x9017e11f },
2887 { 0x0e, 0x400000fe },
2888 { 0x0f, 0x0381e020 },
2889 { 0x10, 0x1345e230 },
2890 { 0x11, 0x13c5e240 },
2891 { 0x15, 0x400000fc },
2892 { 0x1b, 0x400000fb },
2893 {}
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002894};
2895
Takashi Iwai0a427842013-01-14 15:20:13 +01002896static const struct hda_pintbl ecs202_pin_configs[] = {
2897 { 0x0a, 0x0221401f },
2898 { 0x0b, 0x02a19020 },
2899 { 0x0c, 0x01a19020 },
2900 { 0x0d, 0x01114010 },
2901 { 0x0e, 0x408000f0 },
2902 { 0x0f, 0x01813022 },
2903 { 0x10, 0x074510a0 },
2904 { 0x11, 0x40c400f1 },
2905 { 0x15, 0x9037012e },
2906 { 0x1b, 0x40e000f2 },
2907 {}
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002908};
Takashi Iwai76c08822007-06-19 12:17:42 +02002909
Takashi Iwai0a427842013-01-14 15:20:13 +01002910/* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2911static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2912 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2913 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2914 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2915 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2916 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2917 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2918 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2919 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2920 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2921 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2922 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2923 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2924 {}
2925};
2926
2927static const struct hda_fixup stac922x_fixups[];
2928
2929/* remap the fixup from codec SSID and apply it */
2930static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2931 const struct hda_fixup *fix,
2932 int action)
2933{
2934 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2935 return;
2936 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2937 stac922x_fixups);
2938 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2939 snd_hda_apply_fixup(codec, action);
2940}
2941
2942static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2943 const struct hda_fixup *fix,
2944 int action)
2945{
2946 struct sigmatel_spec *spec = codec->spec;
2947
2948 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2949 spec->gpio_mask = spec->gpio_dir = 0x03;
2950 spec->gpio_data = 0x03;
2951 }
2952}
2953
2954static const struct hda_fixup stac922x_fixups[] = {
2955 [STAC_D945_REF] = {
2956 .type = HDA_FIXUP_PINS,
2957 .v.pins = ref922x_pin_configs,
2958 },
2959 [STAC_D945GTP3] = {
2960 .type = HDA_FIXUP_PINS,
2961 .v.pins = d945gtp3_pin_configs,
2962 },
2963 [STAC_D945GTP5] = {
2964 .type = HDA_FIXUP_PINS,
2965 .v.pins = d945gtp5_pin_configs,
2966 },
2967 [STAC_INTEL_MAC_AUTO] = {
2968 .type = HDA_FIXUP_FUNC,
2969 .v.func = stac922x_fixup_intel_mac_auto,
2970 },
2971 [STAC_INTEL_MAC_V1] = {
2972 .type = HDA_FIXUP_PINS,
2973 .v.pins = intel_mac_v1_pin_configs,
2974 .chained = true,
2975 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2976 },
2977 [STAC_INTEL_MAC_V2] = {
2978 .type = HDA_FIXUP_PINS,
2979 .v.pins = intel_mac_v2_pin_configs,
2980 .chained = true,
2981 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2982 },
2983 [STAC_INTEL_MAC_V3] = {
2984 .type = HDA_FIXUP_PINS,
2985 .v.pins = intel_mac_v3_pin_configs,
2986 .chained = true,
2987 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2988 },
2989 [STAC_INTEL_MAC_V4] = {
2990 .type = HDA_FIXUP_PINS,
2991 .v.pins = intel_mac_v4_pin_configs,
2992 .chained = true,
2993 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2994 },
2995 [STAC_INTEL_MAC_V5] = {
2996 .type = HDA_FIXUP_PINS,
2997 .v.pins = intel_mac_v5_pin_configs,
2998 .chained = true,
2999 .chain_id = STAC_922X_INTEL_MAC_GPIO,
3000 },
3001 [STAC_922X_INTEL_MAC_GPIO] = {
3002 .type = HDA_FIXUP_FUNC,
3003 .v.func = stac922x_fixup_intel_mac_gpio,
3004 },
3005 [STAC_ECS_202] = {
3006 .type = HDA_FIXUP_PINS,
3007 .v.pins = ecs202_pin_configs,
3008 },
3009 [STAC_922X_DELL_D81] = {
3010 .type = HDA_FIXUP_PINS,
3011 .v.pins = dell_922x_d81_pin_configs,
3012 },
3013 [STAC_922X_DELL_D82] = {
3014 .type = HDA_FIXUP_PINS,
3015 .v.pins = dell_922x_d82_pin_configs,
3016 },
3017 [STAC_922X_DELL_M81] = {
3018 .type = HDA_FIXUP_PINS,
3019 .v.pins = dell_922x_m81_pin_configs,
3020 },
3021 [STAC_922X_DELL_M82] = {
3022 .type = HDA_FIXUP_PINS,
3023 .v.pins = dell_922x_m82_pin_configs,
3024 },
3025};
3026
3027static const struct hda_model_fixup stac922x_models[] = {
3028 { .id = STAC_D945_REF, .name = "ref" },
3029 { .id = STAC_D945GTP5, .name = "5stack" },
3030 { .id = STAC_D945GTP3, .name = "3stack" },
3031 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
3032 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
3033 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
3034 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
3035 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
3036 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
3037 { .id = STAC_ECS_202, .name = "ecs202" },
3038 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
3039 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
3040 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
3041 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003042 /* for backward compatibility */
Takashi Iwai0a427842013-01-14 15:20:13 +01003043 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
3044 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
3045 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
3046 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
3047 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
3048 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
3049 {}
Matt Porter403d1942005-11-29 15:00:51 +01003050};
3051
Takashi Iwai0a427842013-01-14 15:20:13 +01003052static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003053 /* SigmaTel reference board */
3054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3055 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003056 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3057 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003058 /* Intel 945G based systems */
3059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
3060 "Intel D945G", STAC_D945GTP3),
3061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
3062 "Intel D945G", STAC_D945GTP3),
3063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
3064 "Intel D945G", STAC_D945GTP3),
3065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
3066 "Intel D945G", STAC_D945GTP3),
3067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
3068 "Intel D945G", STAC_D945GTP3),
3069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
3070 "Intel D945G", STAC_D945GTP3),
3071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
3072 "Intel D945G", STAC_D945GTP3),
3073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
3074 "Intel D945G", STAC_D945GTP3),
3075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
3076 "Intel D945G", STAC_D945GTP3),
3077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
3078 "Intel D945G", STAC_D945GTP3),
3079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
3080 "Intel D945G", STAC_D945GTP3),
3081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
3082 "Intel D945G", STAC_D945GTP3),
3083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
3084 "Intel D945G", STAC_D945GTP3),
3085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
3086 "Intel D945G", STAC_D945GTP3),
3087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
3088 "Intel D945G", STAC_D945GTP3),
3089 /* Intel D945G 5-stack systems */
3090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
3091 "Intel D945G", STAC_D945GTP5),
3092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
3093 "Intel D945G", STAC_D945GTP5),
3094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
3095 "Intel D945G", STAC_D945GTP5),
3096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
3097 "Intel D945G", STAC_D945GTP5),
3098 /* Intel 945P based systems */
3099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
3100 "Intel D945P", STAC_D945GTP3),
3101 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
3102 "Intel D945P", STAC_D945GTP3),
3103 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
3104 "Intel D945P", STAC_D945GTP3),
3105 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
3106 "Intel D945P", STAC_D945GTP3),
3107 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
3108 "Intel D945P", STAC_D945GTP3),
3109 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
3110 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01003111 /* other intel */
3112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
3113 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003114 /* other systems */
Takashi Iwai0a427842013-01-14 15:20:13 +01003115
Nicolas Boichat536319a2008-07-21 22:18:01 +08003116 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwai0a427842013-01-14 15:20:13 +01003117 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
3118
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003119 /* Dell systems */
3120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
3121 "unknown Dell", STAC_922X_DELL_D81),
3122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
3123 "unknown Dell", STAC_922X_DELL_D81),
3124 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
3125 "unknown Dell", STAC_922X_DELL_D81),
3126 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
3127 "unknown Dell", STAC_922X_DELL_D82),
3128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
3129 "unknown Dell", STAC_922X_DELL_M81),
3130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
3131 "unknown Dell", STAC_922X_DELL_D82),
3132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
3133 "unknown Dell", STAC_922X_DELL_D81),
3134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
3135 "unknown Dell", STAC_922X_DELL_D81),
3136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
3137 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03003138 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003139 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02003140 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01003141 {} /* terminator */
3142};
3143
Takashi Iwai29ac8362013-01-14 16:03:38 +01003144static const struct hda_pintbl ref927x_pin_configs[] = {
3145 { 0x0a, 0x02214020 },
3146 { 0x0b, 0x02a19080 },
3147 { 0x0c, 0x0181304e },
3148 { 0x0d, 0x01014010 },
3149 { 0x0e, 0x01a19040 },
3150 { 0x0f, 0x01011012 },
3151 { 0x10, 0x01016011 },
3152 { 0x11, 0x0101201f },
3153 { 0x12, 0x183301f0 },
3154 { 0x13, 0x18a001f0 },
3155 { 0x14, 0x18a001f0 },
3156 { 0x21, 0x01442070 },
3157 { 0x22, 0x01c42190 },
3158 { 0x23, 0x40000100 },
3159 {}
Matt Porter3cc08dc2006-01-23 15:27:49 +01003160};
3161
Takashi Iwai29ac8362013-01-14 16:03:38 +01003162static const struct hda_pintbl d965_3st_pin_configs[] = {
3163 { 0x0a, 0x0221401f },
3164 { 0x0b, 0x02a19120 },
3165 { 0x0c, 0x40000100 },
3166 { 0x0d, 0x01014011 },
3167 { 0x0e, 0x01a19021 },
3168 { 0x0f, 0x01813024 },
3169 { 0x10, 0x40000100 },
3170 { 0x11, 0x40000100 },
3171 { 0x12, 0x40000100 },
3172 { 0x13, 0x40000100 },
3173 { 0x14, 0x40000100 },
3174 { 0x21, 0x40000100 },
3175 { 0x22, 0x40000100 },
3176 { 0x23, 0x40000100 },
3177 {}
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003178};
3179
Takashi Iwai29ac8362013-01-14 16:03:38 +01003180static const struct hda_pintbl d965_5st_pin_configs[] = {
3181 { 0x0a, 0x02214020 },
3182 { 0x0b, 0x02a19080 },
3183 { 0x0c, 0x0181304e },
3184 { 0x0d, 0x01014010 },
3185 { 0x0e, 0x01a19040 },
3186 { 0x0f, 0x01011012 },
3187 { 0x10, 0x01016011 },
3188 { 0x11, 0x40000100 },
3189 { 0x12, 0x40000100 },
3190 { 0x13, 0x40000100 },
3191 { 0x14, 0x40000100 },
3192 { 0x21, 0x01442070 },
3193 { 0x22, 0x40000100 },
3194 { 0x23, 0x40000100 },
3195 {}
Tobin Davis93ed1502006-09-01 21:03:12 +02003196};
3197
Takashi Iwai29ac8362013-01-14 16:03:38 +01003198static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
3199 { 0x0a, 0x40000100 },
3200 { 0x0b, 0x40000100 },
3201 { 0x0c, 0x0181304e },
3202 { 0x0d, 0x01014010 },
3203 { 0x0e, 0x01a19040 },
3204 { 0x0f, 0x01011012 },
3205 { 0x10, 0x01016011 },
3206 { 0x11, 0x40000100 },
3207 { 0x12, 0x40000100 },
3208 { 0x13, 0x40000100 },
3209 { 0x14, 0x40000100 },
3210 { 0x21, 0x01442070 },
3211 { 0x22, 0x40000100 },
3212 { 0x23, 0x40000100 },
3213 {}
Takashi Iwai679d92e2009-05-24 19:00:08 +02003214};
3215
Takashi Iwai29ac8362013-01-14 16:03:38 +01003216static const struct hda_pintbl dell_3st_pin_configs[] = {
3217 { 0x0a, 0x02211230 },
3218 { 0x0b, 0x02a11220 },
3219 { 0x0c, 0x01a19040 },
3220 { 0x0d, 0x01114210 },
3221 { 0x0e, 0x01111212 },
3222 { 0x0f, 0x01116211 },
3223 { 0x10, 0x01813050 },
3224 { 0x11, 0x01112214 },
3225 { 0x12, 0x403003fa },
3226 { 0x13, 0x90a60040 },
3227 { 0x14, 0x90a60040 },
3228 { 0x21, 0x404003fb },
3229 { 0x22, 0x40c003fc },
3230 { 0x23, 0x40000100 },
3231 {}
Tobin Davis4ff076e2007-08-07 11:48:12 +02003232};
3233
Takashi Iwai29ac8362013-01-14 16:03:38 +01003234static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
3235 const struct hda_fixup *fix, int action)
3236{
3237 struct sigmatel_spec *spec = codec->spec;
3238
3239 /* no jack detecion for ref-no-jd model */
3240 if (action == HDA_FIXUP_ACT_PROBE)
3241 spec->hp_detect = 0;
3242}
3243
3244static void stac927x_fixup_ref(struct hda_codec *codec,
3245 const struct hda_fixup *fix, int action)
3246{
3247 struct sigmatel_spec *spec = codec->spec;
3248
3249 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3250 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
3251 spec->eapd_mask = spec->gpio_mask = 0;
3252 spec->gpio_dir = spec->gpio_data = 0;
3253 }
3254}
3255
3256static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
3257 const struct hda_fixup *fix, int action)
3258{
3259 struct sigmatel_spec *spec = codec->spec;
3260
3261 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3262 return;
3263
3264 if (codec->subsystem_id != 0x1028022f) {
3265 /* GPIO2 High = Enable EAPD */
3266 spec->eapd_mask = spec->gpio_mask = 0x04;
3267 spec->gpio_dir = spec->gpio_data = 0x04;
3268 }
3269 spec->dmic_nids = stac927x_dmic_nids;
3270 spec->num_dmics = STAC927X_NUM_DMICS;
3271
3272 snd_hda_add_verbs(codec, dell_3st_core_init);
3273 spec->volknob_init = 1;
3274 spec->dmux_nids = stac927x_dmux_nids;
3275 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3276}
3277
3278static void stac927x_fixup_volknob(struct hda_codec *codec,
3279 const struct hda_fixup *fix, int action)
3280{
3281 struct sigmatel_spec *spec = codec->spec;
3282
3283 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3284 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
3285 spec->volknob_init = 1;
3286 }
3287}
3288
3289static const struct hda_fixup stac927x_fixups[] = {
3290 [STAC_D965_REF_NO_JD] = {
3291 .type = HDA_FIXUP_FUNC,
3292 .v.func = stac927x_fixup_ref_no_jd,
3293 .chained = true,
3294 .chain_id = STAC_D965_REF,
3295 },
3296 [STAC_D965_REF] = {
3297 .type = HDA_FIXUP_FUNC,
3298 .v.func = stac927x_fixup_ref,
3299 },
3300 [STAC_D965_3ST] = {
3301 .type = HDA_FIXUP_PINS,
3302 .v.pins = d965_3st_pin_configs,
3303 .chained = true,
3304 .chain_id = STAC_D965_VERBS,
3305 },
3306 [STAC_D965_5ST] = {
3307 .type = HDA_FIXUP_PINS,
3308 .v.pins = d965_5st_pin_configs,
3309 .chained = true,
3310 .chain_id = STAC_D965_VERBS,
3311 },
3312 [STAC_D965_VERBS] = {
3313 .type = HDA_FIXUP_VERBS,
3314 .v.verbs = d965_core_init,
3315 },
3316 [STAC_D965_5ST_NO_FP] = {
3317 .type = HDA_FIXUP_PINS,
3318 .v.pins = d965_5st_no_fp_pin_configs,
3319 },
3320 [STAC_DELL_3ST] = {
3321 .type = HDA_FIXUP_PINS,
3322 .v.pins = dell_3st_pin_configs,
3323 .chained = true,
3324 .chain_id = STAC_927X_DELL_DMIC,
3325 },
3326 [STAC_DELL_BIOS] = {
3327 .type = HDA_FIXUP_PINS,
3328 .v.pins = (const struct hda_pintbl[]) {
3329 /* configure the analog microphone on some laptops */
3330 { 0x0c, 0x90a79130 },
3331 /* correct the front output jack as a hp out */
3332 { 0x0f, 0x0227011f },
3333 /* correct the front input jack as a mic */
3334 { 0x0e, 0x02a79130 },
3335 {}
3336 },
3337 .chained = true,
3338 .chain_id = STAC_927X_DELL_DMIC,
3339 },
3340 [STAC_DELL_BIOS_SPDIF] = {
3341 .type = HDA_FIXUP_PINS,
3342 .v.pins = (const struct hda_pintbl[]) {
3343 /* correct the device field to SPDIF out */
3344 { 0x21, 0x01442070 },
3345 {}
3346 },
3347 .chained = true,
3348 .chain_id = STAC_DELL_BIOS,
3349 },
3350 [STAC_927X_DELL_DMIC] = {
3351 .type = HDA_FIXUP_FUNC,
3352 .v.func = stac927x_fixup_dell_dmic,
3353 },
3354 [STAC_927X_VOLKNOB] = {
3355 .type = HDA_FIXUP_FUNC,
3356 .v.func = stac927x_fixup_volknob,
3357 },
Matt Porter3cc08dc2006-01-23 15:27:49 +01003358};
3359
Takashi Iwai29ac8362013-01-14 16:03:38 +01003360static const struct hda_model_fixup stac927x_models[] = {
3361 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3362 { .id = STAC_D965_REF, .name = "ref" },
3363 { .id = STAC_D965_3ST, .name = "3stack" },
3364 { .id = STAC_D965_5ST, .name = "5stack" },
3365 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3366 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3367 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3368 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3369 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003370};
3371
Takashi Iwai29ac8362013-01-14 16:03:38 +01003372static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003373 /* SigmaTel reference board */
3374 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3375 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003376 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3377 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003378 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003379 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3380 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02003381 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003382 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3383 "Intel D965", STAC_D965_3ST),
3384 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3385 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003386 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
3389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003390 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04003392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
Chengu Wang84d3dc22009-07-30 19:43:55 +08003395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
3397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
3398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
Tobin Davis93ed1502006-09-01 21:03:12 +02003400 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003401 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3402 "Intel D965", STAC_D965_5ST),
3403 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3404 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02003405 /* volume-knob fixes */
3406 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01003407 {} /* terminator */
3408};
3409
Takashi Iwaife6322c2013-01-14 14:46:51 +01003410static const struct hda_pintbl ref9205_pin_configs[] = {
3411 { 0x0a, 0x40000100 },
3412 { 0x0b, 0x40000100 },
3413 { 0x0c, 0x01016011 },
3414 { 0x0d, 0x01014010 },
3415 { 0x0e, 0x01813122 },
3416 { 0x0f, 0x01a19021 },
3417 { 0x14, 0x01019020 },
3418 { 0x16, 0x40000100 },
3419 { 0x17, 0x90a000f0 },
3420 { 0x18, 0x90a000f0 },
3421 { 0x21, 0x01441030 },
3422 { 0x22, 0x01c41030 },
3423 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003424};
3425
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003426/*
3427 STAC 9205 pin configs for
3428 102801F1
3429 102801F2
3430 102801FC
3431 102801FD
3432 10280204
3433 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003434 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01003435 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003436*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003437static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3438 { 0x0a, 0x0321101F },
3439 { 0x0b, 0x03A11020 },
3440 { 0x0c, 0x400003FA },
3441 { 0x0d, 0x90170310 },
3442 { 0x0e, 0x400003FB },
3443 { 0x0f, 0x400003FC },
3444 { 0x14, 0x400003FD },
3445 { 0x16, 0x40F000F9 },
3446 { 0x17, 0x90A60330 },
3447 { 0x18, 0x400003FF },
3448 { 0x21, 0x0144131F },
3449 { 0x22, 0x40C003FE },
3450 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003451};
3452
3453/*
3454 STAC 9205 pin configs for
3455 102801F9
3456 102801FA
3457 102801FE
3458 102801FF (Dell Precision M4300)
3459 10280206
3460 10280200
3461 10280201
3462*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003463static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3464 { 0x0a, 0x0321101f },
3465 { 0x0b, 0x03a11020 },
3466 { 0x0c, 0x90a70330 },
3467 { 0x0d, 0x90170310 },
3468 { 0x0e, 0x400000fe },
3469 { 0x0f, 0x400000ff },
3470 { 0x14, 0x400000fd },
3471 { 0x16, 0x40f000f9 },
3472 { 0x17, 0x400000fa },
3473 { 0x18, 0x400000fc },
3474 { 0x21, 0x0144131f },
3475 { 0x22, 0x40c003f8 },
3476 /* Enable SPDIF in/out */
3477 { 0x1f, 0x01441030 },
3478 { 0x20, 0x1c410030 },
3479 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003480};
3481
Takashi Iwaife6322c2013-01-14 14:46:51 +01003482static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3483 { 0x0a, 0x0421101f },
3484 { 0x0b, 0x04a11020 },
3485 { 0x0c, 0x400003fa },
3486 { 0x0d, 0x90170310 },
3487 { 0x0e, 0x400003fb },
3488 { 0x0f, 0x400003fc },
3489 { 0x14, 0x400003fd },
3490 { 0x16, 0x400003f9 },
3491 { 0x17, 0x90a60330 },
3492 { 0x18, 0x400003ff },
3493 { 0x21, 0x01441340 },
3494 { 0x22, 0x40c003fe },
3495 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003496};
3497
Takashi Iwaife6322c2013-01-14 14:46:51 +01003498static void stac9205_fixup_ref(struct hda_codec *codec,
3499 const struct hda_fixup *fix, int action)
3500{
3501 struct sigmatel_spec *spec = codec->spec;
3502
3503 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3504 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3505 /* SPDIF-In enabled */
3506 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3507 }
3508}
3509
Takashi Iwaife6322c2013-01-14 14:46:51 +01003510static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3511 const struct hda_fixup *fix, int action)
3512{
3513 struct sigmatel_spec *spec = codec->spec;
3514 int err;
3515
3516 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3517 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3518
3519 /* Enable unsol response for GPIO4/Dock HP connection */
3520 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
3521 if (err < 0)
3522 return;
3523 snd_hda_codec_write_cache(codec, codec->afg, 0,
3524 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3525 snd_hda_jack_detect_enable(codec, codec->afg, 0);
3526
3527 spec->gpio_dir = 0x0b;
3528 spec->eapd_mask = 0x01;
3529 spec->gpio_mask = 0x1b;
3530 spec->gpio_mute = 0x10;
3531 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3532 * GPIO3 Low = DRM
3533 */
3534 spec->gpio_data = 0x01;
3535 }
3536}
3537
3538static void stac9205_fixup_eapd(struct hda_codec *codec,
3539 const struct hda_fixup *fix, int action)
3540{
3541 struct sigmatel_spec *spec = codec->spec;
3542
3543 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3544 spec->eapd_switch = 0;
3545}
3546
3547static const struct hda_fixup stac9205_fixups[] = {
3548 [STAC_9205_REF] = {
3549 .type = HDA_FIXUP_FUNC,
3550 .v.func = stac9205_fixup_ref,
3551 },
3552 [STAC_9205_DELL_M42] = {
3553 .type = HDA_FIXUP_PINS,
3554 .v.pins = dell_9205_m42_pin_configs,
3555 },
3556 [STAC_9205_DELL_M43] = {
3557 .type = HDA_FIXUP_FUNC,
3558 .v.func = stac9205_fixup_dell_m43,
3559 },
3560 [STAC_9205_DELL_M44] = {
3561 .type = HDA_FIXUP_PINS,
3562 .v.pins = dell_9205_m44_pin_configs,
3563 },
3564 [STAC_9205_EAPD] = {
3565 .type = HDA_FIXUP_FUNC,
3566 .v.func = stac9205_fixup_eapd,
3567 },
3568 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003569};
3570
Takashi Iwaife6322c2013-01-14 14:46:51 +01003571static const struct hda_model_fixup stac9205_models[] = {
3572 { .id = STAC_9205_REF, .name = "ref" },
3573 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3574 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3575 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3576 { .id = STAC_9205_EAPD, .name = "eapd" },
3577 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003578};
3579
Takashi Iwaife6322c2013-01-14 14:46:51 +01003580static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003581 /* SigmaTel reference board */
3582 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3583 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03003584 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3585 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003586 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3587 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003588 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3590 "unknown Dell", STAC_9205_DELL_M42),
3591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3592 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02003594 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3596 "Dell Precision", STAC_9205_DELL_M43),
3597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3598 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3600 "unknown Dell", STAC_9205_DELL_M42),
3601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3602 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3604 "Dell Precision", STAC_9205_DELL_M43),
3605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003606 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3608 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02003609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3610 "Dell Precision", STAC_9205_DELL_M43),
3611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3612 "Dell Precision", STAC_9205_DELL_M43),
3613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3614 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3616 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3618 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01003619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3620 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003621 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08003622 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003623 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02003624 {} /* terminator */
3625};
3626
Matt2f2f4252005-04-13 14:45:30 +02003627/*
3628 * Analog playback callbacks
3629 */
3630static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
3631 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003632 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003633{
3634 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003635 if (spec->stream_delay)
3636 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01003637 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3638 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02003639}
3640
3641static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3642 struct hda_codec *codec,
3643 unsigned int stream_tag,
3644 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003645 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003646{
3647 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01003648 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02003649}
3650
3651static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3652 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003653 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003654{
3655 struct sigmatel_spec *spec = codec->spec;
3656 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3657}
3658
3659/*
Mattdabbed62005-06-14 10:19:34 +02003660 * Digital playback callbacks
3661 */
3662static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3663 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003664 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003665{
3666 struct sigmatel_spec *spec = codec->spec;
3667 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3668}
3669
3670static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3671 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003672 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003673{
3674 struct sigmatel_spec *spec = codec->spec;
3675 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3676}
3677
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003678static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3679 struct hda_codec *codec,
3680 unsigned int stream_tag,
3681 unsigned int format,
3682 struct snd_pcm_substream *substream)
3683{
3684 struct sigmatel_spec *spec = codec->spec;
3685 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3686 stream_tag, format, substream);
3687}
3688
Takashi Iwai9411e212009-02-13 11:32:28 +01003689static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3690 struct hda_codec *codec,
3691 struct snd_pcm_substream *substream)
3692{
3693 struct sigmatel_spec *spec = codec->spec;
3694 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3695}
3696
Mattdabbed62005-06-14 10:19:34 +02003697
3698/*
Matt2f2f4252005-04-13 14:45:30 +02003699 * Analog capture callbacks
3700 */
3701static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3702 struct hda_codec *codec,
3703 unsigned int stream_tag,
3704 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003705 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003706{
3707 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003708 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003709
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003710 if (spec->powerdown_adcs) {
3711 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003712 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003713 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
3714 }
3715 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02003716 return 0;
3717}
3718
3719static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3720 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003721 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003722{
3723 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003724 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003725
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003726 snd_hda_codec_cleanup_stream(codec, nid);
3727 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003728 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003729 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02003730 return 0;
3731}
3732
Takashi Iwai2b635362011-05-02 12:33:43 +02003733static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02003734 .substreams = 1,
3735 .channels_min = 2,
3736 .channels_max = 2,
3737 /* NID is set in stac92xx_build_pcms */
3738 .ops = {
3739 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003740 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01003741 .prepare = stac92xx_dig_playback_pcm_prepare,
3742 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02003743 },
3744};
3745
Takashi Iwai2b635362011-05-02 12:33:43 +02003746static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02003747 .substreams = 1,
3748 .channels_min = 2,
3749 .channels_max = 2,
3750 /* NID is set in stac92xx_build_pcms */
3751};
3752
Takashi Iwai2b635362011-05-02 12:33:43 +02003753static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02003754 .substreams = 1,
3755 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02003756 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02003757 .nid = 0x02, /* NID to query formats and rates */
3758 .ops = {
3759 .open = stac92xx_playback_pcm_open,
3760 .prepare = stac92xx_playback_pcm_prepare,
3761 .cleanup = stac92xx_playback_pcm_cleanup
3762 },
3763};
3764
Takashi Iwai2b635362011-05-02 12:33:43 +02003765static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003766 .substreams = 1,
3767 .channels_min = 2,
3768 .channels_max = 2,
3769 .nid = 0x06, /* NID to query formats and rates */
3770 .ops = {
3771 .open = stac92xx_playback_pcm_open,
3772 .prepare = stac92xx_playback_pcm_prepare,
3773 .cleanup = stac92xx_playback_pcm_cleanup
3774 },
3775};
3776
Takashi Iwai2b635362011-05-02 12:33:43 +02003777static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02003778 .channels_min = 2,
3779 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003780 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02003781 .ops = {
3782 .prepare = stac92xx_capture_pcm_prepare,
3783 .cleanup = stac92xx_capture_pcm_cleanup
3784 },
3785};
3786
3787static int stac92xx_build_pcms(struct hda_codec *codec)
3788{
3789 struct sigmatel_spec *spec = codec->spec;
3790 struct hda_pcm *info = spec->pcm_rec;
3791
3792 codec->num_pcms = 1;
3793 codec->pcm_info = info;
3794
Mattc7d4b2f2005-06-27 14:59:41 +02003795 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02003796 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01003797 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3798 spec->multiout.dac_nids[0];
Takashi Iwaiee81abb2012-11-08 17:12:10 +01003799 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3800 spec->autocfg.line_outs == 2)
3801 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
3802 snd_pcm_2_1_chmaps;
3803
Matt2f2f4252005-04-13 14:45:30 +02003804 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003805 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003806 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003807
3808 if (spec->alt_switch) {
3809 codec->num_pcms++;
3810 info++;
3811 info->name = "STAC92xx Analog Alt";
3812 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
3813 }
Matt2f2f4252005-04-13 14:45:30 +02003814
Mattdabbed62005-06-14 10:19:34 +02003815 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3816 codec->num_pcms++;
3817 info++;
3818 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003819 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02003820 if (spec->multiout.dig_out_nid) {
3821 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
3822 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3823 }
3824 if (spec->dig_in_nid) {
3825 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
3826 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3827 }
3828 }
3829
Matt2f2f4252005-04-13 14:45:30 +02003830 return 0;
3831}
3832
Matt Porter403d1942005-11-29 15:00:51 +01003833static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
3834
3835{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02003836 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01003837}
3838
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003839#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
3840
3841static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
3842 struct snd_ctl_elem_value *ucontrol)
3843{
3844 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3845 struct sigmatel_spec *spec = codec->spec;
3846
Takashi Iwaid7a89432008-11-12 09:48:04 +01003847 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003848 return 0;
3849}
3850
Takashi Iwai62558ce2009-07-29 14:23:09 +02003851static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003852
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003853static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
3854 struct snd_ctl_elem_value *ucontrol)
3855{
3856 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3857 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003858 int nid = kcontrol->private_value;
3859
3860 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003861
Lucas De Marchi25985ed2011-03-30 22:57:33 -03003862 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003863 * switch changes
3864 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02003865 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003866
3867 return 1;
3868}
3869
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003870static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
3871 struct snd_ctl_elem_info *uinfo)
3872{
3873 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02003874 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003875 "Mic In", "Line In", "Line Out"
3876 };
3877
3878 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3879 struct sigmatel_spec *spec = codec->spec;
3880 hda_nid_t nid = kcontrol->private_value;
3881
3882 if (nid == spec->mic_switch || nid == spec->line_switch)
3883 i = 3;
3884 else
3885 i = 2;
3886
3887 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3888 uinfo->value.enumerated.items = i;
3889 uinfo->count = 1;
3890 if (uinfo->value.enumerated.item >= i)
3891 uinfo->value.enumerated.item = i-1;
3892 strcpy(uinfo->value.enumerated.name,
3893 texts[uinfo->value.enumerated.item]);
3894
3895 return 0;
3896}
3897
3898static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
3899 struct snd_ctl_elem_value *ucontrol)
3900{
3901 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3902 hda_nid_t nid = kcontrol->private_value;
3903 unsigned int vref = stac92xx_vref_get(codec, nid);
3904
Takashi Iwai47408602012-04-20 13:06:53 +02003905 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003906 ucontrol->value.enumerated.item[0] = 0;
3907 else if (vref == AC_PINCTL_VREF_GRD)
3908 ucontrol->value.enumerated.item[0] = 1;
3909 else if (vref == AC_PINCTL_VREF_HIZ)
3910 ucontrol->value.enumerated.item[0] = 2;
3911
3912 return 0;
3913}
3914
3915static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
3916 struct snd_ctl_elem_value *ucontrol)
3917{
3918 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3919 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02003920 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003921 hda_nid_t nid = kcontrol->private_value;
3922
3923 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02003924 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003925 else if (ucontrol->value.enumerated.item[0] == 1)
3926 new_vref = AC_PINCTL_VREF_GRD;
3927 else if (ucontrol->value.enumerated.item[0] == 2)
3928 new_vref = AC_PINCTL_VREF_HIZ;
3929 else
3930 return 0;
3931
3932 if (new_vref != stac92xx_vref_get(codec, nid)) {
3933 error = stac92xx_vref_set(codec, nid, new_vref);
3934 return error;
3935 }
3936
3937 return 0;
3938}
3939
3940static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
3941 struct snd_ctl_elem_info *uinfo)
3942{
Takashi Iwai2b635362011-05-02 12:33:43 +02003943 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3945 struct sigmatel_spec *spec = codec->spec;
3946
3947 if (kcontrol->private_value == spec->line_switch)
3948 texts[0] = "Line In";
3949 else
3950 texts[0] = "Mic In";
3951 texts[1] = "Line Out";
3952 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3953 uinfo->value.enumerated.items = 2;
3954 uinfo->count = 1;
3955
3956 if (uinfo->value.enumerated.item >= 2)
3957 uinfo->value.enumerated.item = 1;
3958 strcpy(uinfo->value.enumerated.name,
3959 texts[uinfo->value.enumerated.item]);
3960
3961 return 0;
3962}
Matt Porter403d1942005-11-29 15:00:51 +01003963
3964static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3965{
3966 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3967 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003968 hda_nid_t nid = kcontrol->private_value;
3969 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01003970
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003971 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01003972 return 0;
3973}
3974
3975static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3976{
3977 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3978 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003979 hda_nid_t nid = kcontrol->private_value;
3980 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3981 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01003982
3983 spec->io_switch[io_idx] = val;
3984
3985 if (val)
3986 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01003987 else {
3988 unsigned int pinctl = AC_PINCTL_IN_EN;
3989 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02003990 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003991 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3992 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01003993
3994 /* check the auto-mute again: we need to mute/unmute the speaker
3995 * appropriately according to the pin direction
3996 */
3997 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02003998 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01003999
Matt Porter403d1942005-11-29 15:00:51 +01004000 return 1;
4001}
4002
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004003#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
4004
4005static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
4006 struct snd_ctl_elem_value *ucontrol)
4007{
4008 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4009 struct sigmatel_spec *spec = codec->spec;
4010
4011 ucontrol->value.integer.value[0] = spec->clfe_swap;
4012 return 0;
4013}
4014
4015static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
4016 struct snd_ctl_elem_value *ucontrol)
4017{
4018 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4019 struct sigmatel_spec *spec = codec->spec;
4020 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004021 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004022
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004023 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004024 return 0;
4025
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004026 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004027
4028 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
4029 spec->clfe_swap ? 0x4 : 0x0);
4030
4031 return 1;
4032}
4033
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004034#define STAC_CODEC_HP_SWITCH(xname) \
4035 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4036 .name = xname, \
4037 .index = 0, \
4038 .info = stac92xx_hp_switch_info, \
4039 .get = stac92xx_hp_switch_get, \
4040 .put = stac92xx_hp_switch_put, \
4041 }
4042
Matt Porter403d1942005-11-29 15:00:51 +01004043#define STAC_CODEC_IO_SWITCH(xname, xpval) \
4044 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4045 .name = xname, \
4046 .index = 0, \
4047 .info = stac92xx_io_switch_info, \
4048 .get = stac92xx_io_switch_get, \
4049 .put = stac92xx_io_switch_put, \
4050 .private_value = xpval, \
4051 }
4052
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004053#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
4054 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4055 .name = xname, \
4056 .index = 0, \
4057 .info = stac92xx_clfe_switch_info, \
4058 .get = stac92xx_clfe_switch_get, \
4059 .put = stac92xx_clfe_switch_put, \
4060 .private_value = xpval, \
4061 }
Matt Porter403d1942005-11-29 15:00:51 +01004062
Mattc7d4b2f2005-06-27 14:59:41 +02004063enum {
4064 STAC_CTL_WIDGET_VOL,
4065 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004066 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01004067 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004068 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01004069 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02004070 STAC_CTL_WIDGET_CLFE_SWITCH,
4071 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02004072};
4073
Takashi Iwai2b635362011-05-02 12:33:43 +02004074static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02004075 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4076 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004077 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01004078 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004079 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01004080 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004081 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02004082 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02004083};
4084
4085/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01004086static struct snd_kcontrol_new *
4087stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004088 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004089 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004090 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02004091{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004092 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02004093
Takashi Iwai603c4012008-07-30 15:01:44 +02004094 knew = snd_array_new(&spec->kctls);
4095 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01004096 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004097 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02004098 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01004099 if (!knew->name) {
4100 /* roolback */
4101 memset(knew, 0, sizeof(*knew));
4102 spec->kctls.alloced--;
4103 return NULL;
4104 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004105 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01004106 return knew;
4107}
4108
Takashi Iwai62cbde12012-09-14 11:58:54 +02004109static struct snd_kcontrol_new *
4110add_control_temp(struct sigmatel_spec *spec,
4111 const struct snd_kcontrol_new *ktemp,
4112 int idx, const char *name,
4113 unsigned long val)
4114{
4115 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
4116 HDA_SUBDEV_AMP_FLAG);
4117 if (!knew)
4118 return NULL;
4119 knew->index = idx;
4120 knew->private_value = val;
4121 return knew;
4122}
4123
Takashi Iwaie3c75962009-01-23 11:57:22 +01004124static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004125 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01004126 int idx, const char *name,
4127 unsigned long val)
4128{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004129 return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM;
Mattc7d4b2f2005-06-27 14:59:41 +02004130}
4131
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004132static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
4133 int type, int idx, const char *name,
4134 unsigned long val)
4135{
4136 return stac92xx_add_control_temp(spec,
4137 &stac92xx_control_templates[type],
4138 idx, name, val);
4139}
4140
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004141
4142/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004143static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
4144 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004145{
4146 return stac92xx_add_control_idx(spec, type, 0, name, val);
4147}
4148
Takashi Iwai2b635362011-05-02 12:33:43 +02004149static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01004150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4151 .name = "Input Source",
4152 .info = stac92xx_mux_enum_info,
4153 .get = stac92xx_mux_enum_get,
4154 .put = stac92xx_mux_enum_put,
4155};
4156
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004157static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
4158 hda_nid_t nid, int idx)
4159{
4160 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4161 int control = 0;
4162 struct sigmatel_spec *spec = codec->spec;
4163 char name[22];
4164
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004165 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
David Henningsson8d032a82012-10-09 12:48:40 +02004166 if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf)
4167 != INPUT_PIN_ATTR_DOCK)
4168 return 0;
Takashi Iwai47408602012-04-20 13:06:53 +02004169 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004170 && nid == spec->line_switch)
4171 control = STAC_CTL_WIDGET_IO_SWITCH;
4172 else if (snd_hda_query_pin_caps(codec, nid)
4173 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
4174 control = STAC_CTL_WIDGET_DC_BIAS;
4175 else if (nid == spec->mic_switch)
4176 control = STAC_CTL_WIDGET_IO_SWITCH;
4177 }
4178
4179 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01004180 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4181 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004182 return stac92xx_add_control(codec->spec, control,
4183 strcat(name, " Jack Mode"), nid);
4184 }
4185
4186 return 0;
4187}
4188
Takashi Iwaie3c75962009-01-23 11:57:22 +01004189static int stac92xx_add_input_source(struct sigmatel_spec *spec)
4190{
4191 struct snd_kcontrol_new *knew;
4192 struct hda_input_mux *imux = &spec->private_imux;
4193
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004194 if (spec->auto_mic)
4195 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01004196 if (!spec->num_adcs || imux->num_items <= 1)
4197 return 0; /* no need for input source control */
4198 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004199 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01004200 if (!knew)
4201 return -ENOMEM;
4202 knew->count = spec->num_adcs;
4203 return 0;
4204}
4205
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004206/* check whether the line-input can be used as line-out */
4207static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01004208{
4209 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004210 struct auto_pin_cfg *cfg = &spec->autocfg;
4211 hda_nid_t nid;
4212 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004213 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004214
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004215 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4216 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004217 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004218 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004219 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01004220 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004221 if (pincap & AC_PINCAP_OUT)
4222 return nid;
4223 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004224 }
Matt Porter403d1942005-11-29 15:00:51 +01004225 return 0;
4226}
4227
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004228static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
4229
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004230/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004231static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004232{
4233 struct sigmatel_spec *spec = codec->spec;
4234 struct auto_pin_cfg *cfg = &spec->autocfg;
4235 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02004236 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004237
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004238 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004239 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4240 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004241 for (i = 0; i < cfg->num_inputs; i++) {
4242 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02004243 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004244 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004245 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4246 /* some laptops have an internal analog microphone
4247 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004248 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004249 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004250 if (pincap & AC_PINCAP_OUT) {
4251 *dac = get_unassigned_dac(codec, nid);
4252 if (*dac)
4253 return nid;
4254 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004255 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004256 }
4257 return 0;
4258}
Steve Longerbeam7b043892007-05-03 20:50:03 +02004259
4260static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4261{
4262 int i;
4263
4264 for (i = 0; i < spec->multiout.num_dacs; i++) {
4265 if (spec->multiout.dac_nids[i] == nid)
4266 return 1;
4267 }
4268
4269 return 0;
4270}
4271
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004272static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4273{
4274 int i;
4275 if (is_in_dac_nids(spec, nid))
4276 return 1;
4277 for (i = 0; i < spec->autocfg.hp_outs; i++)
4278 if (spec->hp_dacs[i] == nid)
4279 return 1;
4280 for (i = 0; i < spec->autocfg.speaker_outs; i++)
4281 if (spec->speaker_dacs[i] == nid)
4282 return 1;
4283 return 0;
4284}
4285
4286static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
4287{
4288 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02004289 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004290 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02004291 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004292 unsigned int wcaps, wtype;
4293
4294 conn_len = snd_hda_get_connections(codec, nid, conn,
4295 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01004296 /* 92HD88: trace back up the link of nids to find the DAC */
4297 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
4298 != AC_WID_AUD_OUT)) {
4299 nid = conn[0];
4300 conn_len = snd_hda_get_connections(codec, nid, conn,
4301 HDA_MAX_CONNECTIONS);
4302 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004303 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01004304 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004305 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004306 /* we check only analog outputs */
4307 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
4308 continue;
4309 /* if this route has a free DAC, assign it */
4310 if (!check_all_dac_nids(spec, conn[j])) {
4311 if (conn_len > 1) {
4312 /* select this DAC in the pin's input mux */
4313 snd_hda_codec_write_cache(codec, nid, 0,
4314 AC_VERB_SET_CONNECT_SEL, j);
4315 }
4316 return conn[j];
4317 }
4318 }
David Henningsson48718ea2011-10-05 09:49:05 +02004319
4320 /* if all DACs are already assigned, connect to the primary DAC,
4321 unless we're assigning a secondary headphone */
4322 fallback_dac = spec->multiout.dac_nids[0];
4323 if (spec->multiout.hp_nid) {
4324 for (j = 0; j < cfg->hp_outs; j++)
4325 if (cfg->hp_pins[j] == nid) {
4326 fallback_dac = spec->multiout.hp_nid;
4327 break;
4328 }
4329 }
4330
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004331 if (conn_len > 1) {
4332 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02004333 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004334 snd_hda_codec_write_cache(codec, nid, 0,
4335 AC_VERB_SET_CONNECT_SEL, j);
4336 break;
4337 }
4338 }
4339 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004340 return 0;
4341}
4342
4343static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4344static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4345
Matt Porter3cc08dc2006-01-23 15:27:49 +01004346/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02004347 * Fill in the dac_nids table from the parsed pin configuration
4348 * This function only works when every pin in line_out_pins[]
4349 * contains atleast one DAC in its connection list. Some 92xx
4350 * codecs are not connected directly to a DAC, such as the 9200
4351 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01004352 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004353static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02004354{
4355 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004356 struct auto_pin_cfg *cfg = &spec->autocfg;
4357 int i;
4358 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004359
Mattc7d4b2f2005-06-27 14:59:41 +02004360 for (i = 0; i < cfg->line_outs; i++) {
4361 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004362 dac = get_unassigned_dac(codec, nid);
4363 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02004364 if (spec->multiout.num_dacs > 0) {
4365 /* we have already working output pins,
4366 * so let's drop the broken ones again
4367 */
4368 cfg->line_outs = spec->multiout.num_dacs;
4369 break;
4370 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004371 /* error out, no available DAC found */
4372 snd_printk(KERN_ERR
4373 "%s: No available DAC for pin 0x%x\n",
4374 __func__, nid);
4375 return -ENODEV;
4376 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004377 add_spec_dacs(spec, dac);
4378 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004379
Takashi Iwai139e0712009-03-06 12:10:41 +01004380 for (i = 0; i < cfg->hp_outs; i++) {
4381 nid = cfg->hp_pins[i];
4382 dac = get_unassigned_dac(codec, nid);
4383 if (dac) {
4384 if (!spec->multiout.hp_nid)
4385 spec->multiout.hp_nid = dac;
4386 else
4387 add_spec_extra_dacs(spec, dac);
4388 }
4389 spec->hp_dacs[i] = dac;
4390 }
4391
4392 for (i = 0; i < cfg->speaker_outs; i++) {
4393 nid = cfg->speaker_pins[i];
4394 dac = get_unassigned_dac(codec, nid);
4395 if (dac)
4396 add_spec_extra_dacs(spec, dac);
4397 spec->speaker_dacs[i] = dac;
4398 }
4399
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004400 /* add line-in as output */
4401 nid = check_line_out_switch(codec);
4402 if (nid) {
4403 dac = get_unassigned_dac(codec, nid);
4404 if (dac) {
4405 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
4406 nid, cfg->line_outs);
4407 cfg->line_out_pins[cfg->line_outs] = nid;
4408 cfg->line_outs++;
4409 spec->line_switch = nid;
4410 add_spec_dacs(spec, dac);
4411 }
4412 }
4413 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004414 nid = check_mic_out_switch(codec, &dac);
4415 if (nid && dac) {
4416 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
4417 nid, cfg->line_outs);
4418 cfg->line_out_pins[cfg->line_outs] = nid;
4419 cfg->line_outs++;
4420 spec->mic_switch = nid;
4421 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02004422 }
4423
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004424 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02004425 spec->multiout.num_dacs,
4426 spec->multiout.dac_nids[0],
4427 spec->multiout.dac_nids[1],
4428 spec->multiout.dac_nids[2],
4429 spec->multiout.dac_nids[3],
4430 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004431
Mattc7d4b2f2005-06-27 14:59:41 +02004432 return 0;
4433}
4434
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004435/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01004436static int create_controls_idx(struct hda_codec *codec, const char *pfx,
4437 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004438{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004439 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004440 char name[32];
4441 int err;
4442
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004443 if (!spec->check_volume_offset) {
4444 unsigned int caps, step, nums, db_scale;
4445 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4446 step = (caps & AC_AMPCAP_STEP_SIZE) >>
4447 AC_AMPCAP_STEP_SIZE_SHIFT;
4448 step = (step + 1) * 25; /* in .01dB unit */
4449 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
4450 AC_AMPCAP_NUM_STEPS_SHIFT;
4451 db_scale = nums * step;
4452 /* if dB scale is over -64dB, and finer enough,
4453 * let's reduce it to half
4454 */
4455 if (db_scale > 6400 && nums >= 0x1f)
4456 spec->volume_offset = nums / 2;
4457 spec->check_volume_offset = 1;
4458 }
4459
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004460 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004461 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004462 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
4463 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004464 if (err < 0)
4465 return err;
4466 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004467 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004468 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
4469 if (err < 0)
4470 return err;
4471 return 0;
4472}
4473
Takashi Iwai668b9652009-03-06 10:13:24 +01004474#define create_controls(codec, pfx, nid, chs) \
4475 create_controls_idx(codec, pfx, 0, nid, chs)
4476
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004477static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
4478{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004479 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004480 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
4481 return 1;
4482 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02004483 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
4484 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004485 spec->multiout.num_dacs++;
4486 }
4487 return 0;
4488}
4489
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004490static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004491{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004492 int i;
4493 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
4494 if (!spec->multiout.extra_out_nid[i]) {
4495 spec->multiout.extra_out_nid[i] = nid;
4496 return 0;
4497 }
4498 }
4499 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
4500 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004501}
4502
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004503/* Create output controls
4504 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
4505 */
4506static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
4507 const hda_nid_t *pins,
4508 const hda_nid_t *dac_nids,
4509 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02004510{
Takashi Iwai76624532008-12-19 10:09:47 +01004511 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01004512 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02004513 "Front", "Surround", NULL /*CLFE*/, "Side"
4514 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004515 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01004516 int i, err;
4517 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004518
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004519 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004520 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004521 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004522 spec->hp_detect = 1;
4523 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004524 nid = dac_nids[i];
4525 if (!nid)
4526 continue;
4527 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02004528 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004529 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004530 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004531 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004532 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004533 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004534 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004535
4536 wid_caps = get_wcaps(codec, nid);
4537
4538 if (wid_caps & AC_WCAP_LR_SWAP) {
4539 err = stac92xx_add_control(spec,
4540 STAC_CTL_WIDGET_CLFE_SWITCH,
4541 "Swap Center/LFE Playback Switch", nid);
4542
4543 if (err < 0)
4544 return err;
4545 }
4546
Mattc7d4b2f2005-06-27 14:59:41 +02004547 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004548 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01004549 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004550 switch (type) {
4551 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01004552 name = "Headphone";
4553 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004554 break;
4555 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01004556 if (num_outs <= 2) {
4557 name = i ? "Bass Speaker" : "Speaker";
4558 idx = 0;
David Henningsson298efee2012-09-06 11:17:58 +02004559 break;
4560 }
4561 /* Fall through in case of multi speaker outs */
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004562 default:
4563 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01004564 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004565 break;
Takashi Iwai76624532008-12-19 10:09:47 +01004566 }
Takashi Iwai668b9652009-03-06 10:13:24 +01004567 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004568 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004569 return err;
4570 }
4571 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004572 return 0;
4573}
4574
Takashi Iwai62cbde12012-09-14 11:58:54 +02004575static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4576 unsigned int dir_mask, unsigned int data);
4577
4578/* hook for controlling mic-mute LED GPIO */
4579static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol,
4580 struct snd_ctl_elem_value *ucontrol)
4581{
4582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4583 struct sigmatel_spec *spec = codec->spec;
4584 int err;
4585 bool mute;
4586
4587 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4588 if (err <= 0)
4589 return err;
4590 mute = !(ucontrol->value.integer.value[0] &&
4591 ucontrol->value.integer.value[1]);
4592 if (spec->mic_mute_led_on != mute) {
4593 spec->mic_mute_led_on = mute;
4594 if (mute)
4595 spec->gpio_data |= spec->mic_mute_led_gpio;
4596 else
4597 spec->gpio_data &= ~spec->mic_mute_led_gpio;
4598 stac_gpio_set(codec, spec->gpio_mask,
4599 spec->gpio_dir, spec->gpio_data);
4600 }
4601 return err;
4602}
4603
Takashi Iwai6479c632009-07-28 18:20:25 +02004604static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
4605 unsigned long sw, int idx)
4606{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004607 struct sigmatel_spec *spec = codec->spec;
4608 struct snd_kcontrol_new *knew;
Takashi Iwai6479c632009-07-28 18:20:25 +02004609 int err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004610
Takashi Iwai6479c632009-07-28 18:20:25 +02004611 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02004612 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02004613 if (err < 0)
4614 return err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004615
4616 knew = add_control_temp(spec,
4617 &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE],
4618 idx, "Capture Switch", sw);
4619 if (!knew)
4620 return -ENOMEM;
4621 /* add a LED hook for some HP laptops */
4622 if (spec->mic_mute_led_gpio)
4623 knew->put = stac92xx_capture_sw_put_led;
4624
Takashi Iwai6479c632009-07-28 18:20:25 +02004625 return 0;
4626}
4627
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004628/* add playback controls from the parsed DAC table */
4629static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
4630 const struct auto_pin_cfg *cfg)
4631{
4632 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004633 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004634 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004635 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004636
4637 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
4638 spec->multiout.dac_nids,
4639 cfg->line_out_type);
4640 if (err < 0)
4641 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004642
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01004643 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004644 err = stac92xx_add_control(spec,
4645 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01004646 "Headphone as Line Out Switch",
4647 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004648 if (err < 0)
4649 return err;
4650 }
4651
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004652 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004653 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004654 break;
4655 nid = cfg->inputs[idx].pin;
4656 err = stac92xx_add_jack_mode_control(codec, nid, idx);
4657 if (err < 0)
4658 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01004659 }
Matt Porter403d1942005-11-29 15:00:51 +01004660
Mattc7d4b2f2005-06-27 14:59:41 +02004661 return 0;
4662}
4663
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004664/* add playback controls for Speaker and HP outputs */
4665static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
4666 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02004667{
4668 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004669 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02004670
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004671 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
4672 spec->hp_dacs, AUTO_PIN_HP_OUT);
4673 if (err < 0)
4674 return err;
4675
4676 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
4677 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
4678 if (err < 0)
4679 return err;
4680
Mattc7d4b2f2005-06-27 14:59:41 +02004681 return 0;
4682}
4683
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004684/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004685static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004686 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004687};
4688
4689/* create mono mux for mono out on capable codecs */
4690static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
4691{
4692 struct sigmatel_spec *spec = codec->spec;
4693 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
4694 int i, num_cons;
4695 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
4696
4697 num_cons = snd_hda_get_connections(codec,
4698 spec->mono_nid,
4699 con_lst,
4700 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004701 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004702 return -EINVAL;
4703
Takashi Iwai10a20af2010-09-09 16:28:02 +02004704 for (i = 0; i < num_cons; i++)
4705 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
4706 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004707
4708 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
4709 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004710}
4711
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004712/* create PC beep volume controls */
4713static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
4714 hda_nid_t nid)
4715{
4716 struct sigmatel_spec *spec = codec->spec;
4717 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004718 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
4719
4720 if (spec->anabeep_nid == nid)
4721 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004722
4723 /* check for mute support for the the amp */
4724 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004725 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004726 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004727 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4728 if (err < 0)
4729 return err;
4730 }
4731
4732 /* check to see if there is volume support for the amp */
4733 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4734 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004735 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004736 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4737 if (err < 0)
4738 return err;
4739 }
4740 return 0;
4741}
4742
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004743#ifdef CONFIG_SND_HDA_INPUT_BEEP
4744#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
4745
4746static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
4747 struct snd_ctl_elem_value *ucontrol)
4748{
4749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4750 ucontrol->value.integer.value[0] = codec->beep->enabled;
4751 return 0;
4752}
4753
4754static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
4755 struct snd_ctl_elem_value *ucontrol)
4756{
4757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004758 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004759}
4760
Takashi Iwai2b635362011-05-02 12:33:43 +02004761static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004762 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4763 .info = stac92xx_dig_beep_switch_info,
4764 .get = stac92xx_dig_beep_switch_get,
4765 .put = stac92xx_dig_beep_switch_put,
4766};
4767
4768static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
4769{
4770 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004771 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004772}
4773#endif
4774
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004775static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
4776{
4777 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02004778 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004779
4780 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004781 hda_nid_t nid;
4782 unsigned int wcaps;
4783 unsigned long val;
4784
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004785 nid = spec->mux_nids[i];
4786 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02004787 if (!(wcaps & AC_WCAP_OUT_AMP))
4788 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004789
Takashi Iwai667067d2009-08-13 18:14:42 +02004790 /* check whether already the same control was created as
4791 * normal Capture Volume.
4792 */
4793 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4794 for (j = 0; j < spec->num_caps; j++) {
4795 if (spec->capvols[j] == val)
4796 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004797 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004798 if (j < spec->num_caps)
4799 continue;
4800
4801 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
4802 "Mux Capture Volume", val);
4803 if (err < 0)
4804 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004805 }
4806 return 0;
4807};
4808
Takashi Iwaiea734962011-01-17 11:29:34 +01004809static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04004810 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02004811};
4812
4813static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
4814{
4815 struct sigmatel_spec *spec = codec->spec;
4816 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01004817 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004818 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04004819 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02004820
4821 num_cons = snd_hda_get_connections(codec,
4822 spec->smux_nids[0],
4823 con_lst,
4824 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004825 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02004826 return -EINVAL;
4827
Matthew Ranostay65973632008-09-16 10:39:37 -04004828 if (!labels)
4829 labels = stac92xx_spdif_labels;
4830
Takashi Iwai10a20af2010-09-09 16:28:02 +02004831 for (i = 0; i < num_cons; i++)
4832 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004833
4834 return 0;
4835}
4836
Matt Porter8b657272006-10-26 17:12:59 +02004837/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004838static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02004839 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
4840 "Digital Mic 3", "Digital Mic 4"
4841};
4842
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004843static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
4844 int idx)
4845{
4846 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4847 int nums;
4848 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
4849 if (idx >= 0 && idx < nums)
4850 return conn[idx];
4851 return 0;
4852}
4853
Takashi Iwai8d087c72011-06-28 12:45:47 +02004854/* look for NID recursively */
4855#define get_connection_index(codec, mux, nid) \
4856 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004857
Takashi Iwai667067d2009-08-13 18:14:42 +02004858/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02004859/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02004860static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004861 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02004862{
4863 unsigned int caps, nums;
4864 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02004865 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02004866
Takashi Iwai96f845d2009-08-29 00:49:36 +02004867 if (direction == HDA_OUTPUT)
4868 caps = AC_WCAP_OUT_AMP;
4869 else
4870 caps = AC_WCAP_IN_AMP;
4871 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02004872 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004873 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02004874 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
4875 if (!nums)
4876 return 0;
4877 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004878 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
4879 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02004880 if (err < 0)
4881 return err;
4882 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02004883}
4884
Matt Porter8b657272006-10-26 17:12:59 +02004885/* create playback/capture controls for input pins on dmic capable codecs */
4886static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
4887 const struct auto_pin_cfg *cfg)
4888{
4889 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02004890 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004891 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004892 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02004893 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02004894
Takashi Iwai10a20af2010-09-09 16:28:02 +02004895 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02004896
Matt Porter8b657272006-10-26 17:12:59 +02004897 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01004898 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004899 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01004900 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02004901
Takashi Iwai667067d2009-08-13 18:14:42 +02004902 nid = spec->dmic_nids[i];
4903 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
4904 continue;
4905 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02004906 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
4907 continue;
4908
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004909 index = get_connection_index(codec, spec->dmux_nids[0], nid);
4910 if (index < 0)
4911 continue;
4912
Takashi Iwai201e06f2011-11-16 15:33:26 +01004913 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4914 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02004915 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01004916 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
4917 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02004918
Takashi Iwai10a20af2010-09-09 16:28:02 +02004919 err = create_elem_capture_vol(codec, nid, label, type_idx,
4920 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004921 if (err < 0)
4922 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004923 if (!err) {
4924 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02004925 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02004926 if (err < 0)
4927 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004928 if (!err) {
4929 nid = get_connected_node(codec,
4930 spec->dmux_nids[0], index);
4931 if (nid)
4932 err = create_elem_capture_vol(codec,
4933 nid, label,
4934 type_idx, HDA_INPUT);
4935 if (err < 0)
4936 return err;
4937 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02004938 }
Matt Porter8b657272006-10-26 17:12:59 +02004939 }
4940
4941 return 0;
4942}
4943
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004944static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02004945 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004946{
4947 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004948 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004949
4950 if (!nid)
4951 return 0;
4952 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004953 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004954 switch (snd_hda_get_input_pin_attr(cfg)) {
4955 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004956 if (*fixed)
4957 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004958 if (type != AC_JACK_MIC_IN)
4959 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004960 *fixed = nid;
4961 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004962 case INPUT_PIN_ATTR_UNUSED:
4963 break;
4964 case INPUT_PIN_ATTR_DOCK:
4965 if (*dock)
4966 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004967 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
4968 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004969 *dock = nid;
4970 break;
4971 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004972 if (*ext)
4973 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004974 if (type != AC_JACK_MIC_IN)
4975 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004976 *ext = nid;
4977 break;
4978 }
4979 return 0;
4980}
4981
4982static int set_mic_route(struct hda_codec *codec,
4983 struct sigmatel_mic_route *mic,
4984 hda_nid_t pin)
4985{
4986 struct sigmatel_spec *spec = codec->spec;
4987 struct auto_pin_cfg *cfg = &spec->autocfg;
4988 int i;
4989
4990 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02004991 if (pin == 0)
4992 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004993 for (i = 0; i < cfg->num_inputs; i++) {
4994 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004995 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004996 }
Takashi Iwai86e29592010-09-09 14:50:17 +02004997 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004998 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004999 i = get_connection_index(codec, spec->mux_nids[0], pin);
5000 if (i < 0)
5001 return -1;
5002 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02005003 mic->dmux_idx = -1;
5004 if (spec->dmux_nids)
5005 mic->dmux_idx = get_connection_index(codec,
5006 spec->dmux_nids[0],
5007 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005008 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005009 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005010 i = get_connection_index(codec, spec->dmux_nids[0], pin);
5011 if (i < 0)
5012 return -1;
5013 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02005014 mic->mux_idx = -1;
5015 if (spec->mux_nids)
5016 mic->mux_idx = get_connection_index(codec,
5017 spec->mux_nids[0],
5018 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005019 }
5020 return 0;
5021}
5022
5023/* return non-zero if the device is for automatic mic switch */
5024static int stac_check_auto_mic(struct hda_codec *codec)
5025{
5026 struct sigmatel_spec *spec = codec->spec;
5027 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02005028 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005029 int i;
5030
Charles Chin99077902010-09-17 10:22:32 +02005031 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005032 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02005033 if (check_mic_pin(codec, cfg->inputs[i].pin,
5034 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005035 return 0;
5036 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02005037 if (check_mic_pin(codec, spec->dmic_nids[i],
5038 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005039 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01005040 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02005041 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005042 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005043 return 0; /* no unsol support */
5044 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02005045 set_mic_route(codec, &spec->int_mic, fixed) ||
5046 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005047 return 0; /* something is wrong */
5048 return 1;
5049}
5050
Mattc7d4b2f2005-06-27 14:59:41 +02005051/* create playback/capture controls for input pins */
5052static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
5053{
5054 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005055 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02005056 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005057 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02005058
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005059 for (i = 0; i < cfg->num_inputs; i++) {
5060 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005061 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02005062
Takashi Iwai314634b2006-09-21 11:56:18 +02005063 index = -1;
5064 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02005065 index = get_connection_index(codec, spec->mux_nids[j],
5066 nid);
5067 if (index >= 0)
5068 break;
Mattc7d4b2f2005-06-27 14:59:41 +02005069 }
Takashi Iwai667067d2009-08-13 18:14:42 +02005070 if (index < 0)
5071 continue;
5072
Takashi Iwai10a20af2010-09-09 16:28:02 +02005073 label = hda_get_autocfg_input_label(codec, cfg, i);
5074 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005075
Takashi Iwai667067d2009-08-13 18:14:42 +02005076 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005077 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02005078 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02005079 if (err < 0)
5080 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02005081 }
Takashi Iwai5207e102009-07-30 13:09:08 +02005082 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02005083
Steve Longerbeam7b043892007-05-03 20:50:03 +02005084 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02005085 /*
5086 * Set the current input for the muxes.
5087 * The STAC9221 has two input muxes with identical source
5088 * NID lists. Hopefully this won't get confused.
5089 */
5090 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005091 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
5092 AC_VERB_SET_CONNECT_SEL,
5093 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005094 }
5095 }
5096
Mattc7d4b2f2005-06-27 14:59:41 +02005097 return 0;
5098}
5099
Mattc7d4b2f2005-06-27 14:59:41 +02005100static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
5101{
5102 struct sigmatel_spec *spec = codec->spec;
5103 int i;
5104
5105 for (i = 0; i < spec->autocfg.line_outs; i++) {
5106 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5107 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
5108 }
5109}
5110
5111static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
5112{
5113 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005114 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005115
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005116 for (i = 0; i < spec->autocfg.hp_outs; i++) {
5117 hda_nid_t pin;
5118 pin = spec->autocfg.hp_pins[i];
5119 if (pin) /* connect to front */
5120 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5121 }
5122 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
5123 hda_nid_t pin;
5124 pin = spec->autocfg.speaker_pins[i];
5125 if (pin) /* connect to front */
5126 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
5127 }
Mattc7d4b2f2005-06-27 14:59:41 +02005128}
5129
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01005130static int is_dual_headphones(struct hda_codec *codec)
5131{
5132 struct sigmatel_spec *spec = codec->spec;
5133 int i, valid_hps;
5134
5135 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
5136 spec->autocfg.hp_outs <= 1)
5137 return 0;
5138 valid_hps = 0;
5139 for (i = 0; i < spec->autocfg.hp_outs; i++) {
5140 hda_nid_t nid = spec->autocfg.hp_pins[i];
5141 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
5142 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
5143 continue;
5144 valid_hps++;
5145 }
5146 return (valid_hps > 1);
5147}
5148
5149
Charles Chin9009b0e2011-11-03 10:27:27 +01005150static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02005151{
5152 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01005153 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005154 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02005155 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02005156
Matt Porter8b657272006-10-26 17:12:59 +02005157 if ((err = snd_hda_parse_pin_def_config(codec,
5158 &spec->autocfg,
5159 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005160 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005161 if (! spec->autocfg.line_outs)
Takashi Iwaif6655d52013-01-17 08:49:01 +01005162 return -EINVAL; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02005163
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005164 /* If we have no real line-out pin and multiple hp-outs, HPs should
5165 * be set up as multi-channel outputs.
5166 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01005167 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005168 /* Copy hp_outs to line_outs, backup line_outs in
5169 * speaker_outs so that the following routines can handle
5170 * HP pins as primary outputs.
5171 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005172 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005173 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
5174 sizeof(spec->autocfg.line_out_pins));
5175 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
5176 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
5177 sizeof(spec->autocfg.hp_pins));
5178 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005179 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5180 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005181 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005182 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005183 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005184 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
5185 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005186 u32 caps = query_amp_caps(codec,
5187 spec->autocfg.mono_out_pin, dir);
5188 hda_nid_t conn_list[1];
5189
5190 /* get the mixer node and then the mono mux if it exists */
5191 if (snd_hda_get_connections(codec,
5192 spec->autocfg.mono_out_pin, conn_list, 1) &&
5193 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02005194 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01005195
5196 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02005197 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005198 /* LR swap check, some stac925x have a mux that
5199 * changes the DACs output path instead of the
5200 * mono-mux path.
5201 */
5202 if (wid_type == AC_WID_AUD_SEL &&
5203 !(wcaps & AC_WCAP_LR_SWAP))
5204 spec->mono_nid = conn_list[0];
5205 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005206 if (dir) {
5207 hda_nid_t nid = spec->autocfg.mono_out_pin;
5208
5209 /* most mono outs have a least a mute/unmute switch */
5210 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
5211 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
5212 "Mono Playback Switch",
5213 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01005214 if (err < 0)
5215 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005216 /* check for volume support for the amp */
5217 if ((caps & AC_AMPCAP_NUM_STEPS)
5218 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
5219 err = stac92xx_add_control(spec,
5220 STAC_CTL_WIDGET_VOL,
5221 "Mono Playback Volume",
5222 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
5223 if (err < 0)
5224 return err;
5225 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005226 }
5227
5228 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
5229 AC_PINCTL_OUT_EN);
5230 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005231
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005232 if (!spec->multiout.num_dacs) {
5233 err = stac92xx_auto_fill_dac_nids(codec);
5234 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02005235 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01005236 err = stac92xx_auto_create_multi_out_ctls(codec,
5237 &spec->autocfg);
5238 if (err < 0)
5239 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005240 }
Mattc7d4b2f2005-06-27 14:59:41 +02005241
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005242 /* setup analog beep controls */
5243 if (spec->anabeep_nid > 0) {
5244 err = stac92xx_auto_create_beep_ctls(codec,
5245 spec->anabeep_nid);
5246 if (err < 0)
5247 return err;
5248 }
5249
5250 /* setup digital beep controls and input device */
5251#ifdef CONFIG_SND_HDA_INPUT_BEEP
5252 if (spec->digbeep_nid > 0) {
5253 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005254 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005255
5256 err = stac92xx_auto_create_beep_ctls(codec, nid);
5257 if (err < 0)
5258 return err;
5259 err = snd_hda_attach_beep_device(codec, nid);
5260 if (err < 0)
5261 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005262 if (codec->beep) {
5263 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005264 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005265 /* if no beep switch is available, make its own one */
5266 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
5267 if (!(caps & AC_AMPCAP_MUTE)) {
5268 err = stac92xx_beep_switch_ctl(codec);
5269 if (err < 0)
5270 return err;
5271 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005272 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005273 }
5274#endif
5275
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005276 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005277 if (err < 0)
5278 return err;
5279
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005280 /* All output parsing done, now restore the swapped hp pins */
5281 if (hp_swap) {
5282 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
5283 sizeof(spec->autocfg.hp_pins));
5284 spec->autocfg.hp_outs = spec->autocfg.line_outs;
5285 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5286 spec->autocfg.line_outs = 0;
5287 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005288
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005289 if (stac_check_auto_mic(codec)) {
5290 spec->auto_mic = 1;
5291 /* only one capture for auto-mic */
5292 spec->num_adcs = 1;
5293 spec->num_caps = 1;
5294 spec->num_muxes = 1;
5295 }
5296
Takashi Iwai6479c632009-07-28 18:20:25 +02005297 for (i = 0; i < spec->num_caps; i++) {
5298 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
5299 spec->capsws[i], i);
5300 if (err < 0)
5301 return err;
5302 }
5303
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005304 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005305 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005306 return err;
5307
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005308 if (spec->mono_nid > 0) {
5309 err = stac92xx_auto_create_mono_output_ctls(codec);
5310 if (err < 0)
5311 return err;
5312 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005313 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02005314 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
5315 &spec->autocfg)) < 0)
5316 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02005317 if (spec->num_muxes > 0) {
5318 err = stac92xx_auto_create_mux_input_ctls(codec);
5319 if (err < 0)
5320 return err;
5321 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02005322 if (spec->num_smuxes > 0) {
5323 err = stac92xx_auto_create_spdif_mux_ctls(codec);
5324 if (err < 0)
5325 return err;
5326 }
Matt Porter8b657272006-10-26 17:12:59 +02005327
Takashi Iwaie3c75962009-01-23 11:57:22 +01005328 err = stac92xx_add_input_source(spec);
5329 if (err < 0)
5330 return err;
5331
Mattc7d4b2f2005-06-27 14:59:41 +02005332 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01005333 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02005334 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02005335
Charles Chin9009b0e2011-11-03 10:27:27 +01005336 /* find digital out and in converters */
5337 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
5338 unsigned int wid_caps = get_wcaps(codec, i);
5339 if (wid_caps & AC_WCAP_DIGITAL) {
5340 switch (get_wcaps_type(wid_caps)) {
5341 case AC_WID_AUD_OUT:
5342 if (!dig_out)
5343 dig_out = i;
5344 break;
5345 case AC_WID_AUD_IN:
5346 if (!dig_in)
5347 dig_in = i;
5348 break;
5349 }
5350 }
5351 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005352 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005353 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005354 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005355 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02005356
Takashi Iwai603c4012008-07-30 15:01:44 +02005357 if (spec->kctls.list)
5358 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005359
5360 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05005361 if (!spec->dinput_mux)
5362 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005363 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005364 spec->mono_mux = &spec->private_mono_mux;
Takashi Iwaif6655d52013-01-17 08:49:01 +01005365 return 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005366}
5367
Takashi Iwai82bc9552006-03-21 11:24:42 +01005368/* add playback controls for HP output */
5369static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
5370 struct auto_pin_cfg *cfg)
5371{
5372 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005373 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01005374
5375 if (! pin)
5376 return 0;
5377
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005378 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01005379 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005380
5381 return 0;
5382}
5383
Richard Fish160ea0d2006-09-06 13:58:25 +02005384/* add playback controls for LFE output */
5385static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
5386 struct auto_pin_cfg *cfg)
5387{
5388 struct sigmatel_spec *spec = codec->spec;
5389 int err;
5390 hda_nid_t lfe_pin = 0x0;
5391 int i;
5392
5393 /*
5394 * search speaker outs and line outs for a mono speaker pin
5395 * with an amp. If one is found, add LFE controls
5396 * for it.
5397 */
5398 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
5399 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005400 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005401 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5402 if (wcaps == AC_WCAP_OUT_AMP)
5403 /* found a mono speaker with an amp, must be lfe */
5404 lfe_pin = pin;
5405 }
5406
5407 /* if speaker_outs is 0, then speakers may be in line_outs */
5408 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
5409 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
5410 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005411 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01005412 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01005413 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005414 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005415 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5416 if (wcaps == AC_WCAP_OUT_AMP)
5417 /* found a mono speaker with an amp,
5418 must be lfe */
5419 lfe_pin = pin;
5420 }
5421 }
5422 }
5423
5424 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01005425 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02005426 if (err < 0)
5427 return err;
5428 }
5429
5430 return 0;
5431}
5432
Mattc7d4b2f2005-06-27 14:59:41 +02005433static int stac9200_parse_auto_config(struct hda_codec *codec)
5434{
5435 struct sigmatel_spec *spec = codec->spec;
5436 int err;
5437
Kailang Yangdf694da2005-12-05 19:42:22 +01005438 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005439 return err;
5440
5441 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
5442 return err;
5443
Takashi Iwai82bc9552006-03-21 11:24:42 +01005444 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
5445 return err;
5446
Richard Fish160ea0d2006-09-06 13:58:25 +02005447 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
5448 return err;
5449
Takashi Iwai355a0ec2008-11-11 16:46:19 +01005450 if (spec->num_muxes > 0) {
5451 err = stac92xx_auto_create_mux_input_ctls(codec);
5452 if (err < 0)
5453 return err;
5454 }
5455
Takashi Iwaie3c75962009-01-23 11:57:22 +01005456 err = stac92xx_add_input_source(spec);
5457 if (err < 0)
5458 return err;
5459
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005460 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02005461 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005462 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02005463 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02005464
Takashi Iwai603c4012008-07-30 15:01:44 +02005465 if (spec->kctls.list)
5466 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005467
5468 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02005469 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02005470
Takashi Iwaif6655d52013-01-17 08:49:01 +01005471 return 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005472}
5473
Sam Revitch62fe78e2006-05-10 15:09:17 +02005474/*
5475 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
5476 * funky external mute control using GPIO pins.
5477 */
5478
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005479static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005480 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02005481{
5482 unsigned int gpiostate, gpiomask, gpiodir;
5483
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005484 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
5485
Sam Revitch62fe78e2006-05-10 15:09:17 +02005486 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5487 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005488 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005489
5490 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5491 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005492 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005493
5494 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5495 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005496 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005497
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005498 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005499 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
5500
5501 snd_hda_codec_write(codec, codec->afg, 0,
5502 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005503 snd_hda_codec_read(codec, codec->afg, 0,
5504 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005505
5506 msleep(1);
5507
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005508 snd_hda_codec_read(codec, codec->afg, 0,
5509 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005510}
5511
Takashi Iwai3a938972011-10-28 01:16:55 +02005512static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005513 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005514{
Takashi Iwai3a938972011-10-28 01:16:55 +02005515 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005516
Takashi Iwai3a938972011-10-28 01:16:55 +02005517 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005518 if (!event)
5519 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02005520 event->action = type;
5521 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005522
Takashi Iwai3a938972011-10-28 01:16:55 +02005523 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005524}
5525
David Henningsson29adc4b2012-09-25 11:31:00 +02005526static void handle_unsol_event(struct hda_codec *codec,
5527 struct hda_jack_tbl *event);
5528
Takashi Iwai62558ce2009-07-29 14:23:09 +02005529/* check if given nid is a valid pin and no other events are assigned
5530 * to it. If OK, assign the event, set the unsol flag, and returns 1.
5531 * Otherwise, returns zero.
5532 */
5533static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
5534 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02005535{
Takashi Iwai3a938972011-10-28 01:16:55 +02005536 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005537
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005538 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02005539 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02005540 event = snd_hda_jack_tbl_new(codec, nid);
5541 if (!event)
5542 return -ENOMEM;
5543 if (event->action && event->action != type)
5544 return 0;
5545 event->action = type;
David Henningsson29adc4b2012-09-25 11:31:00 +02005546 event->callback = handle_unsol_event;
Takashi Iwai3a938972011-10-28 01:16:55 +02005547 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02005548 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02005549}
5550
Takashi Iwaib4ead012012-01-23 18:23:36 +01005551static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005552{
5553 int i;
5554 for (i = 0; i < cfg->hp_outs; i++)
5555 if (cfg->hp_pins[i] == nid)
5556 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01005557 for (i = 0; i < cfg->line_outs; i++)
5558 if (cfg->line_out_pins[i] == nid)
5559 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005560 return 0; /* nid is not a HP-Out */
5561};
5562
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005563static void stac92xx_power_down(struct hda_codec *codec)
5564{
5565 struct sigmatel_spec *spec = codec->spec;
5566
5567 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02005568 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005569 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005570 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005571 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005572 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5573}
5574
Takashi Iwaif73d3582008-11-25 08:21:51 +01005575static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5576 int enable);
5577
Takashi Iwaibc759722013-01-11 17:40:31 +01005578static inline bool get_int_hint(struct hda_codec *codec, const char *key,
5579 int *valp)
Takashi Iwai014c41f2009-12-27 13:53:24 +01005580{
Takashi Iwaibc759722013-01-11 17:40:31 +01005581 return !snd_hda_get_int_hint(codec, key, valp);
Takashi Iwai014c41f2009-12-27 13:53:24 +01005582}
5583
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005584/* override some hints from the hwdep entry */
5585static void stac_store_hints(struct hda_codec *codec)
5586{
5587 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005588 int val;
5589
5590 val = snd_hda_get_bool_hint(codec, "hp_detect");
5591 if (val >= 0)
5592 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01005593 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005594 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
5595 spec->gpio_mask;
5596 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01005597 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
5598 spec->gpio_mask &= spec->gpio_mask;
5599 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
5600 spec->gpio_dir &= spec->gpio_mask;
5601 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
5602 spec->eapd_mask &= spec->gpio_mask;
5603 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
5604 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005605 val = snd_hda_get_bool_hint(codec, "eapd_switch");
5606 if (val >= 0)
5607 spec->eapd_switch = val;
5608}
5609
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005610static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
5611 const hda_nid_t *pins)
5612{
5613 while (num_pins--)
5614 stac_issue_unsol_event(codec, *pins++);
5615}
5616
5617/* fake event to set up pins */
5618static void stac_fake_hp_events(struct hda_codec *codec)
5619{
5620 struct sigmatel_spec *spec = codec->spec;
5621
5622 if (spec->autocfg.hp_outs)
5623 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
5624 spec->autocfg.hp_pins);
5625 if (spec->autocfg.line_outs &&
5626 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
5627 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
5628 spec->autocfg.line_out_pins);
5629}
5630
Mattc7d4b2f2005-06-27 14:59:41 +02005631static int stac92xx_init(struct hda_codec *codec)
5632{
5633 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005634 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005635 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01005636 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005637
David Henningsson5e68fb32012-08-16 14:11:09 +02005638 if (spec->init)
5639 snd_hda_sequence_write(codec, spec->init);
Mattc7d4b2f2005-06-27 14:59:41 +02005640
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005641 snd_hda_apply_verbs(codec);
5642
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005643 /* power down adcs initially */
5644 if (spec->powerdown_adcs)
5645 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005646 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005647 spec->adc_nids[i], 0,
5648 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005649
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005650 /* override some hints */
5651 stac_store_hints(codec);
5652
Takashi Iwaif73d3582008-11-25 08:21:51 +01005653 /* set up GPIO */
5654 gpio = spec->gpio_data;
5655 /* turn on EAPD statically when spec->eapd_switch isn't set.
5656 * otherwise, unsol event will turn it on/off dynamically
5657 */
5658 if (!spec->eapd_switch)
5659 gpio |= spec->eapd_mask;
5660 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
5661
Takashi Iwai82bc9552006-03-21 11:24:42 +01005662 /* set up pins */
5663 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02005664 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005665 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005666 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005667 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005668 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02005669 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
5670 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005671 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02005672 for (i = 0; i < cfg->line_outs; i++) {
5673 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005674 enable_pin_detect(codec, nid, STAC_LO_EVENT);
5675 }
5676 }
5677
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01005678 /* force to enable the first line-out; the others are set up
5679 * in unsol_event
5680 */
5681 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005682 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005683 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005684 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005685 } else {
5686 stac92xx_auto_init_multi_out(codec);
5687 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005688 for (i = 0; i < cfg->hp_outs; i++)
5689 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005690 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005691 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02005692 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005693 if (spec->dmux_nids)
5694 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02005695 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005696 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
5697 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02005698 if (enable_pin_detect(codec, spec->dock_mic.pin,
5699 STAC_MIC_EVENT))
5700 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005701 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005702 for (i = 0; i < cfg->num_inputs; i++) {
5703 hda_nid_t nid = cfg->inputs[i].pin;
5704 int type = cfg->inputs[i].type;
5705 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02005706 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005707 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02005708 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005709 pinctl |= AC_PINCTL_IN_EN;
5710 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5711 } else {
5712 pinctl = snd_hda_codec_read(codec, nid, 0,
5713 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5714 /* if PINCTL already set then skip */
5715 /* Also, if both INPUT and OUTPUT are set,
5716 * it must be a BIOS bug; need to override, too
5717 */
5718 if (!(pinctl & AC_PINCTL_IN_EN) ||
5719 (pinctl & AC_PINCTL_OUT_EN)) {
5720 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005721 pinctl |= AC_PINCTL_IN_EN;
5722 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01005723 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005724 }
5725 conf = snd_hda_codec_get_pincfg(codec, nid);
5726 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
5727 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
5728 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01005729 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01005730 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005731 for (i = 0; i < spec->num_dmics; i++)
5732 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
5733 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005734 if (cfg->dig_out_pins[0])
5735 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01005736 AC_PINCTL_OUT_EN);
5737 if (cfg->dig_in_pin)
5738 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
5739 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005740 for (i = 0; i < spec->num_pwrs; i++) {
5741 hda_nid_t nid = spec->pwr_nids[i];
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005742 unsigned int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005743
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005744 def_conf = snd_hda_codec_get_pincfg(codec, nid);
5745 def_conf = get_defcfg_connect(def_conf);
5746 if (def_conf == AC_JACK_PORT_NONE) {
5747 /* power off unused ports */
5748 stac_toggle_power_map(codec, nid, 0);
5749 continue;
5750 }
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005751 if (def_conf == AC_JACK_PORT_FIXED) {
5752 /* no need for jack detection for fixed pins */
5753 stac_toggle_power_map(codec, nid, 1);
5754 continue;
5755 }
Takashi Iwaieb632122008-12-19 16:39:48 +01005756 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01005757 /* or when the VREF is used for controlling LED */
5758 if (!spec->hp_detect ||
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005759 spec->vref_mute_led_nid == nid ||
5760 !is_jack_detectable(codec, nid)) {
Takashi Iwaieb632122008-12-19 16:39:48 +01005761 stac_toggle_power_map(codec, nid, 1);
5762 continue;
5763 }
5764
Takashi Iwaib4ead012012-01-23 18:23:36 +01005765 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01005766 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005767
Takashi Iwaif73d3582008-11-25 08:21:51 +01005768 pinctl = snd_hda_codec_read(codec, nid, 0,
5769 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5770 /* outputs are only ports capable of power management
5771 * any attempts on powering down a input port cause the
5772 * referenced VREF to act quirky.
5773 */
Takashi Iwaieb632122008-12-19 16:39:48 +01005774 if (pinctl & AC_PINCTL_IN_EN) {
5775 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005776 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01005777 }
Charles Chinafef2cf2011-11-11 08:05:28 +01005778 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02005779 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01005780 continue;
5781 }
5782 /* none of the above, turn the port OFF */
5783 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005784 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01005785
Takashi Iwaic21bd022010-02-08 15:16:08 +01005786 /* sync mute LED */
Takashi Iwai1f43f6c2012-07-31 10:40:05 +02005787 if (spec->gpio_led) {
5788 if (spec->vmaster_mute.hook)
5789 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5790 else /* the very first init call doesn't have vmaster yet */
5791 stac92xx_update_led_status(codec, false);
5792 }
Takashi Iwaic8822462012-05-15 09:11:36 +02005793
5794 /* sync the power-map */
5795 if (spec->num_pwrs)
5796 snd_hda_codec_write(codec, codec->afg, 0,
5797 AC_VERB_IDT_SET_POWER_MAP,
5798 spec->power_map_bits);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005799 if (spec->dac_list)
5800 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02005801 return 0;
5802}
5803
Takashi Iwai603c4012008-07-30 15:01:44 +02005804static void stac92xx_free_kctls(struct hda_codec *codec)
5805{
5806 struct sigmatel_spec *spec = codec->spec;
5807
5808 if (spec->kctls.list) {
5809 struct snd_kcontrol_new *kctl = spec->kctls.list;
5810 int i;
5811 for (i = 0; i < spec->kctls.used; i++)
5812 kfree(kctl[i].name);
5813 }
5814 snd_array_free(&spec->kctls);
5815}
5816
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005817static void stac92xx_shutup_pins(struct hda_codec *codec)
5818{
5819 unsigned int i, def_conf;
5820
5821 if (codec->bus->shutdown)
5822 return;
5823 for (i = 0; i < codec->init_pins.used; i++) {
5824 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
5825 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
5826 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005827 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005828 }
5829}
5830
Takashi Iwai167eae52009-11-06 15:47:50 +01005831static void stac92xx_shutup(struct hda_codec *codec)
5832{
5833 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01005834
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005835 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01005836
5837 if (spec->eapd_mask)
5838 stac_gpio_set(codec, spec->gpio_mask,
5839 spec->gpio_dir, spec->gpio_data &
5840 ~spec->eapd_mask);
5841}
5842
Matt2f2f4252005-04-13 14:45:30 +02005843static void stac92xx_free(struct hda_codec *codec)
5844{
Mattc7d4b2f2005-06-27 14:59:41 +02005845 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005846
5847 if (! spec)
5848 return;
5849
Mattc7d4b2f2005-06-27 14:59:41 +02005850 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005851 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02005852}
5853
Matt4e550962005-07-04 17:51:39 +02005854static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
5855 unsigned int flag)
5856{
Takashi Iwai8ce84192009-01-22 16:59:20 +01005857 unsigned int old_ctl, pin_ctl;
5858
5859 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02005860 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02005861
Takashi Iwaif9acba42007-05-29 18:01:06 +02005862 if (pin_ctl & AC_PINCTL_IN_EN) {
5863 /*
5864 * we need to check the current set-up direction of
5865 * shared input pins since they can be switched via
5866 * "xxx as Output" mixer switch
5867 */
5868 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005869 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02005870 return;
5871 }
5872
Takashi Iwai8ce84192009-01-22 16:59:20 +01005873 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02005874 /* if setting pin direction bits, clear the current
5875 direction bits first */
5876 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
5877 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
5878
Takashi Iwai8ce84192009-01-22 16:59:20 +01005879 pin_ctl |= flag;
5880 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005881 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02005882}
5883
5884static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
5885 unsigned int flag)
5886{
5887 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
5888 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01005889 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005890 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02005891}
5892
Takashi Iwaid56757a2009-11-18 08:00:14 +01005893static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02005894{
5895 if (!nid)
5896 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01005897 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02005898}
5899
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005900static void stac92xx_line_out_detect(struct hda_codec *codec,
5901 int presence)
5902{
5903 struct sigmatel_spec *spec = codec->spec;
5904 struct auto_pin_cfg *cfg = &spec->autocfg;
5905 int i;
5906
David Henningsson042b92c2012-08-22 16:10:43 +02005907 if (cfg->speaker_outs == 0)
5908 return;
5909
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005910 for (i = 0; i < cfg->line_outs; i++) {
5911 if (presence)
5912 break;
5913 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
5914 if (presence) {
5915 unsigned int pinctl;
5916 pinctl = snd_hda_codec_read(codec,
5917 cfg->line_out_pins[i], 0,
5918 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5919 if (pinctl & AC_PINCTL_IN_EN)
5920 presence = 0; /* mic- or line-input */
5921 }
5922 }
5923
5924 if (presence) {
5925 /* disable speakers */
5926 for (i = 0; i < cfg->speaker_outs; i++)
5927 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
5928 AC_PINCTL_OUT_EN);
5929 if (spec->eapd_mask && spec->eapd_switch)
5930 stac_gpio_set(codec, spec->gpio_mask,
5931 spec->gpio_dir, spec->gpio_data &
5932 ~spec->eapd_mask);
5933 } else {
5934 /* enable speakers */
5935 for (i = 0; i < cfg->speaker_outs; i++)
5936 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
5937 AC_PINCTL_OUT_EN);
5938 if (spec->eapd_mask && spec->eapd_switch)
5939 stac_gpio_set(codec, spec->gpio_mask,
5940 spec->gpio_dir, spec->gpio_data |
5941 spec->eapd_mask);
5942 }
5943}
5944
Takashi Iwaid7a89432008-11-12 09:48:04 +01005945/* return non-zero if the hp-pin of the given array index isn't
5946 * a jack-detection target
5947 */
5948static int no_hp_sensing(struct sigmatel_spec *spec, int i)
5949{
5950 struct auto_pin_cfg *cfg = &spec->autocfg;
5951
5952 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005953 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005954 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005955 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005956 return 1;
5957 /* ignore if the pin is set as line-out */
5958 if (cfg->hp_pins[i] == spec->hp_switch)
5959 return 1;
5960 return 0;
5961}
5962
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005963static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02005964{
5965 struct sigmatel_spec *spec = codec->spec;
5966 struct auto_pin_cfg *cfg = &spec->autocfg;
5967 int i, presence;
5968
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005969 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005970 if (spec->gpio_mute)
5971 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
5972 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
5973
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005974 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005975 if (presence)
5976 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01005977 if (no_hp_sensing(spec, i))
5978 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005979 presence = get_pin_presence(codec, cfg->hp_pins[i]);
5980 if (presence) {
5981 unsigned int pinctl;
5982 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
5983 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5984 if (pinctl & AC_PINCTL_IN_EN)
5985 presence = 0; /* mic- or line-input */
5986 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005987 }
Matt4e550962005-07-04 17:51:39 +02005988
5989 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005990 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005991 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005992 stac92xx_reset_pinctl(codec, spec->hp_switch,
5993 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005994 for (i = 0; i < cfg->line_outs; i++)
5995 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
5996 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005997 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005998 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005999 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01006000 stac92xx_set_pinctl(codec, spec->hp_switch,
6001 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02006002 for (i = 0; i < cfg->line_outs; i++)
6003 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
6004 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02006005 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006006 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01006007 /* toggle hp outs */
6008 for (i = 0; i < cfg->hp_outs; i++) {
6009 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
6010 if (no_hp_sensing(spec, i))
6011 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01006012 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01006013 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01006014#if 0 /* FIXME */
6015/* Resetting the pinctl like below may lead to (a sort of) regressions
6016 * on some devices since they use the HP pin actually for line/speaker
6017 * outs although the default pin config shows a different pin (that is
6018 * wrong and useless).
6019 *
6020 * So, it's basically a problem of default pin configs, likely a BIOS issue.
6021 * But, disabling the code below just works around it, and I'm too tired of
6022 * bug reports with such devices...
6023 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01006024 else
6025 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01006026#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01006027 }
Matt4e550962005-07-04 17:51:39 +02006028}
6029
Takashi Iwaif73d3582008-11-25 08:21:51 +01006030static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
6031 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006032{
6033 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01006034 unsigned int idx, val;
6035
6036 for (idx = 0; idx < spec->num_pwrs; idx++) {
6037 if (spec->pwr_nids[idx] == nid)
6038 break;
6039 }
6040 if (idx >= spec->num_pwrs)
6041 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006042
Charles Chinafef2cf2011-11-11 08:05:28 +01006043 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006044
Takashi Iwaic8822462012-05-15 09:11:36 +02006045 val = spec->power_map_bits;
Takashi Iwaif73d3582008-11-25 08:21:51 +01006046 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006047 val &= ~idx;
6048 else
6049 val |= idx;
6050
6051 /* power down unused output ports */
Takashi Iwaic8822462012-05-15 09:11:36 +02006052 if (val != spec->power_map_bits) {
6053 spec->power_map_bits = val;
6054 snd_hda_codec_write(codec, codec->afg, 0,
6055 AC_VERB_IDT_SET_POWER_MAP, val);
6056 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04006057}
6058
Takashi Iwaif73d3582008-11-25 08:21:51 +01006059static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
6060{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01006061 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01006062}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006063
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006064/* get the pin connection (fixed, none, etc) */
6065static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
6066{
6067 struct sigmatel_spec *spec = codec->spec;
6068 unsigned int cfg;
6069
6070 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
6071 return get_defcfg_connect(cfg);
6072}
6073
6074static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006075 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006076{
6077 struct sigmatel_spec *spec = codec->spec;
6078 int idx, num;
6079 unsigned int def_conf;
6080
6081 for (num = 0; num < num_nids; num++) {
6082 for (idx = 0; idx < spec->num_pins; idx++)
6083 if (spec->pin_nids[idx] == nids[num])
6084 break;
6085 if (idx >= spec->num_pins)
6086 break;
6087 def_conf = stac_get_defcfg_connect(codec, idx);
6088 if (def_conf == AC_JACK_PORT_NONE)
6089 break;
6090 }
6091 return num;
6092}
6093
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006094static void stac92xx_mic_detect(struct hda_codec *codec)
6095{
6096 struct sigmatel_spec *spec = codec->spec;
6097 struct sigmatel_mic_route *mic;
6098
6099 if (get_pin_presence(codec, spec->ext_mic.pin))
6100 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02006101 else if (get_pin_presence(codec, spec->dock_mic.pin))
6102 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006103 else
6104 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02006105 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006106 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
6107 AC_VERB_SET_CONNECT_SEL,
6108 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02006109 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006110 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
6111 AC_VERB_SET_CONNECT_SEL,
6112 mic->mux_idx);
6113}
6114
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006115static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02006116 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02006117{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006118 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006119 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006120
Takashi Iwai3a938972011-10-28 01:16:55 +02006121 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02006122 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006123 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02006124 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006125 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006126 case STAC_MIC_EVENT:
6127 stac92xx_mic_detect(codec);
6128 break;
6129 }
6130
Takashi Iwai3a938972011-10-28 01:16:55 +02006131 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006132 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006133 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006134 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04006135 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006136 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006137 if (spec->num_pwrs > 0)
6138 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04006139
6140 switch (codec->subsystem_id) {
6141 case 0x103c308f:
6142 if (event->nid == 0xb) {
6143 int pin = AC_PINCTL_IN_EN;
6144
6145 if (get_pin_presence(codec, 0xa)
6146 && get_pin_presence(codec, 0xb))
6147 pin |= AC_PINCTL_VREF_80;
6148 if (!get_pin_presence(codec, 0xb))
6149 pin |= AC_PINCTL_VREF_80;
6150
6151 /* toggle VREF state based on mic + hp pin
6152 * status
6153 */
6154 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
6155 }
6156 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04006157 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006158 case STAC_VREF_EVENT:
6159 data = snd_hda_codec_read(codec, codec->afg, 0,
6160 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04006161 /* toggle VREF state based on GPIOx status */
6162 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02006163 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04006164 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02006165 }
6166}
6167
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006168static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
6169{
Takashi Iwai3a938972011-10-28 01:16:55 +02006170 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006171 if (!event)
6172 return;
6173 handle_unsol_event(codec, event);
6174}
6175
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306176static void set_hp_led_gpio(struct hda_codec *codec)
6177{
6178 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01006179 unsigned int gpio;
6180
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02006181 if (spec->gpio_led)
6182 return;
6183
Takashi Iwai07f80442010-02-08 15:06:13 +01006184 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
6185 gpio &= AC_GPIO_IO_COUNT;
6186 if (gpio > 3)
6187 spec->gpio_led = 0x08; /* GPIO 3 */
6188 else
6189 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306190}
6191
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006192/*
6193 * This method searches for the mute LED GPIO configuration
6194 * provided as OEM string in SMBIOS. The format of that string
6195 * is HP_Mute_LED_P_G or HP_Mute_LED_P
6196 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
6197 * that corresponds to the NOT muted state of the master volume
6198 * and G is the index of the GPIO to use as the mute LED control (0..9)
6199 * If _G portion is missing it is assigned based on the codec ID
6200 *
6201 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
6202 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306203 *
6204 *
6205 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
6206 * SMBIOS - at least the ones I have seen do not have them - which include
6207 * my own system (HP Pavilion dv6-1110ax) and my cousin's
6208 * HP Pavilion dv9500t CTO.
6209 * Need more information on whether it is true across the entire series.
6210 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006211 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006212static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006213{
6214 struct sigmatel_spec *spec = codec->spec;
6215 const struct dmi_device *dev = NULL;
6216
Takashi Iwai75609312012-05-14 16:52:00 +02006217 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
6218 get_int_hint(codec, "gpio_led_polarity",
6219 &spec->gpio_led_polarity);
6220 return 1;
6221 }
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006222
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006223 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
6224 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
6225 &spec->gpio_led_polarity,
6226 &spec->gpio_led) == 2) {
6227 unsigned int max_gpio;
6228 max_gpio = snd_hda_param_read(codec, codec->afg,
6229 AC_PAR_GPIO_CAP);
6230 max_gpio &= AC_GPIO_IO_COUNT;
6231 if (spec->gpio_led < max_gpio)
6232 spec->gpio_led = 1 << spec->gpio_led;
6233 else
6234 spec->vref_mute_led_nid = spec->gpio_led;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306235 return 1;
6236 }
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006237 if (sscanf(dev->name, "HP_Mute_LED_%d",
6238 &spec->gpio_led_polarity) == 1) {
6239 set_hp_led_gpio(codec);
6240 return 1;
6241 }
6242 /* BIOS bug: unfilled OEM string */
6243 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
6244 set_hp_led_gpio(codec);
Takashi Iwai8c698fe2013-01-15 11:20:50 +01006245 if (default_polarity >= 0)
6246 spec->gpio_led_polarity = default_polarity;
6247 else
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006248 spec->gpio_led_polarity = 1;
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006249 return 1;
6250 }
6251 }
6252
6253 /*
6254 * Fallback case - if we don't find the DMI strings,
6255 * we statically set the GPIO - if not a B-series system
6256 * and default polarity is provided
6257 */
6258 if (!hp_blike_system(codec->subsystem_id) &&
6259 (default_polarity == 0 || default_polarity == 1)) {
6260 set_hp_led_gpio(codec);
6261 spec->gpio_led_polarity = default_polarity;
6262 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006263 }
6264 return 0;
6265}
6266
6267static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08006268{
6269 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006270 case 0x103c1520:
6271 case 0x103c1521:
6272 case 0x103c1523:
6273 case 0x103c1524:
6274 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006275 case 0x103c1722:
6276 case 0x103c1723:
6277 case 0x103c1724:
6278 case 0x103c1725:
6279 case 0x103c1726:
6280 case 0x103c1727:
6281 case 0x103c1728:
6282 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006283 case 0x103c172a:
6284 case 0x103c172b:
6285 case 0x103c307e:
6286 case 0x103c307f:
6287 case 0x103c3080:
6288 case 0x103c3081:
6289 case 0x103c7007:
6290 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006291 return 1;
6292 }
6293 return 0;
6294}
6295
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006296#ifdef CONFIG_PROC_FS
6297static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
6298 struct hda_codec *codec, hda_nid_t nid)
6299{
6300 if (nid == codec->afg)
6301 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02006302 snd_hda_codec_read(codec, nid, 0,
6303 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006304}
6305
6306static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
6307 struct hda_codec *codec,
6308 unsigned int verb)
6309{
6310 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
6311 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
6312}
6313
6314/* stac92hd71bxx, stac92hd73xx */
6315static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
6316 struct hda_codec *codec, hda_nid_t nid)
6317{
6318 stac92hd_proc_hook(buffer, codec, nid);
6319 if (nid == codec->afg)
6320 analog_loop_proc_hook(buffer, codec, 0xfa0);
6321}
6322
6323static void stac9205_proc_hook(struct snd_info_buffer *buffer,
6324 struct hda_codec *codec, hda_nid_t nid)
6325{
6326 if (nid == codec->afg)
6327 analog_loop_proc_hook(buffer, codec, 0xfe0);
6328}
6329
6330static void stac927x_proc_hook(struct snd_info_buffer *buffer,
6331 struct hda_codec *codec, hda_nid_t nid)
6332{
6333 if (nid == codec->afg)
6334 analog_loop_proc_hook(buffer, codec, 0xfeb);
6335}
6336#else
6337#define stac92hd_proc_hook NULL
6338#define stac92hd7x_proc_hook NULL
6339#define stac9205_proc_hook NULL
6340#define stac927x_proc_hook NULL
6341#endif
6342
Takashi Iwai2a439522011-07-26 09:52:50 +02006343#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02006344static int stac92xx_resume(struct hda_codec *codec)
6345{
Takashi Iwai2c885872008-11-18 09:36:55 +01006346 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006347 snd_hda_codec_resume_amp(codec);
6348 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01006349 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01006350 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02006351 return 0;
6352}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006353
Takashi Iwai68cb2b52012-07-02 15:20:37 +02006354static int stac92xx_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006355{
6356 stac92xx_shutup(codec);
6357 return 0;
6358}
6359
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006360static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
6361 unsigned int power_state)
6362{
6363 unsigned int afg_power_state = power_state;
6364 struct sigmatel_spec *spec = codec->spec;
6365
6366 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006367 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006368 /* with vref-out pin used for mute led control
6369 * codec AFG is prevented from D3 state
6370 */
6371 afg_power_state = AC_PWRST_D1;
6372 }
6373 /* this delay seems necessary to avoid click noise at power-down */
6374 msleep(100);
6375 }
6376 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
6377 afg_power_state);
6378 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
6379}
Takashi Iwai350eba432012-03-16 16:09:03 +01006380#else
6381#define stac92xx_suspend NULL
6382#define stac92xx_resume NULL
Takashi Iwai350eba432012-03-16 16:09:03 +01006383#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006384#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006385
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006386/* update mute-LED accoring to the master switch */
6387static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006388{
6389 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006390 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01006391
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006392 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006393 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006394
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006395 /* LED state is inverted on these systems */
6396 if (spec->gpio_led_polarity)
6397 muted = !muted;
6398
Takashi Iwaif1a73742011-12-04 13:44:06 +01006399 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006400 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02006401 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006402 else
Takashi Iwai3e843192012-04-19 12:04:03 +02006403 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006404 stac_gpio_set(codec, spec->gpio_mask,
6405 spec->gpio_dir, spec->gpio_data);
6406 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006407 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01006408 stac_vrefout_set(codec, spec->vref_mute_led_nid,
6409 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006410 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006411}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05006412
Takashi Iwai2b635362011-05-02 12:33:43 +02006413static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02006414 .build_controls = stac92xx_build_controls,
6415 .build_pcms = stac92xx_build_pcms,
6416 .init = stac92xx_init,
6417 .free = stac92xx_free,
David Henningsson29adc4b2012-09-25 11:31:00 +02006418 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02006419#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006420 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02006421 .resume = stac92xx_resume,
6422#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01006423 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02006424};
6425
Takashi Iwai361dab32012-05-09 14:35:27 +02006426static int alloc_stac_spec(struct hda_codec *codec, int num_pins,
6427 const hda_nid_t *pin_nids)
6428{
6429 struct sigmatel_spec *spec;
6430
6431 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6432 if (!spec)
6433 return -ENOMEM;
6434 codec->spec = spec;
6435 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
6436 spec->num_pins = num_pins;
6437 spec->pin_nids = pin_nids;
6438 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
6439 return 0;
6440}
6441
Matt2f2f4252005-04-13 14:45:30 +02006442static int patch_stac9200(struct hda_codec *codec)
6443{
6444 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006445 int err;
Matt2f2f4252005-04-13 14:45:30 +02006446
Takashi Iwai361dab32012-05-09 14:35:27 +02006447 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids),
6448 stac9200_pin_nids);
6449 if (err < 0)
6450 return err;
Matt2f2f4252005-04-13 14:45:30 +02006451
Takashi Iwai361dab32012-05-09 14:35:27 +02006452 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006453 spec->linear_tone_beep = 1;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006454
6455 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
6456 stac9200_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006457
6458 spec->multiout.max_channels = 2;
6459 spec->multiout.num_dacs = 1;
6460 spec->multiout.dac_nids = stac9200_dac_nids;
6461 spec->adc_nids = stac9200_adc_nids;
6462 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02006463 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02006464 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006465 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006466 spec->num_pwrs = 0;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006467 snd_hda_add_verbs(codec, stac9200_eapd_init);
Mattc7d4b2f2005-06-27 14:59:41 +02006468
Matt2f2f4252005-04-13 14:45:30 +02006469 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02006470
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006471 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai117f2572008-03-18 09:53:23 +01006472
Mattc7d4b2f2005-06-27 14:59:41 +02006473 err = stac9200_parse_auto_config(codec);
6474 if (err < 0) {
6475 stac92xx_free(codec);
6476 return err;
6477 }
Matt2f2f4252005-04-13 14:45:30 +02006478
6479 codec->patch_ops = stac92xx_patch_ops;
6480
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006481 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6482
Matt2f2f4252005-04-13 14:45:30 +02006483 return 0;
6484}
6485
Tobin Davis8e21c342007-01-08 11:04:17 +01006486static int patch_stac925x(struct hda_codec *codec)
6487{
6488 struct sigmatel_spec *spec;
6489 int err;
6490
Takashi Iwai361dab32012-05-09 14:35:27 +02006491 err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids),
6492 stac925x_pin_nids);
6493 if (err < 0)
6494 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01006495
Takashi Iwai361dab32012-05-09 14:35:27 +02006496 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006497 spec->linear_tone_beep = 1;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02006498
Takashi Iwaid2077d42013-01-14 14:20:16 +01006499 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
6500 stac925x_fixups);
Tobin Davis8e21c342007-01-08 11:04:17 +01006501
6502 spec->multiout.max_channels = 2;
6503 spec->multiout.num_dacs = 1;
6504 spec->multiout.dac_nids = stac925x_dac_nids;
6505 spec->adc_nids = stac925x_adc_nids;
6506 spec->mux_nids = stac925x_mux_nids;
6507 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006508 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006509 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02006510 switch (codec->vendor_id) {
6511 case 0x83847632: /* STAC9202 */
6512 case 0x83847633: /* STAC9202D */
6513 case 0x83847636: /* STAC9251 */
6514 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02006515 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02006516 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006517 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
6518 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02006519 break;
6520 default:
6521 spec->num_dmics = 0;
6522 break;
6523 }
Tobin Davis8e21c342007-01-08 11:04:17 +01006524
Takashi Iwaid2077d42013-01-14 14:20:16 +01006525 snd_hda_add_verbs(codec, stac925x_core_init);
Tobin Davis8e21c342007-01-08 11:04:17 +01006526 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02006527 spec->num_caps = 1;
6528 spec->capvols = stac925x_capvols;
6529 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01006530
Takashi Iwaid2077d42013-01-14 14:20:16 +01006531 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6532
Charles Chin9009b0e2011-11-03 10:27:27 +01006533 err = stac92xx_parse_auto_config(codec);
Tobin Davis8e21c342007-01-08 11:04:17 +01006534 if (err < 0) {
6535 stac92xx_free(codec);
6536 return err;
6537 }
6538
6539 codec->patch_ops = stac92xx_patch_ops;
6540
Takashi Iwaid2077d42013-01-14 14:20:16 +01006541 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6542
Tobin Davis8e21c342007-01-08 11:04:17 +01006543 return 0;
6544}
6545
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006546static int patch_stac92hd73xx(struct hda_codec *codec)
6547{
6548 struct sigmatel_spec *spec;
6549 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
Takashi Iwai361dab32012-05-09 14:35:27 +02006550 int err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006551 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006552
Takashi Iwai361dab32012-05-09 14:35:27 +02006553 err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids),
6554 stac92hd73xx_pin_nids);
6555 if (err < 0)
6556 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006557
Takashi Iwai361dab32012-05-09 14:35:27 +02006558 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006559 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02006560 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Takashi Iwai55e30142013-01-14 17:30:04 +01006561
6562 snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl,
6563 stac92hd73xx_fixups);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006564
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006565 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006566 conn, STAC92HD73_DAC_COUNT + 2) - 1;
6567
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006568 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006569 printk(KERN_WARNING "hda_codec: Could not determine "
6570 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006571 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006572 }
Takashi Iwai55e30142013-01-14 17:30:04 +01006573
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006574 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006575 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006576 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006577 break;
6578 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006579 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006580 break;
6581 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006582 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
6583 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006584 }
6585 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006586
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006587 spec->aloopback_mask = 0x01;
6588 spec->aloopback_shift = 8;
6589
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006590 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006591 spec->mux_nids = stac92hd73xx_mux_nids;
6592 spec->adc_nids = stac92hd73xx_adc_nids;
6593 spec->dmic_nids = stac92hd73xx_dmic_nids;
6594 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006595 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006596
6597 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
6598 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01006599 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006600
Takashi Iwai6479c632009-07-28 18:20:25 +02006601 spec->num_caps = STAC92HD73XX_NUM_CAPS;
6602 spec->capvols = stac92hd73xx_capvols;
6603 spec->capsws = stac92hd73xx_capsws;
6604
Takashi Iwai55e30142013-01-14 17:30:04 +01006605 /* GPIO0 High = Enable EAPD */
6606 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6607 spec->gpio_data = 0x01;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006608
Takashi Iwai55e30142013-01-14 17:30:04 +01006609 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6610 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6611 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006612
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006613 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
6614 spec->pwr_nids = stac92hd73xx_pwr_nids;
6615
Takashi Iwai55e30142013-01-14 17:30:04 +01006616 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6617
6618 if (!spec->volknob_init)
6619 snd_hda_add_verbs(codec, stac92hd73xx_core_init);
6620
Charles Chin9009b0e2011-11-03 10:27:27 +01006621 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006622 if (err < 0) {
6623 stac92xx_free(codec);
6624 return err;
6625 }
6626
6627 codec->patch_ops = stac92xx_patch_ops;
6628
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006629 codec->proc_widget_hook = stac92hd7x_proc_hook;
6630
Takashi Iwai55e30142013-01-14 17:30:04 +01006631 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6632
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006633 return 0;
6634}
6635
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006636static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006637{
6638 if (codec->vendor_id != 0x111d7605 &&
6639 codec->vendor_id != 0x111d76d1)
6640 return 0;
6641
6642 switch (codec->subsystem_id) {
6643 case 0x103c1618:
6644 case 0x103c1619:
6645 case 0x103c161a:
6646 case 0x103c161b:
6647 case 0x103c161c:
6648 case 0x103c161d:
6649 case 0x103c161e:
6650 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006651
6652 case 0x103c162a:
6653 case 0x103c162b:
6654
6655 case 0x103c1630:
6656 case 0x103c1631:
6657
6658 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006659 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006660 case 0x103c1635:
6661
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006662 case 0x103c3587:
6663 case 0x103c3588:
6664 case 0x103c3589:
6665 case 0x103c358a:
6666
6667 case 0x103c3667:
6668 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006669 case 0x103c3669:
6670
6671 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006672 }
6673 return 0;
6674}
6675
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006676static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
6677{
6678 struct sigmatel_spec *spec = codec->spec;
6679 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
6680 int i;
6681
6682 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
6683 spec->auto_pin_cnt++;
6684
6685 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
6686 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
6687 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
6688 if (nid == stac92hd83xxx_dmic_nids[i]) {
6689 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
6690 spec->auto_dmic_cnt++;
6691 }
6692 }
6693 }
6694}
6695
6696static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
6697{
6698 struct sigmatel_spec *spec = codec->spec;
6699
6700 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
6701 spec->auto_adc_cnt++;
6702}
6703
6704static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
6705{
6706 int i, j;
6707 struct sigmatel_spec *spec = codec->spec;
6708
6709 for (i = 0; i < spec->auto_adc_cnt; i++) {
6710 if (get_connection_index(codec,
6711 spec->auto_adc_nids[i], nid) >= 0) {
6712 /* mux and volume for adc_nids[i] */
6713 if (!spec->auto_mux_nids[i]) {
6714 spec->auto_mux_nids[i] = nid;
6715 /* 92hd codecs capture volume is in mux */
6716 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
6717 3, 0, HDA_OUTPUT);
6718 }
6719 for (j = 0; j < spec->auto_dmic_cnt; j++) {
6720 if (get_connection_index(codec, nid,
6721 spec->auto_dmic_nids[j]) >= 0) {
6722 /* dmux for adc_nids[i] */
6723 if (!spec->auto_dmux_nids[i])
6724 spec->auto_dmux_nids[i] = nid;
6725 break;
6726 }
6727 }
6728 break;
6729 }
6730 }
6731}
6732
6733static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
6734{
6735 hda_nid_t nid, end_nid;
6736 unsigned int wid_caps, wid_type;
6737 struct sigmatel_spec *spec = codec->spec;
6738
6739 end_nid = codec->start_nid + codec->num_nodes;
6740
6741 for (nid = codec->start_nid; nid < end_nid; nid++) {
6742 wid_caps = get_wcaps(codec, nid);
6743 wid_type = get_wcaps_type(wid_caps);
6744
6745 if (wid_type == AC_WID_PIN)
6746 stac92hd8x_add_pin(codec, nid);
6747
6748 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
6749 stac92hd8x_add_adc(codec, nid);
6750 }
6751
6752 for (nid = codec->start_nid; nid < end_nid; nid++) {
6753 wid_caps = get_wcaps(codec, nid);
6754 wid_type = get_wcaps_type(wid_caps);
6755
6756 if (wid_type == AC_WID_AUD_SEL)
6757 stac92hd8x_add_mux(codec, nid);
6758 }
6759
6760 spec->pin_nids = spec->auto_pin_nids;
6761 spec->num_pins = spec->auto_pin_cnt;
6762 spec->adc_nids = spec->auto_adc_nids;
6763 spec->num_adcs = spec->auto_adc_cnt;
6764 spec->capvols = spec->auto_capvols;
6765 spec->capsws = spec->auto_capvols;
6766 spec->num_caps = spec->auto_adc_cnt;
6767 spec->mux_nids = spec->auto_mux_nids;
6768 spec->num_muxes = spec->auto_adc_cnt;
6769 spec->dmux_nids = spec->auto_dmux_nids;
6770 spec->num_dmuxes = spec->auto_adc_cnt;
6771 spec->dmic_nids = spec->auto_dmic_nids;
6772 spec->num_dmics = spec->auto_dmic_cnt;
6773}
6774
Takashi Iwai372f8c72013-01-14 18:06:34 +01006775static void stac_setup_gpio(struct hda_codec *codec)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006776{
Takashi Iwai372f8c72013-01-14 18:06:34 +01006777 struct sigmatel_spec *spec = codec->spec;
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01006778
Takashi Iwaib4e81872009-11-18 17:20:24 +01006779 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006780 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006781 spec->gpio_mask |= spec->gpio_led;
6782 spec->gpio_dir |= spec->gpio_led;
6783 spec->gpio_data |= spec->gpio_led;
6784 } else {
6785 codec->patch_ops.set_power_state =
6786 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006787 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006788 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006789
Takashi Iwai62cbde12012-09-14 11:58:54 +02006790 if (spec->mic_mute_led_gpio) {
6791 spec->gpio_mask |= spec->mic_mute_led_gpio;
6792 spec->gpio_dir |= spec->mic_mute_led_gpio;
6793 spec->mic_mute_led_on = true;
6794 spec->gpio_data |= spec->mic_mute_led_gpio;
6795 }
Takashi Iwai372f8c72013-01-14 18:06:34 +01006796}
6797
6798static int patch_stac92hd83xxx(struct hda_codec *codec)
6799{
6800 struct sigmatel_spec *spec;
6801 int err;
6802
6803 err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */
6804 if (err < 0)
6805 return err;
6806
6807 codec->epss = 0; /* longer delay needed for D3 */
6808 stac92hd8x_fill_auto_spec(codec);
6809
6810 spec = codec->spec;
6811 spec->linear_tone_beep = 0;
6812 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
6813 spec->digbeep_nid = 0x21;
6814 spec->pwr_nids = stac92hd83xxx_pwr_nids;
6815 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
6816 spec->multiout.dac_nids = spec->dac_nids;
6817
6818 snd_hda_pick_fixup(codec, stac92hd83xxx_models, stac92hd83xxx_fixup_tbl,
6819 stac92hd83xxx_fixups);
6820
6821 snd_hda_add_verbs(codec, stac92hd83xxx_core_init);
6822 spec->default_polarity = -1; /* no default cfg */
6823
6824 codec->patch_ops = stac92xx_patch_ops;
6825
6826 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6827
6828 stac_setup_gpio(codec);
Takashi Iwai62cbde12012-09-14 11:58:54 +02006829
Charles Chin9009b0e2011-11-03 10:27:27 +01006830 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006831 if (err < 0) {
6832 stac92xx_free(codec);
6833 return err;
6834 }
6835
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006836 codec->proc_widget_hook = stac92hd_proc_hook;
6837
Takashi Iwai372f8c72013-01-14 18:06:34 +01006838 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6839
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006840 return 0;
6841}
6842
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006843static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
6844 hda_nid_t dig0pin)
6845{
6846 struct sigmatel_spec *spec = codec->spec;
6847 int idx;
6848
6849 for (idx = 0; idx < spec->num_pins; idx++)
6850 if (spec->pin_nids[idx] == dig0pin)
6851 break;
6852 if ((idx + 2) >= spec->num_pins)
6853 return 0;
6854
6855 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006856 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006857 return 2;
6858
6859 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006860 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006861 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01006862 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006863 return 1;
6864 else
6865 return 0;
6866}
6867
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006868/* HP dv7 bass switch - GPIO5 */
6869#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
6870static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
6871 struct snd_ctl_elem_value *ucontrol)
6872{
6873 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6874 struct sigmatel_spec *spec = codec->spec;
6875 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
6876 return 0;
6877}
6878
6879static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
6880 struct snd_ctl_elem_value *ucontrol)
6881{
6882 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6883 struct sigmatel_spec *spec = codec->spec;
6884 unsigned int gpio_data;
6885
6886 gpio_data = (spec->gpio_data & ~0x20) |
6887 (ucontrol->value.integer.value[0] ? 0x20 : 0);
6888 if (gpio_data == spec->gpio_data)
6889 return 0;
6890 spec->gpio_data = gpio_data;
6891 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
6892 return 1;
6893}
6894
Takashi Iwai2b635362011-05-02 12:33:43 +02006895static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6897 .info = stac_hp_bass_gpio_info,
6898 .get = stac_hp_bass_gpio_get,
6899 .put = stac_hp_bass_gpio_put,
6900};
6901
6902static int stac_add_hp_bass_switch(struct hda_codec *codec)
6903{
6904 struct sigmatel_spec *spec = codec->spec;
6905
6906 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
6907 "Bass Speaker Playback Switch", 0))
6908 return -ENOMEM;
6909
6910 spec->gpio_mask |= 0x20;
6911 spec->gpio_dir |= 0x20;
6912 spec->gpio_data |= 0x20;
6913 return 0;
6914}
6915
Matthew Ranostaye035b842007-11-06 11:53:55 +01006916static int patch_stac92hd71bxx(struct hda_codec *codec)
6917{
6918 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02006919 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Takashi Iwai361dab32012-05-09 14:35:27 +02006920 int err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006921
Takashi Iwai361dab32012-05-09 14:35:27 +02006922 err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS,
6923 stac92hd71bxx_pin_nids_4port);
6924 if (err < 0)
6925 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006926
Takashi Iwai361dab32012-05-09 14:35:27 +02006927 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006928 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006929 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006930 switch (codec->vendor_id) {
6931 case 0x111d76b6:
6932 case 0x111d76b7:
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006933 break;
6934 case 0x111d7603:
6935 case 0x111d7608:
6936 /* On 92HD75Bx 0x27 isn't a pin nid */
6937 spec->num_pins--;
6938 /* fallthrough */
6939 default:
6940 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
6941 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006942 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006943
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006944 snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
6945 stac92hd71bxx_fixups);
6946
6947 /* GPIO0 = EAPD */
6948 spec->gpio_mask = 0x01;
6949 spec->gpio_dir = 0x01;
6950 spec->gpio_data = 0x01;
Takashi Iwai41c3b642008-11-18 10:45:15 +01006951
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006952 spec->dmic_nids = stac92hd71bxx_dmic_nids;
6953 spec->dmux_nids = stac92hd71bxx_dmux_nids;
6954
Takashi Iwai6479c632009-07-28 18:20:25 +02006955 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
6956 spec->capvols = stac92hd71bxx_capvols;
6957 spec->capsws = stac92hd71bxx_capsws;
6958
Matthew Ranostay541eee82007-12-14 12:08:04 +01006959 switch (codec->vendor_id) {
6960 case 0x111d76b6: /* 4 Port without Analog Mixer */
6961 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02006962 unmute_init++;
6963 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006964 case 0x111d76b4: /* 6 Port without Analog Mixer */
6965 case 0x111d76b5:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006966 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006967 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006968 stac92hd71bxx_dmic_nids,
6969 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01006970 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006971 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006972 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006973 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006974 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006975
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006976 /* disable VSW */
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006977 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01006978 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
6979 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02006980 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006981 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006982 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006983 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006984 break;
6985 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006986 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006987 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006988
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006989 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006990 default:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006991 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006992 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006993 stac92hd71bxx_dmic_nids,
6994 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02006995 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01006996 }
6997
David Henningsson5e68fb32012-08-16 14:11:09 +02006998 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006999 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
David Henningsson5e68fb32012-08-16 14:11:09 +02007000
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05007001 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
7002 snd_hda_sequence_write_cache(codec, unmute_init);
7003
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007004 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04007005 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01007006 spec->aloopback_shift = 0;
7007
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02007008 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007009 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007010 spec->mux_nids = stac92hd71bxx_mux_nids;
7011 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02007012 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007013 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007014
7015 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
7016 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02007017 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05007018 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01007019
Takashi Iwaif6655d52013-01-17 08:49:01 +01007020 spec->multiout.dac_nids = spec->dac_nids;
7021 spec->default_polarity = 1;
7022
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007023 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01007024
Takashi Iwai372f8c72013-01-14 18:06:34 +01007025 stac_setup_gpio(codec);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04007026
Charles Chin9009b0e2011-11-03 10:27:27 +01007027 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01007028 if (err < 0) {
7029 stac92xx_free(codec);
7030 return err;
7031 }
7032
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007033 codec->proc_widget_hook = stac92hd7x_proc_hook;
7034
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007035 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7036
Matthew Ranostaye035b842007-11-06 11:53:55 +01007037 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02007038}
Matthew Ranostaye035b842007-11-06 11:53:55 +01007039
Matt2f2f4252005-04-13 14:45:30 +02007040static int patch_stac922x(struct hda_codec *codec)
7041{
7042 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02007043 int err;
Matt2f2f4252005-04-13 14:45:30 +02007044
Takashi Iwai361dab32012-05-09 14:35:27 +02007045 err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids),
7046 stac922x_pin_nids);
7047 if (err < 0)
7048 return err;
Matt2f2f4252005-04-13 14:45:30 +02007049
Takashi Iwai361dab32012-05-09 14:35:27 +02007050 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007051 spec->linear_tone_beep = 1;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02007052
Takashi Iwai0a427842013-01-14 15:20:13 +01007053 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
7054 stac922x_fixups);
Matt2f2f4252005-04-13 14:45:30 +02007055
Matt2f2f4252005-04-13 14:45:30 +02007056 spec->adc_nids = stac922x_adc_nids;
7057 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007058 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007059 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007060 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007061 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02007062
Takashi Iwai6479c632009-07-28 18:20:25 +02007063 spec->num_caps = STAC922X_NUM_CAPS;
7064 spec->capvols = stac922x_capvols;
7065 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02007066
7067 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02007068
Takashi Iwai0a427842013-01-14 15:20:13 +01007069 snd_hda_add_verbs(codec, stac922x_core_init);
7070
7071 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7072
Charles Chin9009b0e2011-11-03 10:27:27 +01007073 err = stac92xx_parse_auto_config(codec);
Matt Porter3cc08dc2006-01-23 15:27:49 +01007074 if (err < 0) {
7075 stac92xx_free(codec);
7076 return err;
7077 }
7078
7079 codec->patch_ops = stac92xx_patch_ops;
7080
Takashi Iwai807a46362007-05-29 19:01:37 +02007081 /* Fix Mux capture level; max to 2 */
7082 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
7083 (0 << AC_AMPCAP_OFFSET_SHIFT) |
7084 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
7085 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
7086 (0 << AC_AMPCAP_MUTE_SHIFT));
7087
Takashi Iwai0a427842013-01-14 15:20:13 +01007088 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7089
Matt Porter3cc08dc2006-01-23 15:27:49 +01007090 return 0;
7091}
7092
7093static int patch_stac927x(struct hda_codec *codec)
7094{
7095 struct sigmatel_spec *spec;
7096 int err;
7097
Takashi Iwai361dab32012-05-09 14:35:27 +02007098 err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids),
7099 stac927x_pin_nids);
7100 if (err < 0)
7101 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007102
Takashi Iwai361dab32012-05-09 14:35:27 +02007103 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007104 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05007105 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwai29ac8362013-01-14 16:03:38 +01007106
7107 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
7108 stac927x_fixups);
Matt Porter3cc08dc2006-01-23 15:27:49 +01007109
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007110 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007111 spec->adc_nids = stac927x_adc_nids;
7112 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
7113 spec->mux_nids = stac927x_mux_nids;
7114 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007115 spec->smux_nids = stac927x_smux_nids;
7116 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04007117 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01007118 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007119 spec->multiout.dac_nids = spec->dac_nids;
7120
Takashi Iwai29ac8362013-01-14 16:03:38 +01007121 /* GPIO0 High = Enable EAPD */
7122 spec->eapd_mask = spec->gpio_mask = 0x01;
7123 spec->gpio_dir = spec->gpio_data = 0x01;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02007124
Takashi Iwai29ac8362013-01-14 16:03:38 +01007125 spec->num_dmics = 0;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007126
Takashi Iwai6479c632009-07-28 18:20:25 +02007127 spec->num_caps = STAC927X_NUM_CAPS;
7128 spec->capvols = stac927x_capvols;
7129 spec->capsws = stac927x_capsws;
7130
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007131 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007132 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007133 spec->aloopback_mask = 0x40;
7134 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05007135 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007136
Takashi Iwaif6655d52013-01-17 08:49:01 +01007137 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7138
Takashi Iwai29ac8362013-01-14 16:03:38 +01007139 if (!spec->volknob_init)
7140 snd_hda_add_verbs(codec, stac927x_core_init);
7141
Charles Chin9009b0e2011-11-03 10:27:27 +01007142 err = stac92xx_parse_auto_config(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02007143 if (err < 0) {
7144 stac92xx_free(codec);
7145 return err;
7146 }
Matt2f2f4252005-04-13 14:45:30 +02007147
7148 codec->patch_ops = stac92xx_patch_ops;
7149
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007150 codec->proc_widget_hook = stac927x_proc_hook;
7151
Takashi Iwai52987652008-01-16 16:09:47 +01007152 /*
7153 * !!FIXME!!
7154 * The STAC927x seem to require fairly long delays for certain
7155 * command sequences. With too short delays (even if the answer
7156 * is set to RIRB properly), it results in the silence output
7157 * on some hardwares like Dell.
7158 *
7159 * The below flag enables the longer delay (see get_response
7160 * in hda_intel.c).
7161 */
7162 codec->bus->needs_damn_long_delay = 1;
7163
Takashi Iwai29ac8362013-01-14 16:03:38 +01007164 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwaie28d8322008-12-17 13:48:29 +01007165
Matt2f2f4252005-04-13 14:45:30 +02007166 return 0;
7167}
7168
Matt Porterf3302a52006-07-31 12:49:34 +02007169static int patch_stac9205(struct hda_codec *codec)
7170{
7171 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02007172 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02007173
Takashi Iwai361dab32012-05-09 14:35:27 +02007174 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids),
7175 stac9205_pin_nids);
7176 if (err < 0)
7177 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02007178
Takashi Iwai361dab32012-05-09 14:35:27 +02007179 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007180 spec->linear_tone_beep = 1;
Takashi Iwaife6322c2013-01-14 14:46:51 +01007181
7182 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
7183 stac9205_fixups);
Matt Porterf3302a52006-07-31 12:49:34 +02007184
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007185 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02007186 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007187 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02007188 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007189 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007190 spec->smux_nids = stac9205_smux_nids;
7191 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007192 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02007193 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007194 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01007195 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007196 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007197
Takashi Iwaife6322c2013-01-14 14:46:51 +01007198 snd_hda_add_verbs(codec, stac9205_core_init);
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007199 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02007200
Takashi Iwai6479c632009-07-28 18:20:25 +02007201 spec->num_caps = STAC9205_NUM_CAPS;
7202 spec->capvols = stac9205_capvols;
7203 spec->capsws = stac9205_capsws;
7204
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007205 spec->aloopback_mask = 0x40;
7206 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007207 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02007208
Takashi Iwaife6322c2013-01-14 14:46:51 +01007209 /* GPIO0 High = EAPD */
7210 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
7211 spec->gpio_data = 0x01;
Matt Porter33382402006-12-18 13:17:28 +01007212
Takashi Iwaife6322c2013-01-14 14:46:51 +01007213 /* Turn on/off EAPD per HP plugging */
7214 spec->eapd_switch = 1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01007215
Takashi Iwaife6322c2013-01-14 14:46:51 +01007216 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Matthew Ranostay87d48362007-07-17 11:52:24 +02007217
Charles Chin9009b0e2011-11-03 10:27:27 +01007218 err = stac92xx_parse_auto_config(codec);
Matt Porterf3302a52006-07-31 12:49:34 +02007219 if (err < 0) {
7220 stac92xx_free(codec);
7221 return err;
7222 }
7223
7224 codec->patch_ops = stac92xx_patch_ops;
7225
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007226 codec->proc_widget_hook = stac9205_proc_hook;
7227
Takashi Iwaife6322c2013-01-14 14:46:51 +01007228 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7229
Matt Porterf3302a52006-07-31 12:49:34 +02007230 return 0;
7231}
7232
Matt2f2f4252005-04-13 14:45:30 +02007233/*
Guillaume Munch6d859062006-08-22 17:15:47 +02007234 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01007235 */
7236
Takashi Iwai2b635362011-05-02 12:33:43 +02007237static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02007238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01007239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
7240 {}
7241};
7242
Takashi Iwai2b635362011-05-02 12:33:43 +02007243static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007244 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
7245 0x11, 0x13, 0x14,
7246};
7247
Takashi Iwai2b635362011-05-02 12:33:43 +02007248static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007249 0x8 /*,0x6*/
7250};
7251
Takashi Iwai2b635362011-05-02 12:33:43 +02007252static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007253 0x15
7254};
7255
Takashi Iwai2b635362011-05-02 12:33:43 +02007256static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02007257 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7258};
7259#define stac9872_capsws stac9872_capvols
7260
Takashi Iwaifc268c12013-01-14 14:29:36 +01007261static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
7262 { 0x0a, 0x03211020 },
7263 { 0x0b, 0x411111f0 },
7264 { 0x0c, 0x411111f0 },
7265 { 0x0d, 0x03a15030 },
7266 { 0x0e, 0x411111f0 },
7267 { 0x0f, 0x90170110 },
7268 { 0x11, 0x411111f0 },
7269 { 0x13, 0x411111f0 },
7270 { 0x14, 0x90a7013e },
7271 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007272};
7273
Takashi Iwaifc268c12013-01-14 14:29:36 +01007274static const struct hda_model_fixup stac9872_models[] = {
7275 { .id = STAC_9872_VAIO, .name = "vaio" },
7276 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007277};
7278
Takashi Iwaifc268c12013-01-14 14:29:36 +01007279static const struct hda_fixup stac9872_fixups[] = {
7280 [STAC_9872_VAIO] = {
7281 .type = HDA_FIXUP_PINS,
7282 .v.pins = stac9872_vaio_pin_configs,
7283 },
Takashi Iwai307282c2009-03-12 18:17:58 +01007284};
7285
Takashi Iwaifc268c12013-01-14 14:29:36 +01007286static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02007287 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
7288 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01007289 {} /* terminator */
7290};
7291
Guillaume Munch6d859062006-08-22 17:15:47 +02007292static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01007293{
7294 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01007295 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01007296
Takashi Iwai361dab32012-05-09 14:35:27 +02007297 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids),
7298 stac9872_pin_nids);
7299 if (err < 0)
7300 return err;
7301
7302 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007303 spec->linear_tone_beep = 1;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007304
Takashi Iwaifc268c12013-01-14 14:29:36 +01007305 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
7306 stac9872_fixups);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007307
Takashi Iwai1e137f92009-01-21 07:41:22 +01007308 spec->multiout.dac_nids = spec->dac_nids;
7309 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
7310 spec->adc_nids = stac9872_adc_nids;
7311 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
7312 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02007313 spec->num_caps = 1;
7314 spec->capvols = stac9872_capvols;
7315 spec->capsws = stac9872_capsws;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007316 snd_hda_add_verbs(codec, stac9872_core_init);
7317
7318 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007319
Charles Chin9009b0e2011-11-03 10:27:27 +01007320 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01007321 if (err < 0) {
7322 stac92xx_free(codec);
7323 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007324 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01007325 spec->input_mux = &spec->private_imux;
7326 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007327
7328 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7329
Takashi Iwaidb064e52006-03-16 16:04:58 +01007330 return 0;
7331}
7332
7333
7334/*
Matt2f2f4252005-04-13 14:45:30 +02007335 * patch entries
7336 */
Takashi Iwai2b635362011-05-02 12:33:43 +02007337static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02007338 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
7339 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
7340 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
7341 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
7342 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
7343 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
7344 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02007345 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
7346 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
7347 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
7348 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
7349 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
7350 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01007351 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
7352 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
7353 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
7354 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
7355 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
7356 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
7357 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
7358 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
7359 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
7360 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01007361 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
7362 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
7363 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
7364 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
7365 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
7366 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02007367 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
7368 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02007369 /* The following does not take into account .id=0x83847661 when subsys =
7370 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
7371 * currently not fully supported.
7372 */
7373 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
7374 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
7375 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01007376 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02007377 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
7378 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
7379 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
7380 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
7381 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
7382 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
7383 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
7384 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007385 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007386 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01007387 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007388 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04007389 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02007390 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
7391 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01007392 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
7393 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
7394 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
7395 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007396 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01007397 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
7398 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007399 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01007400 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7401 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7402 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7403 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7404 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7405 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7406 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7407 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02007408 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
7409 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
7410 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
7411 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
7412 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
7413 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
7414 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
7415 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
7416 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
7417 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
7418 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
7419 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
7420 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
7421 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
7422 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02007423 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007424 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06007425 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
7426 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007427 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01007428 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
7429 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
7430 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
7431 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
7432 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
7433 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
7434 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
7435 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
7436 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
7437 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
7438 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
7439 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02007440 {} /* terminator */
7441};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01007442
7443MODULE_ALIAS("snd-hda-codec-id:8384*");
7444MODULE_ALIAS("snd-hda-codec-id:111d*");
7445
7446MODULE_LICENSE("GPL");
7447MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
7448
7449static struct hda_codec_preset_list sigmatel_list = {
7450 .preset = snd_hda_preset_sigmatel,
7451 .owner = THIS_MODULE,
7452};
7453
7454static int __init patch_sigmatel_init(void)
7455{
7456 return snd_hda_add_codec_preset(&sigmatel_list);
7457}
7458
7459static void __exit patch_sigmatel_exit(void)
7460{
7461 snd_hda_delete_codec_preset(&sigmatel_list);
7462}
7463
7464module_init(patch_sigmatel_init)
7465module_exit(patch_sigmatel_exit)