blob: fa16ff79866c72b85eed2a7145325c61532c9fbf [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 Iwai372f8c72013-01-14 18:06:34 +01002346 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02002347 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002348};
2349
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002350static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2351 { 0x0a, 0x02214030 },
2352 { 0x0b, 0x02a19040 },
2353 { 0x0c, 0x01a19020 },
2354 { 0x0d, 0x01014010 },
2355 { 0x0e, 0x0181302e },
2356 { 0x0f, 0x01014010 },
2357 { 0x14, 0x01019020 },
2358 { 0x18, 0x90a000f0 },
2359 { 0x19, 0x90a000f0 },
2360 { 0x1e, 0x01452050 },
2361 { 0x1f, 0x01452050 },
2362 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002363};
2364
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002365static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2366 { 0x0a, 0x0421101f },
2367 { 0x0b, 0x04a11221 },
2368 { 0x0c, 0x40f000f0 },
2369 { 0x0d, 0x90170110 },
2370 { 0x0e, 0x23a1902e },
2371 { 0x0f, 0x23014250 },
2372 { 0x14, 0x40f000f0 },
2373 { 0x18, 0x90a000f0 },
2374 { 0x19, 0x40f000f0 },
2375 { 0x1e, 0x4f0000f0 },
2376 { 0x1f, 0x4f0000f0 },
2377 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002378};
2379
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002380static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2381 { 0x0a, 0x0421101f },
2382 { 0x0b, 0x04a11221 },
2383 { 0x0c, 0x90a70330 },
2384 { 0x0d, 0x90170110 },
2385 { 0x0e, 0x23a1902e },
2386 { 0x0f, 0x23014250 },
2387 { 0x14, 0x40f000f0 },
2388 { 0x18, 0x40f000f0 },
2389 { 0x19, 0x40f000f0 },
2390 { 0x1e, 0x044413b0 },
2391 { 0x1f, 0x044413b0 },
2392 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002393};
2394
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002395static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2396 { 0x0a, 0x0421101f },
2397 { 0x0b, 0x04a11221 },
2398 { 0x0c, 0x90a70330 },
2399 { 0x0d, 0x90170110 },
2400 { 0x0e, 0x40f000f0 },
2401 { 0x0f, 0x40f000f0 },
2402 { 0x14, 0x40f000f0 },
2403 { 0x18, 0x90a000f0 },
2404 { 0x19, 0x40f000f0 },
2405 { 0x1e, 0x044413b0 },
2406 { 0x1f, 0x044413b0 },
2407 {}
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002408};
2409
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002410static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2411 const struct hda_fixup *fix, int action)
2412{
2413 struct sigmatel_spec *spec = codec->spec;
2414
2415 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2416 return;
2417
2418 snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2419 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2420}
2421
2422static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec,
2423 const struct hda_fixup *fix, int action)
2424{
2425 struct sigmatel_spec *spec = codec->spec;
2426
2427 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2428 return;
2429 spec->num_dmics = 0;
2430 spec->num_smuxes = 0;
2431 spec->num_dmuxes = 0;
2432}
2433
2434static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec,
2435 const struct hda_fixup *fix, int action)
2436{
2437 struct sigmatel_spec *spec = codec->spec;
2438
2439 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2440 return;
2441 spec->num_dmics = 1;
2442 spec->num_smuxes = 0;
2443 spec->num_dmuxes = 1;
2444}
2445
2446static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2447 const struct hda_fixup *fix, int action)
2448{
2449 struct sigmatel_spec *spec = codec->spec;
2450
2451 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2452 return;
2453
2454 /* Enable VREF power saving on GPIO1 detect */
2455 stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02);
2456 snd_hda_codec_write_cache(codec, codec->afg, 0,
2457 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
2458 snd_hda_jack_detect_enable(codec, codec->afg, 0);
2459 spec->gpio_mask |= 0x02;
2460
2461 /* enable internal microphone */
2462 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2463 stac92xx_auto_set_pinctl(codec, 0x0e,
2464 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2465
2466 stac92hd71bxx_fixup_no_dmic(codec, fix, action);
2467}
2468
2469static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec,
2470 const struct hda_fixup *fix, int action)
2471{
2472 struct sigmatel_spec *spec = codec->spec;
2473
2474 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2475 return;
2476 spec->num_dmics = 1;
2477 /* I don't know if it needs 1 or 2 smuxes - will wait for
2478 * bug reports to fix if needed
2479 */
2480 spec->num_smuxes = 1;
2481 spec->num_dmuxes = 1;
2482}
2483
2484static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2485 const struct hda_fixup *fix, int action)
2486{
2487 struct sigmatel_spec *spec = codec->spec;
2488
2489 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2490 return;
2491 spec->gpio_led = 0x01;
2492}
2493
2494static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2495 const struct hda_fixup *fix, int action)
2496{
2497 struct sigmatel_spec *spec = codec->spec;
2498 unsigned int cap;
2499
2500 switch (action) {
2501 case HDA_FIXUP_ACT_PRE_PROBE:
2502 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2503 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
2504 /* HP dv6 gives the headphone pin as a line-out. Thus we
2505 * need to set hp_detect flag here to force to enable HP
2506 * detection.
2507 */
2508 spec->hp_detect = 1;
2509 break;
2510
2511 case HDA_FIXUP_ACT_PROBE:
2512 /* enable bass on HP dv7 */
2513 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2514 cap &= AC_GPIO_IO_COUNT;
2515 if (cap >= 6)
2516 stac_add_hp_bass_switch(codec);
2517 break;
2518 }
2519}
2520
2521static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
2522 const struct hda_fixup *fix, int action)
2523{
2524 struct sigmatel_spec *spec = codec->spec;
2525
2526 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2527 return;
2528 spec->gpio_led = 0x08;
2529 spec->num_dmics = 1;
2530 spec->num_smuxes = 1;
2531 spec->num_dmuxes = 1;
2532}
2533
2534
2535static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
2536 const struct hda_fixup *fix, int action)
2537{
2538 struct sigmatel_spec *spec = codec->spec;
2539
2540 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2541 return;
2542
2543 if (hp_blike_system(codec->subsystem_id)) {
2544 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
2545 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
2546 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
2547 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
2548 /* It was changed in the BIOS to just satisfy MS DTM.
2549 * Lets turn it back into slaved HP
2550 */
2551 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
2552 | (AC_JACK_HP_OUT <<
2553 AC_DEFCFG_DEVICE_SHIFT);
2554 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
2555 | AC_DEFCFG_SEQUENCE)))
2556 | 0x1f;
2557 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
2558 }
2559 }
2560
2561 if (find_mute_led_cfg(codec, 1))
2562 snd_printd("mute LED gpio %d polarity %d\n",
2563 spec->gpio_led,
2564 spec->gpio_led_polarity);
2565
2566}
2567
2568static const struct hda_fixup stac92hd71bxx_fixups[] = {
2569 [STAC_92HD71BXX_REF] = {
2570 .type = HDA_FIXUP_FUNC,
2571 .v.func = stac92hd71bxx_fixup_ref,
2572 },
2573 [STAC_DELL_M4_1] = {
2574 .type = HDA_FIXUP_PINS,
2575 .v.pins = dell_m4_1_pin_configs,
2576 .chained = true,
2577 .chain_id = STAC_92HD71BXX_NO_SMUX,
2578 },
2579 [STAC_DELL_M4_2] = {
2580 .type = HDA_FIXUP_PINS,
2581 .v.pins = dell_m4_2_pin_configs,
2582 .chained = true,
2583 .chain_id = STAC_92HD71BXX_NO_DMIC,
2584 },
2585 [STAC_DELL_M4_3] = {
2586 .type = HDA_FIXUP_PINS,
2587 .v.pins = dell_m4_3_pin_configs,
2588 .chained = true,
2589 .chain_id = STAC_92HD71BXX_NO_SMUX,
2590 },
2591 [STAC_HP_M4] = {
2592 .type = HDA_FIXUP_FUNC,
2593 .v.func = stac92hd71bxx_fixup_hp_m4,
2594 .chained = true,
2595 .chain_id = STAC_92HD71BXX_HP,
2596 },
2597 [STAC_HP_DV4] = {
2598 .type = HDA_FIXUP_FUNC,
2599 .v.func = stac92hd71bxx_fixup_hp_dv4,
2600 .chained = true,
2601 .chain_id = STAC_HP_DV5,
2602 },
2603 [STAC_HP_DV5] = {
2604 .type = HDA_FIXUP_FUNC,
2605 .v.func = stac92hd71bxx_fixup_hp_dv5,
2606 .chained = true,
2607 .chain_id = STAC_92HD71BXX_HP,
2608 },
2609 [STAC_HP_HDX] = {
2610 .type = HDA_FIXUP_FUNC,
2611 .v.func = stac92hd71bxx_fixup_hp_hdx,
2612 .chained = true,
2613 .chain_id = STAC_92HD71BXX_HP,
2614 },
2615 [STAC_HP_DV4_1222NR] = {
2616 .type = HDA_FIXUP_FUNC,
2617 .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr,
2618 .chained = true,
2619 .chain_id = STAC_HP_DV4,
2620 },
2621 [STAC_92HD71BXX_NO_DMIC] = {
2622 .type = HDA_FIXUP_FUNC,
2623 .v.func = stac92hd71bxx_fixup_no_dmic,
2624 },
2625 [STAC_92HD71BXX_NO_SMUX] = {
2626 .type = HDA_FIXUP_FUNC,
2627 .v.func = stac92hd71bxx_fixup_no_smux,
2628 },
2629 [STAC_92HD71BXX_HP] = {
2630 .type = HDA_FIXUP_FUNC,
2631 .v.func = stac92hd71bxx_fixup_hp,
2632 },
Matthew Ranostaye035b842007-11-06 11:53:55 +01002633};
2634
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002635static const struct hda_model_fixup stac92hd71bxx_models[] = {
2636 { .id = STAC_92HD71BXX_REF, .name = "ref" },
2637 { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
2638 { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
2639 { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
2640 { .id = STAC_HP_M4, .name = "hp-m4" },
2641 { .id = STAC_HP_DV4, .name = "hp-dv4" },
2642 { .id = STAC_HP_DV5, .name = "hp-dv5" },
2643 { .id = STAC_HP_HDX, .name = "hp-hdx" },
2644 { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" },
2645 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002646};
2647
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002648static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002649 /* SigmaTel reference board */
2650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2651 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002652 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2653 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04002654 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
2655 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01002656 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2657 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01002658 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2659 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002660 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002661 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002662 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2663 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002664 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2665 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04002666 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002667 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002668 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002669 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02002670 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2671 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05302672 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2673 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11002674 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2675 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02002676 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2677 "HP", STAC_HP_DV5),
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002678 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2680 "unknown Dell", STAC_DELL_M4_1),
2681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2682 "unknown Dell", STAC_DELL_M4_1),
2683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2684 "unknown Dell", STAC_DELL_M4_1),
2685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2686 "unknown Dell", STAC_DELL_M4_1),
2687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2688 "unknown Dell", STAC_DELL_M4_1),
2689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2690 "unknown Dell", STAC_DELL_M4_1),
2691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2692 "unknown Dell", STAC_DELL_M4_1),
2693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2694 "unknown Dell", STAC_DELL_M4_2),
2695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2696 "unknown Dell", STAC_DELL_M4_2),
2697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2698 "unknown Dell", STAC_DELL_M4_2),
2699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2700 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2702 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002703 {} /* terminator */
2704};
2705
Takashi Iwai0a427842013-01-14 15:20:13 +01002706static const struct hda_pintbl ref922x_pin_configs[] = {
2707 { 0x0a, 0x01014010 },
2708 { 0x0b, 0x01016011 },
2709 { 0x0c, 0x01012012 },
2710 { 0x0d, 0x0221401f },
2711 { 0x0e, 0x01813122 },
2712 { 0x0f, 0x01011014 },
2713 { 0x10, 0x01441030 },
2714 { 0x11, 0x01c41030 },
2715 { 0x15, 0x40000100 },
2716 { 0x1b, 0x40000100 },
2717 {}
Matt2f2f4252005-04-13 14:45:30 +02002718};
2719
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002720/*
2721 STAC 922X pin configs for
2722 102801A7
2723 102801AB
2724 102801A9
2725 102801D1
2726 102801D2
2727*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002728static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2729 { 0x0a, 0x02214030 },
2730 { 0x0b, 0x01a19021 },
2731 { 0x0c, 0x01111012 },
2732 { 0x0d, 0x01114010 },
2733 { 0x0e, 0x02a19020 },
2734 { 0x0f, 0x01117011 },
2735 { 0x10, 0x400001f0 },
2736 { 0x11, 0x400001f1 },
2737 { 0x15, 0x01813122 },
2738 { 0x1b, 0x400001f2 },
2739 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002740};
2741
2742/*
2743 STAC 922X pin configs for
2744 102801AC
2745 102801D0
2746*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002747static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2748 { 0x0a, 0x02214030 },
2749 { 0x0b, 0x01a19021 },
2750 { 0x0c, 0x01111012 },
2751 { 0x0d, 0x01114010 },
2752 { 0x0e, 0x02a19020 },
2753 { 0x0f, 0x01117011 },
2754 { 0x10, 0x01451140 },
2755 { 0x11, 0x400001f0 },
2756 { 0x15, 0x01813122 },
2757 { 0x1b, 0x400001f1 },
2758 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002759};
2760
2761/*
2762 STAC 922X pin configs for
2763 102801BF
2764*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002765static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2766 { 0x0a, 0x0321101f },
2767 { 0x0b, 0x01112024 },
2768 { 0x0c, 0x01111222 },
2769 { 0x0d, 0x91174220 },
2770 { 0x0e, 0x03a11050 },
2771 { 0x0f, 0x01116221 },
2772 { 0x10, 0x90a70330 },
2773 { 0x11, 0x01452340 },
2774 { 0x15, 0x40C003f1 },
2775 { 0x1b, 0x405003f0 },
2776 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002777};
2778
2779/*
2780 STAC 9221 A1 pin configs for
2781 102801D7 (Dell XPS M1210)
2782*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002783static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2784 { 0x0a, 0x02211211 },
2785 { 0x0b, 0x408103ff },
2786 { 0x0c, 0x02a1123e },
2787 { 0x0d, 0x90100310 },
2788 { 0x0e, 0x408003f1 },
2789 { 0x0f, 0x0221121f },
2790 { 0x10, 0x03451340 },
2791 { 0x11, 0x40c003f2 },
2792 { 0x15, 0x508003f3 },
2793 { 0x1b, 0x405003f4 },
2794 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002795};
2796
Takashi Iwai0a427842013-01-14 15:20:13 +01002797static const struct hda_pintbl d945gtp3_pin_configs[] = {
2798 { 0x0a, 0x0221401f },
2799 { 0x0b, 0x01a19022 },
2800 { 0x0c, 0x01813021 },
2801 { 0x0d, 0x01014010 },
2802 { 0x0e, 0x40000100 },
2803 { 0x0f, 0x40000100 },
2804 { 0x10, 0x40000100 },
2805 { 0x11, 0x40000100 },
2806 { 0x15, 0x02a19120 },
2807 { 0x1b, 0x40000100 },
2808 {}
Matt Porter403d1942005-11-29 15:00:51 +01002809};
2810
Takashi Iwai0a427842013-01-14 15:20:13 +01002811static const struct hda_pintbl d945gtp5_pin_configs[] = {
2812 { 0x0a, 0x0221401f },
2813 { 0x0b, 0x01011012 },
2814 { 0x0c, 0x01813024 },
2815 { 0x0d, 0x01014010 },
2816 { 0x0e, 0x01a19021 },
2817 { 0x0f, 0x01016011 },
2818 { 0x10, 0x01452130 },
2819 { 0x11, 0x40000100 },
2820 { 0x15, 0x02a19320 },
2821 { 0x1b, 0x40000100 },
2822 {}
Matt Porter403d1942005-11-29 15:00:51 +01002823};
2824
Takashi Iwai0a427842013-01-14 15:20:13 +01002825static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2826 { 0x0a, 0x0121e21f },
2827 { 0x0b, 0x400000ff },
2828 { 0x0c, 0x9017e110 },
2829 { 0x0d, 0x400000fd },
2830 { 0x0e, 0x400000fe },
2831 { 0x0f, 0x0181e020 },
2832 { 0x10, 0x1145e030 },
2833 { 0x11, 0x11c5e240 },
2834 { 0x15, 0x400000fc },
2835 { 0x1b, 0x400000fb },
2836 {}
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002837};
2838
Takashi Iwai0a427842013-01-14 15:20:13 +01002839static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2840 { 0x0a, 0x0121e21f },
2841 { 0x0b, 0x90a7012e },
2842 { 0x0c, 0x9017e110 },
2843 { 0x0d, 0x400000fd },
2844 { 0x0e, 0x400000fe },
2845 { 0x0f, 0x0181e020 },
2846 { 0x10, 0x1145e230 },
2847 { 0x11, 0x500000fa },
2848 { 0x15, 0x400000fc },
2849 { 0x1b, 0x400000fb },
2850 {}
Sylvain FORETf16928f2007-04-27 14:22:36 +02002851};
2852
Takashi Iwai0a427842013-01-14 15:20:13 +01002853static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2854 { 0x0a, 0x0121e21f },
2855 { 0x0b, 0x90a7012e },
2856 { 0x0c, 0x9017e110 },
2857 { 0x0d, 0x400000fd },
2858 { 0x0e, 0x400000fe },
2859 { 0x0f, 0x0181e020 },
2860 { 0x10, 0x1145e230 },
2861 { 0x11, 0x11c5e240 },
2862 { 0x15, 0x400000fc },
2863 { 0x1b, 0x400000fb },
2864 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002865};
2866
Takashi Iwai0a427842013-01-14 15:20:13 +01002867static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2868 { 0x0a, 0x0321e21f },
2869 { 0x0b, 0x03a1e02e },
2870 { 0x0c, 0x9017e110 },
2871 { 0x0d, 0x9017e11f },
2872 { 0x0e, 0x400000fe },
2873 { 0x0f, 0x0381e020 },
2874 { 0x10, 0x1345e230 },
2875 { 0x11, 0x13c5e240 },
2876 { 0x15, 0x400000fc },
2877 { 0x1b, 0x400000fb },
2878 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002879};
2880
Takashi Iwai0a427842013-01-14 15:20:13 +01002881static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2882 { 0x0a, 0x0321e21f },
2883 { 0x0b, 0x03a1e02e },
2884 { 0x0c, 0x9017e110 },
2885 { 0x0d, 0x9017e11f },
2886 { 0x0e, 0x400000fe },
2887 { 0x0f, 0x0381e020 },
2888 { 0x10, 0x1345e230 },
2889 { 0x11, 0x13c5e240 },
2890 { 0x15, 0x400000fc },
2891 { 0x1b, 0x400000fb },
2892 {}
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002893};
2894
Takashi Iwai0a427842013-01-14 15:20:13 +01002895static const struct hda_pintbl ecs202_pin_configs[] = {
2896 { 0x0a, 0x0221401f },
2897 { 0x0b, 0x02a19020 },
2898 { 0x0c, 0x01a19020 },
2899 { 0x0d, 0x01114010 },
2900 { 0x0e, 0x408000f0 },
2901 { 0x0f, 0x01813022 },
2902 { 0x10, 0x074510a0 },
2903 { 0x11, 0x40c400f1 },
2904 { 0x15, 0x9037012e },
2905 { 0x1b, 0x40e000f2 },
2906 {}
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002907};
Takashi Iwai76c08822007-06-19 12:17:42 +02002908
Takashi Iwai0a427842013-01-14 15:20:13 +01002909/* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2910static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2911 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2912 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2913 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2914 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2915 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2916 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2917 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2918 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2919 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2920 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2921 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2922 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2923 {}
2924};
2925
2926static const struct hda_fixup stac922x_fixups[];
2927
2928/* remap the fixup from codec SSID and apply it */
2929static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2930 const struct hda_fixup *fix,
2931 int action)
2932{
2933 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2934 return;
2935 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2936 stac922x_fixups);
2937 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2938 snd_hda_apply_fixup(codec, action);
2939}
2940
2941static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2942 const struct hda_fixup *fix,
2943 int action)
2944{
2945 struct sigmatel_spec *spec = codec->spec;
2946
2947 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2948 spec->gpio_mask = spec->gpio_dir = 0x03;
2949 spec->gpio_data = 0x03;
2950 }
2951}
2952
2953static const struct hda_fixup stac922x_fixups[] = {
2954 [STAC_D945_REF] = {
2955 .type = HDA_FIXUP_PINS,
2956 .v.pins = ref922x_pin_configs,
2957 },
2958 [STAC_D945GTP3] = {
2959 .type = HDA_FIXUP_PINS,
2960 .v.pins = d945gtp3_pin_configs,
2961 },
2962 [STAC_D945GTP5] = {
2963 .type = HDA_FIXUP_PINS,
2964 .v.pins = d945gtp5_pin_configs,
2965 },
2966 [STAC_INTEL_MAC_AUTO] = {
2967 .type = HDA_FIXUP_FUNC,
2968 .v.func = stac922x_fixup_intel_mac_auto,
2969 },
2970 [STAC_INTEL_MAC_V1] = {
2971 .type = HDA_FIXUP_PINS,
2972 .v.pins = intel_mac_v1_pin_configs,
2973 .chained = true,
2974 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2975 },
2976 [STAC_INTEL_MAC_V2] = {
2977 .type = HDA_FIXUP_PINS,
2978 .v.pins = intel_mac_v2_pin_configs,
2979 .chained = true,
2980 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2981 },
2982 [STAC_INTEL_MAC_V3] = {
2983 .type = HDA_FIXUP_PINS,
2984 .v.pins = intel_mac_v3_pin_configs,
2985 .chained = true,
2986 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2987 },
2988 [STAC_INTEL_MAC_V4] = {
2989 .type = HDA_FIXUP_PINS,
2990 .v.pins = intel_mac_v4_pin_configs,
2991 .chained = true,
2992 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2993 },
2994 [STAC_INTEL_MAC_V5] = {
2995 .type = HDA_FIXUP_PINS,
2996 .v.pins = intel_mac_v5_pin_configs,
2997 .chained = true,
2998 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2999 },
3000 [STAC_922X_INTEL_MAC_GPIO] = {
3001 .type = HDA_FIXUP_FUNC,
3002 .v.func = stac922x_fixup_intel_mac_gpio,
3003 },
3004 [STAC_ECS_202] = {
3005 .type = HDA_FIXUP_PINS,
3006 .v.pins = ecs202_pin_configs,
3007 },
3008 [STAC_922X_DELL_D81] = {
3009 .type = HDA_FIXUP_PINS,
3010 .v.pins = dell_922x_d81_pin_configs,
3011 },
3012 [STAC_922X_DELL_D82] = {
3013 .type = HDA_FIXUP_PINS,
3014 .v.pins = dell_922x_d82_pin_configs,
3015 },
3016 [STAC_922X_DELL_M81] = {
3017 .type = HDA_FIXUP_PINS,
3018 .v.pins = dell_922x_m81_pin_configs,
3019 },
3020 [STAC_922X_DELL_M82] = {
3021 .type = HDA_FIXUP_PINS,
3022 .v.pins = dell_922x_m82_pin_configs,
3023 },
3024};
3025
3026static const struct hda_model_fixup stac922x_models[] = {
3027 { .id = STAC_D945_REF, .name = "ref" },
3028 { .id = STAC_D945GTP5, .name = "5stack" },
3029 { .id = STAC_D945GTP3, .name = "3stack" },
3030 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
3031 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
3032 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
3033 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
3034 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
3035 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
3036 { .id = STAC_ECS_202, .name = "ecs202" },
3037 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
3038 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
3039 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
3040 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003041 /* for backward compatibility */
Takashi Iwai0a427842013-01-14 15:20:13 +01003042 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
3043 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
3044 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
3045 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
3046 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
3047 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
3048 {}
Matt Porter403d1942005-11-29 15:00:51 +01003049};
3050
Takashi Iwai0a427842013-01-14 15:20:13 +01003051static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003052 /* SigmaTel reference board */
3053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3054 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003055 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3056 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003057 /* Intel 945G based systems */
3058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
3059 "Intel D945G", STAC_D945GTP3),
3060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
3061 "Intel D945G", STAC_D945GTP3),
3062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
3063 "Intel D945G", STAC_D945GTP3),
3064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
3065 "Intel D945G", STAC_D945GTP3),
3066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
3067 "Intel D945G", STAC_D945GTP3),
3068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
3069 "Intel D945G", STAC_D945GTP3),
3070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
3071 "Intel D945G", STAC_D945GTP3),
3072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
3073 "Intel D945G", STAC_D945GTP3),
3074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
3075 "Intel D945G", STAC_D945GTP3),
3076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
3077 "Intel D945G", STAC_D945GTP3),
3078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
3079 "Intel D945G", STAC_D945GTP3),
3080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
3081 "Intel D945G", STAC_D945GTP3),
3082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
3083 "Intel D945G", STAC_D945GTP3),
3084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
3085 "Intel D945G", STAC_D945GTP3),
3086 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
3087 "Intel D945G", STAC_D945GTP3),
3088 /* Intel D945G 5-stack systems */
3089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
3090 "Intel D945G", STAC_D945GTP5),
3091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
3092 "Intel D945G", STAC_D945GTP5),
3093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
3094 "Intel D945G", STAC_D945GTP5),
3095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
3096 "Intel D945G", STAC_D945GTP5),
3097 /* Intel 945P based systems */
3098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
3099 "Intel D945P", STAC_D945GTP3),
3100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
3101 "Intel D945P", STAC_D945GTP3),
3102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
3103 "Intel D945P", STAC_D945GTP3),
3104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
3105 "Intel D945P", STAC_D945GTP3),
3106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
3107 "Intel D945P", STAC_D945GTP3),
3108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
3109 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01003110 /* other intel */
3111 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
3112 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003113 /* other systems */
Takashi Iwai0a427842013-01-14 15:20:13 +01003114
Nicolas Boichat536319a2008-07-21 22:18:01 +08003115 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwai0a427842013-01-14 15:20:13 +01003116 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
3117
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003118 /* Dell systems */
3119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
3120 "unknown Dell", STAC_922X_DELL_D81),
3121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
3122 "unknown Dell", STAC_922X_DELL_D81),
3123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
3124 "unknown Dell", STAC_922X_DELL_D81),
3125 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
3126 "unknown Dell", STAC_922X_DELL_D82),
3127 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
3128 "unknown Dell", STAC_922X_DELL_M81),
3129 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
3130 "unknown Dell", STAC_922X_DELL_D82),
3131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
3132 "unknown Dell", STAC_922X_DELL_D81),
3133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
3134 "unknown Dell", STAC_922X_DELL_D81),
3135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
3136 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03003137 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003138 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02003139 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01003140 {} /* terminator */
3141};
3142
Takashi Iwai29ac8362013-01-14 16:03:38 +01003143static const struct hda_pintbl ref927x_pin_configs[] = {
3144 { 0x0a, 0x02214020 },
3145 { 0x0b, 0x02a19080 },
3146 { 0x0c, 0x0181304e },
3147 { 0x0d, 0x01014010 },
3148 { 0x0e, 0x01a19040 },
3149 { 0x0f, 0x01011012 },
3150 { 0x10, 0x01016011 },
3151 { 0x11, 0x0101201f },
3152 { 0x12, 0x183301f0 },
3153 { 0x13, 0x18a001f0 },
3154 { 0x14, 0x18a001f0 },
3155 { 0x21, 0x01442070 },
3156 { 0x22, 0x01c42190 },
3157 { 0x23, 0x40000100 },
3158 {}
Matt Porter3cc08dc2006-01-23 15:27:49 +01003159};
3160
Takashi Iwai29ac8362013-01-14 16:03:38 +01003161static const struct hda_pintbl d965_3st_pin_configs[] = {
3162 { 0x0a, 0x0221401f },
3163 { 0x0b, 0x02a19120 },
3164 { 0x0c, 0x40000100 },
3165 { 0x0d, 0x01014011 },
3166 { 0x0e, 0x01a19021 },
3167 { 0x0f, 0x01813024 },
3168 { 0x10, 0x40000100 },
3169 { 0x11, 0x40000100 },
3170 { 0x12, 0x40000100 },
3171 { 0x13, 0x40000100 },
3172 { 0x14, 0x40000100 },
3173 { 0x21, 0x40000100 },
3174 { 0x22, 0x40000100 },
3175 { 0x23, 0x40000100 },
3176 {}
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003177};
3178
Takashi Iwai29ac8362013-01-14 16:03:38 +01003179static const struct hda_pintbl d965_5st_pin_configs[] = {
3180 { 0x0a, 0x02214020 },
3181 { 0x0b, 0x02a19080 },
3182 { 0x0c, 0x0181304e },
3183 { 0x0d, 0x01014010 },
3184 { 0x0e, 0x01a19040 },
3185 { 0x0f, 0x01011012 },
3186 { 0x10, 0x01016011 },
3187 { 0x11, 0x40000100 },
3188 { 0x12, 0x40000100 },
3189 { 0x13, 0x40000100 },
3190 { 0x14, 0x40000100 },
3191 { 0x21, 0x01442070 },
3192 { 0x22, 0x40000100 },
3193 { 0x23, 0x40000100 },
3194 {}
Tobin Davis93ed1502006-09-01 21:03:12 +02003195};
3196
Takashi Iwai29ac8362013-01-14 16:03:38 +01003197static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
3198 { 0x0a, 0x40000100 },
3199 { 0x0b, 0x40000100 },
3200 { 0x0c, 0x0181304e },
3201 { 0x0d, 0x01014010 },
3202 { 0x0e, 0x01a19040 },
3203 { 0x0f, 0x01011012 },
3204 { 0x10, 0x01016011 },
3205 { 0x11, 0x40000100 },
3206 { 0x12, 0x40000100 },
3207 { 0x13, 0x40000100 },
3208 { 0x14, 0x40000100 },
3209 { 0x21, 0x01442070 },
3210 { 0x22, 0x40000100 },
3211 { 0x23, 0x40000100 },
3212 {}
Takashi Iwai679d92e2009-05-24 19:00:08 +02003213};
3214
Takashi Iwai29ac8362013-01-14 16:03:38 +01003215static const struct hda_pintbl dell_3st_pin_configs[] = {
3216 { 0x0a, 0x02211230 },
3217 { 0x0b, 0x02a11220 },
3218 { 0x0c, 0x01a19040 },
3219 { 0x0d, 0x01114210 },
3220 { 0x0e, 0x01111212 },
3221 { 0x0f, 0x01116211 },
3222 { 0x10, 0x01813050 },
3223 { 0x11, 0x01112214 },
3224 { 0x12, 0x403003fa },
3225 { 0x13, 0x90a60040 },
3226 { 0x14, 0x90a60040 },
3227 { 0x21, 0x404003fb },
3228 { 0x22, 0x40c003fc },
3229 { 0x23, 0x40000100 },
3230 {}
Tobin Davis4ff076e2007-08-07 11:48:12 +02003231};
3232
Takashi Iwai29ac8362013-01-14 16:03:38 +01003233static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
3234 const struct hda_fixup *fix, int action)
3235{
3236 struct sigmatel_spec *spec = codec->spec;
3237
3238 /* no jack detecion for ref-no-jd model */
3239 if (action == HDA_FIXUP_ACT_PROBE)
3240 spec->hp_detect = 0;
3241}
3242
3243static void stac927x_fixup_ref(struct hda_codec *codec,
3244 const struct hda_fixup *fix, int action)
3245{
3246 struct sigmatel_spec *spec = codec->spec;
3247
3248 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3249 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
3250 spec->eapd_mask = spec->gpio_mask = 0;
3251 spec->gpio_dir = spec->gpio_data = 0;
3252 }
3253}
3254
3255static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
3256 const struct hda_fixup *fix, int action)
3257{
3258 struct sigmatel_spec *spec = codec->spec;
3259
3260 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3261 return;
3262
3263 if (codec->subsystem_id != 0x1028022f) {
3264 /* GPIO2 High = Enable EAPD */
3265 spec->eapd_mask = spec->gpio_mask = 0x04;
3266 spec->gpio_dir = spec->gpio_data = 0x04;
3267 }
3268 spec->dmic_nids = stac927x_dmic_nids;
3269 spec->num_dmics = STAC927X_NUM_DMICS;
3270
3271 snd_hda_add_verbs(codec, dell_3st_core_init);
3272 spec->volknob_init = 1;
3273 spec->dmux_nids = stac927x_dmux_nids;
3274 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3275}
3276
3277static void stac927x_fixup_volknob(struct hda_codec *codec,
3278 const struct hda_fixup *fix, int action)
3279{
3280 struct sigmatel_spec *spec = codec->spec;
3281
3282 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3283 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
3284 spec->volknob_init = 1;
3285 }
3286}
3287
3288static const struct hda_fixup stac927x_fixups[] = {
3289 [STAC_D965_REF_NO_JD] = {
3290 .type = HDA_FIXUP_FUNC,
3291 .v.func = stac927x_fixup_ref_no_jd,
3292 .chained = true,
3293 .chain_id = STAC_D965_REF,
3294 },
3295 [STAC_D965_REF] = {
3296 .type = HDA_FIXUP_FUNC,
3297 .v.func = stac927x_fixup_ref,
3298 },
3299 [STAC_D965_3ST] = {
3300 .type = HDA_FIXUP_PINS,
3301 .v.pins = d965_3st_pin_configs,
3302 .chained = true,
3303 .chain_id = STAC_D965_VERBS,
3304 },
3305 [STAC_D965_5ST] = {
3306 .type = HDA_FIXUP_PINS,
3307 .v.pins = d965_5st_pin_configs,
3308 .chained = true,
3309 .chain_id = STAC_D965_VERBS,
3310 },
3311 [STAC_D965_VERBS] = {
3312 .type = HDA_FIXUP_VERBS,
3313 .v.verbs = d965_core_init,
3314 },
3315 [STAC_D965_5ST_NO_FP] = {
3316 .type = HDA_FIXUP_PINS,
3317 .v.pins = d965_5st_no_fp_pin_configs,
3318 },
3319 [STAC_DELL_3ST] = {
3320 .type = HDA_FIXUP_PINS,
3321 .v.pins = dell_3st_pin_configs,
3322 .chained = true,
3323 .chain_id = STAC_927X_DELL_DMIC,
3324 },
3325 [STAC_DELL_BIOS] = {
3326 .type = HDA_FIXUP_PINS,
3327 .v.pins = (const struct hda_pintbl[]) {
3328 /* configure the analog microphone on some laptops */
3329 { 0x0c, 0x90a79130 },
3330 /* correct the front output jack as a hp out */
3331 { 0x0f, 0x0227011f },
3332 /* correct the front input jack as a mic */
3333 { 0x0e, 0x02a79130 },
3334 {}
3335 },
3336 .chained = true,
3337 .chain_id = STAC_927X_DELL_DMIC,
3338 },
3339 [STAC_DELL_BIOS_SPDIF] = {
3340 .type = HDA_FIXUP_PINS,
3341 .v.pins = (const struct hda_pintbl[]) {
3342 /* correct the device field to SPDIF out */
3343 { 0x21, 0x01442070 },
3344 {}
3345 },
3346 .chained = true,
3347 .chain_id = STAC_DELL_BIOS,
3348 },
3349 [STAC_927X_DELL_DMIC] = {
3350 .type = HDA_FIXUP_FUNC,
3351 .v.func = stac927x_fixup_dell_dmic,
3352 },
3353 [STAC_927X_VOLKNOB] = {
3354 .type = HDA_FIXUP_FUNC,
3355 .v.func = stac927x_fixup_volknob,
3356 },
Matt Porter3cc08dc2006-01-23 15:27:49 +01003357};
3358
Takashi Iwai29ac8362013-01-14 16:03:38 +01003359static const struct hda_model_fixup stac927x_models[] = {
3360 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3361 { .id = STAC_D965_REF, .name = "ref" },
3362 { .id = STAC_D965_3ST, .name = "3stack" },
3363 { .id = STAC_D965_5ST, .name = "5stack" },
3364 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3365 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3366 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3367 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3368 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003369};
3370
Takashi Iwai29ac8362013-01-14 16:03:38 +01003371static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003372 /* SigmaTel reference board */
3373 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3374 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003375 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3376 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003377 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003378 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3379 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02003380 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003381 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3382 "Intel D965", STAC_D965_3ST),
3383 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3384 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003385 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
3388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003389 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04003391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
Chengu Wang84d3dc22009-07-30 19:43:55 +08003394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
3396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
3397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
Tobin Davis93ed1502006-09-01 21:03:12 +02003399 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003400 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3401 "Intel D965", STAC_D965_5ST),
3402 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3403 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02003404 /* volume-knob fixes */
3405 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01003406 {} /* terminator */
3407};
3408
Takashi Iwaife6322c2013-01-14 14:46:51 +01003409static const struct hda_pintbl ref9205_pin_configs[] = {
3410 { 0x0a, 0x40000100 },
3411 { 0x0b, 0x40000100 },
3412 { 0x0c, 0x01016011 },
3413 { 0x0d, 0x01014010 },
3414 { 0x0e, 0x01813122 },
3415 { 0x0f, 0x01a19021 },
3416 { 0x14, 0x01019020 },
3417 { 0x16, 0x40000100 },
3418 { 0x17, 0x90a000f0 },
3419 { 0x18, 0x90a000f0 },
3420 { 0x21, 0x01441030 },
3421 { 0x22, 0x01c41030 },
3422 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003423};
3424
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003425/*
3426 STAC 9205 pin configs for
3427 102801F1
3428 102801F2
3429 102801FC
3430 102801FD
3431 10280204
3432 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003433 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01003434 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003435*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003436static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3437 { 0x0a, 0x0321101F },
3438 { 0x0b, 0x03A11020 },
3439 { 0x0c, 0x400003FA },
3440 { 0x0d, 0x90170310 },
3441 { 0x0e, 0x400003FB },
3442 { 0x0f, 0x400003FC },
3443 { 0x14, 0x400003FD },
3444 { 0x16, 0x40F000F9 },
3445 { 0x17, 0x90A60330 },
3446 { 0x18, 0x400003FF },
3447 { 0x21, 0x0144131F },
3448 { 0x22, 0x40C003FE },
3449 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003450};
3451
3452/*
3453 STAC 9205 pin configs for
3454 102801F9
3455 102801FA
3456 102801FE
3457 102801FF (Dell Precision M4300)
3458 10280206
3459 10280200
3460 10280201
3461*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003462static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3463 { 0x0a, 0x0321101f },
3464 { 0x0b, 0x03a11020 },
3465 { 0x0c, 0x90a70330 },
3466 { 0x0d, 0x90170310 },
3467 { 0x0e, 0x400000fe },
3468 { 0x0f, 0x400000ff },
3469 { 0x14, 0x400000fd },
3470 { 0x16, 0x40f000f9 },
3471 { 0x17, 0x400000fa },
3472 { 0x18, 0x400000fc },
3473 { 0x21, 0x0144131f },
3474 { 0x22, 0x40c003f8 },
3475 /* Enable SPDIF in/out */
3476 { 0x1f, 0x01441030 },
3477 { 0x20, 0x1c410030 },
3478 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003479};
3480
Takashi Iwaife6322c2013-01-14 14:46:51 +01003481static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3482 { 0x0a, 0x0421101f },
3483 { 0x0b, 0x04a11020 },
3484 { 0x0c, 0x400003fa },
3485 { 0x0d, 0x90170310 },
3486 { 0x0e, 0x400003fb },
3487 { 0x0f, 0x400003fc },
3488 { 0x14, 0x400003fd },
3489 { 0x16, 0x400003f9 },
3490 { 0x17, 0x90a60330 },
3491 { 0x18, 0x400003ff },
3492 { 0x21, 0x01441340 },
3493 { 0x22, 0x40c003fe },
3494 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003495};
3496
Takashi Iwaife6322c2013-01-14 14:46:51 +01003497static void stac9205_fixup_ref(struct hda_codec *codec,
3498 const struct hda_fixup *fix, int action)
3499{
3500 struct sigmatel_spec *spec = codec->spec;
3501
3502 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3503 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3504 /* SPDIF-In enabled */
3505 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3506 }
3507}
3508
Takashi Iwaife6322c2013-01-14 14:46:51 +01003509static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3510 const struct hda_fixup *fix, int action)
3511{
3512 struct sigmatel_spec *spec = codec->spec;
3513 int err;
3514
3515 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3516 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3517
3518 /* Enable unsol response for GPIO4/Dock HP connection */
3519 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
3520 if (err < 0)
3521 return;
3522 snd_hda_codec_write_cache(codec, codec->afg, 0,
3523 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3524 snd_hda_jack_detect_enable(codec, codec->afg, 0);
3525
3526 spec->gpio_dir = 0x0b;
3527 spec->eapd_mask = 0x01;
3528 spec->gpio_mask = 0x1b;
3529 spec->gpio_mute = 0x10;
3530 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3531 * GPIO3 Low = DRM
3532 */
3533 spec->gpio_data = 0x01;
3534 }
3535}
3536
3537static void stac9205_fixup_eapd(struct hda_codec *codec,
3538 const struct hda_fixup *fix, int action)
3539{
3540 struct sigmatel_spec *spec = codec->spec;
3541
3542 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3543 spec->eapd_switch = 0;
3544}
3545
3546static const struct hda_fixup stac9205_fixups[] = {
3547 [STAC_9205_REF] = {
3548 .type = HDA_FIXUP_FUNC,
3549 .v.func = stac9205_fixup_ref,
3550 },
3551 [STAC_9205_DELL_M42] = {
3552 .type = HDA_FIXUP_PINS,
3553 .v.pins = dell_9205_m42_pin_configs,
3554 },
3555 [STAC_9205_DELL_M43] = {
3556 .type = HDA_FIXUP_FUNC,
3557 .v.func = stac9205_fixup_dell_m43,
3558 },
3559 [STAC_9205_DELL_M44] = {
3560 .type = HDA_FIXUP_PINS,
3561 .v.pins = dell_9205_m44_pin_configs,
3562 },
3563 [STAC_9205_EAPD] = {
3564 .type = HDA_FIXUP_FUNC,
3565 .v.func = stac9205_fixup_eapd,
3566 },
3567 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003568};
3569
Takashi Iwaife6322c2013-01-14 14:46:51 +01003570static const struct hda_model_fixup stac9205_models[] = {
3571 { .id = STAC_9205_REF, .name = "ref" },
3572 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3573 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3574 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3575 { .id = STAC_9205_EAPD, .name = "eapd" },
3576 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003577};
3578
Takashi Iwaife6322c2013-01-14 14:46:51 +01003579static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003580 /* SigmaTel reference board */
3581 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3582 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03003583 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3584 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003585 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3586 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003587 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3589 "unknown Dell", STAC_9205_DELL_M42),
3590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3591 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02003593 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3595 "Dell Precision", STAC_9205_DELL_M43),
3596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3597 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3599 "unknown Dell", STAC_9205_DELL_M42),
3600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3601 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3603 "Dell Precision", STAC_9205_DELL_M43),
3604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003605 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3607 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02003608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3609 "Dell Precision", STAC_9205_DELL_M43),
3610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3611 "Dell Precision", STAC_9205_DELL_M43),
3612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3613 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3615 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3617 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01003618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3619 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003620 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08003621 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003622 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02003623 {} /* terminator */
3624};
3625
Matt2f2f4252005-04-13 14:45:30 +02003626/*
3627 * Analog playback callbacks
3628 */
3629static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
3630 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003631 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003632{
3633 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003634 if (spec->stream_delay)
3635 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01003636 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3637 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02003638}
3639
3640static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3641 struct hda_codec *codec,
3642 unsigned int stream_tag,
3643 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003644 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003645{
3646 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01003647 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02003648}
3649
3650static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3651 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003652 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003653{
3654 struct sigmatel_spec *spec = codec->spec;
3655 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3656}
3657
3658/*
Mattdabbed62005-06-14 10:19:34 +02003659 * Digital playback callbacks
3660 */
3661static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3662 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003663 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003664{
3665 struct sigmatel_spec *spec = codec->spec;
3666 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3667}
3668
3669static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3670 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003671 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003672{
3673 struct sigmatel_spec *spec = codec->spec;
3674 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3675}
3676
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003677static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3678 struct hda_codec *codec,
3679 unsigned int stream_tag,
3680 unsigned int format,
3681 struct snd_pcm_substream *substream)
3682{
3683 struct sigmatel_spec *spec = codec->spec;
3684 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3685 stream_tag, format, substream);
3686}
3687
Takashi Iwai9411e212009-02-13 11:32:28 +01003688static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3689 struct hda_codec *codec,
3690 struct snd_pcm_substream *substream)
3691{
3692 struct sigmatel_spec *spec = codec->spec;
3693 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3694}
3695
Mattdabbed62005-06-14 10:19:34 +02003696
3697/*
Matt2f2f4252005-04-13 14:45:30 +02003698 * Analog capture callbacks
3699 */
3700static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3701 struct hda_codec *codec,
3702 unsigned int stream_tag,
3703 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003704 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003705{
3706 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003707 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003708
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003709 if (spec->powerdown_adcs) {
3710 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003711 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003712 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
3713 }
3714 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02003715 return 0;
3716}
3717
3718static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3719 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003720 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003721{
3722 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003723 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003724
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003725 snd_hda_codec_cleanup_stream(codec, nid);
3726 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003727 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003728 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02003729 return 0;
3730}
3731
Takashi Iwai2b635362011-05-02 12:33:43 +02003732static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02003733 .substreams = 1,
3734 .channels_min = 2,
3735 .channels_max = 2,
3736 /* NID is set in stac92xx_build_pcms */
3737 .ops = {
3738 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003739 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01003740 .prepare = stac92xx_dig_playback_pcm_prepare,
3741 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02003742 },
3743};
3744
Takashi Iwai2b635362011-05-02 12:33:43 +02003745static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02003746 .substreams = 1,
3747 .channels_min = 2,
3748 .channels_max = 2,
3749 /* NID is set in stac92xx_build_pcms */
3750};
3751
Takashi Iwai2b635362011-05-02 12:33:43 +02003752static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02003753 .substreams = 1,
3754 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02003755 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02003756 .nid = 0x02, /* NID to query formats and rates */
3757 .ops = {
3758 .open = stac92xx_playback_pcm_open,
3759 .prepare = stac92xx_playback_pcm_prepare,
3760 .cleanup = stac92xx_playback_pcm_cleanup
3761 },
3762};
3763
Takashi Iwai2b635362011-05-02 12:33:43 +02003764static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003765 .substreams = 1,
3766 .channels_min = 2,
3767 .channels_max = 2,
3768 .nid = 0x06, /* NID to query formats and rates */
3769 .ops = {
3770 .open = stac92xx_playback_pcm_open,
3771 .prepare = stac92xx_playback_pcm_prepare,
3772 .cleanup = stac92xx_playback_pcm_cleanup
3773 },
3774};
3775
Takashi Iwai2b635362011-05-02 12:33:43 +02003776static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02003777 .channels_min = 2,
3778 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003779 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02003780 .ops = {
3781 .prepare = stac92xx_capture_pcm_prepare,
3782 .cleanup = stac92xx_capture_pcm_cleanup
3783 },
3784};
3785
3786static int stac92xx_build_pcms(struct hda_codec *codec)
3787{
3788 struct sigmatel_spec *spec = codec->spec;
3789 struct hda_pcm *info = spec->pcm_rec;
3790
3791 codec->num_pcms = 1;
3792 codec->pcm_info = info;
3793
Mattc7d4b2f2005-06-27 14:59:41 +02003794 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02003795 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01003796 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3797 spec->multiout.dac_nids[0];
Takashi Iwaiee81abb2012-11-08 17:12:10 +01003798 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3799 spec->autocfg.line_outs == 2)
3800 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
3801 snd_pcm_2_1_chmaps;
3802
Matt2f2f4252005-04-13 14:45:30 +02003803 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003804 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003805 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003806
3807 if (spec->alt_switch) {
3808 codec->num_pcms++;
3809 info++;
3810 info->name = "STAC92xx Analog Alt";
3811 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
3812 }
Matt2f2f4252005-04-13 14:45:30 +02003813
Mattdabbed62005-06-14 10:19:34 +02003814 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3815 codec->num_pcms++;
3816 info++;
3817 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003818 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02003819 if (spec->multiout.dig_out_nid) {
3820 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
3821 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3822 }
3823 if (spec->dig_in_nid) {
3824 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
3825 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3826 }
3827 }
3828
Matt2f2f4252005-04-13 14:45:30 +02003829 return 0;
3830}
3831
Matt Porter403d1942005-11-29 15:00:51 +01003832static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
3833
3834{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02003835 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01003836}
3837
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003838#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
3839
3840static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
3841 struct snd_ctl_elem_value *ucontrol)
3842{
3843 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3844 struct sigmatel_spec *spec = codec->spec;
3845
Takashi Iwaid7a89432008-11-12 09:48:04 +01003846 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003847 return 0;
3848}
3849
Takashi Iwai62558ce2009-07-29 14:23:09 +02003850static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003851
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003852static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
3853 struct snd_ctl_elem_value *ucontrol)
3854{
3855 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3856 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003857 int nid = kcontrol->private_value;
3858
3859 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003860
Lucas De Marchi25985ed2011-03-30 22:57:33 -03003861 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003862 * switch changes
3863 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02003864 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003865
3866 return 1;
3867}
3868
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003869static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
3870 struct snd_ctl_elem_info *uinfo)
3871{
3872 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02003873 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003874 "Mic In", "Line In", "Line Out"
3875 };
3876
3877 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3878 struct sigmatel_spec *spec = codec->spec;
3879 hda_nid_t nid = kcontrol->private_value;
3880
3881 if (nid == spec->mic_switch || nid == spec->line_switch)
3882 i = 3;
3883 else
3884 i = 2;
3885
3886 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3887 uinfo->value.enumerated.items = i;
3888 uinfo->count = 1;
3889 if (uinfo->value.enumerated.item >= i)
3890 uinfo->value.enumerated.item = i-1;
3891 strcpy(uinfo->value.enumerated.name,
3892 texts[uinfo->value.enumerated.item]);
3893
3894 return 0;
3895}
3896
3897static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
3898 struct snd_ctl_elem_value *ucontrol)
3899{
3900 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3901 hda_nid_t nid = kcontrol->private_value;
3902 unsigned int vref = stac92xx_vref_get(codec, nid);
3903
Takashi Iwai47408602012-04-20 13:06:53 +02003904 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003905 ucontrol->value.enumerated.item[0] = 0;
3906 else if (vref == AC_PINCTL_VREF_GRD)
3907 ucontrol->value.enumerated.item[0] = 1;
3908 else if (vref == AC_PINCTL_VREF_HIZ)
3909 ucontrol->value.enumerated.item[0] = 2;
3910
3911 return 0;
3912}
3913
3914static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
3915 struct snd_ctl_elem_value *ucontrol)
3916{
3917 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3918 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02003919 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003920 hda_nid_t nid = kcontrol->private_value;
3921
3922 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02003923 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003924 else if (ucontrol->value.enumerated.item[0] == 1)
3925 new_vref = AC_PINCTL_VREF_GRD;
3926 else if (ucontrol->value.enumerated.item[0] == 2)
3927 new_vref = AC_PINCTL_VREF_HIZ;
3928 else
3929 return 0;
3930
3931 if (new_vref != stac92xx_vref_get(codec, nid)) {
3932 error = stac92xx_vref_set(codec, nid, new_vref);
3933 return error;
3934 }
3935
3936 return 0;
3937}
3938
3939static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
3940 struct snd_ctl_elem_info *uinfo)
3941{
Takashi Iwai2b635362011-05-02 12:33:43 +02003942 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003943 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3944 struct sigmatel_spec *spec = codec->spec;
3945
3946 if (kcontrol->private_value == spec->line_switch)
3947 texts[0] = "Line In";
3948 else
3949 texts[0] = "Mic In";
3950 texts[1] = "Line Out";
3951 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3952 uinfo->value.enumerated.items = 2;
3953 uinfo->count = 1;
3954
3955 if (uinfo->value.enumerated.item >= 2)
3956 uinfo->value.enumerated.item = 1;
3957 strcpy(uinfo->value.enumerated.name,
3958 texts[uinfo->value.enumerated.item]);
3959
3960 return 0;
3961}
Matt Porter403d1942005-11-29 15:00:51 +01003962
3963static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3964{
3965 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3966 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003967 hda_nid_t nid = kcontrol->private_value;
3968 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01003969
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003970 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01003971 return 0;
3972}
3973
3974static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3975{
3976 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3977 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003978 hda_nid_t nid = kcontrol->private_value;
3979 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3980 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01003981
3982 spec->io_switch[io_idx] = val;
3983
3984 if (val)
3985 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01003986 else {
3987 unsigned int pinctl = AC_PINCTL_IN_EN;
3988 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02003989 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003990 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3991 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01003992
3993 /* check the auto-mute again: we need to mute/unmute the speaker
3994 * appropriately according to the pin direction
3995 */
3996 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02003997 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01003998
Matt Porter403d1942005-11-29 15:00:51 +01003999 return 1;
4000}
4001
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004002#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
4003
4004static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
4005 struct snd_ctl_elem_value *ucontrol)
4006{
4007 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4008 struct sigmatel_spec *spec = codec->spec;
4009
4010 ucontrol->value.integer.value[0] = spec->clfe_swap;
4011 return 0;
4012}
4013
4014static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
4015 struct snd_ctl_elem_value *ucontrol)
4016{
4017 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4018 struct sigmatel_spec *spec = codec->spec;
4019 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004020 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004021
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004022 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004023 return 0;
4024
Takashi Iwai68ea7b22007-11-15 15:54:38 +01004025 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004026
4027 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
4028 spec->clfe_swap ? 0x4 : 0x0);
4029
4030 return 1;
4031}
4032
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004033#define STAC_CODEC_HP_SWITCH(xname) \
4034 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4035 .name = xname, \
4036 .index = 0, \
4037 .info = stac92xx_hp_switch_info, \
4038 .get = stac92xx_hp_switch_get, \
4039 .put = stac92xx_hp_switch_put, \
4040 }
4041
Matt Porter403d1942005-11-29 15:00:51 +01004042#define STAC_CODEC_IO_SWITCH(xname, xpval) \
4043 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4044 .name = xname, \
4045 .index = 0, \
4046 .info = stac92xx_io_switch_info, \
4047 .get = stac92xx_io_switch_get, \
4048 .put = stac92xx_io_switch_put, \
4049 .private_value = xpval, \
4050 }
4051
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004052#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
4053 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4054 .name = xname, \
4055 .index = 0, \
4056 .info = stac92xx_clfe_switch_info, \
4057 .get = stac92xx_clfe_switch_get, \
4058 .put = stac92xx_clfe_switch_put, \
4059 .private_value = xpval, \
4060 }
Matt Porter403d1942005-11-29 15:00:51 +01004061
Mattc7d4b2f2005-06-27 14:59:41 +02004062enum {
4063 STAC_CTL_WIDGET_VOL,
4064 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004065 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01004066 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004067 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01004068 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02004069 STAC_CTL_WIDGET_CLFE_SWITCH,
4070 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02004071};
4072
Takashi Iwai2b635362011-05-02 12:33:43 +02004073static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02004074 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4075 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004076 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01004077 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004078 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01004079 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004080 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02004081 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02004082};
4083
4084/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01004085static struct snd_kcontrol_new *
4086stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004087 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004088 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004089 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02004090{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004091 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02004092
Takashi Iwai603c4012008-07-30 15:01:44 +02004093 knew = snd_array_new(&spec->kctls);
4094 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01004095 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004096 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02004097 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01004098 if (!knew->name) {
4099 /* roolback */
4100 memset(knew, 0, sizeof(*knew));
4101 spec->kctls.alloced--;
4102 return NULL;
4103 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004104 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01004105 return knew;
4106}
4107
Takashi Iwai62cbde12012-09-14 11:58:54 +02004108static struct snd_kcontrol_new *
4109add_control_temp(struct sigmatel_spec *spec,
4110 const struct snd_kcontrol_new *ktemp,
4111 int idx, const char *name,
4112 unsigned long val)
4113{
4114 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
4115 HDA_SUBDEV_AMP_FLAG);
4116 if (!knew)
4117 return NULL;
4118 knew->index = idx;
4119 knew->private_value = val;
4120 return knew;
4121}
4122
Takashi Iwaie3c75962009-01-23 11:57:22 +01004123static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004124 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01004125 int idx, const char *name,
4126 unsigned long val)
4127{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004128 return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM;
Mattc7d4b2f2005-06-27 14:59:41 +02004129}
4130
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004131static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
4132 int type, int idx, const char *name,
4133 unsigned long val)
4134{
4135 return stac92xx_add_control_temp(spec,
4136 &stac92xx_control_templates[type],
4137 idx, name, val);
4138}
4139
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004140
4141/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004142static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
4143 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004144{
4145 return stac92xx_add_control_idx(spec, type, 0, name, val);
4146}
4147
Takashi Iwai2b635362011-05-02 12:33:43 +02004148static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01004149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4150 .name = "Input Source",
4151 .info = stac92xx_mux_enum_info,
4152 .get = stac92xx_mux_enum_get,
4153 .put = stac92xx_mux_enum_put,
4154};
4155
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004156static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
4157 hda_nid_t nid, int idx)
4158{
4159 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4160 int control = 0;
4161 struct sigmatel_spec *spec = codec->spec;
4162 char name[22];
4163
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004164 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
David Henningsson8d032a82012-10-09 12:48:40 +02004165 if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf)
4166 != INPUT_PIN_ATTR_DOCK)
4167 return 0;
Takashi Iwai47408602012-04-20 13:06:53 +02004168 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004169 && nid == spec->line_switch)
4170 control = STAC_CTL_WIDGET_IO_SWITCH;
4171 else if (snd_hda_query_pin_caps(codec, nid)
4172 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
4173 control = STAC_CTL_WIDGET_DC_BIAS;
4174 else if (nid == spec->mic_switch)
4175 control = STAC_CTL_WIDGET_IO_SWITCH;
4176 }
4177
4178 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01004179 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4180 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004181 return stac92xx_add_control(codec->spec, control,
4182 strcat(name, " Jack Mode"), nid);
4183 }
4184
4185 return 0;
4186}
4187
Takashi Iwaie3c75962009-01-23 11:57:22 +01004188static int stac92xx_add_input_source(struct sigmatel_spec *spec)
4189{
4190 struct snd_kcontrol_new *knew;
4191 struct hda_input_mux *imux = &spec->private_imux;
4192
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004193 if (spec->auto_mic)
4194 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01004195 if (!spec->num_adcs || imux->num_items <= 1)
4196 return 0; /* no need for input source control */
4197 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004198 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01004199 if (!knew)
4200 return -ENOMEM;
4201 knew->count = spec->num_adcs;
4202 return 0;
4203}
4204
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004205/* check whether the line-input can be used as line-out */
4206static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01004207{
4208 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004209 struct auto_pin_cfg *cfg = &spec->autocfg;
4210 hda_nid_t nid;
4211 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004212 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004213
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004214 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4215 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004216 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004217 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004218 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01004219 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004220 if (pincap & AC_PINCAP_OUT)
4221 return nid;
4222 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004223 }
Matt Porter403d1942005-11-29 15:00:51 +01004224 return 0;
4225}
4226
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004227static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
4228
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004229/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004230static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004231{
4232 struct sigmatel_spec *spec = codec->spec;
4233 struct auto_pin_cfg *cfg = &spec->autocfg;
4234 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02004235 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004236
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004237 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004238 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
4239 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004240 for (i = 0; i < cfg->num_inputs; i++) {
4241 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02004242 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004243 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004244 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4245 /* some laptops have an internal analog microphone
4246 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004247 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004248 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004249 if (pincap & AC_PINCAP_OUT) {
4250 *dac = get_unassigned_dac(codec, nid);
4251 if (*dac)
4252 return nid;
4253 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004254 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004255 }
4256 return 0;
4257}
Steve Longerbeam7b043892007-05-03 20:50:03 +02004258
4259static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4260{
4261 int i;
4262
4263 for (i = 0; i < spec->multiout.num_dacs; i++) {
4264 if (spec->multiout.dac_nids[i] == nid)
4265 return 1;
4266 }
4267
4268 return 0;
4269}
4270
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004271static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
4272{
4273 int i;
4274 if (is_in_dac_nids(spec, nid))
4275 return 1;
4276 for (i = 0; i < spec->autocfg.hp_outs; i++)
4277 if (spec->hp_dacs[i] == nid)
4278 return 1;
4279 for (i = 0; i < spec->autocfg.speaker_outs; i++)
4280 if (spec->speaker_dacs[i] == nid)
4281 return 1;
4282 return 0;
4283}
4284
4285static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
4286{
4287 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02004288 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004289 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02004290 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004291 unsigned int wcaps, wtype;
4292
4293 conn_len = snd_hda_get_connections(codec, nid, conn,
4294 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01004295 /* 92HD88: trace back up the link of nids to find the DAC */
4296 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
4297 != AC_WID_AUD_OUT)) {
4298 nid = conn[0];
4299 conn_len = snd_hda_get_connections(codec, nid, conn,
4300 HDA_MAX_CONNECTIONS);
4301 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004302 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01004303 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004304 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004305 /* we check only analog outputs */
4306 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
4307 continue;
4308 /* if this route has a free DAC, assign it */
4309 if (!check_all_dac_nids(spec, conn[j])) {
4310 if (conn_len > 1) {
4311 /* select this DAC in the pin's input mux */
4312 snd_hda_codec_write_cache(codec, nid, 0,
4313 AC_VERB_SET_CONNECT_SEL, j);
4314 }
4315 return conn[j];
4316 }
4317 }
David Henningsson48718ea2011-10-05 09:49:05 +02004318
4319 /* if all DACs are already assigned, connect to the primary DAC,
4320 unless we're assigning a secondary headphone */
4321 fallback_dac = spec->multiout.dac_nids[0];
4322 if (spec->multiout.hp_nid) {
4323 for (j = 0; j < cfg->hp_outs; j++)
4324 if (cfg->hp_pins[j] == nid) {
4325 fallback_dac = spec->multiout.hp_nid;
4326 break;
4327 }
4328 }
4329
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004330 if (conn_len > 1) {
4331 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02004332 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004333 snd_hda_codec_write_cache(codec, nid, 0,
4334 AC_VERB_SET_CONNECT_SEL, j);
4335 break;
4336 }
4337 }
4338 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004339 return 0;
4340}
4341
4342static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4343static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4344
Matt Porter3cc08dc2006-01-23 15:27:49 +01004345/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02004346 * Fill in the dac_nids table from the parsed pin configuration
4347 * This function only works when every pin in line_out_pins[]
4348 * contains atleast one DAC in its connection list. Some 92xx
4349 * codecs are not connected directly to a DAC, such as the 9200
4350 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01004351 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004352static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02004353{
4354 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004355 struct auto_pin_cfg *cfg = &spec->autocfg;
4356 int i;
4357 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004358
Mattc7d4b2f2005-06-27 14:59:41 +02004359 for (i = 0; i < cfg->line_outs; i++) {
4360 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004361 dac = get_unassigned_dac(codec, nid);
4362 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02004363 if (spec->multiout.num_dacs > 0) {
4364 /* we have already working output pins,
4365 * so let's drop the broken ones again
4366 */
4367 cfg->line_outs = spec->multiout.num_dacs;
4368 break;
4369 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004370 /* error out, no available DAC found */
4371 snd_printk(KERN_ERR
4372 "%s: No available DAC for pin 0x%x\n",
4373 __func__, nid);
4374 return -ENODEV;
4375 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004376 add_spec_dacs(spec, dac);
4377 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004378
Takashi Iwai139e0712009-03-06 12:10:41 +01004379 for (i = 0; i < cfg->hp_outs; i++) {
4380 nid = cfg->hp_pins[i];
4381 dac = get_unassigned_dac(codec, nid);
4382 if (dac) {
4383 if (!spec->multiout.hp_nid)
4384 spec->multiout.hp_nid = dac;
4385 else
4386 add_spec_extra_dacs(spec, dac);
4387 }
4388 spec->hp_dacs[i] = dac;
4389 }
4390
4391 for (i = 0; i < cfg->speaker_outs; i++) {
4392 nid = cfg->speaker_pins[i];
4393 dac = get_unassigned_dac(codec, nid);
4394 if (dac)
4395 add_spec_extra_dacs(spec, dac);
4396 spec->speaker_dacs[i] = dac;
4397 }
4398
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004399 /* add line-in as output */
4400 nid = check_line_out_switch(codec);
4401 if (nid) {
4402 dac = get_unassigned_dac(codec, nid);
4403 if (dac) {
4404 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
4405 nid, cfg->line_outs);
4406 cfg->line_out_pins[cfg->line_outs] = nid;
4407 cfg->line_outs++;
4408 spec->line_switch = nid;
4409 add_spec_dacs(spec, dac);
4410 }
4411 }
4412 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004413 nid = check_mic_out_switch(codec, &dac);
4414 if (nid && dac) {
4415 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
4416 nid, cfg->line_outs);
4417 cfg->line_out_pins[cfg->line_outs] = nid;
4418 cfg->line_outs++;
4419 spec->mic_switch = nid;
4420 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02004421 }
4422
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004423 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02004424 spec->multiout.num_dacs,
4425 spec->multiout.dac_nids[0],
4426 spec->multiout.dac_nids[1],
4427 spec->multiout.dac_nids[2],
4428 spec->multiout.dac_nids[3],
4429 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004430
Mattc7d4b2f2005-06-27 14:59:41 +02004431 return 0;
4432}
4433
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004434/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01004435static int create_controls_idx(struct hda_codec *codec, const char *pfx,
4436 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004437{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004438 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004439 char name[32];
4440 int err;
4441
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004442 if (!spec->check_volume_offset) {
4443 unsigned int caps, step, nums, db_scale;
4444 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4445 step = (caps & AC_AMPCAP_STEP_SIZE) >>
4446 AC_AMPCAP_STEP_SIZE_SHIFT;
4447 step = (step + 1) * 25; /* in .01dB unit */
4448 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
4449 AC_AMPCAP_NUM_STEPS_SHIFT;
4450 db_scale = nums * step;
4451 /* if dB scale is over -64dB, and finer enough,
4452 * let's reduce it to half
4453 */
4454 if (db_scale > 6400 && nums >= 0x1f)
4455 spec->volume_offset = nums / 2;
4456 spec->check_volume_offset = 1;
4457 }
4458
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004459 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004460 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004461 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
4462 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004463 if (err < 0)
4464 return err;
4465 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004466 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004467 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
4468 if (err < 0)
4469 return err;
4470 return 0;
4471}
4472
Takashi Iwai668b9652009-03-06 10:13:24 +01004473#define create_controls(codec, pfx, nid, chs) \
4474 create_controls_idx(codec, pfx, 0, nid, chs)
4475
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004476static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
4477{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004478 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004479 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
4480 return 1;
4481 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02004482 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
4483 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004484 spec->multiout.num_dacs++;
4485 }
4486 return 0;
4487}
4488
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004489static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004490{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004491 int i;
4492 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
4493 if (!spec->multiout.extra_out_nid[i]) {
4494 spec->multiout.extra_out_nid[i] = nid;
4495 return 0;
4496 }
4497 }
4498 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
4499 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004500}
4501
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004502/* Create output controls
4503 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
4504 */
4505static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
4506 const hda_nid_t *pins,
4507 const hda_nid_t *dac_nids,
4508 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02004509{
Takashi Iwai76624532008-12-19 10:09:47 +01004510 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01004511 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02004512 "Front", "Surround", NULL /*CLFE*/, "Side"
4513 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004514 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01004515 int i, err;
4516 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004517
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004518 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004519 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004520 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004521 spec->hp_detect = 1;
4522 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004523 nid = dac_nids[i];
4524 if (!nid)
4525 continue;
4526 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02004527 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004528 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004529 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004530 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004531 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004532 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004533 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004534
4535 wid_caps = get_wcaps(codec, nid);
4536
4537 if (wid_caps & AC_WCAP_LR_SWAP) {
4538 err = stac92xx_add_control(spec,
4539 STAC_CTL_WIDGET_CLFE_SWITCH,
4540 "Swap Center/LFE Playback Switch", nid);
4541
4542 if (err < 0)
4543 return err;
4544 }
4545
Mattc7d4b2f2005-06-27 14:59:41 +02004546 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004547 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01004548 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004549 switch (type) {
4550 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01004551 name = "Headphone";
4552 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004553 break;
4554 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01004555 if (num_outs <= 2) {
4556 name = i ? "Bass Speaker" : "Speaker";
4557 idx = 0;
David Henningsson298efee2012-09-06 11:17:58 +02004558 break;
4559 }
4560 /* Fall through in case of multi speaker outs */
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004561 default:
4562 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01004563 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004564 break;
Takashi Iwai76624532008-12-19 10:09:47 +01004565 }
Takashi Iwai668b9652009-03-06 10:13:24 +01004566 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004567 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004568 return err;
4569 }
4570 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004571 return 0;
4572}
4573
Takashi Iwai62cbde12012-09-14 11:58:54 +02004574static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4575 unsigned int dir_mask, unsigned int data);
4576
4577/* hook for controlling mic-mute LED GPIO */
4578static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol,
4579 struct snd_ctl_elem_value *ucontrol)
4580{
4581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4582 struct sigmatel_spec *spec = codec->spec;
4583 int err;
4584 bool mute;
4585
4586 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4587 if (err <= 0)
4588 return err;
4589 mute = !(ucontrol->value.integer.value[0] &&
4590 ucontrol->value.integer.value[1]);
4591 if (spec->mic_mute_led_on != mute) {
4592 spec->mic_mute_led_on = mute;
4593 if (mute)
4594 spec->gpio_data |= spec->mic_mute_led_gpio;
4595 else
4596 spec->gpio_data &= ~spec->mic_mute_led_gpio;
4597 stac_gpio_set(codec, spec->gpio_mask,
4598 spec->gpio_dir, spec->gpio_data);
4599 }
4600 return err;
4601}
4602
Takashi Iwai6479c632009-07-28 18:20:25 +02004603static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
4604 unsigned long sw, int idx)
4605{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004606 struct sigmatel_spec *spec = codec->spec;
4607 struct snd_kcontrol_new *knew;
Takashi Iwai6479c632009-07-28 18:20:25 +02004608 int err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004609
Takashi Iwai6479c632009-07-28 18:20:25 +02004610 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02004611 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02004612 if (err < 0)
4613 return err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004614
4615 knew = add_control_temp(spec,
4616 &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE],
4617 idx, "Capture Switch", sw);
4618 if (!knew)
4619 return -ENOMEM;
4620 /* add a LED hook for some HP laptops */
4621 if (spec->mic_mute_led_gpio)
4622 knew->put = stac92xx_capture_sw_put_led;
4623
Takashi Iwai6479c632009-07-28 18:20:25 +02004624 return 0;
4625}
4626
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004627/* add playback controls from the parsed DAC table */
4628static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
4629 const struct auto_pin_cfg *cfg)
4630{
4631 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004632 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004633 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004634 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004635
4636 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
4637 spec->multiout.dac_nids,
4638 cfg->line_out_type);
4639 if (err < 0)
4640 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004641
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01004642 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004643 err = stac92xx_add_control(spec,
4644 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01004645 "Headphone as Line Out Switch",
4646 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004647 if (err < 0)
4648 return err;
4649 }
4650
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004651 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004652 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004653 break;
4654 nid = cfg->inputs[idx].pin;
4655 err = stac92xx_add_jack_mode_control(codec, nid, idx);
4656 if (err < 0)
4657 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01004658 }
Matt Porter403d1942005-11-29 15:00:51 +01004659
Mattc7d4b2f2005-06-27 14:59:41 +02004660 return 0;
4661}
4662
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004663/* add playback controls for Speaker and HP outputs */
4664static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
4665 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02004666{
4667 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004668 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02004669
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004670 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
4671 spec->hp_dacs, AUTO_PIN_HP_OUT);
4672 if (err < 0)
4673 return err;
4674
4675 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
4676 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
4677 if (err < 0)
4678 return err;
4679
Mattc7d4b2f2005-06-27 14:59:41 +02004680 return 0;
4681}
4682
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004683/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004684static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004685 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004686};
4687
4688/* create mono mux for mono out on capable codecs */
4689static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
4690{
4691 struct sigmatel_spec *spec = codec->spec;
4692 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
4693 int i, num_cons;
4694 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
4695
4696 num_cons = snd_hda_get_connections(codec,
4697 spec->mono_nid,
4698 con_lst,
4699 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004700 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004701 return -EINVAL;
4702
Takashi Iwai10a20af2010-09-09 16:28:02 +02004703 for (i = 0; i < num_cons; i++)
4704 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
4705 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004706
4707 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
4708 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004709}
4710
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004711/* create PC beep volume controls */
4712static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
4713 hda_nid_t nid)
4714{
4715 struct sigmatel_spec *spec = codec->spec;
4716 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004717 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
4718
4719 if (spec->anabeep_nid == nid)
4720 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004721
4722 /* check for mute support for the the amp */
4723 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004724 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004725 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004726 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4727 if (err < 0)
4728 return err;
4729 }
4730
4731 /* check to see if there is volume support for the amp */
4732 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4733 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004734 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004735 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4736 if (err < 0)
4737 return err;
4738 }
4739 return 0;
4740}
4741
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004742#ifdef CONFIG_SND_HDA_INPUT_BEEP
4743#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
4744
4745static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
4746 struct snd_ctl_elem_value *ucontrol)
4747{
4748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4749 ucontrol->value.integer.value[0] = codec->beep->enabled;
4750 return 0;
4751}
4752
4753static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
4754 struct snd_ctl_elem_value *ucontrol)
4755{
4756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004757 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004758}
4759
Takashi Iwai2b635362011-05-02 12:33:43 +02004760static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004761 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4762 .info = stac92xx_dig_beep_switch_info,
4763 .get = stac92xx_dig_beep_switch_get,
4764 .put = stac92xx_dig_beep_switch_put,
4765};
4766
4767static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
4768{
4769 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004770 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004771}
4772#endif
4773
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004774static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
4775{
4776 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02004777 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004778
4779 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004780 hda_nid_t nid;
4781 unsigned int wcaps;
4782 unsigned long val;
4783
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004784 nid = spec->mux_nids[i];
4785 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02004786 if (!(wcaps & AC_WCAP_OUT_AMP))
4787 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004788
Takashi Iwai667067d2009-08-13 18:14:42 +02004789 /* check whether already the same control was created as
4790 * normal Capture Volume.
4791 */
4792 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4793 for (j = 0; j < spec->num_caps; j++) {
4794 if (spec->capvols[j] == val)
4795 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004796 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004797 if (j < spec->num_caps)
4798 continue;
4799
4800 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
4801 "Mux Capture Volume", val);
4802 if (err < 0)
4803 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004804 }
4805 return 0;
4806};
4807
Takashi Iwaiea734962011-01-17 11:29:34 +01004808static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04004809 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02004810};
4811
4812static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
4813{
4814 struct sigmatel_spec *spec = codec->spec;
4815 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01004816 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004817 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04004818 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02004819
4820 num_cons = snd_hda_get_connections(codec,
4821 spec->smux_nids[0],
4822 con_lst,
4823 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004824 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02004825 return -EINVAL;
4826
Matthew Ranostay65973632008-09-16 10:39:37 -04004827 if (!labels)
4828 labels = stac92xx_spdif_labels;
4829
Takashi Iwai10a20af2010-09-09 16:28:02 +02004830 for (i = 0; i < num_cons; i++)
4831 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004832
4833 return 0;
4834}
4835
Matt Porter8b657272006-10-26 17:12:59 +02004836/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004837static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02004838 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
4839 "Digital Mic 3", "Digital Mic 4"
4840};
4841
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004842static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
4843 int idx)
4844{
4845 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4846 int nums;
4847 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
4848 if (idx >= 0 && idx < nums)
4849 return conn[idx];
4850 return 0;
4851}
4852
Takashi Iwai8d087c72011-06-28 12:45:47 +02004853/* look for NID recursively */
4854#define get_connection_index(codec, mux, nid) \
4855 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004856
Takashi Iwai667067d2009-08-13 18:14:42 +02004857/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02004858/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02004859static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004860 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02004861{
4862 unsigned int caps, nums;
4863 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02004864 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02004865
Takashi Iwai96f845d2009-08-29 00:49:36 +02004866 if (direction == HDA_OUTPUT)
4867 caps = AC_WCAP_OUT_AMP;
4868 else
4869 caps = AC_WCAP_IN_AMP;
4870 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02004871 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004872 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02004873 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
4874 if (!nums)
4875 return 0;
4876 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004877 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
4878 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02004879 if (err < 0)
4880 return err;
4881 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02004882}
4883
Matt Porter8b657272006-10-26 17:12:59 +02004884/* create playback/capture controls for input pins on dmic capable codecs */
4885static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
4886 const struct auto_pin_cfg *cfg)
4887{
4888 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02004889 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004890 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004891 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02004892 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02004893
Takashi Iwai10a20af2010-09-09 16:28:02 +02004894 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02004895
Matt Porter8b657272006-10-26 17:12:59 +02004896 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01004897 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004898 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01004899 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02004900
Takashi Iwai667067d2009-08-13 18:14:42 +02004901 nid = spec->dmic_nids[i];
4902 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
4903 continue;
4904 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02004905 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
4906 continue;
4907
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004908 index = get_connection_index(codec, spec->dmux_nids[0], nid);
4909 if (index < 0)
4910 continue;
4911
Takashi Iwai201e06f2011-11-16 15:33:26 +01004912 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4913 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02004914 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01004915 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
4916 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02004917
Takashi Iwai10a20af2010-09-09 16:28:02 +02004918 err = create_elem_capture_vol(codec, nid, label, type_idx,
4919 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004920 if (err < 0)
4921 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004922 if (!err) {
4923 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02004924 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02004925 if (err < 0)
4926 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004927 if (!err) {
4928 nid = get_connected_node(codec,
4929 spec->dmux_nids[0], index);
4930 if (nid)
4931 err = create_elem_capture_vol(codec,
4932 nid, label,
4933 type_idx, HDA_INPUT);
4934 if (err < 0)
4935 return err;
4936 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02004937 }
Matt Porter8b657272006-10-26 17:12:59 +02004938 }
4939
4940 return 0;
4941}
4942
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004943static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02004944 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004945{
4946 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004947 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004948
4949 if (!nid)
4950 return 0;
4951 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004952 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004953 switch (snd_hda_get_input_pin_attr(cfg)) {
4954 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004955 if (*fixed)
4956 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004957 if (type != AC_JACK_MIC_IN)
4958 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004959 *fixed = nid;
4960 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004961 case INPUT_PIN_ATTR_UNUSED:
4962 break;
4963 case INPUT_PIN_ATTR_DOCK:
4964 if (*dock)
4965 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004966 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
4967 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004968 *dock = nid;
4969 break;
4970 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004971 if (*ext)
4972 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004973 if (type != AC_JACK_MIC_IN)
4974 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004975 *ext = nid;
4976 break;
4977 }
4978 return 0;
4979}
4980
4981static int set_mic_route(struct hda_codec *codec,
4982 struct sigmatel_mic_route *mic,
4983 hda_nid_t pin)
4984{
4985 struct sigmatel_spec *spec = codec->spec;
4986 struct auto_pin_cfg *cfg = &spec->autocfg;
4987 int i;
4988
4989 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02004990 if (pin == 0)
4991 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004992 for (i = 0; i < cfg->num_inputs; i++) {
4993 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004994 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004995 }
Takashi Iwai86e29592010-09-09 14:50:17 +02004996 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004997 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004998 i = get_connection_index(codec, spec->mux_nids[0], pin);
4999 if (i < 0)
5000 return -1;
5001 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02005002 mic->dmux_idx = -1;
5003 if (spec->dmux_nids)
5004 mic->dmux_idx = get_connection_index(codec,
5005 spec->dmux_nids[0],
5006 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005007 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005008 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005009 i = get_connection_index(codec, spec->dmux_nids[0], pin);
5010 if (i < 0)
5011 return -1;
5012 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02005013 mic->mux_idx = -1;
5014 if (spec->mux_nids)
5015 mic->mux_idx = get_connection_index(codec,
5016 spec->mux_nids[0],
5017 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005018 }
5019 return 0;
5020}
5021
5022/* return non-zero if the device is for automatic mic switch */
5023static int stac_check_auto_mic(struct hda_codec *codec)
5024{
5025 struct sigmatel_spec *spec = codec->spec;
5026 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02005027 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005028 int i;
5029
Charles Chin99077902010-09-17 10:22:32 +02005030 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005031 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02005032 if (check_mic_pin(codec, cfg->inputs[i].pin,
5033 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005034 return 0;
5035 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02005036 if (check_mic_pin(codec, spec->dmic_nids[i],
5037 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005038 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01005039 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02005040 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005041 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005042 return 0; /* no unsol support */
5043 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02005044 set_mic_route(codec, &spec->int_mic, fixed) ||
5045 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005046 return 0; /* something is wrong */
5047 return 1;
5048}
5049
Mattc7d4b2f2005-06-27 14:59:41 +02005050/* create playback/capture controls for input pins */
5051static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
5052{
5053 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005054 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02005055 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005056 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02005057
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005058 for (i = 0; i < cfg->num_inputs; i++) {
5059 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005060 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02005061
Takashi Iwai314634b2006-09-21 11:56:18 +02005062 index = -1;
5063 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02005064 index = get_connection_index(codec, spec->mux_nids[j],
5065 nid);
5066 if (index >= 0)
5067 break;
Mattc7d4b2f2005-06-27 14:59:41 +02005068 }
Takashi Iwai667067d2009-08-13 18:14:42 +02005069 if (index < 0)
5070 continue;
5071
Takashi Iwai10a20af2010-09-09 16:28:02 +02005072 label = hda_get_autocfg_input_label(codec, cfg, i);
5073 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005074
Takashi Iwai667067d2009-08-13 18:14:42 +02005075 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02005076 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02005077 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02005078 if (err < 0)
5079 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02005080 }
Takashi Iwai5207e102009-07-30 13:09:08 +02005081 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02005082
Steve Longerbeam7b043892007-05-03 20:50:03 +02005083 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02005084 /*
5085 * Set the current input for the muxes.
5086 * The STAC9221 has two input muxes with identical source
5087 * NID lists. Hopefully this won't get confused.
5088 */
5089 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005090 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
5091 AC_VERB_SET_CONNECT_SEL,
5092 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005093 }
5094 }
5095
Mattc7d4b2f2005-06-27 14:59:41 +02005096 return 0;
5097}
5098
Mattc7d4b2f2005-06-27 14:59:41 +02005099static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
5100{
5101 struct sigmatel_spec *spec = codec->spec;
5102 int i;
5103
5104 for (i = 0; i < spec->autocfg.line_outs; i++) {
5105 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5106 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
5107 }
5108}
5109
5110static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
5111{
5112 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005113 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005114
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005115 for (i = 0; i < spec->autocfg.hp_outs; i++) {
5116 hda_nid_t pin;
5117 pin = spec->autocfg.hp_pins[i];
5118 if (pin) /* connect to front */
5119 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5120 }
5121 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
5122 hda_nid_t pin;
5123 pin = spec->autocfg.speaker_pins[i];
5124 if (pin) /* connect to front */
5125 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
5126 }
Mattc7d4b2f2005-06-27 14:59:41 +02005127}
5128
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01005129static int is_dual_headphones(struct hda_codec *codec)
5130{
5131 struct sigmatel_spec *spec = codec->spec;
5132 int i, valid_hps;
5133
5134 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
5135 spec->autocfg.hp_outs <= 1)
5136 return 0;
5137 valid_hps = 0;
5138 for (i = 0; i < spec->autocfg.hp_outs; i++) {
5139 hda_nid_t nid = spec->autocfg.hp_pins[i];
5140 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
5141 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
5142 continue;
5143 valid_hps++;
5144 }
5145 return (valid_hps > 1);
5146}
5147
5148
Charles Chin9009b0e2011-11-03 10:27:27 +01005149static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02005150{
5151 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01005152 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005153 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02005154 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02005155
Matt Porter8b657272006-10-26 17:12:59 +02005156 if ((err = snd_hda_parse_pin_def_config(codec,
5157 &spec->autocfg,
5158 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005159 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005160 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01005161 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02005162
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005163 /* If we have no real line-out pin and multiple hp-outs, HPs should
5164 * be set up as multi-channel outputs.
5165 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01005166 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005167 /* Copy hp_outs to line_outs, backup line_outs in
5168 * speaker_outs so that the following routines can handle
5169 * HP pins as primary outputs.
5170 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005171 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005172 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
5173 sizeof(spec->autocfg.line_out_pins));
5174 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
5175 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
5176 sizeof(spec->autocfg.hp_pins));
5177 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005178 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5179 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005180 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005181 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005182 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005183 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
5184 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005185 u32 caps = query_amp_caps(codec,
5186 spec->autocfg.mono_out_pin, dir);
5187 hda_nid_t conn_list[1];
5188
5189 /* get the mixer node and then the mono mux if it exists */
5190 if (snd_hda_get_connections(codec,
5191 spec->autocfg.mono_out_pin, conn_list, 1) &&
5192 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02005193 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01005194
5195 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02005196 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01005197 /* LR swap check, some stac925x have a mux that
5198 * changes the DACs output path instead of the
5199 * mono-mux path.
5200 */
5201 if (wid_type == AC_WID_AUD_SEL &&
5202 !(wcaps & AC_WCAP_LR_SWAP))
5203 spec->mono_nid = conn_list[0];
5204 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005205 if (dir) {
5206 hda_nid_t nid = spec->autocfg.mono_out_pin;
5207
5208 /* most mono outs have a least a mute/unmute switch */
5209 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
5210 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
5211 "Mono Playback Switch",
5212 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01005213 if (err < 0)
5214 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005215 /* check for volume support for the amp */
5216 if ((caps & AC_AMPCAP_NUM_STEPS)
5217 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
5218 err = stac92xx_add_control(spec,
5219 STAC_CTL_WIDGET_VOL,
5220 "Mono Playback Volume",
5221 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
5222 if (err < 0)
5223 return err;
5224 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01005225 }
5226
5227 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
5228 AC_PINCTL_OUT_EN);
5229 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01005230
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005231 if (!spec->multiout.num_dacs) {
5232 err = stac92xx_auto_fill_dac_nids(codec);
5233 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02005234 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01005235 err = stac92xx_auto_create_multi_out_ctls(codec,
5236 &spec->autocfg);
5237 if (err < 0)
5238 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005239 }
Mattc7d4b2f2005-06-27 14:59:41 +02005240
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005241 /* setup analog beep controls */
5242 if (spec->anabeep_nid > 0) {
5243 err = stac92xx_auto_create_beep_ctls(codec,
5244 spec->anabeep_nid);
5245 if (err < 0)
5246 return err;
5247 }
5248
5249 /* setup digital beep controls and input device */
5250#ifdef CONFIG_SND_HDA_INPUT_BEEP
5251 if (spec->digbeep_nid > 0) {
5252 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005253 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005254
5255 err = stac92xx_auto_create_beep_ctls(codec, nid);
5256 if (err < 0)
5257 return err;
5258 err = snd_hda_attach_beep_device(codec, nid);
5259 if (err < 0)
5260 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005261 if (codec->beep) {
5262 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005263 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01005264 /* if no beep switch is available, make its own one */
5265 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
5266 if (!(caps & AC_AMPCAP_MUTE)) {
5267 err = stac92xx_beep_switch_ctl(codec);
5268 if (err < 0)
5269 return err;
5270 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01005271 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005272 }
5273#endif
5274
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005275 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005276 if (err < 0)
5277 return err;
5278
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005279 /* All output parsing done, now restore the swapped hp pins */
5280 if (hp_swap) {
5281 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
5282 sizeof(spec->autocfg.hp_pins));
5283 spec->autocfg.hp_outs = spec->autocfg.line_outs;
5284 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
5285 spec->autocfg.line_outs = 0;
5286 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005287
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005288 if (stac_check_auto_mic(codec)) {
5289 spec->auto_mic = 1;
5290 /* only one capture for auto-mic */
5291 spec->num_adcs = 1;
5292 spec->num_caps = 1;
5293 spec->num_muxes = 1;
5294 }
5295
Takashi Iwai6479c632009-07-28 18:20:25 +02005296 for (i = 0; i < spec->num_caps; i++) {
5297 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
5298 spec->capsws[i], i);
5299 if (err < 0)
5300 return err;
5301 }
5302
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01005303 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005304 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005305 return err;
5306
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005307 if (spec->mono_nid > 0) {
5308 err = stac92xx_auto_create_mono_output_ctls(codec);
5309 if (err < 0)
5310 return err;
5311 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005312 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02005313 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
5314 &spec->autocfg)) < 0)
5315 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02005316 if (spec->num_muxes > 0) {
5317 err = stac92xx_auto_create_mux_input_ctls(codec);
5318 if (err < 0)
5319 return err;
5320 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02005321 if (spec->num_smuxes > 0) {
5322 err = stac92xx_auto_create_spdif_mux_ctls(codec);
5323 if (err < 0)
5324 return err;
5325 }
Matt Porter8b657272006-10-26 17:12:59 +02005326
Takashi Iwaie3c75962009-01-23 11:57:22 +01005327 err = stac92xx_add_input_source(spec);
5328 if (err < 0)
5329 return err;
5330
Mattc7d4b2f2005-06-27 14:59:41 +02005331 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01005332 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02005333 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02005334
Charles Chin9009b0e2011-11-03 10:27:27 +01005335 /* find digital out and in converters */
5336 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
5337 unsigned int wid_caps = get_wcaps(codec, i);
5338 if (wid_caps & AC_WCAP_DIGITAL) {
5339 switch (get_wcaps_type(wid_caps)) {
5340 case AC_WID_AUD_OUT:
5341 if (!dig_out)
5342 dig_out = i;
5343 break;
5344 case AC_WID_AUD_IN:
5345 if (!dig_in)
5346 dig_in = i;
5347 break;
5348 }
5349 }
5350 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005351 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005352 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005353 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005354 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02005355
Takashi Iwai603c4012008-07-30 15:01:44 +02005356 if (spec->kctls.list)
5357 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005358
5359 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05005360 if (!spec->dinput_mux)
5361 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005362 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005363 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02005364 return 1;
5365}
5366
Takashi Iwai82bc9552006-03-21 11:24:42 +01005367/* add playback controls for HP output */
5368static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
5369 struct auto_pin_cfg *cfg)
5370{
5371 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005372 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01005373
5374 if (! pin)
5375 return 0;
5376
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005377 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01005378 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005379
5380 return 0;
5381}
5382
Richard Fish160ea0d2006-09-06 13:58:25 +02005383/* add playback controls for LFE output */
5384static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
5385 struct auto_pin_cfg *cfg)
5386{
5387 struct sigmatel_spec *spec = codec->spec;
5388 int err;
5389 hda_nid_t lfe_pin = 0x0;
5390 int i;
5391
5392 /*
5393 * search speaker outs and line outs for a mono speaker pin
5394 * with an amp. If one is found, add LFE controls
5395 * for it.
5396 */
5397 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
5398 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005399 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005400 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5401 if (wcaps == AC_WCAP_OUT_AMP)
5402 /* found a mono speaker with an amp, must be lfe */
5403 lfe_pin = pin;
5404 }
5405
5406 /* if speaker_outs is 0, then speakers may be in line_outs */
5407 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
5408 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
5409 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005410 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01005411 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01005412 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005413 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005414 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5415 if (wcaps == AC_WCAP_OUT_AMP)
5416 /* found a mono speaker with an amp,
5417 must be lfe */
5418 lfe_pin = pin;
5419 }
5420 }
5421 }
5422
5423 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01005424 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02005425 if (err < 0)
5426 return err;
5427 }
5428
5429 return 0;
5430}
5431
Mattc7d4b2f2005-06-27 14:59:41 +02005432static int stac9200_parse_auto_config(struct hda_codec *codec)
5433{
5434 struct sigmatel_spec *spec = codec->spec;
5435 int err;
5436
Kailang Yangdf694da2005-12-05 19:42:22 +01005437 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005438 return err;
5439
5440 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
5441 return err;
5442
Takashi Iwai82bc9552006-03-21 11:24:42 +01005443 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
5444 return err;
5445
Richard Fish160ea0d2006-09-06 13:58:25 +02005446 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
5447 return err;
5448
Takashi Iwai355a0ec2008-11-11 16:46:19 +01005449 if (spec->num_muxes > 0) {
5450 err = stac92xx_auto_create_mux_input_ctls(codec);
5451 if (err < 0)
5452 return err;
5453 }
5454
Takashi Iwaie3c75962009-01-23 11:57:22 +01005455 err = stac92xx_add_input_source(spec);
5456 if (err < 0)
5457 return err;
5458
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005459 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02005460 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005461 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02005462 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02005463
Takashi Iwai603c4012008-07-30 15:01:44 +02005464 if (spec->kctls.list)
5465 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005466
5467 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02005468 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02005469
5470 return 1;
5471}
5472
Sam Revitch62fe78e2006-05-10 15:09:17 +02005473/*
5474 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
5475 * funky external mute control using GPIO pins.
5476 */
5477
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005478static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005479 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02005480{
5481 unsigned int gpiostate, gpiomask, gpiodir;
5482
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005483 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
5484
Sam Revitch62fe78e2006-05-10 15:09:17 +02005485 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5486 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005487 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005488
5489 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5490 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005491 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005492
5493 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5494 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005495 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005496
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005497 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005498 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
5499
5500 snd_hda_codec_write(codec, codec->afg, 0,
5501 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005502 snd_hda_codec_read(codec, codec->afg, 0,
5503 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005504
5505 msleep(1);
5506
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005507 snd_hda_codec_read(codec, codec->afg, 0,
5508 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005509}
5510
Takashi Iwai3a938972011-10-28 01:16:55 +02005511static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005512 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005513{
Takashi Iwai3a938972011-10-28 01:16:55 +02005514 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005515
Takashi Iwai3a938972011-10-28 01:16:55 +02005516 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005517 if (!event)
5518 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02005519 event->action = type;
5520 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005521
Takashi Iwai3a938972011-10-28 01:16:55 +02005522 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005523}
5524
David Henningsson29adc4b2012-09-25 11:31:00 +02005525static void handle_unsol_event(struct hda_codec *codec,
5526 struct hda_jack_tbl *event);
5527
Takashi Iwai62558ce2009-07-29 14:23:09 +02005528/* check if given nid is a valid pin and no other events are assigned
5529 * to it. If OK, assign the event, set the unsol flag, and returns 1.
5530 * Otherwise, returns zero.
5531 */
5532static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
5533 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02005534{
Takashi Iwai3a938972011-10-28 01:16:55 +02005535 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005536
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005537 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02005538 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02005539 event = snd_hda_jack_tbl_new(codec, nid);
5540 if (!event)
5541 return -ENOMEM;
5542 if (event->action && event->action != type)
5543 return 0;
5544 event->action = type;
David Henningsson29adc4b2012-09-25 11:31:00 +02005545 event->callback = handle_unsol_event;
Takashi Iwai3a938972011-10-28 01:16:55 +02005546 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02005547 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02005548}
5549
Takashi Iwaib4ead012012-01-23 18:23:36 +01005550static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005551{
5552 int i;
5553 for (i = 0; i < cfg->hp_outs; i++)
5554 if (cfg->hp_pins[i] == nid)
5555 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01005556 for (i = 0; i < cfg->line_outs; i++)
5557 if (cfg->line_out_pins[i] == nid)
5558 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005559 return 0; /* nid is not a HP-Out */
5560};
5561
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005562static void stac92xx_power_down(struct hda_codec *codec)
5563{
5564 struct sigmatel_spec *spec = codec->spec;
5565
5566 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02005567 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005568 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005569 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005570 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005571 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5572}
5573
Takashi Iwaif73d3582008-11-25 08:21:51 +01005574static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5575 int enable);
5576
Takashi Iwaibc759722013-01-11 17:40:31 +01005577static inline bool get_int_hint(struct hda_codec *codec, const char *key,
5578 int *valp)
Takashi Iwai014c41f2009-12-27 13:53:24 +01005579{
Takashi Iwaibc759722013-01-11 17:40:31 +01005580 return !snd_hda_get_int_hint(codec, key, valp);
Takashi Iwai014c41f2009-12-27 13:53:24 +01005581}
5582
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005583/* override some hints from the hwdep entry */
5584static void stac_store_hints(struct hda_codec *codec)
5585{
5586 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005587 int val;
5588
5589 val = snd_hda_get_bool_hint(codec, "hp_detect");
5590 if (val >= 0)
5591 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01005592 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005593 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
5594 spec->gpio_mask;
5595 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01005596 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
5597 spec->gpio_mask &= spec->gpio_mask;
5598 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
5599 spec->gpio_dir &= spec->gpio_mask;
5600 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
5601 spec->eapd_mask &= spec->gpio_mask;
5602 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
5603 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005604 val = snd_hda_get_bool_hint(codec, "eapd_switch");
5605 if (val >= 0)
5606 spec->eapd_switch = val;
5607}
5608
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005609static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
5610 const hda_nid_t *pins)
5611{
5612 while (num_pins--)
5613 stac_issue_unsol_event(codec, *pins++);
5614}
5615
5616/* fake event to set up pins */
5617static void stac_fake_hp_events(struct hda_codec *codec)
5618{
5619 struct sigmatel_spec *spec = codec->spec;
5620
5621 if (spec->autocfg.hp_outs)
5622 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
5623 spec->autocfg.hp_pins);
5624 if (spec->autocfg.line_outs &&
5625 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
5626 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
5627 spec->autocfg.line_out_pins);
5628}
5629
Mattc7d4b2f2005-06-27 14:59:41 +02005630static int stac92xx_init(struct hda_codec *codec)
5631{
5632 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005633 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005634 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01005635 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005636
David Henningsson5e68fb32012-08-16 14:11:09 +02005637 if (spec->init)
5638 snd_hda_sequence_write(codec, spec->init);
Mattc7d4b2f2005-06-27 14:59:41 +02005639
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005640 snd_hda_apply_verbs(codec);
5641
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005642 /* power down adcs initially */
5643 if (spec->powerdown_adcs)
5644 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005645 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005646 spec->adc_nids[i], 0,
5647 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005648
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005649 /* override some hints */
5650 stac_store_hints(codec);
5651
Takashi Iwaif73d3582008-11-25 08:21:51 +01005652 /* set up GPIO */
5653 gpio = spec->gpio_data;
5654 /* turn on EAPD statically when spec->eapd_switch isn't set.
5655 * otherwise, unsol event will turn it on/off dynamically
5656 */
5657 if (!spec->eapd_switch)
5658 gpio |= spec->eapd_mask;
5659 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
5660
Takashi Iwai82bc9552006-03-21 11:24:42 +01005661 /* set up pins */
5662 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02005663 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005664 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005665 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005666 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005667 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02005668 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
5669 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005670 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02005671 for (i = 0; i < cfg->line_outs; i++) {
5672 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005673 enable_pin_detect(codec, nid, STAC_LO_EVENT);
5674 }
5675 }
5676
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01005677 /* force to enable the first line-out; the others are set up
5678 * in unsol_event
5679 */
5680 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005681 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005682 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005683 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005684 } else {
5685 stac92xx_auto_init_multi_out(codec);
5686 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005687 for (i = 0; i < cfg->hp_outs; i++)
5688 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005689 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005690 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02005691 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005692 if (spec->dmux_nids)
5693 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02005694 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005695 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
5696 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02005697 if (enable_pin_detect(codec, spec->dock_mic.pin,
5698 STAC_MIC_EVENT))
5699 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005700 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005701 for (i = 0; i < cfg->num_inputs; i++) {
5702 hda_nid_t nid = cfg->inputs[i].pin;
5703 int type = cfg->inputs[i].type;
5704 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02005705 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005706 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02005707 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005708 pinctl |= AC_PINCTL_IN_EN;
5709 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5710 } else {
5711 pinctl = snd_hda_codec_read(codec, nid, 0,
5712 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5713 /* if PINCTL already set then skip */
5714 /* Also, if both INPUT and OUTPUT are set,
5715 * it must be a BIOS bug; need to override, too
5716 */
5717 if (!(pinctl & AC_PINCTL_IN_EN) ||
5718 (pinctl & AC_PINCTL_OUT_EN)) {
5719 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005720 pinctl |= AC_PINCTL_IN_EN;
5721 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01005722 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005723 }
5724 conf = snd_hda_codec_get_pincfg(codec, nid);
5725 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
5726 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
5727 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01005728 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01005729 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005730 for (i = 0; i < spec->num_dmics; i++)
5731 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
5732 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005733 if (cfg->dig_out_pins[0])
5734 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01005735 AC_PINCTL_OUT_EN);
5736 if (cfg->dig_in_pin)
5737 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
5738 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005739 for (i = 0; i < spec->num_pwrs; i++) {
5740 hda_nid_t nid = spec->pwr_nids[i];
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005741 unsigned int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005742
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005743 def_conf = snd_hda_codec_get_pincfg(codec, nid);
5744 def_conf = get_defcfg_connect(def_conf);
5745 if (def_conf == AC_JACK_PORT_NONE) {
5746 /* power off unused ports */
5747 stac_toggle_power_map(codec, nid, 0);
5748 continue;
5749 }
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005750 if (def_conf == AC_JACK_PORT_FIXED) {
5751 /* no need for jack detection for fixed pins */
5752 stac_toggle_power_map(codec, nid, 1);
5753 continue;
5754 }
Takashi Iwaieb632122008-12-19 16:39:48 +01005755 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01005756 /* or when the VREF is used for controlling LED */
5757 if (!spec->hp_detect ||
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005758 spec->vref_mute_led_nid == nid ||
5759 !is_jack_detectable(codec, nid)) {
Takashi Iwaieb632122008-12-19 16:39:48 +01005760 stac_toggle_power_map(codec, nid, 1);
5761 continue;
5762 }
5763
Takashi Iwaib4ead012012-01-23 18:23:36 +01005764 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01005765 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005766
Takashi Iwaif73d3582008-11-25 08:21:51 +01005767 pinctl = snd_hda_codec_read(codec, nid, 0,
5768 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5769 /* outputs are only ports capable of power management
5770 * any attempts on powering down a input port cause the
5771 * referenced VREF to act quirky.
5772 */
Takashi Iwaieb632122008-12-19 16:39:48 +01005773 if (pinctl & AC_PINCTL_IN_EN) {
5774 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005775 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01005776 }
Charles Chinafef2cf2011-11-11 08:05:28 +01005777 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02005778 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01005779 continue;
5780 }
5781 /* none of the above, turn the port OFF */
5782 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005783 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01005784
Takashi Iwaic21bd022010-02-08 15:16:08 +01005785 /* sync mute LED */
Takashi Iwai1f43f6c2012-07-31 10:40:05 +02005786 if (spec->gpio_led) {
5787 if (spec->vmaster_mute.hook)
5788 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5789 else /* the very first init call doesn't have vmaster yet */
5790 stac92xx_update_led_status(codec, false);
5791 }
Takashi Iwaic8822462012-05-15 09:11:36 +02005792
5793 /* sync the power-map */
5794 if (spec->num_pwrs)
5795 snd_hda_codec_write(codec, codec->afg, 0,
5796 AC_VERB_IDT_SET_POWER_MAP,
5797 spec->power_map_bits);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005798 if (spec->dac_list)
5799 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02005800 return 0;
5801}
5802
Takashi Iwai603c4012008-07-30 15:01:44 +02005803static void stac92xx_free_kctls(struct hda_codec *codec)
5804{
5805 struct sigmatel_spec *spec = codec->spec;
5806
5807 if (spec->kctls.list) {
5808 struct snd_kcontrol_new *kctl = spec->kctls.list;
5809 int i;
5810 for (i = 0; i < spec->kctls.used; i++)
5811 kfree(kctl[i].name);
5812 }
5813 snd_array_free(&spec->kctls);
5814}
5815
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005816static void stac92xx_shutup_pins(struct hda_codec *codec)
5817{
5818 unsigned int i, def_conf;
5819
5820 if (codec->bus->shutdown)
5821 return;
5822 for (i = 0; i < codec->init_pins.used; i++) {
5823 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
5824 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
5825 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005826 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005827 }
5828}
5829
Takashi Iwai167eae52009-11-06 15:47:50 +01005830static void stac92xx_shutup(struct hda_codec *codec)
5831{
5832 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01005833
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005834 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01005835
5836 if (spec->eapd_mask)
5837 stac_gpio_set(codec, spec->gpio_mask,
5838 spec->gpio_dir, spec->gpio_data &
5839 ~spec->eapd_mask);
5840}
5841
Matt2f2f4252005-04-13 14:45:30 +02005842static void stac92xx_free(struct hda_codec *codec)
5843{
Mattc7d4b2f2005-06-27 14:59:41 +02005844 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005845
5846 if (! spec)
5847 return;
5848
Mattc7d4b2f2005-06-27 14:59:41 +02005849 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005850 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02005851}
5852
Matt4e550962005-07-04 17:51:39 +02005853static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
5854 unsigned int flag)
5855{
Takashi Iwai8ce84192009-01-22 16:59:20 +01005856 unsigned int old_ctl, pin_ctl;
5857
5858 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02005859 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02005860
Takashi Iwaif9acba42007-05-29 18:01:06 +02005861 if (pin_ctl & AC_PINCTL_IN_EN) {
5862 /*
5863 * we need to check the current set-up direction of
5864 * shared input pins since they can be switched via
5865 * "xxx as Output" mixer switch
5866 */
5867 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005868 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02005869 return;
5870 }
5871
Takashi Iwai8ce84192009-01-22 16:59:20 +01005872 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02005873 /* if setting pin direction bits, clear the current
5874 direction bits first */
5875 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
5876 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
5877
Takashi Iwai8ce84192009-01-22 16:59:20 +01005878 pin_ctl |= flag;
5879 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005880 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02005881}
5882
5883static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
5884 unsigned int flag)
5885{
5886 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
5887 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01005888 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005889 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02005890}
5891
Takashi Iwaid56757a2009-11-18 08:00:14 +01005892static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02005893{
5894 if (!nid)
5895 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01005896 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02005897}
5898
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005899static void stac92xx_line_out_detect(struct hda_codec *codec,
5900 int presence)
5901{
5902 struct sigmatel_spec *spec = codec->spec;
5903 struct auto_pin_cfg *cfg = &spec->autocfg;
5904 int i;
5905
David Henningsson042b92c2012-08-22 16:10:43 +02005906 if (cfg->speaker_outs == 0)
5907 return;
5908
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005909 for (i = 0; i < cfg->line_outs; i++) {
5910 if (presence)
5911 break;
5912 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
5913 if (presence) {
5914 unsigned int pinctl;
5915 pinctl = snd_hda_codec_read(codec,
5916 cfg->line_out_pins[i], 0,
5917 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5918 if (pinctl & AC_PINCTL_IN_EN)
5919 presence = 0; /* mic- or line-input */
5920 }
5921 }
5922
5923 if (presence) {
5924 /* disable speakers */
5925 for (i = 0; i < cfg->speaker_outs; i++)
5926 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
5927 AC_PINCTL_OUT_EN);
5928 if (spec->eapd_mask && spec->eapd_switch)
5929 stac_gpio_set(codec, spec->gpio_mask,
5930 spec->gpio_dir, spec->gpio_data &
5931 ~spec->eapd_mask);
5932 } else {
5933 /* enable speakers */
5934 for (i = 0; i < cfg->speaker_outs; i++)
5935 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
5936 AC_PINCTL_OUT_EN);
5937 if (spec->eapd_mask && spec->eapd_switch)
5938 stac_gpio_set(codec, spec->gpio_mask,
5939 spec->gpio_dir, spec->gpio_data |
5940 spec->eapd_mask);
5941 }
5942}
5943
Takashi Iwaid7a89432008-11-12 09:48:04 +01005944/* return non-zero if the hp-pin of the given array index isn't
5945 * a jack-detection target
5946 */
5947static int no_hp_sensing(struct sigmatel_spec *spec, int i)
5948{
5949 struct auto_pin_cfg *cfg = &spec->autocfg;
5950
5951 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005952 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005953 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005954 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005955 return 1;
5956 /* ignore if the pin is set as line-out */
5957 if (cfg->hp_pins[i] == spec->hp_switch)
5958 return 1;
5959 return 0;
5960}
5961
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005962static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02005963{
5964 struct sigmatel_spec *spec = codec->spec;
5965 struct auto_pin_cfg *cfg = &spec->autocfg;
5966 int i, presence;
5967
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005968 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005969 if (spec->gpio_mute)
5970 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
5971 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
5972
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005973 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005974 if (presence)
5975 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01005976 if (no_hp_sensing(spec, i))
5977 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005978 presence = get_pin_presence(codec, cfg->hp_pins[i]);
5979 if (presence) {
5980 unsigned int pinctl;
5981 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
5982 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5983 if (pinctl & AC_PINCTL_IN_EN)
5984 presence = 0; /* mic- or line-input */
5985 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005986 }
Matt4e550962005-07-04 17:51:39 +02005987
5988 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005989 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005990 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005991 stac92xx_reset_pinctl(codec, spec->hp_switch,
5992 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005993 for (i = 0; i < cfg->line_outs; i++)
5994 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
5995 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005996 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005997 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005998 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005999 stac92xx_set_pinctl(codec, spec->hp_switch,
6000 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02006001 for (i = 0; i < cfg->line_outs; i++)
6002 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
6003 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02006004 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006005 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01006006 /* toggle hp outs */
6007 for (i = 0; i < cfg->hp_outs; i++) {
6008 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
6009 if (no_hp_sensing(spec, i))
6010 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01006011 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01006012 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01006013#if 0 /* FIXME */
6014/* Resetting the pinctl like below may lead to (a sort of) regressions
6015 * on some devices since they use the HP pin actually for line/speaker
6016 * outs although the default pin config shows a different pin (that is
6017 * wrong and useless).
6018 *
6019 * So, it's basically a problem of default pin configs, likely a BIOS issue.
6020 * But, disabling the code below just works around it, and I'm too tired of
6021 * bug reports with such devices...
6022 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01006023 else
6024 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01006025#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01006026 }
Matt4e550962005-07-04 17:51:39 +02006027}
6028
Takashi Iwaif73d3582008-11-25 08:21:51 +01006029static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
6030 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006031{
6032 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01006033 unsigned int idx, val;
6034
6035 for (idx = 0; idx < spec->num_pwrs; idx++) {
6036 if (spec->pwr_nids[idx] == nid)
6037 break;
6038 }
6039 if (idx >= spec->num_pwrs)
6040 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006041
Charles Chinafef2cf2011-11-11 08:05:28 +01006042 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006043
Takashi Iwaic8822462012-05-15 09:11:36 +02006044 val = spec->power_map_bits;
Takashi Iwaif73d3582008-11-25 08:21:51 +01006045 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006046 val &= ~idx;
6047 else
6048 val |= idx;
6049
6050 /* power down unused output ports */
Takashi Iwaic8822462012-05-15 09:11:36 +02006051 if (val != spec->power_map_bits) {
6052 spec->power_map_bits = val;
6053 snd_hda_codec_write(codec, codec->afg, 0,
6054 AC_VERB_IDT_SET_POWER_MAP, val);
6055 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04006056}
6057
Takashi Iwaif73d3582008-11-25 08:21:51 +01006058static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
6059{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01006060 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01006061}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006062
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006063/* get the pin connection (fixed, none, etc) */
6064static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
6065{
6066 struct sigmatel_spec *spec = codec->spec;
6067 unsigned int cfg;
6068
6069 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
6070 return get_defcfg_connect(cfg);
6071}
6072
6073static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006074 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006075{
6076 struct sigmatel_spec *spec = codec->spec;
6077 int idx, num;
6078 unsigned int def_conf;
6079
6080 for (num = 0; num < num_nids; num++) {
6081 for (idx = 0; idx < spec->num_pins; idx++)
6082 if (spec->pin_nids[idx] == nids[num])
6083 break;
6084 if (idx >= spec->num_pins)
6085 break;
6086 def_conf = stac_get_defcfg_connect(codec, idx);
6087 if (def_conf == AC_JACK_PORT_NONE)
6088 break;
6089 }
6090 return num;
6091}
6092
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006093static void stac92xx_mic_detect(struct hda_codec *codec)
6094{
6095 struct sigmatel_spec *spec = codec->spec;
6096 struct sigmatel_mic_route *mic;
6097
6098 if (get_pin_presence(codec, spec->ext_mic.pin))
6099 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02006100 else if (get_pin_presence(codec, spec->dock_mic.pin))
6101 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006102 else
6103 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02006104 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006105 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
6106 AC_VERB_SET_CONNECT_SEL,
6107 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02006108 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006109 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
6110 AC_VERB_SET_CONNECT_SEL,
6111 mic->mux_idx);
6112}
6113
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006114static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02006115 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02006116{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006117 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006118 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006119
Takashi Iwai3a938972011-10-28 01:16:55 +02006120 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02006121 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006122 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02006123 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006124 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006125 case STAC_MIC_EVENT:
6126 stac92xx_mic_detect(codec);
6127 break;
6128 }
6129
Takashi Iwai3a938972011-10-28 01:16:55 +02006130 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006131 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02006132 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02006133 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04006134 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006135 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006136 if (spec->num_pwrs > 0)
6137 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04006138
6139 switch (codec->subsystem_id) {
6140 case 0x103c308f:
6141 if (event->nid == 0xb) {
6142 int pin = AC_PINCTL_IN_EN;
6143
6144 if (get_pin_presence(codec, 0xa)
6145 && get_pin_presence(codec, 0xb))
6146 pin |= AC_PINCTL_VREF_80;
6147 if (!get_pin_presence(codec, 0xb))
6148 pin |= AC_PINCTL_VREF_80;
6149
6150 /* toggle VREF state based on mic + hp pin
6151 * status
6152 */
6153 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
6154 }
6155 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04006156 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006157 case STAC_VREF_EVENT:
6158 data = snd_hda_codec_read(codec, codec->afg, 0,
6159 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04006160 /* toggle VREF state based on GPIOx status */
6161 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02006162 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04006163 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02006164 }
6165}
6166
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006167static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
6168{
Takashi Iwai3a938972011-10-28 01:16:55 +02006169 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02006170 if (!event)
6171 return;
6172 handle_unsol_event(codec, event);
6173}
6174
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306175static void set_hp_led_gpio(struct hda_codec *codec)
6176{
6177 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01006178 unsigned int gpio;
6179
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02006180 if (spec->gpio_led)
6181 return;
6182
Takashi Iwai07f80442010-02-08 15:06:13 +01006183 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
6184 gpio &= AC_GPIO_IO_COUNT;
6185 if (gpio > 3)
6186 spec->gpio_led = 0x08; /* GPIO 3 */
6187 else
6188 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306189}
6190
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006191/*
6192 * This method searches for the mute LED GPIO configuration
6193 * provided as OEM string in SMBIOS. The format of that string
6194 * is HP_Mute_LED_P_G or HP_Mute_LED_P
6195 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
6196 * that corresponds to the NOT muted state of the master volume
6197 * and G is the index of the GPIO to use as the mute LED control (0..9)
6198 * If _G portion is missing it is assigned based on the codec ID
6199 *
6200 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
6201 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306202 *
6203 *
6204 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
6205 * SMBIOS - at least the ones I have seen do not have them - which include
6206 * my own system (HP Pavilion dv6-1110ax) and my cousin's
6207 * HP Pavilion dv9500t CTO.
6208 * Need more information on whether it is true across the entire series.
6209 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006210 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006211static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006212{
6213 struct sigmatel_spec *spec = codec->spec;
6214 const struct dmi_device *dev = NULL;
6215
Takashi Iwai75609312012-05-14 16:52:00 +02006216 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
6217 get_int_hint(codec, "gpio_led_polarity",
6218 &spec->gpio_led_polarity);
6219 return 1;
6220 }
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006221
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006222 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
6223 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
6224 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006225 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306226 &spec->gpio_led_polarity,
6227 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006228 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)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006233 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01006234 else
6235 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006236 return 1;
6237 }
6238 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306239 &spec->gpio_led_polarity) == 1) {
6240 set_hp_led_gpio(codec);
6241 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006242 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02006243 /* BIOS bug: unfilled OEM string */
6244 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
6245 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02006246 switch (codec->subsystem_id) {
6247 case 0x103c148a:
6248 spec->gpio_led_polarity = 0;
6249 break;
6250 default:
6251 spec->gpio_led_polarity = 1;
6252 break;
6253 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02006254 return 1;
6255 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006256 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306257
6258 /*
6259 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006260 * we statically set the GPIO - if not a B-series system
6261 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306262 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006263 if (!hp_blike_system(codec->subsystem_id) &&
6264 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306265 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01006266 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306267 return 1;
6268 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006269 }
6270 return 0;
6271}
6272
6273static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08006274{
6275 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006276 case 0x103c1520:
6277 case 0x103c1521:
6278 case 0x103c1523:
6279 case 0x103c1524:
6280 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006281 case 0x103c1722:
6282 case 0x103c1723:
6283 case 0x103c1724:
6284 case 0x103c1725:
6285 case 0x103c1726:
6286 case 0x103c1727:
6287 case 0x103c1728:
6288 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006289 case 0x103c172a:
6290 case 0x103c172b:
6291 case 0x103c307e:
6292 case 0x103c307f:
6293 case 0x103c3080:
6294 case 0x103c3081:
6295 case 0x103c7007:
6296 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08006297 return 1;
6298 }
6299 return 0;
6300}
6301
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006302#ifdef CONFIG_PROC_FS
6303static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
6304 struct hda_codec *codec, hda_nid_t nid)
6305{
6306 if (nid == codec->afg)
6307 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02006308 snd_hda_codec_read(codec, nid, 0,
6309 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006310}
6311
6312static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
6313 struct hda_codec *codec,
6314 unsigned int verb)
6315{
6316 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
6317 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
6318}
6319
6320/* stac92hd71bxx, stac92hd73xx */
6321static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
6322 struct hda_codec *codec, hda_nid_t nid)
6323{
6324 stac92hd_proc_hook(buffer, codec, nid);
6325 if (nid == codec->afg)
6326 analog_loop_proc_hook(buffer, codec, 0xfa0);
6327}
6328
6329static void stac9205_proc_hook(struct snd_info_buffer *buffer,
6330 struct hda_codec *codec, hda_nid_t nid)
6331{
6332 if (nid == codec->afg)
6333 analog_loop_proc_hook(buffer, codec, 0xfe0);
6334}
6335
6336static void stac927x_proc_hook(struct snd_info_buffer *buffer,
6337 struct hda_codec *codec, hda_nid_t nid)
6338{
6339 if (nid == codec->afg)
6340 analog_loop_proc_hook(buffer, codec, 0xfeb);
6341}
6342#else
6343#define stac92hd_proc_hook NULL
6344#define stac92hd7x_proc_hook NULL
6345#define stac9205_proc_hook NULL
6346#define stac927x_proc_hook NULL
6347#endif
6348
Takashi Iwai2a439522011-07-26 09:52:50 +02006349#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02006350static int stac92xx_resume(struct hda_codec *codec)
6351{
Takashi Iwai2c885872008-11-18 09:36:55 +01006352 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006353 snd_hda_codec_resume_amp(codec);
6354 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01006355 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01006356 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02006357 return 0;
6358}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006359
Takashi Iwai68cb2b52012-07-02 15:20:37 +02006360static int stac92xx_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006361{
6362 stac92xx_shutup(codec);
6363 return 0;
6364}
6365
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006366static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
6367 unsigned int power_state)
6368{
6369 unsigned int afg_power_state = power_state;
6370 struct sigmatel_spec *spec = codec->spec;
6371
6372 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006373 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006374 /* with vref-out pin used for mute led control
6375 * codec AFG is prevented from D3 state
6376 */
6377 afg_power_state = AC_PWRST_D1;
6378 }
6379 /* this delay seems necessary to avoid click noise at power-down */
6380 msleep(100);
6381 }
6382 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
6383 afg_power_state);
6384 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
6385}
Takashi Iwai350eba432012-03-16 16:09:03 +01006386#else
6387#define stac92xx_suspend NULL
6388#define stac92xx_resume NULL
Takashi Iwai350eba432012-03-16 16:09:03 +01006389#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006390#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006391
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006392/* update mute-LED accoring to the master switch */
6393static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006394{
6395 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006396 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01006397
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006398 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006399 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006400
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006401 /* LED state is inverted on these systems */
6402 if (spec->gpio_led_polarity)
6403 muted = !muted;
6404
Takashi Iwaif1a73742011-12-04 13:44:06 +01006405 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006406 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02006407 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006408 else
Takashi Iwai3e843192012-04-19 12:04:03 +02006409 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006410 stac_gpio_set(codec, spec->gpio_mask,
6411 spec->gpio_dir, spec->gpio_data);
6412 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006413 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01006414 stac_vrefout_set(codec, spec->vref_mute_led_nid,
6415 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006416 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006417}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05006418
Takashi Iwai2b635362011-05-02 12:33:43 +02006419static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02006420 .build_controls = stac92xx_build_controls,
6421 .build_pcms = stac92xx_build_pcms,
6422 .init = stac92xx_init,
6423 .free = stac92xx_free,
David Henningsson29adc4b2012-09-25 11:31:00 +02006424 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02006425#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006426 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02006427 .resume = stac92xx_resume,
6428#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01006429 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02006430};
6431
Takashi Iwai361dab32012-05-09 14:35:27 +02006432static int alloc_stac_spec(struct hda_codec *codec, int num_pins,
6433 const hda_nid_t *pin_nids)
6434{
6435 struct sigmatel_spec *spec;
6436
6437 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6438 if (!spec)
6439 return -ENOMEM;
6440 codec->spec = spec;
6441 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
6442 spec->num_pins = num_pins;
6443 spec->pin_nids = pin_nids;
6444 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
6445 return 0;
6446}
6447
Matt2f2f4252005-04-13 14:45:30 +02006448static int patch_stac9200(struct hda_codec *codec)
6449{
6450 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006451 int err;
Matt2f2f4252005-04-13 14:45:30 +02006452
Takashi Iwai361dab32012-05-09 14:35:27 +02006453 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids),
6454 stac9200_pin_nids);
6455 if (err < 0)
6456 return err;
Matt2f2f4252005-04-13 14:45:30 +02006457
Takashi Iwai361dab32012-05-09 14:35:27 +02006458 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006459 spec->linear_tone_beep = 1;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006460
6461 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
6462 stac9200_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006463
6464 spec->multiout.max_channels = 2;
6465 spec->multiout.num_dacs = 1;
6466 spec->multiout.dac_nids = stac9200_dac_nids;
6467 spec->adc_nids = stac9200_adc_nids;
6468 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02006469 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02006470 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006471 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006472 spec->num_pwrs = 0;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006473 snd_hda_add_verbs(codec, stac9200_eapd_init);
Mattc7d4b2f2005-06-27 14:59:41 +02006474
Matt2f2f4252005-04-13 14:45:30 +02006475 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02006476
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006477 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai117f2572008-03-18 09:53:23 +01006478
Mattc7d4b2f2005-06-27 14:59:41 +02006479 err = stac9200_parse_auto_config(codec);
6480 if (err < 0) {
6481 stac92xx_free(codec);
6482 return err;
6483 }
Matt2f2f4252005-04-13 14:45:30 +02006484
6485 codec->patch_ops = stac92xx_patch_ops;
6486
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006487 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6488
Matt2f2f4252005-04-13 14:45:30 +02006489 return 0;
6490}
6491
Tobin Davis8e21c342007-01-08 11:04:17 +01006492static int patch_stac925x(struct hda_codec *codec)
6493{
6494 struct sigmatel_spec *spec;
6495 int err;
6496
Takashi Iwai361dab32012-05-09 14:35:27 +02006497 err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids),
6498 stac925x_pin_nids);
6499 if (err < 0)
6500 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01006501
Takashi Iwai361dab32012-05-09 14:35:27 +02006502 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006503 spec->linear_tone_beep = 1;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02006504
Takashi Iwaid2077d42013-01-14 14:20:16 +01006505 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
6506 stac925x_fixups);
Tobin Davis8e21c342007-01-08 11:04:17 +01006507
6508 spec->multiout.max_channels = 2;
6509 spec->multiout.num_dacs = 1;
6510 spec->multiout.dac_nids = stac925x_dac_nids;
6511 spec->adc_nids = stac925x_adc_nids;
6512 spec->mux_nids = stac925x_mux_nids;
6513 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006514 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006515 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02006516 switch (codec->vendor_id) {
6517 case 0x83847632: /* STAC9202 */
6518 case 0x83847633: /* STAC9202D */
6519 case 0x83847636: /* STAC9251 */
6520 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02006521 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02006522 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006523 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
6524 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02006525 break;
6526 default:
6527 spec->num_dmics = 0;
6528 break;
6529 }
Tobin Davis8e21c342007-01-08 11:04:17 +01006530
Takashi Iwaid2077d42013-01-14 14:20:16 +01006531 snd_hda_add_verbs(codec, stac925x_core_init);
Tobin Davis8e21c342007-01-08 11:04:17 +01006532 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02006533 spec->num_caps = 1;
6534 spec->capvols = stac925x_capvols;
6535 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01006536
Takashi Iwaid2077d42013-01-14 14:20:16 +01006537 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6538
Charles Chin9009b0e2011-11-03 10:27:27 +01006539 err = stac92xx_parse_auto_config(codec);
Takashi Iwaid2077d42013-01-14 14:20:16 +01006540 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006541 err = -EINVAL;
Tobin Davis8e21c342007-01-08 11:04:17 +01006542 if (err < 0) {
6543 stac92xx_free(codec);
6544 return err;
6545 }
6546
6547 codec->patch_ops = stac92xx_patch_ops;
6548
Takashi Iwaid2077d42013-01-14 14:20:16 +01006549 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6550
Tobin Davis8e21c342007-01-08 11:04:17 +01006551 return 0;
6552}
6553
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006554static int patch_stac92hd73xx(struct hda_codec *codec)
6555{
6556 struct sigmatel_spec *spec;
6557 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
Takashi Iwai361dab32012-05-09 14:35:27 +02006558 int err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006559 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006560
Takashi Iwai361dab32012-05-09 14:35:27 +02006561 err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids),
6562 stac92hd73xx_pin_nids);
6563 if (err < 0)
6564 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006565
Takashi Iwai361dab32012-05-09 14:35:27 +02006566 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006567 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02006568 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Takashi Iwai55e30142013-01-14 17:30:04 +01006569
6570 snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl,
6571 stac92hd73xx_fixups);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006572
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006573 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006574 conn, STAC92HD73_DAC_COUNT + 2) - 1;
6575
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006576 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006577 printk(KERN_WARNING "hda_codec: Could not determine "
6578 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006579 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006580 }
Takashi Iwai55e30142013-01-14 17:30:04 +01006581
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006582 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006583 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006584 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006585 break;
6586 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006587 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006588 break;
6589 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006590 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
6591 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006592 }
6593 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006594
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006595 spec->aloopback_mask = 0x01;
6596 spec->aloopback_shift = 8;
6597
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006598 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006599 spec->mux_nids = stac92hd73xx_mux_nids;
6600 spec->adc_nids = stac92hd73xx_adc_nids;
6601 spec->dmic_nids = stac92hd73xx_dmic_nids;
6602 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006603 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006604
6605 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
6606 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01006607 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006608
Takashi Iwai6479c632009-07-28 18:20:25 +02006609 spec->num_caps = STAC92HD73XX_NUM_CAPS;
6610 spec->capvols = stac92hd73xx_capvols;
6611 spec->capsws = stac92hd73xx_capsws;
6612
Takashi Iwai55e30142013-01-14 17:30:04 +01006613 /* GPIO0 High = Enable EAPD */
6614 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6615 spec->gpio_data = 0x01;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006616
Takashi Iwai55e30142013-01-14 17:30:04 +01006617 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6618 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6619 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006620
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006621 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
6622 spec->pwr_nids = stac92hd73xx_pwr_nids;
6623
Takashi Iwai55e30142013-01-14 17:30:04 +01006624 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6625
6626 if (!spec->volknob_init)
6627 snd_hda_add_verbs(codec, stac92hd73xx_core_init);
6628
Charles Chin9009b0e2011-11-03 10:27:27 +01006629 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006630
Takashi Iwai55e30142013-01-14 17:30:04 +01006631 if (!err)
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006632 err = -EINVAL;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006633 if (err < 0) {
6634 stac92xx_free(codec);
6635 return err;
6636 }
6637
6638 codec->patch_ops = stac92xx_patch_ops;
6639
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006640 codec->proc_widget_hook = stac92hd7x_proc_hook;
6641
Takashi Iwai55e30142013-01-14 17:30:04 +01006642 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6643
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006644 return 0;
6645}
6646
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006647static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006648{
6649 if (codec->vendor_id != 0x111d7605 &&
6650 codec->vendor_id != 0x111d76d1)
6651 return 0;
6652
6653 switch (codec->subsystem_id) {
6654 case 0x103c1618:
6655 case 0x103c1619:
6656 case 0x103c161a:
6657 case 0x103c161b:
6658 case 0x103c161c:
6659 case 0x103c161d:
6660 case 0x103c161e:
6661 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006662
6663 case 0x103c162a:
6664 case 0x103c162b:
6665
6666 case 0x103c1630:
6667 case 0x103c1631:
6668
6669 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006670 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006671 case 0x103c1635:
6672
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006673 case 0x103c3587:
6674 case 0x103c3588:
6675 case 0x103c3589:
6676 case 0x103c358a:
6677
6678 case 0x103c3667:
6679 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006680 case 0x103c3669:
6681
6682 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006683 }
6684 return 0;
6685}
6686
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006687static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
6688{
6689 struct sigmatel_spec *spec = codec->spec;
6690 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
6691 int i;
6692
6693 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
6694 spec->auto_pin_cnt++;
6695
6696 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
6697 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
6698 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
6699 if (nid == stac92hd83xxx_dmic_nids[i]) {
6700 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
6701 spec->auto_dmic_cnt++;
6702 }
6703 }
6704 }
6705}
6706
6707static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
6708{
6709 struct sigmatel_spec *spec = codec->spec;
6710
6711 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
6712 spec->auto_adc_cnt++;
6713}
6714
6715static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
6716{
6717 int i, j;
6718 struct sigmatel_spec *spec = codec->spec;
6719
6720 for (i = 0; i < spec->auto_adc_cnt; i++) {
6721 if (get_connection_index(codec,
6722 spec->auto_adc_nids[i], nid) >= 0) {
6723 /* mux and volume for adc_nids[i] */
6724 if (!spec->auto_mux_nids[i]) {
6725 spec->auto_mux_nids[i] = nid;
6726 /* 92hd codecs capture volume is in mux */
6727 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
6728 3, 0, HDA_OUTPUT);
6729 }
6730 for (j = 0; j < spec->auto_dmic_cnt; j++) {
6731 if (get_connection_index(codec, nid,
6732 spec->auto_dmic_nids[j]) >= 0) {
6733 /* dmux for adc_nids[i] */
6734 if (!spec->auto_dmux_nids[i])
6735 spec->auto_dmux_nids[i] = nid;
6736 break;
6737 }
6738 }
6739 break;
6740 }
6741 }
6742}
6743
6744static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
6745{
6746 hda_nid_t nid, end_nid;
6747 unsigned int wid_caps, wid_type;
6748 struct sigmatel_spec *spec = codec->spec;
6749
6750 end_nid = codec->start_nid + codec->num_nodes;
6751
6752 for (nid = codec->start_nid; nid < end_nid; nid++) {
6753 wid_caps = get_wcaps(codec, nid);
6754 wid_type = get_wcaps_type(wid_caps);
6755
6756 if (wid_type == AC_WID_PIN)
6757 stac92hd8x_add_pin(codec, nid);
6758
6759 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
6760 stac92hd8x_add_adc(codec, nid);
6761 }
6762
6763 for (nid = codec->start_nid; nid < end_nid; nid++) {
6764 wid_caps = get_wcaps(codec, nid);
6765 wid_type = get_wcaps_type(wid_caps);
6766
6767 if (wid_type == AC_WID_AUD_SEL)
6768 stac92hd8x_add_mux(codec, nid);
6769 }
6770
6771 spec->pin_nids = spec->auto_pin_nids;
6772 spec->num_pins = spec->auto_pin_cnt;
6773 spec->adc_nids = spec->auto_adc_nids;
6774 spec->num_adcs = spec->auto_adc_cnt;
6775 spec->capvols = spec->auto_capvols;
6776 spec->capsws = spec->auto_capvols;
6777 spec->num_caps = spec->auto_adc_cnt;
6778 spec->mux_nids = spec->auto_mux_nids;
6779 spec->num_muxes = spec->auto_adc_cnt;
6780 spec->dmux_nids = spec->auto_dmux_nids;
6781 spec->num_dmuxes = spec->auto_adc_cnt;
6782 spec->dmic_nids = spec->auto_dmic_nids;
6783 spec->num_dmics = spec->auto_dmic_cnt;
6784}
6785
Takashi Iwai372f8c72013-01-14 18:06:34 +01006786static void stac_setup_gpio(struct hda_codec *codec)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006787{
Takashi Iwai372f8c72013-01-14 18:06:34 +01006788 struct sigmatel_spec *spec = codec->spec;
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01006789
Takashi Iwaib4e81872009-11-18 17:20:24 +01006790 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006791 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006792 spec->gpio_mask |= spec->gpio_led;
6793 spec->gpio_dir |= spec->gpio_led;
6794 spec->gpio_data |= spec->gpio_led;
6795 } else {
6796 codec->patch_ops.set_power_state =
6797 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006798 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006799 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006800
Takashi Iwai62cbde12012-09-14 11:58:54 +02006801 if (spec->mic_mute_led_gpio) {
6802 spec->gpio_mask |= spec->mic_mute_led_gpio;
6803 spec->gpio_dir |= spec->mic_mute_led_gpio;
6804 spec->mic_mute_led_on = true;
6805 spec->gpio_data |= spec->mic_mute_led_gpio;
6806 }
Takashi Iwai372f8c72013-01-14 18:06:34 +01006807}
6808
6809static int patch_stac92hd83xxx(struct hda_codec *codec)
6810{
6811 struct sigmatel_spec *spec;
6812 int err;
6813
6814 err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */
6815 if (err < 0)
6816 return err;
6817
6818 codec->epss = 0; /* longer delay needed for D3 */
6819 stac92hd8x_fill_auto_spec(codec);
6820
6821 spec = codec->spec;
6822 spec->linear_tone_beep = 0;
6823 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
6824 spec->digbeep_nid = 0x21;
6825 spec->pwr_nids = stac92hd83xxx_pwr_nids;
6826 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
6827 spec->multiout.dac_nids = spec->dac_nids;
6828
6829 snd_hda_pick_fixup(codec, stac92hd83xxx_models, stac92hd83xxx_fixup_tbl,
6830 stac92hd83xxx_fixups);
6831
6832 snd_hda_add_verbs(codec, stac92hd83xxx_core_init);
6833 spec->default_polarity = -1; /* no default cfg */
6834
6835 codec->patch_ops = stac92xx_patch_ops;
6836
6837 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6838
6839 stac_setup_gpio(codec);
Takashi Iwai62cbde12012-09-14 11:58:54 +02006840
Charles Chin9009b0e2011-11-03 10:27:27 +01006841 err = stac92xx_parse_auto_config(codec);
Takashi Iwai372f8c72013-01-14 18:06:34 +01006842 if (!err)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006843 err = -EINVAL;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006844 if (err < 0) {
6845 stac92xx_free(codec);
6846 return err;
6847 }
6848
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006849 codec->proc_widget_hook = stac92hd_proc_hook;
6850
Takashi Iwai372f8c72013-01-14 18:06:34 +01006851 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6852
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006853 return 0;
6854}
6855
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006856static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
6857 hda_nid_t dig0pin)
6858{
6859 struct sigmatel_spec *spec = codec->spec;
6860 int idx;
6861
6862 for (idx = 0; idx < spec->num_pins; idx++)
6863 if (spec->pin_nids[idx] == dig0pin)
6864 break;
6865 if ((idx + 2) >= spec->num_pins)
6866 return 0;
6867
6868 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006869 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006870 return 2;
6871
6872 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006873 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006874 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01006875 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006876 return 1;
6877 else
6878 return 0;
6879}
6880
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006881/* HP dv7 bass switch - GPIO5 */
6882#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
6883static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
6884 struct snd_ctl_elem_value *ucontrol)
6885{
6886 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6887 struct sigmatel_spec *spec = codec->spec;
6888 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
6889 return 0;
6890}
6891
6892static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
6893 struct snd_ctl_elem_value *ucontrol)
6894{
6895 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6896 struct sigmatel_spec *spec = codec->spec;
6897 unsigned int gpio_data;
6898
6899 gpio_data = (spec->gpio_data & ~0x20) |
6900 (ucontrol->value.integer.value[0] ? 0x20 : 0);
6901 if (gpio_data == spec->gpio_data)
6902 return 0;
6903 spec->gpio_data = gpio_data;
6904 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
6905 return 1;
6906}
6907
Takashi Iwai2b635362011-05-02 12:33:43 +02006908static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6910 .info = stac_hp_bass_gpio_info,
6911 .get = stac_hp_bass_gpio_get,
6912 .put = stac_hp_bass_gpio_put,
6913};
6914
6915static int stac_add_hp_bass_switch(struct hda_codec *codec)
6916{
6917 struct sigmatel_spec *spec = codec->spec;
6918
6919 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
6920 "Bass Speaker Playback Switch", 0))
6921 return -ENOMEM;
6922
6923 spec->gpio_mask |= 0x20;
6924 spec->gpio_dir |= 0x20;
6925 spec->gpio_data |= 0x20;
6926 return 0;
6927}
6928
Matthew Ranostaye035b842007-11-06 11:53:55 +01006929static int patch_stac92hd71bxx(struct hda_codec *codec)
6930{
6931 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02006932 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Takashi Iwai361dab32012-05-09 14:35:27 +02006933 int err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006934
Takashi Iwai361dab32012-05-09 14:35:27 +02006935 err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS,
6936 stac92hd71bxx_pin_nids_4port);
6937 if (err < 0)
6938 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006939
Takashi Iwai361dab32012-05-09 14:35:27 +02006940 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006941 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006942 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006943 switch (codec->vendor_id) {
6944 case 0x111d76b6:
6945 case 0x111d76b7:
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006946 break;
6947 case 0x111d7603:
6948 case 0x111d7608:
6949 /* On 92HD75Bx 0x27 isn't a pin nid */
6950 spec->num_pins--;
6951 /* fallthrough */
6952 default:
6953 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
6954 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006955 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006956
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006957 snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
6958 stac92hd71bxx_fixups);
6959
6960 /* GPIO0 = EAPD */
6961 spec->gpio_mask = 0x01;
6962 spec->gpio_dir = 0x01;
6963 spec->gpio_data = 0x01;
Takashi Iwai41c3b642008-11-18 10:45:15 +01006964
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006965 spec->dmic_nids = stac92hd71bxx_dmic_nids;
6966 spec->dmux_nids = stac92hd71bxx_dmux_nids;
6967
Takashi Iwai6479c632009-07-28 18:20:25 +02006968 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
6969 spec->capvols = stac92hd71bxx_capvols;
6970 spec->capsws = stac92hd71bxx_capsws;
6971
Matthew Ranostay541eee82007-12-14 12:08:04 +01006972 switch (codec->vendor_id) {
6973 case 0x111d76b6: /* 4 Port without Analog Mixer */
6974 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02006975 unmute_init++;
6976 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006977 case 0x111d76b4: /* 6 Port without Analog Mixer */
6978 case 0x111d76b5:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006979 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006980 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006981 stac92hd71bxx_dmic_nids,
6982 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01006983 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006984 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006985 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006986 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006987 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006988
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006989 /* disable VSW */
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006990 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01006991 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
6992 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02006993 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006994 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006995 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006996 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006997 break;
6998 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006999 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02007000 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02007001
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007002 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01007003 default:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04007004 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007005 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05007006 stac92hd71bxx_dmic_nids,
7007 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02007008 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01007009 }
7010
David Henningsson5e68fb32012-08-16 14:11:09 +02007011 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007012 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
David Henningsson5e68fb32012-08-16 14:11:09 +02007013
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05007014 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
7015 snd_hda_sequence_write_cache(codec, unmute_init);
7016
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007017 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04007018 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01007019 spec->aloopback_shift = 0;
7020
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02007021 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007022 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007023 spec->mux_nids = stac92hd71bxx_mux_nids;
7024 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02007025 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007026 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007027
7028 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
7029 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02007030 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05007031 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01007032
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007033 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01007034
Takashi Iwai372f8c72013-01-14 18:06:34 +01007035 stac_setup_gpio(codec);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04007036
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01007037 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007038
Charles Chin9009b0e2011-11-03 10:27:27 +01007039 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007040 if (!err)
Matthew Ranostaye035b842007-11-06 11:53:55 +01007041 err = -EINVAL;
Matthew Ranostaye035b842007-11-06 11:53:55 +01007042 if (err < 0) {
7043 stac92xx_free(codec);
7044 return err;
7045 }
7046
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007047 codec->proc_widget_hook = stac92hd7x_proc_hook;
7048
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01007049 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7050
Matthew Ranostaye035b842007-11-06 11:53:55 +01007051 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02007052}
Matthew Ranostaye035b842007-11-06 11:53:55 +01007053
Matt2f2f4252005-04-13 14:45:30 +02007054static int patch_stac922x(struct hda_codec *codec)
7055{
7056 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02007057 int err;
Matt2f2f4252005-04-13 14:45:30 +02007058
Takashi Iwai361dab32012-05-09 14:35:27 +02007059 err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids),
7060 stac922x_pin_nids);
7061 if (err < 0)
7062 return err;
Matt2f2f4252005-04-13 14:45:30 +02007063
Takashi Iwai361dab32012-05-09 14:35:27 +02007064 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007065 spec->linear_tone_beep = 1;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02007066
Takashi Iwai0a427842013-01-14 15:20:13 +01007067 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
7068 stac922x_fixups);
Matt2f2f4252005-04-13 14:45:30 +02007069
Matt2f2f4252005-04-13 14:45:30 +02007070 spec->adc_nids = stac922x_adc_nids;
7071 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007072 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007073 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007074 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007075 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02007076
Takashi Iwai6479c632009-07-28 18:20:25 +02007077 spec->num_caps = STAC922X_NUM_CAPS;
7078 spec->capvols = stac922x_capvols;
7079 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02007080
7081 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02007082
Takashi Iwai0a427842013-01-14 15:20:13 +01007083 snd_hda_add_verbs(codec, stac922x_core_init);
7084
7085 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7086
Charles Chin9009b0e2011-11-03 10:27:27 +01007087 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0a427842013-01-14 15:20:13 +01007088 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007089 err = -EINVAL;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007090 if (err < 0) {
7091 stac92xx_free(codec);
7092 return err;
7093 }
7094
7095 codec->patch_ops = stac92xx_patch_ops;
7096
Takashi Iwai807a46362007-05-29 19:01:37 +02007097 /* Fix Mux capture level; max to 2 */
7098 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
7099 (0 << AC_AMPCAP_OFFSET_SHIFT) |
7100 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
7101 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
7102 (0 << AC_AMPCAP_MUTE_SHIFT));
7103
Takashi Iwai0a427842013-01-14 15:20:13 +01007104 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7105
Matt Porter3cc08dc2006-01-23 15:27:49 +01007106 return 0;
7107}
7108
7109static int patch_stac927x(struct hda_codec *codec)
7110{
7111 struct sigmatel_spec *spec;
7112 int err;
7113
Takashi Iwai361dab32012-05-09 14:35:27 +02007114 err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids),
7115 stac927x_pin_nids);
7116 if (err < 0)
7117 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007118
Takashi Iwai361dab32012-05-09 14:35:27 +02007119 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007120 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05007121 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwai29ac8362013-01-14 16:03:38 +01007122
7123 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
7124 stac927x_fixups);
Matt Porter3cc08dc2006-01-23 15:27:49 +01007125
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007126 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007127 spec->adc_nids = stac927x_adc_nids;
7128 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
7129 spec->mux_nids = stac927x_mux_nids;
7130 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007131 spec->smux_nids = stac927x_smux_nids;
7132 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04007133 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01007134 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007135 spec->multiout.dac_nids = spec->dac_nids;
7136
Takashi Iwai29ac8362013-01-14 16:03:38 +01007137 /* GPIO0 High = Enable EAPD */
7138 spec->eapd_mask = spec->gpio_mask = 0x01;
7139 spec->gpio_dir = spec->gpio_data = 0x01;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02007140
Takashi Iwai29ac8362013-01-14 16:03:38 +01007141 spec->num_dmics = 0;
Matt Porter3cc08dc2006-01-23 15:27:49 +01007142
Takashi Iwai6479c632009-07-28 18:20:25 +02007143 spec->num_caps = STAC927X_NUM_CAPS;
7144 spec->capvols = stac927x_capvols;
7145 spec->capsws = stac927x_capsws;
7146
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007147 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007148 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007149 spec->aloopback_mask = 0x40;
7150 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05007151 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01007152
Takashi Iwai29ac8362013-01-14 16:03:38 +01007153 if (!spec->volknob_init)
7154 snd_hda_add_verbs(codec, stac927x_core_init);
7155
7156 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7157
Charles Chin9009b0e2011-11-03 10:27:27 +01007158 err = stac92xx_parse_auto_config(codec);
Takashi Iwai29ac8362013-01-14 16:03:38 +01007159 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007160 err = -EINVAL;
Mattc7d4b2f2005-06-27 14:59:41 +02007161 if (err < 0) {
7162 stac92xx_free(codec);
7163 return err;
7164 }
Matt2f2f4252005-04-13 14:45:30 +02007165
7166 codec->patch_ops = stac92xx_patch_ops;
7167
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007168 codec->proc_widget_hook = stac927x_proc_hook;
7169
Takashi Iwai52987652008-01-16 16:09:47 +01007170 /*
7171 * !!FIXME!!
7172 * The STAC927x seem to require fairly long delays for certain
7173 * command sequences. With too short delays (even if the answer
7174 * is set to RIRB properly), it results in the silence output
7175 * on some hardwares like Dell.
7176 *
7177 * The below flag enables the longer delay (see get_response
7178 * in hda_intel.c).
7179 */
7180 codec->bus->needs_damn_long_delay = 1;
7181
Takashi Iwai29ac8362013-01-14 16:03:38 +01007182 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwaie28d8322008-12-17 13:48:29 +01007183
Matt2f2f4252005-04-13 14:45:30 +02007184 return 0;
7185}
7186
Matt Porterf3302a52006-07-31 12:49:34 +02007187static int patch_stac9205(struct hda_codec *codec)
7188{
7189 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02007190 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02007191
Takashi Iwai361dab32012-05-09 14:35:27 +02007192 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids),
7193 stac9205_pin_nids);
7194 if (err < 0)
7195 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02007196
Takashi Iwai361dab32012-05-09 14:35:27 +02007197 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007198 spec->linear_tone_beep = 1;
Takashi Iwaife6322c2013-01-14 14:46:51 +01007199
7200 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
7201 stac9205_fixups);
Matt Porterf3302a52006-07-31 12:49:34 +02007202
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007203 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02007204 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007205 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02007206 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007207 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007208 spec->smux_nids = stac9205_smux_nids;
7209 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007210 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02007211 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007212 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01007213 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007214 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007215
Takashi Iwaife6322c2013-01-14 14:46:51 +01007216 snd_hda_add_verbs(codec, stac9205_core_init);
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007217 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02007218
Takashi Iwai6479c632009-07-28 18:20:25 +02007219 spec->num_caps = STAC9205_NUM_CAPS;
7220 spec->capvols = stac9205_capvols;
7221 spec->capsws = stac9205_capsws;
7222
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007223 spec->aloopback_mask = 0x40;
7224 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007225 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02007226
Takashi Iwaife6322c2013-01-14 14:46:51 +01007227 /* GPIO0 High = EAPD */
7228 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
7229 spec->gpio_data = 0x01;
Matt Porter33382402006-12-18 13:17:28 +01007230
Takashi Iwaife6322c2013-01-14 14:46:51 +01007231 /* Turn on/off EAPD per HP plugging */
7232 spec->eapd_switch = 1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01007233
Takashi Iwaife6322c2013-01-14 14:46:51 +01007234 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Matthew Ranostay87d48362007-07-17 11:52:24 +02007235
Charles Chin9009b0e2011-11-03 10:27:27 +01007236 err = stac92xx_parse_auto_config(codec);
Takashi Iwaife6322c2013-01-14 14:46:51 +01007237 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007238 err = -EINVAL;
Matt Porterf3302a52006-07-31 12:49:34 +02007239 if (err < 0) {
7240 stac92xx_free(codec);
7241 return err;
7242 }
7243
7244 codec->patch_ops = stac92xx_patch_ops;
7245
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007246 codec->proc_widget_hook = stac9205_proc_hook;
7247
Takashi Iwaife6322c2013-01-14 14:46:51 +01007248 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7249
Matt Porterf3302a52006-07-31 12:49:34 +02007250 return 0;
7251}
7252
Matt2f2f4252005-04-13 14:45:30 +02007253/*
Guillaume Munch6d859062006-08-22 17:15:47 +02007254 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01007255 */
7256
Takashi Iwai2b635362011-05-02 12:33:43 +02007257static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02007258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01007259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
7260 {}
7261};
7262
Takashi Iwai2b635362011-05-02 12:33:43 +02007263static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007264 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
7265 0x11, 0x13, 0x14,
7266};
7267
Takashi Iwai2b635362011-05-02 12:33:43 +02007268static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007269 0x8 /*,0x6*/
7270};
7271
Takashi Iwai2b635362011-05-02 12:33:43 +02007272static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007273 0x15
7274};
7275
Takashi Iwai2b635362011-05-02 12:33:43 +02007276static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02007277 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7278};
7279#define stac9872_capsws stac9872_capvols
7280
Takashi Iwaifc268c12013-01-14 14:29:36 +01007281static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
7282 { 0x0a, 0x03211020 },
7283 { 0x0b, 0x411111f0 },
7284 { 0x0c, 0x411111f0 },
7285 { 0x0d, 0x03a15030 },
7286 { 0x0e, 0x411111f0 },
7287 { 0x0f, 0x90170110 },
7288 { 0x11, 0x411111f0 },
7289 { 0x13, 0x411111f0 },
7290 { 0x14, 0x90a7013e },
7291 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007292};
7293
Takashi Iwaifc268c12013-01-14 14:29:36 +01007294static const struct hda_model_fixup stac9872_models[] = {
7295 { .id = STAC_9872_VAIO, .name = "vaio" },
7296 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007297};
7298
Takashi Iwaifc268c12013-01-14 14:29:36 +01007299static const struct hda_fixup stac9872_fixups[] = {
7300 [STAC_9872_VAIO] = {
7301 .type = HDA_FIXUP_PINS,
7302 .v.pins = stac9872_vaio_pin_configs,
7303 },
Takashi Iwai307282c2009-03-12 18:17:58 +01007304};
7305
Takashi Iwaifc268c12013-01-14 14:29:36 +01007306static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02007307 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
7308 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01007309 {} /* terminator */
7310};
7311
Guillaume Munch6d859062006-08-22 17:15:47 +02007312static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01007313{
7314 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01007315 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01007316
Takashi Iwai361dab32012-05-09 14:35:27 +02007317 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids),
7318 stac9872_pin_nids);
7319 if (err < 0)
7320 return err;
7321
7322 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007323 spec->linear_tone_beep = 1;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007324
Takashi Iwaifc268c12013-01-14 14:29:36 +01007325 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
7326 stac9872_fixups);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007327
Takashi Iwai1e137f92009-01-21 07:41:22 +01007328 spec->multiout.dac_nids = spec->dac_nids;
7329 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
7330 spec->adc_nids = stac9872_adc_nids;
7331 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
7332 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02007333 spec->num_caps = 1;
7334 spec->capvols = stac9872_capvols;
7335 spec->capsws = stac9872_capsws;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007336 snd_hda_add_verbs(codec, stac9872_core_init);
7337
7338 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007339
Charles Chin9009b0e2011-11-03 10:27:27 +01007340 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01007341 if (err < 0) {
7342 stac92xx_free(codec);
7343 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007344 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01007345 spec->input_mux = &spec->private_imux;
7346 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007347
7348 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7349
Takashi Iwaidb064e52006-03-16 16:04:58 +01007350 return 0;
7351}
7352
7353
7354/*
Matt2f2f4252005-04-13 14:45:30 +02007355 * patch entries
7356 */
Takashi Iwai2b635362011-05-02 12:33:43 +02007357static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02007358 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
7359 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
7360 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
7361 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
7362 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
7363 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
7364 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02007365 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
7366 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
7367 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
7368 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
7369 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
7370 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01007371 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
7372 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
7373 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
7374 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
7375 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
7376 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
7377 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
7378 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
7379 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
7380 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01007381 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
7382 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
7383 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
7384 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
7385 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
7386 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02007387 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
7388 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02007389 /* The following does not take into account .id=0x83847661 when subsys =
7390 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
7391 * currently not fully supported.
7392 */
7393 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
7394 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
7395 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01007396 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02007397 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
7398 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
7399 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
7400 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
7401 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
7402 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
7403 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
7404 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007405 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007406 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01007407 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007408 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04007409 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02007410 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
7411 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01007412 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
7413 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
7414 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
7415 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007416 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01007417 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
7418 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007419 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01007420 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7421 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7422 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7423 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7424 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7425 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7426 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7427 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02007428 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
7429 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
7430 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
7431 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
7432 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
7433 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
7434 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
7435 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
7436 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
7437 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
7438 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
7439 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
7440 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
7441 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
7442 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02007443 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007444 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06007445 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
7446 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007447 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01007448 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
7449 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
7450 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
7451 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
7452 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
7453 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
7454 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
7455 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
7456 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
7457 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
7458 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
7459 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02007460 {} /* terminator */
7461};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01007462
7463MODULE_ALIAS("snd-hda-codec-id:8384*");
7464MODULE_ALIAS("snd-hda-codec-id:111d*");
7465
7466MODULE_LICENSE("GPL");
7467MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
7468
7469static struct hda_codec_preset_list sigmatel_list = {
7470 .preset = snd_hda_preset_sigmatel,
7471 .owner = THIS_MODULE,
7472};
7473
7474static int __init patch_sigmatel_init(void)
7475{
7476 return snd_hda_add_codec_preset(&sigmatel_list);
7477}
7478
7479static void __exit patch_sigmatel_exit(void)
7480{
7481 snd_hda_delete_codec_preset(&sigmatel_list);
7482}
7483
7484module_init(patch_sigmatel_init)
7485module_exit(patch_sigmatel_exit)