blob: ccad9adae928311cf4336bd5bf7e246a81adb10c [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +010031#include <linux/dmi.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040032#include <linux/module.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020034#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040035#include <sound/jack.h>
Clemens Ladischa74ccea2010-10-22 15:52:34 +020036#include <sound/tlv.h>
Matt2f2f4252005-04-13 14:45:30 +020037#include "hda_codec.h"
38#include "hda_local.h"
Takashi Iwai128bc4b2012-05-07 17:42:31 +020039#include "hda_auto_parser.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020040#include "hda_beep.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020041#include "hda_jack.h"
Matt2f2f4252005-04-13 14:45:30 +020042
Takashi Iwaic6e4c662008-11-25 11:58:19 +010043enum {
44 STAC_VREF_EVENT = 1,
45 STAC_INSERT_EVENT,
46 STAC_PWR_EVENT,
47 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020048 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020049 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010050};
Matt4e550962005-07-04 17:51:39 +020051
Takashi Iwaif5fcc132006-11-24 17:07:44 +010052enum {
53 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010054 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020055 STAC_9200_DELL_D21,
56 STAC_9200_DELL_D22,
57 STAC_9200_DELL_D23,
58 STAC_9200_DELL_M21,
59 STAC_9200_DELL_M22,
60 STAC_9200_DELL_M23,
61 STAC_9200_DELL_M24,
62 STAC_9200_DELL_M25,
63 STAC_9200_DELL_M26,
64 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020065 STAC_9200_M4,
66 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010067 STAC_9200_PANASONIC,
Takashi Iwaid39a3ae2013-01-14 14:06:26 +010068 STAC_9200_EAPD_INIT,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_9200_MODELS
70};
71
72enum {
73 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020074 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020075 STAC_9205_DELL_M43,
76 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010077 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010078 STAC_9205_MODELS
79};
80
81enum {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010082 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010083 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080084 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010085 STAC_DELL_M6_AMIC,
86 STAC_DELL_M6_DMIC,
87 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050088 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020089 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010090 STAC_92HD73XX_MODELS
91};
92
93enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020094 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050095 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050096 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010097 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -050098 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -060099 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600100 STAC_HP_ZEPHYR,
Takashi Iwaia3e19972012-07-26 08:17:20 +0200101 STAC_92HD83XXX_HP_LED,
Takashi Iwaiff8a1e22012-07-31 10:16:59 +0200102 STAC_92HD83XXX_HP_INV_LED,
Takashi Iwai62cbde12012-09-14 11:58:54 +0200103 STAC_92HD83XXX_HP_MIC_LED,
David Henningsson8d032a82012-10-09 12:48:40 +0200104 STAC_92HD83XXX_HEADSET_JACK,
Takashi Iwai372f8c72013-01-14 18:06:34 +0100105 STAC_92HD83XXX_HP,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200106 STAC_92HD83XXX_MODELS
107};
108
109enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100110 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100111 STAC_DELL_M4_1,
112 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500113 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400114 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200115 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100116 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100117 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400118 STAC_HP_DV4_1222NR,
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100119 STAC_92HD71BXX_HP,
120 STAC_92HD71BXX_NO_DMIC,
121 STAC_92HD71BXX_NO_SMUX,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100122 STAC_92HD71BXX_MODELS
123};
124
125enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100126 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200127 STAC_M1,
128 STAC_M1_2,
129 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100130 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200131 STAC_M3,
132 STAC_M5,
133 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100134 STAC_925x_MODELS
135};
136
137enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100138 STAC_D945_REF,
139 STAC_D945GTP3,
140 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200141 STAC_INTEL_MAC_V1,
142 STAC_INTEL_MAC_V2,
143 STAC_INTEL_MAC_V3,
144 STAC_INTEL_MAC_V4,
145 STAC_INTEL_MAC_V5,
Takashi Iwai0a427842013-01-14 15:20:13 +0100146 STAC_INTEL_MAC_AUTO,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300147 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200148 STAC_922X_DELL_D81,
149 STAC_922X_DELL_D82,
150 STAC_922X_DELL_M81,
151 STAC_922X_DELL_M82,
Takashi Iwai0a427842013-01-14 15:20:13 +0100152 STAC_922X_INTEL_MAC_GPIO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100153 STAC_922X_MODELS
154};
155
156enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100157 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100158 STAC_D965_REF,
159 STAC_D965_3ST,
160 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200161 STAC_D965_5ST_NO_FP,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100162 STAC_D965_VERBS,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200163 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100164 STAC_DELL_BIOS,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100165 STAC_DELL_BIOS_SPDIF,
166 STAC_927X_DELL_DMIC,
Takashi Iwai54930532009-10-11 17:38:29 +0200167 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100168 STAC_927X_MODELS
169};
Matt Porter403d1942005-11-29 15:00:51 +0100170
Takashi Iwai307282c2009-03-12 18:17:58 +0100171enum {
Takashi Iwai307282c2009-03-12 18:17:58 +0100172 STAC_9872_VAIO,
173 STAC_9872_MODELS
174};
175
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200176struct sigmatel_mic_route {
177 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200178 signed char mux_idx;
179 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200180};
181
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600182#define MAX_PINS_NUM 16
183#define MAX_ADCS_NUM 4
184#define MAX_DMICS_NUM 4
185
Matt2f2f4252005-04-13 14:45:30 +0200186struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100187 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200188 unsigned int num_mixers;
189
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;
Takashi Iwai372f8c72013-01-14 18:06:34 +0100212 int default_polarity;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100213
Takashi Iwai62cbde12012-09-14 11:58:54 +0200214 unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
215 bool mic_mute_led_on; /* current mic mute state */
216
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200217 /* stream */
218 unsigned int stream_delay;
219
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100220 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200221 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100222 unsigned char aloopback_mask;
223 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200224
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100225 /* power management */
Takashi Iwaic8822462012-05-15 09:11:36 +0200226 unsigned int power_map_bits;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200228 const hda_nid_t *pwr_nids;
229 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100230
Matt2f2f4252005-04-13 14:45:30 +0200231 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100232 struct hda_input_mux *mono_mux;
233 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200234 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100235 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100236 hda_nid_t hp_dacs[5];
237 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200238
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100239 int volume_offset;
240
Matt2f2f4252005-04-13 14:45:30 +0200241 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200242 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200243 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200244 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200245 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200246 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200247 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200248 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100249 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200250 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200251 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200252 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200253
Takashi Iwai2b635362011-05-02 12:33:43 +0200254 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
255 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200256 unsigned int num_caps; /* number of capture volume/switch elements */
257
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200258 struct sigmatel_mic_route ext_mic;
259 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200260 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200261
Takashi Iwaiea734962011-01-17 11:29:34 +0100262 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200263
Mattdabbed62005-06-14 10:19:34 +0200264 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100265 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200266 hda_nid_t anabeep_nid;
267 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200268
Matt2f2f4252005-04-13 14:45:30 +0200269 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200270 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200271 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200272
273 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200274 const struct hda_verb *init;
275 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200276
277 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200278 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100279 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200280 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100281 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200282 struct hda_input_mux *sinput_mux;
283 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400284 unsigned int cur_amux;
285 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200286 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200287
Matt Porter403d1942005-11-29 15:00:51 +0100288 /* i/o switches */
289 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200290 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100291 hda_nid_t line_switch; /* shared line-in for input and output */
292 hda_nid_t mic_switch; /* shared mic-in for input and output */
293 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200294 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200295
Mattc7d4b2f2005-06-27 14:59:41 +0200296 struct hda_pcm pcm_rec[2]; /* PCM information */
297
298 /* dynamic controls and input_mux */
299 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200300 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200301 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200302 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200303 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100304 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600305
306 /* auto spec */
307 unsigned auto_pin_cnt;
308 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
309 unsigned auto_adc_cnt;
310 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
311 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
312 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
313 unsigned long auto_capvols[MAX_ADCS_NUM];
314 unsigned auto_dmic_cnt;
315 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100316
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100317 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200318};
319
Takashi Iwaic8822462012-05-15 09:11:36 +0200320#define AC_VERB_IDT_SET_POWER_MAP 0x7ec
321#define AC_VERB_IDT_GET_POWER_MAP 0xfec
322
Takashi Iwai2b635362011-05-02 12:33:43 +0200323static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200324 0x03,
325};
326
Takashi Iwai2b635362011-05-02 12:33:43 +0200327static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200328 0x0c,
329};
330
Takashi Iwai2b635362011-05-02 12:33:43 +0200331static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200332 0x02,
333};
334
Takashi Iwai2b635362011-05-02 12:33:43 +0200335static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100336 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
337 0x0f, 0x10, 0x11
338};
339
Takashi Iwai2b635362011-05-02 12:33:43 +0200340static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400341 0x26, 0,
342};
343
Takashi Iwai2b635362011-05-02 12:33:43 +0200344static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345 0x1a, 0x1b
346};
347
348#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200349static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100350 0x13, 0x14, 0
351};
352
353#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100354
Takashi Iwai2b635362011-05-02 12:33:43 +0200355static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200356 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100357};
358
Takashi Iwai2b635362011-05-02 12:33:43 +0200359static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100360 0x20, 0x21,
361};
362
Takashi Iwai2b635362011-05-02 12:33:43 +0200363static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200364 0x22, 0x23,
365};
366
Takashi Iwai6479c632009-07-28 18:20:25 +0200367#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200368static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200369 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
370 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
371};
372#define stac92hd73xx_capsws stac92hd73xx_capvols
373
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200374#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200375
Charles Chinafef2cf2011-11-11 08:05:28 +0100376static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
377 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
378 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200379};
380
Takashi Iwai2b635362011-05-02 12:33:43 +0200381static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400382 0x1e, 0,
383};
384
Takashi Iwai2b635362011-05-02 12:33:43 +0200385static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600386 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200387};
388
Takashi Iwai2b635362011-05-02 12:33:43 +0200389static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100390 0x0a, 0x0d, 0x0f
391};
392
Takashi Iwai2b635362011-05-02 12:33:43 +0200393static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100394 0x12, 0x13,
395};
396
Takashi Iwai2b635362011-05-02 12:33:43 +0200397static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100398 0x1a, 0x1b
399};
400
Takashi Iwai2b635362011-05-02 12:33:43 +0200401static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400402 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100403};
404
Takashi Iwai2b635362011-05-02 12:33:43 +0200405static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200406 0x24, 0x25,
407};
408
Matthew Ranostaye035b842007-11-06 11:53:55 +0100409#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200410static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100411 0x18, 0x19, 0
412};
413
Takashi Iwai2b635362011-05-02 12:33:43 +0200414static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
415 0x18, 0
416};
417
418static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400419 0x22, 0
420};
421
Takashi Iwai6479c632009-07-28 18:20:25 +0200422#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200423static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200424 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
426};
427#define stac92hd71bxx_capsws stac92hd71bxx_capvols
428
Takashi Iwai2b635362011-05-02 12:33:43 +0200429static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100430 0x03,
431};
432
Takashi Iwai2b635362011-05-02 12:33:43 +0200433static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100434 0x0f,
435};
436
Takashi Iwai2b635362011-05-02 12:33:43 +0200437static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100438 0x02,
439};
440
Takashi Iwaif6e98522007-10-16 14:27:04 +0200441#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200442static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200443 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200444};
445
Takashi Iwai2b635362011-05-02 12:33:43 +0200446static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100447 0x14,
448};
449
Takashi Iwai2b635362011-05-02 12:33:43 +0200450static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200451 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
452};
Takashi Iwai2b635362011-05-02 12:33:43 +0200453static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200454 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
455};
456
Takashi Iwai2b635362011-05-02 12:33:43 +0200457static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200458 0x06, 0x07,
459};
460
Takashi Iwai2b635362011-05-02 12:33:43 +0200461static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200462 0x12, 0x13,
463};
464
Takashi Iwai6479c632009-07-28 18:20:25 +0200465#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200466static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200467 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
468 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
469};
470#define stac922x_capsws stac922x_capvols
471
Takashi Iwai2b635362011-05-02 12:33:43 +0200472static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500473 0x1f, 0,
474};
475
Takashi Iwai2b635362011-05-02 12:33:43 +0200476static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100477 0x07, 0x08, 0x09
478};
479
Takashi Iwai2b635362011-05-02 12:33:43 +0200480static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100481 0x15, 0x16, 0x17
482};
483
Takashi Iwai2b635362011-05-02 12:33:43 +0200484static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200485 0x21,
486};
487
Takashi Iwai2b635362011-05-02 12:33:43 +0200488static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100489 0x02, 0x03, 0x04, 0x05, 0x06, 0
490};
491
Takashi Iwai2b635362011-05-02 12:33:43 +0200492static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100493 0x1b,
494};
495
Matthew Ranostay7f168592007-10-18 17:38:17 +0200496#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200497static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200498 0x13, 0x14, 0
499};
500
Takashi Iwai6479c632009-07-28 18:20:25 +0200501#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200502static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200503 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
504 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
506};
Takashi Iwai2b635362011-05-02 12:33:43 +0200507static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200508 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
509 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
511};
512
Takashi Iwaiea734962011-01-17 11:29:34 +0100513static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400514 "Digital Playback", "ADAT", "Analog Mux 1",
515 "Analog Mux 2", "Analog Mux 3"
516};
517
Takashi Iwai2b635362011-05-02 12:33:43 +0200518static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200519 0x12, 0x13
520};
521
Takashi Iwai2b635362011-05-02 12:33:43 +0200522static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200523 0x19, 0x1a
524};
525
Takashi Iwai2b635362011-05-02 12:33:43 +0200526static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100527 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100528};
529
Takashi Iwai2b635362011-05-02 12:33:43 +0200530static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200531 0x21,
532};
533
Takashi Iwaif6e98522007-10-16 14:27:04 +0200534#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200535static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200536 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200537};
538
Takashi Iwai6479c632009-07-28 18:20:25 +0200539#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200540static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200541 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
542 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
543};
Takashi Iwai2b635362011-05-02 12:33:43 +0200544static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200545 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
546 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
547};
548
Takashi Iwai2b635362011-05-02 12:33:43 +0200549static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200550 0x08, 0x09, 0x0d, 0x0e,
551 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200552};
553
Takashi Iwai2b635362011-05-02 12:33:43 +0200554static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100555 0x07, 0x08, 0x0a, 0x0b,
556 0x0c, 0x0d, 0x10, 0x11,
557};
558
Takashi Iwai2b635362011-05-02 12:33:43 +0200559static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200560 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
561 0x0f, 0x10, 0x11, 0x15, 0x1b,
562};
563
Takashi Iwai2b635362011-05-02 12:33:43 +0200564static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200567 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100568};
569
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500570#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200571static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500572 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
573 0x00, 0x14, 0x18, 0x19, 0x1e,
574 0x1f, 0x20, 0x27
575};
Takashi Iwai2b635362011-05-02 12:33:43 +0200576static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500579 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100580};
581
Takashi Iwai2b635362011-05-02 12:33:43 +0200582static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x10, 0x11, 0x12, 0x13,
585 0x14, 0x21, 0x22, 0x23,
586};
587
Takashi Iwai2b635362011-05-02 12:33:43 +0200588static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200589 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
590 0x0f, 0x14, 0x16, 0x17, 0x18,
591 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200592};
593
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100594static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
595 unsigned char type, int data);
596static int stac_add_hp_bass_switch(struct hda_codec *codec);
597static void stac92xx_auto_set_pinctl(struct hda_codec *codec,
598 hda_nid_t nid, int pin_type);
Takashi Iwai372f8c72013-01-14 18:06:34 +0100599static int hp_bnb2011_with_dock(struct hda_codec *codec);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100600static int hp_blike_system(u32 subsystem_id);
601static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity);
602
Matt Porter8b657272006-10-26 17:12:59 +0200603static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
604 struct snd_ctl_elem_info *uinfo)
605{
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
608 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
609}
610
611static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_value *ucontrol)
613{
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100616 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200617
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100618 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200619 return 0;
620}
621
622static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *ucontrol)
624{
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100627 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200628
629 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100630 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200631}
632
Matthew Ranostayd9737752008-09-07 12:03:41 +0200633static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_info *uinfo)
635{
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
639}
640
641static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
646 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
647
648 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
649 return 0;
650}
651
652static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400657 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200658 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400659 int err, val;
660 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200661
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400662 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200663 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400664 if (err < 0)
665 return err;
666
667 if (spec->spdif_mute) {
668 if (smux_idx == 0)
669 nid = spec->multiout.dig_out_nid;
670 else
671 nid = codec->slave_dig_outs[smux_idx - 1];
672 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100673 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400674 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100675 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400676 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100677 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
678 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400679 }
680 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200681}
682
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500683static int stac_vrefout_set(struct hda_codec *codec,
684 hda_nid_t nid, unsigned int new_vref)
685{
686 int error, pinctl;
687
688 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
689 pinctl = snd_hda_codec_read(codec, nid, 0,
690 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
691
692 if (pinctl < 0)
693 return pinctl;
694
695 pinctl &= 0xff;
696 pinctl &= ~AC_PINCTL_VREFEN;
697 pinctl |= (new_vref & AC_PINCTL_VREFEN);
698
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200699 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500700 if (error < 0)
701 return error;
702
703 return 1;
704}
705
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200706static unsigned int stac92xx_vref_set(struct hda_codec *codec,
707 hda_nid_t nid, unsigned int new_vref)
708{
Takashi Iwaib8621512009-06-22 08:00:10 +0200709 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200710 unsigned int pincfg;
711 pincfg = snd_hda_codec_read(codec, nid, 0,
712 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
713
714 pincfg &= 0xff;
715 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
716 pincfg |= new_vref;
717
718 if (new_vref == AC_PINCTL_VREF_HIZ)
719 pincfg |= AC_PINCTL_OUT_EN;
720 else
721 pincfg |= AC_PINCTL_IN_EN;
722
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200723 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200724 if (error < 0)
725 return error;
726 else
727 return 1;
728}
729
730static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
731{
732 unsigned int vref;
733 vref = snd_hda_codec_read(codec, nid, 0,
734 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
735 vref &= AC_PINCTL_VREFEN;
736 return vref;
737}
738
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100739static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200740{
741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
742 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200743 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200744}
745
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100746static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200747{
748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
749 struct sigmatel_spec *spec = codec->spec;
750 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
751
752 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
753 return 0;
754}
755
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100756static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200757{
758 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
759 struct sigmatel_spec *spec = codec->spec;
760 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200761 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600762 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200763
Takashi Iwai5207e102009-07-30 13:09:08 +0200764 idx = ucontrol->value.enumerated.item[0];
765 if (idx >= imux->num_items)
766 idx = imux->num_items - 1;
767 prev_idx = spec->cur_mux[adc_idx];
768 if (prev_idx == idx)
769 return 0;
770 if (idx < spec->num_analog_muxes) {
771 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
772 AC_VERB_SET_CONNECT_SEL,
773 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600774 if (prev_idx >= spec->num_analog_muxes &&
775 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200776 imux = spec->dinput_mux;
777 /* 0 = analog */
778 snd_hda_codec_write_cache(codec,
779 spec->dmux_nids[adc_idx], 0,
780 AC_VERB_SET_CONNECT_SEL,
781 imux->items[0].index);
782 }
783 } else {
784 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600785 /* first dimux item is hardcoded to select analog imux,
786 * so lets skip it
787 */
788 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200789 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
790 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600791 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200792 }
793 spec->cur_mux[adc_idx] = idx;
794 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200795}
796
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100797static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
798 struct snd_ctl_elem_info *uinfo)
799{
800 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
801 struct sigmatel_spec *spec = codec->spec;
802 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
803}
804
805static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
806 struct snd_ctl_elem_value *ucontrol)
807{
808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
809 struct sigmatel_spec *spec = codec->spec;
810
811 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
812 return 0;
813}
814
815static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
816 struct snd_ctl_elem_value *ucontrol)
817{
818 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
819 struct sigmatel_spec *spec = codec->spec;
820
821 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
822 spec->mono_nid, &spec->cur_mmux);
823}
824
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200825#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
826
827static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
828 struct snd_ctl_elem_value *ucontrol)
829{
830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100831 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200832 struct sigmatel_spec *spec = codec->spec;
833
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 ucontrol->value.integer.value[0] = !!(spec->aloopback &
835 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200836 return 0;
837}
838
839static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
840 struct snd_ctl_elem_value *ucontrol)
841{
842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
843 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100844 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200845 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100846 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200847
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100848 idx_val = spec->aloopback_mask << idx;
849 if (ucontrol->value.integer.value[0])
850 val = spec->aloopback | idx_val;
851 else
852 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100853 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200854 return 0;
855
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100856 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200857
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100858 /* Only return the bits defined by the shift value of the
859 * first two bytes of the mask
860 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200861 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100862 kcontrol->private_value & 0xFFFF, 0x0);
863 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200864
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100865 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200866 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100867 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200868 } else {
869 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100870 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200871 }
872
873 snd_hda_codec_write_cache(codec, codec->afg, 0,
874 kcontrol->private_value >> 16, dac_mode);
875
876 return 1;
877}
878
Takashi Iwai2b635362011-05-02 12:33:43 +0200879static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200880 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200881 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200882 {}
883};
884
Takashi Iwai2b635362011-05-02 12:33:43 +0200885static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200886 /* set dac0mux for dac converter */
887 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
888 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
889 {}
890};
891
Takashi Iwai2b635362011-05-02 12:33:43 +0200892static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100893 /* set master volume to max value without distortion
894 * and direct control */
895 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100896 {}
897};
898
Takashi Iwai2b635362011-05-02 12:33:43 +0200899static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100900 /* set master volume and direct control */
901 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100902 {}
903};
904
Takashi Iwai2b635362011-05-02 12:33:43 +0200905static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200906 /* power state controls amps */
907 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200908 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200909};
910
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600911static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
912 { 0x22, 0x785, 0x43 },
913 { 0x22, 0x782, 0xe0 },
914 { 0x22, 0x795, 0x00 },
915 {}
916};
917
Takashi Iwai2b635362011-05-02 12:33:43 +0200918static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100919 /* set master volume and direct control */
920 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200921 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100922};
923
Takashi Iwai2b635362011-05-02 12:33:43 +0200924static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500925 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
926 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100927 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
928 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100929 {}
930};
931
Takashi Iwai2b635362011-05-02 12:33:43 +0200932static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100933 /* set dac0mux for dac converter */
934 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100935 /* mute the master volume */
936 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100937 {}
938};
939
Takashi Iwai2b635362011-05-02 12:33:43 +0200940static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200941 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200942 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200943 {}
944};
945
Takashi Iwai2b635362011-05-02 12:33:43 +0200946static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200947 /* unmute node 0x1b */
948 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
949 /* select node 0x03 as DAC */
950 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
951 {}
952};
953
Takashi Iwai2b635362011-05-02 12:33:43 +0200954static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200955 /* don't set delta bit */
956 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
957 /* unmute node 0x1b */
958 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
959 /* select node 0x03 as DAC */
960 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
961 {}
962};
963
Takashi Iwai2b635362011-05-02 12:33:43 +0200964static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100965 /* set master volume and direct control */
966 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200967 /* enable analog pc beep path */
968 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100969 {}
970};
971
Takashi Iwai2b635362011-05-02 12:33:43 +0200972static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200973 /* don't set delta bit */
974 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
975 /* enable analog pc beep path */
976 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
977 {}
978};
979
Takashi Iwai2b635362011-05-02 12:33:43 +0200980static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200981 /* set master volume and direct control */
982 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200983 /* enable analog pc beep path */
984 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200985 {}
986};
987
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100988#define STAC_MONO_MUX \
989 { \
990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
991 .name = "Mono Mux", \
992 .count = 1, \
993 .info = stac92xx_mono_mux_enum_info, \
994 .get = stac92xx_mono_mux_enum_get, \
995 .put = stac92xx_mono_mux_enum_put, \
996 }
997
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100998#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200999 { \
1000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1001 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001002 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001003 .info = stac92xx_aloopback_info, \
1004 .get = stac92xx_aloopback_get, \
1005 .put = stac92xx_aloopback_put, \
1006 .private_value = verb_read | (verb_write << 16), \
1007 }
1008
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001009#define DC_BIAS(xname, idx, nid) \
1010 { \
1011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1012 .name = xname, \
1013 .index = idx, \
1014 .info = stac92xx_dc_bias_info, \
1015 .get = stac92xx_dc_bias_get, \
1016 .put = stac92xx_dc_bias_put, \
1017 .private_value = nid, \
1018 }
1019
Takashi Iwai2b635362011-05-02 12:33:43 +02001020static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001021 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001023 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1024 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001025 { } /* end */
1026};
1027
Takashi Iwai2b635362011-05-02 12:33:43 +02001028static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001029 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1030 {}
1031};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001032
Takashi Iwai2b635362011-05-02 12:33:43 +02001033static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001034 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1035 {}
1036};
1037
Takashi Iwai2b635362011-05-02 12:33:43 +02001038static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001039 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1040 {}
1041};
1042
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001043
Takashi Iwai2b635362011-05-02 12:33:43 +02001044static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001045 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1046};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001047
Takashi Iwai2b635362011-05-02 12:33:43 +02001048static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001049 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1050 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001051 { } /* end */
1052};
1053
Takashi Iwai2b635362011-05-02 12:33:43 +02001054static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001055 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1056 {}
1057};
1058
Takashi Iwai2b635362011-05-02 12:33:43 +02001059static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001060 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1061 {}
1062};
1063
Takashi Iwai1697055e2007-12-18 18:05:52 +01001064static struct snd_kcontrol_new stac_dmux_mixer = {
1065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1066 .name = "Digital Input Source",
1067 /* count set later */
1068 .info = stac92xx_dmux_enum_info,
1069 .get = stac92xx_dmux_enum_get,
1070 .put = stac92xx_dmux_enum_put,
1071};
1072
Matthew Ranostayd9737752008-09-07 12:03:41 +02001073static struct snd_kcontrol_new stac_smux_mixer = {
1074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001075 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001076 /* count set later */
1077 .info = stac92xx_smux_enum_info,
1078 .get = stac92xx_smux_enum_get,
1079 .put = stac92xx_smux_enum_put,
1080};
1081
Takashi Iwai9322ca52012-02-03 14:28:01 +01001082static const char * const slave_pfxs[] = {
1083 "Front", "Surround", "Center", "LFE", "Side",
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01001084 "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001085 NULL
1086};
1087
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001088static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1089
1090static void stac92xx_vmaster_hook(void *private_data, int val)
1091{
1092 stac92xx_update_led_status(private_data, val);
1093}
1094
Takashi Iwai603c4012008-07-30 15:01:44 +02001095static void stac92xx_free_kctls(struct hda_codec *codec);
1096
Matt2f2f4252005-04-13 14:45:30 +02001097static int stac92xx_build_controls(struct hda_codec *codec)
1098{
1099 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001100 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001101 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001102 int i;
Matt2f2f4252005-04-13 14:45:30 +02001103
Takashi Iwai6479c632009-07-28 18:20:25 +02001104 if (spec->mixer) {
1105 err = snd_hda_add_new_ctls(codec, spec->mixer);
1106 if (err < 0)
1107 return err;
1108 }
Mattc7d4b2f2005-06-27 14:59:41 +02001109
1110 for (i = 0; i < spec->num_mixers; i++) {
1111 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1112 if (err < 0)
1113 return err;
1114 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001115 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1116 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001117 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001118 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001119 snd_ctl_new1(&stac_dmux_mixer, codec));
1120 if (err < 0)
1121 return err;
1122 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001123 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001124 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1125 struct hda_input_mux *smux = &spec->private_smux;
1126 /* check for mute support on SPDIF out */
1127 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001128 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001129 spec->spdif_mute = 1;
1130 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001131 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001132 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001133 snd_ctl_new1(&stac_smux_mixer, codec));
1134 if (err < 0)
1135 return err;
1136 }
Mattc7d4b2f2005-06-27 14:59:41 +02001137
Mattdabbed62005-06-14 10:19:34 +02001138 if (spec->multiout.dig_out_nid) {
Takashi Iwaidcda5802012-10-12 17:24:51 +02001139 err = snd_hda_create_dig_out_ctls(codec,
1140 spec->multiout.dig_out_nid,
1141 spec->multiout.dig_out_nid,
1142 spec->autocfg.dig_out_type[0]);
Mattdabbed62005-06-14 10:19:34 +02001143 if (err < 0)
1144 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001145 err = snd_hda_create_spdif_share_sw(codec,
1146 &spec->multiout);
1147 if (err < 0)
1148 return err;
1149 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001150 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001151 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001152 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1153 if (err < 0)
1154 return err;
1155 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001156
1157 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001158 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1159 HDA_OUTPUT, vmaster_tlv);
1160 /* correct volume offset */
1161 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1162 /* minimum value is actually mute */
1163 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1164 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1165 vmaster_tlv, slave_pfxs,
1166 "Playback Volume");
1167 if (err < 0)
1168 return err;
1169
1170 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1171 NULL, slave_pfxs,
1172 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001173 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001174 if (err < 0)
1175 return err;
1176
1177 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001178 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001179 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001180 if (err < 0)
1181 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001182 }
1183
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001184 if (spec->aloopback_ctl &&
1185 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1186 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1187 if (err < 0)
1188 return err;
1189 }
1190
Takashi Iwai603c4012008-07-30 15:01:44 +02001191 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001192
Takashi Iwai01a61e12011-10-28 00:03:22 +02001193 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1194 if (err < 0)
1195 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001196
Mattdabbed62005-06-14 10:19:34 +02001197 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001198}
1199
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001200static const struct hda_pintbl ref9200_pin_configs[] = {
1201 { 0x08, 0x01c47010 },
1202 { 0x09, 0x01447010 },
1203 { 0x0d, 0x0221401f },
1204 { 0x0e, 0x01114010 },
1205 { 0x0f, 0x02a19020 },
1206 { 0x10, 0x01a19021 },
1207 { 0x11, 0x90100140 },
1208 { 0x12, 0x01813122 },
1209 {}
Matt2f2f4252005-04-13 14:45:30 +02001210};
1211
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001212static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1213 { 0x08, 0x400000fe },
1214 { 0x09, 0x404500f4 },
1215 { 0x0d, 0x400100f0 },
1216 { 0x0e, 0x90110010 },
1217 { 0x0f, 0x400100f1 },
1218 { 0x10, 0x02a1902e },
1219 { 0x11, 0x500000f2 },
1220 { 0x12, 0x500000f3 },
1221 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001222};
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001223
1224static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1225 { 0x08, 0x400000fe },
1226 { 0x09, 0x404500f4 },
1227 { 0x0d, 0x400100f0 },
1228 { 0x0e, 0x90110010 },
1229 { 0x0f, 0x400100f1 },
1230 { 0x10, 0x02a1902e },
1231 { 0x11, 0x500000f2 },
1232 { 0x12, 0x500000f3 },
1233 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001234};
1235
1236/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001237 STAC 9200 pin configs for
1238 102801A8
1239 102801DE
1240 102801E8
1241*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001242static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1243 { 0x08, 0x400001f0 },
1244 { 0x09, 0x400001f1 },
1245 { 0x0d, 0x02214030 },
1246 { 0x0e, 0x01014010 },
1247 { 0x0f, 0x02a19020 },
1248 { 0x10, 0x01a19021 },
1249 { 0x11, 0x90100140 },
1250 { 0x12, 0x01813122 },
1251 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001252};
1253
1254/*
1255 STAC 9200 pin configs for
1256 102801C0
1257 102801C1
1258*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001259static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1260 { 0x08, 0x400001f0 },
1261 { 0x09, 0x400001f1 },
1262 { 0x0d, 0x0221401f },
1263 { 0x0e, 0x01014010 },
1264 { 0x0f, 0x01813020 },
1265 { 0x10, 0x02a19021 },
1266 { 0x11, 0x90100140 },
1267 { 0x12, 0x400001f2 },
1268 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001269};
1270
1271/*
1272 STAC 9200 pin configs for
1273 102801C4 (Dell Dimension E310)
1274 102801C5
1275 102801C7
1276 102801D9
1277 102801DA
1278 102801E3
1279*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001280static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1281 { 0x08, 0x400001f0 },
1282 { 0x09, 0x400001f1 },
1283 { 0x0d, 0x0221401f },
1284 { 0x0e, 0x01014010 },
1285 { 0x0f, 0x01813020 },
1286 { 0x10, 0x01a19021 },
1287 { 0x11, 0x90100140 },
1288 { 0x12, 0x400001f2 },
1289 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001290};
1291
1292
1293/*
1294 STAC 9200-32 pin configs for
1295 102801B5 (Dell Inspiron 630m)
1296 102801D8 (Dell Inspiron 640m)
1297*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001298static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1299 { 0x08, 0x40c003fa },
1300 { 0x09, 0x03441340 },
1301 { 0x0d, 0x0321121f },
1302 { 0x0e, 0x90170310 },
1303 { 0x0f, 0x408003fb },
1304 { 0x10, 0x03a11020 },
1305 { 0x11, 0x401003fc },
1306 { 0x12, 0x403003fd },
1307 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001308};
1309
1310/*
1311 STAC 9200-32 pin configs for
1312 102801C2 (Dell Latitude D620)
1313 102801C8
1314 102801CC (Dell Latitude D820)
1315 102801D4
1316 102801D6
1317*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001318static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1319 { 0x08, 0x40c003fa },
1320 { 0x09, 0x0144131f },
1321 { 0x0d, 0x0321121f },
1322 { 0x0e, 0x90170310 },
1323 { 0x0f, 0x90a70321 },
1324 { 0x10, 0x03a11020 },
1325 { 0x11, 0x401003fb },
1326 { 0x12, 0x40f000fc },
1327 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001328};
1329
1330/*
1331 STAC 9200-32 pin configs for
1332 102801CE (Dell XPS M1710)
1333 102801CF (Dell Precision M90)
1334*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001335static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1336 { 0x08, 0x40c003fa },
1337 { 0x09, 0x01441340 },
1338 { 0x0d, 0x0421421f },
1339 { 0x0e, 0x90170310 },
1340 { 0x0f, 0x408003fb },
1341 { 0x10, 0x04a1102e },
1342 { 0x11, 0x90170311 },
1343 { 0x12, 0x403003fc },
1344 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001345};
1346
1347/*
1348 STAC 9200-32 pin configs for
1349 102801C9
1350 102801CA
1351 102801CB (Dell Latitude 120L)
1352 102801D3
1353*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001354static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1355 { 0x08, 0x40c003fa },
1356 { 0x09, 0x404003fb },
1357 { 0x0d, 0x0321121f },
1358 { 0x0e, 0x90170310 },
1359 { 0x0f, 0x408003fc },
1360 { 0x10, 0x03a11020 },
1361 { 0x11, 0x401003fd },
1362 { 0x12, 0x403003fe },
1363 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364};
1365
1366/*
1367 STAC 9200-32 pin configs for
1368 102801BD (Dell Inspiron E1505n)
1369 102801EE
1370 102801EF
1371*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001372static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1373 { 0x08, 0x40c003fa },
1374 { 0x09, 0x01441340 },
1375 { 0x0d, 0x0421121f },
1376 { 0x0e, 0x90170310 },
1377 { 0x0f, 0x408003fb },
1378 { 0x10, 0x04a11020 },
1379 { 0x11, 0x401003fc },
1380 { 0x12, 0x403003fd },
1381 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001382};
1383
1384/*
1385 STAC 9200-32 pin configs for
1386 102801F5 (Dell Inspiron 1501)
1387 102801F6
1388*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001389static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1390 { 0x08, 0x40c003fa },
1391 { 0x09, 0x404003fb },
1392 { 0x0d, 0x0421121f },
1393 { 0x0e, 0x90170310 },
1394 { 0x0f, 0x408003fc },
1395 { 0x10, 0x04a11020 },
1396 { 0x11, 0x401003fd },
1397 { 0x12, 0x403003fe },
1398 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399};
1400
1401/*
1402 STAC 9200-32
1403 102801CD (Dell Inspiron E1705/9400)
1404*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001405static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1406 { 0x08, 0x40c003fa },
1407 { 0x09, 0x01441340 },
1408 { 0x0d, 0x0421121f },
1409 { 0x0e, 0x90170310 },
1410 { 0x0f, 0x90170310 },
1411 { 0x10, 0x04a11020 },
1412 { 0x11, 0x90170310 },
1413 { 0x12, 0x40f003fc },
1414 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001415};
1416
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001417static const struct hda_pintbl oqo9200_pin_configs[] = {
1418 { 0x08, 0x40c000f0 },
1419 { 0x09, 0x404000f1 },
1420 { 0x0d, 0x0221121f },
1421 { 0x0e, 0x02211210 },
1422 { 0x0f, 0x90170111 },
1423 { 0x10, 0x90a70120 },
1424 { 0x11, 0x400000f2 },
1425 { 0x12, 0x400000f3 },
1426 {}
Tobin Davisbf277782008-02-03 20:31:47 +01001427};
1428
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001429
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001430static void stac9200_fixup_panasonic(struct hda_codec *codec,
1431 const struct hda_fixup *fix, int action)
1432{
1433 struct sigmatel_spec *spec = codec->spec;
1434
1435 switch (action) {
1436 case HDA_FIXUP_ACT_PRE_PROBE:
1437 spec->gpio_mask = spec->gpio_dir = 0x09;
1438 spec->gpio_data = 0x00;
1439 break;
1440 case HDA_FIXUP_ACT_PROBE:
1441 /* CF-74 has no headphone detection, and the driver should *NOT*
1442 * do detection and HP/speaker toggle because the hardware does it.
1443 */
1444 spec->hp_detect = 0;
1445 break;
1446 }
1447}
1448
1449
1450static const struct hda_fixup stac9200_fixups[] = {
1451 [STAC_REF] = {
1452 .type = HDA_FIXUP_PINS,
1453 .v.pins = ref9200_pin_configs,
1454 },
1455 [STAC_9200_OQO] = {
1456 .type = HDA_FIXUP_PINS,
1457 .v.pins = oqo9200_pin_configs,
1458 .chained = true,
1459 .chain_id = STAC_9200_EAPD_INIT,
1460 },
1461 [STAC_9200_DELL_D21] = {
1462 .type = HDA_FIXUP_PINS,
1463 .v.pins = dell9200_d21_pin_configs,
1464 },
1465 [STAC_9200_DELL_D22] = {
1466 .type = HDA_FIXUP_PINS,
1467 .v.pins = dell9200_d22_pin_configs,
1468 },
1469 [STAC_9200_DELL_D23] = {
1470 .type = HDA_FIXUP_PINS,
1471 .v.pins = dell9200_d23_pin_configs,
1472 },
1473 [STAC_9200_DELL_M21] = {
1474 .type = HDA_FIXUP_PINS,
1475 .v.pins = dell9200_m21_pin_configs,
1476 },
1477 [STAC_9200_DELL_M22] = {
1478 .type = HDA_FIXUP_PINS,
1479 .v.pins = dell9200_m22_pin_configs,
1480 },
1481 [STAC_9200_DELL_M23] = {
1482 .type = HDA_FIXUP_PINS,
1483 .v.pins = dell9200_m23_pin_configs,
1484 },
1485 [STAC_9200_DELL_M24] = {
1486 .type = HDA_FIXUP_PINS,
1487 .v.pins = dell9200_m24_pin_configs,
1488 },
1489 [STAC_9200_DELL_M25] = {
1490 .type = HDA_FIXUP_PINS,
1491 .v.pins = dell9200_m25_pin_configs,
1492 },
1493 [STAC_9200_DELL_M26] = {
1494 .type = HDA_FIXUP_PINS,
1495 .v.pins = dell9200_m26_pin_configs,
1496 },
1497 [STAC_9200_DELL_M27] = {
1498 .type = HDA_FIXUP_PINS,
1499 .v.pins = dell9200_m27_pin_configs,
1500 },
1501 [STAC_9200_M4] = {
1502 .type = HDA_FIXUP_PINS,
1503 .v.pins = gateway9200_m4_pin_configs,
1504 .chained = true,
1505 .chain_id = STAC_9200_EAPD_INIT,
1506 },
1507 [STAC_9200_M4_2] = {
1508 .type = HDA_FIXUP_PINS,
1509 .v.pins = gateway9200_m4_2_pin_configs,
1510 .chained = true,
1511 .chain_id = STAC_9200_EAPD_INIT,
1512 },
1513 [STAC_9200_PANASONIC] = {
1514 .type = HDA_FIXUP_FUNC,
1515 .v.func = stac9200_fixup_panasonic,
1516 },
1517 [STAC_9200_EAPD_INIT] = {
1518 .type = HDA_FIXUP_VERBS,
1519 .v.verbs = (const struct hda_verb[]) {
1520 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1521 {}
1522 },
1523 },
Matt Porter403d1942005-11-29 15:00:51 +01001524};
1525
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001526static const struct hda_model_fixup stac9200_models[] = {
1527 { .id = STAC_REF, .name = "ref" },
1528 { .id = STAC_9200_OQO, .name = "oqo" },
1529 { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1530 { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1531 { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1532 { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1533 { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1534 { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1535 { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1536 { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1537 { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1538 { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1539 { .id = STAC_9200_M4, .name = "gateway-m4" },
1540 { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1541 { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1542 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001543};
1544
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001545static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001546 /* SigmaTel reference board */
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1548 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001549 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1550 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001551 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1553 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001555 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1557 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1559 "unknown Dell", STAC_9200_DELL_D22),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1561 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001563 "Dell Latitude D620", STAC_9200_DELL_M22),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1565 "unknown Dell", STAC_9200_DELL_D23),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1567 "unknown Dell", STAC_9200_DELL_D23),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1569 "unknown Dell", STAC_9200_DELL_M22),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1571 "unknown Dell", STAC_9200_DELL_M24),
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1573 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001574 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001575 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001576 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001577 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001579 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001581 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001583 "Dell Precision M90", STAC_9200_DELL_M23),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1585 "unknown Dell", STAC_9200_DELL_M22),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1587 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001589 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001591 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1593 "unknown Dell", STAC_9200_DELL_D23),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1595 "unknown Dell", STAC_9200_DELL_D23),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1597 "unknown Dell", STAC_9200_DELL_D21),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1599 "unknown Dell", STAC_9200_DELL_D23),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1601 "unknown Dell", STAC_9200_DELL_D21),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1603 "unknown Dell", STAC_9200_DELL_M25),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1605 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001607 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1609 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001610 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001611 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001612 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001613 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1614 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1615 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001616 /* OQO Mobile */
1617 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001618 {} /* terminator */
1619};
1620
Takashi Iwaid2077d42013-01-14 14:20:16 +01001621static const struct hda_pintbl ref925x_pin_configs[] = {
1622 { 0x07, 0x40c003f0 },
1623 { 0x08, 0x424503f2 },
1624 { 0x0a, 0x01813022 },
1625 { 0x0b, 0x02a19021 },
1626 { 0x0c, 0x90a70320 },
1627 { 0x0d, 0x02214210 },
1628 { 0x10, 0x01019020 },
1629 { 0x11, 0x9033032e },
1630 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001631};
1632
Takashi Iwaid2077d42013-01-14 14:20:16 +01001633static const struct hda_pintbl stac925xM1_pin_configs[] = {
1634 { 0x07, 0x40c003f4 },
1635 { 0x08, 0x424503f2 },
1636 { 0x0a, 0x400000f3 },
1637 { 0x0b, 0x02a19020 },
1638 { 0x0c, 0x40a000f0 },
1639 { 0x0d, 0x90100210 },
1640 { 0x10, 0x400003f1 },
1641 { 0x11, 0x9033032e },
1642 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001643};
1644
Takashi Iwaid2077d42013-01-14 14:20:16 +01001645static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1646 { 0x07, 0x40c003f4 },
1647 { 0x08, 0x424503f2 },
1648 { 0x0a, 0x400000f3 },
1649 { 0x0b, 0x02a19020 },
1650 { 0x0c, 0x40a000f0 },
1651 { 0x0d, 0x90100210 },
1652 { 0x10, 0x400003f1 },
1653 { 0x11, 0x9033032e },
1654 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001655};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001656
Takashi Iwaid2077d42013-01-14 14:20:16 +01001657static const struct hda_pintbl stac925xM2_pin_configs[] = {
1658 { 0x07, 0x40c003f4 },
1659 { 0x08, 0x424503f2 },
1660 { 0x0a, 0x400000f3 },
1661 { 0x0b, 0x02a19020 },
1662 { 0x0c, 0x40a000f0 },
1663 { 0x0d, 0x90100210 },
1664 { 0x10, 0x400003f1 },
1665 { 0x11, 0x9033032e },
1666 {}
Tobin Davis2c11f952007-05-17 09:36:34 +02001667};
1668
Takashi Iwaid2077d42013-01-14 14:20:16 +01001669static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1670 { 0x07, 0x40c003f4 },
1671 { 0x08, 0x424503f2 },
1672 { 0x0a, 0x400000f3 },
1673 { 0x0b, 0x02a19020 },
1674 { 0x0c, 0x40a000f0 },
1675 { 0x0d, 0x90100210 },
1676 { 0x10, 0x400003f1 },
1677 { 0x11, 0x9033032e },
1678 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001679};
1680
Takashi Iwaid2077d42013-01-14 14:20:16 +01001681static const struct hda_pintbl stac925xM3_pin_configs[] = {
1682 { 0x07, 0x40c003f4 },
1683 { 0x08, 0x424503f2 },
1684 { 0x0a, 0x400000f3 },
1685 { 0x0b, 0x02a19020 },
1686 { 0x0c, 0x40a000f0 },
1687 { 0x0d, 0x90100210 },
1688 { 0x10, 0x400003f1 },
1689 { 0x11, 0x503303f3 },
1690 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001691};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001692
Takashi Iwaid2077d42013-01-14 14:20:16 +01001693static const struct hda_pintbl stac925xM5_pin_configs[] = {
1694 { 0x07, 0x40c003f4 },
1695 { 0x08, 0x424503f2 },
1696 { 0x0a, 0x400000f3 },
1697 { 0x0b, 0x02a19020 },
1698 { 0x0c, 0x40a000f0 },
1699 { 0x0d, 0x90100210 },
1700 { 0x10, 0x400003f1 },
1701 { 0x11, 0x9033032e },
1702 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001703};
1704
Takashi Iwaid2077d42013-01-14 14:20:16 +01001705static const struct hda_pintbl stac925xM6_pin_configs[] = {
1706 { 0x07, 0x40c003f4 },
1707 { 0x08, 0x424503f2 },
1708 { 0x0a, 0x400000f3 },
1709 { 0x0b, 0x02a19020 },
1710 { 0x0c, 0x40a000f0 },
1711 { 0x0d, 0x90100210 },
1712 { 0x10, 0x400003f1 },
1713 { 0x11, 0x90330320 },
1714 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001715};
1716
Takashi Iwaid2077d42013-01-14 14:20:16 +01001717static const struct hda_fixup stac925x_fixups[] = {
1718 [STAC_REF] = {
1719 .type = HDA_FIXUP_PINS,
1720 .v.pins = ref925x_pin_configs,
1721 },
1722 [STAC_M1] = {
1723 .type = HDA_FIXUP_PINS,
1724 .v.pins = stac925xM1_pin_configs,
1725 },
1726 [STAC_M1_2] = {
1727 .type = HDA_FIXUP_PINS,
1728 .v.pins = stac925xM1_2_pin_configs,
1729 },
1730 [STAC_M2] = {
1731 .type = HDA_FIXUP_PINS,
1732 .v.pins = stac925xM2_pin_configs,
1733 },
1734 [STAC_M2_2] = {
1735 .type = HDA_FIXUP_PINS,
1736 .v.pins = stac925xM2_2_pin_configs,
1737 },
1738 [STAC_M3] = {
1739 .type = HDA_FIXUP_PINS,
1740 .v.pins = stac925xM3_pin_configs,
1741 },
1742 [STAC_M5] = {
1743 .type = HDA_FIXUP_PINS,
1744 .v.pins = stac925xM5_pin_configs,
1745 },
1746 [STAC_M6] = {
1747 .type = HDA_FIXUP_PINS,
1748 .v.pins = stac925xM6_pin_configs,
1749 },
Tobin Davis8e21c342007-01-08 11:04:17 +01001750};
1751
Takashi Iwaid2077d42013-01-14 14:20:16 +01001752static const struct hda_model_fixup stac925x_models[] = {
1753 { .id = STAC_REF, .name = "ref" },
1754 { .id = STAC_M1, .name = "m1" },
1755 { .id = STAC_M1_2, .name = "m1-2" },
1756 { .id = STAC_M2, .name = "m2" },
1757 { .id = STAC_M2_2, .name = "m2-2" },
1758 { .id = STAC_M3, .name = "m3" },
1759 { .id = STAC_M5, .name = "m5" },
1760 { .id = STAC_M6, .name = "m6" },
1761 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001762};
1763
Takashi Iwaid2077d42013-01-14 14:20:16 +01001764static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1765 /* SigmaTel reference board */
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1767 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1768 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1769
1770 /* Default table for unknown ID */
1771 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1772
1773 /* gateway machines are checked via codec ssid */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001774 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1775 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1776 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1777 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001778 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001779 /* Not sure about the brand name for those */
1780 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1781 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1782 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1783 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001784 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001785};
1786
Takashi Iwai55e30142013-01-14 17:30:04 +01001787static const struct hda_pintbl ref92hd73xx_pin_configs[] = {
1788 { 0x0a, 0x02214030 },
1789 { 0x0b, 0x02a19040 },
1790 { 0x0c, 0x01a19020 },
1791 { 0x0d, 0x02214030 },
1792 { 0x0e, 0x0181302e },
1793 { 0x0f, 0x01014010 },
1794 { 0x10, 0x01014020 },
1795 { 0x11, 0x01014030 },
1796 { 0x12, 0x02319040 },
1797 { 0x13, 0x90a000f0 },
1798 { 0x14, 0x90a000f0 },
1799 { 0x22, 0x01452050 },
1800 { 0x23, 0x01452050 },
1801 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01001802};
1803
Takashi Iwai55e30142013-01-14 17:30:04 +01001804static const struct hda_pintbl dell_m6_pin_configs[] = {
1805 { 0x0a, 0x0321101f },
1806 { 0x0b, 0x4f00000f },
1807 { 0x0c, 0x4f0000f0 },
1808 { 0x0d, 0x90170110 },
1809 { 0x0e, 0x03a11020 },
1810 { 0x0f, 0x0321101f },
1811 { 0x10, 0x4f0000f0 },
1812 { 0x11, 0x4f0000f0 },
1813 { 0x12, 0x4f0000f0 },
1814 { 0x13, 0x90a60160 },
1815 { 0x14, 0x4f0000f0 },
1816 { 0x22, 0x4f0000f0 },
1817 { 0x23, 0x4f0000f0 },
1818 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001819};
1820
Takashi Iwai55e30142013-01-14 17:30:04 +01001821static const struct hda_pintbl alienware_m17x_pin_configs[] = {
1822 { 0x0a, 0x0321101f },
1823 { 0x0b, 0x0321101f },
1824 { 0x0c, 0x03a11020 },
1825 { 0x0d, 0x03014020 },
1826 { 0x0e, 0x90170110 },
1827 { 0x0f, 0x4f0000f0 },
1828 { 0x10, 0x4f0000f0 },
1829 { 0x11, 0x4f0000f0 },
1830 { 0x12, 0x4f0000f0 },
1831 { 0x13, 0x90a60160 },
1832 { 0x14, 0x4f0000f0 },
1833 { 0x22, 0x4f0000f0 },
1834 { 0x23, 0x904601b0 },
1835 {}
Takashi Iwai842ae632009-09-02 07:43:08 +02001836};
1837
Takashi Iwai55e30142013-01-14 17:30:04 +01001838static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1839 { 0x0a, 0x02214230 },
1840 { 0x0b, 0x02A19240 },
1841 { 0x0c, 0x01013214 },
1842 { 0x0d, 0x01014210 },
1843 { 0x0e, 0x01A19250 },
1844 { 0x0f, 0x01011212 },
1845 { 0x10, 0x01016211 },
1846 {}
Alexey Fisher52dc4382009-12-12 11:16:41 +02001847};
1848
Takashi Iwai55e30142013-01-14 17:30:04 +01001849static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
1850 const struct hda_fixup *fix, int action)
1851{
1852 struct sigmatel_spec *spec = codec->spec;
1853
1854 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1855 return;
1856
1857 snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs);
1858 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
1859}
1860
1861static void stac92hd73xx_fixup_dell(struct hda_codec *codec)
1862{
1863 struct sigmatel_spec *spec = codec->spec;
1864
1865 snd_hda_apply_pincfgs(codec, dell_m6_pin_configs);
1866 spec->num_smuxes = 0;
1867 spec->eapd_switch = 0;
1868}
1869
1870static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec,
1871 const struct hda_fixup *fix, int action)
1872{
1873 struct sigmatel_spec *spec = codec->spec;
1874
1875 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1876 return;
1877
1878 stac92hd73xx_fixup_dell(codec);
1879 snd_hda_add_verbs(codec, dell_eq_core_init);
1880 spec->volknob_init = 1;
1881}
1882
1883/* Analog Mics */
1884static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec,
1885 const struct hda_fixup *fix, int action)
1886{
1887 struct sigmatel_spec *spec = codec->spec;
1888
1889 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1890 return;
1891
1892 stac92hd73xx_fixup_dell(codec);
1893 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1894 spec->num_dmics = 0;
1895}
1896
1897/* Digital Mics */
1898static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec,
1899 const struct hda_fixup *fix, int action)
1900{
1901 struct sigmatel_spec *spec = codec->spec;
1902
1903 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1904 return;
1905
1906 stac92hd73xx_fixup_dell(codec);
1907 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1908 spec->num_dmics = 1;
1909}
1910
1911/* Both */
1912static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec,
1913 const struct hda_fixup *fix, int action)
1914{
1915 struct sigmatel_spec *spec = codec->spec;
1916
1917 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1918 return;
1919
1920 stac92hd73xx_fixup_dell(codec);
1921 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1922 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1923 spec->num_dmics = 1;
1924}
1925
1926static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec,
1927 const struct hda_fixup *fix, int action)
1928{
1929 struct sigmatel_spec *spec = codec->spec;
1930
1931 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1932 return;
1933
1934 snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs);
1935 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
1936 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
1937 spec->eapd_switch = 0;
1938}
1939
1940static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec,
1941 const struct hda_fixup *fix, int action)
1942{
1943 struct sigmatel_spec *spec = codec->spec;
1944
1945 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1946 return;
1947 spec->hp_detect = 0;
1948}
1949
1950static const struct hda_fixup stac92hd73xx_fixups[] = {
1951 [STAC_92HD73XX_REF] = {
1952 .type = HDA_FIXUP_FUNC,
1953 .v.func = stac92hd73xx_fixup_ref,
1954 },
1955 [STAC_DELL_M6_AMIC] = {
1956 .type = HDA_FIXUP_FUNC,
1957 .v.func = stac92hd73xx_fixup_dell_m6_amic,
1958 },
1959 [STAC_DELL_M6_DMIC] = {
1960 .type = HDA_FIXUP_FUNC,
1961 .v.func = stac92hd73xx_fixup_dell_m6_dmic,
1962 },
1963 [STAC_DELL_M6_BOTH] = {
1964 .type = HDA_FIXUP_FUNC,
1965 .v.func = stac92hd73xx_fixup_dell_m6_both,
1966 },
1967 [STAC_DELL_EQ] = {
1968 .type = HDA_FIXUP_FUNC,
1969 .v.func = stac92hd73xx_fixup_dell_eq,
1970 },
1971 [STAC_ALIENWARE_M17X] = {
1972 .type = HDA_FIXUP_FUNC,
1973 .v.func = stac92hd73xx_fixup_alienware_m17x,
1974 },
1975 [STAC_92HD73XX_INTEL] = {
1976 .type = HDA_FIXUP_PINS,
1977 .v.pins = intel_dg45id_pin_configs,
1978 },
1979 [STAC_92HD73XX_NO_JD] = {
1980 .type = HDA_FIXUP_FUNC,
1981 .v.func = stac92hd73xx_fixup_no_jd,
1982 }
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001983};
1984
Takashi Iwai55e30142013-01-14 17:30:04 +01001985static const struct hda_model_fixup stac92hd73xx_models[] = {
1986 { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" },
1987 { .id = STAC_92HD73XX_REF, .name = "ref" },
1988 { .id = STAC_92HD73XX_INTEL, .name = "intel" },
1989 { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" },
1990 { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" },
1991 { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" },
1992 { .id = STAC_DELL_EQ, .name = "dell-eq" },
1993 { .id = STAC_ALIENWARE_M17X, .name = "alienware" },
1994 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001995};
1996
Takashi Iwai55e30142013-01-14 17:30:04 +01001997static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001998 /* SigmaTel reference board */
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01002000 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002001 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2002 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08002003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
2004 "Intel DG45ID", STAC_92HD73XX_INTEL),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
2006 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002007 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002008 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002009 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002010 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002011 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
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, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002014 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002015 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
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, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002018 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002019 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002020 "unknown Dell", STAC_DELL_M6_DMIC),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
2022 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01002023 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01002024 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01002025 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
2026 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02002027 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
2028 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00002029 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
2030 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04002031 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01002032 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04002033 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02002034 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Takashi Iwai55e30142013-01-14 17:30:04 +01002035 /* codec SSID matching */
Takashi Iwai842ae632009-09-02 07:43:08 +02002036 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
2037 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05002038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
2039 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01002040 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01002041 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02002042 {} /* terminator */
2043};
2044
Takashi Iwai372f8c72013-01-14 18:06:34 +01002045static const struct hda_pintbl ref92hd83xxx_pin_configs[] = {
2046 { 0x0a, 0x02214030 },
2047 { 0x0b, 0x02211010 },
2048 { 0x0c, 0x02a19020 },
2049 { 0x0d, 0x02170130 },
2050 { 0x0e, 0x01014050 },
2051 { 0x0f, 0x01819040 },
2052 { 0x10, 0x01014020 },
2053 { 0x11, 0x90a3014e },
2054 { 0x1f, 0x01451160 },
2055 { 0x20, 0x98560170 },
2056 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002057};
2058
Takashi Iwai372f8c72013-01-14 18:06:34 +01002059static const struct hda_pintbl dell_s14_pin_configs[] = {
2060 { 0x0a, 0x0221403f },
2061 { 0x0b, 0x0221101f },
2062 { 0x0c, 0x02a19020 },
2063 { 0x0d, 0x90170110 },
2064 { 0x0e, 0x40f000f0 },
2065 { 0x0f, 0x40f000f0 },
2066 { 0x10, 0x40f000f0 },
2067 { 0x11, 0x90a60160 },
2068 { 0x1f, 0x40f000f0 },
2069 { 0x20, 0x40f000f0 },
2070 {}
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002071};
2072
Takashi Iwai372f8c72013-01-14 18:06:34 +01002073static const struct hda_pintbl dell_vostro_3500_pin_configs[] = {
2074 { 0x0a, 0x02a11020 },
2075 { 0x0b, 0x0221101f },
2076 { 0x0c, 0x400000f0 },
2077 { 0x0d, 0x90170110 },
2078 { 0x0e, 0x400000f1 },
2079 { 0x0f, 0x400000f2 },
2080 { 0x10, 0x400000f3 },
2081 { 0x11, 0x90a60160 },
2082 { 0x1f, 0x400000f4 },
2083 { 0x20, 0x400000f5 },
2084 {}
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002085};
2086
Takashi Iwai372f8c72013-01-14 18:06:34 +01002087static const struct hda_pintbl hp_dv7_4000_pin_configs[] = {
2088 { 0x0a, 0x03a12050 },
2089 { 0x0b, 0x0321201f },
2090 { 0x0c, 0x40f000f0 },
2091 { 0x0d, 0x90170110 },
2092 { 0x0e, 0x40f000f0 },
2093 { 0x0f, 0x40f000f0 },
2094 { 0x10, 0x90170110 },
2095 { 0x11, 0xd5a30140 },
2096 { 0x1f, 0x40f000f0 },
2097 { 0x20, 0x40f000f0 },
2098 {}
Steven Eastland48315592010-08-06 15:07:35 -06002099};
2100
Takashi Iwai372f8c72013-01-14 18:06:34 +01002101static const struct hda_pintbl hp_zephyr_pin_configs[] = {
2102 { 0x0a, 0x01813050 },
2103 { 0x0b, 0x0421201f },
2104 { 0x0c, 0x04a1205e },
2105 { 0x0d, 0x96130310 },
2106 { 0x0e, 0x96130310 },
2107 { 0x0f, 0x0101401f },
2108 { 0x10, 0x1111611f },
2109 { 0x11, 0xd5a30130 },
2110 {}
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002111};
2112
Takashi Iwai372f8c72013-01-14 18:06:34 +01002113static const struct hda_pintbl hp_cNB11_intquad_pin_configs[] = {
2114 { 0x0a, 0x40f000f0 },
2115 { 0x0b, 0x0221101f },
2116 { 0x0c, 0x02a11020 },
2117 { 0x0d, 0x92170110 },
2118 { 0x0e, 0x40f000f0 },
2119 { 0x0f, 0x92170110 },
2120 { 0x10, 0x40f000f0 },
2121 { 0x11, 0xd5a30130 },
2122 { 0x1f, 0x40f000f0 },
2123 { 0x20, 0x40f000f0 },
2124 {}
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002125};
2126
Takashi Iwai372f8c72013-01-14 18:06:34 +01002127static void stac92hd83xxx_fixup_hp(struct hda_codec *codec,
2128 const struct hda_fixup *fix, int action)
2129{
2130 struct sigmatel_spec *spec = codec->spec;
2131
2132 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2133 return;
2134
2135 if (hp_bnb2011_with_dock(codec)) {
2136 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
2137 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
2138 }
2139
2140 if (find_mute_led_cfg(codec, spec->default_polarity))
2141 snd_printd("mute LED gpio %d polarity %d\n",
2142 spec->gpio_led,
2143 spec->gpio_led_polarity);
2144}
2145
2146static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec,
2147 const struct hda_fixup *fix, int action)
2148{
2149 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2150 return;
2151
2152 snd_hda_apply_pincfgs(codec, hp_zephyr_pin_configs);
2153 snd_hda_add_verbs(codec, stac92hd83xxx_hp_zephyr_init);
2154}
2155
2156static void stac92hd83xxx_fixup_hp_led(struct hda_codec *codec,
2157 const struct hda_fixup *fix, int action)
2158{
2159 struct sigmatel_spec *spec = codec->spec;
2160
2161 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2162 spec->default_polarity = 0;
2163}
2164
2165static void stac92hd83xxx_fixup_hp_inv_led(struct hda_codec *codec,
2166 const struct hda_fixup *fix, int action)
2167{
2168 struct sigmatel_spec *spec = codec->spec;
2169
2170 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2171 spec->default_polarity = 1;
2172}
2173
2174static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
2175 const struct hda_fixup *fix, int action)
2176{
2177 struct sigmatel_spec *spec = codec->spec;
2178
2179 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2180 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
2181}
2182
2183static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
2184 const struct hda_fixup *fix, int action)
2185{
2186 struct sigmatel_spec *spec = codec->spec;
2187
2188 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2189 spec->headset_jack = 1;
2190}
2191
2192static const struct hda_fixup stac92hd83xxx_fixups[] = {
2193 [STAC_92HD83XXX_REF] = {
2194 .type = HDA_FIXUP_PINS,
2195 .v.pins = ref92hd83xxx_pin_configs,
2196 },
2197 [STAC_92HD83XXX_PWR_REF] = {
2198 .type = HDA_FIXUP_PINS,
2199 .v.pins = ref92hd83xxx_pin_configs,
2200 },
2201 [STAC_DELL_S14] = {
2202 .type = HDA_FIXUP_PINS,
2203 .v.pins = dell_s14_pin_configs,
2204 },
2205 [STAC_DELL_VOSTRO_3500] = {
2206 .type = HDA_FIXUP_PINS,
2207 .v.pins = dell_vostro_3500_pin_configs,
2208 },
2209 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = {
2210 .type = HDA_FIXUP_PINS,
2211 .v.pins = hp_cNB11_intquad_pin_configs,
2212 .chained = true,
2213 .chain_id = STAC_92HD83XXX_HP,
2214 },
2215 [STAC_92HD83XXX_HP] = {
2216 .type = HDA_FIXUP_FUNC,
2217 .v.func = stac92hd83xxx_fixup_hp,
2218 },
2219 [STAC_HP_DV7_4000] = {
2220 .type = HDA_FIXUP_PINS,
2221 .v.pins = hp_dv7_4000_pin_configs,
2222 .chained = true,
2223 .chain_id = STAC_92HD83XXX_HP,
2224 },
2225 [STAC_HP_ZEPHYR] = {
2226 .type = HDA_FIXUP_FUNC,
2227 .v.func = stac92hd83xxx_fixup_hp_zephyr,
2228 .chained = true,
2229 .chain_id = STAC_92HD83XXX_HP,
2230 },
2231 [STAC_92HD83XXX_HP_LED] = {
2232 .type = HDA_FIXUP_FUNC,
2233 .v.func = stac92hd83xxx_fixup_hp_led,
2234 .chained = true,
2235 .chain_id = STAC_92HD83XXX_HP,
2236 },
2237 [STAC_92HD83XXX_HP_INV_LED] = {
2238 .type = HDA_FIXUP_FUNC,
2239 .v.func = stac92hd83xxx_fixup_hp_inv_led,
2240 .chained = true,
2241 .chain_id = STAC_92HD83XXX_HP,
2242 },
2243 [STAC_92HD83XXX_HP_MIC_LED] = {
2244 .type = HDA_FIXUP_FUNC,
2245 .v.func = stac92hd83xxx_fixup_hp_mic_led,
2246 .chained = true,
2247 .chain_id = STAC_92HD83XXX_HP,
2248 },
2249 [STAC_92HD83XXX_HEADSET_JACK] = {
2250 .type = HDA_FIXUP_FUNC,
2251 .v.func = stac92hd83xxx_fixup_headset_jack,
2252 },
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002253};
2254
Takashi Iwai372f8c72013-01-14 18:06:34 +01002255static const struct hda_model_fixup stac92hd83xxx_models[] = {
2256 { .id = STAC_92HD83XXX_REF, .name = "ref" },
2257 { .id = STAC_92HD83XXX_PWR_REF, .name = "mic-ref" },
2258 { .id = STAC_DELL_S14, .name = "dell-s14" },
2259 { .id = STAC_DELL_VOSTRO_3500, .name = "dell-vostro-3500" },
2260 { .id = STAC_92HD83XXX_HP_cNB11_INTQUAD, .name = "hp_cNB11_intquad" },
2261 { .id = STAC_HP_DV7_4000, .name = "hp-dv7-4000" },
2262 { .id = STAC_HP_ZEPHYR, .name = "hp-zephyr" },
2263 { .id = STAC_92HD83XXX_HP_LED, .name = "hp-led" },
2264 { .id = STAC_92HD83XXX_HP_INV_LED, .name = "hp-inv-led" },
2265 { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" },
2266 { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" },
2267 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002268};
2269
Takashi Iwai372f8c72013-01-14 18:06:34 +01002270static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002271 /* SigmaTel reference board */
2272 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01002273 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002274 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2275 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
2277 "unknown Dell", STAC_DELL_S14),
David Henningsson8d032a82012-10-09 12:48:40 +02002278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
2279 "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
2280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
2281 "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
2282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
2283 "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
2285 "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
2286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
2287 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
2289 "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
2290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
2291 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
2293 "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
2294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
2295 "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
2297 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002298 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
2299 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2300 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
2301 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2302 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
2303 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2304 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
Takashi Iwai8ae58652012-12-13 14:33:42 +01002305 "HP Pavilion dv7", STAC_HP_DV7_4000),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002306 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
2307 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2308 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
2309 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Takashi Iwai62cbde12012-09-14 11:58:54 +02002310 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
2311 "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002312 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
2313 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2314 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
2315 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2316 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
2317 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2318 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
2319 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2320 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
2321 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2322 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
2323 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2324 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
2325 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2326 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
2327 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2328 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
2329 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2330 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
2331 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2332 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
2333 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2334 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2335 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2336 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2337 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2338 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2339 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002340 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2341 "HP", STAC_HP_ZEPHYR),
Takashi Iwaia3e19972012-07-26 08:17:20 +02002342 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2343 "HP Mini", STAC_92HD83XXX_HP_LED),
Gustavo Maciel Dias Vieira5afc13a2012-10-26 12:51:53 -02002344 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2345 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
Takashi Iwai8c698fe2013-01-15 11:20:50 +01002346 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a,
2347 "HP Mini", STAC_92HD83XXX_HP_LED),
Takashi Iwai372f8c72013-01-14 18:06:34 +01002348 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02002349 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002350};
2351
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002352static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2353 { 0x0a, 0x02214030 },
2354 { 0x0b, 0x02a19040 },
2355 { 0x0c, 0x01a19020 },
2356 { 0x0d, 0x01014010 },
2357 { 0x0e, 0x0181302e },
2358 { 0x0f, 0x01014010 },
2359 { 0x14, 0x01019020 },
2360 { 0x18, 0x90a000f0 },
2361 { 0x19, 0x90a000f0 },
2362 { 0x1e, 0x01452050 },
2363 { 0x1f, 0x01452050 },
2364 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002365};
2366
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002367static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2368 { 0x0a, 0x0421101f },
2369 { 0x0b, 0x04a11221 },
2370 { 0x0c, 0x40f000f0 },
2371 { 0x0d, 0x90170110 },
2372 { 0x0e, 0x23a1902e },
2373 { 0x0f, 0x23014250 },
2374 { 0x14, 0x40f000f0 },
2375 { 0x18, 0x90a000f0 },
2376 { 0x19, 0x40f000f0 },
2377 { 0x1e, 0x4f0000f0 },
2378 { 0x1f, 0x4f0000f0 },
2379 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002380};
2381
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002382static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2383 { 0x0a, 0x0421101f },
2384 { 0x0b, 0x04a11221 },
2385 { 0x0c, 0x90a70330 },
2386 { 0x0d, 0x90170110 },
2387 { 0x0e, 0x23a1902e },
2388 { 0x0f, 0x23014250 },
2389 { 0x14, 0x40f000f0 },
2390 { 0x18, 0x40f000f0 },
2391 { 0x19, 0x40f000f0 },
2392 { 0x1e, 0x044413b0 },
2393 { 0x1f, 0x044413b0 },
2394 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002395};
2396
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002397static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2398 { 0x0a, 0x0421101f },
2399 { 0x0b, 0x04a11221 },
2400 { 0x0c, 0x90a70330 },
2401 { 0x0d, 0x90170110 },
2402 { 0x0e, 0x40f000f0 },
2403 { 0x0f, 0x40f000f0 },
2404 { 0x14, 0x40f000f0 },
2405 { 0x18, 0x90a000f0 },
2406 { 0x19, 0x40f000f0 },
2407 { 0x1e, 0x044413b0 },
2408 { 0x1f, 0x044413b0 },
2409 {}
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002410};
2411
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002412static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2413 const struct hda_fixup *fix, int action)
2414{
2415 struct sigmatel_spec *spec = codec->spec;
2416
2417 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2418 return;
2419
2420 snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2421 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2422}
2423
2424static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec,
2425 const struct hda_fixup *fix, int action)
2426{
2427 struct sigmatel_spec *spec = codec->spec;
2428
2429 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2430 return;
2431 spec->num_dmics = 0;
2432 spec->num_smuxes = 0;
2433 spec->num_dmuxes = 0;
2434}
2435
2436static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec,
2437 const struct hda_fixup *fix, int action)
2438{
2439 struct sigmatel_spec *spec = codec->spec;
2440
2441 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2442 return;
2443 spec->num_dmics = 1;
2444 spec->num_smuxes = 0;
2445 spec->num_dmuxes = 1;
2446}
2447
2448static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2449 const struct hda_fixup *fix, int action)
2450{
2451 struct sigmatel_spec *spec = codec->spec;
2452
2453 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2454 return;
2455
2456 /* Enable VREF power saving on GPIO1 detect */
2457 stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02);
2458 snd_hda_codec_write_cache(codec, codec->afg, 0,
2459 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
2460 snd_hda_jack_detect_enable(codec, codec->afg, 0);
2461 spec->gpio_mask |= 0x02;
2462
2463 /* enable internal microphone */
2464 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2465 stac92xx_auto_set_pinctl(codec, 0x0e,
2466 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2467
2468 stac92hd71bxx_fixup_no_dmic(codec, fix, action);
2469}
2470
2471static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec,
2472 const struct hda_fixup *fix, int action)
2473{
2474 struct sigmatel_spec *spec = codec->spec;
2475
2476 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2477 return;
2478 spec->num_dmics = 1;
2479 /* I don't know if it needs 1 or 2 smuxes - will wait for
2480 * bug reports to fix if needed
2481 */
2482 spec->num_smuxes = 1;
2483 spec->num_dmuxes = 1;
2484}
2485
2486static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2487 const struct hda_fixup *fix, int action)
2488{
2489 struct sigmatel_spec *spec = codec->spec;
2490
2491 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2492 return;
2493 spec->gpio_led = 0x01;
2494}
2495
2496static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2497 const struct hda_fixup *fix, int action)
2498{
2499 struct sigmatel_spec *spec = codec->spec;
2500 unsigned int cap;
2501
2502 switch (action) {
2503 case HDA_FIXUP_ACT_PRE_PROBE:
2504 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2505 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
2506 /* HP dv6 gives the headphone pin as a line-out. Thus we
2507 * need to set hp_detect flag here to force to enable HP
2508 * detection.
2509 */
2510 spec->hp_detect = 1;
2511 break;
2512
2513 case HDA_FIXUP_ACT_PROBE:
2514 /* enable bass on HP dv7 */
2515 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2516 cap &= AC_GPIO_IO_COUNT;
2517 if (cap >= 6)
2518 stac_add_hp_bass_switch(codec);
2519 break;
2520 }
2521}
2522
2523static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
2524 const struct hda_fixup *fix, int action)
2525{
2526 struct sigmatel_spec *spec = codec->spec;
2527
2528 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2529 return;
2530 spec->gpio_led = 0x08;
2531 spec->num_dmics = 1;
2532 spec->num_smuxes = 1;
2533 spec->num_dmuxes = 1;
2534}
2535
2536
2537static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
2538 const struct hda_fixup *fix, int action)
2539{
2540 struct sigmatel_spec *spec = codec->spec;
2541
2542 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2543 return;
2544
2545 if (hp_blike_system(codec->subsystem_id)) {
2546 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
2547 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
2548 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
2549 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
2550 /* It was changed in the BIOS to just satisfy MS DTM.
2551 * Lets turn it back into slaved HP
2552 */
2553 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
2554 | (AC_JACK_HP_OUT <<
2555 AC_DEFCFG_DEVICE_SHIFT);
2556 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
2557 | AC_DEFCFG_SEQUENCE)))
2558 | 0x1f;
2559 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
2560 }
2561 }
2562
2563 if (find_mute_led_cfg(codec, 1))
2564 snd_printd("mute LED gpio %d polarity %d\n",
2565 spec->gpio_led,
2566 spec->gpio_led_polarity);
2567
2568}
2569
2570static const struct hda_fixup stac92hd71bxx_fixups[] = {
2571 [STAC_92HD71BXX_REF] = {
2572 .type = HDA_FIXUP_FUNC,
2573 .v.func = stac92hd71bxx_fixup_ref,
2574 },
2575 [STAC_DELL_M4_1] = {
2576 .type = HDA_FIXUP_PINS,
2577 .v.pins = dell_m4_1_pin_configs,
2578 .chained = true,
2579 .chain_id = STAC_92HD71BXX_NO_SMUX,
2580 },
2581 [STAC_DELL_M4_2] = {
2582 .type = HDA_FIXUP_PINS,
2583 .v.pins = dell_m4_2_pin_configs,
2584 .chained = true,
2585 .chain_id = STAC_92HD71BXX_NO_DMIC,
2586 },
2587 [STAC_DELL_M4_3] = {
2588 .type = HDA_FIXUP_PINS,
2589 .v.pins = dell_m4_3_pin_configs,
2590 .chained = true,
2591 .chain_id = STAC_92HD71BXX_NO_SMUX,
2592 },
2593 [STAC_HP_M4] = {
2594 .type = HDA_FIXUP_FUNC,
2595 .v.func = stac92hd71bxx_fixup_hp_m4,
2596 .chained = true,
2597 .chain_id = STAC_92HD71BXX_HP,
2598 },
2599 [STAC_HP_DV4] = {
2600 .type = HDA_FIXUP_FUNC,
2601 .v.func = stac92hd71bxx_fixup_hp_dv4,
2602 .chained = true,
2603 .chain_id = STAC_HP_DV5,
2604 },
2605 [STAC_HP_DV5] = {
2606 .type = HDA_FIXUP_FUNC,
2607 .v.func = stac92hd71bxx_fixup_hp_dv5,
2608 .chained = true,
2609 .chain_id = STAC_92HD71BXX_HP,
2610 },
2611 [STAC_HP_HDX] = {
2612 .type = HDA_FIXUP_FUNC,
2613 .v.func = stac92hd71bxx_fixup_hp_hdx,
2614 .chained = true,
2615 .chain_id = STAC_92HD71BXX_HP,
2616 },
2617 [STAC_HP_DV4_1222NR] = {
2618 .type = HDA_FIXUP_FUNC,
2619 .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr,
2620 .chained = true,
2621 .chain_id = STAC_HP_DV4,
2622 },
2623 [STAC_92HD71BXX_NO_DMIC] = {
2624 .type = HDA_FIXUP_FUNC,
2625 .v.func = stac92hd71bxx_fixup_no_dmic,
2626 },
2627 [STAC_92HD71BXX_NO_SMUX] = {
2628 .type = HDA_FIXUP_FUNC,
2629 .v.func = stac92hd71bxx_fixup_no_smux,
2630 },
2631 [STAC_92HD71BXX_HP] = {
2632 .type = HDA_FIXUP_FUNC,
2633 .v.func = stac92hd71bxx_fixup_hp,
2634 },
Matthew Ranostaye035b842007-11-06 11:53:55 +01002635};
2636
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002637static const struct hda_model_fixup stac92hd71bxx_models[] = {
2638 { .id = STAC_92HD71BXX_REF, .name = "ref" },
2639 { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
2640 { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
2641 { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
2642 { .id = STAC_HP_M4, .name = "hp-m4" },
2643 { .id = STAC_HP_DV4, .name = "hp-dv4" },
2644 { .id = STAC_HP_DV5, .name = "hp-dv5" },
2645 { .id = STAC_HP_HDX, .name = "hp-hdx" },
2646 { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" },
2647 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002648};
2649
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002650static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002651 /* SigmaTel reference board */
2652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2653 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002654 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2655 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04002656 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
2657 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01002658 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2659 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01002660 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2661 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002662 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002663 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002664 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2665 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002666 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2667 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04002668 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002669 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002670 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002671 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02002672 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2673 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05302674 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2675 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11002676 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2677 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02002678 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2679 "HP", STAC_HP_DV5),
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002680 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2682 "unknown Dell", STAC_DELL_M4_1),
2683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2684 "unknown Dell", STAC_DELL_M4_1),
2685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2686 "unknown Dell", STAC_DELL_M4_1),
2687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2688 "unknown Dell", STAC_DELL_M4_1),
2689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2690 "unknown Dell", STAC_DELL_M4_1),
2691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2692 "unknown Dell", STAC_DELL_M4_1),
2693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2694 "unknown Dell", STAC_DELL_M4_1),
2695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2696 "unknown Dell", STAC_DELL_M4_2),
2697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2698 "unknown Dell", STAC_DELL_M4_2),
2699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2700 "unknown Dell", STAC_DELL_M4_2),
2701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2702 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2704 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002705 {} /* terminator */
2706};
2707
Takashi Iwai0a427842013-01-14 15:20:13 +01002708static const struct hda_pintbl ref922x_pin_configs[] = {
2709 { 0x0a, 0x01014010 },
2710 { 0x0b, 0x01016011 },
2711 { 0x0c, 0x01012012 },
2712 { 0x0d, 0x0221401f },
2713 { 0x0e, 0x01813122 },
2714 { 0x0f, 0x01011014 },
2715 { 0x10, 0x01441030 },
2716 { 0x11, 0x01c41030 },
2717 { 0x15, 0x40000100 },
2718 { 0x1b, 0x40000100 },
2719 {}
Matt2f2f4252005-04-13 14:45:30 +02002720};
2721
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002722/*
2723 STAC 922X pin configs for
2724 102801A7
2725 102801AB
2726 102801A9
2727 102801D1
2728 102801D2
2729*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002730static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2731 { 0x0a, 0x02214030 },
2732 { 0x0b, 0x01a19021 },
2733 { 0x0c, 0x01111012 },
2734 { 0x0d, 0x01114010 },
2735 { 0x0e, 0x02a19020 },
2736 { 0x0f, 0x01117011 },
2737 { 0x10, 0x400001f0 },
2738 { 0x11, 0x400001f1 },
2739 { 0x15, 0x01813122 },
2740 { 0x1b, 0x400001f2 },
2741 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002742};
2743
2744/*
2745 STAC 922X pin configs for
2746 102801AC
2747 102801D0
2748*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002749static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2750 { 0x0a, 0x02214030 },
2751 { 0x0b, 0x01a19021 },
2752 { 0x0c, 0x01111012 },
2753 { 0x0d, 0x01114010 },
2754 { 0x0e, 0x02a19020 },
2755 { 0x0f, 0x01117011 },
2756 { 0x10, 0x01451140 },
2757 { 0x11, 0x400001f0 },
2758 { 0x15, 0x01813122 },
2759 { 0x1b, 0x400001f1 },
2760 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002761};
2762
2763/*
2764 STAC 922X pin configs for
2765 102801BF
2766*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002767static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2768 { 0x0a, 0x0321101f },
2769 { 0x0b, 0x01112024 },
2770 { 0x0c, 0x01111222 },
2771 { 0x0d, 0x91174220 },
2772 { 0x0e, 0x03a11050 },
2773 { 0x0f, 0x01116221 },
2774 { 0x10, 0x90a70330 },
2775 { 0x11, 0x01452340 },
2776 { 0x15, 0x40C003f1 },
2777 { 0x1b, 0x405003f0 },
2778 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002779};
2780
2781/*
2782 STAC 9221 A1 pin configs for
2783 102801D7 (Dell XPS M1210)
2784*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002785static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2786 { 0x0a, 0x02211211 },
2787 { 0x0b, 0x408103ff },
2788 { 0x0c, 0x02a1123e },
2789 { 0x0d, 0x90100310 },
2790 { 0x0e, 0x408003f1 },
2791 { 0x0f, 0x0221121f },
2792 { 0x10, 0x03451340 },
2793 { 0x11, 0x40c003f2 },
2794 { 0x15, 0x508003f3 },
2795 { 0x1b, 0x405003f4 },
2796 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002797};
2798
Takashi Iwai0a427842013-01-14 15:20:13 +01002799static const struct hda_pintbl d945gtp3_pin_configs[] = {
2800 { 0x0a, 0x0221401f },
2801 { 0x0b, 0x01a19022 },
2802 { 0x0c, 0x01813021 },
2803 { 0x0d, 0x01014010 },
2804 { 0x0e, 0x40000100 },
2805 { 0x0f, 0x40000100 },
2806 { 0x10, 0x40000100 },
2807 { 0x11, 0x40000100 },
2808 { 0x15, 0x02a19120 },
2809 { 0x1b, 0x40000100 },
2810 {}
Matt Porter403d1942005-11-29 15:00:51 +01002811};
2812
Takashi Iwai0a427842013-01-14 15:20:13 +01002813static const struct hda_pintbl d945gtp5_pin_configs[] = {
2814 { 0x0a, 0x0221401f },
2815 { 0x0b, 0x01011012 },
2816 { 0x0c, 0x01813024 },
2817 { 0x0d, 0x01014010 },
2818 { 0x0e, 0x01a19021 },
2819 { 0x0f, 0x01016011 },
2820 { 0x10, 0x01452130 },
2821 { 0x11, 0x40000100 },
2822 { 0x15, 0x02a19320 },
2823 { 0x1b, 0x40000100 },
2824 {}
Matt Porter403d1942005-11-29 15:00:51 +01002825};
2826
Takashi Iwai0a427842013-01-14 15:20:13 +01002827static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2828 { 0x0a, 0x0121e21f },
2829 { 0x0b, 0x400000ff },
2830 { 0x0c, 0x9017e110 },
2831 { 0x0d, 0x400000fd },
2832 { 0x0e, 0x400000fe },
2833 { 0x0f, 0x0181e020 },
2834 { 0x10, 0x1145e030 },
2835 { 0x11, 0x11c5e240 },
2836 { 0x15, 0x400000fc },
2837 { 0x1b, 0x400000fb },
2838 {}
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002839};
2840
Takashi Iwai0a427842013-01-14 15:20:13 +01002841static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2842 { 0x0a, 0x0121e21f },
2843 { 0x0b, 0x90a7012e },
2844 { 0x0c, 0x9017e110 },
2845 { 0x0d, 0x400000fd },
2846 { 0x0e, 0x400000fe },
2847 { 0x0f, 0x0181e020 },
2848 { 0x10, 0x1145e230 },
2849 { 0x11, 0x500000fa },
2850 { 0x15, 0x400000fc },
2851 { 0x1b, 0x400000fb },
2852 {}
Sylvain FORETf16928f2007-04-27 14:22:36 +02002853};
2854
Takashi Iwai0a427842013-01-14 15:20:13 +01002855static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2856 { 0x0a, 0x0121e21f },
2857 { 0x0b, 0x90a7012e },
2858 { 0x0c, 0x9017e110 },
2859 { 0x0d, 0x400000fd },
2860 { 0x0e, 0x400000fe },
2861 { 0x0f, 0x0181e020 },
2862 { 0x10, 0x1145e230 },
2863 { 0x11, 0x11c5e240 },
2864 { 0x15, 0x400000fc },
2865 { 0x1b, 0x400000fb },
2866 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002867};
2868
Takashi Iwai0a427842013-01-14 15:20:13 +01002869static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2870 { 0x0a, 0x0321e21f },
2871 { 0x0b, 0x03a1e02e },
2872 { 0x0c, 0x9017e110 },
2873 { 0x0d, 0x9017e11f },
2874 { 0x0e, 0x400000fe },
2875 { 0x0f, 0x0381e020 },
2876 { 0x10, 0x1345e230 },
2877 { 0x11, 0x13c5e240 },
2878 { 0x15, 0x400000fc },
2879 { 0x1b, 0x400000fb },
2880 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002881};
2882
Takashi Iwai0a427842013-01-14 15:20:13 +01002883static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2884 { 0x0a, 0x0321e21f },
2885 { 0x0b, 0x03a1e02e },
2886 { 0x0c, 0x9017e110 },
2887 { 0x0d, 0x9017e11f },
2888 { 0x0e, 0x400000fe },
2889 { 0x0f, 0x0381e020 },
2890 { 0x10, 0x1345e230 },
2891 { 0x11, 0x13c5e240 },
2892 { 0x15, 0x400000fc },
2893 { 0x1b, 0x400000fb },
2894 {}
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002895};
2896
Takashi Iwai0a427842013-01-14 15:20:13 +01002897static const struct hda_pintbl ecs202_pin_configs[] = {
2898 { 0x0a, 0x0221401f },
2899 { 0x0b, 0x02a19020 },
2900 { 0x0c, 0x01a19020 },
2901 { 0x0d, 0x01114010 },
2902 { 0x0e, 0x408000f0 },
2903 { 0x0f, 0x01813022 },
2904 { 0x10, 0x074510a0 },
2905 { 0x11, 0x40c400f1 },
2906 { 0x15, 0x9037012e },
2907 { 0x1b, 0x40e000f2 },
2908 {}
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002909};
Takashi Iwai76c08822007-06-19 12:17:42 +02002910
Takashi Iwai0a427842013-01-14 15:20:13 +01002911/* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2912static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2913 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2914 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2915 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2916 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2917 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2918 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2919 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2920 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2921 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2922 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2923 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2924 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2925 {}
2926};
2927
2928static const struct hda_fixup stac922x_fixups[];
2929
2930/* remap the fixup from codec SSID and apply it */
2931static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2932 const struct hda_fixup *fix,
2933 int action)
2934{
2935 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2936 return;
2937 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2938 stac922x_fixups);
2939 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2940 snd_hda_apply_fixup(codec, action);
2941}
2942
2943static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2944 const struct hda_fixup *fix,
2945 int action)
2946{
2947 struct sigmatel_spec *spec = codec->spec;
2948
2949 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2950 spec->gpio_mask = spec->gpio_dir = 0x03;
2951 spec->gpio_data = 0x03;
2952 }
2953}
2954
2955static const struct hda_fixup stac922x_fixups[] = {
2956 [STAC_D945_REF] = {
2957 .type = HDA_FIXUP_PINS,
2958 .v.pins = ref922x_pin_configs,
2959 },
2960 [STAC_D945GTP3] = {
2961 .type = HDA_FIXUP_PINS,
2962 .v.pins = d945gtp3_pin_configs,
2963 },
2964 [STAC_D945GTP5] = {
2965 .type = HDA_FIXUP_PINS,
2966 .v.pins = d945gtp5_pin_configs,
2967 },
2968 [STAC_INTEL_MAC_AUTO] = {
2969 .type = HDA_FIXUP_FUNC,
2970 .v.func = stac922x_fixup_intel_mac_auto,
2971 },
2972 [STAC_INTEL_MAC_V1] = {
2973 .type = HDA_FIXUP_PINS,
2974 .v.pins = intel_mac_v1_pin_configs,
2975 .chained = true,
2976 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2977 },
2978 [STAC_INTEL_MAC_V2] = {
2979 .type = HDA_FIXUP_PINS,
2980 .v.pins = intel_mac_v2_pin_configs,
2981 .chained = true,
2982 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2983 },
2984 [STAC_INTEL_MAC_V3] = {
2985 .type = HDA_FIXUP_PINS,
2986 .v.pins = intel_mac_v3_pin_configs,
2987 .chained = true,
2988 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2989 },
2990 [STAC_INTEL_MAC_V4] = {
2991 .type = HDA_FIXUP_PINS,
2992 .v.pins = intel_mac_v4_pin_configs,
2993 .chained = true,
2994 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2995 },
2996 [STAC_INTEL_MAC_V5] = {
2997 .type = HDA_FIXUP_PINS,
2998 .v.pins = intel_mac_v5_pin_configs,
2999 .chained = true,
3000 .chain_id = STAC_922X_INTEL_MAC_GPIO,
3001 },
3002 [STAC_922X_INTEL_MAC_GPIO] = {
3003 .type = HDA_FIXUP_FUNC,
3004 .v.func = stac922x_fixup_intel_mac_gpio,
3005 },
3006 [STAC_ECS_202] = {
3007 .type = HDA_FIXUP_PINS,
3008 .v.pins = ecs202_pin_configs,
3009 },
3010 [STAC_922X_DELL_D81] = {
3011 .type = HDA_FIXUP_PINS,
3012 .v.pins = dell_922x_d81_pin_configs,
3013 },
3014 [STAC_922X_DELL_D82] = {
3015 .type = HDA_FIXUP_PINS,
3016 .v.pins = dell_922x_d82_pin_configs,
3017 },
3018 [STAC_922X_DELL_M81] = {
3019 .type = HDA_FIXUP_PINS,
3020 .v.pins = dell_922x_m81_pin_configs,
3021 },
3022 [STAC_922X_DELL_M82] = {
3023 .type = HDA_FIXUP_PINS,
3024 .v.pins = dell_922x_m82_pin_configs,
3025 },
3026};
3027
3028static const struct hda_model_fixup stac922x_models[] = {
3029 { .id = STAC_D945_REF, .name = "ref" },
3030 { .id = STAC_D945GTP5, .name = "5stack" },
3031 { .id = STAC_D945GTP3, .name = "3stack" },
3032 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
3033 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
3034 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
3035 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
3036 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
3037 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
3038 { .id = STAC_ECS_202, .name = "ecs202" },
3039 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
3040 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
3041 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
3042 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003043 /* for backward compatibility */
Takashi Iwai0a427842013-01-14 15:20:13 +01003044 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
3045 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
3046 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
3047 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
3048 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
3049 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
3050 {}
Matt Porter403d1942005-11-29 15:00:51 +01003051};
3052
Takashi Iwai0a427842013-01-14 15:20:13 +01003053static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003054 /* SigmaTel reference board */
3055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3056 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003057 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3058 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003059 /* Intel 945G based systems */
3060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
3061 "Intel D945G", STAC_D945GTP3),
3062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
3063 "Intel D945G", STAC_D945GTP3),
3064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
3065 "Intel D945G", STAC_D945GTP3),
3066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
3067 "Intel D945G", STAC_D945GTP3),
3068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
3069 "Intel D945G", STAC_D945GTP3),
3070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
3071 "Intel D945G", STAC_D945GTP3),
3072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
3073 "Intel D945G", STAC_D945GTP3),
3074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
3075 "Intel D945G", STAC_D945GTP3),
3076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
3077 "Intel D945G", STAC_D945GTP3),
3078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
3079 "Intel D945G", STAC_D945GTP3),
3080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
3081 "Intel D945G", STAC_D945GTP3),
3082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
3083 "Intel D945G", STAC_D945GTP3),
3084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
3085 "Intel D945G", STAC_D945GTP3),
3086 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
3087 "Intel D945G", STAC_D945GTP3),
3088 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
3089 "Intel D945G", STAC_D945GTP3),
3090 /* Intel D945G 5-stack systems */
3091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
3092 "Intel D945G", STAC_D945GTP5),
3093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
3094 "Intel D945G", STAC_D945GTP5),
3095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
3096 "Intel D945G", STAC_D945GTP5),
3097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
3098 "Intel D945G", STAC_D945GTP5),
3099 /* Intel 945P based systems */
3100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
3101 "Intel D945P", STAC_D945GTP3),
3102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
3103 "Intel D945P", STAC_D945GTP3),
3104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
3105 "Intel D945P", STAC_D945GTP3),
3106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
3107 "Intel D945P", STAC_D945GTP3),
3108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
3109 "Intel D945P", STAC_D945GTP3),
3110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
3111 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01003112 /* other intel */
3113 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
3114 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003115 /* other systems */
Takashi Iwai0a427842013-01-14 15:20:13 +01003116
Nicolas Boichat536319a2008-07-21 22:18:01 +08003117 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwai0a427842013-01-14 15:20:13 +01003118 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
3119
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003120 /* Dell systems */
3121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
3122 "unknown Dell", STAC_922X_DELL_D81),
3123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
3124 "unknown Dell", STAC_922X_DELL_D81),
3125 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
3126 "unknown Dell", STAC_922X_DELL_D81),
3127 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
3128 "unknown Dell", STAC_922X_DELL_D82),
3129 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
3130 "unknown Dell", STAC_922X_DELL_M81),
3131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
3132 "unknown Dell", STAC_922X_DELL_D82),
3133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
3134 "unknown Dell", STAC_922X_DELL_D81),
3135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
3136 "unknown Dell", STAC_922X_DELL_D81),
3137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
3138 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03003139 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003140 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02003141 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01003142 {} /* terminator */
3143};
3144
Takashi Iwai29ac8362013-01-14 16:03:38 +01003145static const struct hda_pintbl ref927x_pin_configs[] = {
3146 { 0x0a, 0x02214020 },
3147 { 0x0b, 0x02a19080 },
3148 { 0x0c, 0x0181304e },
3149 { 0x0d, 0x01014010 },
3150 { 0x0e, 0x01a19040 },
3151 { 0x0f, 0x01011012 },
3152 { 0x10, 0x01016011 },
3153 { 0x11, 0x0101201f },
3154 { 0x12, 0x183301f0 },
3155 { 0x13, 0x18a001f0 },
3156 { 0x14, 0x18a001f0 },
3157 { 0x21, 0x01442070 },
3158 { 0x22, 0x01c42190 },
3159 { 0x23, 0x40000100 },
3160 {}
Matt Porter3cc08dc2006-01-23 15:27:49 +01003161};
3162
Takashi Iwai29ac8362013-01-14 16:03:38 +01003163static const struct hda_pintbl d965_3st_pin_configs[] = {
3164 { 0x0a, 0x0221401f },
3165 { 0x0b, 0x02a19120 },
3166 { 0x0c, 0x40000100 },
3167 { 0x0d, 0x01014011 },
3168 { 0x0e, 0x01a19021 },
3169 { 0x0f, 0x01813024 },
3170 { 0x10, 0x40000100 },
3171 { 0x11, 0x40000100 },
3172 { 0x12, 0x40000100 },
3173 { 0x13, 0x40000100 },
3174 { 0x14, 0x40000100 },
3175 { 0x21, 0x40000100 },
3176 { 0x22, 0x40000100 },
3177 { 0x23, 0x40000100 },
3178 {}
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003179};
3180
Takashi Iwai29ac8362013-01-14 16:03:38 +01003181static const struct hda_pintbl d965_5st_pin_configs[] = {
3182 { 0x0a, 0x02214020 },
3183 { 0x0b, 0x02a19080 },
3184 { 0x0c, 0x0181304e },
3185 { 0x0d, 0x01014010 },
3186 { 0x0e, 0x01a19040 },
3187 { 0x0f, 0x01011012 },
3188 { 0x10, 0x01016011 },
3189 { 0x11, 0x40000100 },
3190 { 0x12, 0x40000100 },
3191 { 0x13, 0x40000100 },
3192 { 0x14, 0x40000100 },
3193 { 0x21, 0x01442070 },
3194 { 0x22, 0x40000100 },
3195 { 0x23, 0x40000100 },
3196 {}
Tobin Davis93ed1502006-09-01 21:03:12 +02003197};
3198
Takashi Iwai29ac8362013-01-14 16:03:38 +01003199static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
3200 { 0x0a, 0x40000100 },
3201 { 0x0b, 0x40000100 },
3202 { 0x0c, 0x0181304e },
3203 { 0x0d, 0x01014010 },
3204 { 0x0e, 0x01a19040 },
3205 { 0x0f, 0x01011012 },
3206 { 0x10, 0x01016011 },
3207 { 0x11, 0x40000100 },
3208 { 0x12, 0x40000100 },
3209 { 0x13, 0x40000100 },
3210 { 0x14, 0x40000100 },
3211 { 0x21, 0x01442070 },
3212 { 0x22, 0x40000100 },
3213 { 0x23, 0x40000100 },
3214 {}
Takashi Iwai679d92e2009-05-24 19:00:08 +02003215};
3216
Takashi Iwai29ac8362013-01-14 16:03:38 +01003217static const struct hda_pintbl dell_3st_pin_configs[] = {
3218 { 0x0a, 0x02211230 },
3219 { 0x0b, 0x02a11220 },
3220 { 0x0c, 0x01a19040 },
3221 { 0x0d, 0x01114210 },
3222 { 0x0e, 0x01111212 },
3223 { 0x0f, 0x01116211 },
3224 { 0x10, 0x01813050 },
3225 { 0x11, 0x01112214 },
3226 { 0x12, 0x403003fa },
3227 { 0x13, 0x90a60040 },
3228 { 0x14, 0x90a60040 },
3229 { 0x21, 0x404003fb },
3230 { 0x22, 0x40c003fc },
3231 { 0x23, 0x40000100 },
3232 {}
Tobin Davis4ff076e2007-08-07 11:48:12 +02003233};
3234
Takashi Iwai29ac8362013-01-14 16:03:38 +01003235static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
3236 const struct hda_fixup *fix, int action)
3237{
3238 struct sigmatel_spec *spec = codec->spec;
3239
3240 /* no jack detecion for ref-no-jd model */
3241 if (action == HDA_FIXUP_ACT_PROBE)
3242 spec->hp_detect = 0;
3243}
3244
3245static void stac927x_fixup_ref(struct hda_codec *codec,
3246 const struct hda_fixup *fix, int action)
3247{
3248 struct sigmatel_spec *spec = codec->spec;
3249
3250 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3251 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
3252 spec->eapd_mask = spec->gpio_mask = 0;
3253 spec->gpio_dir = spec->gpio_data = 0;
3254 }
3255}
3256
3257static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
3258 const struct hda_fixup *fix, int action)
3259{
3260 struct sigmatel_spec *spec = codec->spec;
3261
3262 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3263 return;
3264
3265 if (codec->subsystem_id != 0x1028022f) {
3266 /* GPIO2 High = Enable EAPD */
3267 spec->eapd_mask = spec->gpio_mask = 0x04;
3268 spec->gpio_dir = spec->gpio_data = 0x04;
3269 }
3270 spec->dmic_nids = stac927x_dmic_nids;
3271 spec->num_dmics = STAC927X_NUM_DMICS;
3272
3273 snd_hda_add_verbs(codec, dell_3st_core_init);
3274 spec->volknob_init = 1;
3275 spec->dmux_nids = stac927x_dmux_nids;
3276 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3277}
3278
3279static void stac927x_fixup_volknob(struct hda_codec *codec,
3280 const struct hda_fixup *fix, int action)
3281{
3282 struct sigmatel_spec *spec = codec->spec;
3283
3284 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3285 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
3286 spec->volknob_init = 1;
3287 }
3288}
3289
3290static const struct hda_fixup stac927x_fixups[] = {
3291 [STAC_D965_REF_NO_JD] = {
3292 .type = HDA_FIXUP_FUNC,
3293 .v.func = stac927x_fixup_ref_no_jd,
3294 .chained = true,
3295 .chain_id = STAC_D965_REF,
3296 },
3297 [STAC_D965_REF] = {
3298 .type = HDA_FIXUP_FUNC,
3299 .v.func = stac927x_fixup_ref,
3300 },
3301 [STAC_D965_3ST] = {
3302 .type = HDA_FIXUP_PINS,
3303 .v.pins = d965_3st_pin_configs,
3304 .chained = true,
3305 .chain_id = STAC_D965_VERBS,
3306 },
3307 [STAC_D965_5ST] = {
3308 .type = HDA_FIXUP_PINS,
3309 .v.pins = d965_5st_pin_configs,
3310 .chained = true,
3311 .chain_id = STAC_D965_VERBS,
3312 },
3313 [STAC_D965_VERBS] = {
3314 .type = HDA_FIXUP_VERBS,
3315 .v.verbs = d965_core_init,
3316 },
3317 [STAC_D965_5ST_NO_FP] = {
3318 .type = HDA_FIXUP_PINS,
3319 .v.pins = d965_5st_no_fp_pin_configs,
3320 },
3321 [STAC_DELL_3ST] = {
3322 .type = HDA_FIXUP_PINS,
3323 .v.pins = dell_3st_pin_configs,
3324 .chained = true,
3325 .chain_id = STAC_927X_DELL_DMIC,
3326 },
3327 [STAC_DELL_BIOS] = {
3328 .type = HDA_FIXUP_PINS,
3329 .v.pins = (const struct hda_pintbl[]) {
3330 /* configure the analog microphone on some laptops */
3331 { 0x0c, 0x90a79130 },
3332 /* correct the front output jack as a hp out */
3333 { 0x0f, 0x0227011f },
3334 /* correct the front input jack as a mic */
3335 { 0x0e, 0x02a79130 },
3336 {}
3337 },
3338 .chained = true,
3339 .chain_id = STAC_927X_DELL_DMIC,
3340 },
3341 [STAC_DELL_BIOS_SPDIF] = {
3342 .type = HDA_FIXUP_PINS,
3343 .v.pins = (const struct hda_pintbl[]) {
3344 /* correct the device field to SPDIF out */
3345 { 0x21, 0x01442070 },
3346 {}
3347 },
3348 .chained = true,
3349 .chain_id = STAC_DELL_BIOS,
3350 },
3351 [STAC_927X_DELL_DMIC] = {
3352 .type = HDA_FIXUP_FUNC,
3353 .v.func = stac927x_fixup_dell_dmic,
3354 },
3355 [STAC_927X_VOLKNOB] = {
3356 .type = HDA_FIXUP_FUNC,
3357 .v.func = stac927x_fixup_volknob,
3358 },
Matt Porter3cc08dc2006-01-23 15:27:49 +01003359};
3360
Takashi Iwai29ac8362013-01-14 16:03:38 +01003361static const struct hda_model_fixup stac927x_models[] = {
3362 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3363 { .id = STAC_D965_REF, .name = "ref" },
3364 { .id = STAC_D965_3ST, .name = "3stack" },
3365 { .id = STAC_D965_5ST, .name = "5stack" },
3366 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3367 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3368 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3369 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3370 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003371};
3372
Takashi Iwai29ac8362013-01-14 16:03:38 +01003373static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003374 /* SigmaTel reference board */
3375 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3376 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003377 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3378 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003379 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003380 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3381 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02003382 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003383 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3384 "Intel D965", STAC_D965_3ST),
3385 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3386 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003387 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
3390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003391 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04003393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
Chengu Wang84d3dc22009-07-30 19:43:55 +08003396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
3398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
3399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
Tobin Davis93ed1502006-09-01 21:03:12 +02003401 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003402 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3403 "Intel D965", STAC_D965_5ST),
3404 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3405 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02003406 /* volume-knob fixes */
3407 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01003408 {} /* terminator */
3409};
3410
Takashi Iwaife6322c2013-01-14 14:46:51 +01003411static const struct hda_pintbl ref9205_pin_configs[] = {
3412 { 0x0a, 0x40000100 },
3413 { 0x0b, 0x40000100 },
3414 { 0x0c, 0x01016011 },
3415 { 0x0d, 0x01014010 },
3416 { 0x0e, 0x01813122 },
3417 { 0x0f, 0x01a19021 },
3418 { 0x14, 0x01019020 },
3419 { 0x16, 0x40000100 },
3420 { 0x17, 0x90a000f0 },
3421 { 0x18, 0x90a000f0 },
3422 { 0x21, 0x01441030 },
3423 { 0x22, 0x01c41030 },
3424 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003425};
3426
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003427/*
3428 STAC 9205 pin configs for
3429 102801F1
3430 102801F2
3431 102801FC
3432 102801FD
3433 10280204
3434 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003435 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01003436 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003437*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003438static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3439 { 0x0a, 0x0321101F },
3440 { 0x0b, 0x03A11020 },
3441 { 0x0c, 0x400003FA },
3442 { 0x0d, 0x90170310 },
3443 { 0x0e, 0x400003FB },
3444 { 0x0f, 0x400003FC },
3445 { 0x14, 0x400003FD },
3446 { 0x16, 0x40F000F9 },
3447 { 0x17, 0x90A60330 },
3448 { 0x18, 0x400003FF },
3449 { 0x21, 0x0144131F },
3450 { 0x22, 0x40C003FE },
3451 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003452};
3453
3454/*
3455 STAC 9205 pin configs for
3456 102801F9
3457 102801FA
3458 102801FE
3459 102801FF (Dell Precision M4300)
3460 10280206
3461 10280200
3462 10280201
3463*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003464static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3465 { 0x0a, 0x0321101f },
3466 { 0x0b, 0x03a11020 },
3467 { 0x0c, 0x90a70330 },
3468 { 0x0d, 0x90170310 },
3469 { 0x0e, 0x400000fe },
3470 { 0x0f, 0x400000ff },
3471 { 0x14, 0x400000fd },
3472 { 0x16, 0x40f000f9 },
3473 { 0x17, 0x400000fa },
3474 { 0x18, 0x400000fc },
3475 { 0x21, 0x0144131f },
3476 { 0x22, 0x40c003f8 },
3477 /* Enable SPDIF in/out */
3478 { 0x1f, 0x01441030 },
3479 { 0x20, 0x1c410030 },
3480 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003481};
3482
Takashi Iwaife6322c2013-01-14 14:46:51 +01003483static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3484 { 0x0a, 0x0421101f },
3485 { 0x0b, 0x04a11020 },
3486 { 0x0c, 0x400003fa },
3487 { 0x0d, 0x90170310 },
3488 { 0x0e, 0x400003fb },
3489 { 0x0f, 0x400003fc },
3490 { 0x14, 0x400003fd },
3491 { 0x16, 0x400003f9 },
3492 { 0x17, 0x90a60330 },
3493 { 0x18, 0x400003ff },
3494 { 0x21, 0x01441340 },
3495 { 0x22, 0x40c003fe },
3496 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003497};
3498
Takashi Iwaife6322c2013-01-14 14:46:51 +01003499static void stac9205_fixup_ref(struct hda_codec *codec,
3500 const struct hda_fixup *fix, int action)
3501{
3502 struct sigmatel_spec *spec = codec->spec;
3503
3504 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3505 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3506 /* SPDIF-In enabled */
3507 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3508 }
3509}
3510
Takashi Iwaife6322c2013-01-14 14:46:51 +01003511static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3512 const struct hda_fixup *fix, int action)
3513{
3514 struct sigmatel_spec *spec = codec->spec;
3515 int err;
3516
3517 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3518 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3519
3520 /* Enable unsol response for GPIO4/Dock HP connection */
3521 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
3522 if (err < 0)
3523 return;
3524 snd_hda_codec_write_cache(codec, codec->afg, 0,
3525 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3526 snd_hda_jack_detect_enable(codec, codec->afg, 0);
3527
3528 spec->gpio_dir = 0x0b;
3529 spec->eapd_mask = 0x01;
3530 spec->gpio_mask = 0x1b;
3531 spec->gpio_mute = 0x10;
3532 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3533 * GPIO3 Low = DRM
3534 */
3535 spec->gpio_data = 0x01;
3536 }
3537}
3538
3539static void stac9205_fixup_eapd(struct hda_codec *codec,
3540 const struct hda_fixup *fix, int action)
3541{
3542 struct sigmatel_spec *spec = codec->spec;
3543
3544 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3545 spec->eapd_switch = 0;
3546}
3547
3548static const struct hda_fixup stac9205_fixups[] = {
3549 [STAC_9205_REF] = {
3550 .type = HDA_FIXUP_FUNC,
3551 .v.func = stac9205_fixup_ref,
3552 },
3553 [STAC_9205_DELL_M42] = {
3554 .type = HDA_FIXUP_PINS,
3555 .v.pins = dell_9205_m42_pin_configs,
3556 },
3557 [STAC_9205_DELL_M43] = {
3558 .type = HDA_FIXUP_FUNC,
3559 .v.func = stac9205_fixup_dell_m43,
3560 },
3561 [STAC_9205_DELL_M44] = {
3562 .type = HDA_FIXUP_PINS,
3563 .v.pins = dell_9205_m44_pin_configs,
3564 },
3565 [STAC_9205_EAPD] = {
3566 .type = HDA_FIXUP_FUNC,
3567 .v.func = stac9205_fixup_eapd,
3568 },
3569 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003570};
3571
Takashi Iwaife6322c2013-01-14 14:46:51 +01003572static const struct hda_model_fixup stac9205_models[] = {
3573 { .id = STAC_9205_REF, .name = "ref" },
3574 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3575 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3576 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3577 { .id = STAC_9205_EAPD, .name = "eapd" },
3578 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003579};
3580
Takashi Iwaife6322c2013-01-14 14:46:51 +01003581static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582 /* SigmaTel reference board */
3583 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3584 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03003585 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3586 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003587 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3588 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003589 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3591 "unknown Dell", STAC_9205_DELL_M42),
3592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3593 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02003595 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3597 "Dell Precision", STAC_9205_DELL_M43),
3598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3599 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3601 "unknown Dell", STAC_9205_DELL_M42),
3602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3603 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3605 "Dell Precision", STAC_9205_DELL_M43),
3606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003607 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3609 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02003610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3611 "Dell Precision", STAC_9205_DELL_M43),
3612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3613 "Dell Precision", STAC_9205_DELL_M43),
3614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3615 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3617 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3619 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01003620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3621 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003622 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08003623 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003624 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02003625 {} /* terminator */
3626};
3627
Matt2f2f4252005-04-13 14:45:30 +02003628/*
3629 * Analog playback callbacks
3630 */
3631static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
3632 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003633 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003634{
3635 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003636 if (spec->stream_delay)
3637 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01003638 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3639 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02003640}
3641
3642static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3643 struct hda_codec *codec,
3644 unsigned int stream_tag,
3645 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003646 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003647{
3648 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01003649 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02003650}
3651
3652static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3653 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003654 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003655{
3656 struct sigmatel_spec *spec = codec->spec;
3657 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3658}
3659
3660/*
Mattdabbed62005-06-14 10:19:34 +02003661 * Digital playback callbacks
3662 */
3663static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3664 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003665 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003666{
3667 struct sigmatel_spec *spec = codec->spec;
3668 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3669}
3670
3671static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3672 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003673 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003674{
3675 struct sigmatel_spec *spec = codec->spec;
3676 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3677}
3678
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003679static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3680 struct hda_codec *codec,
3681 unsigned int stream_tag,
3682 unsigned int format,
3683 struct snd_pcm_substream *substream)
3684{
3685 struct sigmatel_spec *spec = codec->spec;
3686 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3687 stream_tag, format, substream);
3688}
3689
Takashi Iwai9411e212009-02-13 11:32:28 +01003690static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3691 struct hda_codec *codec,
3692 struct snd_pcm_substream *substream)
3693{
3694 struct sigmatel_spec *spec = codec->spec;
3695 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3696}
3697
Mattdabbed62005-06-14 10:19:34 +02003698
3699/*
Matt2f2f4252005-04-13 14:45:30 +02003700 * Analog capture callbacks
3701 */
3702static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3703 struct hda_codec *codec,
3704 unsigned int stream_tag,
3705 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003706 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003707{
3708 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003709 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003710
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003711 if (spec->powerdown_adcs) {
3712 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003713 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003714 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
3715 }
3716 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02003717 return 0;
3718}
3719
3720static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3721 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003722 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003723{
3724 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003725 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003726
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003727 snd_hda_codec_cleanup_stream(codec, nid);
3728 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003729 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003730 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02003731 return 0;
3732}
3733
Takashi Iwai2b635362011-05-02 12:33:43 +02003734static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02003735 .substreams = 1,
3736 .channels_min = 2,
3737 .channels_max = 2,
3738 /* NID is set in stac92xx_build_pcms */
3739 .ops = {
3740 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003741 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01003742 .prepare = stac92xx_dig_playback_pcm_prepare,
3743 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02003744 },
3745};
3746
Takashi Iwai2b635362011-05-02 12:33:43 +02003747static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02003748 .substreams = 1,
3749 .channels_min = 2,
3750 .channels_max = 2,
3751 /* NID is set in stac92xx_build_pcms */
3752};
3753
Takashi Iwai2b635362011-05-02 12:33:43 +02003754static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02003755 .substreams = 1,
3756 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02003757 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02003758 .nid = 0x02, /* NID to query formats and rates */
3759 .ops = {
3760 .open = stac92xx_playback_pcm_open,
3761 .prepare = stac92xx_playback_pcm_prepare,
3762 .cleanup = stac92xx_playback_pcm_cleanup
3763 },
3764};
3765
Takashi Iwai2b635362011-05-02 12:33:43 +02003766static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003767 .substreams = 1,
3768 .channels_min = 2,
3769 .channels_max = 2,
3770 .nid = 0x06, /* NID to query formats and rates */
3771 .ops = {
3772 .open = stac92xx_playback_pcm_open,
3773 .prepare = stac92xx_playback_pcm_prepare,
3774 .cleanup = stac92xx_playback_pcm_cleanup
3775 },
3776};
3777
Takashi Iwai2b635362011-05-02 12:33:43 +02003778static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02003779 .channels_min = 2,
3780 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003781 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02003782 .ops = {
3783 .prepare = stac92xx_capture_pcm_prepare,
3784 .cleanup = stac92xx_capture_pcm_cleanup
3785 },
3786};
3787
3788static int stac92xx_build_pcms(struct hda_codec *codec)
3789{
3790 struct sigmatel_spec *spec = codec->spec;
3791 struct hda_pcm *info = spec->pcm_rec;
3792
3793 codec->num_pcms = 1;
3794 codec->pcm_info = info;
3795
Mattc7d4b2f2005-06-27 14:59:41 +02003796 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02003797 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01003798 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3799 spec->multiout.dac_nids[0];
Takashi Iwaiee81abb2012-11-08 17:12:10 +01003800 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3801 spec->autocfg.line_outs == 2)
3802 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
3803 snd_pcm_2_1_chmaps;
3804
Matt2f2f4252005-04-13 14:45:30 +02003805 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003806 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003807 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003808
3809 if (spec->alt_switch) {
3810 codec->num_pcms++;
3811 info++;
3812 info->name = "STAC92xx Analog Alt";
3813 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
3814 }
Matt2f2f4252005-04-13 14:45:30 +02003815
Mattdabbed62005-06-14 10:19:34 +02003816 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3817 codec->num_pcms++;
3818 info++;
3819 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003820 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02003821 if (spec->multiout.dig_out_nid) {
3822 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
3823 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3824 }
3825 if (spec->dig_in_nid) {
3826 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
3827 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3828 }
3829 }
3830
Matt2f2f4252005-04-13 14:45:30 +02003831 return 0;
3832}
3833
Matt Porter403d1942005-11-29 15:00:51 +01003834static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
3835
3836{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02003837 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01003838}
3839
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003840#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
3841
3842static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
3843 struct snd_ctl_elem_value *ucontrol)
3844{
3845 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3846 struct sigmatel_spec *spec = codec->spec;
3847
Takashi Iwaid7a89432008-11-12 09:48:04 +01003848 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003849 return 0;
3850}
3851
Takashi Iwai62558ce2009-07-29 14:23:09 +02003852static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003853
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003854static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
3855 struct snd_ctl_elem_value *ucontrol)
3856{
3857 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3858 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003859 int nid = kcontrol->private_value;
3860
3861 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003862
Lucas De Marchi25985ed2011-03-30 22:57:33 -03003863 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003864 * switch changes
3865 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02003866 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003867
3868 return 1;
3869}
3870
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003871static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
3872 struct snd_ctl_elem_info *uinfo)
3873{
3874 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02003875 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003876 "Mic In", "Line In", "Line Out"
3877 };
3878
3879 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3880 struct sigmatel_spec *spec = codec->spec;
3881 hda_nid_t nid = kcontrol->private_value;
3882
3883 if (nid == spec->mic_switch || nid == spec->line_switch)
3884 i = 3;
3885 else
3886 i = 2;
3887
3888 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3889 uinfo->value.enumerated.items = i;
3890 uinfo->count = 1;
3891 if (uinfo->value.enumerated.item >= i)
3892 uinfo->value.enumerated.item = i-1;
3893 strcpy(uinfo->value.enumerated.name,
3894 texts[uinfo->value.enumerated.item]);
3895
3896 return 0;
3897}
3898
3899static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
3900 struct snd_ctl_elem_value *ucontrol)
3901{
3902 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3903 hda_nid_t nid = kcontrol->private_value;
3904 unsigned int vref = stac92xx_vref_get(codec, nid);
3905
Takashi Iwai47408602012-04-20 13:06:53 +02003906 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003907 ucontrol->value.enumerated.item[0] = 0;
3908 else if (vref == AC_PINCTL_VREF_GRD)
3909 ucontrol->value.enumerated.item[0] = 1;
3910 else if (vref == AC_PINCTL_VREF_HIZ)
3911 ucontrol->value.enumerated.item[0] = 2;
3912
3913 return 0;
3914}
3915
3916static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
3917 struct snd_ctl_elem_value *ucontrol)
3918{
3919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3920 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02003921 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003922 hda_nid_t nid = kcontrol->private_value;
3923
3924 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02003925 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003926 else if (ucontrol->value.enumerated.item[0] == 1)
3927 new_vref = AC_PINCTL_VREF_GRD;
3928 else if (ucontrol->value.enumerated.item[0] == 2)
3929 new_vref = AC_PINCTL_VREF_HIZ;
3930 else
3931 return 0;
3932
3933 if (new_vref != stac92xx_vref_get(codec, nid)) {
3934 error = stac92xx_vref_set(codec, nid, new_vref);
3935 return error;
3936 }
3937
3938 return 0;
3939}
3940
3941static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
3942 struct snd_ctl_elem_info *uinfo)
3943{
Takashi Iwai2b635362011-05-02 12:33:43 +02003944 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3946 struct sigmatel_spec *spec = codec->spec;
3947
3948 if (kcontrol->private_value == spec->line_switch)
3949 texts[0] = "Line In";
3950 else
3951 texts[0] = "Mic In";
3952 texts[1] = "Line Out";
3953 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3954 uinfo->value.enumerated.items = 2;
3955 uinfo->count = 1;
3956
3957 if (uinfo->value.enumerated.item >= 2)
3958 uinfo->value.enumerated.item = 1;
3959 strcpy(uinfo->value.enumerated.name,
3960 texts[uinfo->value.enumerated.item]);
3961
3962 return 0;
3963}
Matt Porter403d1942005-11-29 15:00:51 +01003964
3965static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3966{
3967 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3968 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003969 hda_nid_t nid = kcontrol->private_value;
3970 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01003971
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003972 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01003973 return 0;
3974}
3975
3976static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3977{
3978 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3979 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003980 hda_nid_t nid = kcontrol->private_value;
3981 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3982 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01003983
3984 spec->io_switch[io_idx] = val;
3985
3986 if (val)
3987 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01003988 else {
3989 unsigned int pinctl = AC_PINCTL_IN_EN;
3990 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02003991 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003992 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3993 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01003994
3995 /* check the auto-mute again: we need to mute/unmute the speaker
3996 * appropriately according to the pin direction
3997 */
3998 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02003999 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01004000
Matt Porter403d1942005-11-29 15:00:51 +01004001 return 1;
4002}
4003
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004004#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
4005
4006static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
4007 struct snd_ctl_elem_value *ucontrol)
4008{
4009 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4010 struct sigmatel_spec *spec = codec->spec;
4011
4012 ucontrol->value.integer.value[0] = spec->clfe_swap;
4013 return 0;
4014}
4015
4016static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
4017 struct snd_ctl_elem_value *ucontrol)
4018{
4019 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4020 struct sigmatel_spec *spec = codec->spec;
4021 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004022 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004023
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004024 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004025 return 0;
4026
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004027 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004028
4029 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
4030 spec->clfe_swap ? 0x4 : 0x0);
4031
4032 return 1;
4033}
4034
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004035#define STAC_CODEC_HP_SWITCH(xname) \
4036 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4037 .name = xname, \
4038 .index = 0, \
4039 .info = stac92xx_hp_switch_info, \
4040 .get = stac92xx_hp_switch_get, \
4041 .put = stac92xx_hp_switch_put, \
4042 }
4043
Matt Porter403d1942005-11-29 15:00:51 +01004044#define STAC_CODEC_IO_SWITCH(xname, xpval) \
4045 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4046 .name = xname, \
4047 .index = 0, \
4048 .info = stac92xx_io_switch_info, \
4049 .get = stac92xx_io_switch_get, \
4050 .put = stac92xx_io_switch_put, \
4051 .private_value = xpval, \
4052 }
4053
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004054#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
4055 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4056 .name = xname, \
4057 .index = 0, \
4058 .info = stac92xx_clfe_switch_info, \
4059 .get = stac92xx_clfe_switch_get, \
4060 .put = stac92xx_clfe_switch_put, \
4061 .private_value = xpval, \
4062 }
Matt Porter403d1942005-11-29 15:00:51 +01004063
Mattc7d4b2f2005-06-27 14:59:41 +02004064enum {
4065 STAC_CTL_WIDGET_VOL,
4066 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004067 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01004068 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004069 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01004070 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02004071 STAC_CTL_WIDGET_CLFE_SWITCH,
4072 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02004073};
4074
Takashi Iwai2b635362011-05-02 12:33:43 +02004075static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02004076 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4077 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004078 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01004079 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004080 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01004081 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004082 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02004083 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02004084};
4085
4086/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01004087static struct snd_kcontrol_new *
4088stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004089 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004090 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004091 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02004092{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004093 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02004094
Takashi Iwai603c4012008-07-30 15:01:44 +02004095 knew = snd_array_new(&spec->kctls);
4096 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01004097 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004098 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02004099 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01004100 if (!knew->name) {
4101 /* roolback */
4102 memset(knew, 0, sizeof(*knew));
4103 spec->kctls.alloced--;
4104 return NULL;
4105 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004106 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01004107 return knew;
4108}
4109
Takashi Iwai62cbde12012-09-14 11:58:54 +02004110static struct snd_kcontrol_new *
4111add_control_temp(struct sigmatel_spec *spec,
4112 const struct snd_kcontrol_new *ktemp,
4113 int idx, const char *name,
4114 unsigned long val)
4115{
4116 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
4117 HDA_SUBDEV_AMP_FLAG);
4118 if (!knew)
4119 return NULL;
4120 knew->index = idx;
4121 knew->private_value = val;
4122 return knew;
4123}
4124
Takashi Iwaie3c75962009-01-23 11:57:22 +01004125static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004126 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01004127 int idx, const char *name,
4128 unsigned long val)
4129{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004130 return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM;
Mattc7d4b2f2005-06-27 14:59:41 +02004131}
4132
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004133static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
4134 int type, int idx, const char *name,
4135 unsigned long val)
4136{
4137 return stac92xx_add_control_temp(spec,
4138 &stac92xx_control_templates[type],
4139 idx, name, val);
4140}
4141
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004142
4143/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004144static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
4145 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004146{
4147 return stac92xx_add_control_idx(spec, type, 0, name, val);
4148}
4149
Takashi Iwai2b635362011-05-02 12:33:43 +02004150static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01004151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4152 .name = "Input Source",
4153 .info = stac92xx_mux_enum_info,
4154 .get = stac92xx_mux_enum_get,
4155 .put = stac92xx_mux_enum_put,
4156};
4157
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004158static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
4159 hda_nid_t nid, int idx)
4160{
4161 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4162 int control = 0;
4163 struct sigmatel_spec *spec = codec->spec;
4164 char name[22];
4165
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004166 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
David Henningsson8d032a82012-10-09 12:48:40 +02004167 if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf)
4168 != INPUT_PIN_ATTR_DOCK)
4169 return 0;
Takashi Iwai47408602012-04-20 13:06:53 +02004170 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004171 && nid == spec->line_switch)
4172 control = STAC_CTL_WIDGET_IO_SWITCH;
4173 else if (snd_hda_query_pin_caps(codec, nid)
4174 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
4175 control = STAC_CTL_WIDGET_DC_BIAS;
4176 else if (nid == spec->mic_switch)
4177 control = STAC_CTL_WIDGET_IO_SWITCH;
4178 }
4179
4180 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01004181 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4182 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004183 return stac92xx_add_control(codec->spec, control,
4184 strcat(name, " Jack Mode"), nid);
4185 }
4186
4187 return 0;
4188}
4189
Takashi Iwaie3c75962009-01-23 11:57:22 +01004190static int stac92xx_add_input_source(struct sigmatel_spec *spec)
4191{
4192 struct snd_kcontrol_new *knew;
4193 struct hda_input_mux *imux = &spec->private_imux;
4194
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004195 if (spec->auto_mic)
4196 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01004197 if (!spec->num_adcs || imux->num_items <= 1)
4198 return 0; /* no need for input source control */
4199 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004200 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01004201 if (!knew)
4202 return -ENOMEM;
4203 knew->count = spec->num_adcs;
4204 return 0;
4205}
4206
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004207/* check whether the line-input can be used as line-out */
4208static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01004209{
4210 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004211 struct auto_pin_cfg *cfg = &spec->autocfg;
4212 hda_nid_t nid;
4213 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004214 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004215
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004216 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4217 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004218 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004219 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004220 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01004221 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004222 if (pincap & AC_PINCAP_OUT)
4223 return nid;
4224 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004225 }
Matt Porter403d1942005-11-29 15:00:51 +01004226 return 0;
4227}
4228
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004229static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
4230
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004231/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004232static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004233{
4234 struct sigmatel_spec *spec = codec->spec;
4235 struct auto_pin_cfg *cfg = &spec->autocfg;
4236 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02004237 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004238
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004239 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004240 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4241 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004242 for (i = 0; i < cfg->num_inputs; i++) {
4243 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02004244 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004245 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004246 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4247 /* some laptops have an internal analog microphone
4248 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004249 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004250 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004251 if (pincap & AC_PINCAP_OUT) {
4252 *dac = get_unassigned_dac(codec, nid);
4253 if (*dac)
4254 return nid;
4255 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004256 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004257 }
4258 return 0;
4259}
Steve Longerbeam7b043892007-05-03 20:50:03 +02004260
4261static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4262{
4263 int i;
4264
4265 for (i = 0; i < spec->multiout.num_dacs; i++) {
4266 if (spec->multiout.dac_nids[i] == nid)
4267 return 1;
4268 }
4269
4270 return 0;
4271}
4272
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004273static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4274{
4275 int i;
4276 if (is_in_dac_nids(spec, nid))
4277 return 1;
4278 for (i = 0; i < spec->autocfg.hp_outs; i++)
4279 if (spec->hp_dacs[i] == nid)
4280 return 1;
4281 for (i = 0; i < spec->autocfg.speaker_outs; i++)
4282 if (spec->speaker_dacs[i] == nid)
4283 return 1;
4284 return 0;
4285}
4286
4287static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
4288{
4289 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02004290 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004291 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02004292 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004293 unsigned int wcaps, wtype;
4294
4295 conn_len = snd_hda_get_connections(codec, nid, conn,
4296 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01004297 /* 92HD88: trace back up the link of nids to find the DAC */
4298 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
4299 != AC_WID_AUD_OUT)) {
4300 nid = conn[0];
4301 conn_len = snd_hda_get_connections(codec, nid, conn,
4302 HDA_MAX_CONNECTIONS);
4303 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004304 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01004305 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004306 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004307 /* we check only analog outputs */
4308 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
4309 continue;
4310 /* if this route has a free DAC, assign it */
4311 if (!check_all_dac_nids(spec, conn[j])) {
4312 if (conn_len > 1) {
4313 /* select this DAC in the pin's input mux */
4314 snd_hda_codec_write_cache(codec, nid, 0,
4315 AC_VERB_SET_CONNECT_SEL, j);
4316 }
4317 return conn[j];
4318 }
4319 }
David Henningsson48718ea2011-10-05 09:49:05 +02004320
4321 /* if all DACs are already assigned, connect to the primary DAC,
4322 unless we're assigning a secondary headphone */
4323 fallback_dac = spec->multiout.dac_nids[0];
4324 if (spec->multiout.hp_nid) {
4325 for (j = 0; j < cfg->hp_outs; j++)
4326 if (cfg->hp_pins[j] == nid) {
4327 fallback_dac = spec->multiout.hp_nid;
4328 break;
4329 }
4330 }
4331
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004332 if (conn_len > 1) {
4333 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02004334 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004335 snd_hda_codec_write_cache(codec, nid, 0,
4336 AC_VERB_SET_CONNECT_SEL, j);
4337 break;
4338 }
4339 }
4340 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004341 return 0;
4342}
4343
4344static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4345static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4346
Matt Porter3cc08dc2006-01-23 15:27:49 +01004347/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02004348 * Fill in the dac_nids table from the parsed pin configuration
4349 * This function only works when every pin in line_out_pins[]
4350 * contains atleast one DAC in its connection list. Some 92xx
4351 * codecs are not connected directly to a DAC, such as the 9200
4352 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01004353 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004354static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02004355{
4356 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004357 struct auto_pin_cfg *cfg = &spec->autocfg;
4358 int i;
4359 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004360
Mattc7d4b2f2005-06-27 14:59:41 +02004361 for (i = 0; i < cfg->line_outs; i++) {
4362 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004363 dac = get_unassigned_dac(codec, nid);
4364 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02004365 if (spec->multiout.num_dacs > 0) {
4366 /* we have already working output pins,
4367 * so let's drop the broken ones again
4368 */
4369 cfg->line_outs = spec->multiout.num_dacs;
4370 break;
4371 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004372 /* error out, no available DAC found */
4373 snd_printk(KERN_ERR
4374 "%s: No available DAC for pin 0x%x\n",
4375 __func__, nid);
4376 return -ENODEV;
4377 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004378 add_spec_dacs(spec, dac);
4379 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004380
Takashi Iwai139e0712009-03-06 12:10:41 +01004381 for (i = 0; i < cfg->hp_outs; i++) {
4382 nid = cfg->hp_pins[i];
4383 dac = get_unassigned_dac(codec, nid);
4384 if (dac) {
4385 if (!spec->multiout.hp_nid)
4386 spec->multiout.hp_nid = dac;
4387 else
4388 add_spec_extra_dacs(spec, dac);
4389 }
4390 spec->hp_dacs[i] = dac;
4391 }
4392
4393 for (i = 0; i < cfg->speaker_outs; i++) {
4394 nid = cfg->speaker_pins[i];
4395 dac = get_unassigned_dac(codec, nid);
4396 if (dac)
4397 add_spec_extra_dacs(spec, dac);
4398 spec->speaker_dacs[i] = dac;
4399 }
4400
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004401 /* add line-in as output */
4402 nid = check_line_out_switch(codec);
4403 if (nid) {
4404 dac = get_unassigned_dac(codec, nid);
4405 if (dac) {
4406 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
4407 nid, cfg->line_outs);
4408 cfg->line_out_pins[cfg->line_outs] = nid;
4409 cfg->line_outs++;
4410 spec->line_switch = nid;
4411 add_spec_dacs(spec, dac);
4412 }
4413 }
4414 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004415 nid = check_mic_out_switch(codec, &dac);
4416 if (nid && dac) {
4417 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
4418 nid, cfg->line_outs);
4419 cfg->line_out_pins[cfg->line_outs] = nid;
4420 cfg->line_outs++;
4421 spec->mic_switch = nid;
4422 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02004423 }
4424
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004425 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02004426 spec->multiout.num_dacs,
4427 spec->multiout.dac_nids[0],
4428 spec->multiout.dac_nids[1],
4429 spec->multiout.dac_nids[2],
4430 spec->multiout.dac_nids[3],
4431 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004432
Mattc7d4b2f2005-06-27 14:59:41 +02004433 return 0;
4434}
4435
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004436/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01004437static int create_controls_idx(struct hda_codec *codec, const char *pfx,
4438 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004439{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004440 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004441 char name[32];
4442 int err;
4443
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004444 if (!spec->check_volume_offset) {
4445 unsigned int caps, step, nums, db_scale;
4446 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4447 step = (caps & AC_AMPCAP_STEP_SIZE) >>
4448 AC_AMPCAP_STEP_SIZE_SHIFT;
4449 step = (step + 1) * 25; /* in .01dB unit */
4450 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
4451 AC_AMPCAP_NUM_STEPS_SHIFT;
4452 db_scale = nums * step;
4453 /* if dB scale is over -64dB, and finer enough,
4454 * let's reduce it to half
4455 */
4456 if (db_scale > 6400 && nums >= 0x1f)
4457 spec->volume_offset = nums / 2;
4458 spec->check_volume_offset = 1;
4459 }
4460
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004461 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004462 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004463 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
4464 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004465 if (err < 0)
4466 return err;
4467 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004468 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004469 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
4470 if (err < 0)
4471 return err;
4472 return 0;
4473}
4474
Takashi Iwai668b9652009-03-06 10:13:24 +01004475#define create_controls(codec, pfx, nid, chs) \
4476 create_controls_idx(codec, pfx, 0, nid, chs)
4477
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004478static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
4479{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004480 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004481 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
4482 return 1;
4483 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02004484 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
4485 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004486 spec->multiout.num_dacs++;
4487 }
4488 return 0;
4489}
4490
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004491static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004492{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004493 int i;
4494 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
4495 if (!spec->multiout.extra_out_nid[i]) {
4496 spec->multiout.extra_out_nid[i] = nid;
4497 return 0;
4498 }
4499 }
4500 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
4501 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004502}
4503
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004504/* Create output controls
4505 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
4506 */
4507static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
4508 const hda_nid_t *pins,
4509 const hda_nid_t *dac_nids,
4510 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02004511{
Takashi Iwai76624532008-12-19 10:09:47 +01004512 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01004513 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02004514 "Front", "Surround", NULL /*CLFE*/, "Side"
4515 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004516 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01004517 int i, err;
4518 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004519
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004520 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004521 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004522 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004523 spec->hp_detect = 1;
4524 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004525 nid = dac_nids[i];
4526 if (!nid)
4527 continue;
4528 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02004529 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004530 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004531 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004532 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004533 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004534 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004535 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004536
4537 wid_caps = get_wcaps(codec, nid);
4538
4539 if (wid_caps & AC_WCAP_LR_SWAP) {
4540 err = stac92xx_add_control(spec,
4541 STAC_CTL_WIDGET_CLFE_SWITCH,
4542 "Swap Center/LFE Playback Switch", nid);
4543
4544 if (err < 0)
4545 return err;
4546 }
4547
Mattc7d4b2f2005-06-27 14:59:41 +02004548 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004549 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01004550 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004551 switch (type) {
4552 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01004553 name = "Headphone";
4554 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004555 break;
4556 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01004557 if (num_outs <= 2) {
4558 name = i ? "Bass Speaker" : "Speaker";
4559 idx = 0;
David Henningsson298efee2012-09-06 11:17:58 +02004560 break;
4561 }
4562 /* Fall through in case of multi speaker outs */
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004563 default:
4564 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01004565 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004566 break;
Takashi Iwai76624532008-12-19 10:09:47 +01004567 }
Takashi Iwai668b9652009-03-06 10:13:24 +01004568 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004569 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004570 return err;
4571 }
4572 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004573 return 0;
4574}
4575
Takashi Iwai62cbde12012-09-14 11:58:54 +02004576static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4577 unsigned int dir_mask, unsigned int data);
4578
4579/* hook for controlling mic-mute LED GPIO */
4580static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol,
4581 struct snd_ctl_elem_value *ucontrol)
4582{
4583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4584 struct sigmatel_spec *spec = codec->spec;
4585 int err;
4586 bool mute;
4587
4588 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4589 if (err <= 0)
4590 return err;
4591 mute = !(ucontrol->value.integer.value[0] &&
4592 ucontrol->value.integer.value[1]);
4593 if (spec->mic_mute_led_on != mute) {
4594 spec->mic_mute_led_on = mute;
4595 if (mute)
4596 spec->gpio_data |= spec->mic_mute_led_gpio;
4597 else
4598 spec->gpio_data &= ~spec->mic_mute_led_gpio;
4599 stac_gpio_set(codec, spec->gpio_mask,
4600 spec->gpio_dir, spec->gpio_data);
4601 }
4602 return err;
4603}
4604
Takashi Iwai6479c632009-07-28 18:20:25 +02004605static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
4606 unsigned long sw, int idx)
4607{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004608 struct sigmatel_spec *spec = codec->spec;
4609 struct snd_kcontrol_new *knew;
Takashi Iwai6479c632009-07-28 18:20:25 +02004610 int err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004611
Takashi Iwai6479c632009-07-28 18:20:25 +02004612 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02004613 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02004614 if (err < 0)
4615 return err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004616
4617 knew = add_control_temp(spec,
4618 &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE],
4619 idx, "Capture Switch", sw);
4620 if (!knew)
4621 return -ENOMEM;
4622 /* add a LED hook for some HP laptops */
4623 if (spec->mic_mute_led_gpio)
4624 knew->put = stac92xx_capture_sw_put_led;
4625
Takashi Iwai6479c632009-07-28 18:20:25 +02004626 return 0;
4627}
4628
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004629/* add playback controls from the parsed DAC table */
4630static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
4631 const struct auto_pin_cfg *cfg)
4632{
4633 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004634 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004635 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004636 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004637
4638 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
4639 spec->multiout.dac_nids,
4640 cfg->line_out_type);
4641 if (err < 0)
4642 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004643
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01004644 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004645 err = stac92xx_add_control(spec,
4646 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01004647 "Headphone as Line Out Switch",
4648 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004649 if (err < 0)
4650 return err;
4651 }
4652
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004653 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004654 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004655 break;
4656 nid = cfg->inputs[idx].pin;
4657 err = stac92xx_add_jack_mode_control(codec, nid, idx);
4658 if (err < 0)
4659 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01004660 }
Matt Porter403d1942005-11-29 15:00:51 +01004661
Mattc7d4b2f2005-06-27 14:59:41 +02004662 return 0;
4663}
4664
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004665/* add playback controls for Speaker and HP outputs */
4666static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
4667 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02004668{
4669 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004670 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02004671
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004672 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
4673 spec->hp_dacs, AUTO_PIN_HP_OUT);
4674 if (err < 0)
4675 return err;
4676
4677 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
4678 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
4679 if (err < 0)
4680 return err;
4681
Mattc7d4b2f2005-06-27 14:59:41 +02004682 return 0;
4683}
4684
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004685/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004686static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004687 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004688};
4689
4690/* create mono mux for mono out on capable codecs */
4691static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
4692{
4693 struct sigmatel_spec *spec = codec->spec;
4694 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
4695 int i, num_cons;
4696 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
4697
4698 num_cons = snd_hda_get_connections(codec,
4699 spec->mono_nid,
4700 con_lst,
4701 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004702 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004703 return -EINVAL;
4704
Takashi Iwai10a20af2010-09-09 16:28:02 +02004705 for (i = 0; i < num_cons; i++)
4706 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
4707 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004708
4709 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
4710 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004711}
4712
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004713/* create PC beep volume controls */
4714static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
4715 hda_nid_t nid)
4716{
4717 struct sigmatel_spec *spec = codec->spec;
4718 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004719 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
4720
4721 if (spec->anabeep_nid == nid)
4722 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004723
4724 /* check for mute support for the the amp */
4725 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004726 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004727 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004728 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4729 if (err < 0)
4730 return err;
4731 }
4732
4733 /* check to see if there is volume support for the amp */
4734 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4735 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004736 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004737 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4738 if (err < 0)
4739 return err;
4740 }
4741 return 0;
4742}
4743
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004744#ifdef CONFIG_SND_HDA_INPUT_BEEP
4745#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
4746
4747static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
4748 struct snd_ctl_elem_value *ucontrol)
4749{
4750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4751 ucontrol->value.integer.value[0] = codec->beep->enabled;
4752 return 0;
4753}
4754
4755static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
4756 struct snd_ctl_elem_value *ucontrol)
4757{
4758 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004759 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004760}
4761
Takashi Iwai2b635362011-05-02 12:33:43 +02004762static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004763 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4764 .info = stac92xx_dig_beep_switch_info,
4765 .get = stac92xx_dig_beep_switch_get,
4766 .put = stac92xx_dig_beep_switch_put,
4767};
4768
4769static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
4770{
4771 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004772 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004773}
4774#endif
4775
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004776static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
4777{
4778 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02004779 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004780
4781 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004782 hda_nid_t nid;
4783 unsigned int wcaps;
4784 unsigned long val;
4785
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004786 nid = spec->mux_nids[i];
4787 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02004788 if (!(wcaps & AC_WCAP_OUT_AMP))
4789 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004790
Takashi Iwai667067d2009-08-13 18:14:42 +02004791 /* check whether already the same control was created as
4792 * normal Capture Volume.
4793 */
4794 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4795 for (j = 0; j < spec->num_caps; j++) {
4796 if (spec->capvols[j] == val)
4797 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004798 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004799 if (j < spec->num_caps)
4800 continue;
4801
4802 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
4803 "Mux Capture Volume", val);
4804 if (err < 0)
4805 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004806 }
4807 return 0;
4808};
4809
Takashi Iwaiea734962011-01-17 11:29:34 +01004810static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04004811 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02004812};
4813
4814static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
4815{
4816 struct sigmatel_spec *spec = codec->spec;
4817 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01004818 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004819 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04004820 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02004821
4822 num_cons = snd_hda_get_connections(codec,
4823 spec->smux_nids[0],
4824 con_lst,
4825 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004826 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02004827 return -EINVAL;
4828
Matthew Ranostay65973632008-09-16 10:39:37 -04004829 if (!labels)
4830 labels = stac92xx_spdif_labels;
4831
Takashi Iwai10a20af2010-09-09 16:28:02 +02004832 for (i = 0; i < num_cons; i++)
4833 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004834
4835 return 0;
4836}
4837
Matt Porter8b657272006-10-26 17:12:59 +02004838/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004839static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02004840 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
4841 "Digital Mic 3", "Digital Mic 4"
4842};
4843
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004844static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
4845 int idx)
4846{
4847 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4848 int nums;
4849 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
4850 if (idx >= 0 && idx < nums)
4851 return conn[idx];
4852 return 0;
4853}
4854
Takashi Iwai8d087c72011-06-28 12:45:47 +02004855/* look for NID recursively */
4856#define get_connection_index(codec, mux, nid) \
4857 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004858
Takashi Iwai667067d2009-08-13 18:14:42 +02004859/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02004860/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02004861static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004862 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02004863{
4864 unsigned int caps, nums;
4865 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02004866 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02004867
Takashi Iwai96f845d2009-08-29 00:49:36 +02004868 if (direction == HDA_OUTPUT)
4869 caps = AC_WCAP_OUT_AMP;
4870 else
4871 caps = AC_WCAP_IN_AMP;
4872 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02004873 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004874 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02004875 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
4876 if (!nums)
4877 return 0;
4878 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004879 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
4880 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02004881 if (err < 0)
4882 return err;
4883 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02004884}
4885
Matt Porter8b657272006-10-26 17:12:59 +02004886/* create playback/capture controls for input pins on dmic capable codecs */
4887static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
4888 const struct auto_pin_cfg *cfg)
4889{
4890 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02004891 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004892 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004893 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02004894 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02004895
Takashi Iwai10a20af2010-09-09 16:28:02 +02004896 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02004897
Matt Porter8b657272006-10-26 17:12:59 +02004898 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01004899 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004900 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01004901 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02004902
Takashi Iwai667067d2009-08-13 18:14:42 +02004903 nid = spec->dmic_nids[i];
4904 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
4905 continue;
4906 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02004907 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
4908 continue;
4909
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004910 index = get_connection_index(codec, spec->dmux_nids[0], nid);
4911 if (index < 0)
4912 continue;
4913
Takashi Iwai201e06f2011-11-16 15:33:26 +01004914 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4915 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02004916 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01004917 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
4918 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02004919
Takashi Iwai10a20af2010-09-09 16:28:02 +02004920 err = create_elem_capture_vol(codec, nid, label, type_idx,
4921 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004922 if (err < 0)
4923 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004924 if (!err) {
4925 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02004926 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02004927 if (err < 0)
4928 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004929 if (!err) {
4930 nid = get_connected_node(codec,
4931 spec->dmux_nids[0], index);
4932 if (nid)
4933 err = create_elem_capture_vol(codec,
4934 nid, label,
4935 type_idx, HDA_INPUT);
4936 if (err < 0)
4937 return err;
4938 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02004939 }
Matt Porter8b657272006-10-26 17:12:59 +02004940 }
4941
4942 return 0;
4943}
4944
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004945static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02004946 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004947{
4948 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004949 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004950
4951 if (!nid)
4952 return 0;
4953 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004954 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004955 switch (snd_hda_get_input_pin_attr(cfg)) {
4956 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004957 if (*fixed)
4958 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004959 if (type != AC_JACK_MIC_IN)
4960 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004961 *fixed = nid;
4962 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004963 case INPUT_PIN_ATTR_UNUSED:
4964 break;
4965 case INPUT_PIN_ATTR_DOCK:
4966 if (*dock)
4967 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004968 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
4969 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004970 *dock = nid;
4971 break;
4972 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004973 if (*ext)
4974 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004975 if (type != AC_JACK_MIC_IN)
4976 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004977 *ext = nid;
4978 break;
4979 }
4980 return 0;
4981}
4982
4983static int set_mic_route(struct hda_codec *codec,
4984 struct sigmatel_mic_route *mic,
4985 hda_nid_t pin)
4986{
4987 struct sigmatel_spec *spec = codec->spec;
4988 struct auto_pin_cfg *cfg = &spec->autocfg;
4989 int i;
4990
4991 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02004992 if (pin == 0)
4993 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004994 for (i = 0; i < cfg->num_inputs; i++) {
4995 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004996 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004997 }
Takashi Iwai86e29592010-09-09 14:50:17 +02004998 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004999 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005000 i = get_connection_index(codec, spec->mux_nids[0], pin);
5001 if (i < 0)
5002 return -1;
5003 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02005004 mic->dmux_idx = -1;
5005 if (spec->dmux_nids)
5006 mic->dmux_idx = get_connection_index(codec,
5007 spec->dmux_nids[0],
5008 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005009 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005010 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005011 i = get_connection_index(codec, spec->dmux_nids[0], pin);
5012 if (i < 0)
5013 return -1;
5014 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02005015 mic->mux_idx = -1;
5016 if (spec->mux_nids)
5017 mic->mux_idx = get_connection_index(codec,
5018 spec->mux_nids[0],
5019 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005020 }
5021 return 0;
5022}
5023
5024/* return non-zero if the device is for automatic mic switch */
5025static int stac_check_auto_mic(struct hda_codec *codec)
5026{
5027 struct sigmatel_spec *spec = codec->spec;
5028 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02005029 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005030 int i;
5031
Charles Chin99077902010-09-17 10:22:32 +02005032 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005033 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02005034 if (check_mic_pin(codec, cfg->inputs[i].pin,
5035 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005036 return 0;
5037 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02005038 if (check_mic_pin(codec, spec->dmic_nids[i],
5039 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005040 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01005041 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02005042 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005043 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005044 return 0; /* no unsol support */
5045 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02005046 set_mic_route(codec, &spec->int_mic, fixed) ||
5047 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005048 return 0; /* something is wrong */
5049 return 1;
5050}
5051
Mattc7d4b2f2005-06-27 14:59:41 +02005052/* create playback/capture controls for input pins */
5053static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
5054{
5055 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005056 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02005057 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005058 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02005059
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005060 for (i = 0; i < cfg->num_inputs; i++) {
5061 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005062 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02005063
Takashi Iwai314634b2006-09-21 11:56:18 +02005064 index = -1;
5065 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02005066 index = get_connection_index(codec, spec->mux_nids[j],
5067 nid);
5068 if (index >= 0)
5069 break;
Mattc7d4b2f2005-06-27 14:59:41 +02005070 }
Takashi Iwai667067d2009-08-13 18:14:42 +02005071 if (index < 0)
5072 continue;
5073
Takashi Iwai10a20af2010-09-09 16:28:02 +02005074 label = hda_get_autocfg_input_label(codec, cfg, i);
5075 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005076
Takashi Iwai667067d2009-08-13 18:14:42 +02005077 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005078 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02005079 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02005080 if (err < 0)
5081 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02005082 }
Takashi Iwai5207e102009-07-30 13:09:08 +02005083 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02005084
Steve Longerbeam7b043892007-05-03 20:50:03 +02005085 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02005086 /*
5087 * Set the current input for the muxes.
5088 * The STAC9221 has two input muxes with identical source
5089 * NID lists. Hopefully this won't get confused.
5090 */
5091 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005092 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
5093 AC_VERB_SET_CONNECT_SEL,
5094 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005095 }
5096 }
5097
Mattc7d4b2f2005-06-27 14:59:41 +02005098 return 0;
5099}
5100
Mattc7d4b2f2005-06-27 14:59:41 +02005101static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
5102{
5103 struct sigmatel_spec *spec = codec->spec;
5104 int i;
5105
5106 for (i = 0; i < spec->autocfg.line_outs; i++) {
5107 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5108 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
5109 }
5110}
5111
5112static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
5113{
5114 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005115 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005116
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005117 for (i = 0; i < spec->autocfg.hp_outs; i++) {
5118 hda_nid_t pin;
5119 pin = spec->autocfg.hp_pins[i];
5120 if (pin) /* connect to front */
5121 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5122 }
5123 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
5124 hda_nid_t pin;
5125 pin = spec->autocfg.speaker_pins[i];
5126 if (pin) /* connect to front */
5127 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
5128 }
Mattc7d4b2f2005-06-27 14:59:41 +02005129}
5130
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01005131static int is_dual_headphones(struct hda_codec *codec)
5132{
5133 struct sigmatel_spec *spec = codec->spec;
5134 int i, valid_hps;
5135
5136 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
5137 spec->autocfg.hp_outs <= 1)
5138 return 0;
5139 valid_hps = 0;
5140 for (i = 0; i < spec->autocfg.hp_outs; i++) {
5141 hda_nid_t nid = spec->autocfg.hp_pins[i];
5142 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
5143 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
5144 continue;
5145 valid_hps++;
5146 }
5147 return (valid_hps > 1);
5148}
5149
5150
Charles Chin9009b0e2011-11-03 10:27:27 +01005151static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02005152{
5153 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01005154 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005155 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02005156 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02005157
Matt Porter8b657272006-10-26 17:12:59 +02005158 if ((err = snd_hda_parse_pin_def_config(codec,
5159 &spec->autocfg,
5160 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005161 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005162 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01005163 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02005164
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005165 /* If we have no real line-out pin and multiple hp-outs, HPs should
5166 * be set up as multi-channel outputs.
5167 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01005168 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005169 /* Copy hp_outs to line_outs, backup line_outs in
5170 * speaker_outs so that the following routines can handle
5171 * HP pins as primary outputs.
5172 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005173 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005174 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
5175 sizeof(spec->autocfg.line_out_pins));
5176 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
5177 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
5178 sizeof(spec->autocfg.hp_pins));
5179 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005180 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5181 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005182 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005183 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005184 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005185 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
5186 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005187 u32 caps = query_amp_caps(codec,
5188 spec->autocfg.mono_out_pin, dir);
5189 hda_nid_t conn_list[1];
5190
5191 /* get the mixer node and then the mono mux if it exists */
5192 if (snd_hda_get_connections(codec,
5193 spec->autocfg.mono_out_pin, conn_list, 1) &&
5194 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02005195 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01005196
5197 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02005198 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005199 /* LR swap check, some stac925x have a mux that
5200 * changes the DACs output path instead of the
5201 * mono-mux path.
5202 */
5203 if (wid_type == AC_WID_AUD_SEL &&
5204 !(wcaps & AC_WCAP_LR_SWAP))
5205 spec->mono_nid = conn_list[0];
5206 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005207 if (dir) {
5208 hda_nid_t nid = spec->autocfg.mono_out_pin;
5209
5210 /* most mono outs have a least a mute/unmute switch */
5211 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
5212 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
5213 "Mono Playback Switch",
5214 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01005215 if (err < 0)
5216 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005217 /* check for volume support for the amp */
5218 if ((caps & AC_AMPCAP_NUM_STEPS)
5219 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
5220 err = stac92xx_add_control(spec,
5221 STAC_CTL_WIDGET_VOL,
5222 "Mono Playback Volume",
5223 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
5224 if (err < 0)
5225 return err;
5226 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005227 }
5228
5229 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
5230 AC_PINCTL_OUT_EN);
5231 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005232
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005233 if (!spec->multiout.num_dacs) {
5234 err = stac92xx_auto_fill_dac_nids(codec);
5235 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02005236 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01005237 err = stac92xx_auto_create_multi_out_ctls(codec,
5238 &spec->autocfg);
5239 if (err < 0)
5240 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005241 }
Mattc7d4b2f2005-06-27 14:59:41 +02005242
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005243 /* setup analog beep controls */
5244 if (spec->anabeep_nid > 0) {
5245 err = stac92xx_auto_create_beep_ctls(codec,
5246 spec->anabeep_nid);
5247 if (err < 0)
5248 return err;
5249 }
5250
5251 /* setup digital beep controls and input device */
5252#ifdef CONFIG_SND_HDA_INPUT_BEEP
5253 if (spec->digbeep_nid > 0) {
5254 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005255 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005256
5257 err = stac92xx_auto_create_beep_ctls(codec, nid);
5258 if (err < 0)
5259 return err;
5260 err = snd_hda_attach_beep_device(codec, nid);
5261 if (err < 0)
5262 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005263 if (codec->beep) {
5264 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005265 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005266 /* if no beep switch is available, make its own one */
5267 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
5268 if (!(caps & AC_AMPCAP_MUTE)) {
5269 err = stac92xx_beep_switch_ctl(codec);
5270 if (err < 0)
5271 return err;
5272 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005273 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005274 }
5275#endif
5276
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005277 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005278 if (err < 0)
5279 return err;
5280
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005281 /* All output parsing done, now restore the swapped hp pins */
5282 if (hp_swap) {
5283 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
5284 sizeof(spec->autocfg.hp_pins));
5285 spec->autocfg.hp_outs = spec->autocfg.line_outs;
5286 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5287 spec->autocfg.line_outs = 0;
5288 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005289
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005290 if (stac_check_auto_mic(codec)) {
5291 spec->auto_mic = 1;
5292 /* only one capture for auto-mic */
5293 spec->num_adcs = 1;
5294 spec->num_caps = 1;
5295 spec->num_muxes = 1;
5296 }
5297
Takashi Iwai6479c632009-07-28 18:20:25 +02005298 for (i = 0; i < spec->num_caps; i++) {
5299 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
5300 spec->capsws[i], i);
5301 if (err < 0)
5302 return err;
5303 }
5304
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005305 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005306 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005307 return err;
5308
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005309 if (spec->mono_nid > 0) {
5310 err = stac92xx_auto_create_mono_output_ctls(codec);
5311 if (err < 0)
5312 return err;
5313 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005314 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02005315 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
5316 &spec->autocfg)) < 0)
5317 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02005318 if (spec->num_muxes > 0) {
5319 err = stac92xx_auto_create_mux_input_ctls(codec);
5320 if (err < 0)
5321 return err;
5322 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02005323 if (spec->num_smuxes > 0) {
5324 err = stac92xx_auto_create_spdif_mux_ctls(codec);
5325 if (err < 0)
5326 return err;
5327 }
Matt Porter8b657272006-10-26 17:12:59 +02005328
Takashi Iwaie3c75962009-01-23 11:57:22 +01005329 err = stac92xx_add_input_source(spec);
5330 if (err < 0)
5331 return err;
5332
Mattc7d4b2f2005-06-27 14:59:41 +02005333 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01005334 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02005335 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02005336
Charles Chin9009b0e2011-11-03 10:27:27 +01005337 /* find digital out and in converters */
5338 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
5339 unsigned int wid_caps = get_wcaps(codec, i);
5340 if (wid_caps & AC_WCAP_DIGITAL) {
5341 switch (get_wcaps_type(wid_caps)) {
5342 case AC_WID_AUD_OUT:
5343 if (!dig_out)
5344 dig_out = i;
5345 break;
5346 case AC_WID_AUD_IN:
5347 if (!dig_in)
5348 dig_in = i;
5349 break;
5350 }
5351 }
5352 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005353 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005354 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005355 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005356 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02005357
Takashi Iwai603c4012008-07-30 15:01:44 +02005358 if (spec->kctls.list)
5359 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005360
5361 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05005362 if (!spec->dinput_mux)
5363 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005364 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005365 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02005366 return 1;
5367}
5368
Takashi Iwai82bc9552006-03-21 11:24:42 +01005369/* add playback controls for HP output */
5370static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
5371 struct auto_pin_cfg *cfg)
5372{
5373 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005374 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01005375
5376 if (! pin)
5377 return 0;
5378
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005379 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01005380 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005381
5382 return 0;
5383}
5384
Richard Fish160ea0d2006-09-06 13:58:25 +02005385/* add playback controls for LFE output */
5386static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
5387 struct auto_pin_cfg *cfg)
5388{
5389 struct sigmatel_spec *spec = codec->spec;
5390 int err;
5391 hda_nid_t lfe_pin = 0x0;
5392 int i;
5393
5394 /*
5395 * search speaker outs and line outs for a mono speaker pin
5396 * with an amp. If one is found, add LFE controls
5397 * for it.
5398 */
5399 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
5400 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005401 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005402 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5403 if (wcaps == AC_WCAP_OUT_AMP)
5404 /* found a mono speaker with an amp, must be lfe */
5405 lfe_pin = pin;
5406 }
5407
5408 /* if speaker_outs is 0, then speakers may be in line_outs */
5409 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
5410 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
5411 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005412 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01005413 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01005414 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005415 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005416 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5417 if (wcaps == AC_WCAP_OUT_AMP)
5418 /* found a mono speaker with an amp,
5419 must be lfe */
5420 lfe_pin = pin;
5421 }
5422 }
5423 }
5424
5425 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01005426 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02005427 if (err < 0)
5428 return err;
5429 }
5430
5431 return 0;
5432}
5433
Mattc7d4b2f2005-06-27 14:59:41 +02005434static int stac9200_parse_auto_config(struct hda_codec *codec)
5435{
5436 struct sigmatel_spec *spec = codec->spec;
5437 int err;
5438
Kailang Yangdf694da2005-12-05 19:42:22 +01005439 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005440 return err;
5441
5442 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
5443 return err;
5444
Takashi Iwai82bc9552006-03-21 11:24:42 +01005445 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
5446 return err;
5447
Richard Fish160ea0d2006-09-06 13:58:25 +02005448 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
5449 return err;
5450
Takashi Iwai355a0ec2008-11-11 16:46:19 +01005451 if (spec->num_muxes > 0) {
5452 err = stac92xx_auto_create_mux_input_ctls(codec);
5453 if (err < 0)
5454 return err;
5455 }
5456
Takashi Iwaie3c75962009-01-23 11:57:22 +01005457 err = stac92xx_add_input_source(spec);
5458 if (err < 0)
5459 return err;
5460
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005461 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02005462 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005463 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02005464 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02005465
Takashi Iwai603c4012008-07-30 15:01:44 +02005466 if (spec->kctls.list)
5467 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005468
5469 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02005470 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02005471
5472 return 1;
5473}
5474
Sam Revitch62fe78e2006-05-10 15:09:17 +02005475/*
5476 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
5477 * funky external mute control using GPIO pins.
5478 */
5479
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005480static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005481 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02005482{
5483 unsigned int gpiostate, gpiomask, gpiodir;
5484
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005485 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
5486
Sam Revitch62fe78e2006-05-10 15:09:17 +02005487 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5488 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005489 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005490
5491 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5492 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005493 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005494
5495 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5496 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005497 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005498
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005499 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005500 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
5501
5502 snd_hda_codec_write(codec, codec->afg, 0,
5503 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005504 snd_hda_codec_read(codec, codec->afg, 0,
5505 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005506
5507 msleep(1);
5508
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005509 snd_hda_codec_read(codec, codec->afg, 0,
5510 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005511}
5512
Takashi Iwai3a938972011-10-28 01:16:55 +02005513static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005514 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005515{
Takashi Iwai3a938972011-10-28 01:16:55 +02005516 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005517
Takashi Iwai3a938972011-10-28 01:16:55 +02005518 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005519 if (!event)
5520 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02005521 event->action = type;
5522 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005523
Takashi Iwai3a938972011-10-28 01:16:55 +02005524 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005525}
5526
David Henningsson29adc4b2012-09-25 11:31:00 +02005527static void handle_unsol_event(struct hda_codec *codec,
5528 struct hda_jack_tbl *event);
5529
Takashi Iwai62558ce2009-07-29 14:23:09 +02005530/* check if given nid is a valid pin and no other events are assigned
5531 * to it. If OK, assign the event, set the unsol flag, and returns 1.
5532 * Otherwise, returns zero.
5533 */
5534static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
5535 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02005536{
Takashi Iwai3a938972011-10-28 01:16:55 +02005537 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005538
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005539 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02005540 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02005541 event = snd_hda_jack_tbl_new(codec, nid);
5542 if (!event)
5543 return -ENOMEM;
5544 if (event->action && event->action != type)
5545 return 0;
5546 event->action = type;
David Henningsson29adc4b2012-09-25 11:31:00 +02005547 event->callback = handle_unsol_event;
Takashi Iwai3a938972011-10-28 01:16:55 +02005548 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02005549 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02005550}
5551
Takashi Iwaib4ead012012-01-23 18:23:36 +01005552static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005553{
5554 int i;
5555 for (i = 0; i < cfg->hp_outs; i++)
5556 if (cfg->hp_pins[i] == nid)
5557 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01005558 for (i = 0; i < cfg->line_outs; i++)
5559 if (cfg->line_out_pins[i] == nid)
5560 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005561 return 0; /* nid is not a HP-Out */
5562};
5563
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005564static void stac92xx_power_down(struct hda_codec *codec)
5565{
5566 struct sigmatel_spec *spec = codec->spec;
5567
5568 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02005569 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005570 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005571 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005572 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005573 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5574}
5575
Takashi Iwaif73d3582008-11-25 08:21:51 +01005576static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5577 int enable);
5578
Takashi Iwaibc759722013-01-11 17:40:31 +01005579static inline bool get_int_hint(struct hda_codec *codec, const char *key,
5580 int *valp)
Takashi Iwai014c41f2009-12-27 13:53:24 +01005581{
Takashi Iwaibc759722013-01-11 17:40:31 +01005582 return !snd_hda_get_int_hint(codec, key, valp);
Takashi Iwai014c41f2009-12-27 13:53:24 +01005583}
5584
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005585/* override some hints from the hwdep entry */
5586static void stac_store_hints(struct hda_codec *codec)
5587{
5588 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005589 int val;
5590
5591 val = snd_hda_get_bool_hint(codec, "hp_detect");
5592 if (val >= 0)
5593 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01005594 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005595 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
5596 spec->gpio_mask;
5597 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01005598 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
5599 spec->gpio_mask &= spec->gpio_mask;
5600 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
5601 spec->gpio_dir &= spec->gpio_mask;
5602 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
5603 spec->eapd_mask &= spec->gpio_mask;
5604 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
5605 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005606 val = snd_hda_get_bool_hint(codec, "eapd_switch");
5607 if (val >= 0)
5608 spec->eapd_switch = val;
5609}
5610
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005611static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
5612 const hda_nid_t *pins)
5613{
5614 while (num_pins--)
5615 stac_issue_unsol_event(codec, *pins++);
5616}
5617
5618/* fake event to set up pins */
5619static void stac_fake_hp_events(struct hda_codec *codec)
5620{
5621 struct sigmatel_spec *spec = codec->spec;
5622
5623 if (spec->autocfg.hp_outs)
5624 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
5625 spec->autocfg.hp_pins);
5626 if (spec->autocfg.line_outs &&
5627 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
5628 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
5629 spec->autocfg.line_out_pins);
5630}
5631
Mattc7d4b2f2005-06-27 14:59:41 +02005632static int stac92xx_init(struct hda_codec *codec)
5633{
5634 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005635 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005636 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01005637 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005638
David Henningsson5e68fb32012-08-16 14:11:09 +02005639 if (spec->init)
5640 snd_hda_sequence_write(codec, spec->init);
Mattc7d4b2f2005-06-27 14:59:41 +02005641
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005642 snd_hda_apply_verbs(codec);
5643
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005644 /* power down adcs initially */
5645 if (spec->powerdown_adcs)
5646 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005647 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005648 spec->adc_nids[i], 0,
5649 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005650
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005651 /* override some hints */
5652 stac_store_hints(codec);
5653
Takashi Iwaif73d3582008-11-25 08:21:51 +01005654 /* set up GPIO */
5655 gpio = spec->gpio_data;
5656 /* turn on EAPD statically when spec->eapd_switch isn't set.
5657 * otherwise, unsol event will turn it on/off dynamically
5658 */
5659 if (!spec->eapd_switch)
5660 gpio |= spec->eapd_mask;
5661 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
5662
Takashi Iwai82bc9552006-03-21 11:24:42 +01005663 /* set up pins */
5664 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02005665 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005666 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005667 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005668 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005669 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02005670 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
5671 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005672 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02005673 for (i = 0; i < cfg->line_outs; i++) {
5674 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005675 enable_pin_detect(codec, nid, STAC_LO_EVENT);
5676 }
5677 }
5678
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01005679 /* force to enable the first line-out; the others are set up
5680 * in unsol_event
5681 */
5682 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005683 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005684 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005685 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005686 } else {
5687 stac92xx_auto_init_multi_out(codec);
5688 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005689 for (i = 0; i < cfg->hp_outs; i++)
5690 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005691 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005692 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02005693 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005694 if (spec->dmux_nids)
5695 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02005696 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005697 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
5698 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02005699 if (enable_pin_detect(codec, spec->dock_mic.pin,
5700 STAC_MIC_EVENT))
5701 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005702 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005703 for (i = 0; i < cfg->num_inputs; i++) {
5704 hda_nid_t nid = cfg->inputs[i].pin;
5705 int type = cfg->inputs[i].type;
5706 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02005707 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005708 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02005709 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005710 pinctl |= AC_PINCTL_IN_EN;
5711 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5712 } else {
5713 pinctl = snd_hda_codec_read(codec, nid, 0,
5714 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5715 /* if PINCTL already set then skip */
5716 /* Also, if both INPUT and OUTPUT are set,
5717 * it must be a BIOS bug; need to override, too
5718 */
5719 if (!(pinctl & AC_PINCTL_IN_EN) ||
5720 (pinctl & AC_PINCTL_OUT_EN)) {
5721 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005722 pinctl |= AC_PINCTL_IN_EN;
5723 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01005724 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005725 }
5726 conf = snd_hda_codec_get_pincfg(codec, nid);
5727 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
5728 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
5729 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01005730 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01005731 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005732 for (i = 0; i < spec->num_dmics; i++)
5733 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
5734 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005735 if (cfg->dig_out_pins[0])
5736 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01005737 AC_PINCTL_OUT_EN);
5738 if (cfg->dig_in_pin)
5739 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
5740 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005741 for (i = 0; i < spec->num_pwrs; i++) {
5742 hda_nid_t nid = spec->pwr_nids[i];
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005743 unsigned int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005744
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005745 def_conf = snd_hda_codec_get_pincfg(codec, nid);
5746 def_conf = get_defcfg_connect(def_conf);
5747 if (def_conf == AC_JACK_PORT_NONE) {
5748 /* power off unused ports */
5749 stac_toggle_power_map(codec, nid, 0);
5750 continue;
5751 }
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005752 if (def_conf == AC_JACK_PORT_FIXED) {
5753 /* no need for jack detection for fixed pins */
5754 stac_toggle_power_map(codec, nid, 1);
5755 continue;
5756 }
Takashi Iwaieb632122008-12-19 16:39:48 +01005757 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01005758 /* or when the VREF is used for controlling LED */
5759 if (!spec->hp_detect ||
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005760 spec->vref_mute_led_nid == nid ||
5761 !is_jack_detectable(codec, nid)) {
Takashi Iwaieb632122008-12-19 16:39:48 +01005762 stac_toggle_power_map(codec, nid, 1);
5763 continue;
5764 }
5765
Takashi Iwaib4ead012012-01-23 18:23:36 +01005766 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01005767 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005768
Takashi Iwaif73d3582008-11-25 08:21:51 +01005769 pinctl = snd_hda_codec_read(codec, nid, 0,
5770 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5771 /* outputs are only ports capable of power management
5772 * any attempts on powering down a input port cause the
5773 * referenced VREF to act quirky.
5774 */
Takashi Iwaieb632122008-12-19 16:39:48 +01005775 if (pinctl & AC_PINCTL_IN_EN) {
5776 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005777 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01005778 }
Charles Chinafef2cf2011-11-11 08:05:28 +01005779 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02005780 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01005781 continue;
5782 }
5783 /* none of the above, turn the port OFF */
5784 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005785 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01005786
Takashi Iwaic21bd022010-02-08 15:16:08 +01005787 /* sync mute LED */
Takashi Iwai1f43f6c2012-07-31 10:40:05 +02005788 if (spec->gpio_led) {
5789 if (spec->vmaster_mute.hook)
5790 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5791 else /* the very first init call doesn't have vmaster yet */
5792 stac92xx_update_led_status(codec, false);
5793 }
Takashi Iwaic8822462012-05-15 09:11:36 +02005794
5795 /* sync the power-map */
5796 if (spec->num_pwrs)
5797 snd_hda_codec_write(codec, codec->afg, 0,
5798 AC_VERB_IDT_SET_POWER_MAP,
5799 spec->power_map_bits);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005800 if (spec->dac_list)
5801 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02005802 return 0;
5803}
5804
Takashi Iwai603c4012008-07-30 15:01:44 +02005805static void stac92xx_free_kctls(struct hda_codec *codec)
5806{
5807 struct sigmatel_spec *spec = codec->spec;
5808
5809 if (spec->kctls.list) {
5810 struct snd_kcontrol_new *kctl = spec->kctls.list;
5811 int i;
5812 for (i = 0; i < spec->kctls.used; i++)
5813 kfree(kctl[i].name);
5814 }
5815 snd_array_free(&spec->kctls);
5816}
5817
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005818static void stac92xx_shutup_pins(struct hda_codec *codec)
5819{
5820 unsigned int i, def_conf;
5821
5822 if (codec->bus->shutdown)
5823 return;
5824 for (i = 0; i < codec->init_pins.used; i++) {
5825 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
5826 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
5827 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005828 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005829 }
5830}
5831
Takashi Iwai167eae52009-11-06 15:47:50 +01005832static void stac92xx_shutup(struct hda_codec *codec)
5833{
5834 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01005835
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005836 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01005837
5838 if (spec->eapd_mask)
5839 stac_gpio_set(codec, spec->gpio_mask,
5840 spec->gpio_dir, spec->gpio_data &
5841 ~spec->eapd_mask);
5842}
5843
Matt2f2f4252005-04-13 14:45:30 +02005844static void stac92xx_free(struct hda_codec *codec)
5845{
Mattc7d4b2f2005-06-27 14:59:41 +02005846 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005847
5848 if (! spec)
5849 return;
5850
Mattc7d4b2f2005-06-27 14:59:41 +02005851 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005852 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02005853}
5854
Matt4e550962005-07-04 17:51:39 +02005855static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
5856 unsigned int flag)
5857{
Takashi Iwai8ce84192009-01-22 16:59:20 +01005858 unsigned int old_ctl, pin_ctl;
5859
5860 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02005861 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02005862
Takashi Iwaif9acba42007-05-29 18:01:06 +02005863 if (pin_ctl & AC_PINCTL_IN_EN) {
5864 /*
5865 * we need to check the current set-up direction of
5866 * shared input pins since they can be switched via
5867 * "xxx as Output" mixer switch
5868 */
5869 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005870 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02005871 return;
5872 }
5873
Takashi Iwai8ce84192009-01-22 16:59:20 +01005874 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02005875 /* if setting pin direction bits, clear the current
5876 direction bits first */
5877 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
5878 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
5879
Takashi Iwai8ce84192009-01-22 16:59:20 +01005880 pin_ctl |= flag;
5881 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005882 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02005883}
5884
5885static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
5886 unsigned int flag)
5887{
5888 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
5889 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01005890 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005891 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02005892}
5893
Takashi Iwaid56757a2009-11-18 08:00:14 +01005894static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02005895{
5896 if (!nid)
5897 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01005898 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02005899}
5900
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005901static void stac92xx_line_out_detect(struct hda_codec *codec,
5902 int presence)
5903{
5904 struct sigmatel_spec *spec = codec->spec;
5905 struct auto_pin_cfg *cfg = &spec->autocfg;
5906 int i;
5907
David Henningsson042b92c2012-08-22 16:10:43 +02005908 if (cfg->speaker_outs == 0)
5909 return;
5910
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005911 for (i = 0; i < cfg->line_outs; i++) {
5912 if (presence)
5913 break;
5914 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
5915 if (presence) {
5916 unsigned int pinctl;
5917 pinctl = snd_hda_codec_read(codec,
5918 cfg->line_out_pins[i], 0,
5919 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5920 if (pinctl & AC_PINCTL_IN_EN)
5921 presence = 0; /* mic- or line-input */
5922 }
5923 }
5924
5925 if (presence) {
5926 /* disable speakers */
5927 for (i = 0; i < cfg->speaker_outs; i++)
5928 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
5929 AC_PINCTL_OUT_EN);
5930 if (spec->eapd_mask && spec->eapd_switch)
5931 stac_gpio_set(codec, spec->gpio_mask,
5932 spec->gpio_dir, spec->gpio_data &
5933 ~spec->eapd_mask);
5934 } else {
5935 /* enable speakers */
5936 for (i = 0; i < cfg->speaker_outs; i++)
5937 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
5938 AC_PINCTL_OUT_EN);
5939 if (spec->eapd_mask && spec->eapd_switch)
5940 stac_gpio_set(codec, spec->gpio_mask,
5941 spec->gpio_dir, spec->gpio_data |
5942 spec->eapd_mask);
5943 }
5944}
5945
Takashi Iwaid7a89432008-11-12 09:48:04 +01005946/* return non-zero if the hp-pin of the given array index isn't
5947 * a jack-detection target
5948 */
5949static int no_hp_sensing(struct sigmatel_spec *spec, int i)
5950{
5951 struct auto_pin_cfg *cfg = &spec->autocfg;
5952
5953 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005954 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005955 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005956 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005957 return 1;
5958 /* ignore if the pin is set as line-out */
5959 if (cfg->hp_pins[i] == spec->hp_switch)
5960 return 1;
5961 return 0;
5962}
5963
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005964static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02005965{
5966 struct sigmatel_spec *spec = codec->spec;
5967 struct auto_pin_cfg *cfg = &spec->autocfg;
5968 int i, presence;
5969
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005970 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005971 if (spec->gpio_mute)
5972 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
5973 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
5974
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005975 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005976 if (presence)
5977 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01005978 if (no_hp_sensing(spec, i))
5979 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005980 presence = get_pin_presence(codec, cfg->hp_pins[i]);
5981 if (presence) {
5982 unsigned int pinctl;
5983 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
5984 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5985 if (pinctl & AC_PINCTL_IN_EN)
5986 presence = 0; /* mic- or line-input */
5987 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005988 }
Matt4e550962005-07-04 17:51:39 +02005989
5990 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005991 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005992 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005993 stac92xx_reset_pinctl(codec, spec->hp_switch,
5994 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005995 for (i = 0; i < cfg->line_outs; i++)
5996 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
5997 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005998 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005999 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02006000 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01006001 stac92xx_set_pinctl(codec, spec->hp_switch,
6002 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02006003 for (i = 0; i < cfg->line_outs; i++)
6004 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
6005 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02006006 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006007 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01006008 /* toggle hp outs */
6009 for (i = 0; i < cfg->hp_outs; i++) {
6010 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
6011 if (no_hp_sensing(spec, i))
6012 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01006013 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01006014 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01006015#if 0 /* FIXME */
6016/* Resetting the pinctl like below may lead to (a sort of) regressions
6017 * on some devices since they use the HP pin actually for line/speaker
6018 * outs although the default pin config shows a different pin (that is
6019 * wrong and useless).
6020 *
6021 * So, it's basically a problem of default pin configs, likely a BIOS issue.
6022 * But, disabling the code below just works around it, and I'm too tired of
6023 * bug reports with such devices...
6024 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01006025 else
6026 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01006027#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01006028 }
Matt4e550962005-07-04 17:51:39 +02006029}
6030
Takashi Iwaif73d3582008-11-25 08:21:51 +01006031static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
6032 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006033{
6034 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01006035 unsigned int idx, val;
6036
6037 for (idx = 0; idx < spec->num_pwrs; idx++) {
6038 if (spec->pwr_nids[idx] == nid)
6039 break;
6040 }
6041 if (idx >= spec->num_pwrs)
6042 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006043
Charles Chinafef2cf2011-11-11 08:05:28 +01006044 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006045
Takashi Iwaic8822462012-05-15 09:11:36 +02006046 val = spec->power_map_bits;
Takashi Iwaif73d3582008-11-25 08:21:51 +01006047 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006048 val &= ~idx;
6049 else
6050 val |= idx;
6051
6052 /* power down unused output ports */
Takashi Iwaic8822462012-05-15 09:11:36 +02006053 if (val != spec->power_map_bits) {
6054 spec->power_map_bits = val;
6055 snd_hda_codec_write(codec, codec->afg, 0,
6056 AC_VERB_IDT_SET_POWER_MAP, val);
6057 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04006058}
6059
Takashi Iwaif73d3582008-11-25 08:21:51 +01006060static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
6061{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01006062 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01006063}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006064
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006065/* get the pin connection (fixed, none, etc) */
6066static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
6067{
6068 struct sigmatel_spec *spec = codec->spec;
6069 unsigned int cfg;
6070
6071 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
6072 return get_defcfg_connect(cfg);
6073}
6074
6075static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006076 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006077{
6078 struct sigmatel_spec *spec = codec->spec;
6079 int idx, num;
6080 unsigned int def_conf;
6081
6082 for (num = 0; num < num_nids; num++) {
6083 for (idx = 0; idx < spec->num_pins; idx++)
6084 if (spec->pin_nids[idx] == nids[num])
6085 break;
6086 if (idx >= spec->num_pins)
6087 break;
6088 def_conf = stac_get_defcfg_connect(codec, idx);
6089 if (def_conf == AC_JACK_PORT_NONE)
6090 break;
6091 }
6092 return num;
6093}
6094
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006095static void stac92xx_mic_detect(struct hda_codec *codec)
6096{
6097 struct sigmatel_spec *spec = codec->spec;
6098 struct sigmatel_mic_route *mic;
6099
6100 if (get_pin_presence(codec, spec->ext_mic.pin))
6101 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02006102 else if (get_pin_presence(codec, spec->dock_mic.pin))
6103 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006104 else
6105 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02006106 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006107 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
6108 AC_VERB_SET_CONNECT_SEL,
6109 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02006110 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006111 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
6112 AC_VERB_SET_CONNECT_SEL,
6113 mic->mux_idx);
6114}
6115
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006116static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02006117 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02006118{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006119 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006120 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006121
Takashi Iwai3a938972011-10-28 01:16:55 +02006122 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02006123 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006124 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02006125 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006126 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006127 case STAC_MIC_EVENT:
6128 stac92xx_mic_detect(codec);
6129 break;
6130 }
6131
Takashi Iwai3a938972011-10-28 01:16:55 +02006132 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006133 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006134 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006135 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04006136 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006137 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006138 if (spec->num_pwrs > 0)
6139 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04006140
6141 switch (codec->subsystem_id) {
6142 case 0x103c308f:
6143 if (event->nid == 0xb) {
6144 int pin = AC_PINCTL_IN_EN;
6145
6146 if (get_pin_presence(codec, 0xa)
6147 && get_pin_presence(codec, 0xb))
6148 pin |= AC_PINCTL_VREF_80;
6149 if (!get_pin_presence(codec, 0xb))
6150 pin |= AC_PINCTL_VREF_80;
6151
6152 /* toggle VREF state based on mic + hp pin
6153 * status
6154 */
6155 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
6156 }
6157 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04006158 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006159 case STAC_VREF_EVENT:
6160 data = snd_hda_codec_read(codec, codec->afg, 0,
6161 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04006162 /* toggle VREF state based on GPIOx status */
6163 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02006164 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04006165 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02006166 }
6167}
6168
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006169static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
6170{
Takashi Iwai3a938972011-10-28 01:16:55 +02006171 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006172 if (!event)
6173 return;
6174 handle_unsol_event(codec, event);
6175}
6176
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306177static void set_hp_led_gpio(struct hda_codec *codec)
6178{
6179 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01006180 unsigned int gpio;
6181
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02006182 if (spec->gpio_led)
6183 return;
6184
Takashi Iwai07f80442010-02-08 15:06:13 +01006185 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
6186 gpio &= AC_GPIO_IO_COUNT;
6187 if (gpio > 3)
6188 spec->gpio_led = 0x08; /* GPIO 3 */
6189 else
6190 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306191}
6192
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006193/*
6194 * This method searches for the mute LED GPIO configuration
6195 * provided as OEM string in SMBIOS. The format of that string
6196 * is HP_Mute_LED_P_G or HP_Mute_LED_P
6197 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
6198 * that corresponds to the NOT muted state of the master volume
6199 * and G is the index of the GPIO to use as the mute LED control (0..9)
6200 * If _G portion is missing it is assigned based on the codec ID
6201 *
6202 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
6203 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306204 *
6205 *
6206 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
6207 * SMBIOS - at least the ones I have seen do not have them - which include
6208 * my own system (HP Pavilion dv6-1110ax) and my cousin's
6209 * HP Pavilion dv9500t CTO.
6210 * Need more information on whether it is true across the entire series.
6211 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006212 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006213static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006214{
6215 struct sigmatel_spec *spec = codec->spec;
6216 const struct dmi_device *dev = NULL;
6217
Takashi Iwai75609312012-05-14 16:52:00 +02006218 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
6219 get_int_hint(codec, "gpio_led_polarity",
6220 &spec->gpio_led_polarity);
6221 return 1;
6222 }
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006223
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006224 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
6225 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
6226 &spec->gpio_led_polarity,
6227 &spec->gpio_led) == 2) {
6228 unsigned int max_gpio;
6229 max_gpio = snd_hda_param_read(codec, codec->afg,
6230 AC_PAR_GPIO_CAP);
6231 max_gpio &= AC_GPIO_IO_COUNT;
6232 if (spec->gpio_led < max_gpio)
6233 spec->gpio_led = 1 << spec->gpio_led;
6234 else
6235 spec->vref_mute_led_nid = spec->gpio_led;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306236 return 1;
6237 }
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006238 if (sscanf(dev->name, "HP_Mute_LED_%d",
6239 &spec->gpio_led_polarity) == 1) {
6240 set_hp_led_gpio(codec);
6241 return 1;
6242 }
6243 /* BIOS bug: unfilled OEM string */
6244 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
6245 set_hp_led_gpio(codec);
Takashi Iwai8c698fe2013-01-15 11:20:50 +01006246 if (default_polarity >= 0)
6247 spec->gpio_led_polarity = default_polarity;
6248 else
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006249 spec->gpio_led_polarity = 1;
Takashi Iwai89bb3e72013-01-15 11:12:18 +01006250 return 1;
6251 }
6252 }
6253
6254 /*
6255 * Fallback case - if we don't find the DMI strings,
6256 * we statically set the GPIO - if not a B-series system
6257 * and default polarity is provided
6258 */
6259 if (!hp_blike_system(codec->subsystem_id) &&
6260 (default_polarity == 0 || default_polarity == 1)) {
6261 set_hp_led_gpio(codec);
6262 spec->gpio_led_polarity = default_polarity;
6263 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006264 }
6265 return 0;
6266}
6267
6268static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08006269{
6270 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006271 case 0x103c1520:
6272 case 0x103c1521:
6273 case 0x103c1523:
6274 case 0x103c1524:
6275 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006276 case 0x103c1722:
6277 case 0x103c1723:
6278 case 0x103c1724:
6279 case 0x103c1725:
6280 case 0x103c1726:
6281 case 0x103c1727:
6282 case 0x103c1728:
6283 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006284 case 0x103c172a:
6285 case 0x103c172b:
6286 case 0x103c307e:
6287 case 0x103c307f:
6288 case 0x103c3080:
6289 case 0x103c3081:
6290 case 0x103c7007:
6291 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006292 return 1;
6293 }
6294 return 0;
6295}
6296
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006297#ifdef CONFIG_PROC_FS
6298static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
6299 struct hda_codec *codec, hda_nid_t nid)
6300{
6301 if (nid == codec->afg)
6302 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02006303 snd_hda_codec_read(codec, nid, 0,
6304 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006305}
6306
6307static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
6308 struct hda_codec *codec,
6309 unsigned int verb)
6310{
6311 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
6312 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
6313}
6314
6315/* stac92hd71bxx, stac92hd73xx */
6316static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
6317 struct hda_codec *codec, hda_nid_t nid)
6318{
6319 stac92hd_proc_hook(buffer, codec, nid);
6320 if (nid == codec->afg)
6321 analog_loop_proc_hook(buffer, codec, 0xfa0);
6322}
6323
6324static void stac9205_proc_hook(struct snd_info_buffer *buffer,
6325 struct hda_codec *codec, hda_nid_t nid)
6326{
6327 if (nid == codec->afg)
6328 analog_loop_proc_hook(buffer, codec, 0xfe0);
6329}
6330
6331static void stac927x_proc_hook(struct snd_info_buffer *buffer,
6332 struct hda_codec *codec, hda_nid_t nid)
6333{
6334 if (nid == codec->afg)
6335 analog_loop_proc_hook(buffer, codec, 0xfeb);
6336}
6337#else
6338#define stac92hd_proc_hook NULL
6339#define stac92hd7x_proc_hook NULL
6340#define stac9205_proc_hook NULL
6341#define stac927x_proc_hook NULL
6342#endif
6343
Takashi Iwai2a439522011-07-26 09:52:50 +02006344#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02006345static int stac92xx_resume(struct hda_codec *codec)
6346{
Takashi Iwai2c885872008-11-18 09:36:55 +01006347 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006348 snd_hda_codec_resume_amp(codec);
6349 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01006350 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01006351 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02006352 return 0;
6353}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006354
Takashi Iwai68cb2b52012-07-02 15:20:37 +02006355static int stac92xx_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006356{
6357 stac92xx_shutup(codec);
6358 return 0;
6359}
6360
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006361static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
6362 unsigned int power_state)
6363{
6364 unsigned int afg_power_state = power_state;
6365 struct sigmatel_spec *spec = codec->spec;
6366
6367 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006368 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006369 /* with vref-out pin used for mute led control
6370 * codec AFG is prevented from D3 state
6371 */
6372 afg_power_state = AC_PWRST_D1;
6373 }
6374 /* this delay seems necessary to avoid click noise at power-down */
6375 msleep(100);
6376 }
6377 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
6378 afg_power_state);
6379 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
6380}
Takashi Iwai350eba432012-03-16 16:09:03 +01006381#else
6382#define stac92xx_suspend NULL
6383#define stac92xx_resume NULL
Takashi Iwai350eba432012-03-16 16:09:03 +01006384#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006385#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006386
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006387/* update mute-LED accoring to the master switch */
6388static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006389{
6390 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006391 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01006392
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006393 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006394 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006395
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006396 /* LED state is inverted on these systems */
6397 if (spec->gpio_led_polarity)
6398 muted = !muted;
6399
Takashi Iwaif1a73742011-12-04 13:44:06 +01006400 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006401 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02006402 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006403 else
Takashi Iwai3e843192012-04-19 12:04:03 +02006404 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006405 stac_gpio_set(codec, spec->gpio_mask,
6406 spec->gpio_dir, spec->gpio_data);
6407 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006408 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01006409 stac_vrefout_set(codec, spec->vref_mute_led_nid,
6410 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006411 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006412}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05006413
Takashi Iwai2b635362011-05-02 12:33:43 +02006414static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02006415 .build_controls = stac92xx_build_controls,
6416 .build_pcms = stac92xx_build_pcms,
6417 .init = stac92xx_init,
6418 .free = stac92xx_free,
David Henningsson29adc4b2012-09-25 11:31:00 +02006419 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02006420#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006421 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02006422 .resume = stac92xx_resume,
6423#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01006424 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02006425};
6426
Takashi Iwai361dab32012-05-09 14:35:27 +02006427static int alloc_stac_spec(struct hda_codec *codec, int num_pins,
6428 const hda_nid_t *pin_nids)
6429{
6430 struct sigmatel_spec *spec;
6431
6432 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6433 if (!spec)
6434 return -ENOMEM;
6435 codec->spec = spec;
6436 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
6437 spec->num_pins = num_pins;
6438 spec->pin_nids = pin_nids;
6439 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
6440 return 0;
6441}
6442
Matt2f2f4252005-04-13 14:45:30 +02006443static int patch_stac9200(struct hda_codec *codec)
6444{
6445 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006446 int err;
Matt2f2f4252005-04-13 14:45:30 +02006447
Takashi Iwai361dab32012-05-09 14:35:27 +02006448 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids),
6449 stac9200_pin_nids);
6450 if (err < 0)
6451 return err;
Matt2f2f4252005-04-13 14:45:30 +02006452
Takashi Iwai361dab32012-05-09 14:35:27 +02006453 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006454 spec->linear_tone_beep = 1;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006455
6456 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
6457 stac9200_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006458
6459 spec->multiout.max_channels = 2;
6460 spec->multiout.num_dacs = 1;
6461 spec->multiout.dac_nids = stac9200_dac_nids;
6462 spec->adc_nids = stac9200_adc_nids;
6463 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02006464 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02006465 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006466 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006467 spec->num_pwrs = 0;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006468 snd_hda_add_verbs(codec, stac9200_eapd_init);
Mattc7d4b2f2005-06-27 14:59:41 +02006469
Matt2f2f4252005-04-13 14:45:30 +02006470 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02006471
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006472 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai117f2572008-03-18 09:53:23 +01006473
Mattc7d4b2f2005-06-27 14:59:41 +02006474 err = stac9200_parse_auto_config(codec);
6475 if (err < 0) {
6476 stac92xx_free(codec);
6477 return err;
6478 }
Matt2f2f4252005-04-13 14:45:30 +02006479
6480 codec->patch_ops = stac92xx_patch_ops;
6481
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006482 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6483
Matt2f2f4252005-04-13 14:45:30 +02006484 return 0;
6485}
6486
Tobin Davis8e21c342007-01-08 11:04:17 +01006487static int patch_stac925x(struct hda_codec *codec)
6488{
6489 struct sigmatel_spec *spec;
6490 int err;
6491
Takashi Iwai361dab32012-05-09 14:35:27 +02006492 err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids),
6493 stac925x_pin_nids);
6494 if (err < 0)
6495 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01006496
Takashi Iwai361dab32012-05-09 14:35:27 +02006497 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006498 spec->linear_tone_beep = 1;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02006499
Takashi Iwaid2077d42013-01-14 14:20:16 +01006500 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
6501 stac925x_fixups);
Tobin Davis8e21c342007-01-08 11:04:17 +01006502
6503 spec->multiout.max_channels = 2;
6504 spec->multiout.num_dacs = 1;
6505 spec->multiout.dac_nids = stac925x_dac_nids;
6506 spec->adc_nids = stac925x_adc_nids;
6507 spec->mux_nids = stac925x_mux_nids;
6508 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006509 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006510 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02006511 switch (codec->vendor_id) {
6512 case 0x83847632: /* STAC9202 */
6513 case 0x83847633: /* STAC9202D */
6514 case 0x83847636: /* STAC9251 */
6515 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02006516 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02006517 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006518 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
6519 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02006520 break;
6521 default:
6522 spec->num_dmics = 0;
6523 break;
6524 }
Tobin Davis8e21c342007-01-08 11:04:17 +01006525
Takashi Iwaid2077d42013-01-14 14:20:16 +01006526 snd_hda_add_verbs(codec, stac925x_core_init);
Tobin Davis8e21c342007-01-08 11:04:17 +01006527 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02006528 spec->num_caps = 1;
6529 spec->capvols = stac925x_capvols;
6530 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01006531
Takashi Iwaid2077d42013-01-14 14:20:16 +01006532 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6533
Charles Chin9009b0e2011-11-03 10:27:27 +01006534 err = stac92xx_parse_auto_config(codec);
Takashi Iwaid2077d42013-01-14 14:20:16 +01006535 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006536 err = -EINVAL;
Tobin Davis8e21c342007-01-08 11:04:17 +01006537 if (err < 0) {
6538 stac92xx_free(codec);
6539 return err;
6540 }
6541
6542 codec->patch_ops = stac92xx_patch_ops;
6543
Takashi Iwaid2077d42013-01-14 14:20:16 +01006544 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6545
Tobin Davis8e21c342007-01-08 11:04:17 +01006546 return 0;
6547}
6548
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006549static int patch_stac92hd73xx(struct hda_codec *codec)
6550{
6551 struct sigmatel_spec *spec;
6552 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
Takashi Iwai361dab32012-05-09 14:35:27 +02006553 int err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006554 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006555
Takashi Iwai361dab32012-05-09 14:35:27 +02006556 err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids),
6557 stac92hd73xx_pin_nids);
6558 if (err < 0)
6559 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006560
Takashi Iwai361dab32012-05-09 14:35:27 +02006561 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006562 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02006563 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Takashi Iwai55e30142013-01-14 17:30:04 +01006564
6565 snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl,
6566 stac92hd73xx_fixups);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006567
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006568 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006569 conn, STAC92HD73_DAC_COUNT + 2) - 1;
6570
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006571 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006572 printk(KERN_WARNING "hda_codec: Could not determine "
6573 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006574 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006575 }
Takashi Iwai55e30142013-01-14 17:30:04 +01006576
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006577 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006578 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006579 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006580 break;
6581 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006582 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006583 break;
6584 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006585 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
6586 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006587 }
6588 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006589
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006590 spec->aloopback_mask = 0x01;
6591 spec->aloopback_shift = 8;
6592
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006593 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006594 spec->mux_nids = stac92hd73xx_mux_nids;
6595 spec->adc_nids = stac92hd73xx_adc_nids;
6596 spec->dmic_nids = stac92hd73xx_dmic_nids;
6597 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006598 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006599
6600 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
6601 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01006602 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006603
Takashi Iwai6479c632009-07-28 18:20:25 +02006604 spec->num_caps = STAC92HD73XX_NUM_CAPS;
6605 spec->capvols = stac92hd73xx_capvols;
6606 spec->capsws = stac92hd73xx_capsws;
6607
Takashi Iwai55e30142013-01-14 17:30:04 +01006608 /* GPIO0 High = Enable EAPD */
6609 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6610 spec->gpio_data = 0x01;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006611
Takashi Iwai55e30142013-01-14 17:30:04 +01006612 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6613 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6614 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006615
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006616 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
6617 spec->pwr_nids = stac92hd73xx_pwr_nids;
6618
Takashi Iwai55e30142013-01-14 17:30:04 +01006619 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6620
6621 if (!spec->volknob_init)
6622 snd_hda_add_verbs(codec, stac92hd73xx_core_init);
6623
Charles Chin9009b0e2011-11-03 10:27:27 +01006624 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006625
Takashi Iwai55e30142013-01-14 17:30:04 +01006626 if (!err)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006627 err = -EINVAL;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006628 if (err < 0) {
6629 stac92xx_free(codec);
6630 return err;
6631 }
6632
6633 codec->patch_ops = stac92xx_patch_ops;
6634
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006635 codec->proc_widget_hook = stac92hd7x_proc_hook;
6636
Takashi Iwai55e30142013-01-14 17:30:04 +01006637 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6638
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006639 return 0;
6640}
6641
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006642static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006643{
6644 if (codec->vendor_id != 0x111d7605 &&
6645 codec->vendor_id != 0x111d76d1)
6646 return 0;
6647
6648 switch (codec->subsystem_id) {
6649 case 0x103c1618:
6650 case 0x103c1619:
6651 case 0x103c161a:
6652 case 0x103c161b:
6653 case 0x103c161c:
6654 case 0x103c161d:
6655 case 0x103c161e:
6656 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006657
6658 case 0x103c162a:
6659 case 0x103c162b:
6660
6661 case 0x103c1630:
6662 case 0x103c1631:
6663
6664 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006665 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006666 case 0x103c1635:
6667
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006668 case 0x103c3587:
6669 case 0x103c3588:
6670 case 0x103c3589:
6671 case 0x103c358a:
6672
6673 case 0x103c3667:
6674 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006675 case 0x103c3669:
6676
6677 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006678 }
6679 return 0;
6680}
6681
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006682static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
6683{
6684 struct sigmatel_spec *spec = codec->spec;
6685 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
6686 int i;
6687
6688 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
6689 spec->auto_pin_cnt++;
6690
6691 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
6692 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
6693 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
6694 if (nid == stac92hd83xxx_dmic_nids[i]) {
6695 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
6696 spec->auto_dmic_cnt++;
6697 }
6698 }
6699 }
6700}
6701
6702static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
6703{
6704 struct sigmatel_spec *spec = codec->spec;
6705
6706 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
6707 spec->auto_adc_cnt++;
6708}
6709
6710static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
6711{
6712 int i, j;
6713 struct sigmatel_spec *spec = codec->spec;
6714
6715 for (i = 0; i < spec->auto_adc_cnt; i++) {
6716 if (get_connection_index(codec,
6717 spec->auto_adc_nids[i], nid) >= 0) {
6718 /* mux and volume for adc_nids[i] */
6719 if (!spec->auto_mux_nids[i]) {
6720 spec->auto_mux_nids[i] = nid;
6721 /* 92hd codecs capture volume is in mux */
6722 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
6723 3, 0, HDA_OUTPUT);
6724 }
6725 for (j = 0; j < spec->auto_dmic_cnt; j++) {
6726 if (get_connection_index(codec, nid,
6727 spec->auto_dmic_nids[j]) >= 0) {
6728 /* dmux for adc_nids[i] */
6729 if (!spec->auto_dmux_nids[i])
6730 spec->auto_dmux_nids[i] = nid;
6731 break;
6732 }
6733 }
6734 break;
6735 }
6736 }
6737}
6738
6739static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
6740{
6741 hda_nid_t nid, end_nid;
6742 unsigned int wid_caps, wid_type;
6743 struct sigmatel_spec *spec = codec->spec;
6744
6745 end_nid = codec->start_nid + codec->num_nodes;
6746
6747 for (nid = codec->start_nid; nid < end_nid; nid++) {
6748 wid_caps = get_wcaps(codec, nid);
6749 wid_type = get_wcaps_type(wid_caps);
6750
6751 if (wid_type == AC_WID_PIN)
6752 stac92hd8x_add_pin(codec, nid);
6753
6754 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
6755 stac92hd8x_add_adc(codec, nid);
6756 }
6757
6758 for (nid = codec->start_nid; nid < end_nid; nid++) {
6759 wid_caps = get_wcaps(codec, nid);
6760 wid_type = get_wcaps_type(wid_caps);
6761
6762 if (wid_type == AC_WID_AUD_SEL)
6763 stac92hd8x_add_mux(codec, nid);
6764 }
6765
6766 spec->pin_nids = spec->auto_pin_nids;
6767 spec->num_pins = spec->auto_pin_cnt;
6768 spec->adc_nids = spec->auto_adc_nids;
6769 spec->num_adcs = spec->auto_adc_cnt;
6770 spec->capvols = spec->auto_capvols;
6771 spec->capsws = spec->auto_capvols;
6772 spec->num_caps = spec->auto_adc_cnt;
6773 spec->mux_nids = spec->auto_mux_nids;
6774 spec->num_muxes = spec->auto_adc_cnt;
6775 spec->dmux_nids = spec->auto_dmux_nids;
6776 spec->num_dmuxes = spec->auto_adc_cnt;
6777 spec->dmic_nids = spec->auto_dmic_nids;
6778 spec->num_dmics = spec->auto_dmic_cnt;
6779}
6780
Takashi Iwai372f8c72013-01-14 18:06:34 +01006781static void stac_setup_gpio(struct hda_codec *codec)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006782{
Takashi Iwai372f8c72013-01-14 18:06:34 +01006783 struct sigmatel_spec *spec = codec->spec;
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01006784
Takashi Iwaib4e81872009-11-18 17:20:24 +01006785 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006786 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006787 spec->gpio_mask |= spec->gpio_led;
6788 spec->gpio_dir |= spec->gpio_led;
6789 spec->gpio_data |= spec->gpio_led;
6790 } else {
6791 codec->patch_ops.set_power_state =
6792 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006793 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006794 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006795
Takashi Iwai62cbde12012-09-14 11:58:54 +02006796 if (spec->mic_mute_led_gpio) {
6797 spec->gpio_mask |= spec->mic_mute_led_gpio;
6798 spec->gpio_dir |= spec->mic_mute_led_gpio;
6799 spec->mic_mute_led_on = true;
6800 spec->gpio_data |= spec->mic_mute_led_gpio;
6801 }
Takashi Iwai372f8c72013-01-14 18:06:34 +01006802}
6803
6804static int patch_stac92hd83xxx(struct hda_codec *codec)
6805{
6806 struct sigmatel_spec *spec;
6807 int err;
6808
6809 err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */
6810 if (err < 0)
6811 return err;
6812
6813 codec->epss = 0; /* longer delay needed for D3 */
6814 stac92hd8x_fill_auto_spec(codec);
6815
6816 spec = codec->spec;
6817 spec->linear_tone_beep = 0;
6818 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
6819 spec->digbeep_nid = 0x21;
6820 spec->pwr_nids = stac92hd83xxx_pwr_nids;
6821 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
6822 spec->multiout.dac_nids = spec->dac_nids;
6823
6824 snd_hda_pick_fixup(codec, stac92hd83xxx_models, stac92hd83xxx_fixup_tbl,
6825 stac92hd83xxx_fixups);
6826
6827 snd_hda_add_verbs(codec, stac92hd83xxx_core_init);
6828 spec->default_polarity = -1; /* no default cfg */
6829
6830 codec->patch_ops = stac92xx_patch_ops;
6831
6832 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6833
6834 stac_setup_gpio(codec);
Takashi Iwai62cbde12012-09-14 11:58:54 +02006835
Charles Chin9009b0e2011-11-03 10:27:27 +01006836 err = stac92xx_parse_auto_config(codec);
Takashi Iwai372f8c72013-01-14 18:06:34 +01006837 if (!err)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006838 err = -EINVAL;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006839 if (err < 0) {
6840 stac92xx_free(codec);
6841 return err;
6842 }
6843
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006844 codec->proc_widget_hook = stac92hd_proc_hook;
6845
Takashi Iwai372f8c72013-01-14 18:06:34 +01006846 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6847
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006848 return 0;
6849}
6850
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006851static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
6852 hda_nid_t dig0pin)
6853{
6854 struct sigmatel_spec *spec = codec->spec;
6855 int idx;
6856
6857 for (idx = 0; idx < spec->num_pins; idx++)
6858 if (spec->pin_nids[idx] == dig0pin)
6859 break;
6860 if ((idx + 2) >= spec->num_pins)
6861 return 0;
6862
6863 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006864 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006865 return 2;
6866
6867 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006868 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006869 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01006870 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006871 return 1;
6872 else
6873 return 0;
6874}
6875
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006876/* HP dv7 bass switch - GPIO5 */
6877#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
6878static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
6879 struct snd_ctl_elem_value *ucontrol)
6880{
6881 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6882 struct sigmatel_spec *spec = codec->spec;
6883 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
6884 return 0;
6885}
6886
6887static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
6888 struct snd_ctl_elem_value *ucontrol)
6889{
6890 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6891 struct sigmatel_spec *spec = codec->spec;
6892 unsigned int gpio_data;
6893
6894 gpio_data = (spec->gpio_data & ~0x20) |
6895 (ucontrol->value.integer.value[0] ? 0x20 : 0);
6896 if (gpio_data == spec->gpio_data)
6897 return 0;
6898 spec->gpio_data = gpio_data;
6899 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
6900 return 1;
6901}
6902
Takashi Iwai2b635362011-05-02 12:33:43 +02006903static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6905 .info = stac_hp_bass_gpio_info,
6906 .get = stac_hp_bass_gpio_get,
6907 .put = stac_hp_bass_gpio_put,
6908};
6909
6910static int stac_add_hp_bass_switch(struct hda_codec *codec)
6911{
6912 struct sigmatel_spec *spec = codec->spec;
6913
6914 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
6915 "Bass Speaker Playback Switch", 0))
6916 return -ENOMEM;
6917
6918 spec->gpio_mask |= 0x20;
6919 spec->gpio_dir |= 0x20;
6920 spec->gpio_data |= 0x20;
6921 return 0;
6922}
6923
Matthew Ranostaye035b842007-11-06 11:53:55 +01006924static int patch_stac92hd71bxx(struct hda_codec *codec)
6925{
6926 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02006927 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Takashi Iwai361dab32012-05-09 14:35:27 +02006928 int err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006929
Takashi Iwai361dab32012-05-09 14:35:27 +02006930 err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS,
6931 stac92hd71bxx_pin_nids_4port);
6932 if (err < 0)
6933 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006934
Takashi Iwai361dab32012-05-09 14:35:27 +02006935 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006936 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006937 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006938 switch (codec->vendor_id) {
6939 case 0x111d76b6:
6940 case 0x111d76b7:
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006941 break;
6942 case 0x111d7603:
6943 case 0x111d7608:
6944 /* On 92HD75Bx 0x27 isn't a pin nid */
6945 spec->num_pins--;
6946 /* fallthrough */
6947 default:
6948 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
6949 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006950 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006951
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006952 snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
6953 stac92hd71bxx_fixups);
6954
6955 /* GPIO0 = EAPD */
6956 spec->gpio_mask = 0x01;
6957 spec->gpio_dir = 0x01;
6958 spec->gpio_data = 0x01;
Takashi Iwai41c3b642008-11-18 10:45:15 +01006959
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006960 spec->dmic_nids = stac92hd71bxx_dmic_nids;
6961 spec->dmux_nids = stac92hd71bxx_dmux_nids;
6962
Takashi Iwai6479c632009-07-28 18:20:25 +02006963 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
6964 spec->capvols = stac92hd71bxx_capvols;
6965 spec->capsws = stac92hd71bxx_capsws;
6966
Matthew Ranostay541eee82007-12-14 12:08:04 +01006967 switch (codec->vendor_id) {
6968 case 0x111d76b6: /* 4 Port without Analog Mixer */
6969 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02006970 unmute_init++;
6971 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006972 case 0x111d76b4: /* 6 Port without Analog Mixer */
6973 case 0x111d76b5:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006974 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006975 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006976 stac92hd71bxx_dmic_nids,
6977 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01006978 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006979 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006980 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006981 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006982 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006983
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006984 /* disable VSW */
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006985 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01006986 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
6987 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02006988 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006989 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006990 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006991 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006992 break;
6993 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006994 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006995 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006996
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006997 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006998 default:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006999 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007000 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05007001 stac92hd71bxx_dmic_nids,
7002 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02007003 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01007004 }
7005
David Henningsson5e68fb32012-08-16 14:11:09 +02007006 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007007 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
David Henningsson5e68fb32012-08-16 14:11:09 +02007008
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05007009 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
7010 snd_hda_sequence_write_cache(codec, unmute_init);
7011
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007012 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04007013 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01007014 spec->aloopback_shift = 0;
7015
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02007016 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007017 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007018 spec->mux_nids = stac92hd71bxx_mux_nids;
7019 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02007020 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007021 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007022
7023 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
7024 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02007025 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05007026 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01007027
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007028 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01007029
Takashi Iwai372f8c72013-01-14 18:06:34 +01007030 stac_setup_gpio(codec);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04007031
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01007032 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007033
Charles Chin9009b0e2011-11-03 10:27:27 +01007034 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007035 if (!err)
Matthew Ranostaye035b842007-11-06 11:53:55 +01007036 err = -EINVAL;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007037 if (err < 0) {
7038 stac92xx_free(codec);
7039 return err;
7040 }
7041
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007042 codec->proc_widget_hook = stac92hd7x_proc_hook;
7043
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007044 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7045
Matthew Ranostaye035b842007-11-06 11:53:55 +01007046 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02007047}
Matthew Ranostaye035b842007-11-06 11:53:55 +01007048
Matt2f2f4252005-04-13 14:45:30 +02007049static int patch_stac922x(struct hda_codec *codec)
7050{
7051 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02007052 int err;
Matt2f2f4252005-04-13 14:45:30 +02007053
Takashi Iwai361dab32012-05-09 14:35:27 +02007054 err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids),
7055 stac922x_pin_nids);
7056 if (err < 0)
7057 return err;
Matt2f2f4252005-04-13 14:45:30 +02007058
Takashi Iwai361dab32012-05-09 14:35:27 +02007059 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007060 spec->linear_tone_beep = 1;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02007061
Takashi Iwai0a427842013-01-14 15:20:13 +01007062 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
7063 stac922x_fixups);
Matt2f2f4252005-04-13 14:45:30 +02007064
Matt2f2f4252005-04-13 14:45:30 +02007065 spec->adc_nids = stac922x_adc_nids;
7066 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007067 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007068 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007069 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007070 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02007071
Takashi Iwai6479c632009-07-28 18:20:25 +02007072 spec->num_caps = STAC922X_NUM_CAPS;
7073 spec->capvols = stac922x_capvols;
7074 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02007075
7076 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02007077
Takashi Iwai0a427842013-01-14 15:20:13 +01007078 snd_hda_add_verbs(codec, stac922x_core_init);
7079
7080 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7081
Charles Chin9009b0e2011-11-03 10:27:27 +01007082 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0a427842013-01-14 15:20:13 +01007083 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007084 err = -EINVAL;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007085 if (err < 0) {
7086 stac92xx_free(codec);
7087 return err;
7088 }
7089
7090 codec->patch_ops = stac92xx_patch_ops;
7091
Takashi Iwai807a46362007-05-29 19:01:37 +02007092 /* Fix Mux capture level; max to 2 */
7093 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
7094 (0 << AC_AMPCAP_OFFSET_SHIFT) |
7095 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
7096 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
7097 (0 << AC_AMPCAP_MUTE_SHIFT));
7098
Takashi Iwai0a427842013-01-14 15:20:13 +01007099 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7100
Matt Porter3cc08dc2006-01-23 15:27:49 +01007101 return 0;
7102}
7103
7104static int patch_stac927x(struct hda_codec *codec)
7105{
7106 struct sigmatel_spec *spec;
7107 int err;
7108
Takashi Iwai361dab32012-05-09 14:35:27 +02007109 err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids),
7110 stac927x_pin_nids);
7111 if (err < 0)
7112 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007113
Takashi Iwai361dab32012-05-09 14:35:27 +02007114 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007115 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05007116 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwai29ac8362013-01-14 16:03:38 +01007117
7118 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
7119 stac927x_fixups);
Matt Porter3cc08dc2006-01-23 15:27:49 +01007120
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007121 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007122 spec->adc_nids = stac927x_adc_nids;
7123 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
7124 spec->mux_nids = stac927x_mux_nids;
7125 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007126 spec->smux_nids = stac927x_smux_nids;
7127 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04007128 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01007129 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007130 spec->multiout.dac_nids = spec->dac_nids;
7131
Takashi Iwai29ac8362013-01-14 16:03:38 +01007132 /* GPIO0 High = Enable EAPD */
7133 spec->eapd_mask = spec->gpio_mask = 0x01;
7134 spec->gpio_dir = spec->gpio_data = 0x01;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02007135
Takashi Iwai29ac8362013-01-14 16:03:38 +01007136 spec->num_dmics = 0;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007137
Takashi Iwai6479c632009-07-28 18:20:25 +02007138 spec->num_caps = STAC927X_NUM_CAPS;
7139 spec->capvols = stac927x_capvols;
7140 spec->capsws = stac927x_capsws;
7141
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007142 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007143 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007144 spec->aloopback_mask = 0x40;
7145 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05007146 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007147
Takashi Iwai29ac8362013-01-14 16:03:38 +01007148 if (!spec->volknob_init)
7149 snd_hda_add_verbs(codec, stac927x_core_init);
7150
7151 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7152
Charles Chin9009b0e2011-11-03 10:27:27 +01007153 err = stac92xx_parse_auto_config(codec);
Takashi Iwai29ac8362013-01-14 16:03:38 +01007154 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007155 err = -EINVAL;
Mattc7d4b2f2005-06-27 14:59:41 +02007156 if (err < 0) {
7157 stac92xx_free(codec);
7158 return err;
7159 }
Matt2f2f4252005-04-13 14:45:30 +02007160
7161 codec->patch_ops = stac92xx_patch_ops;
7162
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007163 codec->proc_widget_hook = stac927x_proc_hook;
7164
Takashi Iwai52987652008-01-16 16:09:47 +01007165 /*
7166 * !!FIXME!!
7167 * The STAC927x seem to require fairly long delays for certain
7168 * command sequences. With too short delays (even if the answer
7169 * is set to RIRB properly), it results in the silence output
7170 * on some hardwares like Dell.
7171 *
7172 * The below flag enables the longer delay (see get_response
7173 * in hda_intel.c).
7174 */
7175 codec->bus->needs_damn_long_delay = 1;
7176
Takashi Iwai29ac8362013-01-14 16:03:38 +01007177 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwaie28d8322008-12-17 13:48:29 +01007178
Matt2f2f4252005-04-13 14:45:30 +02007179 return 0;
7180}
7181
Matt Porterf3302a52006-07-31 12:49:34 +02007182static int patch_stac9205(struct hda_codec *codec)
7183{
7184 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02007185 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02007186
Takashi Iwai361dab32012-05-09 14:35:27 +02007187 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids),
7188 stac9205_pin_nids);
7189 if (err < 0)
7190 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02007191
Takashi Iwai361dab32012-05-09 14:35:27 +02007192 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007193 spec->linear_tone_beep = 1;
Takashi Iwaife6322c2013-01-14 14:46:51 +01007194
7195 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
7196 stac9205_fixups);
Matt Porterf3302a52006-07-31 12:49:34 +02007197
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007198 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02007199 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007200 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02007201 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007202 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007203 spec->smux_nids = stac9205_smux_nids;
7204 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007205 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02007206 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007207 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01007208 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007209 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007210
Takashi Iwaife6322c2013-01-14 14:46:51 +01007211 snd_hda_add_verbs(codec, stac9205_core_init);
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007212 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02007213
Takashi Iwai6479c632009-07-28 18:20:25 +02007214 spec->num_caps = STAC9205_NUM_CAPS;
7215 spec->capvols = stac9205_capvols;
7216 spec->capsws = stac9205_capsws;
7217
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007218 spec->aloopback_mask = 0x40;
7219 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007220 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02007221
Takashi Iwaife6322c2013-01-14 14:46:51 +01007222 /* GPIO0 High = EAPD */
7223 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
7224 spec->gpio_data = 0x01;
Matt Porter33382402006-12-18 13:17:28 +01007225
Takashi Iwaife6322c2013-01-14 14:46:51 +01007226 /* Turn on/off EAPD per HP plugging */
7227 spec->eapd_switch = 1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01007228
Takashi Iwaife6322c2013-01-14 14:46:51 +01007229 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Matthew Ranostay87d48362007-07-17 11:52:24 +02007230
Charles Chin9009b0e2011-11-03 10:27:27 +01007231 err = stac92xx_parse_auto_config(codec);
Takashi Iwaife6322c2013-01-14 14:46:51 +01007232 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007233 err = -EINVAL;
Matt Porterf3302a52006-07-31 12:49:34 +02007234 if (err < 0) {
7235 stac92xx_free(codec);
7236 return err;
7237 }
7238
7239 codec->patch_ops = stac92xx_patch_ops;
7240
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007241 codec->proc_widget_hook = stac9205_proc_hook;
7242
Takashi Iwaife6322c2013-01-14 14:46:51 +01007243 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7244
Matt Porterf3302a52006-07-31 12:49:34 +02007245 return 0;
7246}
7247
Matt2f2f4252005-04-13 14:45:30 +02007248/*
Guillaume Munch6d859062006-08-22 17:15:47 +02007249 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01007250 */
7251
Takashi Iwai2b635362011-05-02 12:33:43 +02007252static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02007253 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01007254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
7255 {}
7256};
7257
Takashi Iwai2b635362011-05-02 12:33:43 +02007258static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007259 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
7260 0x11, 0x13, 0x14,
7261};
7262
Takashi Iwai2b635362011-05-02 12:33:43 +02007263static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007264 0x8 /*,0x6*/
7265};
7266
Takashi Iwai2b635362011-05-02 12:33:43 +02007267static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007268 0x15
7269};
7270
Takashi Iwai2b635362011-05-02 12:33:43 +02007271static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02007272 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7273};
7274#define stac9872_capsws stac9872_capvols
7275
Takashi Iwaifc268c12013-01-14 14:29:36 +01007276static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
7277 { 0x0a, 0x03211020 },
7278 { 0x0b, 0x411111f0 },
7279 { 0x0c, 0x411111f0 },
7280 { 0x0d, 0x03a15030 },
7281 { 0x0e, 0x411111f0 },
7282 { 0x0f, 0x90170110 },
7283 { 0x11, 0x411111f0 },
7284 { 0x13, 0x411111f0 },
7285 { 0x14, 0x90a7013e },
7286 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007287};
7288
Takashi Iwaifc268c12013-01-14 14:29:36 +01007289static const struct hda_model_fixup stac9872_models[] = {
7290 { .id = STAC_9872_VAIO, .name = "vaio" },
7291 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007292};
7293
Takashi Iwaifc268c12013-01-14 14:29:36 +01007294static const struct hda_fixup stac9872_fixups[] = {
7295 [STAC_9872_VAIO] = {
7296 .type = HDA_FIXUP_PINS,
7297 .v.pins = stac9872_vaio_pin_configs,
7298 },
Takashi Iwai307282c2009-03-12 18:17:58 +01007299};
7300
Takashi Iwaifc268c12013-01-14 14:29:36 +01007301static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02007302 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
7303 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01007304 {} /* terminator */
7305};
7306
Guillaume Munch6d859062006-08-22 17:15:47 +02007307static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01007308{
7309 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01007310 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01007311
Takashi Iwai361dab32012-05-09 14:35:27 +02007312 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids),
7313 stac9872_pin_nids);
7314 if (err < 0)
7315 return err;
7316
7317 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007318 spec->linear_tone_beep = 1;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007319
Takashi Iwaifc268c12013-01-14 14:29:36 +01007320 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
7321 stac9872_fixups);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007322
Takashi Iwai1e137f92009-01-21 07:41:22 +01007323 spec->multiout.dac_nids = spec->dac_nids;
7324 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
7325 spec->adc_nids = stac9872_adc_nids;
7326 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
7327 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02007328 spec->num_caps = 1;
7329 spec->capvols = stac9872_capvols;
7330 spec->capsws = stac9872_capsws;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007331 snd_hda_add_verbs(codec, stac9872_core_init);
7332
7333 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007334
Charles Chin9009b0e2011-11-03 10:27:27 +01007335 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01007336 if (err < 0) {
7337 stac92xx_free(codec);
7338 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007339 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01007340 spec->input_mux = &spec->private_imux;
7341 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007342
7343 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7344
Takashi Iwaidb064e52006-03-16 16:04:58 +01007345 return 0;
7346}
7347
7348
7349/*
Matt2f2f4252005-04-13 14:45:30 +02007350 * patch entries
7351 */
Takashi Iwai2b635362011-05-02 12:33:43 +02007352static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02007353 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
7354 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
7355 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
7356 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
7357 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
7358 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
7359 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02007360 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
7361 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
7362 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
7363 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
7364 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
7365 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01007366 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
7367 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
7368 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
7369 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
7370 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
7371 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
7372 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
7373 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
7374 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
7375 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01007376 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
7377 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
7378 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
7379 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
7380 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
7381 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02007382 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
7383 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02007384 /* The following does not take into account .id=0x83847661 when subsys =
7385 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
7386 * currently not fully supported.
7387 */
7388 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
7389 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
7390 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01007391 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02007392 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
7393 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
7394 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
7395 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
7396 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
7397 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
7398 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
7399 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007400 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007401 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01007402 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007403 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04007404 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02007405 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
7406 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01007407 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
7408 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
7409 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
7410 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007411 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01007412 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
7413 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007414 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01007415 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7416 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7417 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7418 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7419 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7420 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7421 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7422 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02007423 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
7424 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
7425 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
7426 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
7427 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
7428 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
7429 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
7430 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
7431 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
7432 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
7433 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
7434 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
7435 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
7436 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
7437 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02007438 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007439 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06007440 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
7441 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007442 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01007443 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
7444 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
7445 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
7446 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
7447 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
7448 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
7449 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
7450 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
7451 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
7452 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
7453 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
7454 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02007455 {} /* terminator */
7456};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01007457
7458MODULE_ALIAS("snd-hda-codec-id:8384*");
7459MODULE_ALIAS("snd-hda-codec-id:111d*");
7460
7461MODULE_LICENSE("GPL");
7462MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
7463
7464static struct hda_codec_preset_list sigmatel_list = {
7465 .preset = snd_hda_preset_sigmatel,
7466 .owner = THIS_MODULE,
7467};
7468
7469static int __init patch_sigmatel_init(void)
7470{
7471 return snd_hda_add_codec_preset(&sigmatel_list);
7472}
7473
7474static void __exit patch_sigmatel_exit(void)
7475{
7476 snd_hda_delete_codec_preset(&sigmatel_list);
7477}
7478
7479module_init(patch_sigmatel_init)
7480module_exit(patch_sigmatel_exit)