blob: 3cb44c1b395a2306bb5cee18eeeb4b4054999d9b [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 {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010094 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020095 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050096 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050097 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010098 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -050099 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -0600100 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600101 STAC_HP_ZEPHYR,
Takashi Iwaia3e19972012-07-26 08:17:20 +0200102 STAC_92HD83XXX_HP_LED,
Takashi Iwaiff8a1e22012-07-31 10:16:59 +0200103 STAC_92HD83XXX_HP_INV_LED,
Takashi Iwai62cbde12012-09-14 11:58:54 +0200104 STAC_92HD83XXX_HP_MIC_LED,
David Henningsson8d032a82012-10-09 12:48:40 +0200105 STAC_92HD83XXX_HEADSET_JACK,
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
Matt Porter403d1942005-11-29 15:00:51 +0100190 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500191 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200192 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100193 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100194 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400195 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100196 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200197 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100198 unsigned int linear_tone_beep:1;
David Henningsson8d032a82012-10-09 12:48:40 +0200199 unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
Takashi Iwai29ac8362013-01-14 16:03:38 +0100200 unsigned int volknob_init:1; /* special volume-knob initialization */
Mattc7d4b2f2005-06-27 14:59:41 +0200201
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100202 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200203 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100204 unsigned int gpio_mask;
205 unsigned int gpio_dir;
206 unsigned int gpio_data;
207 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200208 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100209 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100210 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500211 unsigned int vref_led;
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);
598static int hp_blike_system(u32 subsystem_id);
599static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity);
600
Matt Porter8b657272006-10-26 17:12:59 +0200601static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
602 struct snd_ctl_elem_info *uinfo)
603{
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 struct sigmatel_spec *spec = codec->spec;
606 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
607}
608
609static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
610 struct snd_ctl_elem_value *ucontrol)
611{
612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
613 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100614 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200615
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100616 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200617 return 0;
618}
619
620static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
621 struct snd_ctl_elem_value *ucontrol)
622{
623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
624 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100625 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200626
627 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100628 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200629}
630
Matthew Ranostayd9737752008-09-07 12:03:41 +0200631static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_info *uinfo)
633{
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 struct sigmatel_spec *spec = codec->spec;
636 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
637}
638
639static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
641{
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 struct sigmatel_spec *spec = codec->spec;
644 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
645
646 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
647 return 0;
648}
649
650static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
652{
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400655 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200656 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400657 int err, val;
658 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200659
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400660 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200661 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400662 if (err < 0)
663 return err;
664
665 if (spec->spdif_mute) {
666 if (smux_idx == 0)
667 nid = spec->multiout.dig_out_nid;
668 else
669 nid = codec->slave_dig_outs[smux_idx - 1];
670 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100671 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400672 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100673 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400674 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100675 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
676 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400677 }
678 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200679}
680
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500681static int stac_vrefout_set(struct hda_codec *codec,
682 hda_nid_t nid, unsigned int new_vref)
683{
684 int error, pinctl;
685
686 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
687 pinctl = snd_hda_codec_read(codec, nid, 0,
688 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
689
690 if (pinctl < 0)
691 return pinctl;
692
693 pinctl &= 0xff;
694 pinctl &= ~AC_PINCTL_VREFEN;
695 pinctl |= (new_vref & AC_PINCTL_VREFEN);
696
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200697 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500698 if (error < 0)
699 return error;
700
701 return 1;
702}
703
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200704static unsigned int stac92xx_vref_set(struct hda_codec *codec,
705 hda_nid_t nid, unsigned int new_vref)
706{
Takashi Iwaib8621512009-06-22 08:00:10 +0200707 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200708 unsigned int pincfg;
709 pincfg = snd_hda_codec_read(codec, nid, 0,
710 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
711
712 pincfg &= 0xff;
713 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
714 pincfg |= new_vref;
715
716 if (new_vref == AC_PINCTL_VREF_HIZ)
717 pincfg |= AC_PINCTL_OUT_EN;
718 else
719 pincfg |= AC_PINCTL_IN_EN;
720
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200721 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200722 if (error < 0)
723 return error;
724 else
725 return 1;
726}
727
728static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
729{
730 unsigned int vref;
731 vref = snd_hda_codec_read(codec, nid, 0,
732 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
733 vref &= AC_PINCTL_VREFEN;
734 return vref;
735}
736
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100737static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200738{
739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
740 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200741 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200742}
743
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100744static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200745{
746 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
747 struct sigmatel_spec *spec = codec->spec;
748 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
749
750 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
751 return 0;
752}
753
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100754static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200755{
756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
757 struct sigmatel_spec *spec = codec->spec;
758 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200759 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600760 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200761
Takashi Iwai5207e102009-07-30 13:09:08 +0200762 idx = ucontrol->value.enumerated.item[0];
763 if (idx >= imux->num_items)
764 idx = imux->num_items - 1;
765 prev_idx = spec->cur_mux[adc_idx];
766 if (prev_idx == idx)
767 return 0;
768 if (idx < spec->num_analog_muxes) {
769 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
770 AC_VERB_SET_CONNECT_SEL,
771 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600772 if (prev_idx >= spec->num_analog_muxes &&
773 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200774 imux = spec->dinput_mux;
775 /* 0 = analog */
776 snd_hda_codec_write_cache(codec,
777 spec->dmux_nids[adc_idx], 0,
778 AC_VERB_SET_CONNECT_SEL,
779 imux->items[0].index);
780 }
781 } else {
782 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600783 /* first dimux item is hardcoded to select analog imux,
784 * so lets skip it
785 */
786 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200787 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
788 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600789 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200790 }
791 spec->cur_mux[adc_idx] = idx;
792 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200793}
794
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100795static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
796 struct snd_ctl_elem_info *uinfo)
797{
798 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
799 struct sigmatel_spec *spec = codec->spec;
800 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
801}
802
803static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
804 struct snd_ctl_elem_value *ucontrol)
805{
806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
807 struct sigmatel_spec *spec = codec->spec;
808
809 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
810 return 0;
811}
812
813static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
814 struct snd_ctl_elem_value *ucontrol)
815{
816 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
817 struct sigmatel_spec *spec = codec->spec;
818
819 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
820 spec->mono_nid, &spec->cur_mmux);
821}
822
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200823#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
824
825static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
826 struct snd_ctl_elem_value *ucontrol)
827{
828 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100829 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200830 struct sigmatel_spec *spec = codec->spec;
831
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100832 ucontrol->value.integer.value[0] = !!(spec->aloopback &
833 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200834 return 0;
835}
836
837static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
838 struct snd_ctl_elem_value *ucontrol)
839{
840 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
841 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100842 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200843 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100844 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200845
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100846 idx_val = spec->aloopback_mask << idx;
847 if (ucontrol->value.integer.value[0])
848 val = spec->aloopback | idx_val;
849 else
850 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100851 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200852 return 0;
853
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100854 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200855
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100856 /* Only return the bits defined by the shift value of the
857 * first two bytes of the mask
858 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200859 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100860 kcontrol->private_value & 0xFFFF, 0x0);
861 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200862
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100863 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200864 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100865 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200866 } else {
867 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100868 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200869 }
870
871 snd_hda_codec_write_cache(codec, codec->afg, 0,
872 kcontrol->private_value >> 16, dac_mode);
873
874 return 1;
875}
876
Takashi Iwai2b635362011-05-02 12:33:43 +0200877static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200878 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200879 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200880 {}
881};
882
Takashi Iwai2b635362011-05-02 12:33:43 +0200883static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200884 /* set dac0mux for dac converter */
885 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
886 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
887 {}
888};
889
Takashi Iwai2b635362011-05-02 12:33:43 +0200890static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100891 /* set master volume to max value without distortion
892 * and direct control */
893 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100894 {}
895};
896
Takashi Iwai2b635362011-05-02 12:33:43 +0200897static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100898 /* set master volume and direct control */
899 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100900 {}
901};
902
Takashi Iwai2b635362011-05-02 12:33:43 +0200903static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200904 /* power state controls amps */
905 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200906 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200907};
908
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600909static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
910 { 0x22, 0x785, 0x43 },
911 { 0x22, 0x782, 0xe0 },
912 { 0x22, 0x795, 0x00 },
913 {}
914};
915
Takashi Iwai2b635362011-05-02 12:33:43 +0200916static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100917 /* set master volume and direct control */
918 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200919 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100920};
921
Takashi Iwai2b635362011-05-02 12:33:43 +0200922static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500923 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
924 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100925 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
926 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100927 {}
928};
929
Takashi Iwai2b635362011-05-02 12:33:43 +0200930static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100931 /* set dac0mux for dac converter */
932 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100933 /* mute the master volume */
934 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100935 {}
936};
937
Takashi Iwai2b635362011-05-02 12:33:43 +0200938static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200939 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200940 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200941 {}
942};
943
Takashi Iwai2b635362011-05-02 12:33:43 +0200944static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200945 /* unmute node 0x1b */
946 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
947 /* select node 0x03 as DAC */
948 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
949 {}
950};
951
Takashi Iwai2b635362011-05-02 12:33:43 +0200952static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200953 /* don't set delta bit */
954 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
955 /* unmute node 0x1b */
956 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
957 /* select node 0x03 as DAC */
958 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
959 {}
960};
961
Takashi Iwai2b635362011-05-02 12:33:43 +0200962static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100963 /* set master volume and direct control */
964 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200965 /* enable analog pc beep path */
966 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100967 {}
968};
969
Takashi Iwai2b635362011-05-02 12:33:43 +0200970static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200971 /* don't set delta bit */
972 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
973 /* enable analog pc beep path */
974 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
975 {}
976};
977
Takashi Iwai2b635362011-05-02 12:33:43 +0200978static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200979 /* set master volume and direct control */
980 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200981 /* enable analog pc beep path */
982 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200983 {}
984};
985
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100986#define STAC_MONO_MUX \
987 { \
988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
989 .name = "Mono Mux", \
990 .count = 1, \
991 .info = stac92xx_mono_mux_enum_info, \
992 .get = stac92xx_mono_mux_enum_get, \
993 .put = stac92xx_mono_mux_enum_put, \
994 }
995
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100996#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200997 { \
998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
999 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001000 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001001 .info = stac92xx_aloopback_info, \
1002 .get = stac92xx_aloopback_get, \
1003 .put = stac92xx_aloopback_put, \
1004 .private_value = verb_read | (verb_write << 16), \
1005 }
1006
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001007#define DC_BIAS(xname, idx, nid) \
1008 { \
1009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1010 .name = xname, \
1011 .index = idx, \
1012 .info = stac92xx_dc_bias_info, \
1013 .get = stac92xx_dc_bias_get, \
1014 .put = stac92xx_dc_bias_put, \
1015 .private_value = nid, \
1016 }
1017
Takashi Iwai2b635362011-05-02 12:33:43 +02001018static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001019 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001021 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001023 { } /* end */
1024};
1025
Takashi Iwai2b635362011-05-02 12:33:43 +02001026static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1028 {}
1029};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001030
Takashi Iwai2b635362011-05-02 12:33:43 +02001031static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001032 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1033 {}
1034};
1035
Takashi Iwai2b635362011-05-02 12:33:43 +02001036static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001037 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1038 {}
1039};
1040
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001041
Takashi Iwai2b635362011-05-02 12:33:43 +02001042static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001043 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1044};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001045
Takashi Iwai2b635362011-05-02 12:33:43 +02001046static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001047 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1048 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001049 { } /* end */
1050};
1051
Takashi Iwai2b635362011-05-02 12:33:43 +02001052static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001053 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1054 {}
1055};
1056
Takashi Iwai2b635362011-05-02 12:33:43 +02001057static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001058 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1059 {}
1060};
1061
Takashi Iwai1697055e2007-12-18 18:05:52 +01001062static struct snd_kcontrol_new stac_dmux_mixer = {
1063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1064 .name = "Digital Input Source",
1065 /* count set later */
1066 .info = stac92xx_dmux_enum_info,
1067 .get = stac92xx_dmux_enum_get,
1068 .put = stac92xx_dmux_enum_put,
1069};
1070
Matthew Ranostayd9737752008-09-07 12:03:41 +02001071static struct snd_kcontrol_new stac_smux_mixer = {
1072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001073 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001074 /* count set later */
1075 .info = stac92xx_smux_enum_info,
1076 .get = stac92xx_smux_enum_get,
1077 .put = stac92xx_smux_enum_put,
1078};
1079
Takashi Iwai9322ca52012-02-03 14:28:01 +01001080static const char * const slave_pfxs[] = {
1081 "Front", "Surround", "Center", "LFE", "Side",
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01001082 "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001083 NULL
1084};
1085
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001086static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1087
1088static void stac92xx_vmaster_hook(void *private_data, int val)
1089{
1090 stac92xx_update_led_status(private_data, val);
1091}
1092
Takashi Iwai603c4012008-07-30 15:01:44 +02001093static void stac92xx_free_kctls(struct hda_codec *codec);
1094
Matt2f2f4252005-04-13 14:45:30 +02001095static int stac92xx_build_controls(struct hda_codec *codec)
1096{
1097 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001098 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001099 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001100 int i;
Matt2f2f4252005-04-13 14:45:30 +02001101
Takashi Iwai6479c632009-07-28 18:20:25 +02001102 if (spec->mixer) {
1103 err = snd_hda_add_new_ctls(codec, spec->mixer);
1104 if (err < 0)
1105 return err;
1106 }
Mattc7d4b2f2005-06-27 14:59:41 +02001107
1108 for (i = 0; i < spec->num_mixers; i++) {
1109 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1110 if (err < 0)
1111 return err;
1112 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001113 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1114 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001115 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001116 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001117 snd_ctl_new1(&stac_dmux_mixer, codec));
1118 if (err < 0)
1119 return err;
1120 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001121 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001122 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1123 struct hda_input_mux *smux = &spec->private_smux;
1124 /* check for mute support on SPDIF out */
1125 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001126 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001127 spec->spdif_mute = 1;
1128 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001129 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001130 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001131 snd_ctl_new1(&stac_smux_mixer, codec));
1132 if (err < 0)
1133 return err;
1134 }
Mattc7d4b2f2005-06-27 14:59:41 +02001135
Mattdabbed62005-06-14 10:19:34 +02001136 if (spec->multiout.dig_out_nid) {
Takashi Iwaidcda5802012-10-12 17:24:51 +02001137 err = snd_hda_create_dig_out_ctls(codec,
1138 spec->multiout.dig_out_nid,
1139 spec->multiout.dig_out_nid,
1140 spec->autocfg.dig_out_type[0]);
Mattdabbed62005-06-14 10:19:34 +02001141 if (err < 0)
1142 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001143 err = snd_hda_create_spdif_share_sw(codec,
1144 &spec->multiout);
1145 if (err < 0)
1146 return err;
1147 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001148 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001149 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001150 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1151 if (err < 0)
1152 return err;
1153 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001154
1155 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001156 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1157 HDA_OUTPUT, vmaster_tlv);
1158 /* correct volume offset */
1159 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1160 /* minimum value is actually mute */
1161 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1162 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1163 vmaster_tlv, slave_pfxs,
1164 "Playback Volume");
1165 if (err < 0)
1166 return err;
1167
1168 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1169 NULL, slave_pfxs,
1170 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001171 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001172 if (err < 0)
1173 return err;
1174
1175 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001176 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001177 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001178 if (err < 0)
1179 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001180 }
1181
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001182 if (spec->aloopback_ctl &&
1183 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1184 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1185 if (err < 0)
1186 return err;
1187 }
1188
Takashi Iwai603c4012008-07-30 15:01:44 +02001189 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001190
Takashi Iwai01a61e12011-10-28 00:03:22 +02001191 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1192 if (err < 0)
1193 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001194
Mattdabbed62005-06-14 10:19:34 +02001195 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001196}
1197
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001198static const struct hda_pintbl ref9200_pin_configs[] = {
1199 { 0x08, 0x01c47010 },
1200 { 0x09, 0x01447010 },
1201 { 0x0d, 0x0221401f },
1202 { 0x0e, 0x01114010 },
1203 { 0x0f, 0x02a19020 },
1204 { 0x10, 0x01a19021 },
1205 { 0x11, 0x90100140 },
1206 { 0x12, 0x01813122 },
1207 {}
Matt2f2f4252005-04-13 14:45:30 +02001208};
1209
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001210static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1211 { 0x08, 0x400000fe },
1212 { 0x09, 0x404500f4 },
1213 { 0x0d, 0x400100f0 },
1214 { 0x0e, 0x90110010 },
1215 { 0x0f, 0x400100f1 },
1216 { 0x10, 0x02a1902e },
1217 { 0x11, 0x500000f2 },
1218 { 0x12, 0x500000f3 },
1219 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001220};
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001221
1222static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1223 { 0x08, 0x400000fe },
1224 { 0x09, 0x404500f4 },
1225 { 0x0d, 0x400100f0 },
1226 { 0x0e, 0x90110010 },
1227 { 0x0f, 0x400100f1 },
1228 { 0x10, 0x02a1902e },
1229 { 0x11, 0x500000f2 },
1230 { 0x12, 0x500000f3 },
1231 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001232};
1233
1234/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001235 STAC 9200 pin configs for
1236 102801A8
1237 102801DE
1238 102801E8
1239*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001240static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1241 { 0x08, 0x400001f0 },
1242 { 0x09, 0x400001f1 },
1243 { 0x0d, 0x02214030 },
1244 { 0x0e, 0x01014010 },
1245 { 0x0f, 0x02a19020 },
1246 { 0x10, 0x01a19021 },
1247 { 0x11, 0x90100140 },
1248 { 0x12, 0x01813122 },
1249 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001250};
1251
1252/*
1253 STAC 9200 pin configs for
1254 102801C0
1255 102801C1
1256*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001257static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1258 { 0x08, 0x400001f0 },
1259 { 0x09, 0x400001f1 },
1260 { 0x0d, 0x0221401f },
1261 { 0x0e, 0x01014010 },
1262 { 0x0f, 0x01813020 },
1263 { 0x10, 0x02a19021 },
1264 { 0x11, 0x90100140 },
1265 { 0x12, 0x400001f2 },
1266 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001267};
1268
1269/*
1270 STAC 9200 pin configs for
1271 102801C4 (Dell Dimension E310)
1272 102801C5
1273 102801C7
1274 102801D9
1275 102801DA
1276 102801E3
1277*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001278static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1279 { 0x08, 0x400001f0 },
1280 { 0x09, 0x400001f1 },
1281 { 0x0d, 0x0221401f },
1282 { 0x0e, 0x01014010 },
1283 { 0x0f, 0x01813020 },
1284 { 0x10, 0x01a19021 },
1285 { 0x11, 0x90100140 },
1286 { 0x12, 0x400001f2 },
1287 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001288};
1289
1290
1291/*
1292 STAC 9200-32 pin configs for
1293 102801B5 (Dell Inspiron 630m)
1294 102801D8 (Dell Inspiron 640m)
1295*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001296static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1297 { 0x08, 0x40c003fa },
1298 { 0x09, 0x03441340 },
1299 { 0x0d, 0x0321121f },
1300 { 0x0e, 0x90170310 },
1301 { 0x0f, 0x408003fb },
1302 { 0x10, 0x03a11020 },
1303 { 0x11, 0x401003fc },
1304 { 0x12, 0x403003fd },
1305 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001306};
1307
1308/*
1309 STAC 9200-32 pin configs for
1310 102801C2 (Dell Latitude D620)
1311 102801C8
1312 102801CC (Dell Latitude D820)
1313 102801D4
1314 102801D6
1315*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001316static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1317 { 0x08, 0x40c003fa },
1318 { 0x09, 0x0144131f },
1319 { 0x0d, 0x0321121f },
1320 { 0x0e, 0x90170310 },
1321 { 0x0f, 0x90a70321 },
1322 { 0x10, 0x03a11020 },
1323 { 0x11, 0x401003fb },
1324 { 0x12, 0x40f000fc },
1325 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001326};
1327
1328/*
1329 STAC 9200-32 pin configs for
1330 102801CE (Dell XPS M1710)
1331 102801CF (Dell Precision M90)
1332*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001333static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1334 { 0x08, 0x40c003fa },
1335 { 0x09, 0x01441340 },
1336 { 0x0d, 0x0421421f },
1337 { 0x0e, 0x90170310 },
1338 { 0x0f, 0x408003fb },
1339 { 0x10, 0x04a1102e },
1340 { 0x11, 0x90170311 },
1341 { 0x12, 0x403003fc },
1342 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001343};
1344
1345/*
1346 STAC 9200-32 pin configs for
1347 102801C9
1348 102801CA
1349 102801CB (Dell Latitude 120L)
1350 102801D3
1351*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001352static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1353 { 0x08, 0x40c003fa },
1354 { 0x09, 0x404003fb },
1355 { 0x0d, 0x0321121f },
1356 { 0x0e, 0x90170310 },
1357 { 0x0f, 0x408003fc },
1358 { 0x10, 0x03a11020 },
1359 { 0x11, 0x401003fd },
1360 { 0x12, 0x403003fe },
1361 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001362};
1363
1364/*
1365 STAC 9200-32 pin configs for
1366 102801BD (Dell Inspiron E1505n)
1367 102801EE
1368 102801EF
1369*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001370static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1371 { 0x08, 0x40c003fa },
1372 { 0x09, 0x01441340 },
1373 { 0x0d, 0x0421121f },
1374 { 0x0e, 0x90170310 },
1375 { 0x0f, 0x408003fb },
1376 { 0x10, 0x04a11020 },
1377 { 0x11, 0x401003fc },
1378 { 0x12, 0x403003fd },
1379 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001380};
1381
1382/*
1383 STAC 9200-32 pin configs for
1384 102801F5 (Dell Inspiron 1501)
1385 102801F6
1386*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001387static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1388 { 0x08, 0x40c003fa },
1389 { 0x09, 0x404003fb },
1390 { 0x0d, 0x0421121f },
1391 { 0x0e, 0x90170310 },
1392 { 0x0f, 0x408003fc },
1393 { 0x10, 0x04a11020 },
1394 { 0x11, 0x401003fd },
1395 { 0x12, 0x403003fe },
1396 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001397};
1398
1399/*
1400 STAC 9200-32
1401 102801CD (Dell Inspiron E1705/9400)
1402*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001403static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1404 { 0x08, 0x40c003fa },
1405 { 0x09, 0x01441340 },
1406 { 0x0d, 0x0421121f },
1407 { 0x0e, 0x90170310 },
1408 { 0x0f, 0x90170310 },
1409 { 0x10, 0x04a11020 },
1410 { 0x11, 0x90170310 },
1411 { 0x12, 0x40f003fc },
1412 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001413};
1414
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001415static const struct hda_pintbl oqo9200_pin_configs[] = {
1416 { 0x08, 0x40c000f0 },
1417 { 0x09, 0x404000f1 },
1418 { 0x0d, 0x0221121f },
1419 { 0x0e, 0x02211210 },
1420 { 0x0f, 0x90170111 },
1421 { 0x10, 0x90a70120 },
1422 { 0x11, 0x400000f2 },
1423 { 0x12, 0x400000f3 },
1424 {}
Tobin Davisbf277782008-02-03 20:31:47 +01001425};
1426
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001427
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001428static void stac9200_fixup_panasonic(struct hda_codec *codec,
1429 const struct hda_fixup *fix, int action)
1430{
1431 struct sigmatel_spec *spec = codec->spec;
1432
1433 switch (action) {
1434 case HDA_FIXUP_ACT_PRE_PROBE:
1435 spec->gpio_mask = spec->gpio_dir = 0x09;
1436 spec->gpio_data = 0x00;
1437 break;
1438 case HDA_FIXUP_ACT_PROBE:
1439 /* CF-74 has no headphone detection, and the driver should *NOT*
1440 * do detection and HP/speaker toggle because the hardware does it.
1441 */
1442 spec->hp_detect = 0;
1443 break;
1444 }
1445}
1446
1447
1448static const struct hda_fixup stac9200_fixups[] = {
1449 [STAC_REF] = {
1450 .type = HDA_FIXUP_PINS,
1451 .v.pins = ref9200_pin_configs,
1452 },
1453 [STAC_9200_OQO] = {
1454 .type = HDA_FIXUP_PINS,
1455 .v.pins = oqo9200_pin_configs,
1456 .chained = true,
1457 .chain_id = STAC_9200_EAPD_INIT,
1458 },
1459 [STAC_9200_DELL_D21] = {
1460 .type = HDA_FIXUP_PINS,
1461 .v.pins = dell9200_d21_pin_configs,
1462 },
1463 [STAC_9200_DELL_D22] = {
1464 .type = HDA_FIXUP_PINS,
1465 .v.pins = dell9200_d22_pin_configs,
1466 },
1467 [STAC_9200_DELL_D23] = {
1468 .type = HDA_FIXUP_PINS,
1469 .v.pins = dell9200_d23_pin_configs,
1470 },
1471 [STAC_9200_DELL_M21] = {
1472 .type = HDA_FIXUP_PINS,
1473 .v.pins = dell9200_m21_pin_configs,
1474 },
1475 [STAC_9200_DELL_M22] = {
1476 .type = HDA_FIXUP_PINS,
1477 .v.pins = dell9200_m22_pin_configs,
1478 },
1479 [STAC_9200_DELL_M23] = {
1480 .type = HDA_FIXUP_PINS,
1481 .v.pins = dell9200_m23_pin_configs,
1482 },
1483 [STAC_9200_DELL_M24] = {
1484 .type = HDA_FIXUP_PINS,
1485 .v.pins = dell9200_m24_pin_configs,
1486 },
1487 [STAC_9200_DELL_M25] = {
1488 .type = HDA_FIXUP_PINS,
1489 .v.pins = dell9200_m25_pin_configs,
1490 },
1491 [STAC_9200_DELL_M26] = {
1492 .type = HDA_FIXUP_PINS,
1493 .v.pins = dell9200_m26_pin_configs,
1494 },
1495 [STAC_9200_DELL_M27] = {
1496 .type = HDA_FIXUP_PINS,
1497 .v.pins = dell9200_m27_pin_configs,
1498 },
1499 [STAC_9200_M4] = {
1500 .type = HDA_FIXUP_PINS,
1501 .v.pins = gateway9200_m4_pin_configs,
1502 .chained = true,
1503 .chain_id = STAC_9200_EAPD_INIT,
1504 },
1505 [STAC_9200_M4_2] = {
1506 .type = HDA_FIXUP_PINS,
1507 .v.pins = gateway9200_m4_2_pin_configs,
1508 .chained = true,
1509 .chain_id = STAC_9200_EAPD_INIT,
1510 },
1511 [STAC_9200_PANASONIC] = {
1512 .type = HDA_FIXUP_FUNC,
1513 .v.func = stac9200_fixup_panasonic,
1514 },
1515 [STAC_9200_EAPD_INIT] = {
1516 .type = HDA_FIXUP_VERBS,
1517 .v.verbs = (const struct hda_verb[]) {
1518 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1519 {}
1520 },
1521 },
Matt Porter403d1942005-11-29 15:00:51 +01001522};
1523
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001524static const struct hda_model_fixup stac9200_models[] = {
1525 { .id = STAC_REF, .name = "ref" },
1526 { .id = STAC_9200_OQO, .name = "oqo" },
1527 { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1528 { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1529 { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1530 { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1531 { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1532 { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1533 { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1534 { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1535 { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1536 { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1537 { .id = STAC_9200_M4, .name = "gateway-m4" },
1538 { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1539 { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1540 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001541};
1542
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001543static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001544 /* SigmaTel reference board */
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1546 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001547 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1548 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001549 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1551 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001553 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1555 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1557 "unknown Dell", STAC_9200_DELL_D22),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1559 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001561 "Dell Latitude D620", STAC_9200_DELL_M22),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1563 "unknown Dell", STAC_9200_DELL_D23),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1565 "unknown Dell", STAC_9200_DELL_D23),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1567 "unknown Dell", STAC_9200_DELL_M22),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1569 "unknown Dell", STAC_9200_DELL_M24),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1571 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001572 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001573 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001574 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001575 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001576 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001577 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001579 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001581 "Dell Precision M90", STAC_9200_DELL_M23),
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1583 "unknown Dell", STAC_9200_DELL_M22),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1585 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001587 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001589 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1591 "unknown Dell", STAC_9200_DELL_D23),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1593 "unknown Dell", STAC_9200_DELL_D23),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1595 "unknown Dell", STAC_9200_DELL_D21),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1597 "unknown Dell", STAC_9200_DELL_D23),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1599 "unknown Dell", STAC_9200_DELL_D21),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1601 "unknown Dell", STAC_9200_DELL_M25),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1603 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001605 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1607 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001608 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001609 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001610 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001611 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1612 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1613 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001614 /* OQO Mobile */
1615 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001616 {} /* terminator */
1617};
1618
Takashi Iwaid2077d42013-01-14 14:20:16 +01001619static const struct hda_pintbl ref925x_pin_configs[] = {
1620 { 0x07, 0x40c003f0 },
1621 { 0x08, 0x424503f2 },
1622 { 0x0a, 0x01813022 },
1623 { 0x0b, 0x02a19021 },
1624 { 0x0c, 0x90a70320 },
1625 { 0x0d, 0x02214210 },
1626 { 0x10, 0x01019020 },
1627 { 0x11, 0x9033032e },
1628 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001629};
1630
Takashi Iwaid2077d42013-01-14 14:20:16 +01001631static const struct hda_pintbl stac925xM1_pin_configs[] = {
1632 { 0x07, 0x40c003f4 },
1633 { 0x08, 0x424503f2 },
1634 { 0x0a, 0x400000f3 },
1635 { 0x0b, 0x02a19020 },
1636 { 0x0c, 0x40a000f0 },
1637 { 0x0d, 0x90100210 },
1638 { 0x10, 0x400003f1 },
1639 { 0x11, 0x9033032e },
1640 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001641};
1642
Takashi Iwaid2077d42013-01-14 14:20:16 +01001643static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1644 { 0x07, 0x40c003f4 },
1645 { 0x08, 0x424503f2 },
1646 { 0x0a, 0x400000f3 },
1647 { 0x0b, 0x02a19020 },
1648 { 0x0c, 0x40a000f0 },
1649 { 0x0d, 0x90100210 },
1650 { 0x10, 0x400003f1 },
1651 { 0x11, 0x9033032e },
1652 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001653};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001654
Takashi Iwaid2077d42013-01-14 14:20:16 +01001655static const struct hda_pintbl stac925xM2_pin_configs[] = {
1656 { 0x07, 0x40c003f4 },
1657 { 0x08, 0x424503f2 },
1658 { 0x0a, 0x400000f3 },
1659 { 0x0b, 0x02a19020 },
1660 { 0x0c, 0x40a000f0 },
1661 { 0x0d, 0x90100210 },
1662 { 0x10, 0x400003f1 },
1663 { 0x11, 0x9033032e },
1664 {}
Tobin Davis2c11f952007-05-17 09:36:34 +02001665};
1666
Takashi Iwaid2077d42013-01-14 14:20:16 +01001667static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1668 { 0x07, 0x40c003f4 },
1669 { 0x08, 0x424503f2 },
1670 { 0x0a, 0x400000f3 },
1671 { 0x0b, 0x02a19020 },
1672 { 0x0c, 0x40a000f0 },
1673 { 0x0d, 0x90100210 },
1674 { 0x10, 0x400003f1 },
1675 { 0x11, 0x9033032e },
1676 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001677};
1678
Takashi Iwaid2077d42013-01-14 14:20:16 +01001679static const struct hda_pintbl stac925xM3_pin_configs[] = {
1680 { 0x07, 0x40c003f4 },
1681 { 0x08, 0x424503f2 },
1682 { 0x0a, 0x400000f3 },
1683 { 0x0b, 0x02a19020 },
1684 { 0x0c, 0x40a000f0 },
1685 { 0x0d, 0x90100210 },
1686 { 0x10, 0x400003f1 },
1687 { 0x11, 0x503303f3 },
1688 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001689};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001690
Takashi Iwaid2077d42013-01-14 14:20:16 +01001691static const struct hda_pintbl stac925xM5_pin_configs[] = {
1692 { 0x07, 0x40c003f4 },
1693 { 0x08, 0x424503f2 },
1694 { 0x0a, 0x400000f3 },
1695 { 0x0b, 0x02a19020 },
1696 { 0x0c, 0x40a000f0 },
1697 { 0x0d, 0x90100210 },
1698 { 0x10, 0x400003f1 },
1699 { 0x11, 0x9033032e },
1700 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001701};
1702
Takashi Iwaid2077d42013-01-14 14:20:16 +01001703static const struct hda_pintbl stac925xM6_pin_configs[] = {
1704 { 0x07, 0x40c003f4 },
1705 { 0x08, 0x424503f2 },
1706 { 0x0a, 0x400000f3 },
1707 { 0x0b, 0x02a19020 },
1708 { 0x0c, 0x40a000f0 },
1709 { 0x0d, 0x90100210 },
1710 { 0x10, 0x400003f1 },
1711 { 0x11, 0x90330320 },
1712 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001713};
1714
Takashi Iwaid2077d42013-01-14 14:20:16 +01001715static const struct hda_fixup stac925x_fixups[] = {
1716 [STAC_REF] = {
1717 .type = HDA_FIXUP_PINS,
1718 .v.pins = ref925x_pin_configs,
1719 },
1720 [STAC_M1] = {
1721 .type = HDA_FIXUP_PINS,
1722 .v.pins = stac925xM1_pin_configs,
1723 },
1724 [STAC_M1_2] = {
1725 .type = HDA_FIXUP_PINS,
1726 .v.pins = stac925xM1_2_pin_configs,
1727 },
1728 [STAC_M2] = {
1729 .type = HDA_FIXUP_PINS,
1730 .v.pins = stac925xM2_pin_configs,
1731 },
1732 [STAC_M2_2] = {
1733 .type = HDA_FIXUP_PINS,
1734 .v.pins = stac925xM2_2_pin_configs,
1735 },
1736 [STAC_M3] = {
1737 .type = HDA_FIXUP_PINS,
1738 .v.pins = stac925xM3_pin_configs,
1739 },
1740 [STAC_M5] = {
1741 .type = HDA_FIXUP_PINS,
1742 .v.pins = stac925xM5_pin_configs,
1743 },
1744 [STAC_M6] = {
1745 .type = HDA_FIXUP_PINS,
1746 .v.pins = stac925xM6_pin_configs,
1747 },
Tobin Davis8e21c342007-01-08 11:04:17 +01001748};
1749
Takashi Iwaid2077d42013-01-14 14:20:16 +01001750static const struct hda_model_fixup stac925x_models[] = {
1751 { .id = STAC_REF, .name = "ref" },
1752 { .id = STAC_M1, .name = "m1" },
1753 { .id = STAC_M1_2, .name = "m1-2" },
1754 { .id = STAC_M2, .name = "m2" },
1755 { .id = STAC_M2_2, .name = "m2-2" },
1756 { .id = STAC_M3, .name = "m3" },
1757 { .id = STAC_M5, .name = "m5" },
1758 { .id = STAC_M6, .name = "m6" },
1759 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001760};
1761
Takashi Iwaid2077d42013-01-14 14:20:16 +01001762static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1763 /* SigmaTel reference board */
1764 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1766 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1767
1768 /* Default table for unknown ID */
1769 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1770
1771 /* gateway machines are checked via codec ssid */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001772 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1773 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1774 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1775 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001776 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001777 /* Not sure about the brand name for those */
1778 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1779 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1780 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1781 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001782 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001783};
1784
Takashi Iwai55e30142013-01-14 17:30:04 +01001785static const struct hda_pintbl ref92hd73xx_pin_configs[] = {
1786 { 0x0a, 0x02214030 },
1787 { 0x0b, 0x02a19040 },
1788 { 0x0c, 0x01a19020 },
1789 { 0x0d, 0x02214030 },
1790 { 0x0e, 0x0181302e },
1791 { 0x0f, 0x01014010 },
1792 { 0x10, 0x01014020 },
1793 { 0x11, 0x01014030 },
1794 { 0x12, 0x02319040 },
1795 { 0x13, 0x90a000f0 },
1796 { 0x14, 0x90a000f0 },
1797 { 0x22, 0x01452050 },
1798 { 0x23, 0x01452050 },
1799 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01001800};
1801
Takashi Iwai55e30142013-01-14 17:30:04 +01001802static const struct hda_pintbl dell_m6_pin_configs[] = {
1803 { 0x0a, 0x0321101f },
1804 { 0x0b, 0x4f00000f },
1805 { 0x0c, 0x4f0000f0 },
1806 { 0x0d, 0x90170110 },
1807 { 0x0e, 0x03a11020 },
1808 { 0x0f, 0x0321101f },
1809 { 0x10, 0x4f0000f0 },
1810 { 0x11, 0x4f0000f0 },
1811 { 0x12, 0x4f0000f0 },
1812 { 0x13, 0x90a60160 },
1813 { 0x14, 0x4f0000f0 },
1814 { 0x22, 0x4f0000f0 },
1815 { 0x23, 0x4f0000f0 },
1816 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001817};
1818
Takashi Iwai55e30142013-01-14 17:30:04 +01001819static const struct hda_pintbl alienware_m17x_pin_configs[] = {
1820 { 0x0a, 0x0321101f },
1821 { 0x0b, 0x0321101f },
1822 { 0x0c, 0x03a11020 },
1823 { 0x0d, 0x03014020 },
1824 { 0x0e, 0x90170110 },
1825 { 0x0f, 0x4f0000f0 },
1826 { 0x10, 0x4f0000f0 },
1827 { 0x11, 0x4f0000f0 },
1828 { 0x12, 0x4f0000f0 },
1829 { 0x13, 0x90a60160 },
1830 { 0x14, 0x4f0000f0 },
1831 { 0x22, 0x4f0000f0 },
1832 { 0x23, 0x904601b0 },
1833 {}
Takashi Iwai842ae632009-09-02 07:43:08 +02001834};
1835
Takashi Iwai55e30142013-01-14 17:30:04 +01001836static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1837 { 0x0a, 0x02214230 },
1838 { 0x0b, 0x02A19240 },
1839 { 0x0c, 0x01013214 },
1840 { 0x0d, 0x01014210 },
1841 { 0x0e, 0x01A19250 },
1842 { 0x0f, 0x01011212 },
1843 { 0x10, 0x01016211 },
1844 {}
Alexey Fisher52dc4382009-12-12 11:16:41 +02001845};
1846
Takashi Iwai55e30142013-01-14 17:30:04 +01001847static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
1848 const struct hda_fixup *fix, int action)
1849{
1850 struct sigmatel_spec *spec = codec->spec;
1851
1852 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1853 return;
1854
1855 snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs);
1856 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
1857}
1858
1859static void stac92hd73xx_fixup_dell(struct hda_codec *codec)
1860{
1861 struct sigmatel_spec *spec = codec->spec;
1862
1863 snd_hda_apply_pincfgs(codec, dell_m6_pin_configs);
1864 spec->num_smuxes = 0;
1865 spec->eapd_switch = 0;
1866}
1867
1868static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec,
1869 const struct hda_fixup *fix, int action)
1870{
1871 struct sigmatel_spec *spec = codec->spec;
1872
1873 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1874 return;
1875
1876 stac92hd73xx_fixup_dell(codec);
1877 snd_hda_add_verbs(codec, dell_eq_core_init);
1878 spec->volknob_init = 1;
1879}
1880
1881/* Analog Mics */
1882static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec,
1883 const struct hda_fixup *fix, int action)
1884{
1885 struct sigmatel_spec *spec = codec->spec;
1886
1887 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1888 return;
1889
1890 stac92hd73xx_fixup_dell(codec);
1891 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1892 spec->num_dmics = 0;
1893}
1894
1895/* Digital Mics */
1896static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec,
1897 const struct hda_fixup *fix, int action)
1898{
1899 struct sigmatel_spec *spec = codec->spec;
1900
1901 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1902 return;
1903
1904 stac92hd73xx_fixup_dell(codec);
1905 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1906 spec->num_dmics = 1;
1907}
1908
1909/* Both */
1910static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec,
1911 const struct hda_fixup *fix, int action)
1912{
1913 struct sigmatel_spec *spec = codec->spec;
1914
1915 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1916 return;
1917
1918 stac92hd73xx_fixup_dell(codec);
1919 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1920 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1921 spec->num_dmics = 1;
1922}
1923
1924static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec,
1925 const struct hda_fixup *fix, int action)
1926{
1927 struct sigmatel_spec *spec = codec->spec;
1928
1929 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1930 return;
1931
1932 snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs);
1933 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
1934 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
1935 spec->eapd_switch = 0;
1936}
1937
1938static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec,
1939 const struct hda_fixup *fix, int action)
1940{
1941 struct sigmatel_spec *spec = codec->spec;
1942
1943 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1944 return;
1945 spec->hp_detect = 0;
1946}
1947
1948static const struct hda_fixup stac92hd73xx_fixups[] = {
1949 [STAC_92HD73XX_REF] = {
1950 .type = HDA_FIXUP_FUNC,
1951 .v.func = stac92hd73xx_fixup_ref,
1952 },
1953 [STAC_DELL_M6_AMIC] = {
1954 .type = HDA_FIXUP_FUNC,
1955 .v.func = stac92hd73xx_fixup_dell_m6_amic,
1956 },
1957 [STAC_DELL_M6_DMIC] = {
1958 .type = HDA_FIXUP_FUNC,
1959 .v.func = stac92hd73xx_fixup_dell_m6_dmic,
1960 },
1961 [STAC_DELL_M6_BOTH] = {
1962 .type = HDA_FIXUP_FUNC,
1963 .v.func = stac92hd73xx_fixup_dell_m6_both,
1964 },
1965 [STAC_DELL_EQ] = {
1966 .type = HDA_FIXUP_FUNC,
1967 .v.func = stac92hd73xx_fixup_dell_eq,
1968 },
1969 [STAC_ALIENWARE_M17X] = {
1970 .type = HDA_FIXUP_FUNC,
1971 .v.func = stac92hd73xx_fixup_alienware_m17x,
1972 },
1973 [STAC_92HD73XX_INTEL] = {
1974 .type = HDA_FIXUP_PINS,
1975 .v.pins = intel_dg45id_pin_configs,
1976 },
1977 [STAC_92HD73XX_NO_JD] = {
1978 .type = HDA_FIXUP_FUNC,
1979 .v.func = stac92hd73xx_fixup_no_jd,
1980 }
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001981};
1982
Takashi Iwai55e30142013-01-14 17:30:04 +01001983static const struct hda_model_fixup stac92hd73xx_models[] = {
1984 { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" },
1985 { .id = STAC_92HD73XX_REF, .name = "ref" },
1986 { .id = STAC_92HD73XX_INTEL, .name = "intel" },
1987 { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" },
1988 { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" },
1989 { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" },
1990 { .id = STAC_DELL_EQ, .name = "dell-eq" },
1991 { .id = STAC_ALIENWARE_M17X, .name = "alienware" },
1992 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001993};
1994
Takashi Iwai55e30142013-01-14 17:30:04 +01001995static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001996 /* SigmaTel reference board */
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001998 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001999 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2000 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08002001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
2002 "Intel DG45ID", STAC_92HD73XX_INTEL),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
2004 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002005 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002006 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002007 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002008 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002009 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002010 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002011 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002012 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002013 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002014 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002015 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002016 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002017 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002018 "unknown Dell", STAC_DELL_M6_DMIC),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
2020 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01002021 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002022 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01002023 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
2024 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02002025 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
2026 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00002027 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
2028 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04002029 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01002030 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04002031 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02002032 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Takashi Iwai55e30142013-01-14 17:30:04 +01002033 /* codec SSID matching */
Takashi Iwai842ae632009-09-02 07:43:08 +02002034 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
2035 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05002036 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
2037 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01002038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01002039 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02002040 {} /* terminator */
2041};
2042
Takashi Iwai2b635362011-05-02 12:33:43 +02002043static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002044 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
2045 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002046 0x01451160, 0x98560170,
2047};
2048
Takashi Iwai2b635362011-05-02 12:33:43 +02002049static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02002050 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
2051 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002052 0x40f000f0, 0x40f000f0,
2053};
2054
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002055static const unsigned int dell_vostro_3500_pin_configs[10] = {
2056 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
2057 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
2058 0x400000f4, 0x400000f5,
2059};
2060
Takashi Iwai2b635362011-05-02 12:33:43 +02002061static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06002062 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
2063 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
2064 0x40f000f0, 0x40f000f0,
2065};
2066
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002067static const unsigned int hp_zephyr_pin_configs[10] = {
2068 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
2069 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
2070 0, 0,
2071};
2072
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002073static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
2074 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
2075 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
2076 0x40f000f0, 0x40f000f0,
2077};
2078
Takashi Iwai2b635362011-05-02 12:33:43 +02002079static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002080 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05002081 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002082 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002083 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002084 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06002085 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002086 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002087};
2088
Takashi Iwaiea734962011-01-17 11:29:34 +01002089static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002090 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002091 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05002092 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002093 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002094 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002095 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06002096 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002097 [STAC_HP_ZEPHYR] = "hp-zephyr",
Takashi Iwaia3e19972012-07-26 08:17:20 +02002098 [STAC_92HD83XXX_HP_LED] = "hp-led",
Takashi Iwaiff8a1e22012-07-31 10:16:59 +02002099 [STAC_92HD83XXX_HP_INV_LED] = "hp-inv-led",
Takashi Iwai62cbde12012-09-14 11:58:54 +02002100 [STAC_92HD83XXX_HP_MIC_LED] = "hp-mic-led",
David Henningsson8d032a82012-10-09 12:48:40 +02002101 [STAC_92HD83XXX_HEADSET_JACK] = "headset-jack",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002102};
2103
Takashi Iwai2b635362011-05-02 12:33:43 +02002104static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002105 /* SigmaTel reference board */
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01002107 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002108 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2109 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
2111 "unknown Dell", STAC_DELL_S14),
David Henningsson8d032a82012-10-09 12:48:40 +02002112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
2113 "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
2115 "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
2117 "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
2119 "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
2121 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
2123 "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
2125 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2126 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
2127 "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
2129 "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
2131 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002132 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
2133 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
2135 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2136 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
2137 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
Takashi Iwai8ae58652012-12-13 14:33:42 +01002139 "HP Pavilion dv7", STAC_HP_DV7_4000),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002140 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
2141 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2142 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
2143 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Takashi Iwai62cbde12012-09-14 11:58:54 +02002144 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
2145 "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002146 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
2147 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
2149 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
2151 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
2153 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
2155 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
2157 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
2159 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
2161 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
2163 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
2165 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
2167 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2169 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2171 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2173 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002174 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2175 "HP", STAC_HP_ZEPHYR),
Takashi Iwaia3e19972012-07-26 08:17:20 +02002176 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2177 "HP Mini", STAC_92HD83XXX_HP_LED),
Gustavo Maciel Dias Vieira5afc13a2012-10-26 12:51:53 -02002178 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2179 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002180 {} /* terminator */
2181};
2182
2183static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2185 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02002186 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002187};
2188
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002189static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2190 { 0x0a, 0x02214030 },
2191 { 0x0b, 0x02a19040 },
2192 { 0x0c, 0x01a19020 },
2193 { 0x0d, 0x01014010 },
2194 { 0x0e, 0x0181302e },
2195 { 0x0f, 0x01014010 },
2196 { 0x14, 0x01019020 },
2197 { 0x18, 0x90a000f0 },
2198 { 0x19, 0x90a000f0 },
2199 { 0x1e, 0x01452050 },
2200 { 0x1f, 0x01452050 },
2201 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002202};
2203
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002204static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2205 { 0x0a, 0x0421101f },
2206 { 0x0b, 0x04a11221 },
2207 { 0x0c, 0x40f000f0 },
2208 { 0x0d, 0x90170110 },
2209 { 0x0e, 0x23a1902e },
2210 { 0x0f, 0x23014250 },
2211 { 0x14, 0x40f000f0 },
2212 { 0x18, 0x90a000f0 },
2213 { 0x19, 0x40f000f0 },
2214 { 0x1e, 0x4f0000f0 },
2215 { 0x1f, 0x4f0000f0 },
2216 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002217};
2218
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002219static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2220 { 0x0a, 0x0421101f },
2221 { 0x0b, 0x04a11221 },
2222 { 0x0c, 0x90a70330 },
2223 { 0x0d, 0x90170110 },
2224 { 0x0e, 0x23a1902e },
2225 { 0x0f, 0x23014250 },
2226 { 0x14, 0x40f000f0 },
2227 { 0x18, 0x40f000f0 },
2228 { 0x19, 0x40f000f0 },
2229 { 0x1e, 0x044413b0 },
2230 { 0x1f, 0x044413b0 },
2231 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002232};
2233
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002234static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2235 { 0x0a, 0x0421101f },
2236 { 0x0b, 0x04a11221 },
2237 { 0x0c, 0x90a70330 },
2238 { 0x0d, 0x90170110 },
2239 { 0x0e, 0x40f000f0 },
2240 { 0x0f, 0x40f000f0 },
2241 { 0x14, 0x40f000f0 },
2242 { 0x18, 0x90a000f0 },
2243 { 0x19, 0x40f000f0 },
2244 { 0x1e, 0x044413b0 },
2245 { 0x1f, 0x044413b0 },
2246 {}
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002247};
2248
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002249static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2250 const struct hda_fixup *fix, int action)
2251{
2252 struct sigmatel_spec *spec = codec->spec;
2253
2254 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2255 return;
2256
2257 snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2258 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2259}
2260
2261static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec,
2262 const struct hda_fixup *fix, int action)
2263{
2264 struct sigmatel_spec *spec = codec->spec;
2265
2266 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2267 return;
2268 spec->num_dmics = 0;
2269 spec->num_smuxes = 0;
2270 spec->num_dmuxes = 0;
2271}
2272
2273static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec,
2274 const struct hda_fixup *fix, int action)
2275{
2276 struct sigmatel_spec *spec = codec->spec;
2277
2278 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2279 return;
2280 spec->num_dmics = 1;
2281 spec->num_smuxes = 0;
2282 spec->num_dmuxes = 1;
2283}
2284
2285static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2286 const struct hda_fixup *fix, int action)
2287{
2288 struct sigmatel_spec *spec = codec->spec;
2289
2290 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2291 return;
2292
2293 /* Enable VREF power saving on GPIO1 detect */
2294 stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02);
2295 snd_hda_codec_write_cache(codec, codec->afg, 0,
2296 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
2297 snd_hda_jack_detect_enable(codec, codec->afg, 0);
2298 spec->gpio_mask |= 0x02;
2299
2300 /* enable internal microphone */
2301 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2302 stac92xx_auto_set_pinctl(codec, 0x0e,
2303 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2304
2305 stac92hd71bxx_fixup_no_dmic(codec, fix, action);
2306}
2307
2308static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec,
2309 const struct hda_fixup *fix, int action)
2310{
2311 struct sigmatel_spec *spec = codec->spec;
2312
2313 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2314 return;
2315 spec->num_dmics = 1;
2316 /* I don't know if it needs 1 or 2 smuxes - will wait for
2317 * bug reports to fix if needed
2318 */
2319 spec->num_smuxes = 1;
2320 spec->num_dmuxes = 1;
2321}
2322
2323static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2324 const struct hda_fixup *fix, int action)
2325{
2326 struct sigmatel_spec *spec = codec->spec;
2327
2328 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2329 return;
2330 spec->gpio_led = 0x01;
2331}
2332
2333static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2334 const struct hda_fixup *fix, int action)
2335{
2336 struct sigmatel_spec *spec = codec->spec;
2337 unsigned int cap;
2338
2339 switch (action) {
2340 case HDA_FIXUP_ACT_PRE_PROBE:
2341 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2342 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
2343 /* HP dv6 gives the headphone pin as a line-out. Thus we
2344 * need to set hp_detect flag here to force to enable HP
2345 * detection.
2346 */
2347 spec->hp_detect = 1;
2348 break;
2349
2350 case HDA_FIXUP_ACT_PROBE:
2351 /* enable bass on HP dv7 */
2352 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2353 cap &= AC_GPIO_IO_COUNT;
2354 if (cap >= 6)
2355 stac_add_hp_bass_switch(codec);
2356 break;
2357 }
2358}
2359
2360static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
2361 const struct hda_fixup *fix, int action)
2362{
2363 struct sigmatel_spec *spec = codec->spec;
2364
2365 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2366 return;
2367 spec->gpio_led = 0x08;
2368 spec->num_dmics = 1;
2369 spec->num_smuxes = 1;
2370 spec->num_dmuxes = 1;
2371}
2372
2373
2374static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
2375 const struct hda_fixup *fix, int action)
2376{
2377 struct sigmatel_spec *spec = codec->spec;
2378
2379 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2380 return;
2381
2382 if (hp_blike_system(codec->subsystem_id)) {
2383 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
2384 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
2385 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
2386 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
2387 /* It was changed in the BIOS to just satisfy MS DTM.
2388 * Lets turn it back into slaved HP
2389 */
2390 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
2391 | (AC_JACK_HP_OUT <<
2392 AC_DEFCFG_DEVICE_SHIFT);
2393 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
2394 | AC_DEFCFG_SEQUENCE)))
2395 | 0x1f;
2396 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
2397 }
2398 }
2399
2400 if (find_mute_led_cfg(codec, 1))
2401 snd_printd("mute LED gpio %d polarity %d\n",
2402 spec->gpio_led,
2403 spec->gpio_led_polarity);
2404
2405}
2406
2407static const struct hda_fixup stac92hd71bxx_fixups[] = {
2408 [STAC_92HD71BXX_REF] = {
2409 .type = HDA_FIXUP_FUNC,
2410 .v.func = stac92hd71bxx_fixup_ref,
2411 },
2412 [STAC_DELL_M4_1] = {
2413 .type = HDA_FIXUP_PINS,
2414 .v.pins = dell_m4_1_pin_configs,
2415 .chained = true,
2416 .chain_id = STAC_92HD71BXX_NO_SMUX,
2417 },
2418 [STAC_DELL_M4_2] = {
2419 .type = HDA_FIXUP_PINS,
2420 .v.pins = dell_m4_2_pin_configs,
2421 .chained = true,
2422 .chain_id = STAC_92HD71BXX_NO_DMIC,
2423 },
2424 [STAC_DELL_M4_3] = {
2425 .type = HDA_FIXUP_PINS,
2426 .v.pins = dell_m4_3_pin_configs,
2427 .chained = true,
2428 .chain_id = STAC_92HD71BXX_NO_SMUX,
2429 },
2430 [STAC_HP_M4] = {
2431 .type = HDA_FIXUP_FUNC,
2432 .v.func = stac92hd71bxx_fixup_hp_m4,
2433 .chained = true,
2434 .chain_id = STAC_92HD71BXX_HP,
2435 },
2436 [STAC_HP_DV4] = {
2437 .type = HDA_FIXUP_FUNC,
2438 .v.func = stac92hd71bxx_fixup_hp_dv4,
2439 .chained = true,
2440 .chain_id = STAC_HP_DV5,
2441 },
2442 [STAC_HP_DV5] = {
2443 .type = HDA_FIXUP_FUNC,
2444 .v.func = stac92hd71bxx_fixup_hp_dv5,
2445 .chained = true,
2446 .chain_id = STAC_92HD71BXX_HP,
2447 },
2448 [STAC_HP_HDX] = {
2449 .type = HDA_FIXUP_FUNC,
2450 .v.func = stac92hd71bxx_fixup_hp_hdx,
2451 .chained = true,
2452 .chain_id = STAC_92HD71BXX_HP,
2453 },
2454 [STAC_HP_DV4_1222NR] = {
2455 .type = HDA_FIXUP_FUNC,
2456 .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr,
2457 .chained = true,
2458 .chain_id = STAC_HP_DV4,
2459 },
2460 [STAC_92HD71BXX_NO_DMIC] = {
2461 .type = HDA_FIXUP_FUNC,
2462 .v.func = stac92hd71bxx_fixup_no_dmic,
2463 },
2464 [STAC_92HD71BXX_NO_SMUX] = {
2465 .type = HDA_FIXUP_FUNC,
2466 .v.func = stac92hd71bxx_fixup_no_smux,
2467 },
2468 [STAC_92HD71BXX_HP] = {
2469 .type = HDA_FIXUP_FUNC,
2470 .v.func = stac92hd71bxx_fixup_hp,
2471 },
Matthew Ranostaye035b842007-11-06 11:53:55 +01002472};
2473
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002474static const struct hda_model_fixup stac92hd71bxx_models[] = {
2475 { .id = STAC_92HD71BXX_REF, .name = "ref" },
2476 { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
2477 { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
2478 { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
2479 { .id = STAC_HP_M4, .name = "hp-m4" },
2480 { .id = STAC_HP_DV4, .name = "hp-dv4" },
2481 { .id = STAC_HP_DV5, .name = "hp-dv5" },
2482 { .id = STAC_HP_HDX, .name = "hp-hdx" },
2483 { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" },
2484 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002485};
2486
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002487static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002488 /* SigmaTel reference board */
2489 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2490 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002491 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2492 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04002493 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
2494 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01002495 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2496 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01002497 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2498 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002499 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002500 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002501 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2502 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002503 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2504 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04002505 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002506 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002507 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002508 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02002509 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2510 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05302511 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2512 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11002513 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2514 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02002515 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2516 "HP", STAC_HP_DV5),
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002517 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2519 "unknown Dell", STAC_DELL_M4_1),
2520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2521 "unknown Dell", STAC_DELL_M4_1),
2522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2523 "unknown Dell", STAC_DELL_M4_1),
2524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2525 "unknown Dell", STAC_DELL_M4_1),
2526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2527 "unknown Dell", STAC_DELL_M4_1),
2528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2529 "unknown Dell", STAC_DELL_M4_1),
2530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2531 "unknown Dell", STAC_DELL_M4_1),
2532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2533 "unknown Dell", STAC_DELL_M4_2),
2534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2535 "unknown Dell", STAC_DELL_M4_2),
2536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2537 "unknown Dell", STAC_DELL_M4_2),
2538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2539 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2541 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002542 {} /* terminator */
2543};
2544
Takashi Iwai0a427842013-01-14 15:20:13 +01002545static const struct hda_pintbl ref922x_pin_configs[] = {
2546 { 0x0a, 0x01014010 },
2547 { 0x0b, 0x01016011 },
2548 { 0x0c, 0x01012012 },
2549 { 0x0d, 0x0221401f },
2550 { 0x0e, 0x01813122 },
2551 { 0x0f, 0x01011014 },
2552 { 0x10, 0x01441030 },
2553 { 0x11, 0x01c41030 },
2554 { 0x15, 0x40000100 },
2555 { 0x1b, 0x40000100 },
2556 {}
Matt2f2f4252005-04-13 14:45:30 +02002557};
2558
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002559/*
2560 STAC 922X pin configs for
2561 102801A7
2562 102801AB
2563 102801A9
2564 102801D1
2565 102801D2
2566*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002567static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2568 { 0x0a, 0x02214030 },
2569 { 0x0b, 0x01a19021 },
2570 { 0x0c, 0x01111012 },
2571 { 0x0d, 0x01114010 },
2572 { 0x0e, 0x02a19020 },
2573 { 0x0f, 0x01117011 },
2574 { 0x10, 0x400001f0 },
2575 { 0x11, 0x400001f1 },
2576 { 0x15, 0x01813122 },
2577 { 0x1b, 0x400001f2 },
2578 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002579};
2580
2581/*
2582 STAC 922X pin configs for
2583 102801AC
2584 102801D0
2585*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002586static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2587 { 0x0a, 0x02214030 },
2588 { 0x0b, 0x01a19021 },
2589 { 0x0c, 0x01111012 },
2590 { 0x0d, 0x01114010 },
2591 { 0x0e, 0x02a19020 },
2592 { 0x0f, 0x01117011 },
2593 { 0x10, 0x01451140 },
2594 { 0x11, 0x400001f0 },
2595 { 0x15, 0x01813122 },
2596 { 0x1b, 0x400001f1 },
2597 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002598};
2599
2600/*
2601 STAC 922X pin configs for
2602 102801BF
2603*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002604static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2605 { 0x0a, 0x0321101f },
2606 { 0x0b, 0x01112024 },
2607 { 0x0c, 0x01111222 },
2608 { 0x0d, 0x91174220 },
2609 { 0x0e, 0x03a11050 },
2610 { 0x0f, 0x01116221 },
2611 { 0x10, 0x90a70330 },
2612 { 0x11, 0x01452340 },
2613 { 0x15, 0x40C003f1 },
2614 { 0x1b, 0x405003f0 },
2615 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002616};
2617
2618/*
2619 STAC 9221 A1 pin configs for
2620 102801D7 (Dell XPS M1210)
2621*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002622static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2623 { 0x0a, 0x02211211 },
2624 { 0x0b, 0x408103ff },
2625 { 0x0c, 0x02a1123e },
2626 { 0x0d, 0x90100310 },
2627 { 0x0e, 0x408003f1 },
2628 { 0x0f, 0x0221121f },
2629 { 0x10, 0x03451340 },
2630 { 0x11, 0x40c003f2 },
2631 { 0x15, 0x508003f3 },
2632 { 0x1b, 0x405003f4 },
2633 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002634};
2635
Takashi Iwai0a427842013-01-14 15:20:13 +01002636static const struct hda_pintbl d945gtp3_pin_configs[] = {
2637 { 0x0a, 0x0221401f },
2638 { 0x0b, 0x01a19022 },
2639 { 0x0c, 0x01813021 },
2640 { 0x0d, 0x01014010 },
2641 { 0x0e, 0x40000100 },
2642 { 0x0f, 0x40000100 },
2643 { 0x10, 0x40000100 },
2644 { 0x11, 0x40000100 },
2645 { 0x15, 0x02a19120 },
2646 { 0x1b, 0x40000100 },
2647 {}
Matt Porter403d1942005-11-29 15:00:51 +01002648};
2649
Takashi Iwai0a427842013-01-14 15:20:13 +01002650static const struct hda_pintbl d945gtp5_pin_configs[] = {
2651 { 0x0a, 0x0221401f },
2652 { 0x0b, 0x01011012 },
2653 { 0x0c, 0x01813024 },
2654 { 0x0d, 0x01014010 },
2655 { 0x0e, 0x01a19021 },
2656 { 0x0f, 0x01016011 },
2657 { 0x10, 0x01452130 },
2658 { 0x11, 0x40000100 },
2659 { 0x15, 0x02a19320 },
2660 { 0x1b, 0x40000100 },
2661 {}
Matt Porter403d1942005-11-29 15:00:51 +01002662};
2663
Takashi Iwai0a427842013-01-14 15:20:13 +01002664static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2665 { 0x0a, 0x0121e21f },
2666 { 0x0b, 0x400000ff },
2667 { 0x0c, 0x9017e110 },
2668 { 0x0d, 0x400000fd },
2669 { 0x0e, 0x400000fe },
2670 { 0x0f, 0x0181e020 },
2671 { 0x10, 0x1145e030 },
2672 { 0x11, 0x11c5e240 },
2673 { 0x15, 0x400000fc },
2674 { 0x1b, 0x400000fb },
2675 {}
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002676};
2677
Takashi Iwai0a427842013-01-14 15:20:13 +01002678static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2679 { 0x0a, 0x0121e21f },
2680 { 0x0b, 0x90a7012e },
2681 { 0x0c, 0x9017e110 },
2682 { 0x0d, 0x400000fd },
2683 { 0x0e, 0x400000fe },
2684 { 0x0f, 0x0181e020 },
2685 { 0x10, 0x1145e230 },
2686 { 0x11, 0x500000fa },
2687 { 0x15, 0x400000fc },
2688 { 0x1b, 0x400000fb },
2689 {}
Sylvain FORETf16928f2007-04-27 14:22:36 +02002690};
2691
Takashi Iwai0a427842013-01-14 15:20:13 +01002692static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2693 { 0x0a, 0x0121e21f },
2694 { 0x0b, 0x90a7012e },
2695 { 0x0c, 0x9017e110 },
2696 { 0x0d, 0x400000fd },
2697 { 0x0e, 0x400000fe },
2698 { 0x0f, 0x0181e020 },
2699 { 0x10, 0x1145e230 },
2700 { 0x11, 0x11c5e240 },
2701 { 0x15, 0x400000fc },
2702 { 0x1b, 0x400000fb },
2703 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002704};
2705
Takashi Iwai0a427842013-01-14 15:20:13 +01002706static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2707 { 0x0a, 0x0321e21f },
2708 { 0x0b, 0x03a1e02e },
2709 { 0x0c, 0x9017e110 },
2710 { 0x0d, 0x9017e11f },
2711 { 0x0e, 0x400000fe },
2712 { 0x0f, 0x0381e020 },
2713 { 0x10, 0x1345e230 },
2714 { 0x11, 0x13c5e240 },
2715 { 0x15, 0x400000fc },
2716 { 0x1b, 0x400000fb },
2717 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002718};
2719
Takashi Iwai0a427842013-01-14 15:20:13 +01002720static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2721 { 0x0a, 0x0321e21f },
2722 { 0x0b, 0x03a1e02e },
2723 { 0x0c, 0x9017e110 },
2724 { 0x0d, 0x9017e11f },
2725 { 0x0e, 0x400000fe },
2726 { 0x0f, 0x0381e020 },
2727 { 0x10, 0x1345e230 },
2728 { 0x11, 0x13c5e240 },
2729 { 0x15, 0x400000fc },
2730 { 0x1b, 0x400000fb },
2731 {}
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002732};
2733
Takashi Iwai0a427842013-01-14 15:20:13 +01002734static const struct hda_pintbl ecs202_pin_configs[] = {
2735 { 0x0a, 0x0221401f },
2736 { 0x0b, 0x02a19020 },
2737 { 0x0c, 0x01a19020 },
2738 { 0x0d, 0x01114010 },
2739 { 0x0e, 0x408000f0 },
2740 { 0x0f, 0x01813022 },
2741 { 0x10, 0x074510a0 },
2742 { 0x11, 0x40c400f1 },
2743 { 0x15, 0x9037012e },
2744 { 0x1b, 0x40e000f2 },
2745 {}
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002746};
Takashi Iwai76c08822007-06-19 12:17:42 +02002747
Takashi Iwai0a427842013-01-14 15:20:13 +01002748/* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2749static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2750 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2751 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2752 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2753 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2754 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2755 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2756 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2757 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2758 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2759 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2760 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2761 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2762 {}
2763};
2764
2765static const struct hda_fixup stac922x_fixups[];
2766
2767/* remap the fixup from codec SSID and apply it */
2768static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2769 const struct hda_fixup *fix,
2770 int action)
2771{
2772 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2773 return;
2774 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2775 stac922x_fixups);
2776 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2777 snd_hda_apply_fixup(codec, action);
2778}
2779
2780static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2781 const struct hda_fixup *fix,
2782 int action)
2783{
2784 struct sigmatel_spec *spec = codec->spec;
2785
2786 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2787 spec->gpio_mask = spec->gpio_dir = 0x03;
2788 spec->gpio_data = 0x03;
2789 }
2790}
2791
2792static const struct hda_fixup stac922x_fixups[] = {
2793 [STAC_D945_REF] = {
2794 .type = HDA_FIXUP_PINS,
2795 .v.pins = ref922x_pin_configs,
2796 },
2797 [STAC_D945GTP3] = {
2798 .type = HDA_FIXUP_PINS,
2799 .v.pins = d945gtp3_pin_configs,
2800 },
2801 [STAC_D945GTP5] = {
2802 .type = HDA_FIXUP_PINS,
2803 .v.pins = d945gtp5_pin_configs,
2804 },
2805 [STAC_INTEL_MAC_AUTO] = {
2806 .type = HDA_FIXUP_FUNC,
2807 .v.func = stac922x_fixup_intel_mac_auto,
2808 },
2809 [STAC_INTEL_MAC_V1] = {
2810 .type = HDA_FIXUP_PINS,
2811 .v.pins = intel_mac_v1_pin_configs,
2812 .chained = true,
2813 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2814 },
2815 [STAC_INTEL_MAC_V2] = {
2816 .type = HDA_FIXUP_PINS,
2817 .v.pins = intel_mac_v2_pin_configs,
2818 .chained = true,
2819 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2820 },
2821 [STAC_INTEL_MAC_V3] = {
2822 .type = HDA_FIXUP_PINS,
2823 .v.pins = intel_mac_v3_pin_configs,
2824 .chained = true,
2825 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2826 },
2827 [STAC_INTEL_MAC_V4] = {
2828 .type = HDA_FIXUP_PINS,
2829 .v.pins = intel_mac_v4_pin_configs,
2830 .chained = true,
2831 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2832 },
2833 [STAC_INTEL_MAC_V5] = {
2834 .type = HDA_FIXUP_PINS,
2835 .v.pins = intel_mac_v5_pin_configs,
2836 .chained = true,
2837 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2838 },
2839 [STAC_922X_INTEL_MAC_GPIO] = {
2840 .type = HDA_FIXUP_FUNC,
2841 .v.func = stac922x_fixup_intel_mac_gpio,
2842 },
2843 [STAC_ECS_202] = {
2844 .type = HDA_FIXUP_PINS,
2845 .v.pins = ecs202_pin_configs,
2846 },
2847 [STAC_922X_DELL_D81] = {
2848 .type = HDA_FIXUP_PINS,
2849 .v.pins = dell_922x_d81_pin_configs,
2850 },
2851 [STAC_922X_DELL_D82] = {
2852 .type = HDA_FIXUP_PINS,
2853 .v.pins = dell_922x_d82_pin_configs,
2854 },
2855 [STAC_922X_DELL_M81] = {
2856 .type = HDA_FIXUP_PINS,
2857 .v.pins = dell_922x_m81_pin_configs,
2858 },
2859 [STAC_922X_DELL_M82] = {
2860 .type = HDA_FIXUP_PINS,
2861 .v.pins = dell_922x_m82_pin_configs,
2862 },
2863};
2864
2865static const struct hda_model_fixup stac922x_models[] = {
2866 { .id = STAC_D945_REF, .name = "ref" },
2867 { .id = STAC_D945GTP5, .name = "5stack" },
2868 { .id = STAC_D945GTP3, .name = "3stack" },
2869 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
2870 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
2871 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
2872 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
2873 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
2874 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
2875 { .id = STAC_ECS_202, .name = "ecs202" },
2876 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
2877 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
2878 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
2879 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002880 /* for backward compatibility */
Takashi Iwai0a427842013-01-14 15:20:13 +01002881 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
2882 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
2883 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
2884 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
2885 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
2886 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
2887 {}
Matt Porter403d1942005-11-29 15:00:51 +01002888};
2889
Takashi Iwai0a427842013-01-14 15:20:13 +01002890static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002891 /* SigmaTel reference board */
2892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2893 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002894 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2895 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002896 /* Intel 945G based systems */
2897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2898 "Intel D945G", STAC_D945GTP3),
2899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2900 "Intel D945G", STAC_D945GTP3),
2901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2902 "Intel D945G", STAC_D945GTP3),
2903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2904 "Intel D945G", STAC_D945GTP3),
2905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2906 "Intel D945G", STAC_D945GTP3),
2907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2908 "Intel D945G", STAC_D945GTP3),
2909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2910 "Intel D945G", STAC_D945GTP3),
2911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2912 "Intel D945G", STAC_D945GTP3),
2913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2914 "Intel D945G", STAC_D945GTP3),
2915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2916 "Intel D945G", STAC_D945GTP3),
2917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2918 "Intel D945G", STAC_D945GTP3),
2919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2920 "Intel D945G", STAC_D945GTP3),
2921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2922 "Intel D945G", STAC_D945GTP3),
2923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2924 "Intel D945G", STAC_D945GTP3),
2925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2926 "Intel D945G", STAC_D945GTP3),
2927 /* Intel D945G 5-stack systems */
2928 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2929 "Intel D945G", STAC_D945GTP5),
2930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2931 "Intel D945G", STAC_D945GTP5),
2932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2933 "Intel D945G", STAC_D945GTP5),
2934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2935 "Intel D945G", STAC_D945GTP5),
2936 /* Intel 945P based systems */
2937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2938 "Intel D945P", STAC_D945GTP3),
2939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2940 "Intel D945P", STAC_D945GTP3),
2941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2942 "Intel D945P", STAC_D945GTP3),
2943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2944 "Intel D945P", STAC_D945GTP3),
2945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2946 "Intel D945P", STAC_D945GTP3),
2947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2948 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002949 /* other intel */
2950 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2951 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002952 /* other systems */
Takashi Iwai0a427842013-01-14 15:20:13 +01002953
Nicolas Boichat536319a2008-07-21 22:18:01 +08002954 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwai0a427842013-01-14 15:20:13 +01002955 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
2956
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002957 /* Dell systems */
2958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2959 "unknown Dell", STAC_922X_DELL_D81),
2960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2961 "unknown Dell", STAC_922X_DELL_D81),
2962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2963 "unknown Dell", STAC_922X_DELL_D81),
2964 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2965 "unknown Dell", STAC_922X_DELL_D82),
2966 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2967 "unknown Dell", STAC_922X_DELL_M81),
2968 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2969 "unknown Dell", STAC_922X_DELL_D82),
2970 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2971 "unknown Dell", STAC_922X_DELL_D81),
2972 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2973 "unknown Dell", STAC_922X_DELL_D81),
2974 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2975 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002976 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002977 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002978 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002979 {} /* terminator */
2980};
2981
Takashi Iwai29ac8362013-01-14 16:03:38 +01002982static const struct hda_pintbl ref927x_pin_configs[] = {
2983 { 0x0a, 0x02214020 },
2984 { 0x0b, 0x02a19080 },
2985 { 0x0c, 0x0181304e },
2986 { 0x0d, 0x01014010 },
2987 { 0x0e, 0x01a19040 },
2988 { 0x0f, 0x01011012 },
2989 { 0x10, 0x01016011 },
2990 { 0x11, 0x0101201f },
2991 { 0x12, 0x183301f0 },
2992 { 0x13, 0x18a001f0 },
2993 { 0x14, 0x18a001f0 },
2994 { 0x21, 0x01442070 },
2995 { 0x22, 0x01c42190 },
2996 { 0x23, 0x40000100 },
2997 {}
Matt Porter3cc08dc2006-01-23 15:27:49 +01002998};
2999
Takashi Iwai29ac8362013-01-14 16:03:38 +01003000static const struct hda_pintbl d965_3st_pin_configs[] = {
3001 { 0x0a, 0x0221401f },
3002 { 0x0b, 0x02a19120 },
3003 { 0x0c, 0x40000100 },
3004 { 0x0d, 0x01014011 },
3005 { 0x0e, 0x01a19021 },
3006 { 0x0f, 0x01813024 },
3007 { 0x10, 0x40000100 },
3008 { 0x11, 0x40000100 },
3009 { 0x12, 0x40000100 },
3010 { 0x13, 0x40000100 },
3011 { 0x14, 0x40000100 },
3012 { 0x21, 0x40000100 },
3013 { 0x22, 0x40000100 },
3014 { 0x23, 0x40000100 },
3015 {}
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003016};
3017
Takashi Iwai29ac8362013-01-14 16:03:38 +01003018static const struct hda_pintbl d965_5st_pin_configs[] = {
3019 { 0x0a, 0x02214020 },
3020 { 0x0b, 0x02a19080 },
3021 { 0x0c, 0x0181304e },
3022 { 0x0d, 0x01014010 },
3023 { 0x0e, 0x01a19040 },
3024 { 0x0f, 0x01011012 },
3025 { 0x10, 0x01016011 },
3026 { 0x11, 0x40000100 },
3027 { 0x12, 0x40000100 },
3028 { 0x13, 0x40000100 },
3029 { 0x14, 0x40000100 },
3030 { 0x21, 0x01442070 },
3031 { 0x22, 0x40000100 },
3032 { 0x23, 0x40000100 },
3033 {}
Tobin Davis93ed1502006-09-01 21:03:12 +02003034};
3035
Takashi Iwai29ac8362013-01-14 16:03:38 +01003036static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
3037 { 0x0a, 0x40000100 },
3038 { 0x0b, 0x40000100 },
3039 { 0x0c, 0x0181304e },
3040 { 0x0d, 0x01014010 },
3041 { 0x0e, 0x01a19040 },
3042 { 0x0f, 0x01011012 },
3043 { 0x10, 0x01016011 },
3044 { 0x11, 0x40000100 },
3045 { 0x12, 0x40000100 },
3046 { 0x13, 0x40000100 },
3047 { 0x14, 0x40000100 },
3048 { 0x21, 0x01442070 },
3049 { 0x22, 0x40000100 },
3050 { 0x23, 0x40000100 },
3051 {}
Takashi Iwai679d92e2009-05-24 19:00:08 +02003052};
3053
Takashi Iwai29ac8362013-01-14 16:03:38 +01003054static const struct hda_pintbl dell_3st_pin_configs[] = {
3055 { 0x0a, 0x02211230 },
3056 { 0x0b, 0x02a11220 },
3057 { 0x0c, 0x01a19040 },
3058 { 0x0d, 0x01114210 },
3059 { 0x0e, 0x01111212 },
3060 { 0x0f, 0x01116211 },
3061 { 0x10, 0x01813050 },
3062 { 0x11, 0x01112214 },
3063 { 0x12, 0x403003fa },
3064 { 0x13, 0x90a60040 },
3065 { 0x14, 0x90a60040 },
3066 { 0x21, 0x404003fb },
3067 { 0x22, 0x40c003fc },
3068 { 0x23, 0x40000100 },
3069 {}
Tobin Davis4ff076e2007-08-07 11:48:12 +02003070};
3071
Takashi Iwai29ac8362013-01-14 16:03:38 +01003072static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
3073 const struct hda_fixup *fix, int action)
3074{
3075 struct sigmatel_spec *spec = codec->spec;
3076
3077 /* no jack detecion for ref-no-jd model */
3078 if (action == HDA_FIXUP_ACT_PROBE)
3079 spec->hp_detect = 0;
3080}
3081
3082static void stac927x_fixup_ref(struct hda_codec *codec,
3083 const struct hda_fixup *fix, int action)
3084{
3085 struct sigmatel_spec *spec = codec->spec;
3086
3087 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3088 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
3089 spec->eapd_mask = spec->gpio_mask = 0;
3090 spec->gpio_dir = spec->gpio_data = 0;
3091 }
3092}
3093
3094static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
3095 const struct hda_fixup *fix, int action)
3096{
3097 struct sigmatel_spec *spec = codec->spec;
3098
3099 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3100 return;
3101
3102 if (codec->subsystem_id != 0x1028022f) {
3103 /* GPIO2 High = Enable EAPD */
3104 spec->eapd_mask = spec->gpio_mask = 0x04;
3105 spec->gpio_dir = spec->gpio_data = 0x04;
3106 }
3107 spec->dmic_nids = stac927x_dmic_nids;
3108 spec->num_dmics = STAC927X_NUM_DMICS;
3109
3110 snd_hda_add_verbs(codec, dell_3st_core_init);
3111 spec->volknob_init = 1;
3112 spec->dmux_nids = stac927x_dmux_nids;
3113 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3114}
3115
3116static void stac927x_fixup_volknob(struct hda_codec *codec,
3117 const struct hda_fixup *fix, int action)
3118{
3119 struct sigmatel_spec *spec = codec->spec;
3120
3121 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3122 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
3123 spec->volknob_init = 1;
3124 }
3125}
3126
3127static const struct hda_fixup stac927x_fixups[] = {
3128 [STAC_D965_REF_NO_JD] = {
3129 .type = HDA_FIXUP_FUNC,
3130 .v.func = stac927x_fixup_ref_no_jd,
3131 .chained = true,
3132 .chain_id = STAC_D965_REF,
3133 },
3134 [STAC_D965_REF] = {
3135 .type = HDA_FIXUP_FUNC,
3136 .v.func = stac927x_fixup_ref,
3137 },
3138 [STAC_D965_3ST] = {
3139 .type = HDA_FIXUP_PINS,
3140 .v.pins = d965_3st_pin_configs,
3141 .chained = true,
3142 .chain_id = STAC_D965_VERBS,
3143 },
3144 [STAC_D965_5ST] = {
3145 .type = HDA_FIXUP_PINS,
3146 .v.pins = d965_5st_pin_configs,
3147 .chained = true,
3148 .chain_id = STAC_D965_VERBS,
3149 },
3150 [STAC_D965_VERBS] = {
3151 .type = HDA_FIXUP_VERBS,
3152 .v.verbs = d965_core_init,
3153 },
3154 [STAC_D965_5ST_NO_FP] = {
3155 .type = HDA_FIXUP_PINS,
3156 .v.pins = d965_5st_no_fp_pin_configs,
3157 },
3158 [STAC_DELL_3ST] = {
3159 .type = HDA_FIXUP_PINS,
3160 .v.pins = dell_3st_pin_configs,
3161 .chained = true,
3162 .chain_id = STAC_927X_DELL_DMIC,
3163 },
3164 [STAC_DELL_BIOS] = {
3165 .type = HDA_FIXUP_PINS,
3166 .v.pins = (const struct hda_pintbl[]) {
3167 /* configure the analog microphone on some laptops */
3168 { 0x0c, 0x90a79130 },
3169 /* correct the front output jack as a hp out */
3170 { 0x0f, 0x0227011f },
3171 /* correct the front input jack as a mic */
3172 { 0x0e, 0x02a79130 },
3173 {}
3174 },
3175 .chained = true,
3176 .chain_id = STAC_927X_DELL_DMIC,
3177 },
3178 [STAC_DELL_BIOS_SPDIF] = {
3179 .type = HDA_FIXUP_PINS,
3180 .v.pins = (const struct hda_pintbl[]) {
3181 /* correct the device field to SPDIF out */
3182 { 0x21, 0x01442070 },
3183 {}
3184 },
3185 .chained = true,
3186 .chain_id = STAC_DELL_BIOS,
3187 },
3188 [STAC_927X_DELL_DMIC] = {
3189 .type = HDA_FIXUP_FUNC,
3190 .v.func = stac927x_fixup_dell_dmic,
3191 },
3192 [STAC_927X_VOLKNOB] = {
3193 .type = HDA_FIXUP_FUNC,
3194 .v.func = stac927x_fixup_volknob,
3195 },
Matt Porter3cc08dc2006-01-23 15:27:49 +01003196};
3197
Takashi Iwai29ac8362013-01-14 16:03:38 +01003198static const struct hda_model_fixup stac927x_models[] = {
3199 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3200 { .id = STAC_D965_REF, .name = "ref" },
3201 { .id = STAC_D965_3ST, .name = "3stack" },
3202 { .id = STAC_D965_5ST, .name = "5stack" },
3203 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3204 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3205 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3206 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3207 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003208};
3209
Takashi Iwai29ac8362013-01-14 16:03:38 +01003210static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003211 /* SigmaTel reference board */
3212 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3213 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003214 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3215 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003216 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003217 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3218 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02003219 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003220 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3221 "Intel D965", STAC_D965_3ST),
3222 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3223 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003224 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003225 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
3227 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003228 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003229 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04003230 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003231 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003232 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
Chengu Wang84d3dc22009-07-30 19:43:55 +08003233 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003234 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
3235 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
3236 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003237 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
Tobin Davis93ed1502006-09-01 21:03:12 +02003238 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003239 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3240 "Intel D965", STAC_D965_5ST),
3241 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3242 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02003243 /* volume-knob fixes */
3244 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01003245 {} /* terminator */
3246};
3247
Takashi Iwaife6322c2013-01-14 14:46:51 +01003248static const struct hda_pintbl ref9205_pin_configs[] = {
3249 { 0x0a, 0x40000100 },
3250 { 0x0b, 0x40000100 },
3251 { 0x0c, 0x01016011 },
3252 { 0x0d, 0x01014010 },
3253 { 0x0e, 0x01813122 },
3254 { 0x0f, 0x01a19021 },
3255 { 0x14, 0x01019020 },
3256 { 0x16, 0x40000100 },
3257 { 0x17, 0x90a000f0 },
3258 { 0x18, 0x90a000f0 },
3259 { 0x21, 0x01441030 },
3260 { 0x22, 0x01c41030 },
3261 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003262};
3263
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003264/*
3265 STAC 9205 pin configs for
3266 102801F1
3267 102801F2
3268 102801FC
3269 102801FD
3270 10280204
3271 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003272 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01003273 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003274*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003275static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3276 { 0x0a, 0x0321101F },
3277 { 0x0b, 0x03A11020 },
3278 { 0x0c, 0x400003FA },
3279 { 0x0d, 0x90170310 },
3280 { 0x0e, 0x400003FB },
3281 { 0x0f, 0x400003FC },
3282 { 0x14, 0x400003FD },
3283 { 0x16, 0x40F000F9 },
3284 { 0x17, 0x90A60330 },
3285 { 0x18, 0x400003FF },
3286 { 0x21, 0x0144131F },
3287 { 0x22, 0x40C003FE },
3288 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003289};
3290
3291/*
3292 STAC 9205 pin configs for
3293 102801F9
3294 102801FA
3295 102801FE
3296 102801FF (Dell Precision M4300)
3297 10280206
3298 10280200
3299 10280201
3300*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003301static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3302 { 0x0a, 0x0321101f },
3303 { 0x0b, 0x03a11020 },
3304 { 0x0c, 0x90a70330 },
3305 { 0x0d, 0x90170310 },
3306 { 0x0e, 0x400000fe },
3307 { 0x0f, 0x400000ff },
3308 { 0x14, 0x400000fd },
3309 { 0x16, 0x40f000f9 },
3310 { 0x17, 0x400000fa },
3311 { 0x18, 0x400000fc },
3312 { 0x21, 0x0144131f },
3313 { 0x22, 0x40c003f8 },
3314 /* Enable SPDIF in/out */
3315 { 0x1f, 0x01441030 },
3316 { 0x20, 0x1c410030 },
3317 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003318};
3319
Takashi Iwaife6322c2013-01-14 14:46:51 +01003320static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3321 { 0x0a, 0x0421101f },
3322 { 0x0b, 0x04a11020 },
3323 { 0x0c, 0x400003fa },
3324 { 0x0d, 0x90170310 },
3325 { 0x0e, 0x400003fb },
3326 { 0x0f, 0x400003fc },
3327 { 0x14, 0x400003fd },
3328 { 0x16, 0x400003f9 },
3329 { 0x17, 0x90a60330 },
3330 { 0x18, 0x400003ff },
3331 { 0x21, 0x01441340 },
3332 { 0x22, 0x40c003fe },
3333 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003334};
3335
Takashi Iwaife6322c2013-01-14 14:46:51 +01003336static void stac9205_fixup_ref(struct hda_codec *codec,
3337 const struct hda_fixup *fix, int action)
3338{
3339 struct sigmatel_spec *spec = codec->spec;
3340
3341 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3342 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3343 /* SPDIF-In enabled */
3344 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3345 }
3346}
3347
Takashi Iwaife6322c2013-01-14 14:46:51 +01003348static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3349 const struct hda_fixup *fix, int action)
3350{
3351 struct sigmatel_spec *spec = codec->spec;
3352 int err;
3353
3354 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3355 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3356
3357 /* Enable unsol response for GPIO4/Dock HP connection */
3358 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
3359 if (err < 0)
3360 return;
3361 snd_hda_codec_write_cache(codec, codec->afg, 0,
3362 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3363 snd_hda_jack_detect_enable(codec, codec->afg, 0);
3364
3365 spec->gpio_dir = 0x0b;
3366 spec->eapd_mask = 0x01;
3367 spec->gpio_mask = 0x1b;
3368 spec->gpio_mute = 0x10;
3369 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3370 * GPIO3 Low = DRM
3371 */
3372 spec->gpio_data = 0x01;
3373 }
3374}
3375
3376static void stac9205_fixup_eapd(struct hda_codec *codec,
3377 const struct hda_fixup *fix, int action)
3378{
3379 struct sigmatel_spec *spec = codec->spec;
3380
3381 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3382 spec->eapd_switch = 0;
3383}
3384
3385static const struct hda_fixup stac9205_fixups[] = {
3386 [STAC_9205_REF] = {
3387 .type = HDA_FIXUP_FUNC,
3388 .v.func = stac9205_fixup_ref,
3389 },
3390 [STAC_9205_DELL_M42] = {
3391 .type = HDA_FIXUP_PINS,
3392 .v.pins = dell_9205_m42_pin_configs,
3393 },
3394 [STAC_9205_DELL_M43] = {
3395 .type = HDA_FIXUP_FUNC,
3396 .v.func = stac9205_fixup_dell_m43,
3397 },
3398 [STAC_9205_DELL_M44] = {
3399 .type = HDA_FIXUP_PINS,
3400 .v.pins = dell_9205_m44_pin_configs,
3401 },
3402 [STAC_9205_EAPD] = {
3403 .type = HDA_FIXUP_FUNC,
3404 .v.func = stac9205_fixup_eapd,
3405 },
3406 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003407};
3408
Takashi Iwaife6322c2013-01-14 14:46:51 +01003409static const struct hda_model_fixup stac9205_models[] = {
3410 { .id = STAC_9205_REF, .name = "ref" },
3411 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3412 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3413 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3414 { .id = STAC_9205_EAPD, .name = "eapd" },
3415 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003416};
3417
Takashi Iwaife6322c2013-01-14 14:46:51 +01003418static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003419 /* SigmaTel reference board */
3420 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3421 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03003422 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3423 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003424 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3425 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003426 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003427 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3428 "unknown Dell", STAC_9205_DELL_M42),
3429 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3430 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003431 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02003432 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003433 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3434 "Dell Precision", STAC_9205_DELL_M43),
3435 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3436 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003437 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3438 "unknown Dell", STAC_9205_DELL_M42),
3439 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3440 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003441 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3442 "Dell Precision", STAC_9205_DELL_M43),
3443 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003444 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003445 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3446 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02003447 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3448 "Dell Precision", STAC_9205_DELL_M43),
3449 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3450 "Dell Precision", STAC_9205_DELL_M43),
3451 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3452 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003453 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3454 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003455 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3456 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01003457 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3458 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003459 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08003460 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003461 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02003462 {} /* terminator */
3463};
3464
Takashi Iwai330ee992009-02-20 14:33:36 +01003465static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003466 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02003467{
3468 int i;
3469 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02003470
Takashi Iwai330ee992009-02-20 14:33:36 +01003471 if (!pincfgs)
3472 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02003473
Matthew Ranostay87d48362007-07-17 11:52:24 +02003474 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01003475 if (spec->pin_nids[i] && pincfgs[i])
3476 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
3477 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01003478}
3479
Matt2f2f4252005-04-13 14:45:30 +02003480/*
3481 * Analog playback callbacks
3482 */
3483static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
3484 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003485 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003486{
3487 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003488 if (spec->stream_delay)
3489 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01003490 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3491 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02003492}
3493
3494static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3495 struct hda_codec *codec,
3496 unsigned int stream_tag,
3497 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003498 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003499{
3500 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01003501 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02003502}
3503
3504static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3505 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003506 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003507{
3508 struct sigmatel_spec *spec = codec->spec;
3509 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3510}
3511
3512/*
Mattdabbed62005-06-14 10:19:34 +02003513 * Digital playback callbacks
3514 */
3515static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3516 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003517 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003518{
3519 struct sigmatel_spec *spec = codec->spec;
3520 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3521}
3522
3523static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3524 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003525 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003526{
3527 struct sigmatel_spec *spec = codec->spec;
3528 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3529}
3530
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003531static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3532 struct hda_codec *codec,
3533 unsigned int stream_tag,
3534 unsigned int format,
3535 struct snd_pcm_substream *substream)
3536{
3537 struct sigmatel_spec *spec = codec->spec;
3538 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3539 stream_tag, format, substream);
3540}
3541
Takashi Iwai9411e212009-02-13 11:32:28 +01003542static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3543 struct hda_codec *codec,
3544 struct snd_pcm_substream *substream)
3545{
3546 struct sigmatel_spec *spec = codec->spec;
3547 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3548}
3549
Mattdabbed62005-06-14 10:19:34 +02003550
3551/*
Matt2f2f4252005-04-13 14:45:30 +02003552 * Analog capture callbacks
3553 */
3554static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3555 struct hda_codec *codec,
3556 unsigned int stream_tag,
3557 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003558 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003559{
3560 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003561 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003562
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003563 if (spec->powerdown_adcs) {
3564 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003565 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003566 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
3567 }
3568 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02003569 return 0;
3570}
3571
3572static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3573 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003574 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003575{
3576 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003577 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003578
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003579 snd_hda_codec_cleanup_stream(codec, nid);
3580 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003581 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003582 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02003583 return 0;
3584}
3585
Takashi Iwai2b635362011-05-02 12:33:43 +02003586static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02003587 .substreams = 1,
3588 .channels_min = 2,
3589 .channels_max = 2,
3590 /* NID is set in stac92xx_build_pcms */
3591 .ops = {
3592 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003593 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01003594 .prepare = stac92xx_dig_playback_pcm_prepare,
3595 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02003596 },
3597};
3598
Takashi Iwai2b635362011-05-02 12:33:43 +02003599static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02003600 .substreams = 1,
3601 .channels_min = 2,
3602 .channels_max = 2,
3603 /* NID is set in stac92xx_build_pcms */
3604};
3605
Takashi Iwai2b635362011-05-02 12:33:43 +02003606static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02003607 .substreams = 1,
3608 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02003609 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02003610 .nid = 0x02, /* NID to query formats and rates */
3611 .ops = {
3612 .open = stac92xx_playback_pcm_open,
3613 .prepare = stac92xx_playback_pcm_prepare,
3614 .cleanup = stac92xx_playback_pcm_cleanup
3615 },
3616};
3617
Takashi Iwai2b635362011-05-02 12:33:43 +02003618static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003619 .substreams = 1,
3620 .channels_min = 2,
3621 .channels_max = 2,
3622 .nid = 0x06, /* NID to query formats and rates */
3623 .ops = {
3624 .open = stac92xx_playback_pcm_open,
3625 .prepare = stac92xx_playback_pcm_prepare,
3626 .cleanup = stac92xx_playback_pcm_cleanup
3627 },
3628};
3629
Takashi Iwai2b635362011-05-02 12:33:43 +02003630static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02003631 .channels_min = 2,
3632 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003633 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02003634 .ops = {
3635 .prepare = stac92xx_capture_pcm_prepare,
3636 .cleanup = stac92xx_capture_pcm_cleanup
3637 },
3638};
3639
3640static int stac92xx_build_pcms(struct hda_codec *codec)
3641{
3642 struct sigmatel_spec *spec = codec->spec;
3643 struct hda_pcm *info = spec->pcm_rec;
3644
3645 codec->num_pcms = 1;
3646 codec->pcm_info = info;
3647
Mattc7d4b2f2005-06-27 14:59:41 +02003648 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02003649 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01003650 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3651 spec->multiout.dac_nids[0];
Takashi Iwaiee81abb2012-11-08 17:12:10 +01003652 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3653 spec->autocfg.line_outs == 2)
3654 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
3655 snd_pcm_2_1_chmaps;
3656
Matt2f2f4252005-04-13 14:45:30 +02003657 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003658 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003659 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003660
3661 if (spec->alt_switch) {
3662 codec->num_pcms++;
3663 info++;
3664 info->name = "STAC92xx Analog Alt";
3665 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
3666 }
Matt2f2f4252005-04-13 14:45:30 +02003667
Mattdabbed62005-06-14 10:19:34 +02003668 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3669 codec->num_pcms++;
3670 info++;
3671 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003672 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02003673 if (spec->multiout.dig_out_nid) {
3674 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
3675 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3676 }
3677 if (spec->dig_in_nid) {
3678 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
3679 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3680 }
3681 }
3682
Matt2f2f4252005-04-13 14:45:30 +02003683 return 0;
3684}
3685
Matt Porter403d1942005-11-29 15:00:51 +01003686static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
3687
3688{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02003689 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01003690}
3691
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003692#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
3693
3694static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
3695 struct snd_ctl_elem_value *ucontrol)
3696{
3697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3698 struct sigmatel_spec *spec = codec->spec;
3699
Takashi Iwaid7a89432008-11-12 09:48:04 +01003700 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003701 return 0;
3702}
3703
Takashi Iwai62558ce2009-07-29 14:23:09 +02003704static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003705
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003706static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
3707 struct snd_ctl_elem_value *ucontrol)
3708{
3709 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3710 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003711 int nid = kcontrol->private_value;
3712
3713 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003714
Lucas De Marchi25985ed2011-03-30 22:57:33 -03003715 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003716 * switch changes
3717 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02003718 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003719
3720 return 1;
3721}
3722
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003723static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
3724 struct snd_ctl_elem_info *uinfo)
3725{
3726 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02003727 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003728 "Mic In", "Line In", "Line Out"
3729 };
3730
3731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3732 struct sigmatel_spec *spec = codec->spec;
3733 hda_nid_t nid = kcontrol->private_value;
3734
3735 if (nid == spec->mic_switch || nid == spec->line_switch)
3736 i = 3;
3737 else
3738 i = 2;
3739
3740 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3741 uinfo->value.enumerated.items = i;
3742 uinfo->count = 1;
3743 if (uinfo->value.enumerated.item >= i)
3744 uinfo->value.enumerated.item = i-1;
3745 strcpy(uinfo->value.enumerated.name,
3746 texts[uinfo->value.enumerated.item]);
3747
3748 return 0;
3749}
3750
3751static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
3752 struct snd_ctl_elem_value *ucontrol)
3753{
3754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3755 hda_nid_t nid = kcontrol->private_value;
3756 unsigned int vref = stac92xx_vref_get(codec, nid);
3757
Takashi Iwai47408602012-04-20 13:06:53 +02003758 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003759 ucontrol->value.enumerated.item[0] = 0;
3760 else if (vref == AC_PINCTL_VREF_GRD)
3761 ucontrol->value.enumerated.item[0] = 1;
3762 else if (vref == AC_PINCTL_VREF_HIZ)
3763 ucontrol->value.enumerated.item[0] = 2;
3764
3765 return 0;
3766}
3767
3768static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
3769 struct snd_ctl_elem_value *ucontrol)
3770{
3771 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3772 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02003773 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003774 hda_nid_t nid = kcontrol->private_value;
3775
3776 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02003777 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003778 else if (ucontrol->value.enumerated.item[0] == 1)
3779 new_vref = AC_PINCTL_VREF_GRD;
3780 else if (ucontrol->value.enumerated.item[0] == 2)
3781 new_vref = AC_PINCTL_VREF_HIZ;
3782 else
3783 return 0;
3784
3785 if (new_vref != stac92xx_vref_get(codec, nid)) {
3786 error = stac92xx_vref_set(codec, nid, new_vref);
3787 return error;
3788 }
3789
3790 return 0;
3791}
3792
3793static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
3794 struct snd_ctl_elem_info *uinfo)
3795{
Takashi Iwai2b635362011-05-02 12:33:43 +02003796 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3798 struct sigmatel_spec *spec = codec->spec;
3799
3800 if (kcontrol->private_value == spec->line_switch)
3801 texts[0] = "Line In";
3802 else
3803 texts[0] = "Mic In";
3804 texts[1] = "Line Out";
3805 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3806 uinfo->value.enumerated.items = 2;
3807 uinfo->count = 1;
3808
3809 if (uinfo->value.enumerated.item >= 2)
3810 uinfo->value.enumerated.item = 1;
3811 strcpy(uinfo->value.enumerated.name,
3812 texts[uinfo->value.enumerated.item]);
3813
3814 return 0;
3815}
Matt Porter403d1942005-11-29 15:00:51 +01003816
3817static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3818{
3819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3820 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003821 hda_nid_t nid = kcontrol->private_value;
3822 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01003823
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003824 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01003825 return 0;
3826}
3827
3828static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3829{
3830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3831 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003832 hda_nid_t nid = kcontrol->private_value;
3833 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3834 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01003835
3836 spec->io_switch[io_idx] = val;
3837
3838 if (val)
3839 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01003840 else {
3841 unsigned int pinctl = AC_PINCTL_IN_EN;
3842 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02003843 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003844 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3845 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01003846
3847 /* check the auto-mute again: we need to mute/unmute the speaker
3848 * appropriately according to the pin direction
3849 */
3850 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02003851 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01003852
Matt Porter403d1942005-11-29 15:00:51 +01003853 return 1;
3854}
3855
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003856#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
3857
3858static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
3859 struct snd_ctl_elem_value *ucontrol)
3860{
3861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3862 struct sigmatel_spec *spec = codec->spec;
3863
3864 ucontrol->value.integer.value[0] = spec->clfe_swap;
3865 return 0;
3866}
3867
3868static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
3869 struct snd_ctl_elem_value *ucontrol)
3870{
3871 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3872 struct sigmatel_spec *spec = codec->spec;
3873 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003874 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003875
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003876 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003877 return 0;
3878
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003879 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003880
3881 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
3882 spec->clfe_swap ? 0x4 : 0x0);
3883
3884 return 1;
3885}
3886
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003887#define STAC_CODEC_HP_SWITCH(xname) \
3888 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3889 .name = xname, \
3890 .index = 0, \
3891 .info = stac92xx_hp_switch_info, \
3892 .get = stac92xx_hp_switch_get, \
3893 .put = stac92xx_hp_switch_put, \
3894 }
3895
Matt Porter403d1942005-11-29 15:00:51 +01003896#define STAC_CODEC_IO_SWITCH(xname, xpval) \
3897 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3898 .name = xname, \
3899 .index = 0, \
3900 .info = stac92xx_io_switch_info, \
3901 .get = stac92xx_io_switch_get, \
3902 .put = stac92xx_io_switch_put, \
3903 .private_value = xpval, \
3904 }
3905
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003906#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
3907 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3908 .name = xname, \
3909 .index = 0, \
3910 .info = stac92xx_clfe_switch_info, \
3911 .get = stac92xx_clfe_switch_get, \
3912 .put = stac92xx_clfe_switch_put, \
3913 .private_value = xpval, \
3914 }
Matt Porter403d1942005-11-29 15:00:51 +01003915
Mattc7d4b2f2005-06-27 14:59:41 +02003916enum {
3917 STAC_CTL_WIDGET_VOL,
3918 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003919 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01003920 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003921 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01003922 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003923 STAC_CTL_WIDGET_CLFE_SWITCH,
3924 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02003925};
3926
Takashi Iwai2b635362011-05-02 12:33:43 +02003927static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02003928 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3929 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003930 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01003931 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003932 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01003933 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003934 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003935 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02003936};
3937
3938/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01003939static struct snd_kcontrol_new *
3940stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003941 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01003942 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003943 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02003944{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003945 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02003946
Takashi Iwai603c4012008-07-30 15:01:44 +02003947 knew = snd_array_new(&spec->kctls);
3948 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01003949 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003950 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02003951 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01003952 if (!knew->name) {
3953 /* roolback */
3954 memset(knew, 0, sizeof(*knew));
3955 spec->kctls.alloced--;
3956 return NULL;
3957 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003958 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01003959 return knew;
3960}
3961
Takashi Iwai62cbde12012-09-14 11:58:54 +02003962static struct snd_kcontrol_new *
3963add_control_temp(struct sigmatel_spec *spec,
3964 const struct snd_kcontrol_new *ktemp,
3965 int idx, const char *name,
3966 unsigned long val)
3967{
3968 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
3969 HDA_SUBDEV_AMP_FLAG);
3970 if (!knew)
3971 return NULL;
3972 knew->index = idx;
3973 knew->private_value = val;
3974 return knew;
3975}
3976
Takashi Iwaie3c75962009-01-23 11:57:22 +01003977static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003978 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01003979 int idx, const char *name,
3980 unsigned long val)
3981{
Takashi Iwai62cbde12012-09-14 11:58:54 +02003982 return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM;
Mattc7d4b2f2005-06-27 14:59:41 +02003983}
3984
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003985static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
3986 int type, int idx, const char *name,
3987 unsigned long val)
3988{
3989 return stac92xx_add_control_temp(spec,
3990 &stac92xx_control_templates[type],
3991 idx, name, val);
3992}
3993
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003994
3995/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003996static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
3997 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003998{
3999 return stac92xx_add_control_idx(spec, type, 0, name, val);
4000}
4001
Takashi Iwai2b635362011-05-02 12:33:43 +02004002static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01004003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4004 .name = "Input Source",
4005 .info = stac92xx_mux_enum_info,
4006 .get = stac92xx_mux_enum_get,
4007 .put = stac92xx_mux_enum_put,
4008};
4009
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004010static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
4011 hda_nid_t nid, int idx)
4012{
4013 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4014 int control = 0;
4015 struct sigmatel_spec *spec = codec->spec;
4016 char name[22];
4017
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004018 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
David Henningsson8d032a82012-10-09 12:48:40 +02004019 if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf)
4020 != INPUT_PIN_ATTR_DOCK)
4021 return 0;
Takashi Iwai47408602012-04-20 13:06:53 +02004022 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004023 && nid == spec->line_switch)
4024 control = STAC_CTL_WIDGET_IO_SWITCH;
4025 else if (snd_hda_query_pin_caps(codec, nid)
4026 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
4027 control = STAC_CTL_WIDGET_DC_BIAS;
4028 else if (nid == spec->mic_switch)
4029 control = STAC_CTL_WIDGET_IO_SWITCH;
4030 }
4031
4032 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01004033 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4034 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004035 return stac92xx_add_control(codec->spec, control,
4036 strcat(name, " Jack Mode"), nid);
4037 }
4038
4039 return 0;
4040}
4041
Takashi Iwaie3c75962009-01-23 11:57:22 +01004042static int stac92xx_add_input_source(struct sigmatel_spec *spec)
4043{
4044 struct snd_kcontrol_new *knew;
4045 struct hda_input_mux *imux = &spec->private_imux;
4046
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004047 if (spec->auto_mic)
4048 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01004049 if (!spec->num_adcs || imux->num_items <= 1)
4050 return 0; /* no need for input source control */
4051 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004052 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01004053 if (!knew)
4054 return -ENOMEM;
4055 knew->count = spec->num_adcs;
4056 return 0;
4057}
4058
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004059/* check whether the line-input can be used as line-out */
4060static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01004061{
4062 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004063 struct auto_pin_cfg *cfg = &spec->autocfg;
4064 hda_nid_t nid;
4065 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004066 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004067
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004068 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4069 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004070 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004071 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004072 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01004073 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004074 if (pincap & AC_PINCAP_OUT)
4075 return nid;
4076 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004077 }
Matt Porter403d1942005-11-29 15:00:51 +01004078 return 0;
4079}
4080
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004081static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
4082
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004083/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004084static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004085{
4086 struct sigmatel_spec *spec = codec->spec;
4087 struct auto_pin_cfg *cfg = &spec->autocfg;
4088 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02004089 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004090
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004091 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004092 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4093 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004094 for (i = 0; i < cfg->num_inputs; i++) {
4095 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02004096 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004097 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004098 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4099 /* some laptops have an internal analog microphone
4100 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004101 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004102 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004103 if (pincap & AC_PINCAP_OUT) {
4104 *dac = get_unassigned_dac(codec, nid);
4105 if (*dac)
4106 return nid;
4107 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004108 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004109 }
4110 return 0;
4111}
Steve Longerbeam7b043892007-05-03 20:50:03 +02004112
4113static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4114{
4115 int i;
4116
4117 for (i = 0; i < spec->multiout.num_dacs; i++) {
4118 if (spec->multiout.dac_nids[i] == nid)
4119 return 1;
4120 }
4121
4122 return 0;
4123}
4124
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004125static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4126{
4127 int i;
4128 if (is_in_dac_nids(spec, nid))
4129 return 1;
4130 for (i = 0; i < spec->autocfg.hp_outs; i++)
4131 if (spec->hp_dacs[i] == nid)
4132 return 1;
4133 for (i = 0; i < spec->autocfg.speaker_outs; i++)
4134 if (spec->speaker_dacs[i] == nid)
4135 return 1;
4136 return 0;
4137}
4138
4139static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
4140{
4141 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02004142 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004143 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02004144 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004145 unsigned int wcaps, wtype;
4146
4147 conn_len = snd_hda_get_connections(codec, nid, conn,
4148 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01004149 /* 92HD88: trace back up the link of nids to find the DAC */
4150 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
4151 != AC_WID_AUD_OUT)) {
4152 nid = conn[0];
4153 conn_len = snd_hda_get_connections(codec, nid, conn,
4154 HDA_MAX_CONNECTIONS);
4155 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004156 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01004157 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004158 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004159 /* we check only analog outputs */
4160 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
4161 continue;
4162 /* if this route has a free DAC, assign it */
4163 if (!check_all_dac_nids(spec, conn[j])) {
4164 if (conn_len > 1) {
4165 /* select this DAC in the pin's input mux */
4166 snd_hda_codec_write_cache(codec, nid, 0,
4167 AC_VERB_SET_CONNECT_SEL, j);
4168 }
4169 return conn[j];
4170 }
4171 }
David Henningsson48718ea2011-10-05 09:49:05 +02004172
4173 /* if all DACs are already assigned, connect to the primary DAC,
4174 unless we're assigning a secondary headphone */
4175 fallback_dac = spec->multiout.dac_nids[0];
4176 if (spec->multiout.hp_nid) {
4177 for (j = 0; j < cfg->hp_outs; j++)
4178 if (cfg->hp_pins[j] == nid) {
4179 fallback_dac = spec->multiout.hp_nid;
4180 break;
4181 }
4182 }
4183
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004184 if (conn_len > 1) {
4185 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02004186 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004187 snd_hda_codec_write_cache(codec, nid, 0,
4188 AC_VERB_SET_CONNECT_SEL, j);
4189 break;
4190 }
4191 }
4192 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004193 return 0;
4194}
4195
4196static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4197static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4198
Matt Porter3cc08dc2006-01-23 15:27:49 +01004199/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02004200 * Fill in the dac_nids table from the parsed pin configuration
4201 * This function only works when every pin in line_out_pins[]
4202 * contains atleast one DAC in its connection list. Some 92xx
4203 * codecs are not connected directly to a DAC, such as the 9200
4204 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01004205 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004206static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02004207{
4208 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004209 struct auto_pin_cfg *cfg = &spec->autocfg;
4210 int i;
4211 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004212
Mattc7d4b2f2005-06-27 14:59:41 +02004213 for (i = 0; i < cfg->line_outs; i++) {
4214 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004215 dac = get_unassigned_dac(codec, nid);
4216 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02004217 if (spec->multiout.num_dacs > 0) {
4218 /* we have already working output pins,
4219 * so let's drop the broken ones again
4220 */
4221 cfg->line_outs = spec->multiout.num_dacs;
4222 break;
4223 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004224 /* error out, no available DAC found */
4225 snd_printk(KERN_ERR
4226 "%s: No available DAC for pin 0x%x\n",
4227 __func__, nid);
4228 return -ENODEV;
4229 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004230 add_spec_dacs(spec, dac);
4231 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004232
Takashi Iwai139e0712009-03-06 12:10:41 +01004233 for (i = 0; i < cfg->hp_outs; i++) {
4234 nid = cfg->hp_pins[i];
4235 dac = get_unassigned_dac(codec, nid);
4236 if (dac) {
4237 if (!spec->multiout.hp_nid)
4238 spec->multiout.hp_nid = dac;
4239 else
4240 add_spec_extra_dacs(spec, dac);
4241 }
4242 spec->hp_dacs[i] = dac;
4243 }
4244
4245 for (i = 0; i < cfg->speaker_outs; i++) {
4246 nid = cfg->speaker_pins[i];
4247 dac = get_unassigned_dac(codec, nid);
4248 if (dac)
4249 add_spec_extra_dacs(spec, dac);
4250 spec->speaker_dacs[i] = dac;
4251 }
4252
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004253 /* add line-in as output */
4254 nid = check_line_out_switch(codec);
4255 if (nid) {
4256 dac = get_unassigned_dac(codec, nid);
4257 if (dac) {
4258 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
4259 nid, cfg->line_outs);
4260 cfg->line_out_pins[cfg->line_outs] = nid;
4261 cfg->line_outs++;
4262 spec->line_switch = nid;
4263 add_spec_dacs(spec, dac);
4264 }
4265 }
4266 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004267 nid = check_mic_out_switch(codec, &dac);
4268 if (nid && dac) {
4269 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
4270 nid, cfg->line_outs);
4271 cfg->line_out_pins[cfg->line_outs] = nid;
4272 cfg->line_outs++;
4273 spec->mic_switch = nid;
4274 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02004275 }
4276
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004277 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02004278 spec->multiout.num_dacs,
4279 spec->multiout.dac_nids[0],
4280 spec->multiout.dac_nids[1],
4281 spec->multiout.dac_nids[2],
4282 spec->multiout.dac_nids[3],
4283 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004284
Mattc7d4b2f2005-06-27 14:59:41 +02004285 return 0;
4286}
4287
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004288/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01004289static int create_controls_idx(struct hda_codec *codec, const char *pfx,
4290 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004291{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004292 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004293 char name[32];
4294 int err;
4295
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004296 if (!spec->check_volume_offset) {
4297 unsigned int caps, step, nums, db_scale;
4298 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4299 step = (caps & AC_AMPCAP_STEP_SIZE) >>
4300 AC_AMPCAP_STEP_SIZE_SHIFT;
4301 step = (step + 1) * 25; /* in .01dB unit */
4302 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
4303 AC_AMPCAP_NUM_STEPS_SHIFT;
4304 db_scale = nums * step;
4305 /* if dB scale is over -64dB, and finer enough,
4306 * let's reduce it to half
4307 */
4308 if (db_scale > 6400 && nums >= 0x1f)
4309 spec->volume_offset = nums / 2;
4310 spec->check_volume_offset = 1;
4311 }
4312
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004313 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004314 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004315 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
4316 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004317 if (err < 0)
4318 return err;
4319 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004320 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004321 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
4322 if (err < 0)
4323 return err;
4324 return 0;
4325}
4326
Takashi Iwai668b9652009-03-06 10:13:24 +01004327#define create_controls(codec, pfx, nid, chs) \
4328 create_controls_idx(codec, pfx, 0, nid, chs)
4329
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004330static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
4331{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004332 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004333 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
4334 return 1;
4335 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02004336 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
4337 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004338 spec->multiout.num_dacs++;
4339 }
4340 return 0;
4341}
4342
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004343static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004344{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004345 int i;
4346 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
4347 if (!spec->multiout.extra_out_nid[i]) {
4348 spec->multiout.extra_out_nid[i] = nid;
4349 return 0;
4350 }
4351 }
4352 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
4353 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004354}
4355
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004356/* Create output controls
4357 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
4358 */
4359static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
4360 const hda_nid_t *pins,
4361 const hda_nid_t *dac_nids,
4362 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02004363{
Takashi Iwai76624532008-12-19 10:09:47 +01004364 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01004365 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02004366 "Front", "Surround", NULL /*CLFE*/, "Side"
4367 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004368 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01004369 int i, err;
4370 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004371
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004372 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004373 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004374 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004375 spec->hp_detect = 1;
4376 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004377 nid = dac_nids[i];
4378 if (!nid)
4379 continue;
4380 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02004381 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004382 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004383 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004384 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004385 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004386 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004387 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004388
4389 wid_caps = get_wcaps(codec, nid);
4390
4391 if (wid_caps & AC_WCAP_LR_SWAP) {
4392 err = stac92xx_add_control(spec,
4393 STAC_CTL_WIDGET_CLFE_SWITCH,
4394 "Swap Center/LFE Playback Switch", nid);
4395
4396 if (err < 0)
4397 return err;
4398 }
4399
Mattc7d4b2f2005-06-27 14:59:41 +02004400 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004401 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01004402 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004403 switch (type) {
4404 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01004405 name = "Headphone";
4406 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004407 break;
4408 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01004409 if (num_outs <= 2) {
4410 name = i ? "Bass Speaker" : "Speaker";
4411 idx = 0;
David Henningsson298efee2012-09-06 11:17:58 +02004412 break;
4413 }
4414 /* Fall through in case of multi speaker outs */
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004415 default:
4416 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01004417 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004418 break;
Takashi Iwai76624532008-12-19 10:09:47 +01004419 }
Takashi Iwai668b9652009-03-06 10:13:24 +01004420 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004421 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004422 return err;
4423 }
4424 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004425 return 0;
4426}
4427
Takashi Iwai62cbde12012-09-14 11:58:54 +02004428static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4429 unsigned int dir_mask, unsigned int data);
4430
4431/* hook for controlling mic-mute LED GPIO */
4432static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol,
4433 struct snd_ctl_elem_value *ucontrol)
4434{
4435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4436 struct sigmatel_spec *spec = codec->spec;
4437 int err;
4438 bool mute;
4439
4440 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4441 if (err <= 0)
4442 return err;
4443 mute = !(ucontrol->value.integer.value[0] &&
4444 ucontrol->value.integer.value[1]);
4445 if (spec->mic_mute_led_on != mute) {
4446 spec->mic_mute_led_on = mute;
4447 if (mute)
4448 spec->gpio_data |= spec->mic_mute_led_gpio;
4449 else
4450 spec->gpio_data &= ~spec->mic_mute_led_gpio;
4451 stac_gpio_set(codec, spec->gpio_mask,
4452 spec->gpio_dir, spec->gpio_data);
4453 }
4454 return err;
4455}
4456
Takashi Iwai6479c632009-07-28 18:20:25 +02004457static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
4458 unsigned long sw, int idx)
4459{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004460 struct sigmatel_spec *spec = codec->spec;
4461 struct snd_kcontrol_new *knew;
Takashi Iwai6479c632009-07-28 18:20:25 +02004462 int err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004463
Takashi Iwai6479c632009-07-28 18:20:25 +02004464 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02004465 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02004466 if (err < 0)
4467 return err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004468
4469 knew = add_control_temp(spec,
4470 &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE],
4471 idx, "Capture Switch", sw);
4472 if (!knew)
4473 return -ENOMEM;
4474 /* add a LED hook for some HP laptops */
4475 if (spec->mic_mute_led_gpio)
4476 knew->put = stac92xx_capture_sw_put_led;
4477
Takashi Iwai6479c632009-07-28 18:20:25 +02004478 return 0;
4479}
4480
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004481/* add playback controls from the parsed DAC table */
4482static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
4483 const struct auto_pin_cfg *cfg)
4484{
4485 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004486 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004487 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004488 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004489
4490 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
4491 spec->multiout.dac_nids,
4492 cfg->line_out_type);
4493 if (err < 0)
4494 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004495
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01004496 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004497 err = stac92xx_add_control(spec,
4498 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01004499 "Headphone as Line Out Switch",
4500 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004501 if (err < 0)
4502 return err;
4503 }
4504
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004505 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004506 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004507 break;
4508 nid = cfg->inputs[idx].pin;
4509 err = stac92xx_add_jack_mode_control(codec, nid, idx);
4510 if (err < 0)
4511 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01004512 }
Matt Porter403d1942005-11-29 15:00:51 +01004513
Mattc7d4b2f2005-06-27 14:59:41 +02004514 return 0;
4515}
4516
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004517/* add playback controls for Speaker and HP outputs */
4518static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
4519 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02004520{
4521 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004522 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02004523
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004524 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
4525 spec->hp_dacs, AUTO_PIN_HP_OUT);
4526 if (err < 0)
4527 return err;
4528
4529 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
4530 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
4531 if (err < 0)
4532 return err;
4533
Mattc7d4b2f2005-06-27 14:59:41 +02004534 return 0;
4535}
4536
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004537/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004538static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004539 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004540};
4541
4542/* create mono mux for mono out on capable codecs */
4543static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
4544{
4545 struct sigmatel_spec *spec = codec->spec;
4546 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
4547 int i, num_cons;
4548 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
4549
4550 num_cons = snd_hda_get_connections(codec,
4551 spec->mono_nid,
4552 con_lst,
4553 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004554 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004555 return -EINVAL;
4556
Takashi Iwai10a20af2010-09-09 16:28:02 +02004557 for (i = 0; i < num_cons; i++)
4558 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
4559 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004560
4561 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
4562 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004563}
4564
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004565/* create PC beep volume controls */
4566static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
4567 hda_nid_t nid)
4568{
4569 struct sigmatel_spec *spec = codec->spec;
4570 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004571 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
4572
4573 if (spec->anabeep_nid == nid)
4574 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004575
4576 /* check for mute support for the the amp */
4577 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004578 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004579 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004580 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4581 if (err < 0)
4582 return err;
4583 }
4584
4585 /* check to see if there is volume support for the amp */
4586 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4587 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004588 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004589 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4590 if (err < 0)
4591 return err;
4592 }
4593 return 0;
4594}
4595
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004596#ifdef CONFIG_SND_HDA_INPUT_BEEP
4597#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
4598
4599static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
4600 struct snd_ctl_elem_value *ucontrol)
4601{
4602 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4603 ucontrol->value.integer.value[0] = codec->beep->enabled;
4604 return 0;
4605}
4606
4607static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
4608 struct snd_ctl_elem_value *ucontrol)
4609{
4610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004611 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004612}
4613
Takashi Iwai2b635362011-05-02 12:33:43 +02004614static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4616 .info = stac92xx_dig_beep_switch_info,
4617 .get = stac92xx_dig_beep_switch_get,
4618 .put = stac92xx_dig_beep_switch_put,
4619};
4620
4621static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
4622{
4623 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004624 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004625}
4626#endif
4627
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004628static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
4629{
4630 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02004631 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004632
4633 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004634 hda_nid_t nid;
4635 unsigned int wcaps;
4636 unsigned long val;
4637
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004638 nid = spec->mux_nids[i];
4639 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02004640 if (!(wcaps & AC_WCAP_OUT_AMP))
4641 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004642
Takashi Iwai667067d2009-08-13 18:14:42 +02004643 /* check whether already the same control was created as
4644 * normal Capture Volume.
4645 */
4646 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4647 for (j = 0; j < spec->num_caps; j++) {
4648 if (spec->capvols[j] == val)
4649 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004650 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004651 if (j < spec->num_caps)
4652 continue;
4653
4654 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
4655 "Mux Capture Volume", val);
4656 if (err < 0)
4657 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004658 }
4659 return 0;
4660};
4661
Takashi Iwaiea734962011-01-17 11:29:34 +01004662static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04004663 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02004664};
4665
4666static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
4667{
4668 struct sigmatel_spec *spec = codec->spec;
4669 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01004670 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004671 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04004672 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02004673
4674 num_cons = snd_hda_get_connections(codec,
4675 spec->smux_nids[0],
4676 con_lst,
4677 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004678 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02004679 return -EINVAL;
4680
Matthew Ranostay65973632008-09-16 10:39:37 -04004681 if (!labels)
4682 labels = stac92xx_spdif_labels;
4683
Takashi Iwai10a20af2010-09-09 16:28:02 +02004684 for (i = 0; i < num_cons; i++)
4685 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004686
4687 return 0;
4688}
4689
Matt Porter8b657272006-10-26 17:12:59 +02004690/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004691static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02004692 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
4693 "Digital Mic 3", "Digital Mic 4"
4694};
4695
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004696static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
4697 int idx)
4698{
4699 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4700 int nums;
4701 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
4702 if (idx >= 0 && idx < nums)
4703 return conn[idx];
4704 return 0;
4705}
4706
Takashi Iwai8d087c72011-06-28 12:45:47 +02004707/* look for NID recursively */
4708#define get_connection_index(codec, mux, nid) \
4709 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004710
Takashi Iwai667067d2009-08-13 18:14:42 +02004711/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02004712/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02004713static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004714 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02004715{
4716 unsigned int caps, nums;
4717 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02004718 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02004719
Takashi Iwai96f845d2009-08-29 00:49:36 +02004720 if (direction == HDA_OUTPUT)
4721 caps = AC_WCAP_OUT_AMP;
4722 else
4723 caps = AC_WCAP_IN_AMP;
4724 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02004725 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004726 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02004727 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
4728 if (!nums)
4729 return 0;
4730 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004731 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
4732 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02004733 if (err < 0)
4734 return err;
4735 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02004736}
4737
Matt Porter8b657272006-10-26 17:12:59 +02004738/* create playback/capture controls for input pins on dmic capable codecs */
4739static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
4740 const struct auto_pin_cfg *cfg)
4741{
4742 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02004743 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004744 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004745 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02004746 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02004747
Takashi Iwai10a20af2010-09-09 16:28:02 +02004748 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02004749
Matt Porter8b657272006-10-26 17:12:59 +02004750 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01004751 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004752 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01004753 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02004754
Takashi Iwai667067d2009-08-13 18:14:42 +02004755 nid = spec->dmic_nids[i];
4756 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
4757 continue;
4758 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02004759 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
4760 continue;
4761
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004762 index = get_connection_index(codec, spec->dmux_nids[0], nid);
4763 if (index < 0)
4764 continue;
4765
Takashi Iwai201e06f2011-11-16 15:33:26 +01004766 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4767 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02004768 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01004769 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
4770 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02004771
Takashi Iwai10a20af2010-09-09 16:28:02 +02004772 err = create_elem_capture_vol(codec, nid, label, type_idx,
4773 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004774 if (err < 0)
4775 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004776 if (!err) {
4777 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02004778 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02004779 if (err < 0)
4780 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004781 if (!err) {
4782 nid = get_connected_node(codec,
4783 spec->dmux_nids[0], index);
4784 if (nid)
4785 err = create_elem_capture_vol(codec,
4786 nid, label,
4787 type_idx, HDA_INPUT);
4788 if (err < 0)
4789 return err;
4790 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02004791 }
Matt Porter8b657272006-10-26 17:12:59 +02004792 }
4793
4794 return 0;
4795}
4796
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004797static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02004798 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004799{
4800 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004801 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004802
4803 if (!nid)
4804 return 0;
4805 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004806 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004807 switch (snd_hda_get_input_pin_attr(cfg)) {
4808 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004809 if (*fixed)
4810 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004811 if (type != AC_JACK_MIC_IN)
4812 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004813 *fixed = nid;
4814 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004815 case INPUT_PIN_ATTR_UNUSED:
4816 break;
4817 case INPUT_PIN_ATTR_DOCK:
4818 if (*dock)
4819 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004820 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
4821 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004822 *dock = nid;
4823 break;
4824 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004825 if (*ext)
4826 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004827 if (type != AC_JACK_MIC_IN)
4828 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004829 *ext = nid;
4830 break;
4831 }
4832 return 0;
4833}
4834
4835static int set_mic_route(struct hda_codec *codec,
4836 struct sigmatel_mic_route *mic,
4837 hda_nid_t pin)
4838{
4839 struct sigmatel_spec *spec = codec->spec;
4840 struct auto_pin_cfg *cfg = &spec->autocfg;
4841 int i;
4842
4843 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02004844 if (pin == 0)
4845 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004846 for (i = 0; i < cfg->num_inputs; i++) {
4847 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004848 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004849 }
Takashi Iwai86e29592010-09-09 14:50:17 +02004850 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004851 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004852 i = get_connection_index(codec, spec->mux_nids[0], pin);
4853 if (i < 0)
4854 return -1;
4855 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02004856 mic->dmux_idx = -1;
4857 if (spec->dmux_nids)
4858 mic->dmux_idx = get_connection_index(codec,
4859 spec->dmux_nids[0],
4860 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004861 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004862 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004863 i = get_connection_index(codec, spec->dmux_nids[0], pin);
4864 if (i < 0)
4865 return -1;
4866 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02004867 mic->mux_idx = -1;
4868 if (spec->mux_nids)
4869 mic->mux_idx = get_connection_index(codec,
4870 spec->mux_nids[0],
4871 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004872 }
4873 return 0;
4874}
4875
4876/* return non-zero if the device is for automatic mic switch */
4877static int stac_check_auto_mic(struct hda_codec *codec)
4878{
4879 struct sigmatel_spec *spec = codec->spec;
4880 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02004881 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004882 int i;
4883
Charles Chin99077902010-09-17 10:22:32 +02004884 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004885 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02004886 if (check_mic_pin(codec, cfg->inputs[i].pin,
4887 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004888 return 0;
4889 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02004890 if (check_mic_pin(codec, spec->dmic_nids[i],
4891 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004892 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01004893 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02004894 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004895 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004896 return 0; /* no unsol support */
4897 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02004898 set_mic_route(codec, &spec->int_mic, fixed) ||
4899 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004900 return 0; /* something is wrong */
4901 return 1;
4902}
4903
Mattc7d4b2f2005-06-27 14:59:41 +02004904/* create playback/capture controls for input pins */
4905static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
4906{
4907 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004908 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02004909 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004910 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02004911
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004912 for (i = 0; i < cfg->num_inputs; i++) {
4913 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004914 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02004915
Takashi Iwai314634b2006-09-21 11:56:18 +02004916 index = -1;
4917 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004918 index = get_connection_index(codec, spec->mux_nids[j],
4919 nid);
4920 if (index >= 0)
4921 break;
Mattc7d4b2f2005-06-27 14:59:41 +02004922 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004923 if (index < 0)
4924 continue;
4925
Takashi Iwai10a20af2010-09-09 16:28:02 +02004926 label = hda_get_autocfg_input_label(codec, cfg, i);
4927 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004928
Takashi Iwai667067d2009-08-13 18:14:42 +02004929 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004930 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02004931 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004932 if (err < 0)
4933 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004934 }
Takashi Iwai5207e102009-07-30 13:09:08 +02004935 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02004936
Steve Longerbeam7b043892007-05-03 20:50:03 +02004937 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02004938 /*
4939 * Set the current input for the muxes.
4940 * The STAC9221 has two input muxes with identical source
4941 * NID lists. Hopefully this won't get confused.
4942 */
4943 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004944 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
4945 AC_VERB_SET_CONNECT_SEL,
4946 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004947 }
4948 }
4949
Mattc7d4b2f2005-06-27 14:59:41 +02004950 return 0;
4951}
4952
Mattc7d4b2f2005-06-27 14:59:41 +02004953static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
4954{
4955 struct sigmatel_spec *spec = codec->spec;
4956 int i;
4957
4958 for (i = 0; i < spec->autocfg.line_outs; i++) {
4959 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4960 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
4961 }
4962}
4963
4964static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
4965{
4966 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004967 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004968
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004969 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4970 hda_nid_t pin;
4971 pin = spec->autocfg.hp_pins[i];
4972 if (pin) /* connect to front */
4973 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
4974 }
4975 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
4976 hda_nid_t pin;
4977 pin = spec->autocfg.speaker_pins[i];
4978 if (pin) /* connect to front */
4979 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
4980 }
Mattc7d4b2f2005-06-27 14:59:41 +02004981}
4982
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01004983static int is_dual_headphones(struct hda_codec *codec)
4984{
4985 struct sigmatel_spec *spec = codec->spec;
4986 int i, valid_hps;
4987
4988 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
4989 spec->autocfg.hp_outs <= 1)
4990 return 0;
4991 valid_hps = 0;
4992 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4993 hda_nid_t nid = spec->autocfg.hp_pins[i];
4994 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
4995 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
4996 continue;
4997 valid_hps++;
4998 }
4999 return (valid_hps > 1);
5000}
5001
5002
Charles Chin9009b0e2011-11-03 10:27:27 +01005003static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02005004{
5005 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01005006 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005007 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02005008 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02005009
Matt Porter8b657272006-10-26 17:12:59 +02005010 if ((err = snd_hda_parse_pin_def_config(codec,
5011 &spec->autocfg,
5012 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005013 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005014 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01005015 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02005016
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005017 /* If we have no real line-out pin and multiple hp-outs, HPs should
5018 * be set up as multi-channel outputs.
5019 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01005020 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005021 /* Copy hp_outs to line_outs, backup line_outs in
5022 * speaker_outs so that the following routines can handle
5023 * HP pins as primary outputs.
5024 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005025 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005026 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
5027 sizeof(spec->autocfg.line_out_pins));
5028 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
5029 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
5030 sizeof(spec->autocfg.hp_pins));
5031 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005032 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5033 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005034 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005035 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005036 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005037 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
5038 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005039 u32 caps = query_amp_caps(codec,
5040 spec->autocfg.mono_out_pin, dir);
5041 hda_nid_t conn_list[1];
5042
5043 /* get the mixer node and then the mono mux if it exists */
5044 if (snd_hda_get_connections(codec,
5045 spec->autocfg.mono_out_pin, conn_list, 1) &&
5046 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02005047 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01005048
5049 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02005050 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005051 /* LR swap check, some stac925x have a mux that
5052 * changes the DACs output path instead of the
5053 * mono-mux path.
5054 */
5055 if (wid_type == AC_WID_AUD_SEL &&
5056 !(wcaps & AC_WCAP_LR_SWAP))
5057 spec->mono_nid = conn_list[0];
5058 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005059 if (dir) {
5060 hda_nid_t nid = spec->autocfg.mono_out_pin;
5061
5062 /* most mono outs have a least a mute/unmute switch */
5063 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
5064 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
5065 "Mono Playback Switch",
5066 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01005067 if (err < 0)
5068 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005069 /* check for volume support for the amp */
5070 if ((caps & AC_AMPCAP_NUM_STEPS)
5071 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
5072 err = stac92xx_add_control(spec,
5073 STAC_CTL_WIDGET_VOL,
5074 "Mono Playback Volume",
5075 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
5076 if (err < 0)
5077 return err;
5078 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005079 }
5080
5081 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
5082 AC_PINCTL_OUT_EN);
5083 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005084
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005085 if (!spec->multiout.num_dacs) {
5086 err = stac92xx_auto_fill_dac_nids(codec);
5087 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02005088 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01005089 err = stac92xx_auto_create_multi_out_ctls(codec,
5090 &spec->autocfg);
5091 if (err < 0)
5092 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005093 }
Mattc7d4b2f2005-06-27 14:59:41 +02005094
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005095 /* setup analog beep controls */
5096 if (spec->anabeep_nid > 0) {
5097 err = stac92xx_auto_create_beep_ctls(codec,
5098 spec->anabeep_nid);
5099 if (err < 0)
5100 return err;
5101 }
5102
5103 /* setup digital beep controls and input device */
5104#ifdef CONFIG_SND_HDA_INPUT_BEEP
5105 if (spec->digbeep_nid > 0) {
5106 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005107 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005108
5109 err = stac92xx_auto_create_beep_ctls(codec, nid);
5110 if (err < 0)
5111 return err;
5112 err = snd_hda_attach_beep_device(codec, nid);
5113 if (err < 0)
5114 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005115 if (codec->beep) {
5116 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005117 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005118 /* if no beep switch is available, make its own one */
5119 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
5120 if (!(caps & AC_AMPCAP_MUTE)) {
5121 err = stac92xx_beep_switch_ctl(codec);
5122 if (err < 0)
5123 return err;
5124 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005125 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005126 }
5127#endif
5128
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005129 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005130 if (err < 0)
5131 return err;
5132
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005133 /* All output parsing done, now restore the swapped hp pins */
5134 if (hp_swap) {
5135 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
5136 sizeof(spec->autocfg.hp_pins));
5137 spec->autocfg.hp_outs = spec->autocfg.line_outs;
5138 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5139 spec->autocfg.line_outs = 0;
5140 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005141
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005142 if (stac_check_auto_mic(codec)) {
5143 spec->auto_mic = 1;
5144 /* only one capture for auto-mic */
5145 spec->num_adcs = 1;
5146 spec->num_caps = 1;
5147 spec->num_muxes = 1;
5148 }
5149
Takashi Iwai6479c632009-07-28 18:20:25 +02005150 for (i = 0; i < spec->num_caps; i++) {
5151 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
5152 spec->capsws[i], i);
5153 if (err < 0)
5154 return err;
5155 }
5156
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005157 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005158 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005159 return err;
5160
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005161 if (spec->mono_nid > 0) {
5162 err = stac92xx_auto_create_mono_output_ctls(codec);
5163 if (err < 0)
5164 return err;
5165 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005166 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02005167 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
5168 &spec->autocfg)) < 0)
5169 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02005170 if (spec->num_muxes > 0) {
5171 err = stac92xx_auto_create_mux_input_ctls(codec);
5172 if (err < 0)
5173 return err;
5174 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02005175 if (spec->num_smuxes > 0) {
5176 err = stac92xx_auto_create_spdif_mux_ctls(codec);
5177 if (err < 0)
5178 return err;
5179 }
Matt Porter8b657272006-10-26 17:12:59 +02005180
Takashi Iwaie3c75962009-01-23 11:57:22 +01005181 err = stac92xx_add_input_source(spec);
5182 if (err < 0)
5183 return err;
5184
Mattc7d4b2f2005-06-27 14:59:41 +02005185 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01005186 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02005187 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02005188
Charles Chin9009b0e2011-11-03 10:27:27 +01005189 /* find digital out and in converters */
5190 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
5191 unsigned int wid_caps = get_wcaps(codec, i);
5192 if (wid_caps & AC_WCAP_DIGITAL) {
5193 switch (get_wcaps_type(wid_caps)) {
5194 case AC_WID_AUD_OUT:
5195 if (!dig_out)
5196 dig_out = i;
5197 break;
5198 case AC_WID_AUD_IN:
5199 if (!dig_in)
5200 dig_in = i;
5201 break;
5202 }
5203 }
5204 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005205 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005206 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005207 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005208 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02005209
Takashi Iwai603c4012008-07-30 15:01:44 +02005210 if (spec->kctls.list)
5211 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005212
5213 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05005214 if (!spec->dinput_mux)
5215 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005216 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005217 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02005218 return 1;
5219}
5220
Takashi Iwai82bc9552006-03-21 11:24:42 +01005221/* add playback controls for HP output */
5222static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
5223 struct auto_pin_cfg *cfg)
5224{
5225 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005226 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01005227
5228 if (! pin)
5229 return 0;
5230
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005231 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01005232 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005233
5234 return 0;
5235}
5236
Richard Fish160ea0d2006-09-06 13:58:25 +02005237/* add playback controls for LFE output */
5238static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
5239 struct auto_pin_cfg *cfg)
5240{
5241 struct sigmatel_spec *spec = codec->spec;
5242 int err;
5243 hda_nid_t lfe_pin = 0x0;
5244 int i;
5245
5246 /*
5247 * search speaker outs and line outs for a mono speaker pin
5248 * with an amp. If one is found, add LFE controls
5249 * for it.
5250 */
5251 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
5252 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005253 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005254 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5255 if (wcaps == AC_WCAP_OUT_AMP)
5256 /* found a mono speaker with an amp, must be lfe */
5257 lfe_pin = pin;
5258 }
5259
5260 /* if speaker_outs is 0, then speakers may be in line_outs */
5261 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
5262 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
5263 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005264 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01005265 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01005266 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005267 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005268 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5269 if (wcaps == AC_WCAP_OUT_AMP)
5270 /* found a mono speaker with an amp,
5271 must be lfe */
5272 lfe_pin = pin;
5273 }
5274 }
5275 }
5276
5277 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01005278 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02005279 if (err < 0)
5280 return err;
5281 }
5282
5283 return 0;
5284}
5285
Mattc7d4b2f2005-06-27 14:59:41 +02005286static int stac9200_parse_auto_config(struct hda_codec *codec)
5287{
5288 struct sigmatel_spec *spec = codec->spec;
5289 int err;
5290
Kailang Yangdf694da2005-12-05 19:42:22 +01005291 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005292 return err;
5293
5294 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
5295 return err;
5296
Takashi Iwai82bc9552006-03-21 11:24:42 +01005297 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
5298 return err;
5299
Richard Fish160ea0d2006-09-06 13:58:25 +02005300 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
5301 return err;
5302
Takashi Iwai355a0ec2008-11-11 16:46:19 +01005303 if (spec->num_muxes > 0) {
5304 err = stac92xx_auto_create_mux_input_ctls(codec);
5305 if (err < 0)
5306 return err;
5307 }
5308
Takashi Iwaie3c75962009-01-23 11:57:22 +01005309 err = stac92xx_add_input_source(spec);
5310 if (err < 0)
5311 return err;
5312
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005313 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02005314 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005315 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02005316 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02005317
Takashi Iwai603c4012008-07-30 15:01:44 +02005318 if (spec->kctls.list)
5319 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005320
5321 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02005322 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02005323
5324 return 1;
5325}
5326
Sam Revitch62fe78e2006-05-10 15:09:17 +02005327/*
5328 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
5329 * funky external mute control using GPIO pins.
5330 */
5331
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005332static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005333 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02005334{
5335 unsigned int gpiostate, gpiomask, gpiodir;
5336
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005337 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
5338
Sam Revitch62fe78e2006-05-10 15:09:17 +02005339 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5340 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005341 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005342
5343 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5344 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005345 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005346
5347 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5348 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005349 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005350
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005351 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005352 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
5353
5354 snd_hda_codec_write(codec, codec->afg, 0,
5355 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005356 snd_hda_codec_read(codec, codec->afg, 0,
5357 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005358
5359 msleep(1);
5360
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005361 snd_hda_codec_read(codec, codec->afg, 0,
5362 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005363}
5364
Takashi Iwai3a938972011-10-28 01:16:55 +02005365static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005366 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005367{
Takashi Iwai3a938972011-10-28 01:16:55 +02005368 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005369
Takashi Iwai3a938972011-10-28 01:16:55 +02005370 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005371 if (!event)
5372 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02005373 event->action = type;
5374 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005375
Takashi Iwai3a938972011-10-28 01:16:55 +02005376 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005377}
5378
David Henningsson29adc4b2012-09-25 11:31:00 +02005379static void handle_unsol_event(struct hda_codec *codec,
5380 struct hda_jack_tbl *event);
5381
Takashi Iwai62558ce2009-07-29 14:23:09 +02005382/* check if given nid is a valid pin and no other events are assigned
5383 * to it. If OK, assign the event, set the unsol flag, and returns 1.
5384 * Otherwise, returns zero.
5385 */
5386static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
5387 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02005388{
Takashi Iwai3a938972011-10-28 01:16:55 +02005389 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005390
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005391 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02005392 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02005393 event = snd_hda_jack_tbl_new(codec, nid);
5394 if (!event)
5395 return -ENOMEM;
5396 if (event->action && event->action != type)
5397 return 0;
5398 event->action = type;
David Henningsson29adc4b2012-09-25 11:31:00 +02005399 event->callback = handle_unsol_event;
Takashi Iwai3a938972011-10-28 01:16:55 +02005400 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02005401 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02005402}
5403
Takashi Iwaib4ead012012-01-23 18:23:36 +01005404static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005405{
5406 int i;
5407 for (i = 0; i < cfg->hp_outs; i++)
5408 if (cfg->hp_pins[i] == nid)
5409 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01005410 for (i = 0; i < cfg->line_outs; i++)
5411 if (cfg->line_out_pins[i] == nid)
5412 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005413 return 0; /* nid is not a HP-Out */
5414};
5415
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005416static void stac92xx_power_down(struct hda_codec *codec)
5417{
5418 struct sigmatel_spec *spec = codec->spec;
5419
5420 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02005421 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005422 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005423 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005424 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005425 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5426}
5427
Takashi Iwaif73d3582008-11-25 08:21:51 +01005428static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5429 int enable);
5430
Takashi Iwaibc759722013-01-11 17:40:31 +01005431static inline bool get_int_hint(struct hda_codec *codec, const char *key,
5432 int *valp)
Takashi Iwai014c41f2009-12-27 13:53:24 +01005433{
Takashi Iwaibc759722013-01-11 17:40:31 +01005434 return !snd_hda_get_int_hint(codec, key, valp);
Takashi Iwai014c41f2009-12-27 13:53:24 +01005435}
5436
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005437/* override some hints from the hwdep entry */
5438static void stac_store_hints(struct hda_codec *codec)
5439{
5440 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005441 int val;
5442
5443 val = snd_hda_get_bool_hint(codec, "hp_detect");
5444 if (val >= 0)
5445 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01005446 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005447 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
5448 spec->gpio_mask;
5449 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01005450 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
5451 spec->gpio_mask &= spec->gpio_mask;
5452 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
5453 spec->gpio_dir &= spec->gpio_mask;
5454 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
5455 spec->eapd_mask &= spec->gpio_mask;
5456 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
5457 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005458 val = snd_hda_get_bool_hint(codec, "eapd_switch");
5459 if (val >= 0)
5460 spec->eapd_switch = val;
5461}
5462
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005463static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
5464 const hda_nid_t *pins)
5465{
5466 while (num_pins--)
5467 stac_issue_unsol_event(codec, *pins++);
5468}
5469
5470/* fake event to set up pins */
5471static void stac_fake_hp_events(struct hda_codec *codec)
5472{
5473 struct sigmatel_spec *spec = codec->spec;
5474
5475 if (spec->autocfg.hp_outs)
5476 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
5477 spec->autocfg.hp_pins);
5478 if (spec->autocfg.line_outs &&
5479 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
5480 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
5481 spec->autocfg.line_out_pins);
5482}
5483
Mattc7d4b2f2005-06-27 14:59:41 +02005484static int stac92xx_init(struct hda_codec *codec)
5485{
5486 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005487 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005488 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01005489 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005490
David Henningsson5e68fb32012-08-16 14:11:09 +02005491 if (spec->init)
5492 snd_hda_sequence_write(codec, spec->init);
Mattc7d4b2f2005-06-27 14:59:41 +02005493
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005494 snd_hda_apply_verbs(codec);
5495
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005496 /* power down adcs initially */
5497 if (spec->powerdown_adcs)
5498 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005499 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005500 spec->adc_nids[i], 0,
5501 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005502
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005503 /* override some hints */
5504 stac_store_hints(codec);
5505
Takashi Iwaif73d3582008-11-25 08:21:51 +01005506 /* set up GPIO */
5507 gpio = spec->gpio_data;
5508 /* turn on EAPD statically when spec->eapd_switch isn't set.
5509 * otherwise, unsol event will turn it on/off dynamically
5510 */
5511 if (!spec->eapd_switch)
5512 gpio |= spec->eapd_mask;
5513 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
5514
Takashi Iwai82bc9552006-03-21 11:24:42 +01005515 /* set up pins */
5516 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02005517 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005518 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005519 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005520 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005521 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02005522 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
5523 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005524 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02005525 for (i = 0; i < cfg->line_outs; i++) {
5526 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005527 enable_pin_detect(codec, nid, STAC_LO_EVENT);
5528 }
5529 }
5530
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01005531 /* force to enable the first line-out; the others are set up
5532 * in unsol_event
5533 */
5534 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005535 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005536 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005537 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005538 } else {
5539 stac92xx_auto_init_multi_out(codec);
5540 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005541 for (i = 0; i < cfg->hp_outs; i++)
5542 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005543 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005544 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02005545 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005546 if (spec->dmux_nids)
5547 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02005548 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005549 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
5550 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02005551 if (enable_pin_detect(codec, spec->dock_mic.pin,
5552 STAC_MIC_EVENT))
5553 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005554 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005555 for (i = 0; i < cfg->num_inputs; i++) {
5556 hda_nid_t nid = cfg->inputs[i].pin;
5557 int type = cfg->inputs[i].type;
5558 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02005559 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005560 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02005561 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005562 pinctl |= AC_PINCTL_IN_EN;
5563 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5564 } else {
5565 pinctl = snd_hda_codec_read(codec, nid, 0,
5566 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5567 /* if PINCTL already set then skip */
5568 /* Also, if both INPUT and OUTPUT are set,
5569 * it must be a BIOS bug; need to override, too
5570 */
5571 if (!(pinctl & AC_PINCTL_IN_EN) ||
5572 (pinctl & AC_PINCTL_OUT_EN)) {
5573 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005574 pinctl |= AC_PINCTL_IN_EN;
5575 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01005576 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005577 }
5578 conf = snd_hda_codec_get_pincfg(codec, nid);
5579 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
5580 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
5581 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01005582 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01005583 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005584 for (i = 0; i < spec->num_dmics; i++)
5585 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
5586 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005587 if (cfg->dig_out_pins[0])
5588 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01005589 AC_PINCTL_OUT_EN);
5590 if (cfg->dig_in_pin)
5591 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
5592 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005593 for (i = 0; i < spec->num_pwrs; i++) {
5594 hda_nid_t nid = spec->pwr_nids[i];
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005595 unsigned int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005596
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005597 def_conf = snd_hda_codec_get_pincfg(codec, nid);
5598 def_conf = get_defcfg_connect(def_conf);
5599 if (def_conf == AC_JACK_PORT_NONE) {
5600 /* power off unused ports */
5601 stac_toggle_power_map(codec, nid, 0);
5602 continue;
5603 }
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005604 if (def_conf == AC_JACK_PORT_FIXED) {
5605 /* no need for jack detection for fixed pins */
5606 stac_toggle_power_map(codec, nid, 1);
5607 continue;
5608 }
Takashi Iwaieb632122008-12-19 16:39:48 +01005609 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01005610 /* or when the VREF is used for controlling LED */
5611 if (!spec->hp_detect ||
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005612 spec->vref_mute_led_nid == nid ||
5613 !is_jack_detectable(codec, nid)) {
Takashi Iwaieb632122008-12-19 16:39:48 +01005614 stac_toggle_power_map(codec, nid, 1);
5615 continue;
5616 }
5617
Takashi Iwaib4ead012012-01-23 18:23:36 +01005618 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01005619 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005620
Takashi Iwaif73d3582008-11-25 08:21:51 +01005621 pinctl = snd_hda_codec_read(codec, nid, 0,
5622 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5623 /* outputs are only ports capable of power management
5624 * any attempts on powering down a input port cause the
5625 * referenced VREF to act quirky.
5626 */
Takashi Iwaieb632122008-12-19 16:39:48 +01005627 if (pinctl & AC_PINCTL_IN_EN) {
5628 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005629 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01005630 }
Charles Chinafef2cf2011-11-11 08:05:28 +01005631 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02005632 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01005633 continue;
5634 }
5635 /* none of the above, turn the port OFF */
5636 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005637 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01005638
Takashi Iwaic21bd022010-02-08 15:16:08 +01005639 /* sync mute LED */
Takashi Iwai1f43f6c2012-07-31 10:40:05 +02005640 if (spec->gpio_led) {
5641 if (spec->vmaster_mute.hook)
5642 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5643 else /* the very first init call doesn't have vmaster yet */
5644 stac92xx_update_led_status(codec, false);
5645 }
Takashi Iwaic8822462012-05-15 09:11:36 +02005646
5647 /* sync the power-map */
5648 if (spec->num_pwrs)
5649 snd_hda_codec_write(codec, codec->afg, 0,
5650 AC_VERB_IDT_SET_POWER_MAP,
5651 spec->power_map_bits);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005652 if (spec->dac_list)
5653 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02005654 return 0;
5655}
5656
Takashi Iwai603c4012008-07-30 15:01:44 +02005657static void stac92xx_free_kctls(struct hda_codec *codec)
5658{
5659 struct sigmatel_spec *spec = codec->spec;
5660
5661 if (spec->kctls.list) {
5662 struct snd_kcontrol_new *kctl = spec->kctls.list;
5663 int i;
5664 for (i = 0; i < spec->kctls.used; i++)
5665 kfree(kctl[i].name);
5666 }
5667 snd_array_free(&spec->kctls);
5668}
5669
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005670static void stac92xx_shutup_pins(struct hda_codec *codec)
5671{
5672 unsigned int i, def_conf;
5673
5674 if (codec->bus->shutdown)
5675 return;
5676 for (i = 0; i < codec->init_pins.used; i++) {
5677 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
5678 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
5679 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005680 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005681 }
5682}
5683
Takashi Iwai167eae52009-11-06 15:47:50 +01005684static void stac92xx_shutup(struct hda_codec *codec)
5685{
5686 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01005687
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005688 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01005689
5690 if (spec->eapd_mask)
5691 stac_gpio_set(codec, spec->gpio_mask,
5692 spec->gpio_dir, spec->gpio_data &
5693 ~spec->eapd_mask);
5694}
5695
Matt2f2f4252005-04-13 14:45:30 +02005696static void stac92xx_free(struct hda_codec *codec)
5697{
Mattc7d4b2f2005-06-27 14:59:41 +02005698 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005699
5700 if (! spec)
5701 return;
5702
Mattc7d4b2f2005-06-27 14:59:41 +02005703 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005704 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02005705}
5706
Matt4e550962005-07-04 17:51:39 +02005707static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
5708 unsigned int flag)
5709{
Takashi Iwai8ce84192009-01-22 16:59:20 +01005710 unsigned int old_ctl, pin_ctl;
5711
5712 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02005713 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02005714
Takashi Iwaif9acba42007-05-29 18:01:06 +02005715 if (pin_ctl & AC_PINCTL_IN_EN) {
5716 /*
5717 * we need to check the current set-up direction of
5718 * shared input pins since they can be switched via
5719 * "xxx as Output" mixer switch
5720 */
5721 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005722 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02005723 return;
5724 }
5725
Takashi Iwai8ce84192009-01-22 16:59:20 +01005726 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02005727 /* if setting pin direction bits, clear the current
5728 direction bits first */
5729 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
5730 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
5731
Takashi Iwai8ce84192009-01-22 16:59:20 +01005732 pin_ctl |= flag;
5733 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005734 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02005735}
5736
5737static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
5738 unsigned int flag)
5739{
5740 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
5741 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01005742 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005743 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02005744}
5745
Takashi Iwaid56757a2009-11-18 08:00:14 +01005746static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02005747{
5748 if (!nid)
5749 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01005750 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02005751}
5752
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005753static void stac92xx_line_out_detect(struct hda_codec *codec,
5754 int presence)
5755{
5756 struct sigmatel_spec *spec = codec->spec;
5757 struct auto_pin_cfg *cfg = &spec->autocfg;
5758 int i;
5759
David Henningsson042b92c2012-08-22 16:10:43 +02005760 if (cfg->speaker_outs == 0)
5761 return;
5762
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005763 for (i = 0; i < cfg->line_outs; i++) {
5764 if (presence)
5765 break;
5766 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
5767 if (presence) {
5768 unsigned int pinctl;
5769 pinctl = snd_hda_codec_read(codec,
5770 cfg->line_out_pins[i], 0,
5771 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5772 if (pinctl & AC_PINCTL_IN_EN)
5773 presence = 0; /* mic- or line-input */
5774 }
5775 }
5776
5777 if (presence) {
5778 /* disable speakers */
5779 for (i = 0; i < cfg->speaker_outs; i++)
5780 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
5781 AC_PINCTL_OUT_EN);
5782 if (spec->eapd_mask && spec->eapd_switch)
5783 stac_gpio_set(codec, spec->gpio_mask,
5784 spec->gpio_dir, spec->gpio_data &
5785 ~spec->eapd_mask);
5786 } else {
5787 /* enable speakers */
5788 for (i = 0; i < cfg->speaker_outs; i++)
5789 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
5790 AC_PINCTL_OUT_EN);
5791 if (spec->eapd_mask && spec->eapd_switch)
5792 stac_gpio_set(codec, spec->gpio_mask,
5793 spec->gpio_dir, spec->gpio_data |
5794 spec->eapd_mask);
5795 }
5796}
5797
Takashi Iwaid7a89432008-11-12 09:48:04 +01005798/* return non-zero if the hp-pin of the given array index isn't
5799 * a jack-detection target
5800 */
5801static int no_hp_sensing(struct sigmatel_spec *spec, int i)
5802{
5803 struct auto_pin_cfg *cfg = &spec->autocfg;
5804
5805 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005806 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005807 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005808 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005809 return 1;
5810 /* ignore if the pin is set as line-out */
5811 if (cfg->hp_pins[i] == spec->hp_switch)
5812 return 1;
5813 return 0;
5814}
5815
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005816static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02005817{
5818 struct sigmatel_spec *spec = codec->spec;
5819 struct auto_pin_cfg *cfg = &spec->autocfg;
5820 int i, presence;
5821
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005822 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005823 if (spec->gpio_mute)
5824 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
5825 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
5826
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005827 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005828 if (presence)
5829 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01005830 if (no_hp_sensing(spec, i))
5831 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005832 presence = get_pin_presence(codec, cfg->hp_pins[i]);
5833 if (presence) {
5834 unsigned int pinctl;
5835 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
5836 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5837 if (pinctl & AC_PINCTL_IN_EN)
5838 presence = 0; /* mic- or line-input */
5839 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005840 }
Matt4e550962005-07-04 17:51:39 +02005841
5842 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005843 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005844 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005845 stac92xx_reset_pinctl(codec, spec->hp_switch,
5846 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005847 for (i = 0; i < cfg->line_outs; i++)
5848 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
5849 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005850 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005851 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005852 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005853 stac92xx_set_pinctl(codec, spec->hp_switch,
5854 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005855 for (i = 0; i < cfg->line_outs; i++)
5856 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
5857 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005858 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005859 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01005860 /* toggle hp outs */
5861 for (i = 0; i < cfg->hp_outs; i++) {
5862 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
5863 if (no_hp_sensing(spec, i))
5864 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01005865 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005866 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01005867#if 0 /* FIXME */
5868/* Resetting the pinctl like below may lead to (a sort of) regressions
5869 * on some devices since they use the HP pin actually for line/speaker
5870 * outs although the default pin config shows a different pin (that is
5871 * wrong and useless).
5872 *
5873 * So, it's basically a problem of default pin configs, likely a BIOS issue.
5874 * But, disabling the code below just works around it, and I'm too tired of
5875 * bug reports with such devices...
5876 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01005877 else
5878 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01005879#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01005880 }
Matt4e550962005-07-04 17:51:39 +02005881}
5882
Takashi Iwaif73d3582008-11-25 08:21:51 +01005883static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5884 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005885{
5886 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005887 unsigned int idx, val;
5888
5889 for (idx = 0; idx < spec->num_pwrs; idx++) {
5890 if (spec->pwr_nids[idx] == nid)
5891 break;
5892 }
5893 if (idx >= spec->num_pwrs)
5894 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005895
Charles Chinafef2cf2011-11-11 08:05:28 +01005896 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005897
Takashi Iwaic8822462012-05-15 09:11:36 +02005898 val = spec->power_map_bits;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005899 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005900 val &= ~idx;
5901 else
5902 val |= idx;
5903
5904 /* power down unused output ports */
Takashi Iwaic8822462012-05-15 09:11:36 +02005905 if (val != spec->power_map_bits) {
5906 spec->power_map_bits = val;
5907 snd_hda_codec_write(codec, codec->afg, 0,
5908 AC_VERB_IDT_SET_POWER_MAP, val);
5909 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005910}
5911
Takashi Iwaif73d3582008-11-25 08:21:51 +01005912static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
5913{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005914 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01005915}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005916
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005917/* get the pin connection (fixed, none, etc) */
5918static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5919{
5920 struct sigmatel_spec *spec = codec->spec;
5921 unsigned int cfg;
5922
5923 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5924 return get_defcfg_connect(cfg);
5925}
5926
5927static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005928 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005929{
5930 struct sigmatel_spec *spec = codec->spec;
5931 int idx, num;
5932 unsigned int def_conf;
5933
5934 for (num = 0; num < num_nids; num++) {
5935 for (idx = 0; idx < spec->num_pins; idx++)
5936 if (spec->pin_nids[idx] == nids[num])
5937 break;
5938 if (idx >= spec->num_pins)
5939 break;
5940 def_conf = stac_get_defcfg_connect(codec, idx);
5941 if (def_conf == AC_JACK_PORT_NONE)
5942 break;
5943 }
5944 return num;
5945}
5946
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005947static void stac92xx_mic_detect(struct hda_codec *codec)
5948{
5949 struct sigmatel_spec *spec = codec->spec;
5950 struct sigmatel_mic_route *mic;
5951
5952 if (get_pin_presence(codec, spec->ext_mic.pin))
5953 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02005954 else if (get_pin_presence(codec, spec->dock_mic.pin))
5955 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005956 else
5957 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02005958 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005959 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
5960 AC_VERB_SET_CONNECT_SEL,
5961 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02005962 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005963 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
5964 AC_VERB_SET_CONNECT_SEL,
5965 mic->mux_idx);
5966}
5967
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005968static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02005969 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02005970{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005971 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005972 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005973
Takashi Iwai3a938972011-10-28 01:16:55 +02005974 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005975 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005976 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02005977 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005978 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005979 case STAC_MIC_EVENT:
5980 stac92xx_mic_detect(codec);
5981 break;
5982 }
5983
Takashi Iwai3a938972011-10-28 01:16:55 +02005984 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005985 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005986 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005987 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005988 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005989 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005990 if (spec->num_pwrs > 0)
5991 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04005992
5993 switch (codec->subsystem_id) {
5994 case 0x103c308f:
5995 if (event->nid == 0xb) {
5996 int pin = AC_PINCTL_IN_EN;
5997
5998 if (get_pin_presence(codec, 0xa)
5999 && get_pin_presence(codec, 0xb))
6000 pin |= AC_PINCTL_VREF_80;
6001 if (!get_pin_presence(codec, 0xb))
6002 pin |= AC_PINCTL_VREF_80;
6003
6004 /* toggle VREF state based on mic + hp pin
6005 * status
6006 */
6007 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
6008 }
6009 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04006010 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006011 case STAC_VREF_EVENT:
6012 data = snd_hda_codec_read(codec, codec->afg, 0,
6013 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04006014 /* toggle VREF state based on GPIOx status */
6015 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02006016 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04006017 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02006018 }
6019}
6020
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006021static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
6022{
Takashi Iwai3a938972011-10-28 01:16:55 +02006023 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006024 if (!event)
6025 return;
6026 handle_unsol_event(codec, event);
6027}
6028
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306029static void set_hp_led_gpio(struct hda_codec *codec)
6030{
6031 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01006032 unsigned int gpio;
6033
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02006034 if (spec->gpio_led)
6035 return;
6036
Takashi Iwai07f80442010-02-08 15:06:13 +01006037 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
6038 gpio &= AC_GPIO_IO_COUNT;
6039 if (gpio > 3)
6040 spec->gpio_led = 0x08; /* GPIO 3 */
6041 else
6042 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306043}
6044
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006045/*
6046 * This method searches for the mute LED GPIO configuration
6047 * provided as OEM string in SMBIOS. The format of that string
6048 * is HP_Mute_LED_P_G or HP_Mute_LED_P
6049 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
6050 * that corresponds to the NOT muted state of the master volume
6051 * and G is the index of the GPIO to use as the mute LED control (0..9)
6052 * If _G portion is missing it is assigned based on the codec ID
6053 *
6054 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
6055 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306056 *
6057 *
6058 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
6059 * SMBIOS - at least the ones I have seen do not have them - which include
6060 * my own system (HP Pavilion dv6-1110ax) and my cousin's
6061 * HP Pavilion dv9500t CTO.
6062 * Need more information on whether it is true across the entire series.
6063 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006064 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006065static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006066{
6067 struct sigmatel_spec *spec = codec->spec;
6068 const struct dmi_device *dev = NULL;
6069
Takashi Iwai75609312012-05-14 16:52:00 +02006070 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
6071 get_int_hint(codec, "gpio_led_polarity",
6072 &spec->gpio_led_polarity);
6073 return 1;
6074 }
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006075
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006076 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
6077 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
6078 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006079 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306080 &spec->gpio_led_polarity,
6081 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006082 unsigned int max_gpio;
6083 max_gpio = snd_hda_param_read(codec, codec->afg,
6084 AC_PAR_GPIO_CAP);
6085 max_gpio &= AC_GPIO_IO_COUNT;
6086 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006087 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01006088 else
6089 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006090 return 1;
6091 }
6092 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306093 &spec->gpio_led_polarity) == 1) {
6094 set_hp_led_gpio(codec);
6095 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006096 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02006097 /* BIOS bug: unfilled OEM string */
6098 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
6099 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02006100 switch (codec->subsystem_id) {
6101 case 0x103c148a:
6102 spec->gpio_led_polarity = 0;
6103 break;
6104 default:
6105 spec->gpio_led_polarity = 1;
6106 break;
6107 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02006108 return 1;
6109 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006110 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306111
6112 /*
6113 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006114 * we statically set the GPIO - if not a B-series system
6115 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306116 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006117 if (!hp_blike_system(codec->subsystem_id) &&
6118 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306119 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01006120 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306121 return 1;
6122 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006123 }
6124 return 0;
6125}
6126
6127static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08006128{
6129 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006130 case 0x103c1520:
6131 case 0x103c1521:
6132 case 0x103c1523:
6133 case 0x103c1524:
6134 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006135 case 0x103c1722:
6136 case 0x103c1723:
6137 case 0x103c1724:
6138 case 0x103c1725:
6139 case 0x103c1726:
6140 case 0x103c1727:
6141 case 0x103c1728:
6142 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006143 case 0x103c172a:
6144 case 0x103c172b:
6145 case 0x103c307e:
6146 case 0x103c307f:
6147 case 0x103c3080:
6148 case 0x103c3081:
6149 case 0x103c7007:
6150 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006151 return 1;
6152 }
6153 return 0;
6154}
6155
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006156#ifdef CONFIG_PROC_FS
6157static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
6158 struct hda_codec *codec, hda_nid_t nid)
6159{
6160 if (nid == codec->afg)
6161 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02006162 snd_hda_codec_read(codec, nid, 0,
6163 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006164}
6165
6166static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
6167 struct hda_codec *codec,
6168 unsigned int verb)
6169{
6170 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
6171 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
6172}
6173
6174/* stac92hd71bxx, stac92hd73xx */
6175static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
6176 struct hda_codec *codec, hda_nid_t nid)
6177{
6178 stac92hd_proc_hook(buffer, codec, nid);
6179 if (nid == codec->afg)
6180 analog_loop_proc_hook(buffer, codec, 0xfa0);
6181}
6182
6183static void stac9205_proc_hook(struct snd_info_buffer *buffer,
6184 struct hda_codec *codec, hda_nid_t nid)
6185{
6186 if (nid == codec->afg)
6187 analog_loop_proc_hook(buffer, codec, 0xfe0);
6188}
6189
6190static void stac927x_proc_hook(struct snd_info_buffer *buffer,
6191 struct hda_codec *codec, hda_nid_t nid)
6192{
6193 if (nid == codec->afg)
6194 analog_loop_proc_hook(buffer, codec, 0xfeb);
6195}
6196#else
6197#define stac92hd_proc_hook NULL
6198#define stac92hd7x_proc_hook NULL
6199#define stac9205_proc_hook NULL
6200#define stac927x_proc_hook NULL
6201#endif
6202
Takashi Iwai2a439522011-07-26 09:52:50 +02006203#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02006204static int stac92xx_resume(struct hda_codec *codec)
6205{
Takashi Iwai2c885872008-11-18 09:36:55 +01006206 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006207 snd_hda_codec_resume_amp(codec);
6208 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01006209 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01006210 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02006211 return 0;
6212}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006213
Takashi Iwai68cb2b52012-07-02 15:20:37 +02006214static int stac92xx_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006215{
6216 stac92xx_shutup(codec);
6217 return 0;
6218}
6219
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006220static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
6221 unsigned int power_state)
6222{
6223 unsigned int afg_power_state = power_state;
6224 struct sigmatel_spec *spec = codec->spec;
6225
6226 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006227 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006228 /* with vref-out pin used for mute led control
6229 * codec AFG is prevented from D3 state
6230 */
6231 afg_power_state = AC_PWRST_D1;
6232 }
6233 /* this delay seems necessary to avoid click noise at power-down */
6234 msleep(100);
6235 }
6236 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
6237 afg_power_state);
6238 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
6239}
Takashi Iwai350eba432012-03-16 16:09:03 +01006240#else
6241#define stac92xx_suspend NULL
6242#define stac92xx_resume NULL
Takashi Iwai350eba432012-03-16 16:09:03 +01006243#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006244#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006245
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006246/* update mute-LED accoring to the master switch */
6247static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006248{
6249 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006250 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01006251
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006252 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006253 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006254
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006255 /* LED state is inverted on these systems */
6256 if (spec->gpio_led_polarity)
6257 muted = !muted;
6258
Takashi Iwaif1a73742011-12-04 13:44:06 +01006259 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006260 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02006261 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006262 else
Takashi Iwai3e843192012-04-19 12:04:03 +02006263 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006264 stac_gpio_set(codec, spec->gpio_mask,
6265 spec->gpio_dir, spec->gpio_data);
6266 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006267 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01006268 stac_vrefout_set(codec, spec->vref_mute_led_nid,
6269 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006270 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006271}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05006272
Takashi Iwai2b635362011-05-02 12:33:43 +02006273static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02006274 .build_controls = stac92xx_build_controls,
6275 .build_pcms = stac92xx_build_pcms,
6276 .init = stac92xx_init,
6277 .free = stac92xx_free,
David Henningsson29adc4b2012-09-25 11:31:00 +02006278 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02006279#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006280 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02006281 .resume = stac92xx_resume,
6282#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01006283 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02006284};
6285
Takashi Iwai361dab32012-05-09 14:35:27 +02006286static int alloc_stac_spec(struct hda_codec *codec, int num_pins,
6287 const hda_nid_t *pin_nids)
6288{
6289 struct sigmatel_spec *spec;
6290
6291 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6292 if (!spec)
6293 return -ENOMEM;
6294 codec->spec = spec;
6295 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
6296 spec->num_pins = num_pins;
6297 spec->pin_nids = pin_nids;
6298 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
6299 return 0;
6300}
6301
Matt2f2f4252005-04-13 14:45:30 +02006302static int patch_stac9200(struct hda_codec *codec)
6303{
6304 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006305 int err;
Matt2f2f4252005-04-13 14:45:30 +02006306
Takashi Iwai361dab32012-05-09 14:35:27 +02006307 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids),
6308 stac9200_pin_nids);
6309 if (err < 0)
6310 return err;
Matt2f2f4252005-04-13 14:45:30 +02006311
Takashi Iwai361dab32012-05-09 14:35:27 +02006312 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006313 spec->linear_tone_beep = 1;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006314
6315 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
6316 stac9200_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006317
6318 spec->multiout.max_channels = 2;
6319 spec->multiout.num_dacs = 1;
6320 spec->multiout.dac_nids = stac9200_dac_nids;
6321 spec->adc_nids = stac9200_adc_nids;
6322 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02006323 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02006324 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006325 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006326 spec->num_pwrs = 0;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006327 snd_hda_add_verbs(codec, stac9200_eapd_init);
Mattc7d4b2f2005-06-27 14:59:41 +02006328
Matt2f2f4252005-04-13 14:45:30 +02006329 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02006330
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006331 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai117f2572008-03-18 09:53:23 +01006332
Mattc7d4b2f2005-06-27 14:59:41 +02006333 err = stac9200_parse_auto_config(codec);
6334 if (err < 0) {
6335 stac92xx_free(codec);
6336 return err;
6337 }
Matt2f2f4252005-04-13 14:45:30 +02006338
6339 codec->patch_ops = stac92xx_patch_ops;
6340
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006341 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6342
Matt2f2f4252005-04-13 14:45:30 +02006343 return 0;
6344}
6345
Tobin Davis8e21c342007-01-08 11:04:17 +01006346static int patch_stac925x(struct hda_codec *codec)
6347{
6348 struct sigmatel_spec *spec;
6349 int err;
6350
Takashi Iwai361dab32012-05-09 14:35:27 +02006351 err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids),
6352 stac925x_pin_nids);
6353 if (err < 0)
6354 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01006355
Takashi Iwai361dab32012-05-09 14:35:27 +02006356 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006357 spec->linear_tone_beep = 1;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02006358
Takashi Iwaid2077d42013-01-14 14:20:16 +01006359 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
6360 stac925x_fixups);
Tobin Davis8e21c342007-01-08 11:04:17 +01006361
6362 spec->multiout.max_channels = 2;
6363 spec->multiout.num_dacs = 1;
6364 spec->multiout.dac_nids = stac925x_dac_nids;
6365 spec->adc_nids = stac925x_adc_nids;
6366 spec->mux_nids = stac925x_mux_nids;
6367 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006368 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006369 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02006370 switch (codec->vendor_id) {
6371 case 0x83847632: /* STAC9202 */
6372 case 0x83847633: /* STAC9202D */
6373 case 0x83847636: /* STAC9251 */
6374 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02006375 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02006376 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006377 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
6378 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02006379 break;
6380 default:
6381 spec->num_dmics = 0;
6382 break;
6383 }
Tobin Davis8e21c342007-01-08 11:04:17 +01006384
Takashi Iwaid2077d42013-01-14 14:20:16 +01006385 snd_hda_add_verbs(codec, stac925x_core_init);
Tobin Davis8e21c342007-01-08 11:04:17 +01006386 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02006387 spec->num_caps = 1;
6388 spec->capvols = stac925x_capvols;
6389 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01006390
Takashi Iwaid2077d42013-01-14 14:20:16 +01006391 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6392
Charles Chin9009b0e2011-11-03 10:27:27 +01006393 err = stac92xx_parse_auto_config(codec);
Takashi Iwaid2077d42013-01-14 14:20:16 +01006394 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006395 err = -EINVAL;
Tobin Davis8e21c342007-01-08 11:04:17 +01006396 if (err < 0) {
6397 stac92xx_free(codec);
6398 return err;
6399 }
6400
6401 codec->patch_ops = stac92xx_patch_ops;
6402
Takashi Iwaid2077d42013-01-14 14:20:16 +01006403 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6404
Tobin Davis8e21c342007-01-08 11:04:17 +01006405 return 0;
6406}
6407
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006408static int patch_stac92hd73xx(struct hda_codec *codec)
6409{
6410 struct sigmatel_spec *spec;
6411 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
Takashi Iwai361dab32012-05-09 14:35:27 +02006412 int err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006413 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006414
Takashi Iwai361dab32012-05-09 14:35:27 +02006415 err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids),
6416 stac92hd73xx_pin_nids);
6417 if (err < 0)
6418 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006419
Takashi Iwai361dab32012-05-09 14:35:27 +02006420 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006421 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02006422 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Takashi Iwai55e30142013-01-14 17:30:04 +01006423
6424 snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl,
6425 stac92hd73xx_fixups);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006426
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006427 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006428 conn, STAC92HD73_DAC_COUNT + 2) - 1;
6429
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006430 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006431 printk(KERN_WARNING "hda_codec: Could not determine "
6432 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006433 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006434 }
Takashi Iwai55e30142013-01-14 17:30:04 +01006435
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006436 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006437 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006438 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006439 break;
6440 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006441 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006442 break;
6443 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006444 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
6445 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006446 }
6447 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006448
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006449 spec->aloopback_mask = 0x01;
6450 spec->aloopback_shift = 8;
6451
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006452 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006453 spec->mux_nids = stac92hd73xx_mux_nids;
6454 spec->adc_nids = stac92hd73xx_adc_nids;
6455 spec->dmic_nids = stac92hd73xx_dmic_nids;
6456 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006457 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006458
6459 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
6460 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01006461 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006462
Takashi Iwai6479c632009-07-28 18:20:25 +02006463 spec->num_caps = STAC92HD73XX_NUM_CAPS;
6464 spec->capvols = stac92hd73xx_capvols;
6465 spec->capsws = stac92hd73xx_capsws;
6466
Takashi Iwai55e30142013-01-14 17:30:04 +01006467 /* GPIO0 High = Enable EAPD */
6468 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6469 spec->gpio_data = 0x01;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006470
Takashi Iwai55e30142013-01-14 17:30:04 +01006471 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6472 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6473 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006474
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006475 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
6476 spec->pwr_nids = stac92hd73xx_pwr_nids;
6477
Takashi Iwai55e30142013-01-14 17:30:04 +01006478 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6479
6480 if (!spec->volknob_init)
6481 snd_hda_add_verbs(codec, stac92hd73xx_core_init);
6482
Charles Chin9009b0e2011-11-03 10:27:27 +01006483 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006484
Takashi Iwai55e30142013-01-14 17:30:04 +01006485 if (!err)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006486 err = -EINVAL;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006487 if (err < 0) {
6488 stac92xx_free(codec);
6489 return err;
6490 }
6491
6492 codec->patch_ops = stac92xx_patch_ops;
6493
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006494 codec->proc_widget_hook = stac92hd7x_proc_hook;
6495
Takashi Iwai55e30142013-01-14 17:30:04 +01006496 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6497
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006498 return 0;
6499}
6500
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006501static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006502{
6503 if (codec->vendor_id != 0x111d7605 &&
6504 codec->vendor_id != 0x111d76d1)
6505 return 0;
6506
6507 switch (codec->subsystem_id) {
6508 case 0x103c1618:
6509 case 0x103c1619:
6510 case 0x103c161a:
6511 case 0x103c161b:
6512 case 0x103c161c:
6513 case 0x103c161d:
6514 case 0x103c161e:
6515 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006516
6517 case 0x103c162a:
6518 case 0x103c162b:
6519
6520 case 0x103c1630:
6521 case 0x103c1631:
6522
6523 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006524 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006525 case 0x103c1635:
6526
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006527 case 0x103c3587:
6528 case 0x103c3588:
6529 case 0x103c3589:
6530 case 0x103c358a:
6531
6532 case 0x103c3667:
6533 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006534 case 0x103c3669:
6535
6536 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006537 }
6538 return 0;
6539}
6540
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006541static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
6542{
6543 struct sigmatel_spec *spec = codec->spec;
6544 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
6545 int i;
6546
6547 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
6548 spec->auto_pin_cnt++;
6549
6550 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
6551 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
6552 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
6553 if (nid == stac92hd83xxx_dmic_nids[i]) {
6554 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
6555 spec->auto_dmic_cnt++;
6556 }
6557 }
6558 }
6559}
6560
6561static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
6562{
6563 struct sigmatel_spec *spec = codec->spec;
6564
6565 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
6566 spec->auto_adc_cnt++;
6567}
6568
6569static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
6570{
6571 int i, j;
6572 struct sigmatel_spec *spec = codec->spec;
6573
6574 for (i = 0; i < spec->auto_adc_cnt; i++) {
6575 if (get_connection_index(codec,
6576 spec->auto_adc_nids[i], nid) >= 0) {
6577 /* mux and volume for adc_nids[i] */
6578 if (!spec->auto_mux_nids[i]) {
6579 spec->auto_mux_nids[i] = nid;
6580 /* 92hd codecs capture volume is in mux */
6581 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
6582 3, 0, HDA_OUTPUT);
6583 }
6584 for (j = 0; j < spec->auto_dmic_cnt; j++) {
6585 if (get_connection_index(codec, nid,
6586 spec->auto_dmic_nids[j]) >= 0) {
6587 /* dmux for adc_nids[i] */
6588 if (!spec->auto_dmux_nids[i])
6589 spec->auto_dmux_nids[i] = nid;
6590 break;
6591 }
6592 }
6593 break;
6594 }
6595 }
6596}
6597
6598static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
6599{
6600 hda_nid_t nid, end_nid;
6601 unsigned int wid_caps, wid_type;
6602 struct sigmatel_spec *spec = codec->spec;
6603
6604 end_nid = codec->start_nid + codec->num_nodes;
6605
6606 for (nid = codec->start_nid; nid < end_nid; nid++) {
6607 wid_caps = get_wcaps(codec, nid);
6608 wid_type = get_wcaps_type(wid_caps);
6609
6610 if (wid_type == AC_WID_PIN)
6611 stac92hd8x_add_pin(codec, nid);
6612
6613 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
6614 stac92hd8x_add_adc(codec, nid);
6615 }
6616
6617 for (nid = codec->start_nid; nid < end_nid; nid++) {
6618 wid_caps = get_wcaps(codec, nid);
6619 wid_type = get_wcaps_type(wid_caps);
6620
6621 if (wid_type == AC_WID_AUD_SEL)
6622 stac92hd8x_add_mux(codec, nid);
6623 }
6624
6625 spec->pin_nids = spec->auto_pin_nids;
6626 spec->num_pins = spec->auto_pin_cnt;
6627 spec->adc_nids = spec->auto_adc_nids;
6628 spec->num_adcs = spec->auto_adc_cnt;
6629 spec->capvols = spec->auto_capvols;
6630 spec->capsws = spec->auto_capvols;
6631 spec->num_caps = spec->auto_adc_cnt;
6632 spec->mux_nids = spec->auto_mux_nids;
6633 spec->num_muxes = spec->auto_adc_cnt;
6634 spec->dmux_nids = spec->auto_dmux_nids;
6635 spec->num_dmuxes = spec->auto_adc_cnt;
6636 spec->dmic_nids = spec->auto_dmic_nids;
6637 spec->num_dmics = spec->auto_dmic_cnt;
6638}
6639
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006640static int patch_stac92hd83xxx(struct hda_codec *codec)
6641{
6642 struct sigmatel_spec *spec;
Takashi Iwaia3e19972012-07-26 08:17:20 +02006643 int default_polarity = -1; /* no default cfg */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006644 int err;
6645
Takashi Iwai361dab32012-05-09 14:35:27 +02006646 err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */
6647 if (err < 0)
6648 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006649
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006650 if (hp_bnb2011_with_dock(codec)) {
6651 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
6652 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
6653 }
6654
Takashi Iwaic36b5b02012-08-28 09:20:13 -07006655 codec->epss = 0; /* longer delay needed for D3 */
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006656 stac92hd8x_fill_auto_spec(codec);
6657
Takashi Iwai361dab32012-05-09 14:35:27 +02006658 spec = codec->spec;
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01006659 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006660 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006661 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006662 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006663 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006664 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006665 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006666
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006667 spec->board_config = snd_hda_check_board_config(codec,
6668 STAC_92HD83XXX_MODELS,
6669 stac92hd83xxx_models,
6670 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006671 /* check codec subsystem id if not found */
6672 if (spec->board_config < 0)
6673 spec->board_config =
6674 snd_hda_check_board_codec_sid_config(codec,
6675 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
6676 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006677again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006678 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006679 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6680 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006681 else
6682 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006683 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006684
Takashi Iwaib4e81872009-11-18 17:20:24 +01006685 codec->patch_ops = stac92xx_patch_ops;
6686
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006687 switch (spec->board_config) {
6688 case STAC_HP_ZEPHYR:
6689 spec->init = stac92hd83xxx_hp_zephyr_init;
6690 break;
Takashi Iwaia3e19972012-07-26 08:17:20 +02006691 case STAC_92HD83XXX_HP_LED:
Takashi Iwaiff8a1e22012-07-31 10:16:59 +02006692 default_polarity = 0;
6693 break;
6694 case STAC_92HD83XXX_HP_INV_LED:
Takashi Iwaia3e19972012-07-26 08:17:20 +02006695 default_polarity = 1;
6696 break;
Takashi Iwai62cbde12012-09-14 11:58:54 +02006697 case STAC_92HD83XXX_HP_MIC_LED:
6698 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
6699 break;
David Henningsson8d032a82012-10-09 12:48:40 +02006700 case STAC_92HD83XXX_HEADSET_JACK:
6701 spec->headset_jack = 1;
6702 break;
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006703 }
6704
Takashi Iwaia3e19972012-07-26 08:17:20 +02006705 if (find_mute_led_cfg(codec, default_polarity))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01006706 snd_printd("mute LED gpio %d polarity %d\n",
6707 spec->gpio_led,
6708 spec->gpio_led_polarity);
6709
Takashi Iwaib4e81872009-11-18 17:20:24 +01006710 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006711 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006712 spec->gpio_mask |= spec->gpio_led;
6713 spec->gpio_dir |= spec->gpio_led;
6714 spec->gpio_data |= spec->gpio_led;
6715 } else {
6716 codec->patch_ops.set_power_state =
6717 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006718 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006719 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006720
Takashi Iwai62cbde12012-09-14 11:58:54 +02006721 if (spec->mic_mute_led_gpio) {
6722 spec->gpio_mask |= spec->mic_mute_led_gpio;
6723 spec->gpio_dir |= spec->mic_mute_led_gpio;
6724 spec->mic_mute_led_on = true;
6725 spec->gpio_data |= spec->mic_mute_led_gpio;
6726 }
6727
Charles Chin9009b0e2011-11-03 10:27:27 +01006728 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006729 if (!err) {
6730 if (spec->board_config < 0) {
6731 printk(KERN_WARNING "hda_codec: No auto-config is "
6732 "available, default to model=ref\n");
6733 spec->board_config = STAC_92HD83XXX_REF;
6734 goto again;
6735 }
6736 err = -EINVAL;
6737 }
6738
6739 if (err < 0) {
6740 stac92xx_free(codec);
6741 return err;
6742 }
6743
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006744 codec->proc_widget_hook = stac92hd_proc_hook;
6745
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006746 return 0;
6747}
6748
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006749static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
6750 hda_nid_t dig0pin)
6751{
6752 struct sigmatel_spec *spec = codec->spec;
6753 int idx;
6754
6755 for (idx = 0; idx < spec->num_pins; idx++)
6756 if (spec->pin_nids[idx] == dig0pin)
6757 break;
6758 if ((idx + 2) >= spec->num_pins)
6759 return 0;
6760
6761 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006762 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006763 return 2;
6764
6765 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006766 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006767 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01006768 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006769 return 1;
6770 else
6771 return 0;
6772}
6773
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006774/* HP dv7 bass switch - GPIO5 */
6775#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
6776static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
6777 struct snd_ctl_elem_value *ucontrol)
6778{
6779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6780 struct sigmatel_spec *spec = codec->spec;
6781 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
6782 return 0;
6783}
6784
6785static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
6786 struct snd_ctl_elem_value *ucontrol)
6787{
6788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6789 struct sigmatel_spec *spec = codec->spec;
6790 unsigned int gpio_data;
6791
6792 gpio_data = (spec->gpio_data & ~0x20) |
6793 (ucontrol->value.integer.value[0] ? 0x20 : 0);
6794 if (gpio_data == spec->gpio_data)
6795 return 0;
6796 spec->gpio_data = gpio_data;
6797 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
6798 return 1;
6799}
6800
Takashi Iwai2b635362011-05-02 12:33:43 +02006801static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006802 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6803 .info = stac_hp_bass_gpio_info,
6804 .get = stac_hp_bass_gpio_get,
6805 .put = stac_hp_bass_gpio_put,
6806};
6807
6808static int stac_add_hp_bass_switch(struct hda_codec *codec)
6809{
6810 struct sigmatel_spec *spec = codec->spec;
6811
6812 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
6813 "Bass Speaker Playback Switch", 0))
6814 return -ENOMEM;
6815
6816 spec->gpio_mask |= 0x20;
6817 spec->gpio_dir |= 0x20;
6818 spec->gpio_data |= 0x20;
6819 return 0;
6820}
6821
Matthew Ranostaye035b842007-11-06 11:53:55 +01006822static int patch_stac92hd71bxx(struct hda_codec *codec)
6823{
6824 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02006825 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Takashi Iwai361dab32012-05-09 14:35:27 +02006826 int err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006827
Takashi Iwai361dab32012-05-09 14:35:27 +02006828 err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS,
6829 stac92hd71bxx_pin_nids_4port);
6830 if (err < 0)
6831 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006832
Takashi Iwai361dab32012-05-09 14:35:27 +02006833 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006834 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006835 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006836 switch (codec->vendor_id) {
6837 case 0x111d76b6:
6838 case 0x111d76b7:
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006839 break;
6840 case 0x111d7603:
6841 case 0x111d7608:
6842 /* On 92HD75Bx 0x27 isn't a pin nid */
6843 spec->num_pins--;
6844 /* fallthrough */
6845 default:
6846 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
6847 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006848 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006849
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006850 snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
6851 stac92hd71bxx_fixups);
6852
6853 /* GPIO0 = EAPD */
6854 spec->gpio_mask = 0x01;
6855 spec->gpio_dir = 0x01;
6856 spec->gpio_data = 0x01;
Takashi Iwai41c3b642008-11-18 10:45:15 +01006857
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006858 spec->dmic_nids = stac92hd71bxx_dmic_nids;
6859 spec->dmux_nids = stac92hd71bxx_dmux_nids;
6860
Takashi Iwai6479c632009-07-28 18:20:25 +02006861 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
6862 spec->capvols = stac92hd71bxx_capvols;
6863 spec->capsws = stac92hd71bxx_capsws;
6864
Matthew Ranostay541eee82007-12-14 12:08:04 +01006865 switch (codec->vendor_id) {
6866 case 0x111d76b6: /* 4 Port without Analog Mixer */
6867 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02006868 unmute_init++;
6869 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006870 case 0x111d76b4: /* 6 Port without Analog Mixer */
6871 case 0x111d76b5:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006872 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006873 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006874 stac92hd71bxx_dmic_nids,
6875 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01006876 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006877 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006878 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006879 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006880 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006881
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006882 /* disable VSW */
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006883 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01006884 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
6885 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02006886 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006887 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006888 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006889 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006890 break;
6891 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006892 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006893 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006894
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006895 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006896 default:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006897 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006898 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006899 stac92hd71bxx_dmic_nids,
6900 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02006901 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01006902 }
6903
David Henningsson5e68fb32012-08-16 14:11:09 +02006904 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006905 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
David Henningsson5e68fb32012-08-16 14:11:09 +02006906
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006907 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
6908 snd_hda_sequence_write_cache(codec, unmute_init);
6909
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006910 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04006911 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01006912 spec->aloopback_shift = 0;
6913
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006914 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006915 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006916 spec->mux_nids = stac92hd71bxx_mux_nids;
6917 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006918 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006919 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006920
6921 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
6922 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02006923 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006924 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006925
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006926 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01006927
Takashi Iwai86d190e2009-05-26 15:18:58 +02006928 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006929 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006930 spec->gpio_mask |= spec->gpio_led;
6931 spec->gpio_dir |= spec->gpio_led;
6932 spec->gpio_data |= spec->gpio_led;
6933 } else {
6934 codec->patch_ops.set_power_state =
6935 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006936 }
Takashi Iwai86d190e2009-05-26 15:18:58 +02006937 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04006938
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006939 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006940
Charles Chin9009b0e2011-11-03 10:27:27 +01006941 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006942 if (!err)
Matthew Ranostaye035b842007-11-06 11:53:55 +01006943 err = -EINVAL;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006944 if (err < 0) {
6945 stac92xx_free(codec);
6946 return err;
6947 }
6948
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006949 codec->proc_widget_hook = stac92hd7x_proc_hook;
6950
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006951 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6952
Matthew Ranostaye035b842007-11-06 11:53:55 +01006953 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006954}
Matthew Ranostaye035b842007-11-06 11:53:55 +01006955
Matt2f2f4252005-04-13 14:45:30 +02006956static int patch_stac922x(struct hda_codec *codec)
6957{
6958 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006959 int err;
Matt2f2f4252005-04-13 14:45:30 +02006960
Takashi Iwai361dab32012-05-09 14:35:27 +02006961 err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids),
6962 stac922x_pin_nids);
6963 if (err < 0)
6964 return err;
Matt2f2f4252005-04-13 14:45:30 +02006965
Takashi Iwai361dab32012-05-09 14:35:27 +02006966 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006967 spec->linear_tone_beep = 1;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02006968
Takashi Iwai0a427842013-01-14 15:20:13 +01006969 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
6970 stac922x_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006971
Matt2f2f4252005-04-13 14:45:30 +02006972 spec->adc_nids = stac922x_adc_nids;
6973 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006974 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006975 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006976 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006977 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02006978
Takashi Iwai6479c632009-07-28 18:20:25 +02006979 spec->num_caps = STAC922X_NUM_CAPS;
6980 spec->capvols = stac922x_capvols;
6981 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02006982
6983 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02006984
Takashi Iwai0a427842013-01-14 15:20:13 +01006985 snd_hda_add_verbs(codec, stac922x_core_init);
6986
6987 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6988
Charles Chin9009b0e2011-11-03 10:27:27 +01006989 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0a427842013-01-14 15:20:13 +01006990 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006991 err = -EINVAL;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006992 if (err < 0) {
6993 stac92xx_free(codec);
6994 return err;
6995 }
6996
6997 codec->patch_ops = stac92xx_patch_ops;
6998
Takashi Iwai807a46362007-05-29 19:01:37 +02006999 /* Fix Mux capture level; max to 2 */
7000 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
7001 (0 << AC_AMPCAP_OFFSET_SHIFT) |
7002 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
7003 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
7004 (0 << AC_AMPCAP_MUTE_SHIFT));
7005
Takashi Iwai0a427842013-01-14 15:20:13 +01007006 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7007
Matt Porter3cc08dc2006-01-23 15:27:49 +01007008 return 0;
7009}
7010
7011static int patch_stac927x(struct hda_codec *codec)
7012{
7013 struct sigmatel_spec *spec;
7014 int err;
7015
Takashi Iwai361dab32012-05-09 14:35:27 +02007016 err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids),
7017 stac927x_pin_nids);
7018 if (err < 0)
7019 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007020
Takashi Iwai361dab32012-05-09 14:35:27 +02007021 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007022 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05007023 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwai29ac8362013-01-14 16:03:38 +01007024
7025 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
7026 stac927x_fixups);
Matt Porter3cc08dc2006-01-23 15:27:49 +01007027
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007028 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007029 spec->adc_nids = stac927x_adc_nids;
7030 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
7031 spec->mux_nids = stac927x_mux_nids;
7032 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007033 spec->smux_nids = stac927x_smux_nids;
7034 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04007035 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01007036 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007037 spec->multiout.dac_nids = spec->dac_nids;
7038
Takashi Iwai29ac8362013-01-14 16:03:38 +01007039 /* GPIO0 High = Enable EAPD */
7040 spec->eapd_mask = spec->gpio_mask = 0x01;
7041 spec->gpio_dir = spec->gpio_data = 0x01;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02007042
Takashi Iwai29ac8362013-01-14 16:03:38 +01007043 spec->num_dmics = 0;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007044
Takashi Iwai6479c632009-07-28 18:20:25 +02007045 spec->num_caps = STAC927X_NUM_CAPS;
7046 spec->capvols = stac927x_capvols;
7047 spec->capsws = stac927x_capsws;
7048
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007049 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007050 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007051 spec->aloopback_mask = 0x40;
7052 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05007053 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007054
Takashi Iwai29ac8362013-01-14 16:03:38 +01007055 if (!spec->volknob_init)
7056 snd_hda_add_verbs(codec, stac927x_core_init);
7057
7058 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7059
Charles Chin9009b0e2011-11-03 10:27:27 +01007060 err = stac92xx_parse_auto_config(codec);
Takashi Iwai29ac8362013-01-14 16:03:38 +01007061 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007062 err = -EINVAL;
Mattc7d4b2f2005-06-27 14:59:41 +02007063 if (err < 0) {
7064 stac92xx_free(codec);
7065 return err;
7066 }
Matt2f2f4252005-04-13 14:45:30 +02007067
7068 codec->patch_ops = stac92xx_patch_ops;
7069
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007070 codec->proc_widget_hook = stac927x_proc_hook;
7071
Takashi Iwai52987652008-01-16 16:09:47 +01007072 /*
7073 * !!FIXME!!
7074 * The STAC927x seem to require fairly long delays for certain
7075 * command sequences. With too short delays (even if the answer
7076 * is set to RIRB properly), it results in the silence output
7077 * on some hardwares like Dell.
7078 *
7079 * The below flag enables the longer delay (see get_response
7080 * in hda_intel.c).
7081 */
7082 codec->bus->needs_damn_long_delay = 1;
7083
Takashi Iwai29ac8362013-01-14 16:03:38 +01007084 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwaie28d8322008-12-17 13:48:29 +01007085
Matt2f2f4252005-04-13 14:45:30 +02007086 return 0;
7087}
7088
Matt Porterf3302a52006-07-31 12:49:34 +02007089static int patch_stac9205(struct hda_codec *codec)
7090{
7091 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02007092 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02007093
Takashi Iwai361dab32012-05-09 14:35:27 +02007094 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids),
7095 stac9205_pin_nids);
7096 if (err < 0)
7097 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02007098
Takashi Iwai361dab32012-05-09 14:35:27 +02007099 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007100 spec->linear_tone_beep = 1;
Takashi Iwaife6322c2013-01-14 14:46:51 +01007101
7102 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
7103 stac9205_fixups);
Matt Porterf3302a52006-07-31 12:49:34 +02007104
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007105 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02007106 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007107 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02007108 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007109 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007110 spec->smux_nids = stac9205_smux_nids;
7111 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007112 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02007113 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007114 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01007115 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007116 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007117
Takashi Iwaife6322c2013-01-14 14:46:51 +01007118 snd_hda_add_verbs(codec, stac9205_core_init);
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007119 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02007120
Takashi Iwai6479c632009-07-28 18:20:25 +02007121 spec->num_caps = STAC9205_NUM_CAPS;
7122 spec->capvols = stac9205_capvols;
7123 spec->capsws = stac9205_capsws;
7124
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007125 spec->aloopback_mask = 0x40;
7126 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007127 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02007128
Takashi Iwaife6322c2013-01-14 14:46:51 +01007129 /* GPIO0 High = EAPD */
7130 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
7131 spec->gpio_data = 0x01;
Matt Porter33382402006-12-18 13:17:28 +01007132
Takashi Iwaife6322c2013-01-14 14:46:51 +01007133 /* Turn on/off EAPD per HP plugging */
7134 spec->eapd_switch = 1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01007135
Takashi Iwaife6322c2013-01-14 14:46:51 +01007136 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Matthew Ranostay87d48362007-07-17 11:52:24 +02007137
Charles Chin9009b0e2011-11-03 10:27:27 +01007138 err = stac92xx_parse_auto_config(codec);
Takashi Iwaife6322c2013-01-14 14:46:51 +01007139 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007140 err = -EINVAL;
Matt Porterf3302a52006-07-31 12:49:34 +02007141 if (err < 0) {
7142 stac92xx_free(codec);
7143 return err;
7144 }
7145
7146 codec->patch_ops = stac92xx_patch_ops;
7147
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007148 codec->proc_widget_hook = stac9205_proc_hook;
7149
Takashi Iwaife6322c2013-01-14 14:46:51 +01007150 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7151
Matt Porterf3302a52006-07-31 12:49:34 +02007152 return 0;
7153}
7154
Matt2f2f4252005-04-13 14:45:30 +02007155/*
Guillaume Munch6d859062006-08-22 17:15:47 +02007156 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01007157 */
7158
Takashi Iwai2b635362011-05-02 12:33:43 +02007159static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02007160 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01007161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
7162 {}
7163};
7164
Takashi Iwai2b635362011-05-02 12:33:43 +02007165static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007166 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
7167 0x11, 0x13, 0x14,
7168};
7169
Takashi Iwai2b635362011-05-02 12:33:43 +02007170static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007171 0x8 /*,0x6*/
7172};
7173
Takashi Iwai2b635362011-05-02 12:33:43 +02007174static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007175 0x15
7176};
7177
Takashi Iwai2b635362011-05-02 12:33:43 +02007178static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02007179 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7180};
7181#define stac9872_capsws stac9872_capvols
7182
Takashi Iwaifc268c12013-01-14 14:29:36 +01007183static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
7184 { 0x0a, 0x03211020 },
7185 { 0x0b, 0x411111f0 },
7186 { 0x0c, 0x411111f0 },
7187 { 0x0d, 0x03a15030 },
7188 { 0x0e, 0x411111f0 },
7189 { 0x0f, 0x90170110 },
7190 { 0x11, 0x411111f0 },
7191 { 0x13, 0x411111f0 },
7192 { 0x14, 0x90a7013e },
7193 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007194};
7195
Takashi Iwaifc268c12013-01-14 14:29:36 +01007196static const struct hda_model_fixup stac9872_models[] = {
7197 { .id = STAC_9872_VAIO, .name = "vaio" },
7198 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007199};
7200
Takashi Iwaifc268c12013-01-14 14:29:36 +01007201static const struct hda_fixup stac9872_fixups[] = {
7202 [STAC_9872_VAIO] = {
7203 .type = HDA_FIXUP_PINS,
7204 .v.pins = stac9872_vaio_pin_configs,
7205 },
Takashi Iwai307282c2009-03-12 18:17:58 +01007206};
7207
Takashi Iwaifc268c12013-01-14 14:29:36 +01007208static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02007209 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
7210 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01007211 {} /* terminator */
7212};
7213
Guillaume Munch6d859062006-08-22 17:15:47 +02007214static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01007215{
7216 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01007217 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01007218
Takashi Iwai361dab32012-05-09 14:35:27 +02007219 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids),
7220 stac9872_pin_nids);
7221 if (err < 0)
7222 return err;
7223
7224 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007225 spec->linear_tone_beep = 1;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007226
Takashi Iwaifc268c12013-01-14 14:29:36 +01007227 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
7228 stac9872_fixups);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007229
Takashi Iwai1e137f92009-01-21 07:41:22 +01007230 spec->multiout.dac_nids = spec->dac_nids;
7231 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
7232 spec->adc_nids = stac9872_adc_nids;
7233 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
7234 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02007235 spec->num_caps = 1;
7236 spec->capvols = stac9872_capvols;
7237 spec->capsws = stac9872_capsws;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007238 snd_hda_add_verbs(codec, stac9872_core_init);
7239
7240 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007241
Charles Chin9009b0e2011-11-03 10:27:27 +01007242 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01007243 if (err < 0) {
7244 stac92xx_free(codec);
7245 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007246 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01007247 spec->input_mux = &spec->private_imux;
7248 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007249
7250 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7251
Takashi Iwaidb064e52006-03-16 16:04:58 +01007252 return 0;
7253}
7254
7255
7256/*
Matt2f2f4252005-04-13 14:45:30 +02007257 * patch entries
7258 */
Takashi Iwai2b635362011-05-02 12:33:43 +02007259static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02007260 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
7261 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
7262 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
7263 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
7264 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
7265 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
7266 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02007267 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
7268 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
7269 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
7270 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
7271 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
7272 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01007273 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
7274 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
7275 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
7276 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
7277 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
7278 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
7279 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
7280 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
7281 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
7282 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01007283 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
7284 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
7285 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
7286 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
7287 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
7288 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02007289 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
7290 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02007291 /* The following does not take into account .id=0x83847661 when subsys =
7292 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
7293 * currently not fully supported.
7294 */
7295 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
7296 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
7297 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01007298 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02007299 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
7300 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
7301 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
7302 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
7303 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
7304 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
7305 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
7306 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007307 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007308 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01007309 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007310 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04007311 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02007312 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
7313 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01007314 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
7315 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
7316 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
7317 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007318 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01007319 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
7320 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007321 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01007322 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7323 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7324 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7325 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7326 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7327 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7328 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7329 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02007330 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
7331 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
7332 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
7333 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
7334 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
7335 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
7336 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
7337 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
7338 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
7339 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
7340 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
7341 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
7342 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
7343 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
7344 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02007345 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007346 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06007347 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
7348 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007349 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01007350 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
7351 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
7352 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
7353 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
7354 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
7355 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
7356 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
7357 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
7358 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
7359 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
7360 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
7361 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02007362 {} /* terminator */
7363};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01007364
7365MODULE_ALIAS("snd-hda-codec-id:8384*");
7366MODULE_ALIAS("snd-hda-codec-id:111d*");
7367
7368MODULE_LICENSE("GPL");
7369MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
7370
7371static struct hda_codec_preset_list sigmatel_list = {
7372 .preset = snd_hda_preset_sigmatel,
7373 .owner = THIS_MODULE,
7374};
7375
7376static int __init patch_sigmatel_init(void)
7377{
7378 return snd_hda_add_codec_preset(&sigmatel_list);
7379}
7380
7381static void __exit patch_sigmatel_exit(void)
7382{
7383 snd_hda_delete_codec_preset(&sigmatel_list);
7384}
7385
7386module_init(patch_sigmatel_init)
7387module_exit(patch_sigmatel_exit)