blob: 9d2dfad7f0bcecde1c6c99c181bc37c7aa03281d [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"
Takashi Iwai36c9db72013-01-17 17:07:59 +010042#include "hda_generic.h"
Matt2f2f4252005-04-13 14:45:30 +020043
Takashi Iwaic6e4c662008-11-25 11:58:19 +010044enum {
Takashi Iwai36c9db72013-01-17 17:07:59 +010045 STAC_VREF_EVENT = 8,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010046 STAC_PWR_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010047};
Matt4e550962005-07-04 17:51:39 +020048
Takashi Iwaif5fcc132006-11-24 17:07:44 +010049enum {
50 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010051 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020052 STAC_9200_DELL_D21,
53 STAC_9200_DELL_D22,
54 STAC_9200_DELL_D23,
55 STAC_9200_DELL_M21,
56 STAC_9200_DELL_M22,
57 STAC_9200_DELL_M23,
58 STAC_9200_DELL_M24,
59 STAC_9200_DELL_M25,
60 STAC_9200_DELL_M26,
61 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020062 STAC_9200_M4,
63 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010064 STAC_9200_PANASONIC,
Takashi Iwaid39a3ae2013-01-14 14:06:26 +010065 STAC_9200_EAPD_INIT,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010066 STAC_9200_MODELS
67};
68
69enum {
70 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020071 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020072 STAC_9205_DELL_M43,
73 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010074 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010075 STAC_9205_MODELS
76};
77
78enum {
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010079 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010080 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080081 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010082 STAC_DELL_M6_AMIC,
83 STAC_DELL_M6_DMIC,
84 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050085 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020086 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010087 STAC_92HD73XX_MODELS
88};
89
90enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020091 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050092 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050093 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010094 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -050095 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -060096 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -060097 STAC_HP_ZEPHYR,
Takashi Iwaia3e19972012-07-26 08:17:20 +020098 STAC_92HD83XXX_HP_LED,
Takashi Iwaiff8a1e22012-07-31 10:16:59 +020099 STAC_92HD83XXX_HP_INV_LED,
Takashi Iwai62cbde12012-09-14 11:58:54 +0200100 STAC_92HD83XXX_HP_MIC_LED,
David Henningsson8d032a82012-10-09 12:48:40 +0200101 STAC_92HD83XXX_HEADSET_JACK,
Takashi Iwai372f8c72013-01-14 18:06:34 +0100102 STAC_92HD83XXX_HP,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200103 STAC_92HD83XXX_MODELS
104};
105
106enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100107 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100108 STAC_DELL_M4_1,
109 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500110 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400111 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200112 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100113 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100114 STAC_HP_HDX,
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100115 STAC_92HD71BXX_HP,
116 STAC_92HD71BXX_NO_DMIC,
117 STAC_92HD71BXX_NO_SMUX,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100118 STAC_92HD71BXX_MODELS
119};
120
121enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100122 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200123 STAC_M1,
124 STAC_M1_2,
125 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100126 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200127 STAC_M3,
128 STAC_M5,
129 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100130 STAC_925x_MODELS
131};
132
133enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100134 STAC_D945_REF,
135 STAC_D945GTP3,
136 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200137 STAC_INTEL_MAC_V1,
138 STAC_INTEL_MAC_V2,
139 STAC_INTEL_MAC_V3,
140 STAC_INTEL_MAC_V4,
141 STAC_INTEL_MAC_V5,
Takashi Iwai0a427842013-01-14 15:20:13 +0100142 STAC_INTEL_MAC_AUTO,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300143 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200144 STAC_922X_DELL_D81,
145 STAC_922X_DELL_D82,
146 STAC_922X_DELL_M81,
147 STAC_922X_DELL_M82,
Takashi Iwai0a427842013-01-14 15:20:13 +0100148 STAC_922X_INTEL_MAC_GPIO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100149 STAC_922X_MODELS
150};
151
152enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100153 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100154 STAC_D965_REF,
155 STAC_D965_3ST,
156 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200157 STAC_D965_5ST_NO_FP,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100158 STAC_D965_VERBS,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200159 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100160 STAC_DELL_BIOS,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100161 STAC_DELL_BIOS_SPDIF,
162 STAC_927X_DELL_DMIC,
Takashi Iwai54930532009-10-11 17:38:29 +0200163 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100164 STAC_927X_MODELS
165};
Matt Porter403d1942005-11-29 15:00:51 +0100166
Takashi Iwai307282c2009-03-12 18:17:58 +0100167enum {
Takashi Iwai307282c2009-03-12 18:17:58 +0100168 STAC_9872_VAIO,
169 STAC_9872_MODELS
170};
171
Matt2f2f4252005-04-13 14:45:30 +0200172struct sigmatel_spec {
Takashi Iwai36c9db72013-01-17 17:07:59 +0100173 struct hda_gen_spec gen;
Mattc7d4b2f2005-06-27 14:59:41 +0200174
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500175 unsigned int eapd_switch: 1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100176 unsigned int linear_tone_beep:1;
David Henningsson8d032a82012-10-09 12:48:40 +0200177 unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
Takashi Iwai29ac8362013-01-14 16:03:38 +0100178 unsigned int volknob_init:1; /* special volume-knob initialization */
Takashi Iwai36c9db72013-01-17 17:07:59 +0100179 unsigned int powerdown_adcs:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200180
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100181 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200182 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100183 unsigned int gpio_mask;
184 unsigned int gpio_dir;
185 unsigned int gpio_data;
186 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200187 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100188 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100189 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500190 unsigned int vref_led;
Takashi Iwai372f8c72013-01-14 18:06:34 +0100191 int default_polarity;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100192
Takashi Iwai62cbde12012-09-14 11:58:54 +0200193 unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
194 bool mic_mute_led_on; /* current mic mute state */
195
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200196 /* stream */
197 unsigned int stream_delay;
198
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100199 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200200 const struct snd_kcontrol_new *aloopback_ctl;
Takashi Iwai36c9db72013-01-17 17:07:59 +0100201 unsigned int aloopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100202 unsigned char aloopback_mask;
203 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200204
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100205 /* power management */
Takashi Iwaic8822462012-05-15 09:11:36 +0200206 unsigned int power_map_bits;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100207 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200208 const hda_nid_t *pwr_nids;
Takashi Iwai36c9db72013-01-17 17:07:59 +0100209 unsigned int active_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100210
Takashi Iwai36c9db72013-01-17 17:07:59 +0100211 /* beep widgets */
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200212 hda_nid_t anabeep_nid;
213 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200214};
215
Takashi Iwaic8822462012-05-15 09:11:36 +0200216#define AC_VERB_IDT_SET_POWER_MAP 0x7ec
217#define AC_VERB_IDT_GET_POWER_MAP 0xfec
218
Takashi Iwai2b635362011-05-02 12:33:43 +0200219static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100220 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
221 0x0f, 0x10, 0x11
222};
223
Charles Chinafef2cf2011-11-11 08:05:28 +0100224static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
225 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
226 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200227};
228
Takashi Iwai2b635362011-05-02 12:33:43 +0200229static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100230 0x0a, 0x0d, 0x0f
231};
232
Matthew Ranostaye035b842007-11-06 11:53:55 +0100233
Takashi Iwai36c9db72013-01-17 17:07:59 +0100234/*
235 * PCM hooks
236 */
237static void stac_playback_pcm_hook(struct hda_pcm_stream *hinfo,
238 struct hda_codec *codec,
239 struct snd_pcm_substream *substream,
240 int action)
Matt Porter8b657272006-10-26 17:12:59 +0200241{
Matt Porter8b657272006-10-26 17:12:59 +0200242 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai36c9db72013-01-17 17:07:59 +0100243 if (action == HDA_GEN_PCM_ACT_OPEN && spec->stream_delay)
244 msleep(spec->stream_delay);
Matt Porter8b657272006-10-26 17:12:59 +0200245}
246
Takashi Iwai36c9db72013-01-17 17:07:59 +0100247static void stac_capture_pcm_hook(struct hda_pcm_stream *hinfo,
248 struct hda_codec *codec,
249 struct snd_pcm_substream *substream,
250 int action)
Matt Porter8b657272006-10-26 17:12:59 +0200251{
Matt Porter8b657272006-10-26 17:12:59 +0200252 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai36c9db72013-01-17 17:07:59 +0100253 int i, idx = 0;
Matt Porter8b657272006-10-26 17:12:59 +0200254
Takashi Iwai36c9db72013-01-17 17:07:59 +0100255 if (!spec->powerdown_adcs)
256 return;
Matt Porter8b657272006-10-26 17:12:59 +0200257
Takashi Iwai36c9db72013-01-17 17:07:59 +0100258 for (i = 0; i < spec->gen.num_all_adcs; i++) {
259 if (spec->gen.all_adcs[i] == hinfo->nid) {
260 idx = i;
261 break;
262 }
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400263 }
Takashi Iwai36c9db72013-01-17 17:07:59 +0100264
265 switch (action) {
266 case HDA_GEN_PCM_ACT_OPEN:
267 msleep(40);
268 snd_hda_codec_write(codec, hinfo->nid, 0,
269 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
270 spec->active_adcs |= (1 << idx);
271 break;
272 case HDA_GEN_PCM_ACT_CLOSE:
273 snd_hda_codec_write(codec, hinfo->nid, 0,
274 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
275 spec->active_adcs &= ~(1 << idx);
276 break;
277 }
278}
279
280/*
281 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
282 * funky external mute control using GPIO pins.
283 */
284
285static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
286 unsigned int dir_mask, unsigned int data)
287{
288 unsigned int gpiostate, gpiomask, gpiodir;
289
290 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
291
292 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
293 AC_VERB_GET_GPIO_DATA, 0);
294 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
295
296 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
297 AC_VERB_GET_GPIO_MASK, 0);
298 gpiomask |= mask;
299
300 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
301 AC_VERB_GET_GPIO_DIRECTION, 0);
302 gpiodir |= dir_mask;
303
304 /* Configure GPIOx as CMOS */
305 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
306
307 snd_hda_codec_write(codec, codec->afg, 0,
308 AC_VERB_SET_GPIO_MASK, gpiomask);
309 snd_hda_codec_read(codec, codec->afg, 0,
310 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
311
312 msleep(1);
313
314 snd_hda_codec_read(codec, codec->afg, 0,
315 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
316}
317
318/* hook for controlling mic-mute LED GPIO */
319static void stac_capture_led_hook(struct hda_codec *codec, bool enable)
320{
321 struct sigmatel_spec *spec = codec->spec;
322 bool mute = !enable;
323
324 if (spec->mic_mute_led_on != mute) {
325 spec->mic_mute_led_on = mute;
326 if (mute)
327 spec->gpio_data |= spec->mic_mute_led_gpio;
328 else
329 spec->gpio_data &= ~spec->mic_mute_led_gpio;
330 stac_gpio_set(codec, spec->gpio_mask,
331 spec->gpio_dir, spec->gpio_data);
332 }
Matthew Ranostayd9737752008-09-07 12:03:41 +0200333}
334
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500335static int stac_vrefout_set(struct hda_codec *codec,
336 hda_nid_t nid, unsigned int new_vref)
337{
338 int error, pinctl;
339
340 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
341 pinctl = snd_hda_codec_read(codec, nid, 0,
342 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
343
344 if (pinctl < 0)
345 return pinctl;
346
347 pinctl &= 0xff;
348 pinctl &= ~AC_PINCTL_VREFEN;
349 pinctl |= (new_vref & AC_PINCTL_VREFEN);
350
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200351 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500352 if (error < 0)
353 return error;
354
355 return 1;
356}
357
Takashi Iwai36c9db72013-01-17 17:07:59 +0100358/* update mute-LED accoring to the master switch */
359static void stac_update_led_status(struct hda_codec *codec, int enabled)
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200360{
Matt2f2f4252005-04-13 14:45:30 +0200361 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai36c9db72013-01-17 17:07:59 +0100362 int muted = !enabled;
Matt2f2f4252005-04-13 14:45:30 +0200363
Takashi Iwai36c9db72013-01-17 17:07:59 +0100364 if (!spec->gpio_led)
365 return;
Matt2f2f4252005-04-13 14:45:30 +0200366
Takashi Iwai36c9db72013-01-17 17:07:59 +0100367 /* LED state is inverted on these systems */
368 if (spec->gpio_led_polarity)
369 muted = !muted;
Matt2f2f4252005-04-13 14:45:30 +0200370
Takashi Iwai36c9db72013-01-17 17:07:59 +0100371 if (!spec->vref_mute_led_nid) {
372 if (muted)
373 spec->gpio_data |= spec->gpio_led;
374 else
375 spec->gpio_data &= ~spec->gpio_led;
376 stac_gpio_set(codec, spec->gpio_mask,
377 spec->gpio_dir, spec->gpio_data);
Takashi Iwai5207e102009-07-30 13:09:08 +0200378 } else {
Takashi Iwai36c9db72013-01-17 17:07:59 +0100379 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
380 stac_vrefout_set(codec, spec->vref_mute_led_nid,
381 spec->vref_led);
Takashi Iwai5207e102009-07-30 13:09:08 +0200382 }
Matt2f2f4252005-04-13 14:45:30 +0200383}
384
Takashi Iwai36c9db72013-01-17 17:07:59 +0100385/* vmaster hook to update mute LED */
386static void stac_vmaster_hook(void *private_data, int val)
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100387{
Takashi Iwai36c9db72013-01-17 17:07:59 +0100388 stac_update_led_status(private_data, val);
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100389}
390
Takashi Iwai36c9db72013-01-17 17:07:59 +0100391/* automute hook to handle GPIO mute and EAPD updates */
392static void stac_update_outputs(struct hda_codec *codec)
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100393{
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100394 struct sigmatel_spec *spec = codec->spec;
395
Takashi Iwai36c9db72013-01-17 17:07:59 +0100396 if (spec->gpio_mute)
397 spec->gen.master_mute =
398 !(snd_hda_codec_read(codec, codec->afg, 0,
399 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
400
401 snd_hda_gen_update_outputs(codec);
402
403 if (spec->eapd_mask && spec->eapd_switch) {
404 unsigned int val = spec->gpio_data;
405 if (spec->gen.speaker_muted)
406 val &= ~spec->eapd_mask;
407 else
408 val |= spec->eapd_mask;
409 if (spec->gpio_data != val)
410 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir,
411 val);
412 }
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100413}
414
Takashi Iwai36c9db72013-01-17 17:07:59 +0100415static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
416 bool enable, bool do_write)
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100417{
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100418 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai36c9db72013-01-17 17:07:59 +0100419 unsigned int idx, val;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100420
Takashi Iwai36c9db72013-01-17 17:07:59 +0100421 for (idx = 0; idx < spec->num_pwrs; idx++) {
422 if (spec->pwr_nids[idx] == nid)
423 break;
424 }
425 if (idx >= spec->num_pwrs)
426 return;
427
428 idx = 1 << idx;
429
430 val = spec->power_map_bits;
431 if (enable)
432 val &= ~idx;
433 else
434 val |= idx;
435
436 /* power down unused output ports */
437 if (val != spec->power_map_bits) {
438 spec->power_map_bits = val;
439 if (do_write)
440 snd_hda_codec_write(codec, codec->afg, 0,
441 AC_VERB_IDT_SET_POWER_MAP, val);
442 }
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100443}
444
Takashi Iwai36c9db72013-01-17 17:07:59 +0100445/* update power bit per jack plug/unplug */
446static void jack_update_power(struct hda_codec *codec,
447 struct hda_jack_tbl *jack)
448{
449 struct sigmatel_spec *spec = codec->spec;
450 int i;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200451
Takashi Iwai36c9db72013-01-17 17:07:59 +0100452 if (!spec->num_pwrs)
453 return;
454
455 if (jack && jack->nid) {
456 stac_toggle_power_map(codec, jack->nid,
457 snd_hda_jack_detect(codec, jack->nid),
458 true);
459 return;
460 }
461
462 /* update all jacks */
463 for (i = 0; i < spec->num_pwrs; i++) {
464 hda_nid_t nid = spec->pwr_nids[i];
465 jack = snd_hda_jack_tbl_get(codec, nid);
466 if (!jack || !jack->action)
467 continue;
468 if (jack->action == STAC_PWR_EVENT ||
469 jack->action <= HDA_GEN_LAST_EVENT)
470 stac_toggle_power_map(codec, nid,
471 snd_hda_jack_detect(codec, nid),
472 false);
473 }
474
475 snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_IDT_SET_POWER_MAP,
476 spec->power_map_bits);
477}
478
479static void stac_hp_automute(struct hda_codec *codec,
480 struct hda_jack_tbl *jack)
481{
482 snd_hda_gen_hp_automute(codec, jack);
483 jack_update_power(codec, jack);
484}
485
486static void stac_line_automute(struct hda_codec *codec,
487 struct hda_jack_tbl *jack)
488{
489 snd_hda_gen_line_automute(codec, jack);
490 jack_update_power(codec, jack);
491}
492
493static void stac_vref_event(struct hda_codec *codec, struct hda_jack_tbl *event)
494{
495 unsigned int data;
496
497 data = snd_hda_codec_read(codec, codec->afg, 0,
498 AC_VERB_GET_GPIO_DATA, 0);
499 /* toggle VREF state based on GPIOx status */
500 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
501 !!(data & (1 << event->private_data)));
502}
503
504/* initialize the power map and enable the power event to jacks that
505 * haven't been assigned to automute
506 */
507static void stac_init_power_map(struct hda_codec *codec)
508{
509 struct sigmatel_spec *spec = codec->spec;
510 int i;
511
512 for (i = 0; i < spec->num_pwrs; i++) {
513 hda_nid_t nid = spec->pwr_nids[i];
514 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
515 def_conf = get_defcfg_connect(def_conf);
516 if (snd_hda_jack_tbl_get(codec, nid))
517 continue;
518 if (def_conf == AC_JACK_PORT_COMPLEX &&
519 !(spec->vref_mute_led_nid == nid ||
520 is_jack_detectable(codec, nid))) {
521 snd_hda_jack_detect_enable_callback(codec, nid,
522 STAC_PWR_EVENT,
523 jack_update_power);
524 } else {
525 if (def_conf == AC_JACK_PORT_NONE)
526 stac_toggle_power_map(codec, nid, false, false);
527 else
528 stac_toggle_power_map(codec, nid, true, false);
529 }
530 }
531}
532
533/*
534 */
535
536static inline bool get_int_hint(struct hda_codec *codec, const char *key,
537 int *valp)
538{
539 return !snd_hda_get_int_hint(codec, key, valp);
540}
541
542/* override some hints from the hwdep entry */
543static void stac_store_hints(struct hda_codec *codec)
544{
545 struct sigmatel_spec *spec = codec->spec;
546 int val;
547
548 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
549 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
550 spec->gpio_mask;
551 }
552 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
553 spec->gpio_mask &= spec->gpio_mask;
554 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
555 spec->gpio_dir &= spec->gpio_mask;
556 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
557 spec->eapd_mask &= spec->gpio_mask;
558 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
559 spec->gpio_mute &= spec->gpio_mask;
560 val = snd_hda_get_bool_hint(codec, "eapd_switch");
561 if (val >= 0)
562 spec->eapd_switch = val;
563}
564
565/*
566 * loopback controls
567 */
568
569#define stac_aloopback_info snd_ctl_boolean_mono_info
570
571static int stac_aloopback_get(struct snd_kcontrol *kcontrol,
572 struct snd_ctl_elem_value *ucontrol)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200573{
574 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100575 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200576 struct sigmatel_spec *spec = codec->spec;
577
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100578 ucontrol->value.integer.value[0] = !!(spec->aloopback &
579 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200580 return 0;
581}
582
Takashi Iwai36c9db72013-01-17 17:07:59 +0100583static int stac_aloopback_put(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_value *ucontrol)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200585{
586 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
587 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100588 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200589 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100590 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200591
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100592 idx_val = spec->aloopback_mask << idx;
593 if (ucontrol->value.integer.value[0])
594 val = spec->aloopback | idx_val;
595 else
596 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100597 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200598 return 0;
599
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100600 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200601
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100602 /* Only return the bits defined by the shift value of the
603 * first two bytes of the mask
604 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200605 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100606 kcontrol->private_value & 0xFFFF, 0x0);
607 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200608
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100609 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200610 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100611 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200612 } else {
613 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100614 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200615 }
616
617 snd_hda_codec_write_cache(codec, codec->afg, 0,
618 kcontrol->private_value >> 16, dac_mode);
619
620 return 1;
621}
622
Takashi Iwai36c9db72013-01-17 17:07:59 +0100623#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
624 { \
625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
626 .name = "Analog Loopback", \
627 .count = cnt, \
628 .info = stac_aloopback_info, \
629 .get = stac_aloopback_get, \
630 .put = stac_aloopback_put, \
631 .private_value = verb_read | (verb_write << 16), \
632 }
633
634/*
635 * Mute LED handling on HP laptops
636 */
637
638/* check whether it's a HP laptop with a docking port */
639static bool hp_bnb2011_with_dock(struct hda_codec *codec)
640{
641 if (codec->vendor_id != 0x111d7605 &&
642 codec->vendor_id != 0x111d76d1)
643 return false;
644
645 switch (codec->subsystem_id) {
646 case 0x103c1618:
647 case 0x103c1619:
648 case 0x103c161a:
649 case 0x103c161b:
650 case 0x103c161c:
651 case 0x103c161d:
652 case 0x103c161e:
653 case 0x103c161f:
654
655 case 0x103c162a:
656 case 0x103c162b:
657
658 case 0x103c1630:
659 case 0x103c1631:
660
661 case 0x103c1633:
662 case 0x103c1634:
663 case 0x103c1635:
664
665 case 0x103c3587:
666 case 0x103c3588:
667 case 0x103c3589:
668 case 0x103c358a:
669
670 case 0x103c3667:
671 case 0x103c3668:
672 case 0x103c3669:
673
674 return true;
675 }
676 return false;
677}
678
679static bool hp_blike_system(u32 subsystem_id)
680{
681 switch (subsystem_id) {
682 case 0x103c1520:
683 case 0x103c1521:
684 case 0x103c1523:
685 case 0x103c1524:
686 case 0x103c1525:
687 case 0x103c1722:
688 case 0x103c1723:
689 case 0x103c1724:
690 case 0x103c1725:
691 case 0x103c1726:
692 case 0x103c1727:
693 case 0x103c1728:
694 case 0x103c1729:
695 case 0x103c172a:
696 case 0x103c172b:
697 case 0x103c307e:
698 case 0x103c307f:
699 case 0x103c3080:
700 case 0x103c3081:
701 case 0x103c7007:
702 case 0x103c7008:
703 return true;
704 }
705 return false;
706}
707
708static void set_hp_led_gpio(struct hda_codec *codec)
709{
710 struct sigmatel_spec *spec = codec->spec;
711 unsigned int gpio;
712
713 if (spec->gpio_led)
714 return;
715
716 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
717 gpio &= AC_GPIO_IO_COUNT;
718 if (gpio > 3)
719 spec->gpio_led = 0x08; /* GPIO 3 */
720 else
721 spec->gpio_led = 0x01; /* GPIO 0 */
722}
723
724/*
725 * This method searches for the mute LED GPIO configuration
726 * provided as OEM string in SMBIOS. The format of that string
727 * is HP_Mute_LED_P_G or HP_Mute_LED_P
728 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
729 * that corresponds to the NOT muted state of the master volume
730 * and G is the index of the GPIO to use as the mute LED control (0..9)
731 * If _G portion is missing it is assigned based on the codec ID
732 *
733 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
734 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
735 *
736 *
737 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
738 * SMBIOS - at least the ones I have seen do not have them - which include
739 * my own system (HP Pavilion dv6-1110ax) and my cousin's
740 * HP Pavilion dv9500t CTO.
741 * Need more information on whether it is true across the entire series.
742 * -- kunal
743 */
744static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
745{
746 struct sigmatel_spec *spec = codec->spec;
747 const struct dmi_device *dev = NULL;
748
749 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
750 get_int_hint(codec, "gpio_led_polarity",
751 &spec->gpio_led_polarity);
752 return 1;
753 }
754
755 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
756 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
757 &spec->gpio_led_polarity,
758 &spec->gpio_led) == 2) {
759 unsigned int max_gpio;
760 max_gpio = snd_hda_param_read(codec, codec->afg,
761 AC_PAR_GPIO_CAP);
762 max_gpio &= AC_GPIO_IO_COUNT;
763 if (spec->gpio_led < max_gpio)
764 spec->gpio_led = 1 << spec->gpio_led;
765 else
766 spec->vref_mute_led_nid = spec->gpio_led;
767 return 1;
768 }
769 if (sscanf(dev->name, "HP_Mute_LED_%d",
770 &spec->gpio_led_polarity) == 1) {
771 set_hp_led_gpio(codec);
772 return 1;
773 }
774 /* BIOS bug: unfilled OEM string */
775 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
776 set_hp_led_gpio(codec);
777 if (default_polarity >= 0)
778 spec->gpio_led_polarity = default_polarity;
779 else
780 spec->gpio_led_polarity = 1;
781 return 1;
782 }
783 }
784
785 /*
786 * Fallback case - if we don't find the DMI strings,
787 * we statically set the GPIO - if not a B-series system
788 * and default polarity is provided
789 */
790 if (!hp_blike_system(codec->subsystem_id) &&
791 (default_polarity == 0 || default_polarity == 1)) {
792 set_hp_led_gpio(codec);
793 spec->gpio_led_polarity = default_polarity;
794 return 1;
795 }
796 return 0;
797}
798
799/*
800 * PC beep controls
801 */
802
803/* create PC beep volume controls */
804static int stac_auto_create_beep_ctls(struct hda_codec *codec,
805 hda_nid_t nid)
806{
807 struct sigmatel_spec *spec = codec->spec;
808 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
809 struct snd_kcontrol_new *knew;
810 static struct snd_kcontrol_new abeep_mute_ctl =
811 HDA_CODEC_MUTE(NULL, 0, 0, 0);
812 static struct snd_kcontrol_new dbeep_mute_ctl =
813 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0);
814 static struct snd_kcontrol_new beep_vol_ctl =
815 HDA_CODEC_VOLUME(NULL, 0, 0, 0);
816
817 /* check for mute support for the the amp */
818 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
819 const struct snd_kcontrol_new *temp;
820 if (spec->anabeep_nid == nid)
821 temp = &abeep_mute_ctl;
822 else
823 temp = &dbeep_mute_ctl;
824 knew = snd_hda_gen_add_kctl(&spec->gen,
825 "Beep Playback Switch", temp);
826 if (!knew)
827 return -ENOMEM;
828 knew->private_value =
829 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT);
830 }
831
832 /* check to see if there is volume support for the amp */
833 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
834 knew = snd_hda_gen_add_kctl(&spec->gen,
835 "Beep Playback Volume",
836 &beep_vol_ctl);
837 if (!knew)
838 return -ENOMEM;
839 knew->private_value =
840 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT);
841 }
842 return 0;
843}
844
845#ifdef CONFIG_SND_HDA_INPUT_BEEP
846#define stac_dig_beep_switch_info snd_ctl_boolean_mono_info
847
848static int stac_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
849 struct snd_ctl_elem_value *ucontrol)
850{
851 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
852 ucontrol->value.integer.value[0] = codec->beep->enabled;
853 return 0;
854}
855
856static int stac_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
857 struct snd_ctl_elem_value *ucontrol)
858{
859 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
860 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
861}
862
863static const struct snd_kcontrol_new stac_dig_beep_ctrl = {
864 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
865 .name = "Beep Playback Switch",
866 .info = stac_dig_beep_switch_info,
867 .get = stac_dig_beep_switch_get,
868 .put = stac_dig_beep_switch_put,
869};
870
871static int stac_beep_switch_ctl(struct hda_codec *codec)
872{
873 struct sigmatel_spec *spec = codec->spec;
874
875 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &stac_dig_beep_ctrl))
876 return -ENOMEM;
877 return 0;
878}
879#endif
880
881/*
882 */
883
Takashi Iwai2b635362011-05-02 12:33:43 +0200884static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200885 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200886 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200887 {}
888};
889
Takashi Iwai2b635362011-05-02 12:33:43 +0200890static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200891 /* set dac0mux for dac converter */
892 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
893 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
894 {}
895};
896
Takashi Iwai2b635362011-05-02 12:33:43 +0200897static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100898 /* set master volume to max value without distortion
899 * and direct control */
900 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100901 {}
902};
903
Takashi Iwai2b635362011-05-02 12:33:43 +0200904static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100905 /* set master volume and direct control */
906 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100907 {}
908};
909
Takashi Iwai2b635362011-05-02 12:33:43 +0200910static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200911 /* power state controls amps */
912 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200913 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200914};
915
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600916static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
917 { 0x22, 0x785, 0x43 },
918 { 0x22, 0x782, 0xe0 },
919 { 0x22, 0x795, 0x00 },
920 {}
921};
922
Takashi Iwai2b635362011-05-02 12:33:43 +0200923static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100924 /* set master volume and direct control */
925 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200926 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100927};
928
Takashi Iwai2b635362011-05-02 12:33:43 +0200929static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500930 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
931 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100932 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
933 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100934 {}
935};
936
Takashi Iwai2b635362011-05-02 12:33:43 +0200937static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100938 /* set dac0mux for dac converter */
939 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100940 /* mute the master volume */
941 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100942 {}
943};
944
Takashi Iwai2b635362011-05-02 12:33:43 +0200945static const struct hda_verb stac922x_core_init[] = {
Takashi Iwai36c9db72013-01-17 17:07:59 +0100946 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200947 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200948 {}
949};
950
Takashi Iwai2b635362011-05-02 12:33:43 +0200951static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200952 /* unmute node 0x1b */
953 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
Takashi Iwai36c9db72013-01-17 17:07:59 +0100954 /* select node 0x03 as DAC */
Takashi Iwai19039bd2006-06-28 15:52:16 +0200955 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
956 {}
957};
958
Takashi Iwai2b635362011-05-02 12:33:43 +0200959static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200960 /* don't set delta bit */
961 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
962 /* unmute node 0x1b */
963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
964 /* select node 0x03 as DAC */
965 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
966 {}
967};
968
Takashi Iwai2b635362011-05-02 12:33:43 +0200969static const struct hda_verb stac927x_core_init[] = {
Takashi Iwai36c9db72013-01-17 17:07:59 +0100970 /* set master volume and direct control */
Matt Porter3cc08dc2006-01-23 15:27:49 +0100971 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200972 /* enable analog pc beep path */
973 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100974 {}
975};
976
Takashi Iwai2b635362011-05-02 12:33:43 +0200977static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200978 /* don't set delta bit */
979 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
980 /* enable analog pc beep path */
981 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
982 {}
983};
984
Takashi Iwai2b635362011-05-02 12:33:43 +0200985static const struct hda_verb stac9205_core_init[] = {
Takashi Iwai36c9db72013-01-17 17:07:59 +0100986 /* set master volume and direct control */
Matt Porterf3302a52006-07-31 12:49:34 +0200987 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200988 /* enable analog pc beep path */
989 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200990 {}
991};
992
Takashi Iwai36c9db72013-01-17 17:07:59 +0100993static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback =
994 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3);
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100995
Takashi Iwai36c9db72013-01-17 17:07:59 +0100996static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback =
997 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200998
Takashi Iwai36c9db72013-01-17 17:07:59 +0100999static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback =
1000 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001001
Takashi Iwai36c9db72013-01-17 17:07:59 +01001002static const struct snd_kcontrol_new stac92hd71bxx_loopback =
1003 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2);
Matt2f2f4252005-04-13 14:45:30 +02001004
Takashi Iwai36c9db72013-01-17 17:07:59 +01001005static const struct snd_kcontrol_new stac9205_loopback =
1006 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001007
Takashi Iwai36c9db72013-01-17 17:07:59 +01001008static const struct snd_kcontrol_new stac927x_loopback =
1009 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1);
Matt2f2f4252005-04-13 14:45:30 +02001010
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001011static const struct hda_pintbl ref9200_pin_configs[] = {
1012 { 0x08, 0x01c47010 },
1013 { 0x09, 0x01447010 },
1014 { 0x0d, 0x0221401f },
1015 { 0x0e, 0x01114010 },
1016 { 0x0f, 0x02a19020 },
1017 { 0x10, 0x01a19021 },
1018 { 0x11, 0x90100140 },
1019 { 0x12, 0x01813122 },
1020 {}
Matt2f2f4252005-04-13 14:45:30 +02001021};
1022
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001023static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1024 { 0x08, 0x400000fe },
1025 { 0x09, 0x404500f4 },
1026 { 0x0d, 0x400100f0 },
1027 { 0x0e, 0x90110010 },
1028 { 0x0f, 0x400100f1 },
1029 { 0x10, 0x02a1902e },
1030 { 0x11, 0x500000f2 },
1031 { 0x12, 0x500000f3 },
1032 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001033};
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001034
1035static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1036 { 0x08, 0x400000fe },
1037 { 0x09, 0x404500f4 },
1038 { 0x0d, 0x400100f0 },
1039 { 0x0e, 0x90110010 },
1040 { 0x0f, 0x400100f1 },
1041 { 0x10, 0x02a1902e },
1042 { 0x11, 0x500000f2 },
1043 { 0x12, 0x500000f3 },
1044 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001045};
1046
1047/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001048 STAC 9200 pin configs for
1049 102801A8
1050 102801DE
1051 102801E8
1052*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001053static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1054 { 0x08, 0x400001f0 },
1055 { 0x09, 0x400001f1 },
1056 { 0x0d, 0x02214030 },
1057 { 0x0e, 0x01014010 },
1058 { 0x0f, 0x02a19020 },
1059 { 0x10, 0x01a19021 },
1060 { 0x11, 0x90100140 },
1061 { 0x12, 0x01813122 },
1062 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001063};
1064
Takashi Iwai36c9db72013-01-17 17:07:59 +01001065/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001066 STAC 9200 pin configs for
1067 102801C0
1068 102801C1
1069*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001070static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1071 { 0x08, 0x400001f0 },
1072 { 0x09, 0x400001f1 },
1073 { 0x0d, 0x0221401f },
1074 { 0x0e, 0x01014010 },
1075 { 0x0f, 0x01813020 },
1076 { 0x10, 0x02a19021 },
1077 { 0x11, 0x90100140 },
1078 { 0x12, 0x400001f2 },
1079 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001080};
1081
Takashi Iwai36c9db72013-01-17 17:07:59 +01001082/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001083 STAC 9200 pin configs for
1084 102801C4 (Dell Dimension E310)
1085 102801C5
1086 102801C7
1087 102801D9
1088 102801DA
1089 102801E3
1090*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001091static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1092 { 0x08, 0x400001f0 },
1093 { 0x09, 0x400001f1 },
1094 { 0x0d, 0x0221401f },
1095 { 0x0e, 0x01014010 },
1096 { 0x0f, 0x01813020 },
1097 { 0x10, 0x01a19021 },
1098 { 0x11, 0x90100140 },
1099 { 0x12, 0x400001f2 },
1100 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001101};
1102
1103
1104/*
1105 STAC 9200-32 pin configs for
1106 102801B5 (Dell Inspiron 630m)
1107 102801D8 (Dell Inspiron 640m)
1108*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001109static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1110 { 0x08, 0x40c003fa },
1111 { 0x09, 0x03441340 },
1112 { 0x0d, 0x0321121f },
1113 { 0x0e, 0x90170310 },
1114 { 0x0f, 0x408003fb },
1115 { 0x10, 0x03a11020 },
1116 { 0x11, 0x401003fc },
1117 { 0x12, 0x403003fd },
1118 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001119};
1120
1121/*
1122 STAC 9200-32 pin configs for
1123 102801C2 (Dell Latitude D620)
1124 102801C8
1125 102801CC (Dell Latitude D820)
1126 102801D4
1127 102801D6
1128*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001129static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1130 { 0x08, 0x40c003fa },
1131 { 0x09, 0x0144131f },
1132 { 0x0d, 0x0321121f },
1133 { 0x0e, 0x90170310 },
1134 { 0x0f, 0x90a70321 },
1135 { 0x10, 0x03a11020 },
1136 { 0x11, 0x401003fb },
1137 { 0x12, 0x40f000fc },
1138 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001139};
1140
1141/*
1142 STAC 9200-32 pin configs for
1143 102801CE (Dell XPS M1710)
1144 102801CF (Dell Precision M90)
1145*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001146static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1147 { 0x08, 0x40c003fa },
1148 { 0x09, 0x01441340 },
1149 { 0x0d, 0x0421421f },
1150 { 0x0e, 0x90170310 },
1151 { 0x0f, 0x408003fb },
1152 { 0x10, 0x04a1102e },
1153 { 0x11, 0x90170311 },
1154 { 0x12, 0x403003fc },
1155 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001156};
1157
1158/*
1159 STAC 9200-32 pin configs for
1160 102801C9
1161 102801CA
1162 102801CB (Dell Latitude 120L)
1163 102801D3
1164*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001165static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1166 { 0x08, 0x40c003fa },
1167 { 0x09, 0x404003fb },
1168 { 0x0d, 0x0321121f },
1169 { 0x0e, 0x90170310 },
1170 { 0x0f, 0x408003fc },
1171 { 0x10, 0x03a11020 },
1172 { 0x11, 0x401003fd },
1173 { 0x12, 0x403003fe },
1174 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001175};
1176
1177/*
1178 STAC 9200-32 pin configs for
1179 102801BD (Dell Inspiron E1505n)
1180 102801EE
1181 102801EF
1182*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001183static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1184 { 0x08, 0x40c003fa },
1185 { 0x09, 0x01441340 },
1186 { 0x0d, 0x0421121f },
1187 { 0x0e, 0x90170310 },
1188 { 0x0f, 0x408003fb },
1189 { 0x10, 0x04a11020 },
1190 { 0x11, 0x401003fc },
1191 { 0x12, 0x403003fd },
1192 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001193};
1194
1195/*
1196 STAC 9200-32 pin configs for
1197 102801F5 (Dell Inspiron 1501)
1198 102801F6
1199*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001200static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1201 { 0x08, 0x40c003fa },
1202 { 0x09, 0x404003fb },
1203 { 0x0d, 0x0421121f },
1204 { 0x0e, 0x90170310 },
1205 { 0x0f, 0x408003fc },
1206 { 0x10, 0x04a11020 },
1207 { 0x11, 0x401003fd },
1208 { 0x12, 0x403003fe },
1209 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001210};
1211
1212/*
1213 STAC 9200-32
1214 102801CD (Dell Inspiron E1705/9400)
1215*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001216static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1217 { 0x08, 0x40c003fa },
1218 { 0x09, 0x01441340 },
1219 { 0x0d, 0x0421121f },
1220 { 0x0e, 0x90170310 },
1221 { 0x0f, 0x90170310 },
1222 { 0x10, 0x04a11020 },
1223 { 0x11, 0x90170310 },
1224 { 0x12, 0x40f003fc },
1225 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001226};
1227
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001228static const struct hda_pintbl oqo9200_pin_configs[] = {
1229 { 0x08, 0x40c000f0 },
1230 { 0x09, 0x404000f1 },
1231 { 0x0d, 0x0221121f },
1232 { 0x0e, 0x02211210 },
1233 { 0x0f, 0x90170111 },
1234 { 0x10, 0x90a70120 },
1235 { 0x11, 0x400000f2 },
1236 { 0x12, 0x400000f3 },
1237 {}
Tobin Davisbf277782008-02-03 20:31:47 +01001238};
1239
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001240
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001241static void stac9200_fixup_panasonic(struct hda_codec *codec,
1242 const struct hda_fixup *fix, int action)
1243{
1244 struct sigmatel_spec *spec = codec->spec;
1245
Takashi Iwai36c9db72013-01-17 17:07:59 +01001246 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001247 spec->gpio_mask = spec->gpio_dir = 0x09;
1248 spec->gpio_data = 0x00;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001249 /* CF-74 has no headphone detection, and the driver should *NOT*
1250 * do detection and HP/speaker toggle because the hardware does it.
1251 */
Takashi Iwai36c9db72013-01-17 17:07:59 +01001252 spec->gen.suppress_auto_mute = 1;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001253 }
1254}
1255
1256
1257static const struct hda_fixup stac9200_fixups[] = {
1258 [STAC_REF] = {
1259 .type = HDA_FIXUP_PINS,
1260 .v.pins = ref9200_pin_configs,
1261 },
1262 [STAC_9200_OQO] = {
1263 .type = HDA_FIXUP_PINS,
1264 .v.pins = oqo9200_pin_configs,
1265 .chained = true,
1266 .chain_id = STAC_9200_EAPD_INIT,
1267 },
1268 [STAC_9200_DELL_D21] = {
1269 .type = HDA_FIXUP_PINS,
1270 .v.pins = dell9200_d21_pin_configs,
1271 },
1272 [STAC_9200_DELL_D22] = {
1273 .type = HDA_FIXUP_PINS,
1274 .v.pins = dell9200_d22_pin_configs,
1275 },
1276 [STAC_9200_DELL_D23] = {
1277 .type = HDA_FIXUP_PINS,
1278 .v.pins = dell9200_d23_pin_configs,
1279 },
1280 [STAC_9200_DELL_M21] = {
1281 .type = HDA_FIXUP_PINS,
1282 .v.pins = dell9200_m21_pin_configs,
1283 },
1284 [STAC_9200_DELL_M22] = {
1285 .type = HDA_FIXUP_PINS,
1286 .v.pins = dell9200_m22_pin_configs,
1287 },
1288 [STAC_9200_DELL_M23] = {
1289 .type = HDA_FIXUP_PINS,
1290 .v.pins = dell9200_m23_pin_configs,
1291 },
1292 [STAC_9200_DELL_M24] = {
1293 .type = HDA_FIXUP_PINS,
1294 .v.pins = dell9200_m24_pin_configs,
1295 },
1296 [STAC_9200_DELL_M25] = {
1297 .type = HDA_FIXUP_PINS,
1298 .v.pins = dell9200_m25_pin_configs,
1299 },
1300 [STAC_9200_DELL_M26] = {
1301 .type = HDA_FIXUP_PINS,
1302 .v.pins = dell9200_m26_pin_configs,
1303 },
1304 [STAC_9200_DELL_M27] = {
1305 .type = HDA_FIXUP_PINS,
1306 .v.pins = dell9200_m27_pin_configs,
1307 },
1308 [STAC_9200_M4] = {
1309 .type = HDA_FIXUP_PINS,
1310 .v.pins = gateway9200_m4_pin_configs,
1311 .chained = true,
1312 .chain_id = STAC_9200_EAPD_INIT,
1313 },
1314 [STAC_9200_M4_2] = {
1315 .type = HDA_FIXUP_PINS,
1316 .v.pins = gateway9200_m4_2_pin_configs,
1317 .chained = true,
1318 .chain_id = STAC_9200_EAPD_INIT,
1319 },
1320 [STAC_9200_PANASONIC] = {
1321 .type = HDA_FIXUP_FUNC,
1322 .v.func = stac9200_fixup_panasonic,
1323 },
1324 [STAC_9200_EAPD_INIT] = {
1325 .type = HDA_FIXUP_VERBS,
1326 .v.verbs = (const struct hda_verb[]) {
1327 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1328 {}
1329 },
1330 },
Matt Porter403d1942005-11-29 15:00:51 +01001331};
1332
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001333static const struct hda_model_fixup stac9200_models[] = {
1334 { .id = STAC_REF, .name = "ref" },
1335 { .id = STAC_9200_OQO, .name = "oqo" },
1336 { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1337 { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1338 { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1339 { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1340 { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1341 { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1342 { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1343 { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1344 { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1345 { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1346 { .id = STAC_9200_M4, .name = "gateway-m4" },
1347 { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1348 { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1349 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001350};
1351
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001352static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001353 /* SigmaTel reference board */
1354 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1355 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001356 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1357 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001358 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001359 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1360 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001362 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1364 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1366 "unknown Dell", STAC_9200_DELL_D22),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1368 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001370 "Dell Latitude D620", STAC_9200_DELL_M22),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1372 "unknown Dell", STAC_9200_DELL_D23),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1374 "unknown Dell", STAC_9200_DELL_D23),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1376 "unknown Dell", STAC_9200_DELL_M22),
1377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1378 "unknown Dell", STAC_9200_DELL_M24),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1380 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001382 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001384 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001386 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001388 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390 "Dell Precision M90", STAC_9200_DELL_M23),
1391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1392 "unknown Dell", STAC_9200_DELL_M22),
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1394 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001396 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1400 "unknown Dell", STAC_9200_DELL_D23),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1402 "unknown Dell", STAC_9200_DELL_D23),
1403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1404 "unknown Dell", STAC_9200_DELL_D21),
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1406 "unknown Dell", STAC_9200_DELL_D23),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1408 "unknown Dell", STAC_9200_DELL_D21),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1410 "unknown Dell", STAC_9200_DELL_M25),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1412 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001414 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1416 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001417 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001418 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001419 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001420 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1421 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1422 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001423 /* OQO Mobile */
1424 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001425 {} /* terminator */
1426};
1427
Takashi Iwaid2077d42013-01-14 14:20:16 +01001428static const struct hda_pintbl ref925x_pin_configs[] = {
1429 { 0x07, 0x40c003f0 },
1430 { 0x08, 0x424503f2 },
1431 { 0x0a, 0x01813022 },
1432 { 0x0b, 0x02a19021 },
1433 { 0x0c, 0x90a70320 },
1434 { 0x0d, 0x02214210 },
1435 { 0x10, 0x01019020 },
1436 { 0x11, 0x9033032e },
1437 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001438};
1439
Takashi Iwaid2077d42013-01-14 14:20:16 +01001440static const struct hda_pintbl stac925xM1_pin_configs[] = {
1441 { 0x07, 0x40c003f4 },
1442 { 0x08, 0x424503f2 },
1443 { 0x0a, 0x400000f3 },
1444 { 0x0b, 0x02a19020 },
1445 { 0x0c, 0x40a000f0 },
1446 { 0x0d, 0x90100210 },
1447 { 0x10, 0x400003f1 },
1448 { 0x11, 0x9033032e },
1449 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001450};
1451
Takashi Iwaid2077d42013-01-14 14:20:16 +01001452static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1453 { 0x07, 0x40c003f4 },
1454 { 0x08, 0x424503f2 },
1455 { 0x0a, 0x400000f3 },
1456 { 0x0b, 0x02a19020 },
1457 { 0x0c, 0x40a000f0 },
1458 { 0x0d, 0x90100210 },
1459 { 0x10, 0x400003f1 },
1460 { 0x11, 0x9033032e },
1461 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001462};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001463
Takashi Iwaid2077d42013-01-14 14:20:16 +01001464static const struct hda_pintbl stac925xM2_pin_configs[] = {
1465 { 0x07, 0x40c003f4 },
1466 { 0x08, 0x424503f2 },
1467 { 0x0a, 0x400000f3 },
1468 { 0x0b, 0x02a19020 },
1469 { 0x0c, 0x40a000f0 },
1470 { 0x0d, 0x90100210 },
1471 { 0x10, 0x400003f1 },
1472 { 0x11, 0x9033032e },
1473 {}
Tobin Davis2c11f952007-05-17 09:36:34 +02001474};
1475
Takashi Iwaid2077d42013-01-14 14:20:16 +01001476static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1477 { 0x07, 0x40c003f4 },
1478 { 0x08, 0x424503f2 },
1479 { 0x0a, 0x400000f3 },
1480 { 0x0b, 0x02a19020 },
1481 { 0x0c, 0x40a000f0 },
1482 { 0x0d, 0x90100210 },
1483 { 0x10, 0x400003f1 },
1484 { 0x11, 0x9033032e },
1485 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001486};
1487
Takashi Iwaid2077d42013-01-14 14:20:16 +01001488static const struct hda_pintbl stac925xM3_pin_configs[] = {
1489 { 0x07, 0x40c003f4 },
1490 { 0x08, 0x424503f2 },
1491 { 0x0a, 0x400000f3 },
1492 { 0x0b, 0x02a19020 },
1493 { 0x0c, 0x40a000f0 },
1494 { 0x0d, 0x90100210 },
1495 { 0x10, 0x400003f1 },
1496 { 0x11, 0x503303f3 },
1497 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001498};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001499
Takashi Iwaid2077d42013-01-14 14:20:16 +01001500static const struct hda_pintbl stac925xM5_pin_configs[] = {
1501 { 0x07, 0x40c003f4 },
1502 { 0x08, 0x424503f2 },
1503 { 0x0a, 0x400000f3 },
1504 { 0x0b, 0x02a19020 },
1505 { 0x0c, 0x40a000f0 },
1506 { 0x0d, 0x90100210 },
1507 { 0x10, 0x400003f1 },
1508 { 0x11, 0x9033032e },
1509 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001510};
1511
Takashi Iwaid2077d42013-01-14 14:20:16 +01001512static const struct hda_pintbl stac925xM6_pin_configs[] = {
1513 { 0x07, 0x40c003f4 },
1514 { 0x08, 0x424503f2 },
1515 { 0x0a, 0x400000f3 },
1516 { 0x0b, 0x02a19020 },
1517 { 0x0c, 0x40a000f0 },
1518 { 0x0d, 0x90100210 },
1519 { 0x10, 0x400003f1 },
1520 { 0x11, 0x90330320 },
1521 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001522};
1523
Takashi Iwaid2077d42013-01-14 14:20:16 +01001524static const struct hda_fixup stac925x_fixups[] = {
1525 [STAC_REF] = {
1526 .type = HDA_FIXUP_PINS,
1527 .v.pins = ref925x_pin_configs,
1528 },
1529 [STAC_M1] = {
1530 .type = HDA_FIXUP_PINS,
1531 .v.pins = stac925xM1_pin_configs,
1532 },
1533 [STAC_M1_2] = {
1534 .type = HDA_FIXUP_PINS,
1535 .v.pins = stac925xM1_2_pin_configs,
1536 },
1537 [STAC_M2] = {
1538 .type = HDA_FIXUP_PINS,
1539 .v.pins = stac925xM2_pin_configs,
1540 },
1541 [STAC_M2_2] = {
1542 .type = HDA_FIXUP_PINS,
1543 .v.pins = stac925xM2_2_pin_configs,
1544 },
1545 [STAC_M3] = {
1546 .type = HDA_FIXUP_PINS,
1547 .v.pins = stac925xM3_pin_configs,
1548 },
1549 [STAC_M5] = {
1550 .type = HDA_FIXUP_PINS,
1551 .v.pins = stac925xM5_pin_configs,
1552 },
1553 [STAC_M6] = {
1554 .type = HDA_FIXUP_PINS,
1555 .v.pins = stac925xM6_pin_configs,
1556 },
Tobin Davis8e21c342007-01-08 11:04:17 +01001557};
1558
Takashi Iwaid2077d42013-01-14 14:20:16 +01001559static const struct hda_model_fixup stac925x_models[] = {
1560 { .id = STAC_REF, .name = "ref" },
1561 { .id = STAC_M1, .name = "m1" },
1562 { .id = STAC_M1_2, .name = "m1-2" },
1563 { .id = STAC_M2, .name = "m2" },
1564 { .id = STAC_M2_2, .name = "m2-2" },
1565 { .id = STAC_M3, .name = "m3" },
1566 { .id = STAC_M5, .name = "m5" },
1567 { .id = STAC_M6, .name = "m6" },
1568 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001569};
1570
Takashi Iwaid2077d42013-01-14 14:20:16 +01001571static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1572 /* SigmaTel reference board */
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1575 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1576
1577 /* Default table for unknown ID */
1578 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1579
1580 /* gateway machines are checked via codec ssid */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001581 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1582 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1583 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1584 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001585 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001586 /* Not sure about the brand name for those */
1587 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1588 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1589 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1590 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001591 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001592};
1593
Takashi Iwai55e30142013-01-14 17:30:04 +01001594static const struct hda_pintbl ref92hd73xx_pin_configs[] = {
1595 { 0x0a, 0x02214030 },
1596 { 0x0b, 0x02a19040 },
1597 { 0x0c, 0x01a19020 },
1598 { 0x0d, 0x02214030 },
1599 { 0x0e, 0x0181302e },
1600 { 0x0f, 0x01014010 },
1601 { 0x10, 0x01014020 },
1602 { 0x11, 0x01014030 },
1603 { 0x12, 0x02319040 },
1604 { 0x13, 0x90a000f0 },
1605 { 0x14, 0x90a000f0 },
1606 { 0x22, 0x01452050 },
1607 { 0x23, 0x01452050 },
1608 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01001609};
1610
Takashi Iwai55e30142013-01-14 17:30:04 +01001611static const struct hda_pintbl dell_m6_pin_configs[] = {
1612 { 0x0a, 0x0321101f },
1613 { 0x0b, 0x4f00000f },
1614 { 0x0c, 0x4f0000f0 },
1615 { 0x0d, 0x90170110 },
1616 { 0x0e, 0x03a11020 },
1617 { 0x0f, 0x0321101f },
1618 { 0x10, 0x4f0000f0 },
1619 { 0x11, 0x4f0000f0 },
1620 { 0x12, 0x4f0000f0 },
1621 { 0x13, 0x90a60160 },
1622 { 0x14, 0x4f0000f0 },
1623 { 0x22, 0x4f0000f0 },
1624 { 0x23, 0x4f0000f0 },
1625 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001626};
1627
Takashi Iwai55e30142013-01-14 17:30:04 +01001628static const struct hda_pintbl alienware_m17x_pin_configs[] = {
1629 { 0x0a, 0x0321101f },
1630 { 0x0b, 0x0321101f },
1631 { 0x0c, 0x03a11020 },
1632 { 0x0d, 0x03014020 },
1633 { 0x0e, 0x90170110 },
1634 { 0x0f, 0x4f0000f0 },
1635 { 0x10, 0x4f0000f0 },
1636 { 0x11, 0x4f0000f0 },
1637 { 0x12, 0x4f0000f0 },
1638 { 0x13, 0x90a60160 },
1639 { 0x14, 0x4f0000f0 },
1640 { 0x22, 0x4f0000f0 },
1641 { 0x23, 0x904601b0 },
1642 {}
Takashi Iwai842ae632009-09-02 07:43:08 +02001643};
1644
Takashi Iwai55e30142013-01-14 17:30:04 +01001645static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1646 { 0x0a, 0x02214230 },
1647 { 0x0b, 0x02A19240 },
1648 { 0x0c, 0x01013214 },
1649 { 0x0d, 0x01014210 },
1650 { 0x0e, 0x01A19250 },
1651 { 0x0f, 0x01011212 },
1652 { 0x10, 0x01016211 },
1653 {}
Alexey Fisher52dc4382009-12-12 11:16:41 +02001654};
1655
Takashi Iwai55e30142013-01-14 17:30:04 +01001656static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
1657 const struct hda_fixup *fix, int action)
1658{
1659 struct sigmatel_spec *spec = codec->spec;
1660
1661 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1662 return;
1663
1664 snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs);
1665 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
1666}
1667
1668static void stac92hd73xx_fixup_dell(struct hda_codec *codec)
1669{
1670 struct sigmatel_spec *spec = codec->spec;
1671
1672 snd_hda_apply_pincfgs(codec, dell_m6_pin_configs);
Takashi Iwai55e30142013-01-14 17:30:04 +01001673 spec->eapd_switch = 0;
1674}
1675
1676static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec,
1677 const struct hda_fixup *fix, int action)
1678{
1679 struct sigmatel_spec *spec = codec->spec;
1680
1681 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1682 return;
1683
1684 stac92hd73xx_fixup_dell(codec);
1685 snd_hda_add_verbs(codec, dell_eq_core_init);
1686 spec->volknob_init = 1;
1687}
1688
1689/* Analog Mics */
1690static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec,
1691 const struct hda_fixup *fix, int action)
1692{
Takashi Iwai55e30142013-01-14 17:30:04 +01001693 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1694 return;
1695
1696 stac92hd73xx_fixup_dell(codec);
1697 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Takashi Iwai55e30142013-01-14 17:30:04 +01001698}
1699
1700/* Digital Mics */
1701static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec,
1702 const struct hda_fixup *fix, int action)
1703{
Takashi Iwai55e30142013-01-14 17:30:04 +01001704 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1705 return;
1706
1707 stac92hd73xx_fixup_dell(codec);
1708 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Takashi Iwai55e30142013-01-14 17:30:04 +01001709}
1710
1711/* Both */
1712static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec,
1713 const struct hda_fixup *fix, int action)
1714{
Takashi Iwai55e30142013-01-14 17:30:04 +01001715 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1716 return;
1717
1718 stac92hd73xx_fixup_dell(codec);
1719 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1720 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Takashi Iwai55e30142013-01-14 17:30:04 +01001721}
1722
1723static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec,
1724 const struct hda_fixup *fix, int action)
1725{
1726 struct sigmatel_spec *spec = codec->spec;
1727
1728 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1729 return;
1730
1731 snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs);
Takashi Iwai55e30142013-01-14 17:30:04 +01001732 spec->eapd_switch = 0;
1733}
1734
1735static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec,
1736 const struct hda_fixup *fix, int action)
1737{
Takashi Iwai36c9db72013-01-17 17:07:59 +01001738 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1739 codec->no_jack_detect = 1;
Takashi Iwai55e30142013-01-14 17:30:04 +01001740}
1741
1742static const struct hda_fixup stac92hd73xx_fixups[] = {
1743 [STAC_92HD73XX_REF] = {
1744 .type = HDA_FIXUP_FUNC,
1745 .v.func = stac92hd73xx_fixup_ref,
1746 },
1747 [STAC_DELL_M6_AMIC] = {
1748 .type = HDA_FIXUP_FUNC,
1749 .v.func = stac92hd73xx_fixup_dell_m6_amic,
1750 },
1751 [STAC_DELL_M6_DMIC] = {
1752 .type = HDA_FIXUP_FUNC,
1753 .v.func = stac92hd73xx_fixup_dell_m6_dmic,
1754 },
1755 [STAC_DELL_M6_BOTH] = {
1756 .type = HDA_FIXUP_FUNC,
1757 .v.func = stac92hd73xx_fixup_dell_m6_both,
1758 },
1759 [STAC_DELL_EQ] = {
1760 .type = HDA_FIXUP_FUNC,
1761 .v.func = stac92hd73xx_fixup_dell_eq,
1762 },
1763 [STAC_ALIENWARE_M17X] = {
1764 .type = HDA_FIXUP_FUNC,
1765 .v.func = stac92hd73xx_fixup_alienware_m17x,
1766 },
1767 [STAC_92HD73XX_INTEL] = {
1768 .type = HDA_FIXUP_PINS,
1769 .v.pins = intel_dg45id_pin_configs,
1770 },
1771 [STAC_92HD73XX_NO_JD] = {
1772 .type = HDA_FIXUP_FUNC,
1773 .v.func = stac92hd73xx_fixup_no_jd,
1774 }
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001775};
1776
Takashi Iwai55e30142013-01-14 17:30:04 +01001777static const struct hda_model_fixup stac92hd73xx_models[] = {
1778 { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" },
1779 { .id = STAC_92HD73XX_REF, .name = "ref" },
1780 { .id = STAC_92HD73XX_INTEL, .name = "intel" },
1781 { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" },
1782 { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" },
1783 { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" },
1784 { .id = STAC_DELL_EQ, .name = "dell-eq" },
1785 { .id = STAC_ALIENWARE_M17X, .name = "alienware" },
1786 {}
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001787};
1788
Takashi Iwai55e30142013-01-14 17:30:04 +01001789static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001790 /* SigmaTel reference board */
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001792 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001793 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1794 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001795 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1796 "Intel DG45ID", STAC_92HD73XX_INTEL),
1797 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1798 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001799 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001800 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001801 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001802 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001803 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001804 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001805 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001806 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001807 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001808 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001809 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001810 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001811 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001812 "unknown Dell", STAC_DELL_M6_DMIC),
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1814 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001816 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1818 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1820 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1822 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001824 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001826 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Takashi Iwai55e30142013-01-14 17:30:04 +01001827 /* codec SSID matching */
Takashi Iwai842ae632009-09-02 07:43:08 +02001828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1829 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1831 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001833 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001834 {} /* terminator */
1835};
1836
Takashi Iwai372f8c72013-01-14 18:06:34 +01001837static const struct hda_pintbl ref92hd83xxx_pin_configs[] = {
1838 { 0x0a, 0x02214030 },
1839 { 0x0b, 0x02211010 },
1840 { 0x0c, 0x02a19020 },
1841 { 0x0d, 0x02170130 },
1842 { 0x0e, 0x01014050 },
1843 { 0x0f, 0x01819040 },
1844 { 0x10, 0x01014020 },
1845 { 0x11, 0x90a3014e },
1846 { 0x1f, 0x01451160 },
1847 { 0x20, 0x98560170 },
1848 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001849};
1850
Takashi Iwai372f8c72013-01-14 18:06:34 +01001851static const struct hda_pintbl dell_s14_pin_configs[] = {
1852 { 0x0a, 0x0221403f },
1853 { 0x0b, 0x0221101f },
1854 { 0x0c, 0x02a19020 },
1855 { 0x0d, 0x90170110 },
1856 { 0x0e, 0x40f000f0 },
1857 { 0x0f, 0x40f000f0 },
1858 { 0x10, 0x40f000f0 },
1859 { 0x11, 0x90a60160 },
1860 { 0x1f, 0x40f000f0 },
1861 { 0x20, 0x40f000f0 },
1862 {}
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001863};
1864
Takashi Iwai372f8c72013-01-14 18:06:34 +01001865static const struct hda_pintbl dell_vostro_3500_pin_configs[] = {
1866 { 0x0a, 0x02a11020 },
1867 { 0x0b, 0x0221101f },
1868 { 0x0c, 0x400000f0 },
1869 { 0x0d, 0x90170110 },
1870 { 0x0e, 0x400000f1 },
1871 { 0x0f, 0x400000f2 },
1872 { 0x10, 0x400000f3 },
1873 { 0x11, 0x90a60160 },
1874 { 0x1f, 0x400000f4 },
1875 { 0x20, 0x400000f5 },
1876 {}
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001877};
1878
Takashi Iwai372f8c72013-01-14 18:06:34 +01001879static const struct hda_pintbl hp_dv7_4000_pin_configs[] = {
1880 { 0x0a, 0x03a12050 },
1881 { 0x0b, 0x0321201f },
1882 { 0x0c, 0x40f000f0 },
1883 { 0x0d, 0x90170110 },
1884 { 0x0e, 0x40f000f0 },
1885 { 0x0f, 0x40f000f0 },
1886 { 0x10, 0x90170110 },
1887 { 0x11, 0xd5a30140 },
1888 { 0x1f, 0x40f000f0 },
1889 { 0x20, 0x40f000f0 },
1890 {}
Steven Eastland48315592010-08-06 15:07:35 -06001891};
1892
Takashi Iwai372f8c72013-01-14 18:06:34 +01001893static const struct hda_pintbl hp_zephyr_pin_configs[] = {
1894 { 0x0a, 0x01813050 },
1895 { 0x0b, 0x0421201f },
1896 { 0x0c, 0x04a1205e },
1897 { 0x0d, 0x96130310 },
1898 { 0x0e, 0x96130310 },
1899 { 0x0f, 0x0101401f },
1900 { 0x10, 0x1111611f },
1901 { 0x11, 0xd5a30130 },
1902 {}
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001903};
1904
Takashi Iwai372f8c72013-01-14 18:06:34 +01001905static const struct hda_pintbl hp_cNB11_intquad_pin_configs[] = {
1906 { 0x0a, 0x40f000f0 },
1907 { 0x0b, 0x0221101f },
1908 { 0x0c, 0x02a11020 },
1909 { 0x0d, 0x92170110 },
1910 { 0x0e, 0x40f000f0 },
1911 { 0x0f, 0x92170110 },
1912 { 0x10, 0x40f000f0 },
1913 { 0x11, 0xd5a30130 },
1914 { 0x1f, 0x40f000f0 },
1915 { 0x20, 0x40f000f0 },
1916 {}
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001917};
1918
Takashi Iwai372f8c72013-01-14 18:06:34 +01001919static void stac92hd83xxx_fixup_hp(struct hda_codec *codec,
1920 const struct hda_fixup *fix, int action)
1921{
1922 struct sigmatel_spec *spec = codec->spec;
1923
1924 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1925 return;
1926
1927 if (hp_bnb2011_with_dock(codec)) {
1928 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
1929 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
1930 }
1931
1932 if (find_mute_led_cfg(codec, spec->default_polarity))
1933 snd_printd("mute LED gpio %d polarity %d\n",
1934 spec->gpio_led,
1935 spec->gpio_led_polarity);
1936}
1937
1938static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec,
1939 const struct hda_fixup *fix, int action)
1940{
1941 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1942 return;
1943
1944 snd_hda_apply_pincfgs(codec, hp_zephyr_pin_configs);
1945 snd_hda_add_verbs(codec, stac92hd83xxx_hp_zephyr_init);
1946}
1947
1948static void stac92hd83xxx_fixup_hp_led(struct hda_codec *codec,
1949 const struct hda_fixup *fix, int action)
1950{
1951 struct sigmatel_spec *spec = codec->spec;
1952
1953 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1954 spec->default_polarity = 0;
1955}
1956
1957static void stac92hd83xxx_fixup_hp_inv_led(struct hda_codec *codec,
1958 const struct hda_fixup *fix, int action)
1959{
1960 struct sigmatel_spec *spec = codec->spec;
1961
1962 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1963 spec->default_polarity = 1;
1964}
1965
1966static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
1967 const struct hda_fixup *fix, int action)
1968{
1969 struct sigmatel_spec *spec = codec->spec;
1970
1971 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1972 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
1973}
1974
1975static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
1976 const struct hda_fixup *fix, int action)
1977{
1978 struct sigmatel_spec *spec = codec->spec;
1979
1980 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1981 spec->headset_jack = 1;
1982}
1983
1984static const struct hda_fixup stac92hd83xxx_fixups[] = {
1985 [STAC_92HD83XXX_REF] = {
1986 .type = HDA_FIXUP_PINS,
1987 .v.pins = ref92hd83xxx_pin_configs,
1988 },
1989 [STAC_92HD83XXX_PWR_REF] = {
1990 .type = HDA_FIXUP_PINS,
1991 .v.pins = ref92hd83xxx_pin_configs,
1992 },
1993 [STAC_DELL_S14] = {
1994 .type = HDA_FIXUP_PINS,
1995 .v.pins = dell_s14_pin_configs,
1996 },
1997 [STAC_DELL_VOSTRO_3500] = {
1998 .type = HDA_FIXUP_PINS,
1999 .v.pins = dell_vostro_3500_pin_configs,
2000 },
2001 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = {
2002 .type = HDA_FIXUP_PINS,
2003 .v.pins = hp_cNB11_intquad_pin_configs,
2004 .chained = true,
2005 .chain_id = STAC_92HD83XXX_HP,
2006 },
2007 [STAC_92HD83XXX_HP] = {
2008 .type = HDA_FIXUP_FUNC,
2009 .v.func = stac92hd83xxx_fixup_hp,
2010 },
2011 [STAC_HP_DV7_4000] = {
2012 .type = HDA_FIXUP_PINS,
2013 .v.pins = hp_dv7_4000_pin_configs,
2014 .chained = true,
2015 .chain_id = STAC_92HD83XXX_HP,
2016 },
2017 [STAC_HP_ZEPHYR] = {
2018 .type = HDA_FIXUP_FUNC,
2019 .v.func = stac92hd83xxx_fixup_hp_zephyr,
2020 .chained = true,
2021 .chain_id = STAC_92HD83XXX_HP,
2022 },
2023 [STAC_92HD83XXX_HP_LED] = {
2024 .type = HDA_FIXUP_FUNC,
2025 .v.func = stac92hd83xxx_fixup_hp_led,
2026 .chained = true,
2027 .chain_id = STAC_92HD83XXX_HP,
2028 },
2029 [STAC_92HD83XXX_HP_INV_LED] = {
2030 .type = HDA_FIXUP_FUNC,
2031 .v.func = stac92hd83xxx_fixup_hp_inv_led,
2032 .chained = true,
2033 .chain_id = STAC_92HD83XXX_HP,
2034 },
2035 [STAC_92HD83XXX_HP_MIC_LED] = {
2036 .type = HDA_FIXUP_FUNC,
2037 .v.func = stac92hd83xxx_fixup_hp_mic_led,
2038 .chained = true,
2039 .chain_id = STAC_92HD83XXX_HP,
2040 },
2041 [STAC_92HD83XXX_HEADSET_JACK] = {
2042 .type = HDA_FIXUP_FUNC,
2043 .v.func = stac92hd83xxx_fixup_headset_jack,
2044 },
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002045};
2046
Takashi Iwai372f8c72013-01-14 18:06:34 +01002047static const struct hda_model_fixup stac92hd83xxx_models[] = {
2048 { .id = STAC_92HD83XXX_REF, .name = "ref" },
2049 { .id = STAC_92HD83XXX_PWR_REF, .name = "mic-ref" },
2050 { .id = STAC_DELL_S14, .name = "dell-s14" },
2051 { .id = STAC_DELL_VOSTRO_3500, .name = "dell-vostro-3500" },
2052 { .id = STAC_92HD83XXX_HP_cNB11_INTQUAD, .name = "hp_cNB11_intquad" },
2053 { .id = STAC_HP_DV7_4000, .name = "hp-dv7-4000" },
2054 { .id = STAC_HP_ZEPHYR, .name = "hp-zephyr" },
2055 { .id = STAC_92HD83XXX_HP_LED, .name = "hp-led" },
2056 { .id = STAC_92HD83XXX_HP_INV_LED, .name = "hp-inv-led" },
2057 { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" },
2058 { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" },
2059 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002060};
2061
Takashi Iwai372f8c72013-01-14 18:06:34 +01002062static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002063 /* SigmaTel reference board */
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01002065 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002066 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2067 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05002068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
2069 "unknown Dell", STAC_DELL_S14),
David Henningsson8d032a82012-10-09 12:48:40 +02002070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
2071 "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
2073 "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
2075 "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
2077 "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
2079 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
2081 "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
2083 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
2085 "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
2087 "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01002088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
2089 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002090 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
2091 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
2093 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
2095 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
Takashi Iwai8ae58652012-12-13 14:33:42 +01002097 "HP Pavilion dv7", STAC_HP_DV7_4000),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002098 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
2099 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
2101 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Takashi Iwai62cbde12012-09-14 11:58:54 +02002102 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
2103 "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05002104 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
2105 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
2107 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
2109 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
2111 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
2113 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
2115 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
2117 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
2119 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
2121 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
2123 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
2125 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2126 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2127 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2129 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2131 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002132 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2133 "HP", STAC_HP_ZEPHYR),
Takashi Iwaia3e19972012-07-26 08:17:20 +02002134 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2135 "HP Mini", STAC_92HD83XXX_HP_LED),
Gustavo Maciel Dias Vieira5afc13a2012-10-26 12:51:53 -02002136 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2137 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
Takashi Iwai8c698fe2013-01-15 11:20:50 +01002138 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a,
2139 "HP Mini", STAC_92HD83XXX_HP_LED),
Takashi Iwai372f8c72013-01-14 18:06:34 +01002140 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02002141 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002142};
2143
Takashi Iwai36c9db72013-01-17 17:07:59 +01002144/* HP dv7 bass switch - GPIO5 */
2145#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
2146static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
2147 struct snd_ctl_elem_value *ucontrol)
2148{
2149 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2150 struct sigmatel_spec *spec = codec->spec;
2151 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
2152 return 0;
2153}
2154
2155static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
2156 struct snd_ctl_elem_value *ucontrol)
2157{
2158 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2159 struct sigmatel_spec *spec = codec->spec;
2160 unsigned int gpio_data;
2161
2162 gpio_data = (spec->gpio_data & ~0x20) |
2163 (ucontrol->value.integer.value[0] ? 0x20 : 0);
2164 if (gpio_data == spec->gpio_data)
2165 return 0;
2166 spec->gpio_data = gpio_data;
2167 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
2168 return 1;
2169}
2170
2171static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
2172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2173 .info = stac_hp_bass_gpio_info,
2174 .get = stac_hp_bass_gpio_get,
2175 .put = stac_hp_bass_gpio_put,
2176};
2177
2178static int stac_add_hp_bass_switch(struct hda_codec *codec)
2179{
2180 struct sigmatel_spec *spec = codec->spec;
2181
2182 if (!snd_hda_gen_add_kctl(&spec->gen, "Bass Speaker Playback Switch",
2183 &stac_hp_bass_sw_ctrl))
2184 return -ENOMEM;
2185
2186 spec->gpio_mask |= 0x20;
2187 spec->gpio_dir |= 0x20;
2188 spec->gpio_data |= 0x20;
2189 return 0;
2190}
2191
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002192static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2193 { 0x0a, 0x02214030 },
2194 { 0x0b, 0x02a19040 },
2195 { 0x0c, 0x01a19020 },
2196 { 0x0d, 0x01014010 },
2197 { 0x0e, 0x0181302e },
2198 { 0x0f, 0x01014010 },
2199 { 0x14, 0x01019020 },
2200 { 0x18, 0x90a000f0 },
2201 { 0x19, 0x90a000f0 },
2202 { 0x1e, 0x01452050 },
2203 { 0x1f, 0x01452050 },
2204 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002205};
2206
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002207static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2208 { 0x0a, 0x0421101f },
2209 { 0x0b, 0x04a11221 },
2210 { 0x0c, 0x40f000f0 },
2211 { 0x0d, 0x90170110 },
2212 { 0x0e, 0x23a1902e },
2213 { 0x0f, 0x23014250 },
2214 { 0x14, 0x40f000f0 },
2215 { 0x18, 0x90a000f0 },
2216 { 0x19, 0x40f000f0 },
2217 { 0x1e, 0x4f0000f0 },
2218 { 0x1f, 0x4f0000f0 },
2219 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002220};
2221
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002222static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2223 { 0x0a, 0x0421101f },
2224 { 0x0b, 0x04a11221 },
2225 { 0x0c, 0x90a70330 },
2226 { 0x0d, 0x90170110 },
2227 { 0x0e, 0x23a1902e },
2228 { 0x0f, 0x23014250 },
2229 { 0x14, 0x40f000f0 },
2230 { 0x18, 0x40f000f0 },
2231 { 0x19, 0x40f000f0 },
2232 { 0x1e, 0x044413b0 },
2233 { 0x1f, 0x044413b0 },
2234 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002235};
2236
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002237static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2238 { 0x0a, 0x0421101f },
2239 { 0x0b, 0x04a11221 },
2240 { 0x0c, 0x90a70330 },
2241 { 0x0d, 0x90170110 },
2242 { 0x0e, 0x40f000f0 },
2243 { 0x0f, 0x40f000f0 },
2244 { 0x14, 0x40f000f0 },
2245 { 0x18, 0x90a000f0 },
2246 { 0x19, 0x40f000f0 },
2247 { 0x1e, 0x044413b0 },
2248 { 0x1f, 0x044413b0 },
2249 {}
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002250};
2251
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002252static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2253 const struct hda_fixup *fix, int action)
2254{
2255 struct sigmatel_spec *spec = codec->spec;
2256
2257 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2258 return;
2259
2260 snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2261 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2262}
2263
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002264static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2265 const struct hda_fixup *fix, int action)
2266{
2267 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai36c9db72013-01-17 17:07:59 +01002268 struct hda_jack_tbl *jack;
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002269
2270 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2271 return;
2272
2273 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002274 snd_hda_codec_write_cache(codec, codec->afg, 0,
2275 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai36c9db72013-01-17 17:07:59 +01002276 snd_hda_jack_detect_enable_callback(codec, codec->afg,
2277 STAC_VREF_EVENT,
2278 stac_vref_event);
2279 jack = snd_hda_jack_tbl_get(codec, codec->afg);
2280 if (jack)
2281 jack->private_data = 0x02;
2282
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002283 spec->gpio_mask |= 0x02;
2284
2285 /* enable internal microphone */
2286 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002287}
2288
2289static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2290 const struct hda_fixup *fix, int action)
2291{
2292 struct sigmatel_spec *spec = codec->spec;
2293
2294 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2295 return;
2296 spec->gpio_led = 0x01;
2297}
2298
2299static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2300 const struct hda_fixup *fix, int action)
2301{
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002302 unsigned int cap;
2303
2304 switch (action) {
2305 case HDA_FIXUP_ACT_PRE_PROBE:
2306 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Takashi Iwaif6655d52013-01-17 08:49:01 +01002307 break;
2308
2309 case HDA_FIXUP_ACT_PROBE:
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002310 /* enable bass on HP dv7 */
2311 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2312 cap &= AC_GPIO_IO_COUNT;
2313 if (cap >= 6)
2314 stac_add_hp_bass_switch(codec);
2315 break;
2316 }
2317}
2318
2319static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
2320 const struct hda_fixup *fix, int action)
2321{
2322 struct sigmatel_spec *spec = codec->spec;
2323
2324 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2325 return;
2326 spec->gpio_led = 0x08;
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002327}
2328
2329
2330static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
2331 const struct hda_fixup *fix, int action)
2332{
2333 struct sigmatel_spec *spec = codec->spec;
2334
2335 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2336 return;
2337
2338 if (hp_blike_system(codec->subsystem_id)) {
2339 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
2340 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
2341 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
2342 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
2343 /* It was changed in the BIOS to just satisfy MS DTM.
2344 * Lets turn it back into slaved HP
2345 */
2346 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
2347 | (AC_JACK_HP_OUT <<
2348 AC_DEFCFG_DEVICE_SHIFT);
2349 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
2350 | AC_DEFCFG_SEQUENCE)))
2351 | 0x1f;
2352 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
2353 }
2354 }
2355
Takashi Iwai36c9db72013-01-17 17:07:59 +01002356 if (find_mute_led_cfg(codec, 1))
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002357 snd_printd("mute LED gpio %d polarity %d\n",
2358 spec->gpio_led,
2359 spec->gpio_led_polarity);
2360
2361}
2362
2363static const struct hda_fixup stac92hd71bxx_fixups[] = {
2364 [STAC_92HD71BXX_REF] = {
2365 .type = HDA_FIXUP_FUNC,
2366 .v.func = stac92hd71bxx_fixup_ref,
2367 },
2368 [STAC_DELL_M4_1] = {
2369 .type = HDA_FIXUP_PINS,
2370 .v.pins = dell_m4_1_pin_configs,
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002371 },
2372 [STAC_DELL_M4_2] = {
2373 .type = HDA_FIXUP_PINS,
2374 .v.pins = dell_m4_2_pin_configs,
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002375 },
2376 [STAC_DELL_M4_3] = {
2377 .type = HDA_FIXUP_PINS,
2378 .v.pins = dell_m4_3_pin_configs,
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002379 },
2380 [STAC_HP_M4] = {
2381 .type = HDA_FIXUP_FUNC,
2382 .v.func = stac92hd71bxx_fixup_hp_m4,
2383 .chained = true,
2384 .chain_id = STAC_92HD71BXX_HP,
2385 },
2386 [STAC_HP_DV4] = {
2387 .type = HDA_FIXUP_FUNC,
2388 .v.func = stac92hd71bxx_fixup_hp_dv4,
2389 .chained = true,
2390 .chain_id = STAC_HP_DV5,
2391 },
2392 [STAC_HP_DV5] = {
2393 .type = HDA_FIXUP_FUNC,
2394 .v.func = stac92hd71bxx_fixup_hp_dv5,
2395 .chained = true,
2396 .chain_id = STAC_92HD71BXX_HP,
2397 },
2398 [STAC_HP_HDX] = {
2399 .type = HDA_FIXUP_FUNC,
2400 .v.func = stac92hd71bxx_fixup_hp_hdx,
2401 .chained = true,
2402 .chain_id = STAC_92HD71BXX_HP,
2403 },
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002404 [STAC_92HD71BXX_HP] = {
2405 .type = HDA_FIXUP_FUNC,
2406 .v.func = stac92hd71bxx_fixup_hp,
2407 },
Matthew Ranostaye035b842007-11-06 11:53:55 +01002408};
2409
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002410static const struct hda_model_fixup stac92hd71bxx_models[] = {
2411 { .id = STAC_92HD71BXX_REF, .name = "ref" },
2412 { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
2413 { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
2414 { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
2415 { .id = STAC_HP_M4, .name = "hp-m4" },
2416 { .id = STAC_HP_DV4, .name = "hp-dv4" },
2417 { .id = STAC_HP_DV5, .name = "hp-dv5" },
2418 { .id = STAC_HP_HDX, .name = "hp-hdx" },
Takashi Iwai36c9db72013-01-17 17:07:59 +01002419 { .id = STAC_HP_DV4, .name = "hp-dv4-1222nr" },
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002420 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002421};
2422
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002423static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002424 /* SigmaTel reference board */
2425 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2426 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002427 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2428 "DFI LanParty", STAC_92HD71BXX_REF),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01002429 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2430 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01002431 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2432 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002433 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002434 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002435 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2436 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002437 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2438 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04002439 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002440 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002441 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002442 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02002443 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2444 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05302445 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2446 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11002447 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2448 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02002449 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2450 "HP", STAC_HP_DV5),
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002451 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002452 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2453 "unknown Dell", STAC_DELL_M4_1),
2454 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2455 "unknown Dell", STAC_DELL_M4_1),
2456 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2457 "unknown Dell", STAC_DELL_M4_1),
2458 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2459 "unknown Dell", STAC_DELL_M4_1),
2460 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2461 "unknown Dell", STAC_DELL_M4_1),
2462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2463 "unknown Dell", STAC_DELL_M4_1),
2464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2465 "unknown Dell", STAC_DELL_M4_1),
2466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2467 "unknown Dell", STAC_DELL_M4_2),
2468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2469 "unknown Dell", STAC_DELL_M4_2),
2470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2471 "unknown Dell", STAC_DELL_M4_2),
2472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2473 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2475 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002476 {} /* terminator */
2477};
2478
Takashi Iwai0a427842013-01-14 15:20:13 +01002479static const struct hda_pintbl ref922x_pin_configs[] = {
2480 { 0x0a, 0x01014010 },
2481 { 0x0b, 0x01016011 },
2482 { 0x0c, 0x01012012 },
2483 { 0x0d, 0x0221401f },
2484 { 0x0e, 0x01813122 },
2485 { 0x0f, 0x01011014 },
2486 { 0x10, 0x01441030 },
2487 { 0x11, 0x01c41030 },
2488 { 0x15, 0x40000100 },
2489 { 0x1b, 0x40000100 },
2490 {}
Matt2f2f4252005-04-13 14:45:30 +02002491};
2492
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002493/*
2494 STAC 922X pin configs for
2495 102801A7
2496 102801AB
2497 102801A9
2498 102801D1
2499 102801D2
2500*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002501static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2502 { 0x0a, 0x02214030 },
2503 { 0x0b, 0x01a19021 },
2504 { 0x0c, 0x01111012 },
2505 { 0x0d, 0x01114010 },
2506 { 0x0e, 0x02a19020 },
2507 { 0x0f, 0x01117011 },
2508 { 0x10, 0x400001f0 },
2509 { 0x11, 0x400001f1 },
2510 { 0x15, 0x01813122 },
2511 { 0x1b, 0x400001f2 },
2512 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002513};
2514
2515/*
2516 STAC 922X pin configs for
2517 102801AC
2518 102801D0
2519*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002520static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2521 { 0x0a, 0x02214030 },
2522 { 0x0b, 0x01a19021 },
2523 { 0x0c, 0x01111012 },
2524 { 0x0d, 0x01114010 },
2525 { 0x0e, 0x02a19020 },
2526 { 0x0f, 0x01117011 },
2527 { 0x10, 0x01451140 },
2528 { 0x11, 0x400001f0 },
2529 { 0x15, 0x01813122 },
2530 { 0x1b, 0x400001f1 },
2531 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002532};
2533
2534/*
2535 STAC 922X pin configs for
2536 102801BF
2537*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002538static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2539 { 0x0a, 0x0321101f },
2540 { 0x0b, 0x01112024 },
2541 { 0x0c, 0x01111222 },
2542 { 0x0d, 0x91174220 },
2543 { 0x0e, 0x03a11050 },
2544 { 0x0f, 0x01116221 },
2545 { 0x10, 0x90a70330 },
2546 { 0x11, 0x01452340 },
2547 { 0x15, 0x40C003f1 },
2548 { 0x1b, 0x405003f0 },
2549 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002550};
2551
2552/*
2553 STAC 9221 A1 pin configs for
2554 102801D7 (Dell XPS M1210)
2555*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002556static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2557 { 0x0a, 0x02211211 },
2558 { 0x0b, 0x408103ff },
2559 { 0x0c, 0x02a1123e },
2560 { 0x0d, 0x90100310 },
2561 { 0x0e, 0x408003f1 },
2562 { 0x0f, 0x0221121f },
2563 { 0x10, 0x03451340 },
2564 { 0x11, 0x40c003f2 },
2565 { 0x15, 0x508003f3 },
2566 { 0x1b, 0x405003f4 },
2567 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002568};
2569
Takashi Iwai0a427842013-01-14 15:20:13 +01002570static const struct hda_pintbl d945gtp3_pin_configs[] = {
2571 { 0x0a, 0x0221401f },
2572 { 0x0b, 0x01a19022 },
2573 { 0x0c, 0x01813021 },
2574 { 0x0d, 0x01014010 },
2575 { 0x0e, 0x40000100 },
2576 { 0x0f, 0x40000100 },
2577 { 0x10, 0x40000100 },
2578 { 0x11, 0x40000100 },
2579 { 0x15, 0x02a19120 },
2580 { 0x1b, 0x40000100 },
2581 {}
Matt Porter403d1942005-11-29 15:00:51 +01002582};
2583
Takashi Iwai0a427842013-01-14 15:20:13 +01002584static const struct hda_pintbl d945gtp5_pin_configs[] = {
2585 { 0x0a, 0x0221401f },
2586 { 0x0b, 0x01011012 },
2587 { 0x0c, 0x01813024 },
2588 { 0x0d, 0x01014010 },
2589 { 0x0e, 0x01a19021 },
2590 { 0x0f, 0x01016011 },
2591 { 0x10, 0x01452130 },
2592 { 0x11, 0x40000100 },
2593 { 0x15, 0x02a19320 },
2594 { 0x1b, 0x40000100 },
2595 {}
Matt Porter403d1942005-11-29 15:00:51 +01002596};
2597
Takashi Iwai0a427842013-01-14 15:20:13 +01002598static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2599 { 0x0a, 0x0121e21f },
2600 { 0x0b, 0x400000ff },
2601 { 0x0c, 0x9017e110 },
2602 { 0x0d, 0x400000fd },
2603 { 0x0e, 0x400000fe },
2604 { 0x0f, 0x0181e020 },
2605 { 0x10, 0x1145e030 },
2606 { 0x11, 0x11c5e240 },
2607 { 0x15, 0x400000fc },
2608 { 0x1b, 0x400000fb },
2609 {}
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002610};
2611
Takashi Iwai0a427842013-01-14 15:20:13 +01002612static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2613 { 0x0a, 0x0121e21f },
2614 { 0x0b, 0x90a7012e },
2615 { 0x0c, 0x9017e110 },
2616 { 0x0d, 0x400000fd },
2617 { 0x0e, 0x400000fe },
2618 { 0x0f, 0x0181e020 },
2619 { 0x10, 0x1145e230 },
2620 { 0x11, 0x500000fa },
2621 { 0x15, 0x400000fc },
2622 { 0x1b, 0x400000fb },
2623 {}
Sylvain FORETf16928f2007-04-27 14:22:36 +02002624};
2625
Takashi Iwai0a427842013-01-14 15:20:13 +01002626static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2627 { 0x0a, 0x0121e21f },
2628 { 0x0b, 0x90a7012e },
2629 { 0x0c, 0x9017e110 },
2630 { 0x0d, 0x400000fd },
2631 { 0x0e, 0x400000fe },
2632 { 0x0f, 0x0181e020 },
2633 { 0x10, 0x1145e230 },
2634 { 0x11, 0x11c5e240 },
2635 { 0x15, 0x400000fc },
2636 { 0x1b, 0x400000fb },
2637 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002638};
2639
Takashi Iwai0a427842013-01-14 15:20:13 +01002640static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2641 { 0x0a, 0x0321e21f },
2642 { 0x0b, 0x03a1e02e },
2643 { 0x0c, 0x9017e110 },
2644 { 0x0d, 0x9017e11f },
2645 { 0x0e, 0x400000fe },
2646 { 0x0f, 0x0381e020 },
2647 { 0x10, 0x1345e230 },
2648 { 0x11, 0x13c5e240 },
2649 { 0x15, 0x400000fc },
2650 { 0x1b, 0x400000fb },
2651 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002652};
2653
Takashi Iwai0a427842013-01-14 15:20:13 +01002654static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2655 { 0x0a, 0x0321e21f },
2656 { 0x0b, 0x03a1e02e },
2657 { 0x0c, 0x9017e110 },
2658 { 0x0d, 0x9017e11f },
2659 { 0x0e, 0x400000fe },
2660 { 0x0f, 0x0381e020 },
2661 { 0x10, 0x1345e230 },
2662 { 0x11, 0x13c5e240 },
2663 { 0x15, 0x400000fc },
2664 { 0x1b, 0x400000fb },
2665 {}
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002666};
2667
Takashi Iwai0a427842013-01-14 15:20:13 +01002668static const struct hda_pintbl ecs202_pin_configs[] = {
2669 { 0x0a, 0x0221401f },
2670 { 0x0b, 0x02a19020 },
2671 { 0x0c, 0x01a19020 },
2672 { 0x0d, 0x01114010 },
2673 { 0x0e, 0x408000f0 },
2674 { 0x0f, 0x01813022 },
2675 { 0x10, 0x074510a0 },
2676 { 0x11, 0x40c400f1 },
2677 { 0x15, 0x9037012e },
2678 { 0x1b, 0x40e000f2 },
2679 {}
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002680};
Takashi Iwai76c08822007-06-19 12:17:42 +02002681
Takashi Iwai0a427842013-01-14 15:20:13 +01002682/* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2683static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2684 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2685 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2686 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2687 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2688 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2689 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2690 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2691 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2692 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2693 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2694 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2695 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2696 {}
2697};
2698
2699static const struct hda_fixup stac922x_fixups[];
2700
2701/* remap the fixup from codec SSID and apply it */
2702static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2703 const struct hda_fixup *fix,
2704 int action)
2705{
2706 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2707 return;
2708 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2709 stac922x_fixups);
2710 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2711 snd_hda_apply_fixup(codec, action);
2712}
2713
2714static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2715 const struct hda_fixup *fix,
2716 int action)
2717{
2718 struct sigmatel_spec *spec = codec->spec;
2719
2720 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2721 spec->gpio_mask = spec->gpio_dir = 0x03;
2722 spec->gpio_data = 0x03;
2723 }
2724}
2725
2726static const struct hda_fixup stac922x_fixups[] = {
2727 [STAC_D945_REF] = {
2728 .type = HDA_FIXUP_PINS,
2729 .v.pins = ref922x_pin_configs,
2730 },
2731 [STAC_D945GTP3] = {
2732 .type = HDA_FIXUP_PINS,
2733 .v.pins = d945gtp3_pin_configs,
2734 },
2735 [STAC_D945GTP5] = {
2736 .type = HDA_FIXUP_PINS,
2737 .v.pins = d945gtp5_pin_configs,
2738 },
2739 [STAC_INTEL_MAC_AUTO] = {
2740 .type = HDA_FIXUP_FUNC,
2741 .v.func = stac922x_fixup_intel_mac_auto,
2742 },
2743 [STAC_INTEL_MAC_V1] = {
2744 .type = HDA_FIXUP_PINS,
2745 .v.pins = intel_mac_v1_pin_configs,
2746 .chained = true,
2747 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2748 },
2749 [STAC_INTEL_MAC_V2] = {
2750 .type = HDA_FIXUP_PINS,
2751 .v.pins = intel_mac_v2_pin_configs,
2752 .chained = true,
2753 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2754 },
2755 [STAC_INTEL_MAC_V3] = {
2756 .type = HDA_FIXUP_PINS,
2757 .v.pins = intel_mac_v3_pin_configs,
2758 .chained = true,
2759 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2760 },
2761 [STAC_INTEL_MAC_V4] = {
2762 .type = HDA_FIXUP_PINS,
2763 .v.pins = intel_mac_v4_pin_configs,
2764 .chained = true,
2765 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2766 },
2767 [STAC_INTEL_MAC_V5] = {
2768 .type = HDA_FIXUP_PINS,
2769 .v.pins = intel_mac_v5_pin_configs,
2770 .chained = true,
2771 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2772 },
2773 [STAC_922X_INTEL_MAC_GPIO] = {
2774 .type = HDA_FIXUP_FUNC,
2775 .v.func = stac922x_fixup_intel_mac_gpio,
2776 },
2777 [STAC_ECS_202] = {
2778 .type = HDA_FIXUP_PINS,
2779 .v.pins = ecs202_pin_configs,
2780 },
2781 [STAC_922X_DELL_D81] = {
2782 .type = HDA_FIXUP_PINS,
2783 .v.pins = dell_922x_d81_pin_configs,
2784 },
2785 [STAC_922X_DELL_D82] = {
2786 .type = HDA_FIXUP_PINS,
2787 .v.pins = dell_922x_d82_pin_configs,
2788 },
2789 [STAC_922X_DELL_M81] = {
2790 .type = HDA_FIXUP_PINS,
2791 .v.pins = dell_922x_m81_pin_configs,
2792 },
2793 [STAC_922X_DELL_M82] = {
2794 .type = HDA_FIXUP_PINS,
2795 .v.pins = dell_922x_m82_pin_configs,
2796 },
2797};
2798
2799static const struct hda_model_fixup stac922x_models[] = {
2800 { .id = STAC_D945_REF, .name = "ref" },
2801 { .id = STAC_D945GTP5, .name = "5stack" },
2802 { .id = STAC_D945GTP3, .name = "3stack" },
2803 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
2804 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
2805 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
2806 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
2807 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
2808 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
2809 { .id = STAC_ECS_202, .name = "ecs202" },
2810 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
2811 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
2812 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
2813 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002814 /* for backward compatibility */
Takashi Iwai0a427842013-01-14 15:20:13 +01002815 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
2816 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
2817 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
2818 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
2819 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
2820 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
2821 {}
Matt Porter403d1942005-11-29 15:00:51 +01002822};
2823
Takashi Iwai0a427842013-01-14 15:20:13 +01002824static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002825 /* SigmaTel reference board */
2826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2827 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002828 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2829 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002830 /* Intel 945G based systems */
2831 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2832 "Intel D945G", STAC_D945GTP3),
2833 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2834 "Intel D945G", STAC_D945GTP3),
2835 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2836 "Intel D945G", STAC_D945GTP3),
2837 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2838 "Intel D945G", STAC_D945GTP3),
2839 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2840 "Intel D945G", STAC_D945GTP3),
2841 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2842 "Intel D945G", STAC_D945GTP3),
2843 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2844 "Intel D945G", STAC_D945GTP3),
2845 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2846 "Intel D945G", STAC_D945GTP3),
2847 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2848 "Intel D945G", STAC_D945GTP3),
2849 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2850 "Intel D945G", STAC_D945GTP3),
2851 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2852 "Intel D945G", STAC_D945GTP3),
2853 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2854 "Intel D945G", STAC_D945GTP3),
2855 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2856 "Intel D945G", STAC_D945GTP3),
2857 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2858 "Intel D945G", STAC_D945GTP3),
2859 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2860 "Intel D945G", STAC_D945GTP3),
2861 /* Intel D945G 5-stack systems */
2862 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2863 "Intel D945G", STAC_D945GTP5),
2864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2865 "Intel D945G", STAC_D945GTP5),
2866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2867 "Intel D945G", STAC_D945GTP5),
2868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2869 "Intel D945G", STAC_D945GTP5),
2870 /* Intel 945P based systems */
2871 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2872 "Intel D945P", STAC_D945GTP3),
2873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2874 "Intel D945P", STAC_D945GTP3),
2875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2876 "Intel D945P", STAC_D945GTP3),
2877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2878 "Intel D945P", STAC_D945GTP3),
2879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2880 "Intel D945P", STAC_D945GTP3),
2881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2882 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002883 /* other intel */
2884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2885 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002886 /* other systems */
Takashi Iwai0a427842013-01-14 15:20:13 +01002887
Nicolas Boichat536319a2008-07-21 22:18:01 +08002888 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwai0a427842013-01-14 15:20:13 +01002889 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
2890
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002891 /* Dell systems */
2892 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2893 "unknown Dell", STAC_922X_DELL_D81),
2894 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2895 "unknown Dell", STAC_922X_DELL_D81),
2896 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2897 "unknown Dell", STAC_922X_DELL_D81),
2898 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2899 "unknown Dell", STAC_922X_DELL_D82),
2900 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2901 "unknown Dell", STAC_922X_DELL_M81),
2902 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2903 "unknown Dell", STAC_922X_DELL_D82),
2904 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2905 "unknown Dell", STAC_922X_DELL_D81),
2906 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2907 "unknown Dell", STAC_922X_DELL_D81),
2908 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2909 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002910 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002911 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002912 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002913 {} /* terminator */
2914};
2915
Takashi Iwai29ac8362013-01-14 16:03:38 +01002916static const struct hda_pintbl ref927x_pin_configs[] = {
2917 { 0x0a, 0x02214020 },
2918 { 0x0b, 0x02a19080 },
2919 { 0x0c, 0x0181304e },
2920 { 0x0d, 0x01014010 },
2921 { 0x0e, 0x01a19040 },
2922 { 0x0f, 0x01011012 },
2923 { 0x10, 0x01016011 },
2924 { 0x11, 0x0101201f },
2925 { 0x12, 0x183301f0 },
2926 { 0x13, 0x18a001f0 },
2927 { 0x14, 0x18a001f0 },
2928 { 0x21, 0x01442070 },
2929 { 0x22, 0x01c42190 },
2930 { 0x23, 0x40000100 },
2931 {}
Matt Porter3cc08dc2006-01-23 15:27:49 +01002932};
2933
Takashi Iwai29ac8362013-01-14 16:03:38 +01002934static const struct hda_pintbl d965_3st_pin_configs[] = {
2935 { 0x0a, 0x0221401f },
2936 { 0x0b, 0x02a19120 },
2937 { 0x0c, 0x40000100 },
2938 { 0x0d, 0x01014011 },
2939 { 0x0e, 0x01a19021 },
2940 { 0x0f, 0x01813024 },
2941 { 0x10, 0x40000100 },
2942 { 0x11, 0x40000100 },
2943 { 0x12, 0x40000100 },
2944 { 0x13, 0x40000100 },
2945 { 0x14, 0x40000100 },
2946 { 0x21, 0x40000100 },
2947 { 0x22, 0x40000100 },
2948 { 0x23, 0x40000100 },
2949 {}
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002950};
2951
Takashi Iwai29ac8362013-01-14 16:03:38 +01002952static const struct hda_pintbl d965_5st_pin_configs[] = {
2953 { 0x0a, 0x02214020 },
2954 { 0x0b, 0x02a19080 },
2955 { 0x0c, 0x0181304e },
2956 { 0x0d, 0x01014010 },
2957 { 0x0e, 0x01a19040 },
2958 { 0x0f, 0x01011012 },
2959 { 0x10, 0x01016011 },
2960 { 0x11, 0x40000100 },
2961 { 0x12, 0x40000100 },
2962 { 0x13, 0x40000100 },
2963 { 0x14, 0x40000100 },
2964 { 0x21, 0x01442070 },
2965 { 0x22, 0x40000100 },
2966 { 0x23, 0x40000100 },
2967 {}
Tobin Davis93ed1502006-09-01 21:03:12 +02002968};
2969
Takashi Iwai29ac8362013-01-14 16:03:38 +01002970static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
2971 { 0x0a, 0x40000100 },
2972 { 0x0b, 0x40000100 },
2973 { 0x0c, 0x0181304e },
2974 { 0x0d, 0x01014010 },
2975 { 0x0e, 0x01a19040 },
2976 { 0x0f, 0x01011012 },
2977 { 0x10, 0x01016011 },
2978 { 0x11, 0x40000100 },
2979 { 0x12, 0x40000100 },
2980 { 0x13, 0x40000100 },
2981 { 0x14, 0x40000100 },
2982 { 0x21, 0x01442070 },
2983 { 0x22, 0x40000100 },
2984 { 0x23, 0x40000100 },
2985 {}
Takashi Iwai679d92e2009-05-24 19:00:08 +02002986};
2987
Takashi Iwai29ac8362013-01-14 16:03:38 +01002988static const struct hda_pintbl dell_3st_pin_configs[] = {
2989 { 0x0a, 0x02211230 },
2990 { 0x0b, 0x02a11220 },
2991 { 0x0c, 0x01a19040 },
2992 { 0x0d, 0x01114210 },
2993 { 0x0e, 0x01111212 },
2994 { 0x0f, 0x01116211 },
2995 { 0x10, 0x01813050 },
2996 { 0x11, 0x01112214 },
2997 { 0x12, 0x403003fa },
2998 { 0x13, 0x90a60040 },
2999 { 0x14, 0x90a60040 },
3000 { 0x21, 0x404003fb },
3001 { 0x22, 0x40c003fc },
3002 { 0x23, 0x40000100 },
3003 {}
Tobin Davis4ff076e2007-08-07 11:48:12 +02003004};
3005
Takashi Iwai29ac8362013-01-14 16:03:38 +01003006static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
3007 const struct hda_fixup *fix, int action)
3008{
Takashi Iwai29ac8362013-01-14 16:03:38 +01003009 /* no jack detecion for ref-no-jd model */
Takashi Iwai36c9db72013-01-17 17:07:59 +01003010 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3011 codec->no_jack_detect = 1;
Takashi Iwai29ac8362013-01-14 16:03:38 +01003012}
3013
3014static void stac927x_fixup_ref(struct hda_codec *codec,
3015 const struct hda_fixup *fix, int action)
3016{
3017 struct sigmatel_spec *spec = codec->spec;
3018
3019 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3020 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
3021 spec->eapd_mask = spec->gpio_mask = 0;
3022 spec->gpio_dir = spec->gpio_data = 0;
3023 }
3024}
3025
3026static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
3027 const struct hda_fixup *fix, int action)
3028{
3029 struct sigmatel_spec *spec = codec->spec;
3030
3031 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3032 return;
3033
3034 if (codec->subsystem_id != 0x1028022f) {
3035 /* GPIO2 High = Enable EAPD */
3036 spec->eapd_mask = spec->gpio_mask = 0x04;
3037 spec->gpio_dir = spec->gpio_data = 0x04;
3038 }
Takashi Iwai29ac8362013-01-14 16:03:38 +01003039
3040 snd_hda_add_verbs(codec, dell_3st_core_init);
3041 spec->volknob_init = 1;
Takashi Iwai29ac8362013-01-14 16:03:38 +01003042}
3043
3044static void stac927x_fixup_volknob(struct hda_codec *codec,
3045 const struct hda_fixup *fix, int action)
3046{
3047 struct sigmatel_spec *spec = codec->spec;
3048
3049 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3050 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
3051 spec->volknob_init = 1;
3052 }
3053}
3054
3055static const struct hda_fixup stac927x_fixups[] = {
3056 [STAC_D965_REF_NO_JD] = {
3057 .type = HDA_FIXUP_FUNC,
3058 .v.func = stac927x_fixup_ref_no_jd,
3059 .chained = true,
3060 .chain_id = STAC_D965_REF,
3061 },
3062 [STAC_D965_REF] = {
3063 .type = HDA_FIXUP_FUNC,
3064 .v.func = stac927x_fixup_ref,
3065 },
3066 [STAC_D965_3ST] = {
3067 .type = HDA_FIXUP_PINS,
3068 .v.pins = d965_3st_pin_configs,
3069 .chained = true,
3070 .chain_id = STAC_D965_VERBS,
3071 },
3072 [STAC_D965_5ST] = {
3073 .type = HDA_FIXUP_PINS,
3074 .v.pins = d965_5st_pin_configs,
3075 .chained = true,
3076 .chain_id = STAC_D965_VERBS,
3077 },
3078 [STAC_D965_VERBS] = {
3079 .type = HDA_FIXUP_VERBS,
3080 .v.verbs = d965_core_init,
3081 },
3082 [STAC_D965_5ST_NO_FP] = {
3083 .type = HDA_FIXUP_PINS,
3084 .v.pins = d965_5st_no_fp_pin_configs,
3085 },
3086 [STAC_DELL_3ST] = {
3087 .type = HDA_FIXUP_PINS,
3088 .v.pins = dell_3st_pin_configs,
3089 .chained = true,
3090 .chain_id = STAC_927X_DELL_DMIC,
3091 },
3092 [STAC_DELL_BIOS] = {
3093 .type = HDA_FIXUP_PINS,
3094 .v.pins = (const struct hda_pintbl[]) {
3095 /* configure the analog microphone on some laptops */
3096 { 0x0c, 0x90a79130 },
3097 /* correct the front output jack as a hp out */
3098 { 0x0f, 0x0227011f },
3099 /* correct the front input jack as a mic */
3100 { 0x0e, 0x02a79130 },
3101 {}
3102 },
3103 .chained = true,
3104 .chain_id = STAC_927X_DELL_DMIC,
3105 },
3106 [STAC_DELL_BIOS_SPDIF] = {
3107 .type = HDA_FIXUP_PINS,
3108 .v.pins = (const struct hda_pintbl[]) {
3109 /* correct the device field to SPDIF out */
3110 { 0x21, 0x01442070 },
3111 {}
3112 },
3113 .chained = true,
3114 .chain_id = STAC_DELL_BIOS,
3115 },
3116 [STAC_927X_DELL_DMIC] = {
3117 .type = HDA_FIXUP_FUNC,
3118 .v.func = stac927x_fixup_dell_dmic,
3119 },
3120 [STAC_927X_VOLKNOB] = {
3121 .type = HDA_FIXUP_FUNC,
3122 .v.func = stac927x_fixup_volknob,
3123 },
Matt Porter3cc08dc2006-01-23 15:27:49 +01003124};
3125
Takashi Iwai29ac8362013-01-14 16:03:38 +01003126static const struct hda_model_fixup stac927x_models[] = {
3127 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3128 { .id = STAC_D965_REF, .name = "ref" },
3129 { .id = STAC_D965_3ST, .name = "3stack" },
3130 { .id = STAC_D965_5ST, .name = "5stack" },
3131 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3132 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3133 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3134 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3135 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003136};
3137
Takashi Iwai29ac8362013-01-14 16:03:38 +01003138static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003139 /* SigmaTel reference board */
3140 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3141 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003142 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3143 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003144 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003145 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02003147 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003148 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3149 "Intel D965", STAC_D965_3ST),
3150 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3151 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003152 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
3155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003156 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04003158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
Chengu Wang84d3dc22009-07-30 19:43:55 +08003161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
3163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
3164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
Tobin Davis93ed1502006-09-01 21:03:12 +02003166 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003167 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3168 "Intel D965", STAC_D965_5ST),
3169 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3170 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02003171 /* volume-knob fixes */
3172 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01003173 {} /* terminator */
3174};
3175
Takashi Iwaife6322c2013-01-14 14:46:51 +01003176static const struct hda_pintbl ref9205_pin_configs[] = {
3177 { 0x0a, 0x40000100 },
3178 { 0x0b, 0x40000100 },
3179 { 0x0c, 0x01016011 },
3180 { 0x0d, 0x01014010 },
3181 { 0x0e, 0x01813122 },
3182 { 0x0f, 0x01a19021 },
3183 { 0x14, 0x01019020 },
3184 { 0x16, 0x40000100 },
3185 { 0x17, 0x90a000f0 },
3186 { 0x18, 0x90a000f0 },
3187 { 0x21, 0x01441030 },
3188 { 0x22, 0x01c41030 },
3189 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003190};
3191
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003192/*
3193 STAC 9205 pin configs for
3194 102801F1
3195 102801F2
3196 102801FC
3197 102801FD
3198 10280204
3199 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003200 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01003201 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003202*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003203static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3204 { 0x0a, 0x0321101F },
3205 { 0x0b, 0x03A11020 },
3206 { 0x0c, 0x400003FA },
3207 { 0x0d, 0x90170310 },
3208 { 0x0e, 0x400003FB },
3209 { 0x0f, 0x400003FC },
3210 { 0x14, 0x400003FD },
3211 { 0x16, 0x40F000F9 },
3212 { 0x17, 0x90A60330 },
3213 { 0x18, 0x400003FF },
3214 { 0x21, 0x0144131F },
3215 { 0x22, 0x40C003FE },
3216 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003217};
3218
3219/*
3220 STAC 9205 pin configs for
3221 102801F9
3222 102801FA
3223 102801FE
3224 102801FF (Dell Precision M4300)
3225 10280206
3226 10280200
3227 10280201
3228*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003229static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3230 { 0x0a, 0x0321101f },
3231 { 0x0b, 0x03a11020 },
3232 { 0x0c, 0x90a70330 },
3233 { 0x0d, 0x90170310 },
3234 { 0x0e, 0x400000fe },
3235 { 0x0f, 0x400000ff },
3236 { 0x14, 0x400000fd },
3237 { 0x16, 0x40f000f9 },
3238 { 0x17, 0x400000fa },
3239 { 0x18, 0x400000fc },
3240 { 0x21, 0x0144131f },
3241 { 0x22, 0x40c003f8 },
3242 /* Enable SPDIF in/out */
3243 { 0x1f, 0x01441030 },
3244 { 0x20, 0x1c410030 },
3245 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003246};
3247
Takashi Iwaife6322c2013-01-14 14:46:51 +01003248static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3249 { 0x0a, 0x0421101f },
3250 { 0x0b, 0x04a11020 },
3251 { 0x0c, 0x400003fa },
3252 { 0x0d, 0x90170310 },
3253 { 0x0e, 0x400003fb },
3254 { 0x0f, 0x400003fc },
3255 { 0x14, 0x400003fd },
3256 { 0x16, 0x400003f9 },
3257 { 0x17, 0x90a60330 },
3258 { 0x18, 0x400003ff },
3259 { 0x21, 0x01441340 },
3260 { 0x22, 0x40c003fe },
3261 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003262};
3263
Takashi Iwaife6322c2013-01-14 14:46:51 +01003264static void stac9205_fixup_ref(struct hda_codec *codec,
3265 const struct hda_fixup *fix, int action)
3266{
3267 struct sigmatel_spec *spec = codec->spec;
3268
3269 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3270 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3271 /* SPDIF-In enabled */
3272 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3273 }
3274}
3275
Takashi Iwaife6322c2013-01-14 14:46:51 +01003276static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3277 const struct hda_fixup *fix, int action)
3278{
3279 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003280 struct hda_jack_tbl *jack;
Takashi Iwaife6322c2013-01-14 14:46:51 +01003281
3282 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3283 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3284
3285 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaife6322c2013-01-14 14:46:51 +01003286 snd_hda_codec_write_cache(codec, codec->afg, 0,
3287 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
Takashi Iwai36c9db72013-01-17 17:07:59 +01003288 snd_hda_jack_detect_enable_callback(codec, codec->afg,
3289 STAC_VREF_EVENT,
3290 stac_vref_event);
3291 jack = snd_hda_jack_tbl_get(codec, codec->afg);
3292 if (jack)
3293 jack->private_data = 0x01;
Takashi Iwaife6322c2013-01-14 14:46:51 +01003294
3295 spec->gpio_dir = 0x0b;
3296 spec->eapd_mask = 0x01;
3297 spec->gpio_mask = 0x1b;
3298 spec->gpio_mute = 0x10;
3299 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3300 * GPIO3 Low = DRM
3301 */
3302 spec->gpio_data = 0x01;
3303 }
3304}
3305
3306static void stac9205_fixup_eapd(struct hda_codec *codec,
3307 const struct hda_fixup *fix, int action)
3308{
3309 struct sigmatel_spec *spec = codec->spec;
3310
3311 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3312 spec->eapd_switch = 0;
3313}
3314
3315static const struct hda_fixup stac9205_fixups[] = {
3316 [STAC_9205_REF] = {
3317 .type = HDA_FIXUP_FUNC,
3318 .v.func = stac9205_fixup_ref,
3319 },
3320 [STAC_9205_DELL_M42] = {
3321 .type = HDA_FIXUP_PINS,
3322 .v.pins = dell_9205_m42_pin_configs,
3323 },
3324 [STAC_9205_DELL_M43] = {
3325 .type = HDA_FIXUP_FUNC,
3326 .v.func = stac9205_fixup_dell_m43,
3327 },
3328 [STAC_9205_DELL_M44] = {
3329 .type = HDA_FIXUP_PINS,
3330 .v.pins = dell_9205_m44_pin_configs,
3331 },
3332 [STAC_9205_EAPD] = {
3333 .type = HDA_FIXUP_FUNC,
3334 .v.func = stac9205_fixup_eapd,
3335 },
3336 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003337};
3338
Takashi Iwaife6322c2013-01-14 14:46:51 +01003339static const struct hda_model_fixup stac9205_models[] = {
3340 { .id = STAC_9205_REF, .name = "ref" },
3341 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3342 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3343 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3344 { .id = STAC_9205_EAPD, .name = "eapd" },
3345 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003346};
3347
Takashi Iwaife6322c2013-01-14 14:46:51 +01003348static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003349 /* SigmaTel reference board */
3350 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3351 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03003352 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3353 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003354 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3355 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003356 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003357 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3358 "unknown Dell", STAC_9205_DELL_M42),
3359 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3360 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02003362 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3364 "Dell Precision", STAC_9205_DELL_M43),
3365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3366 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3368 "unknown Dell", STAC_9205_DELL_M42),
3369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3370 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3372 "Dell Precision", STAC_9205_DELL_M43),
3373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003374 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3376 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02003377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3378 "Dell Precision", STAC_9205_DELL_M43),
3379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3380 "Dell Precision", STAC_9205_DELL_M43),
3381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3382 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3384 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3386 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01003387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3388 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003389 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08003390 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003391 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02003392 {} /* terminator */
3393};
3394
Takashi Iwai36c9db72013-01-17 17:07:59 +01003395static int stac_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003396{
3397 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003398 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003399
Takashi Iwai36c9db72013-01-17 17:07:59 +01003400 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003401 if (err < 0)
3402 return err;
3403
Takashi Iwai36c9db72013-01-17 17:07:59 +01003404 /* add hooks */
3405 spec->gen.pcm_playback_hook = stac_playback_pcm_hook;
3406 spec->gen.pcm_capture_hook = stac_capture_pcm_hook;
3407
3408 spec->gen.automute_hook = stac_update_outputs;
3409 spec->gen.hp_automute_hook = stac_hp_automute;
3410 spec->gen.line_automute_hook = stac_line_automute;
3411
3412 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003413 if (err < 0)
3414 return err;
3415
Takashi Iwai36c9db72013-01-17 17:07:59 +01003416 /* minimum value is actually mute */
3417 spec->gen.vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
Mattc7d4b2f2005-06-27 14:59:41 +02003418
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003419 /* setup analog beep controls */
3420 if (spec->anabeep_nid > 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01003421 err = stac_auto_create_beep_ctls(codec,
3422 spec->anabeep_nid);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003423 if (err < 0)
3424 return err;
3425 }
3426
3427 /* setup digital beep controls and input device */
3428#ifdef CONFIG_SND_HDA_INPUT_BEEP
3429 if (spec->digbeep_nid > 0) {
3430 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003431 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003432
Takashi Iwai36c9db72013-01-17 17:07:59 +01003433 err = stac_auto_create_beep_ctls(codec, nid);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003434 if (err < 0)
3435 return err;
3436 err = snd_hda_attach_beep_device(codec, nid);
3437 if (err < 0)
3438 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003439 if (codec->beep) {
3440 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003441 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003442 /* if no beep switch is available, make its own one */
3443 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3444 if (!(caps & AC_AMPCAP_MUTE)) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01003445 err = stac_beep_switch_ctl(codec);
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003446 if (err < 0)
3447 return err;
3448 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003449 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003450 }
3451#endif
3452
Takashi Iwai36c9db72013-01-17 17:07:59 +01003453 if (spec->gpio_led)
3454 spec->gen.vmaster_mute.hook = stac_vmaster_hook;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003455
Takashi Iwai36c9db72013-01-17 17:07:59 +01003456 if (spec->aloopback_ctl &&
3457 snd_hda_get_bool_hint(codec, "loopback") == 1) {
3458 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, spec->aloopback_ctl))
3459 return -ENOMEM;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003460 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003461
Takashi Iwai36c9db72013-01-17 17:07:59 +01003462 stac_init_power_map(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003463
3464 return 0;
3465}
3466
Takashi Iwai36c9db72013-01-17 17:07:59 +01003467
3468static int stac_init(struct hda_codec *codec)
Richard Fish160ea0d2006-09-06 13:58:25 +02003469{
3470 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003471 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01003472 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003473
Takashi Iwai6565e4f2009-03-02 14:38:35 +01003474 /* override some hints */
3475 stac_store_hints(codec);
3476
Takashi Iwaif73d3582008-11-25 08:21:51 +01003477 /* set up GPIO */
3478 gpio = spec->gpio_data;
3479 /* turn on EAPD statically when spec->eapd_switch isn't set.
3480 * otherwise, unsol event will turn it on/off dynamically
3481 */
3482 if (!spec->eapd_switch)
3483 gpio |= spec->eapd_mask;
3484 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3485
Takashi Iwai36c9db72013-01-17 17:07:59 +01003486 snd_hda_gen_init(codec);
Takashi Iwaic8822462012-05-15 09:11:36 +02003487
3488 /* sync the power-map */
3489 if (spec->num_pwrs)
3490 snd_hda_codec_write(codec, codec->afg, 0,
3491 AC_VERB_IDT_SET_POWER_MAP,
3492 spec->power_map_bits);
Takashi Iwai36c9db72013-01-17 17:07:59 +01003493
3494 /* power down inactive ADCs */
3495 if (spec->powerdown_adcs) {
3496 for (i = 0; i < spec->gen.num_all_adcs; i++) {
3497 if (spec->active_adcs & (1 << i))
3498 continue;
3499 snd_hda_codec_write(codec, spec->gen.all_adcs[i], 0,
3500 AC_VERB_SET_POWER_STATE,
3501 AC_PWRST_D3);
3502 }
3503 }
3504
3505 /* power down unused DACs */
3506 for (i = 0; i < spec->gen.num_all_dacs; i++) {
3507 if (!snd_hda_get_nid_path(codec, spec->gen.all_dacs[i], 0))
3508 snd_hda_codec_write(codec, spec->gen.all_dacs[i], 0,
3509 AC_VERB_SET_POWER_STATE,
3510 AC_PWRST_D3);
3511 }
3512
Mattc7d4b2f2005-06-27 14:59:41 +02003513 return 0;
3514}
3515
Takashi Iwai36c9db72013-01-17 17:07:59 +01003516static void stac_shutup(struct hda_codec *codec)
Takashi Iwai603c4012008-07-30 15:01:44 +02003517{
3518 struct sigmatel_spec *spec = codec->spec;
3519
Takashi Iwai36c9db72013-01-17 17:07:59 +01003520 snd_hda_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01003521
3522 if (spec->eapd_mask)
3523 stac_gpio_set(codec, spec->gpio_mask,
3524 spec->gpio_dir, spec->gpio_data &
3525 ~spec->eapd_mask);
3526}
3527
Takashi Iwai36c9db72013-01-17 17:07:59 +01003528static void stac_free(struct hda_codec *codec)
Matt2f2f4252005-04-13 14:45:30 +02003529{
Mattc7d4b2f2005-06-27 14:59:41 +02003530 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003531
Takashi Iwai36c9db72013-01-17 17:07:59 +01003532 if (!spec)
Mattc7d4b2f2005-06-27 14:59:41 +02003533 return;
3534
Takashi Iwai36c9db72013-01-17 17:07:59 +01003535 snd_hda_gen_spec_free(&spec->gen);
Mattc7d4b2f2005-06-27 14:59:41 +02003536 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003537 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003538}
3539
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01003540#ifdef CONFIG_PROC_FS
3541static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
3542 struct hda_codec *codec, hda_nid_t nid)
3543{
3544 if (nid == codec->afg)
3545 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02003546 snd_hda_codec_read(codec, nid, 0,
3547 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01003548}
3549
3550static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
3551 struct hda_codec *codec,
3552 unsigned int verb)
3553{
3554 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
3555 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
3556}
3557
3558/* stac92hd71bxx, stac92hd73xx */
3559static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
3560 struct hda_codec *codec, hda_nid_t nid)
3561{
3562 stac92hd_proc_hook(buffer, codec, nid);
3563 if (nid == codec->afg)
3564 analog_loop_proc_hook(buffer, codec, 0xfa0);
3565}
3566
3567static void stac9205_proc_hook(struct snd_info_buffer *buffer,
3568 struct hda_codec *codec, hda_nid_t nid)
3569{
3570 if (nid == codec->afg)
3571 analog_loop_proc_hook(buffer, codec, 0xfe0);
3572}
3573
3574static void stac927x_proc_hook(struct snd_info_buffer *buffer,
3575 struct hda_codec *codec, hda_nid_t nid)
3576{
3577 if (nid == codec->afg)
3578 analog_loop_proc_hook(buffer, codec, 0xfeb);
3579}
3580#else
3581#define stac92hd_proc_hook NULL
3582#define stac92hd7x_proc_hook NULL
3583#define stac9205_proc_hook NULL
3584#define stac927x_proc_hook NULL
3585#endif
3586
Takashi Iwai2a439522011-07-26 09:52:50 +02003587#ifdef CONFIG_PM
Takashi Iwai36c9db72013-01-17 17:07:59 +01003588static int stac_resume(struct hda_codec *codec)
Mattff6fdc32005-06-27 15:06:52 +02003589{
Takashi Iwai36c9db72013-01-17 17:07:59 +01003590 codec->patch_ops.init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003591 snd_hda_codec_resume_amp(codec);
3592 snd_hda_codec_resume_cache(codec);
Mattff6fdc32005-06-27 15:06:52 +02003593 return 0;
3594}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05003595
Takashi Iwai36c9db72013-01-17 17:07:59 +01003596static int stac_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05003597{
Takashi Iwai36c9db72013-01-17 17:07:59 +01003598 stac_shutup(codec);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05003599 return 0;
3600}
3601
Takashi Iwai36c9db72013-01-17 17:07:59 +01003602static void stac_set_power_state(struct hda_codec *codec, hda_nid_t fg,
3603 unsigned int power_state)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05003604{
3605 unsigned int afg_power_state = power_state;
3606 struct sigmatel_spec *spec = codec->spec;
3607
3608 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01003609 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05003610 /* with vref-out pin used for mute led control
3611 * codec AFG is prevented from D3 state
3612 */
3613 afg_power_state = AC_PWRST_D1;
3614 }
3615 /* this delay seems necessary to avoid click noise at power-down */
3616 msleep(100);
3617 }
3618 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
3619 afg_power_state);
3620 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
3621}
Takashi Iwai350eba432012-03-16 16:09:03 +01003622#else
Takashi Iwai36c9db72013-01-17 17:07:59 +01003623#define stac_suspend NULL
3624#define stac_resume NULL
3625#define stac_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01003626#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05003627
Takashi Iwai36c9db72013-01-17 17:07:59 +01003628static const struct hda_codec_ops stac_patch_ops = {
3629 .build_controls = snd_hda_gen_build_controls,
3630 .build_pcms = snd_hda_gen_build_pcms,
3631 .init = stac_init,
3632 .free = stac_free,
David Henningsson29adc4b2012-09-25 11:31:00 +02003633 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02003634#ifdef CONFIG_PM
Takashi Iwai36c9db72013-01-17 17:07:59 +01003635 .suspend = stac_suspend,
3636 .resume = stac_resume,
Mattff6fdc32005-06-27 15:06:52 +02003637#endif
Takashi Iwai36c9db72013-01-17 17:07:59 +01003638 .reboot_notify = stac_shutup,
Matt2f2f4252005-04-13 14:45:30 +02003639};
3640
Takashi Iwai36c9db72013-01-17 17:07:59 +01003641static int alloc_stac_spec(struct hda_codec *codec)
Takashi Iwai361dab32012-05-09 14:35:27 +02003642{
3643 struct sigmatel_spec *spec;
3644
3645 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3646 if (!spec)
3647 return -ENOMEM;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003648 snd_hda_gen_spec_init(&spec->gen);
Takashi Iwai361dab32012-05-09 14:35:27 +02003649 codec->spec = spec;
3650 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
Takashi Iwai361dab32012-05-09 14:35:27 +02003651 return 0;
3652}
3653
Matt2f2f4252005-04-13 14:45:30 +02003654static int patch_stac9200(struct hda_codec *codec)
3655{
3656 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003657 int err;
Matt2f2f4252005-04-13 14:45:30 +02003658
Takashi Iwai36c9db72013-01-17 17:07:59 +01003659 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02003660 if (err < 0)
3661 return err;
Matt2f2f4252005-04-13 14:45:30 +02003662
Takashi Iwai361dab32012-05-09 14:35:27 +02003663 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003664 spec->linear_tone_beep = 1;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003665 spec->gen.own_eapd_ctl = 1;
3666
3667 codec->patch_ops = stac_patch_ops;
3668
3669 snd_hda_add_verbs(codec, stac9200_eapd_init);
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01003670
3671 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
3672 stac9200_fixups);
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01003673 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai117f2572008-03-18 09:53:23 +01003674
Takashi Iwai36c9db72013-01-17 17:07:59 +01003675 err = stac_parse_auto_config(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02003676 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01003677 stac_free(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02003678 return err;
3679 }
Matt2f2f4252005-04-13 14:45:30 +02003680
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01003681 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3682
Matt2f2f4252005-04-13 14:45:30 +02003683 return 0;
3684}
3685
Tobin Davis8e21c342007-01-08 11:04:17 +01003686static int patch_stac925x(struct hda_codec *codec)
3687{
3688 struct sigmatel_spec *spec;
3689 int err;
3690
Takashi Iwai36c9db72013-01-17 17:07:59 +01003691 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02003692 if (err < 0)
3693 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01003694
Takashi Iwai361dab32012-05-09 14:35:27 +02003695 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003696 spec->linear_tone_beep = 1;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003697 spec->gen.own_eapd_ctl = 1;
3698
3699 codec->patch_ops = stac_patch_ops;
3700
3701 snd_hda_add_verbs(codec, stac925x_core_init);
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02003702
Takashi Iwaid2077d42013-01-14 14:20:16 +01003703 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
3704 stac925x_fixups);
Takashi Iwaid2077d42013-01-14 14:20:16 +01003705 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3706
Takashi Iwai36c9db72013-01-17 17:07:59 +01003707 err = stac_parse_auto_config(codec);
Tobin Davis8e21c342007-01-08 11:04:17 +01003708 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01003709 stac_free(codec);
Tobin Davis8e21c342007-01-08 11:04:17 +01003710 return err;
3711 }
3712
Takashi Iwaid2077d42013-01-14 14:20:16 +01003713 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3714
Tobin Davis8e21c342007-01-08 11:04:17 +01003715 return 0;
3716}
3717
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003718static int patch_stac92hd73xx(struct hda_codec *codec)
3719{
3720 struct sigmatel_spec *spec;
Takashi Iwai361dab32012-05-09 14:35:27 +02003721 int err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003722 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003723
Takashi Iwai36c9db72013-01-17 17:07:59 +01003724 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02003725 if (err < 0)
3726 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003727
Takashi Iwai361dab32012-05-09 14:35:27 +02003728 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003729 spec->linear_tone_beep = 0;
Takashi Iwai55e30142013-01-14 17:30:04 +01003730
Takashi Iwai36c9db72013-01-17 17:07:59 +01003731 num_dacs = snd_hda_get_num_conns(codec, 0x0a) - 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003732 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003733 printk(KERN_WARNING "hda_codec: Could not determine "
3734 "number of channels defaulting to DAC count\n");
Takashi Iwai36c9db72013-01-17 17:07:59 +01003735 num_dacs = 5;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003736 }
Takashi Iwai55e30142013-01-14 17:30:04 +01003737
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003738 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003739 case 0x3: /* 6 Channel */
Takashi Iwai36c9db72013-01-17 17:07:59 +01003740 spec->aloopback_ctl = &stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003741 break;
3742 case 0x4: /* 8 Channel */
Takashi Iwai36c9db72013-01-17 17:07:59 +01003743 spec->aloopback_ctl = &stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003744 break;
3745 case 0x5: /* 10 Channel */
Takashi Iwai36c9db72013-01-17 17:07:59 +01003746 spec->aloopback_ctl = &stac92hd73xx_10ch_loopback;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01003747 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003748 }
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003749
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003750 spec->aloopback_mask = 0x01;
3751 spec->aloopback_shift = 8;
3752
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003753 spec->digbeep_nid = 0x1c;
Takashi Iwai6479c632009-07-28 18:20:25 +02003754
Takashi Iwai55e30142013-01-14 17:30:04 +01003755 /* GPIO0 High = Enable EAPD */
3756 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3757 spec->gpio_data = 0x01;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05003758
Takashi Iwai55e30142013-01-14 17:30:04 +01003759 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01003760
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003761 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3762 spec->pwr_nids = stac92hd73xx_pwr_nids;
3763
Takashi Iwai36c9db72013-01-17 17:07:59 +01003764 spec->gen.own_eapd_ctl = 1;
3765
3766 codec->patch_ops = stac_patch_ops;
3767
3768 snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl,
3769 stac92hd73xx_fixups);
Takashi Iwai55e30142013-01-14 17:30:04 +01003770 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3771
3772 if (!spec->volknob_init)
3773 snd_hda_add_verbs(codec, stac92hd73xx_core_init);
3774
Takashi Iwai36c9db72013-01-17 17:07:59 +01003775 err = stac_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003776 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01003777 stac_free(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003778 return err;
3779 }
3780
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01003781 codec->proc_widget_hook = stac92hd7x_proc_hook;
3782
Takashi Iwai55e30142013-01-14 17:30:04 +01003783 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3784
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003785 return 0;
3786}
3787
Takashi Iwai372f8c72013-01-14 18:06:34 +01003788static void stac_setup_gpio(struct hda_codec *codec)
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003789{
Takashi Iwai372f8c72013-01-14 18:06:34 +01003790 struct sigmatel_spec *spec = codec->spec;
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01003791
Takashi Iwaib4e81872009-11-18 17:20:24 +01003792 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01003793 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05003794 spec->gpio_mask |= spec->gpio_led;
3795 spec->gpio_dir |= spec->gpio_led;
3796 spec->gpio_data |= spec->gpio_led;
3797 } else {
3798 codec->patch_ops.set_power_state =
Takashi Iwai36c9db72013-01-17 17:07:59 +01003799 stac_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05003800 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01003801 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01003802
Takashi Iwai62cbde12012-09-14 11:58:54 +02003803 if (spec->mic_mute_led_gpio) {
3804 spec->gpio_mask |= spec->mic_mute_led_gpio;
3805 spec->gpio_dir |= spec->mic_mute_led_gpio;
3806 spec->mic_mute_led_on = true;
3807 spec->gpio_data |= spec->mic_mute_led_gpio;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003808
3809 spec->gen.capture_switch_hook = stac_capture_led_hook;
Takashi Iwai62cbde12012-09-14 11:58:54 +02003810 }
Takashi Iwai372f8c72013-01-14 18:06:34 +01003811}
3812
3813static int patch_stac92hd83xxx(struct hda_codec *codec)
3814{
3815 struct sigmatel_spec *spec;
3816 int err;
3817
Takashi Iwai36c9db72013-01-17 17:07:59 +01003818 err = alloc_stac_spec(codec);
Takashi Iwai372f8c72013-01-14 18:06:34 +01003819 if (err < 0)
3820 return err;
3821
3822 codec->epss = 0; /* longer delay needed for D3 */
Takashi Iwai372f8c72013-01-14 18:06:34 +01003823
3824 spec = codec->spec;
3825 spec->linear_tone_beep = 0;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003826 spec->gen.own_eapd_ctl = 1;
3827
Takashi Iwai372f8c72013-01-14 18:06:34 +01003828 spec->digbeep_nid = 0x21;
3829 spec->pwr_nids = stac92hd83xxx_pwr_nids;
3830 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwai36c9db72013-01-17 17:07:59 +01003831 spec->default_polarity = -1; /* no default cfg */
3832
3833 codec->patch_ops = stac_patch_ops;
3834
3835 snd_hda_add_verbs(codec, stac92hd83xxx_core_init);
Takashi Iwai372f8c72013-01-14 18:06:34 +01003836
3837 snd_hda_pick_fixup(codec, stac92hd83xxx_models, stac92hd83xxx_fixup_tbl,
3838 stac92hd83xxx_fixups);
Takashi Iwai372f8c72013-01-14 18:06:34 +01003839 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3840
3841 stac_setup_gpio(codec);
Takashi Iwai62cbde12012-09-14 11:58:54 +02003842
Takashi Iwai36c9db72013-01-17 17:07:59 +01003843 err = stac_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003844 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01003845 stac_free(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003846 return err;
3847 }
3848
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01003849 codec->proc_widget_hook = stac92hd_proc_hook;
3850
Takashi Iwai372f8c72013-01-14 18:06:34 +01003851 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3852
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003853 return 0;
3854}
3855
Matthew Ranostaye035b842007-11-06 11:53:55 +01003856static int patch_stac92hd71bxx(struct hda_codec *codec)
3857{
3858 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02003859 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Takashi Iwai361dab32012-05-09 14:35:27 +02003860 int err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003861
Takashi Iwai36c9db72013-01-17 17:07:59 +01003862 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02003863 if (err < 0)
3864 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003865
Takashi Iwai361dab32012-05-09 14:35:27 +02003866 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003867 spec->linear_tone_beep = 0;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003868 spec->gen.own_eapd_ctl = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003869
Takashi Iwai36c9db72013-01-17 17:07:59 +01003870 codec->patch_ops = stac_patch_ops;
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01003871
3872 /* GPIO0 = EAPD */
3873 spec->gpio_mask = 0x01;
3874 spec->gpio_dir = 0x01;
3875 spec->gpio_data = 0x01;
Takashi Iwai41c3b642008-11-18 10:45:15 +01003876
Matthew Ranostay541eee82007-12-14 12:08:04 +01003877 switch (codec->vendor_id) {
3878 case 0x111d76b6: /* 4 Port without Analog Mixer */
3879 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02003880 unmute_init++;
Matthew Ranostay541eee82007-12-14 12:08:04 +01003881 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003882 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003883 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003884 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003885 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003886
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003887 /* disable VSW */
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05003888 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01003889 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
3890 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003891 break;
3892 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003893 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003894 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003895
Takashi Iwai5207e102009-07-30 13:09:08 +02003896 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01003897 }
3898
David Henningsson5e68fb32012-08-16 14:11:09 +02003899 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01003900 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
David Henningsson5e68fb32012-08-16 14:11:09 +02003901
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05003902 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
3903 snd_hda_sequence_write_cache(codec, unmute_init);
3904
Takashi Iwai36c9db72013-01-17 17:07:59 +01003905 spec->aloopback_ctl = &stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003906 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01003907 spec->aloopback_shift = 0;
3908
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003909 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003910 spec->digbeep_nid = 0x26;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003911 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003912 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01003913
Takashi Iwai36c9db72013-01-17 17:07:59 +01003914 snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
3915 stac92hd71bxx_fixups);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01003916 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01003917
Takashi Iwai372f8c72013-01-14 18:06:34 +01003918 stac_setup_gpio(codec);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04003919
Takashi Iwai36c9db72013-01-17 17:07:59 +01003920 err = stac_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003921 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01003922 stac_free(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01003923 return err;
3924 }
3925
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01003926 codec->proc_widget_hook = stac92hd7x_proc_hook;
3927
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01003928 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3929
Matthew Ranostaye035b842007-11-06 11:53:55 +01003930 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02003931}
Matthew Ranostaye035b842007-11-06 11:53:55 +01003932
Matt2f2f4252005-04-13 14:45:30 +02003933static int patch_stac922x(struct hda_codec *codec)
3934{
3935 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003936 int err;
Matt2f2f4252005-04-13 14:45:30 +02003937
Takashi Iwai36c9db72013-01-17 17:07:59 +01003938 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02003939 if (err < 0)
3940 return err;
Matt2f2f4252005-04-13 14:45:30 +02003941
Takashi Iwai361dab32012-05-09 14:35:27 +02003942 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003943 spec->linear_tone_beep = 1;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003944 spec->gen.own_eapd_ctl = 1;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02003945
Takashi Iwai36c9db72013-01-17 17:07:59 +01003946 codec->patch_ops = stac_patch_ops;
Matt2f2f4252005-04-13 14:45:30 +02003947
Takashi Iwai0a427842013-01-14 15:20:13 +01003948 snd_hda_add_verbs(codec, stac922x_core_init);
3949
Takashi Iwai807a46362007-05-29 19:01:37 +02003950 /* Fix Mux capture level; max to 2 */
3951 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3952 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3953 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3954 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3955 (0 << AC_AMPCAP_MUTE_SHIFT));
3956
Takashi Iwai36c9db72013-01-17 17:07:59 +01003957 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
3958 stac922x_fixups);
3959 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3960
3961 err = stac_parse_auto_config(codec);
3962 if (err < 0) {
3963 stac_free(codec);
3964 return err;
3965 }
3966
Takashi Iwai0a427842013-01-14 15:20:13 +01003967 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3968
Matt Porter3cc08dc2006-01-23 15:27:49 +01003969 return 0;
3970}
3971
3972static int patch_stac927x(struct hda_codec *codec)
3973{
3974 struct sigmatel_spec *spec;
3975 int err;
3976
Takashi Iwai36c9db72013-01-17 17:07:59 +01003977 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02003978 if (err < 0)
3979 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003980
Takashi Iwai361dab32012-05-09 14:35:27 +02003981 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003982 spec->linear_tone_beep = 1;
Takashi Iwai36c9db72013-01-17 17:07:59 +01003983 spec->gen.own_eapd_ctl = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003984
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003985 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003986
Takashi Iwai29ac8362013-01-14 16:03:38 +01003987 /* GPIO0 High = Enable EAPD */
3988 spec->eapd_mask = spec->gpio_mask = 0x01;
3989 spec->gpio_dir = spec->gpio_data = 0x01;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02003990
Takashi Iwai36c9db72013-01-17 17:07:59 +01003991 spec->aloopback_ctl = &stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003992 spec->aloopback_mask = 0x40;
3993 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05003994 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003995
Takashi Iwai36c9db72013-01-17 17:07:59 +01003996 codec->patch_ops = stac_patch_ops;
3997
3998 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
3999 stac927x_fixups);
Takashi Iwaif6655d52013-01-17 08:49:01 +01004000 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4001
Takashi Iwai29ac8362013-01-14 16:03:38 +01004002 if (!spec->volknob_init)
4003 snd_hda_add_verbs(codec, stac927x_core_init);
4004
Takashi Iwai36c9db72013-01-17 17:07:59 +01004005 err = stac_parse_auto_config(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004006 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01004007 stac_free(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004008 return err;
4009 }
Matt2f2f4252005-04-13 14:45:30 +02004010
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004011 codec->proc_widget_hook = stac927x_proc_hook;
4012
Takashi Iwai52987652008-01-16 16:09:47 +01004013 /*
4014 * !!FIXME!!
4015 * The STAC927x seem to require fairly long delays for certain
4016 * command sequences. With too short delays (even if the answer
4017 * is set to RIRB properly), it results in the silence output
4018 * on some hardwares like Dell.
4019 *
4020 * The below flag enables the longer delay (see get_response
4021 * in hda_intel.c).
4022 */
4023 codec->bus->needs_damn_long_delay = 1;
4024
Takashi Iwai29ac8362013-01-14 16:03:38 +01004025 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwaie28d8322008-12-17 13:48:29 +01004026
Matt2f2f4252005-04-13 14:45:30 +02004027 return 0;
4028}
4029
Matt Porterf3302a52006-07-31 12:49:34 +02004030static int patch_stac9205(struct hda_codec *codec)
4031{
4032 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004033 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004034
Takashi Iwai36c9db72013-01-17 17:07:59 +01004035 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02004036 if (err < 0)
4037 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02004038
Takashi Iwai361dab32012-05-09 14:35:27 +02004039 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01004040 spec->linear_tone_beep = 1;
Takashi Iwai36c9db72013-01-17 17:07:59 +01004041 spec->gen.own_eapd_ctl = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02004042
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004043 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004044
Takashi Iwaife6322c2013-01-14 14:46:51 +01004045 snd_hda_add_verbs(codec, stac9205_core_init);
Takashi Iwai36c9db72013-01-17 17:07:59 +01004046 spec->aloopback_ctl = &stac9205_loopback;
Takashi Iwai6479c632009-07-28 18:20:25 +02004047
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004048 spec->aloopback_mask = 0x40;
4049 spec->aloopback_shift = 0;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004050
Takashi Iwaife6322c2013-01-14 14:46:51 +01004051 /* GPIO0 High = EAPD */
4052 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4053 spec->gpio_data = 0x01;
Matt Porter33382402006-12-18 13:17:28 +01004054
Takashi Iwaife6322c2013-01-14 14:46:51 +01004055 /* Turn on/off EAPD per HP plugging */
4056 spec->eapd_switch = 1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004057
Takashi Iwai36c9db72013-01-17 17:07:59 +01004058 codec->patch_ops = stac_patch_ops;
4059
4060 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
4061 stac9205_fixups);
Takashi Iwaife6322c2013-01-14 14:46:51 +01004062 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Matthew Ranostay87d48362007-07-17 11:52:24 +02004063
Takashi Iwai36c9db72013-01-17 17:07:59 +01004064 err = stac_parse_auto_config(codec);
Matt Porterf3302a52006-07-31 12:49:34 +02004065 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01004066 stac_free(codec);
Matt Porterf3302a52006-07-31 12:49:34 +02004067 return err;
4068 }
4069
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004070 codec->proc_widget_hook = stac9205_proc_hook;
4071
Takashi Iwaife6322c2013-01-14 14:46:51 +01004072 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4073
Matt Porterf3302a52006-07-31 12:49:34 +02004074 return 0;
4075}
4076
Matt2f2f4252005-04-13 14:45:30 +02004077/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004078 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004079 */
4080
Takashi Iwai2b635362011-05-02 12:33:43 +02004081static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02004082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4084 {}
4085};
4086
Takashi Iwaifc268c12013-01-14 14:29:36 +01004087static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
4088 { 0x0a, 0x03211020 },
4089 { 0x0b, 0x411111f0 },
4090 { 0x0c, 0x411111f0 },
4091 { 0x0d, 0x03a15030 },
4092 { 0x0e, 0x411111f0 },
4093 { 0x0f, 0x90170110 },
4094 { 0x11, 0x411111f0 },
4095 { 0x13, 0x411111f0 },
4096 { 0x14, 0x90a7013e },
4097 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01004098};
4099
Takashi Iwaifc268c12013-01-14 14:29:36 +01004100static const struct hda_model_fixup stac9872_models[] = {
4101 { .id = STAC_9872_VAIO, .name = "vaio" },
4102 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01004103};
4104
Takashi Iwaifc268c12013-01-14 14:29:36 +01004105static const struct hda_fixup stac9872_fixups[] = {
4106 [STAC_9872_VAIO] = {
4107 .type = HDA_FIXUP_PINS,
4108 .v.pins = stac9872_vaio_pin_configs,
4109 },
Takashi Iwai307282c2009-03-12 18:17:58 +01004110};
4111
Takashi Iwaifc268c12013-01-14 14:29:36 +01004112static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02004113 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
4114 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01004115 {} /* terminator */
4116};
4117
Guillaume Munch6d859062006-08-22 17:15:47 +02004118static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004119{
4120 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01004121 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004122
Takashi Iwai36c9db72013-01-17 17:07:59 +01004123 err = alloc_stac_spec(codec);
Takashi Iwai361dab32012-05-09 14:35:27 +02004124 if (err < 0)
4125 return err;
4126
4127 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01004128 spec->linear_tone_beep = 1;
Takashi Iwai36c9db72013-01-17 17:07:59 +01004129 spec->gen.own_eapd_ctl = 1;
4130
4131 codec->patch_ops = stac_patch_ops;
4132
4133 snd_hda_add_verbs(codec, stac9872_core_init);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01004134
Takashi Iwaifc268c12013-01-14 14:29:36 +01004135 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
4136 stac9872_fixups);
Takashi Iwaifc268c12013-01-14 14:29:36 +01004137 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01004138
Takashi Iwai36c9db72013-01-17 17:07:59 +01004139 err = stac_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01004140 if (err < 0) {
Takashi Iwai36c9db72013-01-17 17:07:59 +01004141 stac_free(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01004142 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01004143 }
Takashi Iwaifc268c12013-01-14 14:29:36 +01004144
4145 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4146
Takashi Iwaidb064e52006-03-16 16:04:58 +01004147 return 0;
4148}
4149
4150
4151/*
Matt2f2f4252005-04-13 14:45:30 +02004152 * patch entries
4153 */
Takashi Iwai2b635362011-05-02 12:33:43 +02004154static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02004155 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4156 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4157 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4158 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4159 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4160 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4161 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004162 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4163 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4164 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4165 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4166 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4167 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004168 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4169 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4170 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4171 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4172 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4173 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4174 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4175 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4176 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4177 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004178 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4179 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4180 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4181 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4182 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4183 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004184 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4185 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004186 /* The following does not take into account .id=0x83847661 when subsys =
4187 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4188 * currently not fully supported.
4189 */
4190 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4191 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4192 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01004193 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02004194 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4195 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4196 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4197 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4198 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4199 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4200 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4201 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004202 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004203 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01004204 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004205 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04004206 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02004207 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
4208 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01004209 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
4210 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
4211 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
4212 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004213 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01004214 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4215 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004216 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01004217 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4218 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4219 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4220 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4221 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4222 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4223 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4224 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02004225 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
4226 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
4227 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
4228 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
4229 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
4230 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
4231 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
4232 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
4233 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
4234 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
4235 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
4236 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
4237 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
4238 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
4239 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02004240 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004241 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06004242 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
4243 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004244 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01004245 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
4246 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
4247 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
4248 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
4249 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
4250 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
4251 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
4252 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
4253 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
4254 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
4255 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
4256 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02004257 {} /* terminator */
4258};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01004259
4260MODULE_ALIAS("snd-hda-codec-id:8384*");
4261MODULE_ALIAS("snd-hda-codec-id:111d*");
4262
4263MODULE_LICENSE("GPL");
4264MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
4265
4266static struct hda_codec_preset_list sigmatel_list = {
4267 .preset = snd_hda_preset_sigmatel,
4268 .owner = THIS_MODULE,
4269};
4270
4271static int __init patch_sigmatel_init(void)
4272{
4273 return snd_hda_add_codec_preset(&sigmatel_list);
4274}
4275
4276static void __exit patch_sigmatel_exit(void)
4277{
4278 snd_hda_delete_codec_preset(&sigmatel_list);
4279}
4280
4281module_init(patch_sigmatel_init)
4282module_exit(patch_sigmatel_exit)