blob: 4a2594a7f02cd8de5760032b8443df94506f258e [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +010031#include <linux/dmi.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040032#include <linux/module.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020034#include <sound/asoundef.h>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040035#include <sound/jack.h>
Clemens Ladischa74ccea2010-10-22 15:52:34 +020036#include <sound/tlv.h>
Matt2f2f4252005-04-13 14:45:30 +020037#include "hda_codec.h"
38#include "hda_local.h"
Takashi Iwai128bc4b2012-05-07 17:42:31 +020039#include "hda_auto_parser.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020040#include "hda_beep.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020041#include "hda_jack.h"
Matt2f2f4252005-04-13 14:45:30 +020042
Takashi Iwaic6e4c662008-11-25 11:58:19 +010043enum {
44 STAC_VREF_EVENT = 1,
45 STAC_INSERT_EVENT,
46 STAC_PWR_EVENT,
47 STAC_HP_EVENT,
Takashi Iwaifefd67f2009-07-30 18:03:05 +020048 STAC_LO_EVENT,
Takashi Iwai3d21d3f2009-07-29 14:32:56 +020049 STAC_MIC_EVENT,
Takashi Iwaic6e4c662008-11-25 11:58:19 +010050};
Matt4e550962005-07-04 17:51:39 +020051
Takashi Iwaif5fcc132006-11-24 17:07:44 +010052enum {
53 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010054 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020055 STAC_9200_DELL_D21,
56 STAC_9200_DELL_D22,
57 STAC_9200_DELL_D23,
58 STAC_9200_DELL_M21,
59 STAC_9200_DELL_M22,
60 STAC_9200_DELL_M23,
61 STAC_9200_DELL_M24,
62 STAC_9200_DELL_M25,
63 STAC_9200_DELL_M26,
64 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020065 STAC_9200_M4,
66 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010067 STAC_9200_PANASONIC,
Takashi Iwaid39a3ae2013-01-14 14:06:26 +010068 STAC_9200_EAPD_INIT,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_9200_MODELS
70};
71
72enum {
73 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020074 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020075 STAC_9205_DELL_M43,
76 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010077 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010078 STAC_9205_MODELS
79};
80
81enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010082 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010083 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010084 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080085 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010086 STAC_DELL_M6_AMIC,
87 STAC_DELL_M6_DMIC,
88 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050089 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020090 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010091 STAC_92HD73XX_MODELS
92};
93
94enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010095 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020096 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050097 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050098 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +010099 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -0500100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -0600101 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600102 STAC_HP_ZEPHYR,
Takashi Iwaia3e19972012-07-26 08:17:20 +0200103 STAC_92HD83XXX_HP_LED,
Takashi Iwaiff8a1e22012-07-31 10:16:59 +0200104 STAC_92HD83XXX_HP_INV_LED,
Takashi Iwai62cbde12012-09-14 11:58:54 +0200105 STAC_92HD83XXX_HP_MIC_LED,
David Henningsson8d032a82012-10-09 12:48:40 +0200106 STAC_92HD83XXX_HEADSET_JACK,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200107 STAC_92HD83XXX_MODELS
108};
109
110enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100111 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100112 STAC_DELL_M4_1,
113 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500114 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400115 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200116 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100117 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100118 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400119 STAC_HP_DV4_1222NR,
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100120 STAC_92HD71BXX_HP,
121 STAC_92HD71BXX_NO_DMIC,
122 STAC_92HD71BXX_NO_SMUX,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100123 STAC_92HD71BXX_MODELS
124};
125
126enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100127 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200128 STAC_M1,
129 STAC_M1_2,
130 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100131 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200132 STAC_M3,
133 STAC_M5,
134 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100135 STAC_925x_MODELS
136};
137
138enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100139 STAC_D945_REF,
140 STAC_D945GTP3,
141 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200142 STAC_INTEL_MAC_V1,
143 STAC_INTEL_MAC_V2,
144 STAC_INTEL_MAC_V3,
145 STAC_INTEL_MAC_V4,
146 STAC_INTEL_MAC_V5,
Takashi Iwai0a427842013-01-14 15:20:13 +0100147 STAC_INTEL_MAC_AUTO,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300148 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200149 STAC_922X_DELL_D81,
150 STAC_922X_DELL_D82,
151 STAC_922X_DELL_M81,
152 STAC_922X_DELL_M82,
Takashi Iwai0a427842013-01-14 15:20:13 +0100153 STAC_922X_INTEL_MAC_GPIO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100154 STAC_922X_MODELS
155};
156
157enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100158 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100159 STAC_D965_REF,
160 STAC_D965_3ST,
161 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200162 STAC_D965_5ST_NO_FP,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100163 STAC_D965_VERBS,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200164 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100165 STAC_DELL_BIOS,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100166 STAC_DELL_BIOS_SPDIF,
167 STAC_927X_DELL_DMIC,
Takashi Iwai54930532009-10-11 17:38:29 +0200168 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100169 STAC_927X_MODELS
170};
Matt Porter403d1942005-11-29 15:00:51 +0100171
Takashi Iwai307282c2009-03-12 18:17:58 +0100172enum {
Takashi Iwai307282c2009-03-12 18:17:58 +0100173 STAC_9872_VAIO,
174 STAC_9872_MODELS
175};
176
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200177struct sigmatel_mic_route {
178 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200179 signed char mux_idx;
180 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200181};
182
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600183#define MAX_PINS_NUM 16
184#define MAX_ADCS_NUM 4
185#define MAX_DMICS_NUM 4
186
Matt2f2f4252005-04-13 14:45:30 +0200187struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100188 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200189 unsigned int num_mixers;
190
Matt Porter403d1942005-11-29 15:00:51 +0100191 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500192 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200193 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100194 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100195 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400196 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100197 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200198 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100199 unsigned int linear_tone_beep:1;
David Henningsson8d032a82012-10-09 12:48:40 +0200200 unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
Takashi Iwai29ac8362013-01-14 16:03:38 +0100201 unsigned int volknob_init:1; /* special volume-knob initialization */
Mattc7d4b2f2005-06-27 14:59:41 +0200202
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100203 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200204 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100205 unsigned int gpio_mask;
206 unsigned int gpio_dir;
207 unsigned int gpio_data;
208 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200209 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100210 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100211 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500212 unsigned int vref_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100213
Takashi Iwai62cbde12012-09-14 11:58:54 +0200214 unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
215 bool mic_mute_led_on; /* current mic mute state */
216
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200217 /* stream */
218 unsigned int stream_delay;
219
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100220 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200221 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100222 unsigned char aloopback_mask;
223 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200224
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100225 /* power management */
Takashi Iwaic8822462012-05-15 09:11:36 +0200226 unsigned int power_map_bits;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200228 const hda_nid_t *pwr_nids;
229 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100230
Matt2f2f4252005-04-13 14:45:30 +0200231 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100232 struct hda_input_mux *mono_mux;
233 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200234 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100235 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100236 hda_nid_t hp_dacs[5];
237 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200238
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100239 int volume_offset;
240
Matt2f2f4252005-04-13 14:45:30 +0200241 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200242 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200243 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200244 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200245 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200246 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200247 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200248 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100249 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200250 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200251 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200252 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200253
Takashi Iwai2b635362011-05-02 12:33:43 +0200254 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
255 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200256 unsigned int num_caps; /* number of capture volume/switch elements */
257
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200258 struct sigmatel_mic_route ext_mic;
259 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200260 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200261
Takashi Iwaiea734962011-01-17 11:29:34 +0100262 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200263
Mattdabbed62005-06-14 10:19:34 +0200264 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100265 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200266 hda_nid_t anabeep_nid;
267 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200268
Matt2f2f4252005-04-13 14:45:30 +0200269 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200270 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200271 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200272
273 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200274 const struct hda_verb *init;
275 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200276
277 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200278 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100279 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200280 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100281 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200282 struct hda_input_mux *sinput_mux;
283 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400284 unsigned int cur_amux;
285 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200286 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200287
Matt Porter403d1942005-11-29 15:00:51 +0100288 /* i/o switches */
289 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200290 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100291 hda_nid_t line_switch; /* shared line-in for input and output */
292 hda_nid_t mic_switch; /* shared mic-in for input and output */
293 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200294 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200295
Mattc7d4b2f2005-06-27 14:59:41 +0200296 struct hda_pcm pcm_rec[2]; /* PCM information */
297
298 /* dynamic controls and input_mux */
299 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200300 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200301 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200302 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200303 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100304 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600305
306 /* auto spec */
307 unsigned auto_pin_cnt;
308 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
309 unsigned auto_adc_cnt;
310 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
311 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
312 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
313 unsigned long auto_capvols[MAX_ADCS_NUM];
314 unsigned auto_dmic_cnt;
315 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100316
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100317 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200318};
319
Takashi Iwaic8822462012-05-15 09:11:36 +0200320#define AC_VERB_IDT_SET_POWER_MAP 0x7ec
321#define AC_VERB_IDT_GET_POWER_MAP 0xfec
322
Takashi Iwai2b635362011-05-02 12:33:43 +0200323static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200324 0x03,
325};
326
Takashi Iwai2b635362011-05-02 12:33:43 +0200327static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200328 0x0c,
329};
330
Takashi Iwai2b635362011-05-02 12:33:43 +0200331static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200332 0x02,
333};
334
Takashi Iwai2b635362011-05-02 12:33:43 +0200335static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100336 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
337 0x0f, 0x10, 0x11
338};
339
Takashi Iwai2b635362011-05-02 12:33:43 +0200340static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400341 0x26, 0,
342};
343
Takashi Iwai2b635362011-05-02 12:33:43 +0200344static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345 0x1a, 0x1b
346};
347
348#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200349static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100350 0x13, 0x14, 0
351};
352
353#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100354
Takashi Iwai2b635362011-05-02 12:33:43 +0200355static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200356 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100357};
358
Takashi Iwai2b635362011-05-02 12:33:43 +0200359static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100360 0x20, 0x21,
361};
362
Takashi Iwai2b635362011-05-02 12:33:43 +0200363static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200364 0x22, 0x23,
365};
366
Takashi Iwai6479c632009-07-28 18:20:25 +0200367#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200368static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200369 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
370 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
371};
372#define stac92hd73xx_capsws stac92hd73xx_capvols
373
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200374#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200375
Charles Chinafef2cf2011-11-11 08:05:28 +0100376static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
377 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
378 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200379};
380
Takashi Iwai2b635362011-05-02 12:33:43 +0200381static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400382 0x1e, 0,
383};
384
Takashi Iwai2b635362011-05-02 12:33:43 +0200385static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600386 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200387};
388
Takashi Iwai2b635362011-05-02 12:33:43 +0200389static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100390 0x0a, 0x0d, 0x0f
391};
392
Takashi Iwai2b635362011-05-02 12:33:43 +0200393static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100394 0x12, 0x13,
395};
396
Takashi Iwai2b635362011-05-02 12:33:43 +0200397static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100398 0x1a, 0x1b
399};
400
Takashi Iwai2b635362011-05-02 12:33:43 +0200401static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400402 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100403};
404
Takashi Iwai2b635362011-05-02 12:33:43 +0200405static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200406 0x24, 0x25,
407};
408
Matthew Ranostaye035b842007-11-06 11:53:55 +0100409#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200410static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100411 0x18, 0x19, 0
412};
413
Takashi Iwai2b635362011-05-02 12:33:43 +0200414static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
415 0x18, 0
416};
417
418static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400419 0x22, 0
420};
421
Takashi Iwai6479c632009-07-28 18:20:25 +0200422#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200423static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200424 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
426};
427#define stac92hd71bxx_capsws stac92hd71bxx_capvols
428
Takashi Iwai2b635362011-05-02 12:33:43 +0200429static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100430 0x03,
431};
432
Takashi Iwai2b635362011-05-02 12:33:43 +0200433static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100434 0x0f,
435};
436
Takashi Iwai2b635362011-05-02 12:33:43 +0200437static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100438 0x02,
439};
440
Takashi Iwaif6e98522007-10-16 14:27:04 +0200441#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200442static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200443 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200444};
445
Takashi Iwai2b635362011-05-02 12:33:43 +0200446static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100447 0x14,
448};
449
Takashi Iwai2b635362011-05-02 12:33:43 +0200450static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200451 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
452};
Takashi Iwai2b635362011-05-02 12:33:43 +0200453static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200454 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
455};
456
Takashi Iwai2b635362011-05-02 12:33:43 +0200457static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200458 0x06, 0x07,
459};
460
Takashi Iwai2b635362011-05-02 12:33:43 +0200461static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200462 0x12, 0x13,
463};
464
Takashi Iwai6479c632009-07-28 18:20:25 +0200465#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200466static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200467 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
468 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
469};
470#define stac922x_capsws stac922x_capvols
471
Takashi Iwai2b635362011-05-02 12:33:43 +0200472static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500473 0x1f, 0,
474};
475
Takashi Iwai2b635362011-05-02 12:33:43 +0200476static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100477 0x07, 0x08, 0x09
478};
479
Takashi Iwai2b635362011-05-02 12:33:43 +0200480static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100481 0x15, 0x16, 0x17
482};
483
Takashi Iwai2b635362011-05-02 12:33:43 +0200484static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200485 0x21,
486};
487
Takashi Iwai2b635362011-05-02 12:33:43 +0200488static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100489 0x02, 0x03, 0x04, 0x05, 0x06, 0
490};
491
Takashi Iwai2b635362011-05-02 12:33:43 +0200492static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100493 0x1b,
494};
495
Matthew Ranostay7f168592007-10-18 17:38:17 +0200496#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200497static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200498 0x13, 0x14, 0
499};
500
Takashi Iwai6479c632009-07-28 18:20:25 +0200501#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200502static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200503 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
504 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
506};
Takashi Iwai2b635362011-05-02 12:33:43 +0200507static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200508 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
509 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
511};
512
Takashi Iwaiea734962011-01-17 11:29:34 +0100513static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400514 "Digital Playback", "ADAT", "Analog Mux 1",
515 "Analog Mux 2", "Analog Mux 3"
516};
517
Takashi Iwai2b635362011-05-02 12:33:43 +0200518static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200519 0x12, 0x13
520};
521
Takashi Iwai2b635362011-05-02 12:33:43 +0200522static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200523 0x19, 0x1a
524};
525
Takashi Iwai2b635362011-05-02 12:33:43 +0200526static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100527 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100528};
529
Takashi Iwai2b635362011-05-02 12:33:43 +0200530static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200531 0x21,
532};
533
Takashi Iwaif6e98522007-10-16 14:27:04 +0200534#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200535static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200536 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200537};
538
Takashi Iwai6479c632009-07-28 18:20:25 +0200539#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200540static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200541 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
542 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
543};
Takashi Iwai2b635362011-05-02 12:33:43 +0200544static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200545 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
546 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
547};
548
Takashi Iwai2b635362011-05-02 12:33:43 +0200549static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200550 0x08, 0x09, 0x0d, 0x0e,
551 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200552};
553
Takashi Iwai2b635362011-05-02 12:33:43 +0200554static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100555 0x07, 0x08, 0x0a, 0x0b,
556 0x0c, 0x0d, 0x10, 0x11,
557};
558
Takashi Iwai2b635362011-05-02 12:33:43 +0200559static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200560 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
561 0x0f, 0x10, 0x11, 0x15, 0x1b,
562};
563
Takashi Iwai2b635362011-05-02 12:33:43 +0200564static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200567 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100568};
569
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500570#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200571static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500572 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
573 0x00, 0x14, 0x18, 0x19, 0x1e,
574 0x1f, 0x20, 0x27
575};
Takashi Iwai2b635362011-05-02 12:33:43 +0200576static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500579 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100580};
581
Takashi Iwai2b635362011-05-02 12:33:43 +0200582static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x10, 0x11, 0x12, 0x13,
585 0x14, 0x21, 0x22, 0x23,
586};
587
Takashi Iwai2b635362011-05-02 12:33:43 +0200588static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200589 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
590 0x0f, 0x14, 0x16, 0x17, 0x18,
591 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200592};
593
Takashi Iwai0f6fcb72013-01-14 17:05:25 +0100594static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
595 unsigned char type, int data);
596static int stac_add_hp_bass_switch(struct hda_codec *codec);
597static void stac92xx_auto_set_pinctl(struct hda_codec *codec,
598 hda_nid_t nid, int pin_type);
599static int hp_blike_system(u32 subsystem_id);
600static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity);
601
Matt Porter8b657272006-10-26 17:12:59 +0200602static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_info *uinfo)
604{
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
608}
609
610static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
612{
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100615 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200616
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100617 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200618 return 0;
619}
620
621static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100626 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200627
628 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100629 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200630}
631
Matthew Ranostayd9737752008-09-07 12:03:41 +0200632static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_info *uinfo)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
638}
639
640static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
646
647 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
648 return 0;
649}
650
651static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400656 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200657 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400658 int err, val;
659 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200660
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400661 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200662 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400663 if (err < 0)
664 return err;
665
666 if (spec->spdif_mute) {
667 if (smux_idx == 0)
668 nid = spec->multiout.dig_out_nid;
669 else
670 nid = codec->slave_dig_outs[smux_idx - 1];
671 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100672 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400673 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100674 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400675 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100676 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
677 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400678 }
679 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200680}
681
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500682static int stac_vrefout_set(struct hda_codec *codec,
683 hda_nid_t nid, unsigned int new_vref)
684{
685 int error, pinctl;
686
687 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
688 pinctl = snd_hda_codec_read(codec, nid, 0,
689 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
690
691 if (pinctl < 0)
692 return pinctl;
693
694 pinctl &= 0xff;
695 pinctl &= ~AC_PINCTL_VREFEN;
696 pinctl |= (new_vref & AC_PINCTL_VREFEN);
697
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200698 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500699 if (error < 0)
700 return error;
701
702 return 1;
703}
704
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200705static unsigned int stac92xx_vref_set(struct hda_codec *codec,
706 hda_nid_t nid, unsigned int new_vref)
707{
Takashi Iwaib8621512009-06-22 08:00:10 +0200708 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200709 unsigned int pincfg;
710 pincfg = snd_hda_codec_read(codec, nid, 0,
711 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
712
713 pincfg &= 0xff;
714 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
715 pincfg |= new_vref;
716
717 if (new_vref == AC_PINCTL_VREF_HIZ)
718 pincfg |= AC_PINCTL_OUT_EN;
719 else
720 pincfg |= AC_PINCTL_IN_EN;
721
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200722 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200723 if (error < 0)
724 return error;
725 else
726 return 1;
727}
728
729static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
730{
731 unsigned int vref;
732 vref = snd_hda_codec_read(codec, nid, 0,
733 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
734 vref &= AC_PINCTL_VREFEN;
735 return vref;
736}
737
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100738static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200739{
740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
741 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200742 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200743}
744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100745static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200746{
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 struct sigmatel_spec *spec = codec->spec;
749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
750
751 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
752 return 0;
753}
754
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100755static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200756{
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 struct sigmatel_spec *spec = codec->spec;
759 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200760 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600761 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200762
Takashi Iwai5207e102009-07-30 13:09:08 +0200763 idx = ucontrol->value.enumerated.item[0];
764 if (idx >= imux->num_items)
765 idx = imux->num_items - 1;
766 prev_idx = spec->cur_mux[adc_idx];
767 if (prev_idx == idx)
768 return 0;
769 if (idx < spec->num_analog_muxes) {
770 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
771 AC_VERB_SET_CONNECT_SEL,
772 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600773 if (prev_idx >= spec->num_analog_muxes &&
774 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200775 imux = spec->dinput_mux;
776 /* 0 = analog */
777 snd_hda_codec_write_cache(codec,
778 spec->dmux_nids[adc_idx], 0,
779 AC_VERB_SET_CONNECT_SEL,
780 imux->items[0].index);
781 }
782 } else {
783 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600784 /* first dimux item is hardcoded to select analog imux,
785 * so lets skip it
786 */
787 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200788 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
789 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600790 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200791 }
792 spec->cur_mux[adc_idx] = idx;
793 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200794}
795
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100796static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
797 struct snd_ctl_elem_info *uinfo)
798{
799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
800 struct sigmatel_spec *spec = codec->spec;
801 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
802}
803
804static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
806{
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 struct sigmatel_spec *spec = codec->spec;
809
810 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
811 return 0;
812}
813
814static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
815 struct snd_ctl_elem_value *ucontrol)
816{
817 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
818 struct sigmatel_spec *spec = codec->spec;
819
820 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
821 spec->mono_nid, &spec->cur_mmux);
822}
823
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200824#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
825
826static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
827 struct snd_ctl_elem_value *ucontrol)
828{
829 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200831 struct sigmatel_spec *spec = codec->spec;
832
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 ucontrol->value.integer.value[0] = !!(spec->aloopback &
834 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200835 return 0;
836}
837
838static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
839 struct snd_ctl_elem_value *ucontrol)
840{
841 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
842 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100843 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200844 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100845 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200846
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100847 idx_val = spec->aloopback_mask << idx;
848 if (ucontrol->value.integer.value[0])
849 val = spec->aloopback | idx_val;
850 else
851 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100852 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853 return 0;
854
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100855 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200856
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100857 /* Only return the bits defined by the shift value of the
858 * first two bytes of the mask
859 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200860 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100861 kcontrol->private_value & 0xFFFF, 0x0);
862 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200863
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100864 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200865 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100866 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200867 } else {
868 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100869 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200870 }
871
872 snd_hda_codec_write_cache(codec, codec->afg, 0,
873 kcontrol->private_value >> 16, dac_mode);
874
875 return 1;
876}
877
Takashi Iwai2b635362011-05-02 12:33:43 +0200878static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200879 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200880 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200881 {}
882};
883
Takashi Iwai2b635362011-05-02 12:33:43 +0200884static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200885 /* set dac0mux for dac converter */
886 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
887 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
888 {}
889};
890
Takashi Iwai2b635362011-05-02 12:33:43 +0200891static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100892 /* set master volume to max value without distortion
893 * and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100895 {}
896};
897
Takashi Iwai2b635362011-05-02 12:33:43 +0200898static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100899 /* set master volume and direct control */
900 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100901 {}
902};
903
Takashi Iwai2b635362011-05-02 12:33:43 +0200904static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200905 /* power state controls amps */
906 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200907 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200908};
909
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600910static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
911 { 0x22, 0x785, 0x43 },
912 { 0x22, 0x782, 0xe0 },
913 { 0x22, 0x795, 0x00 },
914 {}
915};
916
Takashi Iwai2b635362011-05-02 12:33:43 +0200917static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100918 /* set master volume and direct control */
919 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200920 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100921};
922
Takashi Iwai2b635362011-05-02 12:33:43 +0200923static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500924 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
925 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100926 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
927 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100928 {}
929};
930
Takashi Iwai2b635362011-05-02 12:33:43 +0200931static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100932 /* set dac0mux for dac converter */
933 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100934 /* mute the master volume */
935 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100936 {}
937};
938
Takashi Iwai2b635362011-05-02 12:33:43 +0200939static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200940 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200941 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200942 {}
943};
944
Takashi Iwai2b635362011-05-02 12:33:43 +0200945static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200946 /* unmute node 0x1b */
947 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
948 /* select node 0x03 as DAC */
949 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
950 {}
951};
952
Takashi Iwai2b635362011-05-02 12:33:43 +0200953static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200954 /* don't set delta bit */
955 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
956 /* unmute node 0x1b */
957 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
958 /* select node 0x03 as DAC */
959 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
960 {}
961};
962
Takashi Iwai2b635362011-05-02 12:33:43 +0200963static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100964 /* set master volume and direct control */
965 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200966 /* enable analog pc beep path */
967 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100968 {}
969};
970
Takashi Iwai2b635362011-05-02 12:33:43 +0200971static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200972 /* don't set delta bit */
973 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
974 /* enable analog pc beep path */
975 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
976 {}
977};
978
Takashi Iwai2b635362011-05-02 12:33:43 +0200979static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200980 /* set master volume and direct control */
981 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200982 /* enable analog pc beep path */
983 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200984 {}
985};
986
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100987#define STAC_MONO_MUX \
988 { \
989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
990 .name = "Mono Mux", \
991 .count = 1, \
992 .info = stac92xx_mono_mux_enum_info, \
993 .get = stac92xx_mono_mux_enum_get, \
994 .put = stac92xx_mono_mux_enum_put, \
995 }
996
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100997#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200998 { \
999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1000 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001001 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +02001002 .info = stac92xx_aloopback_info, \
1003 .get = stac92xx_aloopback_get, \
1004 .put = stac92xx_aloopback_put, \
1005 .private_value = verb_read | (verb_write << 16), \
1006 }
1007
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001008#define DC_BIAS(xname, idx, nid) \
1009 { \
1010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1011 .name = xname, \
1012 .index = idx, \
1013 .info = stac92xx_dc_bias_info, \
1014 .get = stac92xx_dc_bias_get, \
1015 .put = stac92xx_dc_bias_put, \
1016 .private_value = nid, \
1017 }
1018
Takashi Iwai2b635362011-05-02 12:33:43 +02001019static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001020 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1021 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001022 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001024 { } /* end */
1025};
1026
Takashi Iwai2b635362011-05-02 12:33:43 +02001027static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1029 {}
1030};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001031
Takashi Iwai2b635362011-05-02 12:33:43 +02001032static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001033 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1034 {}
1035};
1036
Takashi Iwai2b635362011-05-02 12:33:43 +02001037static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001038 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1039 {}
1040};
1041
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001042
Takashi Iwai2b635362011-05-02 12:33:43 +02001043static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001044 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1045};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001046
Takashi Iwai2b635362011-05-02 12:33:43 +02001047static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001048 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001050 { } /* end */
1051};
1052
Takashi Iwai2b635362011-05-02 12:33:43 +02001053static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001054 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1055 {}
1056};
1057
Takashi Iwai2b635362011-05-02 12:33:43 +02001058static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001059 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1060 {}
1061};
1062
Takashi Iwai1697055e2007-12-18 18:05:52 +01001063static struct snd_kcontrol_new stac_dmux_mixer = {
1064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1065 .name = "Digital Input Source",
1066 /* count set later */
1067 .info = stac92xx_dmux_enum_info,
1068 .get = stac92xx_dmux_enum_get,
1069 .put = stac92xx_dmux_enum_put,
1070};
1071
Matthew Ranostayd9737752008-09-07 12:03:41 +02001072static struct snd_kcontrol_new stac_smux_mixer = {
1073 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001074 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001075 /* count set later */
1076 .info = stac92xx_smux_enum_info,
1077 .get = stac92xx_smux_enum_get,
1078 .put = stac92xx_smux_enum_put,
1079};
1080
Takashi Iwai9322ca52012-02-03 14:28:01 +01001081static const char * const slave_pfxs[] = {
1082 "Front", "Surround", "Center", "LFE", "Side",
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01001083 "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001084 NULL
1085};
1086
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001087static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1088
1089static void stac92xx_vmaster_hook(void *private_data, int val)
1090{
1091 stac92xx_update_led_status(private_data, val);
1092}
1093
Takashi Iwai603c4012008-07-30 15:01:44 +02001094static void stac92xx_free_kctls(struct hda_codec *codec);
1095
Matt2f2f4252005-04-13 14:45:30 +02001096static int stac92xx_build_controls(struct hda_codec *codec)
1097{
1098 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001099 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001100 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001101 int i;
Matt2f2f4252005-04-13 14:45:30 +02001102
Takashi Iwai6479c632009-07-28 18:20:25 +02001103 if (spec->mixer) {
1104 err = snd_hda_add_new_ctls(codec, spec->mixer);
1105 if (err < 0)
1106 return err;
1107 }
Mattc7d4b2f2005-06-27 14:59:41 +02001108
1109 for (i = 0; i < spec->num_mixers; i++) {
1110 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1111 if (err < 0)
1112 return err;
1113 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001114 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1115 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001116 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001117 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001118 snd_ctl_new1(&stac_dmux_mixer, codec));
1119 if (err < 0)
1120 return err;
1121 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001122 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001123 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1124 struct hda_input_mux *smux = &spec->private_smux;
1125 /* check for mute support on SPDIF out */
1126 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001127 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001128 spec->spdif_mute = 1;
1129 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001130 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001131 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001132 snd_ctl_new1(&stac_smux_mixer, codec));
1133 if (err < 0)
1134 return err;
1135 }
Mattc7d4b2f2005-06-27 14:59:41 +02001136
Mattdabbed62005-06-14 10:19:34 +02001137 if (spec->multiout.dig_out_nid) {
Takashi Iwaidcda5802012-10-12 17:24:51 +02001138 err = snd_hda_create_dig_out_ctls(codec,
1139 spec->multiout.dig_out_nid,
1140 spec->multiout.dig_out_nid,
1141 spec->autocfg.dig_out_type[0]);
Mattdabbed62005-06-14 10:19:34 +02001142 if (err < 0)
1143 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001144 err = snd_hda_create_spdif_share_sw(codec,
1145 &spec->multiout);
1146 if (err < 0)
1147 return err;
1148 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001149 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001150 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001151 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1152 if (err < 0)
1153 return err;
1154 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001155
1156 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001157 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1158 HDA_OUTPUT, vmaster_tlv);
1159 /* correct volume offset */
1160 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1161 /* minimum value is actually mute */
1162 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1163 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1164 vmaster_tlv, slave_pfxs,
1165 "Playback Volume");
1166 if (err < 0)
1167 return err;
1168
1169 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1170 NULL, slave_pfxs,
1171 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001172 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001173 if (err < 0)
1174 return err;
1175
1176 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001177 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001178 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001179 if (err < 0)
1180 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001181 }
1182
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001183 if (spec->aloopback_ctl &&
1184 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1185 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1186 if (err < 0)
1187 return err;
1188 }
1189
Takashi Iwai603c4012008-07-30 15:01:44 +02001190 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001191
Takashi Iwai01a61e12011-10-28 00:03:22 +02001192 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1193 if (err < 0)
1194 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001195
Mattdabbed62005-06-14 10:19:34 +02001196 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001197}
1198
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001199static const struct hda_pintbl ref9200_pin_configs[] = {
1200 { 0x08, 0x01c47010 },
1201 { 0x09, 0x01447010 },
1202 { 0x0d, 0x0221401f },
1203 { 0x0e, 0x01114010 },
1204 { 0x0f, 0x02a19020 },
1205 { 0x10, 0x01a19021 },
1206 { 0x11, 0x90100140 },
1207 { 0x12, 0x01813122 },
1208 {}
Matt2f2f4252005-04-13 14:45:30 +02001209};
1210
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001211static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1212 { 0x08, 0x400000fe },
1213 { 0x09, 0x404500f4 },
1214 { 0x0d, 0x400100f0 },
1215 { 0x0e, 0x90110010 },
1216 { 0x0f, 0x400100f1 },
1217 { 0x10, 0x02a1902e },
1218 { 0x11, 0x500000f2 },
1219 { 0x12, 0x500000f3 },
1220 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001221};
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001222
1223static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1224 { 0x08, 0x400000fe },
1225 { 0x09, 0x404500f4 },
1226 { 0x0d, 0x400100f0 },
1227 { 0x0e, 0x90110010 },
1228 { 0x0f, 0x400100f1 },
1229 { 0x10, 0x02a1902e },
1230 { 0x11, 0x500000f2 },
1231 { 0x12, 0x500000f3 },
1232 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001233};
1234
1235/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001236 STAC 9200 pin configs for
1237 102801A8
1238 102801DE
1239 102801E8
1240*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001241static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1242 { 0x08, 0x400001f0 },
1243 { 0x09, 0x400001f1 },
1244 { 0x0d, 0x02214030 },
1245 { 0x0e, 0x01014010 },
1246 { 0x0f, 0x02a19020 },
1247 { 0x10, 0x01a19021 },
1248 { 0x11, 0x90100140 },
1249 { 0x12, 0x01813122 },
1250 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001251};
1252
1253/*
1254 STAC 9200 pin configs for
1255 102801C0
1256 102801C1
1257*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001258static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1259 { 0x08, 0x400001f0 },
1260 { 0x09, 0x400001f1 },
1261 { 0x0d, 0x0221401f },
1262 { 0x0e, 0x01014010 },
1263 { 0x0f, 0x01813020 },
1264 { 0x10, 0x02a19021 },
1265 { 0x11, 0x90100140 },
1266 { 0x12, 0x400001f2 },
1267 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001268};
1269
1270/*
1271 STAC 9200 pin configs for
1272 102801C4 (Dell Dimension E310)
1273 102801C5
1274 102801C7
1275 102801D9
1276 102801DA
1277 102801E3
1278*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001279static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1280 { 0x08, 0x400001f0 },
1281 { 0x09, 0x400001f1 },
1282 { 0x0d, 0x0221401f },
1283 { 0x0e, 0x01014010 },
1284 { 0x0f, 0x01813020 },
1285 { 0x10, 0x01a19021 },
1286 { 0x11, 0x90100140 },
1287 { 0x12, 0x400001f2 },
1288 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001289};
1290
1291
1292/*
1293 STAC 9200-32 pin configs for
1294 102801B5 (Dell Inspiron 630m)
1295 102801D8 (Dell Inspiron 640m)
1296*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001297static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1298 { 0x08, 0x40c003fa },
1299 { 0x09, 0x03441340 },
1300 { 0x0d, 0x0321121f },
1301 { 0x0e, 0x90170310 },
1302 { 0x0f, 0x408003fb },
1303 { 0x10, 0x03a11020 },
1304 { 0x11, 0x401003fc },
1305 { 0x12, 0x403003fd },
1306 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001307};
1308
1309/*
1310 STAC 9200-32 pin configs for
1311 102801C2 (Dell Latitude D620)
1312 102801C8
1313 102801CC (Dell Latitude D820)
1314 102801D4
1315 102801D6
1316*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001317static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1318 { 0x08, 0x40c003fa },
1319 { 0x09, 0x0144131f },
1320 { 0x0d, 0x0321121f },
1321 { 0x0e, 0x90170310 },
1322 { 0x0f, 0x90a70321 },
1323 { 0x10, 0x03a11020 },
1324 { 0x11, 0x401003fb },
1325 { 0x12, 0x40f000fc },
1326 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001327};
1328
1329/*
1330 STAC 9200-32 pin configs for
1331 102801CE (Dell XPS M1710)
1332 102801CF (Dell Precision M90)
1333*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001334static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1335 { 0x08, 0x40c003fa },
1336 { 0x09, 0x01441340 },
1337 { 0x0d, 0x0421421f },
1338 { 0x0e, 0x90170310 },
1339 { 0x0f, 0x408003fb },
1340 { 0x10, 0x04a1102e },
1341 { 0x11, 0x90170311 },
1342 { 0x12, 0x403003fc },
1343 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001344};
1345
1346/*
1347 STAC 9200-32 pin configs for
1348 102801C9
1349 102801CA
1350 102801CB (Dell Latitude 120L)
1351 102801D3
1352*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001353static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1354 { 0x08, 0x40c003fa },
1355 { 0x09, 0x404003fb },
1356 { 0x0d, 0x0321121f },
1357 { 0x0e, 0x90170310 },
1358 { 0x0f, 0x408003fc },
1359 { 0x10, 0x03a11020 },
1360 { 0x11, 0x401003fd },
1361 { 0x12, 0x403003fe },
1362 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001363};
1364
1365/*
1366 STAC 9200-32 pin configs for
1367 102801BD (Dell Inspiron E1505n)
1368 102801EE
1369 102801EF
1370*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001371static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1372 { 0x08, 0x40c003fa },
1373 { 0x09, 0x01441340 },
1374 { 0x0d, 0x0421121f },
1375 { 0x0e, 0x90170310 },
1376 { 0x0f, 0x408003fb },
1377 { 0x10, 0x04a11020 },
1378 { 0x11, 0x401003fc },
1379 { 0x12, 0x403003fd },
1380 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001381};
1382
1383/*
1384 STAC 9200-32 pin configs for
1385 102801F5 (Dell Inspiron 1501)
1386 102801F6
1387*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001388static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1389 { 0x08, 0x40c003fa },
1390 { 0x09, 0x404003fb },
1391 { 0x0d, 0x0421121f },
1392 { 0x0e, 0x90170310 },
1393 { 0x0f, 0x408003fc },
1394 { 0x10, 0x04a11020 },
1395 { 0x11, 0x401003fd },
1396 { 0x12, 0x403003fe },
1397 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398};
1399
1400/*
1401 STAC 9200-32
1402 102801CD (Dell Inspiron E1705/9400)
1403*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001404static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1405 { 0x08, 0x40c003fa },
1406 { 0x09, 0x01441340 },
1407 { 0x0d, 0x0421121f },
1408 { 0x0e, 0x90170310 },
1409 { 0x0f, 0x90170310 },
1410 { 0x10, 0x04a11020 },
1411 { 0x11, 0x90170310 },
1412 { 0x12, 0x40f003fc },
1413 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001414};
1415
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001416static const struct hda_pintbl oqo9200_pin_configs[] = {
1417 { 0x08, 0x40c000f0 },
1418 { 0x09, 0x404000f1 },
1419 { 0x0d, 0x0221121f },
1420 { 0x0e, 0x02211210 },
1421 { 0x0f, 0x90170111 },
1422 { 0x10, 0x90a70120 },
1423 { 0x11, 0x400000f2 },
1424 { 0x12, 0x400000f3 },
1425 {}
Tobin Davisbf277782008-02-03 20:31:47 +01001426};
1427
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001428
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001429static void stac9200_fixup_panasonic(struct hda_codec *codec,
1430 const struct hda_fixup *fix, int action)
1431{
1432 struct sigmatel_spec *spec = codec->spec;
1433
1434 switch (action) {
1435 case HDA_FIXUP_ACT_PRE_PROBE:
1436 spec->gpio_mask = spec->gpio_dir = 0x09;
1437 spec->gpio_data = 0x00;
1438 break;
1439 case HDA_FIXUP_ACT_PROBE:
1440 /* CF-74 has no headphone detection, and the driver should *NOT*
1441 * do detection and HP/speaker toggle because the hardware does it.
1442 */
1443 spec->hp_detect = 0;
1444 break;
1445 }
1446}
1447
1448
1449static const struct hda_fixup stac9200_fixups[] = {
1450 [STAC_REF] = {
1451 .type = HDA_FIXUP_PINS,
1452 .v.pins = ref9200_pin_configs,
1453 },
1454 [STAC_9200_OQO] = {
1455 .type = HDA_FIXUP_PINS,
1456 .v.pins = oqo9200_pin_configs,
1457 .chained = true,
1458 .chain_id = STAC_9200_EAPD_INIT,
1459 },
1460 [STAC_9200_DELL_D21] = {
1461 .type = HDA_FIXUP_PINS,
1462 .v.pins = dell9200_d21_pin_configs,
1463 },
1464 [STAC_9200_DELL_D22] = {
1465 .type = HDA_FIXUP_PINS,
1466 .v.pins = dell9200_d22_pin_configs,
1467 },
1468 [STAC_9200_DELL_D23] = {
1469 .type = HDA_FIXUP_PINS,
1470 .v.pins = dell9200_d23_pin_configs,
1471 },
1472 [STAC_9200_DELL_M21] = {
1473 .type = HDA_FIXUP_PINS,
1474 .v.pins = dell9200_m21_pin_configs,
1475 },
1476 [STAC_9200_DELL_M22] = {
1477 .type = HDA_FIXUP_PINS,
1478 .v.pins = dell9200_m22_pin_configs,
1479 },
1480 [STAC_9200_DELL_M23] = {
1481 .type = HDA_FIXUP_PINS,
1482 .v.pins = dell9200_m23_pin_configs,
1483 },
1484 [STAC_9200_DELL_M24] = {
1485 .type = HDA_FIXUP_PINS,
1486 .v.pins = dell9200_m24_pin_configs,
1487 },
1488 [STAC_9200_DELL_M25] = {
1489 .type = HDA_FIXUP_PINS,
1490 .v.pins = dell9200_m25_pin_configs,
1491 },
1492 [STAC_9200_DELL_M26] = {
1493 .type = HDA_FIXUP_PINS,
1494 .v.pins = dell9200_m26_pin_configs,
1495 },
1496 [STAC_9200_DELL_M27] = {
1497 .type = HDA_FIXUP_PINS,
1498 .v.pins = dell9200_m27_pin_configs,
1499 },
1500 [STAC_9200_M4] = {
1501 .type = HDA_FIXUP_PINS,
1502 .v.pins = gateway9200_m4_pin_configs,
1503 .chained = true,
1504 .chain_id = STAC_9200_EAPD_INIT,
1505 },
1506 [STAC_9200_M4_2] = {
1507 .type = HDA_FIXUP_PINS,
1508 .v.pins = gateway9200_m4_2_pin_configs,
1509 .chained = true,
1510 .chain_id = STAC_9200_EAPD_INIT,
1511 },
1512 [STAC_9200_PANASONIC] = {
1513 .type = HDA_FIXUP_FUNC,
1514 .v.func = stac9200_fixup_panasonic,
1515 },
1516 [STAC_9200_EAPD_INIT] = {
1517 .type = HDA_FIXUP_VERBS,
1518 .v.verbs = (const struct hda_verb[]) {
1519 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1520 {}
1521 },
1522 },
Matt Porter403d1942005-11-29 15:00:51 +01001523};
1524
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001525static const struct hda_model_fixup stac9200_models[] = {
1526 { .id = STAC_REF, .name = "ref" },
1527 { .id = STAC_9200_OQO, .name = "oqo" },
1528 { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1529 { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1530 { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1531 { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1532 { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1533 { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1534 { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1535 { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1536 { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1537 { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1538 { .id = STAC_9200_M4, .name = "gateway-m4" },
1539 { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1540 { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1541 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001542};
1543
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001544static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001545 /* SigmaTel reference board */
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1547 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001548 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1549 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001550 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1552 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001554 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1556 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1558 "unknown Dell", STAC_9200_DELL_D22),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1560 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001562 "Dell Latitude D620", STAC_9200_DELL_M22),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1564 "unknown Dell", STAC_9200_DELL_D23),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1566 "unknown Dell", STAC_9200_DELL_D23),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1568 "unknown Dell", STAC_9200_DELL_M22),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1570 "unknown Dell", STAC_9200_DELL_M24),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1572 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001574 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001576 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001578 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001580 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001582 "Dell Precision M90", STAC_9200_DELL_M23),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1584 "unknown Dell", STAC_9200_DELL_M22),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1586 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001588 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001590 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1592 "unknown Dell", STAC_9200_DELL_D23),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1594 "unknown Dell", STAC_9200_DELL_D23),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1596 "unknown Dell", STAC_9200_DELL_D21),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1598 "unknown Dell", STAC_9200_DELL_D23),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1600 "unknown Dell", STAC_9200_DELL_D21),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1602 "unknown Dell", STAC_9200_DELL_M25),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1604 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001606 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1608 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001609 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001610 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001611 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001612 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1613 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1614 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001615 /* OQO Mobile */
1616 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001617 {} /* terminator */
1618};
1619
Takashi Iwaid2077d42013-01-14 14:20:16 +01001620static const struct hda_pintbl ref925x_pin_configs[] = {
1621 { 0x07, 0x40c003f0 },
1622 { 0x08, 0x424503f2 },
1623 { 0x0a, 0x01813022 },
1624 { 0x0b, 0x02a19021 },
1625 { 0x0c, 0x90a70320 },
1626 { 0x0d, 0x02214210 },
1627 { 0x10, 0x01019020 },
1628 { 0x11, 0x9033032e },
1629 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001630};
1631
Takashi Iwaid2077d42013-01-14 14:20:16 +01001632static const struct hda_pintbl stac925xM1_pin_configs[] = {
1633 { 0x07, 0x40c003f4 },
1634 { 0x08, 0x424503f2 },
1635 { 0x0a, 0x400000f3 },
1636 { 0x0b, 0x02a19020 },
1637 { 0x0c, 0x40a000f0 },
1638 { 0x0d, 0x90100210 },
1639 { 0x10, 0x400003f1 },
1640 { 0x11, 0x9033032e },
1641 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001642};
1643
Takashi Iwaid2077d42013-01-14 14:20:16 +01001644static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1645 { 0x07, 0x40c003f4 },
1646 { 0x08, 0x424503f2 },
1647 { 0x0a, 0x400000f3 },
1648 { 0x0b, 0x02a19020 },
1649 { 0x0c, 0x40a000f0 },
1650 { 0x0d, 0x90100210 },
1651 { 0x10, 0x400003f1 },
1652 { 0x11, 0x9033032e },
1653 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001654};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001655
Takashi Iwaid2077d42013-01-14 14:20:16 +01001656static const struct hda_pintbl stac925xM2_pin_configs[] = {
1657 { 0x07, 0x40c003f4 },
1658 { 0x08, 0x424503f2 },
1659 { 0x0a, 0x400000f3 },
1660 { 0x0b, 0x02a19020 },
1661 { 0x0c, 0x40a000f0 },
1662 { 0x0d, 0x90100210 },
1663 { 0x10, 0x400003f1 },
1664 { 0x11, 0x9033032e },
1665 {}
Tobin Davis2c11f952007-05-17 09:36:34 +02001666};
1667
Takashi Iwaid2077d42013-01-14 14:20:16 +01001668static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1669 { 0x07, 0x40c003f4 },
1670 { 0x08, 0x424503f2 },
1671 { 0x0a, 0x400000f3 },
1672 { 0x0b, 0x02a19020 },
1673 { 0x0c, 0x40a000f0 },
1674 { 0x0d, 0x90100210 },
1675 { 0x10, 0x400003f1 },
1676 { 0x11, 0x9033032e },
1677 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001678};
1679
Takashi Iwaid2077d42013-01-14 14:20:16 +01001680static const struct hda_pintbl stac925xM3_pin_configs[] = {
1681 { 0x07, 0x40c003f4 },
1682 { 0x08, 0x424503f2 },
1683 { 0x0a, 0x400000f3 },
1684 { 0x0b, 0x02a19020 },
1685 { 0x0c, 0x40a000f0 },
1686 { 0x0d, 0x90100210 },
1687 { 0x10, 0x400003f1 },
1688 { 0x11, 0x503303f3 },
1689 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001690};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001691
Takashi Iwaid2077d42013-01-14 14:20:16 +01001692static const struct hda_pintbl stac925xM5_pin_configs[] = {
1693 { 0x07, 0x40c003f4 },
1694 { 0x08, 0x424503f2 },
1695 { 0x0a, 0x400000f3 },
1696 { 0x0b, 0x02a19020 },
1697 { 0x0c, 0x40a000f0 },
1698 { 0x0d, 0x90100210 },
1699 { 0x10, 0x400003f1 },
1700 { 0x11, 0x9033032e },
1701 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001702};
1703
Takashi Iwaid2077d42013-01-14 14:20:16 +01001704static const struct hda_pintbl stac925xM6_pin_configs[] = {
1705 { 0x07, 0x40c003f4 },
1706 { 0x08, 0x424503f2 },
1707 { 0x0a, 0x400000f3 },
1708 { 0x0b, 0x02a19020 },
1709 { 0x0c, 0x40a000f0 },
1710 { 0x0d, 0x90100210 },
1711 { 0x10, 0x400003f1 },
1712 { 0x11, 0x90330320 },
1713 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001714};
1715
Takashi Iwaid2077d42013-01-14 14:20:16 +01001716static const struct hda_fixup stac925x_fixups[] = {
1717 [STAC_REF] = {
1718 .type = HDA_FIXUP_PINS,
1719 .v.pins = ref925x_pin_configs,
1720 },
1721 [STAC_M1] = {
1722 .type = HDA_FIXUP_PINS,
1723 .v.pins = stac925xM1_pin_configs,
1724 },
1725 [STAC_M1_2] = {
1726 .type = HDA_FIXUP_PINS,
1727 .v.pins = stac925xM1_2_pin_configs,
1728 },
1729 [STAC_M2] = {
1730 .type = HDA_FIXUP_PINS,
1731 .v.pins = stac925xM2_pin_configs,
1732 },
1733 [STAC_M2_2] = {
1734 .type = HDA_FIXUP_PINS,
1735 .v.pins = stac925xM2_2_pin_configs,
1736 },
1737 [STAC_M3] = {
1738 .type = HDA_FIXUP_PINS,
1739 .v.pins = stac925xM3_pin_configs,
1740 },
1741 [STAC_M5] = {
1742 .type = HDA_FIXUP_PINS,
1743 .v.pins = stac925xM5_pin_configs,
1744 },
1745 [STAC_M6] = {
1746 .type = HDA_FIXUP_PINS,
1747 .v.pins = stac925xM6_pin_configs,
1748 },
Tobin Davis8e21c342007-01-08 11:04:17 +01001749};
1750
Takashi Iwaid2077d42013-01-14 14:20:16 +01001751static const struct hda_model_fixup stac925x_models[] = {
1752 { .id = STAC_REF, .name = "ref" },
1753 { .id = STAC_M1, .name = "m1" },
1754 { .id = STAC_M1_2, .name = "m1-2" },
1755 { .id = STAC_M2, .name = "m2" },
1756 { .id = STAC_M2_2, .name = "m2-2" },
1757 { .id = STAC_M3, .name = "m3" },
1758 { .id = STAC_M5, .name = "m5" },
1759 { .id = STAC_M6, .name = "m6" },
1760 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001761};
1762
Takashi Iwaid2077d42013-01-14 14:20:16 +01001763static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1764 /* SigmaTel reference board */
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1767 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1768
1769 /* Default table for unknown ID */
1770 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1771
1772 /* gateway machines are checked via codec ssid */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001773 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1774 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1775 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1776 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001777 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001778 /* Not sure about the brand name for those */
1779 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1780 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1781 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1782 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001783 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001784};
1785
Takashi Iwai2b635362011-05-02 12:33:43 +02001786static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001787 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1788 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1789 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001790 0x01452050,
1791};
1792
Takashi Iwai2b635362011-05-02 12:33:43 +02001793static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001794 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001795 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001796 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1797 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001798};
1799
Takashi Iwai2b635362011-05-02 12:33:43 +02001800static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001801 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1802 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1803 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1804 0x904601b0,
1805};
1806
Takashi Iwai2b635362011-05-02 12:33:43 +02001807static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001808 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001809 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001810};
1811
Takashi Iwai2b635362011-05-02 12:33:43 +02001812static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001813 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001814 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1815 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1816 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001817 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001818 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001819 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001820};
1821
Takashi Iwaiea734962011-01-17 11:29:34 +01001822static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001823 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001824 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001825 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001826 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001827 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1828 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1829 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001830 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001831 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001832};
1833
Takashi Iwai2b635362011-05-02 12:33:43 +02001834static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001835 /* SigmaTel reference board */
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001837 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001838 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1839 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1841 "Intel DG45ID", STAC_92HD73XX_INTEL),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1843 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001845 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001847 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001849 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001851 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001853 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001855 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001857 "unknown Dell", STAC_DELL_M6_DMIC),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1859 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001861 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001862 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1863 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001864 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1865 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001866 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1867 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001868 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001869 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001870 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001871 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001872 {} /* terminator */
1873};
1874
Takashi Iwai2b635362011-05-02 12:33:43 +02001875static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001876 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1877 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001878 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1879 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001880 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001881 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001882 {} /* terminator */
1883};
1884
Takashi Iwai2b635362011-05-02 12:33:43 +02001885static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001886 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1887 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001888 0x01451160, 0x98560170,
1889};
1890
Takashi Iwai2b635362011-05-02 12:33:43 +02001891static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001892 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1893 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001894 0x40f000f0, 0x40f000f0,
1895};
1896
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001897static const unsigned int dell_vostro_3500_pin_configs[10] = {
1898 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1899 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1900 0x400000f4, 0x400000f5,
1901};
1902
Takashi Iwai2b635362011-05-02 12:33:43 +02001903static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001904 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1905 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1906 0x40f000f0, 0x40f000f0,
1907};
1908
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001909static const unsigned int hp_zephyr_pin_configs[10] = {
1910 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1911 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1912 0, 0,
1913};
1914
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001915static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1916 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1917 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1918 0x40f000f0, 0x40f000f0,
1919};
1920
Takashi Iwai2b635362011-05-02 12:33:43 +02001921static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001922 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001923 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001924 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001925 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001926 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001927 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001928 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001929};
1930
Takashi Iwaiea734962011-01-17 11:29:34 +01001931static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001932 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001933 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001934 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001935 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001936 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001937 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001938 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001939 [STAC_HP_ZEPHYR] = "hp-zephyr",
Takashi Iwaia3e19972012-07-26 08:17:20 +02001940 [STAC_92HD83XXX_HP_LED] = "hp-led",
Takashi Iwaiff8a1e22012-07-31 10:16:59 +02001941 [STAC_92HD83XXX_HP_INV_LED] = "hp-inv-led",
Takashi Iwai62cbde12012-09-14 11:58:54 +02001942 [STAC_92HD83XXX_HP_MIC_LED] = "hp-mic-led",
David Henningsson8d032a82012-10-09 12:48:40 +02001943 [STAC_92HD83XXX_HEADSET_JACK] = "headset-jack",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001944};
1945
Takashi Iwai2b635362011-05-02 12:33:43 +02001946static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001947 /* SigmaTel reference board */
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001949 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001950 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1951 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001952 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1953 "unknown Dell", STAC_DELL_S14),
David Henningsson8d032a82012-10-09 12:48:40 +02001954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
1955 "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
1957 "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
1959 "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
1961 "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
1963 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
1965 "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
1967 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
1969 "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
1971 "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001972 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1973 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001974 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1975 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1977 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1979 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
Takashi Iwai8ae58652012-12-13 14:33:42 +01001981 "HP Pavilion dv7", STAC_HP_DV7_4000),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001982 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1983 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1985 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Takashi Iwai62cbde12012-09-14 11:58:54 +02001986 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
1987 "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001988 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1989 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1991 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1993 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1995 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1997 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1999 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
2001 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
2003 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
2005 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
2007 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
2009 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2011 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2013 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2015 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002016 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2017 "HP", STAC_HP_ZEPHYR),
Takashi Iwaia3e19972012-07-26 08:17:20 +02002018 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2019 "HP Mini", STAC_92HD83XXX_HP_LED),
Gustavo Maciel Dias Vieira5afc13a2012-10-26 12:51:53 -02002020 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2021 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002022 {} /* terminator */
2023};
2024
2025static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2027 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02002028 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002029};
2030
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002031static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2032 { 0x0a, 0x02214030 },
2033 { 0x0b, 0x02a19040 },
2034 { 0x0c, 0x01a19020 },
2035 { 0x0d, 0x01014010 },
2036 { 0x0e, 0x0181302e },
2037 { 0x0f, 0x01014010 },
2038 { 0x14, 0x01019020 },
2039 { 0x18, 0x90a000f0 },
2040 { 0x19, 0x90a000f0 },
2041 { 0x1e, 0x01452050 },
2042 { 0x1f, 0x01452050 },
2043 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002044};
2045
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002046static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2047 { 0x0a, 0x0421101f },
2048 { 0x0b, 0x04a11221 },
2049 { 0x0c, 0x40f000f0 },
2050 { 0x0d, 0x90170110 },
2051 { 0x0e, 0x23a1902e },
2052 { 0x0f, 0x23014250 },
2053 { 0x14, 0x40f000f0 },
2054 { 0x18, 0x90a000f0 },
2055 { 0x19, 0x40f000f0 },
2056 { 0x1e, 0x4f0000f0 },
2057 { 0x1f, 0x4f0000f0 },
2058 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002059};
2060
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002061static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2062 { 0x0a, 0x0421101f },
2063 { 0x0b, 0x04a11221 },
2064 { 0x0c, 0x90a70330 },
2065 { 0x0d, 0x90170110 },
2066 { 0x0e, 0x23a1902e },
2067 { 0x0f, 0x23014250 },
2068 { 0x14, 0x40f000f0 },
2069 { 0x18, 0x40f000f0 },
2070 { 0x19, 0x40f000f0 },
2071 { 0x1e, 0x044413b0 },
2072 { 0x1f, 0x044413b0 },
2073 {}
Matthew Ranostaya7662642008-02-21 07:51:14 +01002074};
2075
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002076static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2077 { 0x0a, 0x0421101f },
2078 { 0x0b, 0x04a11221 },
2079 { 0x0c, 0x90a70330 },
2080 { 0x0d, 0x90170110 },
2081 { 0x0e, 0x40f000f0 },
2082 { 0x0f, 0x40f000f0 },
2083 { 0x14, 0x40f000f0 },
2084 { 0x18, 0x90a000f0 },
2085 { 0x19, 0x40f000f0 },
2086 { 0x1e, 0x044413b0 },
2087 { 0x1f, 0x044413b0 },
2088 {}
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002089};
2090
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002091static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2092 const struct hda_fixup *fix, int action)
2093{
2094 struct sigmatel_spec *spec = codec->spec;
2095
2096 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2097 return;
2098
2099 snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2100 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2101}
2102
2103static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec,
2104 const struct hda_fixup *fix, int action)
2105{
2106 struct sigmatel_spec *spec = codec->spec;
2107
2108 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2109 return;
2110 spec->num_dmics = 0;
2111 spec->num_smuxes = 0;
2112 spec->num_dmuxes = 0;
2113}
2114
2115static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec,
2116 const struct hda_fixup *fix, int action)
2117{
2118 struct sigmatel_spec *spec = codec->spec;
2119
2120 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2121 return;
2122 spec->num_dmics = 1;
2123 spec->num_smuxes = 0;
2124 spec->num_dmuxes = 1;
2125}
2126
2127static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2128 const struct hda_fixup *fix, int action)
2129{
2130 struct sigmatel_spec *spec = codec->spec;
2131
2132 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2133 return;
2134
2135 /* Enable VREF power saving on GPIO1 detect */
2136 stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02);
2137 snd_hda_codec_write_cache(codec, codec->afg, 0,
2138 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
2139 snd_hda_jack_detect_enable(codec, codec->afg, 0);
2140 spec->gpio_mask |= 0x02;
2141
2142 /* enable internal microphone */
2143 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2144 stac92xx_auto_set_pinctl(codec, 0x0e,
2145 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2146
2147 stac92hd71bxx_fixup_no_dmic(codec, fix, action);
2148}
2149
2150static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec,
2151 const struct hda_fixup *fix, int action)
2152{
2153 struct sigmatel_spec *spec = codec->spec;
2154
2155 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2156 return;
2157 spec->num_dmics = 1;
2158 /* I don't know if it needs 1 or 2 smuxes - will wait for
2159 * bug reports to fix if needed
2160 */
2161 spec->num_smuxes = 1;
2162 spec->num_dmuxes = 1;
2163}
2164
2165static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2166 const struct hda_fixup *fix, int action)
2167{
2168 struct sigmatel_spec *spec = codec->spec;
2169
2170 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2171 return;
2172 spec->gpio_led = 0x01;
2173}
2174
2175static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2176 const struct hda_fixup *fix, int action)
2177{
2178 struct sigmatel_spec *spec = codec->spec;
2179 unsigned int cap;
2180
2181 switch (action) {
2182 case HDA_FIXUP_ACT_PRE_PROBE:
2183 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2184 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
2185 /* HP dv6 gives the headphone pin as a line-out. Thus we
2186 * need to set hp_detect flag here to force to enable HP
2187 * detection.
2188 */
2189 spec->hp_detect = 1;
2190 break;
2191
2192 case HDA_FIXUP_ACT_PROBE:
2193 /* enable bass on HP dv7 */
2194 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2195 cap &= AC_GPIO_IO_COUNT;
2196 if (cap >= 6)
2197 stac_add_hp_bass_switch(codec);
2198 break;
2199 }
2200}
2201
2202static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
2203 const struct hda_fixup *fix, int action)
2204{
2205 struct sigmatel_spec *spec = codec->spec;
2206
2207 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2208 return;
2209 spec->gpio_led = 0x08;
2210 spec->num_dmics = 1;
2211 spec->num_smuxes = 1;
2212 spec->num_dmuxes = 1;
2213}
2214
2215
2216static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
2217 const struct hda_fixup *fix, int action)
2218{
2219 struct sigmatel_spec *spec = codec->spec;
2220
2221 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2222 return;
2223
2224 if (hp_blike_system(codec->subsystem_id)) {
2225 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
2226 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
2227 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
2228 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
2229 /* It was changed in the BIOS to just satisfy MS DTM.
2230 * Lets turn it back into slaved HP
2231 */
2232 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
2233 | (AC_JACK_HP_OUT <<
2234 AC_DEFCFG_DEVICE_SHIFT);
2235 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
2236 | AC_DEFCFG_SEQUENCE)))
2237 | 0x1f;
2238 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
2239 }
2240 }
2241
2242 if (find_mute_led_cfg(codec, 1))
2243 snd_printd("mute LED gpio %d polarity %d\n",
2244 spec->gpio_led,
2245 spec->gpio_led_polarity);
2246
2247}
2248
2249static const struct hda_fixup stac92hd71bxx_fixups[] = {
2250 [STAC_92HD71BXX_REF] = {
2251 .type = HDA_FIXUP_FUNC,
2252 .v.func = stac92hd71bxx_fixup_ref,
2253 },
2254 [STAC_DELL_M4_1] = {
2255 .type = HDA_FIXUP_PINS,
2256 .v.pins = dell_m4_1_pin_configs,
2257 .chained = true,
2258 .chain_id = STAC_92HD71BXX_NO_SMUX,
2259 },
2260 [STAC_DELL_M4_2] = {
2261 .type = HDA_FIXUP_PINS,
2262 .v.pins = dell_m4_2_pin_configs,
2263 .chained = true,
2264 .chain_id = STAC_92HD71BXX_NO_DMIC,
2265 },
2266 [STAC_DELL_M4_3] = {
2267 .type = HDA_FIXUP_PINS,
2268 .v.pins = dell_m4_3_pin_configs,
2269 .chained = true,
2270 .chain_id = STAC_92HD71BXX_NO_SMUX,
2271 },
2272 [STAC_HP_M4] = {
2273 .type = HDA_FIXUP_FUNC,
2274 .v.func = stac92hd71bxx_fixup_hp_m4,
2275 .chained = true,
2276 .chain_id = STAC_92HD71BXX_HP,
2277 },
2278 [STAC_HP_DV4] = {
2279 .type = HDA_FIXUP_FUNC,
2280 .v.func = stac92hd71bxx_fixup_hp_dv4,
2281 .chained = true,
2282 .chain_id = STAC_HP_DV5,
2283 },
2284 [STAC_HP_DV5] = {
2285 .type = HDA_FIXUP_FUNC,
2286 .v.func = stac92hd71bxx_fixup_hp_dv5,
2287 .chained = true,
2288 .chain_id = STAC_92HD71BXX_HP,
2289 },
2290 [STAC_HP_HDX] = {
2291 .type = HDA_FIXUP_FUNC,
2292 .v.func = stac92hd71bxx_fixup_hp_hdx,
2293 .chained = true,
2294 .chain_id = STAC_92HD71BXX_HP,
2295 },
2296 [STAC_HP_DV4_1222NR] = {
2297 .type = HDA_FIXUP_FUNC,
2298 .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr,
2299 .chained = true,
2300 .chain_id = STAC_HP_DV4,
2301 },
2302 [STAC_92HD71BXX_NO_DMIC] = {
2303 .type = HDA_FIXUP_FUNC,
2304 .v.func = stac92hd71bxx_fixup_no_dmic,
2305 },
2306 [STAC_92HD71BXX_NO_SMUX] = {
2307 .type = HDA_FIXUP_FUNC,
2308 .v.func = stac92hd71bxx_fixup_no_smux,
2309 },
2310 [STAC_92HD71BXX_HP] = {
2311 .type = HDA_FIXUP_FUNC,
2312 .v.func = stac92hd71bxx_fixup_hp,
2313 },
Matthew Ranostaye035b842007-11-06 11:53:55 +01002314};
2315
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002316static const struct hda_model_fixup stac92hd71bxx_models[] = {
2317 { .id = STAC_92HD71BXX_REF, .name = "ref" },
2318 { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
2319 { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
2320 { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
2321 { .id = STAC_HP_M4, .name = "hp-m4" },
2322 { .id = STAC_HP_DV4, .name = "hp-dv4" },
2323 { .id = STAC_HP_DV5, .name = "hp-dv5" },
2324 { .id = STAC_HP_HDX, .name = "hp-hdx" },
2325 { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" },
2326 {}
Matthew Ranostaye035b842007-11-06 11:53:55 +01002327};
2328
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002329static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002330 /* SigmaTel reference board */
2331 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2332 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002333 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2334 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04002335 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
2336 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01002337 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2338 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01002339 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2340 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002341 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002342 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002343 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2344 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002345 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2346 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04002347 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002348 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002349 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002350 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02002351 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2352 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05302353 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2354 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11002355 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2356 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02002357 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2358 "HP", STAC_HP_DV5),
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01002359 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2361 "unknown Dell", STAC_DELL_M4_1),
2362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2363 "unknown Dell", STAC_DELL_M4_1),
2364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2365 "unknown Dell", STAC_DELL_M4_1),
2366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2367 "unknown Dell", STAC_DELL_M4_1),
2368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2369 "unknown Dell", STAC_DELL_M4_1),
2370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2371 "unknown Dell", STAC_DELL_M4_1),
2372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2373 "unknown Dell", STAC_DELL_M4_1),
2374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2375 "unknown Dell", STAC_DELL_M4_2),
2376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2377 "unknown Dell", STAC_DELL_M4_2),
2378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2379 "unknown Dell", STAC_DELL_M4_2),
2380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2381 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2383 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002384 {} /* terminator */
2385};
2386
Takashi Iwai0a427842013-01-14 15:20:13 +01002387static const struct hda_pintbl ref922x_pin_configs[] = {
2388 { 0x0a, 0x01014010 },
2389 { 0x0b, 0x01016011 },
2390 { 0x0c, 0x01012012 },
2391 { 0x0d, 0x0221401f },
2392 { 0x0e, 0x01813122 },
2393 { 0x0f, 0x01011014 },
2394 { 0x10, 0x01441030 },
2395 { 0x11, 0x01c41030 },
2396 { 0x15, 0x40000100 },
2397 { 0x1b, 0x40000100 },
2398 {}
Matt2f2f4252005-04-13 14:45:30 +02002399};
2400
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002401/*
2402 STAC 922X pin configs for
2403 102801A7
2404 102801AB
2405 102801A9
2406 102801D1
2407 102801D2
2408*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002409static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2410 { 0x0a, 0x02214030 },
2411 { 0x0b, 0x01a19021 },
2412 { 0x0c, 0x01111012 },
2413 { 0x0d, 0x01114010 },
2414 { 0x0e, 0x02a19020 },
2415 { 0x0f, 0x01117011 },
2416 { 0x10, 0x400001f0 },
2417 { 0x11, 0x400001f1 },
2418 { 0x15, 0x01813122 },
2419 { 0x1b, 0x400001f2 },
2420 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002421};
2422
2423/*
2424 STAC 922X pin configs for
2425 102801AC
2426 102801D0
2427*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002428static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2429 { 0x0a, 0x02214030 },
2430 { 0x0b, 0x01a19021 },
2431 { 0x0c, 0x01111012 },
2432 { 0x0d, 0x01114010 },
2433 { 0x0e, 0x02a19020 },
2434 { 0x0f, 0x01117011 },
2435 { 0x10, 0x01451140 },
2436 { 0x11, 0x400001f0 },
2437 { 0x15, 0x01813122 },
2438 { 0x1b, 0x400001f1 },
2439 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002440};
2441
2442/*
2443 STAC 922X pin configs for
2444 102801BF
2445*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002446static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2447 { 0x0a, 0x0321101f },
2448 { 0x0b, 0x01112024 },
2449 { 0x0c, 0x01111222 },
2450 { 0x0d, 0x91174220 },
2451 { 0x0e, 0x03a11050 },
2452 { 0x0f, 0x01116221 },
2453 { 0x10, 0x90a70330 },
2454 { 0x11, 0x01452340 },
2455 { 0x15, 0x40C003f1 },
2456 { 0x1b, 0x405003f0 },
2457 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002458};
2459
2460/*
2461 STAC 9221 A1 pin configs for
2462 102801D7 (Dell XPS M1210)
2463*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002464static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2465 { 0x0a, 0x02211211 },
2466 { 0x0b, 0x408103ff },
2467 { 0x0c, 0x02a1123e },
2468 { 0x0d, 0x90100310 },
2469 { 0x0e, 0x408003f1 },
2470 { 0x0f, 0x0221121f },
2471 { 0x10, 0x03451340 },
2472 { 0x11, 0x40c003f2 },
2473 { 0x15, 0x508003f3 },
2474 { 0x1b, 0x405003f4 },
2475 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002476};
2477
Takashi Iwai0a427842013-01-14 15:20:13 +01002478static const struct hda_pintbl d945gtp3_pin_configs[] = {
2479 { 0x0a, 0x0221401f },
2480 { 0x0b, 0x01a19022 },
2481 { 0x0c, 0x01813021 },
2482 { 0x0d, 0x01014010 },
2483 { 0x0e, 0x40000100 },
2484 { 0x0f, 0x40000100 },
2485 { 0x10, 0x40000100 },
2486 { 0x11, 0x40000100 },
2487 { 0x15, 0x02a19120 },
2488 { 0x1b, 0x40000100 },
2489 {}
Matt Porter403d1942005-11-29 15:00:51 +01002490};
2491
Takashi Iwai0a427842013-01-14 15:20:13 +01002492static const struct hda_pintbl d945gtp5_pin_configs[] = {
2493 { 0x0a, 0x0221401f },
2494 { 0x0b, 0x01011012 },
2495 { 0x0c, 0x01813024 },
2496 { 0x0d, 0x01014010 },
2497 { 0x0e, 0x01a19021 },
2498 { 0x0f, 0x01016011 },
2499 { 0x10, 0x01452130 },
2500 { 0x11, 0x40000100 },
2501 { 0x15, 0x02a19320 },
2502 { 0x1b, 0x40000100 },
2503 {}
Matt Porter403d1942005-11-29 15:00:51 +01002504};
2505
Takashi Iwai0a427842013-01-14 15:20:13 +01002506static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2507 { 0x0a, 0x0121e21f },
2508 { 0x0b, 0x400000ff },
2509 { 0x0c, 0x9017e110 },
2510 { 0x0d, 0x400000fd },
2511 { 0x0e, 0x400000fe },
2512 { 0x0f, 0x0181e020 },
2513 { 0x10, 0x1145e030 },
2514 { 0x11, 0x11c5e240 },
2515 { 0x15, 0x400000fc },
2516 { 0x1b, 0x400000fb },
2517 {}
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002518};
2519
Takashi Iwai0a427842013-01-14 15:20:13 +01002520static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2521 { 0x0a, 0x0121e21f },
2522 { 0x0b, 0x90a7012e },
2523 { 0x0c, 0x9017e110 },
2524 { 0x0d, 0x400000fd },
2525 { 0x0e, 0x400000fe },
2526 { 0x0f, 0x0181e020 },
2527 { 0x10, 0x1145e230 },
2528 { 0x11, 0x500000fa },
2529 { 0x15, 0x400000fc },
2530 { 0x1b, 0x400000fb },
2531 {}
Sylvain FORETf16928f2007-04-27 14:22:36 +02002532};
2533
Takashi Iwai0a427842013-01-14 15:20:13 +01002534static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2535 { 0x0a, 0x0121e21f },
2536 { 0x0b, 0x90a7012e },
2537 { 0x0c, 0x9017e110 },
2538 { 0x0d, 0x400000fd },
2539 { 0x0e, 0x400000fe },
2540 { 0x0f, 0x0181e020 },
2541 { 0x10, 0x1145e230 },
2542 { 0x11, 0x11c5e240 },
2543 { 0x15, 0x400000fc },
2544 { 0x1b, 0x400000fb },
2545 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002546};
2547
Takashi Iwai0a427842013-01-14 15:20:13 +01002548static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2549 { 0x0a, 0x0321e21f },
2550 { 0x0b, 0x03a1e02e },
2551 { 0x0c, 0x9017e110 },
2552 { 0x0d, 0x9017e11f },
2553 { 0x0e, 0x400000fe },
2554 { 0x0f, 0x0381e020 },
2555 { 0x10, 0x1345e230 },
2556 { 0x11, 0x13c5e240 },
2557 { 0x15, 0x400000fc },
2558 { 0x1b, 0x400000fb },
2559 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002560};
2561
Takashi Iwai0a427842013-01-14 15:20:13 +01002562static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2563 { 0x0a, 0x0321e21f },
2564 { 0x0b, 0x03a1e02e },
2565 { 0x0c, 0x9017e110 },
2566 { 0x0d, 0x9017e11f },
2567 { 0x0e, 0x400000fe },
2568 { 0x0f, 0x0381e020 },
2569 { 0x10, 0x1345e230 },
2570 { 0x11, 0x13c5e240 },
2571 { 0x15, 0x400000fc },
2572 { 0x1b, 0x400000fb },
2573 {}
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002574};
2575
Takashi Iwai0a427842013-01-14 15:20:13 +01002576static const struct hda_pintbl ecs202_pin_configs[] = {
2577 { 0x0a, 0x0221401f },
2578 { 0x0b, 0x02a19020 },
2579 { 0x0c, 0x01a19020 },
2580 { 0x0d, 0x01114010 },
2581 { 0x0e, 0x408000f0 },
2582 { 0x0f, 0x01813022 },
2583 { 0x10, 0x074510a0 },
2584 { 0x11, 0x40c400f1 },
2585 { 0x15, 0x9037012e },
2586 { 0x1b, 0x40e000f2 },
2587 {}
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002588};
Takashi Iwai76c08822007-06-19 12:17:42 +02002589
Takashi Iwai0a427842013-01-14 15:20:13 +01002590/* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2591static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2592 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2593 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2594 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2595 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2596 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2597 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2598 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2599 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2600 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2601 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2602 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2603 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2604 {}
2605};
2606
2607static const struct hda_fixup stac922x_fixups[];
2608
2609/* remap the fixup from codec SSID and apply it */
2610static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2611 const struct hda_fixup *fix,
2612 int action)
2613{
2614 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2615 return;
2616 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2617 stac922x_fixups);
2618 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2619 snd_hda_apply_fixup(codec, action);
2620}
2621
2622static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2623 const struct hda_fixup *fix,
2624 int action)
2625{
2626 struct sigmatel_spec *spec = codec->spec;
2627
2628 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2629 spec->gpio_mask = spec->gpio_dir = 0x03;
2630 spec->gpio_data = 0x03;
2631 }
2632}
2633
2634static const struct hda_fixup stac922x_fixups[] = {
2635 [STAC_D945_REF] = {
2636 .type = HDA_FIXUP_PINS,
2637 .v.pins = ref922x_pin_configs,
2638 },
2639 [STAC_D945GTP3] = {
2640 .type = HDA_FIXUP_PINS,
2641 .v.pins = d945gtp3_pin_configs,
2642 },
2643 [STAC_D945GTP5] = {
2644 .type = HDA_FIXUP_PINS,
2645 .v.pins = d945gtp5_pin_configs,
2646 },
2647 [STAC_INTEL_MAC_AUTO] = {
2648 .type = HDA_FIXUP_FUNC,
2649 .v.func = stac922x_fixup_intel_mac_auto,
2650 },
2651 [STAC_INTEL_MAC_V1] = {
2652 .type = HDA_FIXUP_PINS,
2653 .v.pins = intel_mac_v1_pin_configs,
2654 .chained = true,
2655 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2656 },
2657 [STAC_INTEL_MAC_V2] = {
2658 .type = HDA_FIXUP_PINS,
2659 .v.pins = intel_mac_v2_pin_configs,
2660 .chained = true,
2661 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2662 },
2663 [STAC_INTEL_MAC_V3] = {
2664 .type = HDA_FIXUP_PINS,
2665 .v.pins = intel_mac_v3_pin_configs,
2666 .chained = true,
2667 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2668 },
2669 [STAC_INTEL_MAC_V4] = {
2670 .type = HDA_FIXUP_PINS,
2671 .v.pins = intel_mac_v4_pin_configs,
2672 .chained = true,
2673 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2674 },
2675 [STAC_INTEL_MAC_V5] = {
2676 .type = HDA_FIXUP_PINS,
2677 .v.pins = intel_mac_v5_pin_configs,
2678 .chained = true,
2679 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2680 },
2681 [STAC_922X_INTEL_MAC_GPIO] = {
2682 .type = HDA_FIXUP_FUNC,
2683 .v.func = stac922x_fixup_intel_mac_gpio,
2684 },
2685 [STAC_ECS_202] = {
2686 .type = HDA_FIXUP_PINS,
2687 .v.pins = ecs202_pin_configs,
2688 },
2689 [STAC_922X_DELL_D81] = {
2690 .type = HDA_FIXUP_PINS,
2691 .v.pins = dell_922x_d81_pin_configs,
2692 },
2693 [STAC_922X_DELL_D82] = {
2694 .type = HDA_FIXUP_PINS,
2695 .v.pins = dell_922x_d82_pin_configs,
2696 },
2697 [STAC_922X_DELL_M81] = {
2698 .type = HDA_FIXUP_PINS,
2699 .v.pins = dell_922x_m81_pin_configs,
2700 },
2701 [STAC_922X_DELL_M82] = {
2702 .type = HDA_FIXUP_PINS,
2703 .v.pins = dell_922x_m82_pin_configs,
2704 },
2705};
2706
2707static const struct hda_model_fixup stac922x_models[] = {
2708 { .id = STAC_D945_REF, .name = "ref" },
2709 { .id = STAC_D945GTP5, .name = "5stack" },
2710 { .id = STAC_D945GTP3, .name = "3stack" },
2711 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
2712 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
2713 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
2714 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
2715 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
2716 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
2717 { .id = STAC_ECS_202, .name = "ecs202" },
2718 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
2719 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
2720 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
2721 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002722 /* for backward compatibility */
Takashi Iwai0a427842013-01-14 15:20:13 +01002723 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
2724 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
2725 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
2726 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
2727 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
2728 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
2729 {}
Matt Porter403d1942005-11-29 15:00:51 +01002730};
2731
Takashi Iwai0a427842013-01-14 15:20:13 +01002732static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002733 /* SigmaTel reference board */
2734 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2735 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002736 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2737 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002738 /* Intel 945G based systems */
2739 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2740 "Intel D945G", STAC_D945GTP3),
2741 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2742 "Intel D945G", STAC_D945GTP3),
2743 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2744 "Intel D945G", STAC_D945GTP3),
2745 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2746 "Intel D945G", STAC_D945GTP3),
2747 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2748 "Intel D945G", STAC_D945GTP3),
2749 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2750 "Intel D945G", STAC_D945GTP3),
2751 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2752 "Intel D945G", STAC_D945GTP3),
2753 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2754 "Intel D945G", STAC_D945GTP3),
2755 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2756 "Intel D945G", STAC_D945GTP3),
2757 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2758 "Intel D945G", STAC_D945GTP3),
2759 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2760 "Intel D945G", STAC_D945GTP3),
2761 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2762 "Intel D945G", STAC_D945GTP3),
2763 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2764 "Intel D945G", STAC_D945GTP3),
2765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2766 "Intel D945G", STAC_D945GTP3),
2767 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2768 "Intel D945G", STAC_D945GTP3),
2769 /* Intel D945G 5-stack systems */
2770 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2771 "Intel D945G", STAC_D945GTP5),
2772 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2773 "Intel D945G", STAC_D945GTP5),
2774 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2775 "Intel D945G", STAC_D945GTP5),
2776 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2777 "Intel D945G", STAC_D945GTP5),
2778 /* Intel 945P based systems */
2779 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2780 "Intel D945P", STAC_D945GTP3),
2781 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2782 "Intel D945P", STAC_D945GTP3),
2783 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2784 "Intel D945P", STAC_D945GTP3),
2785 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2786 "Intel D945P", STAC_D945GTP3),
2787 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2788 "Intel D945P", STAC_D945GTP3),
2789 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2790 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002791 /* other intel */
2792 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2793 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002794 /* other systems */
Takashi Iwai0a427842013-01-14 15:20:13 +01002795
Nicolas Boichat536319a2008-07-21 22:18:01 +08002796 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwai0a427842013-01-14 15:20:13 +01002797 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
2798
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002799 /* Dell systems */
2800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2801 "unknown Dell", STAC_922X_DELL_D81),
2802 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2803 "unknown Dell", STAC_922X_DELL_D81),
2804 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2805 "unknown Dell", STAC_922X_DELL_D81),
2806 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2807 "unknown Dell", STAC_922X_DELL_D82),
2808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2809 "unknown Dell", STAC_922X_DELL_M81),
2810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2811 "unknown Dell", STAC_922X_DELL_D82),
2812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2813 "unknown Dell", STAC_922X_DELL_D81),
2814 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2815 "unknown Dell", STAC_922X_DELL_D81),
2816 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2817 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002818 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002819 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002820 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002821 {} /* terminator */
2822};
2823
Takashi Iwai29ac8362013-01-14 16:03:38 +01002824static const struct hda_pintbl ref927x_pin_configs[] = {
2825 { 0x0a, 0x02214020 },
2826 { 0x0b, 0x02a19080 },
2827 { 0x0c, 0x0181304e },
2828 { 0x0d, 0x01014010 },
2829 { 0x0e, 0x01a19040 },
2830 { 0x0f, 0x01011012 },
2831 { 0x10, 0x01016011 },
2832 { 0x11, 0x0101201f },
2833 { 0x12, 0x183301f0 },
2834 { 0x13, 0x18a001f0 },
2835 { 0x14, 0x18a001f0 },
2836 { 0x21, 0x01442070 },
2837 { 0x22, 0x01c42190 },
2838 { 0x23, 0x40000100 },
2839 {}
Matt Porter3cc08dc2006-01-23 15:27:49 +01002840};
2841
Takashi Iwai29ac8362013-01-14 16:03:38 +01002842static const struct hda_pintbl d965_3st_pin_configs[] = {
2843 { 0x0a, 0x0221401f },
2844 { 0x0b, 0x02a19120 },
2845 { 0x0c, 0x40000100 },
2846 { 0x0d, 0x01014011 },
2847 { 0x0e, 0x01a19021 },
2848 { 0x0f, 0x01813024 },
2849 { 0x10, 0x40000100 },
2850 { 0x11, 0x40000100 },
2851 { 0x12, 0x40000100 },
2852 { 0x13, 0x40000100 },
2853 { 0x14, 0x40000100 },
2854 { 0x21, 0x40000100 },
2855 { 0x22, 0x40000100 },
2856 { 0x23, 0x40000100 },
2857 {}
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002858};
2859
Takashi Iwai29ac8362013-01-14 16:03:38 +01002860static const struct hda_pintbl d965_5st_pin_configs[] = {
2861 { 0x0a, 0x02214020 },
2862 { 0x0b, 0x02a19080 },
2863 { 0x0c, 0x0181304e },
2864 { 0x0d, 0x01014010 },
2865 { 0x0e, 0x01a19040 },
2866 { 0x0f, 0x01011012 },
2867 { 0x10, 0x01016011 },
2868 { 0x11, 0x40000100 },
2869 { 0x12, 0x40000100 },
2870 { 0x13, 0x40000100 },
2871 { 0x14, 0x40000100 },
2872 { 0x21, 0x01442070 },
2873 { 0x22, 0x40000100 },
2874 { 0x23, 0x40000100 },
2875 {}
Tobin Davis93ed1502006-09-01 21:03:12 +02002876};
2877
Takashi Iwai29ac8362013-01-14 16:03:38 +01002878static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
2879 { 0x0a, 0x40000100 },
2880 { 0x0b, 0x40000100 },
2881 { 0x0c, 0x0181304e },
2882 { 0x0d, 0x01014010 },
2883 { 0x0e, 0x01a19040 },
2884 { 0x0f, 0x01011012 },
2885 { 0x10, 0x01016011 },
2886 { 0x11, 0x40000100 },
2887 { 0x12, 0x40000100 },
2888 { 0x13, 0x40000100 },
2889 { 0x14, 0x40000100 },
2890 { 0x21, 0x01442070 },
2891 { 0x22, 0x40000100 },
2892 { 0x23, 0x40000100 },
2893 {}
Takashi Iwai679d92e2009-05-24 19:00:08 +02002894};
2895
Takashi Iwai29ac8362013-01-14 16:03:38 +01002896static const struct hda_pintbl dell_3st_pin_configs[] = {
2897 { 0x0a, 0x02211230 },
2898 { 0x0b, 0x02a11220 },
2899 { 0x0c, 0x01a19040 },
2900 { 0x0d, 0x01114210 },
2901 { 0x0e, 0x01111212 },
2902 { 0x0f, 0x01116211 },
2903 { 0x10, 0x01813050 },
2904 { 0x11, 0x01112214 },
2905 { 0x12, 0x403003fa },
2906 { 0x13, 0x90a60040 },
2907 { 0x14, 0x90a60040 },
2908 { 0x21, 0x404003fb },
2909 { 0x22, 0x40c003fc },
2910 { 0x23, 0x40000100 },
2911 {}
Tobin Davis4ff076e2007-08-07 11:48:12 +02002912};
2913
Takashi Iwai29ac8362013-01-14 16:03:38 +01002914static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
2915 const struct hda_fixup *fix, int action)
2916{
2917 struct sigmatel_spec *spec = codec->spec;
2918
2919 /* no jack detecion for ref-no-jd model */
2920 if (action == HDA_FIXUP_ACT_PROBE)
2921 spec->hp_detect = 0;
2922}
2923
2924static void stac927x_fixup_ref(struct hda_codec *codec,
2925 const struct hda_fixup *fix, int action)
2926{
2927 struct sigmatel_spec *spec = codec->spec;
2928
2929 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2930 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
2931 spec->eapd_mask = spec->gpio_mask = 0;
2932 spec->gpio_dir = spec->gpio_data = 0;
2933 }
2934}
2935
2936static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
2937 const struct hda_fixup *fix, int action)
2938{
2939 struct sigmatel_spec *spec = codec->spec;
2940
2941 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2942 return;
2943
2944 if (codec->subsystem_id != 0x1028022f) {
2945 /* GPIO2 High = Enable EAPD */
2946 spec->eapd_mask = spec->gpio_mask = 0x04;
2947 spec->gpio_dir = spec->gpio_data = 0x04;
2948 }
2949 spec->dmic_nids = stac927x_dmic_nids;
2950 spec->num_dmics = STAC927X_NUM_DMICS;
2951
2952 snd_hda_add_verbs(codec, dell_3st_core_init);
2953 spec->volknob_init = 1;
2954 spec->dmux_nids = stac927x_dmux_nids;
2955 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
2956}
2957
2958static void stac927x_fixup_volknob(struct hda_codec *codec,
2959 const struct hda_fixup *fix, int action)
2960{
2961 struct sigmatel_spec *spec = codec->spec;
2962
2963 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2964 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
2965 spec->volknob_init = 1;
2966 }
2967}
2968
2969static const struct hda_fixup stac927x_fixups[] = {
2970 [STAC_D965_REF_NO_JD] = {
2971 .type = HDA_FIXUP_FUNC,
2972 .v.func = stac927x_fixup_ref_no_jd,
2973 .chained = true,
2974 .chain_id = STAC_D965_REF,
2975 },
2976 [STAC_D965_REF] = {
2977 .type = HDA_FIXUP_FUNC,
2978 .v.func = stac927x_fixup_ref,
2979 },
2980 [STAC_D965_3ST] = {
2981 .type = HDA_FIXUP_PINS,
2982 .v.pins = d965_3st_pin_configs,
2983 .chained = true,
2984 .chain_id = STAC_D965_VERBS,
2985 },
2986 [STAC_D965_5ST] = {
2987 .type = HDA_FIXUP_PINS,
2988 .v.pins = d965_5st_pin_configs,
2989 .chained = true,
2990 .chain_id = STAC_D965_VERBS,
2991 },
2992 [STAC_D965_VERBS] = {
2993 .type = HDA_FIXUP_VERBS,
2994 .v.verbs = d965_core_init,
2995 },
2996 [STAC_D965_5ST_NO_FP] = {
2997 .type = HDA_FIXUP_PINS,
2998 .v.pins = d965_5st_no_fp_pin_configs,
2999 },
3000 [STAC_DELL_3ST] = {
3001 .type = HDA_FIXUP_PINS,
3002 .v.pins = dell_3st_pin_configs,
3003 .chained = true,
3004 .chain_id = STAC_927X_DELL_DMIC,
3005 },
3006 [STAC_DELL_BIOS] = {
3007 .type = HDA_FIXUP_PINS,
3008 .v.pins = (const struct hda_pintbl[]) {
3009 /* configure the analog microphone on some laptops */
3010 { 0x0c, 0x90a79130 },
3011 /* correct the front output jack as a hp out */
3012 { 0x0f, 0x0227011f },
3013 /* correct the front input jack as a mic */
3014 { 0x0e, 0x02a79130 },
3015 {}
3016 },
3017 .chained = true,
3018 .chain_id = STAC_927X_DELL_DMIC,
3019 },
3020 [STAC_DELL_BIOS_SPDIF] = {
3021 .type = HDA_FIXUP_PINS,
3022 .v.pins = (const struct hda_pintbl[]) {
3023 /* correct the device field to SPDIF out */
3024 { 0x21, 0x01442070 },
3025 {}
3026 },
3027 .chained = true,
3028 .chain_id = STAC_DELL_BIOS,
3029 },
3030 [STAC_927X_DELL_DMIC] = {
3031 .type = HDA_FIXUP_FUNC,
3032 .v.func = stac927x_fixup_dell_dmic,
3033 },
3034 [STAC_927X_VOLKNOB] = {
3035 .type = HDA_FIXUP_FUNC,
3036 .v.func = stac927x_fixup_volknob,
3037 },
Matt Porter3cc08dc2006-01-23 15:27:49 +01003038};
3039
Takashi Iwai29ac8362013-01-14 16:03:38 +01003040static const struct hda_model_fixup stac927x_models[] = {
3041 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3042 { .id = STAC_D965_REF, .name = "ref" },
3043 { .id = STAC_D965_3ST, .name = "3stack" },
3044 { .id = STAC_D965_5ST, .name = "5stack" },
3045 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3046 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3047 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3048 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3049 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003050};
3051
Takashi Iwai29ac8362013-01-14 16:03:38 +01003052static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003053 /* SigmaTel reference board */
3054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3055 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003056 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3057 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02003058 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02003061 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003062 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3063 "Intel D965", STAC_D965_3ST),
3064 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3065 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003066 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02003068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
3069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003070 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04003072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01003073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
Chengu Wang84d3dc22009-07-30 19:43:55 +08003075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
3077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
3078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01003079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
Tobin Davis93ed1502006-09-01 21:03:12 +02003080 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01003081 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3082 "Intel D965", STAC_D965_5ST),
3083 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3084 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02003085 /* volume-knob fixes */
3086 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01003087 {} /* terminator */
3088};
3089
Takashi Iwaife6322c2013-01-14 14:46:51 +01003090static const struct hda_pintbl ref9205_pin_configs[] = {
3091 { 0x0a, 0x40000100 },
3092 { 0x0b, 0x40000100 },
3093 { 0x0c, 0x01016011 },
3094 { 0x0d, 0x01014010 },
3095 { 0x0e, 0x01813122 },
3096 { 0x0f, 0x01a19021 },
3097 { 0x14, 0x01019020 },
3098 { 0x16, 0x40000100 },
3099 { 0x17, 0x90a000f0 },
3100 { 0x18, 0x90a000f0 },
3101 { 0x21, 0x01441030 },
3102 { 0x22, 0x01c41030 },
3103 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003104};
3105
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003106/*
3107 STAC 9205 pin configs for
3108 102801F1
3109 102801F2
3110 102801FC
3111 102801FD
3112 10280204
3113 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003114 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01003115 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003116*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003117static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3118 { 0x0a, 0x0321101F },
3119 { 0x0b, 0x03A11020 },
3120 { 0x0c, 0x400003FA },
3121 { 0x0d, 0x90170310 },
3122 { 0x0e, 0x400003FB },
3123 { 0x0f, 0x400003FC },
3124 { 0x14, 0x400003FD },
3125 { 0x16, 0x40F000F9 },
3126 { 0x17, 0x90A60330 },
3127 { 0x18, 0x400003FF },
3128 { 0x21, 0x0144131F },
3129 { 0x22, 0x40C003FE },
3130 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003131};
3132
3133/*
3134 STAC 9205 pin configs for
3135 102801F9
3136 102801FA
3137 102801FE
3138 102801FF (Dell Precision M4300)
3139 10280206
3140 10280200
3141 10280201
3142*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01003143static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3144 { 0x0a, 0x0321101f },
3145 { 0x0b, 0x03a11020 },
3146 { 0x0c, 0x90a70330 },
3147 { 0x0d, 0x90170310 },
3148 { 0x0e, 0x400000fe },
3149 { 0x0f, 0x400000ff },
3150 { 0x14, 0x400000fd },
3151 { 0x16, 0x40f000f9 },
3152 { 0x17, 0x400000fa },
3153 { 0x18, 0x400000fc },
3154 { 0x21, 0x0144131f },
3155 { 0x22, 0x40c003f8 },
3156 /* Enable SPDIF in/out */
3157 { 0x1f, 0x01441030 },
3158 { 0x20, 0x1c410030 },
3159 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003160};
3161
Takashi Iwaife6322c2013-01-14 14:46:51 +01003162static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3163 { 0x0a, 0x0421101f },
3164 { 0x0b, 0x04a11020 },
3165 { 0x0c, 0x400003fa },
3166 { 0x0d, 0x90170310 },
3167 { 0x0e, 0x400003fb },
3168 { 0x0f, 0x400003fc },
3169 { 0x14, 0x400003fd },
3170 { 0x16, 0x400003f9 },
3171 { 0x17, 0x90a60330 },
3172 { 0x18, 0x400003ff },
3173 { 0x21, 0x01441340 },
3174 { 0x22, 0x40c003fe },
3175 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003176};
3177
Takashi Iwaife6322c2013-01-14 14:46:51 +01003178static void stac9205_fixup_ref(struct hda_codec *codec,
3179 const struct hda_fixup *fix, int action)
3180{
3181 struct sigmatel_spec *spec = codec->spec;
3182
3183 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3184 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3185 /* SPDIF-In enabled */
3186 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3187 }
3188}
3189
Takashi Iwaife6322c2013-01-14 14:46:51 +01003190static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3191 const struct hda_fixup *fix, int action)
3192{
3193 struct sigmatel_spec *spec = codec->spec;
3194 int err;
3195
3196 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3197 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3198
3199 /* Enable unsol response for GPIO4/Dock HP connection */
3200 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
3201 if (err < 0)
3202 return;
3203 snd_hda_codec_write_cache(codec, codec->afg, 0,
3204 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3205 snd_hda_jack_detect_enable(codec, codec->afg, 0);
3206
3207 spec->gpio_dir = 0x0b;
3208 spec->eapd_mask = 0x01;
3209 spec->gpio_mask = 0x1b;
3210 spec->gpio_mute = 0x10;
3211 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3212 * GPIO3 Low = DRM
3213 */
3214 spec->gpio_data = 0x01;
3215 }
3216}
3217
3218static void stac9205_fixup_eapd(struct hda_codec *codec,
3219 const struct hda_fixup *fix, int action)
3220{
3221 struct sigmatel_spec *spec = codec->spec;
3222
3223 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3224 spec->eapd_switch = 0;
3225}
3226
3227static const struct hda_fixup stac9205_fixups[] = {
3228 [STAC_9205_REF] = {
3229 .type = HDA_FIXUP_FUNC,
3230 .v.func = stac9205_fixup_ref,
3231 },
3232 [STAC_9205_DELL_M42] = {
3233 .type = HDA_FIXUP_PINS,
3234 .v.pins = dell_9205_m42_pin_configs,
3235 },
3236 [STAC_9205_DELL_M43] = {
3237 .type = HDA_FIXUP_FUNC,
3238 .v.func = stac9205_fixup_dell_m43,
3239 },
3240 [STAC_9205_DELL_M44] = {
3241 .type = HDA_FIXUP_PINS,
3242 .v.pins = dell_9205_m44_pin_configs,
3243 },
3244 [STAC_9205_EAPD] = {
3245 .type = HDA_FIXUP_FUNC,
3246 .v.func = stac9205_fixup_eapd,
3247 },
3248 {}
Matt Porterf3302a52006-07-31 12:49:34 +02003249};
3250
Takashi Iwaife6322c2013-01-14 14:46:51 +01003251static const struct hda_model_fixup stac9205_models[] = {
3252 { .id = STAC_9205_REF, .name = "ref" },
3253 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3254 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3255 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3256 { .id = STAC_9205_EAPD, .name = "eapd" },
3257 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003258};
3259
Takashi Iwaife6322c2013-01-14 14:46:51 +01003260static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003261 /* SigmaTel reference board */
3262 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3263 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03003264 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3265 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003266 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3267 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003268 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3270 "unknown Dell", STAC_9205_DELL_M42),
3271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3272 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02003274 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3276 "Dell Precision", STAC_9205_DELL_M43),
3277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3278 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3280 "unknown Dell", STAC_9205_DELL_M42),
3281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3282 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3284 "Dell Precision", STAC_9205_DELL_M43),
3285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003286 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3288 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02003289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3290 "Dell Precision", STAC_9205_DELL_M43),
3291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3292 "Dell Precision", STAC_9205_DELL_M43),
3293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3294 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3296 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3298 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01003299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3300 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003301 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08003302 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003303 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02003304 {} /* terminator */
3305};
3306
Takashi Iwai330ee992009-02-20 14:33:36 +01003307static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003308 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02003309{
3310 int i;
3311 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02003312
Takashi Iwai330ee992009-02-20 14:33:36 +01003313 if (!pincfgs)
3314 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02003315
Matthew Ranostay87d48362007-07-17 11:52:24 +02003316 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01003317 if (spec->pin_nids[i] && pincfgs[i])
3318 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
3319 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01003320}
3321
Matt2f2f4252005-04-13 14:45:30 +02003322/*
3323 * Analog playback callbacks
3324 */
3325static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
3326 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003327 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003328{
3329 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003330 if (spec->stream_delay)
3331 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01003332 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3333 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02003334}
3335
3336static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3337 struct hda_codec *codec,
3338 unsigned int stream_tag,
3339 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003340 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003341{
3342 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01003343 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02003344}
3345
3346static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3347 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003348 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003349{
3350 struct sigmatel_spec *spec = codec->spec;
3351 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3352}
3353
3354/*
Mattdabbed62005-06-14 10:19:34 +02003355 * Digital playback callbacks
3356 */
3357static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3358 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003359 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003360{
3361 struct sigmatel_spec *spec = codec->spec;
3362 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3363}
3364
3365static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3366 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003367 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003368{
3369 struct sigmatel_spec *spec = codec->spec;
3370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3371}
3372
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003373static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3374 struct hda_codec *codec,
3375 unsigned int stream_tag,
3376 unsigned int format,
3377 struct snd_pcm_substream *substream)
3378{
3379 struct sigmatel_spec *spec = codec->spec;
3380 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3381 stream_tag, format, substream);
3382}
3383
Takashi Iwai9411e212009-02-13 11:32:28 +01003384static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3385 struct hda_codec *codec,
3386 struct snd_pcm_substream *substream)
3387{
3388 struct sigmatel_spec *spec = codec->spec;
3389 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3390}
3391
Mattdabbed62005-06-14 10:19:34 +02003392
3393/*
Matt2f2f4252005-04-13 14:45:30 +02003394 * Analog capture callbacks
3395 */
3396static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3397 struct hda_codec *codec,
3398 unsigned int stream_tag,
3399 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003400 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003401{
3402 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003403 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003404
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003405 if (spec->powerdown_adcs) {
3406 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003407 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003408 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
3409 }
3410 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02003411 return 0;
3412}
3413
3414static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3415 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003416 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003417{
3418 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003419 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003420
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003421 snd_hda_codec_cleanup_stream(codec, nid);
3422 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003423 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003424 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02003425 return 0;
3426}
3427
Takashi Iwai2b635362011-05-02 12:33:43 +02003428static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02003429 .substreams = 1,
3430 .channels_min = 2,
3431 .channels_max = 2,
3432 /* NID is set in stac92xx_build_pcms */
3433 .ops = {
3434 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003435 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01003436 .prepare = stac92xx_dig_playback_pcm_prepare,
3437 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02003438 },
3439};
3440
Takashi Iwai2b635362011-05-02 12:33:43 +02003441static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02003442 .substreams = 1,
3443 .channels_min = 2,
3444 .channels_max = 2,
3445 /* NID is set in stac92xx_build_pcms */
3446};
3447
Takashi Iwai2b635362011-05-02 12:33:43 +02003448static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02003449 .substreams = 1,
3450 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02003451 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02003452 .nid = 0x02, /* NID to query formats and rates */
3453 .ops = {
3454 .open = stac92xx_playback_pcm_open,
3455 .prepare = stac92xx_playback_pcm_prepare,
3456 .cleanup = stac92xx_playback_pcm_cleanup
3457 },
3458};
3459
Takashi Iwai2b635362011-05-02 12:33:43 +02003460static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003461 .substreams = 1,
3462 .channels_min = 2,
3463 .channels_max = 2,
3464 .nid = 0x06, /* NID to query formats and rates */
3465 .ops = {
3466 .open = stac92xx_playback_pcm_open,
3467 .prepare = stac92xx_playback_pcm_prepare,
3468 .cleanup = stac92xx_playback_pcm_cleanup
3469 },
3470};
3471
Takashi Iwai2b635362011-05-02 12:33:43 +02003472static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02003473 .channels_min = 2,
3474 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003475 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02003476 .ops = {
3477 .prepare = stac92xx_capture_pcm_prepare,
3478 .cleanup = stac92xx_capture_pcm_cleanup
3479 },
3480};
3481
3482static int stac92xx_build_pcms(struct hda_codec *codec)
3483{
3484 struct sigmatel_spec *spec = codec->spec;
3485 struct hda_pcm *info = spec->pcm_rec;
3486
3487 codec->num_pcms = 1;
3488 codec->pcm_info = info;
3489
Mattc7d4b2f2005-06-27 14:59:41 +02003490 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02003491 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01003492 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3493 spec->multiout.dac_nids[0];
Takashi Iwaiee81abb2012-11-08 17:12:10 +01003494 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3495 spec->autocfg.line_outs == 2)
3496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
3497 snd_pcm_2_1_chmaps;
3498
Matt2f2f4252005-04-13 14:45:30 +02003499 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003500 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003501 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003502
3503 if (spec->alt_switch) {
3504 codec->num_pcms++;
3505 info++;
3506 info->name = "STAC92xx Analog Alt";
3507 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
3508 }
Matt2f2f4252005-04-13 14:45:30 +02003509
Mattdabbed62005-06-14 10:19:34 +02003510 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3511 codec->num_pcms++;
3512 info++;
3513 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003514 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02003515 if (spec->multiout.dig_out_nid) {
3516 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
3517 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3518 }
3519 if (spec->dig_in_nid) {
3520 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
3521 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3522 }
3523 }
3524
Matt2f2f4252005-04-13 14:45:30 +02003525 return 0;
3526}
3527
Matt Porter403d1942005-11-29 15:00:51 +01003528static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
3529
3530{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02003531 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01003532}
3533
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003534#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
3535
3536static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
3537 struct snd_ctl_elem_value *ucontrol)
3538{
3539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3540 struct sigmatel_spec *spec = codec->spec;
3541
Takashi Iwaid7a89432008-11-12 09:48:04 +01003542 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003543 return 0;
3544}
3545
Takashi Iwai62558ce2009-07-29 14:23:09 +02003546static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003547
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003548static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
3549 struct snd_ctl_elem_value *ucontrol)
3550{
3551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3552 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003553 int nid = kcontrol->private_value;
3554
3555 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003556
Lucas De Marchi25985ed2011-03-30 22:57:33 -03003557 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003558 * switch changes
3559 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02003560 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003561
3562 return 1;
3563}
3564
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003565static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
3566 struct snd_ctl_elem_info *uinfo)
3567{
3568 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02003569 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003570 "Mic In", "Line In", "Line Out"
3571 };
3572
3573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3574 struct sigmatel_spec *spec = codec->spec;
3575 hda_nid_t nid = kcontrol->private_value;
3576
3577 if (nid == spec->mic_switch || nid == spec->line_switch)
3578 i = 3;
3579 else
3580 i = 2;
3581
3582 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3583 uinfo->value.enumerated.items = i;
3584 uinfo->count = 1;
3585 if (uinfo->value.enumerated.item >= i)
3586 uinfo->value.enumerated.item = i-1;
3587 strcpy(uinfo->value.enumerated.name,
3588 texts[uinfo->value.enumerated.item]);
3589
3590 return 0;
3591}
3592
3593static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
3594 struct snd_ctl_elem_value *ucontrol)
3595{
3596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3597 hda_nid_t nid = kcontrol->private_value;
3598 unsigned int vref = stac92xx_vref_get(codec, nid);
3599
Takashi Iwai47408602012-04-20 13:06:53 +02003600 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003601 ucontrol->value.enumerated.item[0] = 0;
3602 else if (vref == AC_PINCTL_VREF_GRD)
3603 ucontrol->value.enumerated.item[0] = 1;
3604 else if (vref == AC_PINCTL_VREF_HIZ)
3605 ucontrol->value.enumerated.item[0] = 2;
3606
3607 return 0;
3608}
3609
3610static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
3611 struct snd_ctl_elem_value *ucontrol)
3612{
3613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3614 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02003615 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003616 hda_nid_t nid = kcontrol->private_value;
3617
3618 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02003619 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003620 else if (ucontrol->value.enumerated.item[0] == 1)
3621 new_vref = AC_PINCTL_VREF_GRD;
3622 else if (ucontrol->value.enumerated.item[0] == 2)
3623 new_vref = AC_PINCTL_VREF_HIZ;
3624 else
3625 return 0;
3626
3627 if (new_vref != stac92xx_vref_get(codec, nid)) {
3628 error = stac92xx_vref_set(codec, nid, new_vref);
3629 return error;
3630 }
3631
3632 return 0;
3633}
3634
3635static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
3636 struct snd_ctl_elem_info *uinfo)
3637{
Takashi Iwai2b635362011-05-02 12:33:43 +02003638 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3640 struct sigmatel_spec *spec = codec->spec;
3641
3642 if (kcontrol->private_value == spec->line_switch)
3643 texts[0] = "Line In";
3644 else
3645 texts[0] = "Mic In";
3646 texts[1] = "Line Out";
3647 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3648 uinfo->value.enumerated.items = 2;
3649 uinfo->count = 1;
3650
3651 if (uinfo->value.enumerated.item >= 2)
3652 uinfo->value.enumerated.item = 1;
3653 strcpy(uinfo->value.enumerated.name,
3654 texts[uinfo->value.enumerated.item]);
3655
3656 return 0;
3657}
Matt Porter403d1942005-11-29 15:00:51 +01003658
3659static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3660{
3661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3662 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003663 hda_nid_t nid = kcontrol->private_value;
3664 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01003665
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003666 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01003667 return 0;
3668}
3669
3670static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3671{
3672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3673 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003674 hda_nid_t nid = kcontrol->private_value;
3675 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3676 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01003677
3678 spec->io_switch[io_idx] = val;
3679
3680 if (val)
3681 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01003682 else {
3683 unsigned int pinctl = AC_PINCTL_IN_EN;
3684 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02003685 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003686 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3687 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01003688
3689 /* check the auto-mute again: we need to mute/unmute the speaker
3690 * appropriately according to the pin direction
3691 */
3692 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02003693 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01003694
Matt Porter403d1942005-11-29 15:00:51 +01003695 return 1;
3696}
3697
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003698#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
3699
3700static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
3701 struct snd_ctl_elem_value *ucontrol)
3702{
3703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3704 struct sigmatel_spec *spec = codec->spec;
3705
3706 ucontrol->value.integer.value[0] = spec->clfe_swap;
3707 return 0;
3708}
3709
3710static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
3711 struct snd_ctl_elem_value *ucontrol)
3712{
3713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3714 struct sigmatel_spec *spec = codec->spec;
3715 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003716 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003717
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003718 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003719 return 0;
3720
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003721 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003722
3723 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
3724 spec->clfe_swap ? 0x4 : 0x0);
3725
3726 return 1;
3727}
3728
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003729#define STAC_CODEC_HP_SWITCH(xname) \
3730 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3731 .name = xname, \
3732 .index = 0, \
3733 .info = stac92xx_hp_switch_info, \
3734 .get = stac92xx_hp_switch_get, \
3735 .put = stac92xx_hp_switch_put, \
3736 }
3737
Matt Porter403d1942005-11-29 15:00:51 +01003738#define STAC_CODEC_IO_SWITCH(xname, xpval) \
3739 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3740 .name = xname, \
3741 .index = 0, \
3742 .info = stac92xx_io_switch_info, \
3743 .get = stac92xx_io_switch_get, \
3744 .put = stac92xx_io_switch_put, \
3745 .private_value = xpval, \
3746 }
3747
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003748#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
3749 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3750 .name = xname, \
3751 .index = 0, \
3752 .info = stac92xx_clfe_switch_info, \
3753 .get = stac92xx_clfe_switch_get, \
3754 .put = stac92xx_clfe_switch_put, \
3755 .private_value = xpval, \
3756 }
Matt Porter403d1942005-11-29 15:00:51 +01003757
Mattc7d4b2f2005-06-27 14:59:41 +02003758enum {
3759 STAC_CTL_WIDGET_VOL,
3760 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003761 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01003762 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003763 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01003764 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003765 STAC_CTL_WIDGET_CLFE_SWITCH,
3766 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02003767};
3768
Takashi Iwai2b635362011-05-02 12:33:43 +02003769static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02003770 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3771 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003772 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01003773 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003774 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01003775 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003776 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003777 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02003778};
3779
3780/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01003781static struct snd_kcontrol_new *
3782stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003783 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01003784 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003785 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02003786{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003787 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02003788
Takashi Iwai603c4012008-07-30 15:01:44 +02003789 knew = snd_array_new(&spec->kctls);
3790 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01003791 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003792 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02003793 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01003794 if (!knew->name) {
3795 /* roolback */
3796 memset(knew, 0, sizeof(*knew));
3797 spec->kctls.alloced--;
3798 return NULL;
3799 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003800 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01003801 return knew;
3802}
3803
Takashi Iwai62cbde12012-09-14 11:58:54 +02003804static struct snd_kcontrol_new *
3805add_control_temp(struct sigmatel_spec *spec,
3806 const struct snd_kcontrol_new *ktemp,
3807 int idx, const char *name,
3808 unsigned long val)
3809{
3810 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
3811 HDA_SUBDEV_AMP_FLAG);
3812 if (!knew)
3813 return NULL;
3814 knew->index = idx;
3815 knew->private_value = val;
3816 return knew;
3817}
3818
Takashi Iwaie3c75962009-01-23 11:57:22 +01003819static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003820 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01003821 int idx, const char *name,
3822 unsigned long val)
3823{
Takashi Iwai62cbde12012-09-14 11:58:54 +02003824 return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM;
Mattc7d4b2f2005-06-27 14:59:41 +02003825}
3826
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003827static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
3828 int type, int idx, const char *name,
3829 unsigned long val)
3830{
3831 return stac92xx_add_control_temp(spec,
3832 &stac92xx_control_templates[type],
3833 idx, name, val);
3834}
3835
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003836
3837/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003838static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
3839 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003840{
3841 return stac92xx_add_control_idx(spec, type, 0, name, val);
3842}
3843
Takashi Iwai2b635362011-05-02 12:33:43 +02003844static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01003845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3846 .name = "Input Source",
3847 .info = stac92xx_mux_enum_info,
3848 .get = stac92xx_mux_enum_get,
3849 .put = stac92xx_mux_enum_put,
3850};
3851
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003852static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
3853 hda_nid_t nid, int idx)
3854{
3855 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3856 int control = 0;
3857 struct sigmatel_spec *spec = codec->spec;
3858 char name[22];
3859
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003860 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
David Henningsson8d032a82012-10-09 12:48:40 +02003861 if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf)
3862 != INPUT_PIN_ATTR_DOCK)
3863 return 0;
Takashi Iwai47408602012-04-20 13:06:53 +02003864 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003865 && nid == spec->line_switch)
3866 control = STAC_CTL_WIDGET_IO_SWITCH;
3867 else if (snd_hda_query_pin_caps(codec, nid)
3868 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
3869 control = STAC_CTL_WIDGET_DC_BIAS;
3870 else if (nid == spec->mic_switch)
3871 control = STAC_CTL_WIDGET_IO_SWITCH;
3872 }
3873
3874 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01003875 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3876 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003877 return stac92xx_add_control(codec->spec, control,
3878 strcat(name, " Jack Mode"), nid);
3879 }
3880
3881 return 0;
3882}
3883
Takashi Iwaie3c75962009-01-23 11:57:22 +01003884static int stac92xx_add_input_source(struct sigmatel_spec *spec)
3885{
3886 struct snd_kcontrol_new *knew;
3887 struct hda_input_mux *imux = &spec->private_imux;
3888
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003889 if (spec->auto_mic)
3890 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01003891 if (!spec->num_adcs || imux->num_items <= 1)
3892 return 0; /* no need for input source control */
3893 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01003894 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01003895 if (!knew)
3896 return -ENOMEM;
3897 knew->count = spec->num_adcs;
3898 return 0;
3899}
3900
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003901/* check whether the line-input can be used as line-out */
3902static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01003903{
3904 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003905 struct auto_pin_cfg *cfg = &spec->autocfg;
3906 hda_nid_t nid;
3907 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003908 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003909
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003910 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3911 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003912 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003913 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003914 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01003915 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003916 if (pincap & AC_PINCAP_OUT)
3917 return nid;
3918 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003919 }
Matt Porter403d1942005-11-29 15:00:51 +01003920 return 0;
3921}
3922
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003923static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
3924
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003925/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003926static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003927{
3928 struct sigmatel_spec *spec = codec->spec;
3929 struct auto_pin_cfg *cfg = &spec->autocfg;
3930 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02003931 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003932
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003933 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003934 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3935 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003936 for (i = 0; i < cfg->num_inputs; i++) {
3937 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02003938 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003939 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003940 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3941 /* some laptops have an internal analog microphone
3942 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003943 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003944 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003945 if (pincap & AC_PINCAP_OUT) {
3946 *dac = get_unassigned_dac(codec, nid);
3947 if (*dac)
3948 return nid;
3949 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003950 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003951 }
3952 return 0;
3953}
Steve Longerbeam7b043892007-05-03 20:50:03 +02003954
3955static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3956{
3957 int i;
3958
3959 for (i = 0; i < spec->multiout.num_dacs; i++) {
3960 if (spec->multiout.dac_nids[i] == nid)
3961 return 1;
3962 }
3963
3964 return 0;
3965}
3966
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003967static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3968{
3969 int i;
3970 if (is_in_dac_nids(spec, nid))
3971 return 1;
3972 for (i = 0; i < spec->autocfg.hp_outs; i++)
3973 if (spec->hp_dacs[i] == nid)
3974 return 1;
3975 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3976 if (spec->speaker_dacs[i] == nid)
3977 return 1;
3978 return 0;
3979}
3980
3981static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3982{
3983 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02003984 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003985 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02003986 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003987 unsigned int wcaps, wtype;
3988
3989 conn_len = snd_hda_get_connections(codec, nid, conn,
3990 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01003991 /* 92HD88: trace back up the link of nids to find the DAC */
3992 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
3993 != AC_WID_AUD_OUT)) {
3994 nid = conn[0];
3995 conn_len = snd_hda_get_connections(codec, nid, conn,
3996 HDA_MAX_CONNECTIONS);
3997 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003998 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01003999 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004000 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004001 /* we check only analog outputs */
4002 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
4003 continue;
4004 /* if this route has a free DAC, assign it */
4005 if (!check_all_dac_nids(spec, conn[j])) {
4006 if (conn_len > 1) {
4007 /* select this DAC in the pin's input mux */
4008 snd_hda_codec_write_cache(codec, nid, 0,
4009 AC_VERB_SET_CONNECT_SEL, j);
4010 }
4011 return conn[j];
4012 }
4013 }
David Henningsson48718ea2011-10-05 09:49:05 +02004014
4015 /* if all DACs are already assigned, connect to the primary DAC,
4016 unless we're assigning a secondary headphone */
4017 fallback_dac = spec->multiout.dac_nids[0];
4018 if (spec->multiout.hp_nid) {
4019 for (j = 0; j < cfg->hp_outs; j++)
4020 if (cfg->hp_pins[j] == nid) {
4021 fallback_dac = spec->multiout.hp_nid;
4022 break;
4023 }
4024 }
4025
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004026 if (conn_len > 1) {
4027 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02004028 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01004029 snd_hda_codec_write_cache(codec, nid, 0,
4030 AC_VERB_SET_CONNECT_SEL, j);
4031 break;
4032 }
4033 }
4034 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004035 return 0;
4036}
4037
4038static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4039static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4040
Matt Porter3cc08dc2006-01-23 15:27:49 +01004041/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02004042 * Fill in the dac_nids table from the parsed pin configuration
4043 * This function only works when every pin in line_out_pins[]
4044 * contains atleast one DAC in its connection list. Some 92xx
4045 * codecs are not connected directly to a DAC, such as the 9200
4046 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01004047 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004048static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02004049{
4050 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004051 struct auto_pin_cfg *cfg = &spec->autocfg;
4052 int i;
4053 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004054
Mattc7d4b2f2005-06-27 14:59:41 +02004055 for (i = 0; i < cfg->line_outs; i++) {
4056 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004057 dac = get_unassigned_dac(codec, nid);
4058 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02004059 if (spec->multiout.num_dacs > 0) {
4060 /* we have already working output pins,
4061 * so let's drop the broken ones again
4062 */
4063 cfg->line_outs = spec->multiout.num_dacs;
4064 break;
4065 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004066 /* error out, no available DAC found */
4067 snd_printk(KERN_ERR
4068 "%s: No available DAC for pin 0x%x\n",
4069 __func__, nid);
4070 return -ENODEV;
4071 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004072 add_spec_dacs(spec, dac);
4073 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02004074
Takashi Iwai139e0712009-03-06 12:10:41 +01004075 for (i = 0; i < cfg->hp_outs; i++) {
4076 nid = cfg->hp_pins[i];
4077 dac = get_unassigned_dac(codec, nid);
4078 if (dac) {
4079 if (!spec->multiout.hp_nid)
4080 spec->multiout.hp_nid = dac;
4081 else
4082 add_spec_extra_dacs(spec, dac);
4083 }
4084 spec->hp_dacs[i] = dac;
4085 }
4086
4087 for (i = 0; i < cfg->speaker_outs; i++) {
4088 nid = cfg->speaker_pins[i];
4089 dac = get_unassigned_dac(codec, nid);
4090 if (dac)
4091 add_spec_extra_dacs(spec, dac);
4092 spec->speaker_dacs[i] = dac;
4093 }
4094
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004095 /* add line-in as output */
4096 nid = check_line_out_switch(codec);
4097 if (nid) {
4098 dac = get_unassigned_dac(codec, nid);
4099 if (dac) {
4100 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
4101 nid, cfg->line_outs);
4102 cfg->line_out_pins[cfg->line_outs] = nid;
4103 cfg->line_outs++;
4104 spec->line_switch = nid;
4105 add_spec_dacs(spec, dac);
4106 }
4107 }
4108 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004109 nid = check_mic_out_switch(codec, &dac);
4110 if (nid && dac) {
4111 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
4112 nid, cfg->line_outs);
4113 cfg->line_out_pins[cfg->line_outs] = nid;
4114 cfg->line_outs++;
4115 spec->mic_switch = nid;
4116 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02004117 }
4118
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004119 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02004120 spec->multiout.num_dacs,
4121 spec->multiout.dac_nids[0],
4122 spec->multiout.dac_nids[1],
4123 spec->multiout.dac_nids[2],
4124 spec->multiout.dac_nids[3],
4125 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004126
Mattc7d4b2f2005-06-27 14:59:41 +02004127 return 0;
4128}
4129
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004130/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01004131static int create_controls_idx(struct hda_codec *codec, const char *pfx,
4132 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004133{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004134 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004135 char name[32];
4136 int err;
4137
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004138 if (!spec->check_volume_offset) {
4139 unsigned int caps, step, nums, db_scale;
4140 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4141 step = (caps & AC_AMPCAP_STEP_SIZE) >>
4142 AC_AMPCAP_STEP_SIZE_SHIFT;
4143 step = (step + 1) * 25; /* in .01dB unit */
4144 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
4145 AC_AMPCAP_NUM_STEPS_SHIFT;
4146 db_scale = nums * step;
4147 /* if dB scale is over -64dB, and finer enough,
4148 * let's reduce it to half
4149 */
4150 if (db_scale > 6400 && nums >= 0x1f)
4151 spec->volume_offset = nums / 2;
4152 spec->check_volume_offset = 1;
4153 }
4154
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004155 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004156 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004157 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
4158 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004159 if (err < 0)
4160 return err;
4161 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01004162 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004163 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
4164 if (err < 0)
4165 return err;
4166 return 0;
4167}
4168
Takashi Iwai668b9652009-03-06 10:13:24 +01004169#define create_controls(codec, pfx, nid, chs) \
4170 create_controls_idx(codec, pfx, 0, nid, chs)
4171
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004172static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
4173{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004174 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004175 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
4176 return 1;
4177 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02004178 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
4179 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004180 spec->multiout.num_dacs++;
4181 }
4182 return 0;
4183}
4184
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004185static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004186{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004187 int i;
4188 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
4189 if (!spec->multiout.extra_out_nid[i]) {
4190 spec->multiout.extra_out_nid[i] = nid;
4191 return 0;
4192 }
4193 }
4194 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
4195 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01004196}
4197
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004198/* Create output controls
4199 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
4200 */
4201static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
4202 const hda_nid_t *pins,
4203 const hda_nid_t *dac_nids,
4204 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02004205{
Takashi Iwai76624532008-12-19 10:09:47 +01004206 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01004207 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02004208 "Front", "Surround", NULL /*CLFE*/, "Side"
4209 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004210 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01004211 int i, err;
4212 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004213
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004214 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004215 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004216 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02004217 spec->hp_detect = 1;
4218 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004219 nid = dac_nids[i];
4220 if (!nid)
4221 continue;
4222 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02004223 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004224 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004225 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004226 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004227 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004228 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004229 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004230
4231 wid_caps = get_wcaps(codec, nid);
4232
4233 if (wid_caps & AC_WCAP_LR_SWAP) {
4234 err = stac92xx_add_control(spec,
4235 STAC_CTL_WIDGET_CLFE_SWITCH,
4236 "Swap Center/LFE Playback Switch", nid);
4237
4238 if (err < 0)
4239 return err;
4240 }
4241
Mattc7d4b2f2005-06-27 14:59:41 +02004242 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004243 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01004244 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004245 switch (type) {
4246 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01004247 name = "Headphone";
4248 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004249 break;
4250 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01004251 if (num_outs <= 2) {
4252 name = i ? "Bass Speaker" : "Speaker";
4253 idx = 0;
David Henningsson298efee2012-09-06 11:17:58 +02004254 break;
4255 }
4256 /* Fall through in case of multi speaker outs */
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004257 default:
4258 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01004259 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004260 break;
Takashi Iwai76624532008-12-19 10:09:47 +01004261 }
Takashi Iwai668b9652009-03-06 10:13:24 +01004262 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004263 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004264 return err;
4265 }
4266 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004267 return 0;
4268}
4269
Takashi Iwai62cbde12012-09-14 11:58:54 +02004270static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4271 unsigned int dir_mask, unsigned int data);
4272
4273/* hook for controlling mic-mute LED GPIO */
4274static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol,
4275 struct snd_ctl_elem_value *ucontrol)
4276{
4277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4278 struct sigmatel_spec *spec = codec->spec;
4279 int err;
4280 bool mute;
4281
4282 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4283 if (err <= 0)
4284 return err;
4285 mute = !(ucontrol->value.integer.value[0] &&
4286 ucontrol->value.integer.value[1]);
4287 if (spec->mic_mute_led_on != mute) {
4288 spec->mic_mute_led_on = mute;
4289 if (mute)
4290 spec->gpio_data |= spec->mic_mute_led_gpio;
4291 else
4292 spec->gpio_data &= ~spec->mic_mute_led_gpio;
4293 stac_gpio_set(codec, spec->gpio_mask,
4294 spec->gpio_dir, spec->gpio_data);
4295 }
4296 return err;
4297}
4298
Takashi Iwai6479c632009-07-28 18:20:25 +02004299static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
4300 unsigned long sw, int idx)
4301{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004302 struct sigmatel_spec *spec = codec->spec;
4303 struct snd_kcontrol_new *knew;
Takashi Iwai6479c632009-07-28 18:20:25 +02004304 int err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004305
Takashi Iwai6479c632009-07-28 18:20:25 +02004306 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02004307 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02004308 if (err < 0)
4309 return err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004310
4311 knew = add_control_temp(spec,
4312 &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE],
4313 idx, "Capture Switch", sw);
4314 if (!knew)
4315 return -ENOMEM;
4316 /* add a LED hook for some HP laptops */
4317 if (spec->mic_mute_led_gpio)
4318 knew->put = stac92xx_capture_sw_put_led;
4319
Takashi Iwai6479c632009-07-28 18:20:25 +02004320 return 0;
4321}
4322
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004323/* add playback controls from the parsed DAC table */
4324static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
4325 const struct auto_pin_cfg *cfg)
4326{
4327 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004328 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004329 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004330 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004331
4332 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
4333 spec->multiout.dac_nids,
4334 cfg->line_out_type);
4335 if (err < 0)
4336 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004337
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01004338 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004339 err = stac92xx_add_control(spec,
4340 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01004341 "Headphone as Line Out Switch",
4342 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004343 if (err < 0)
4344 return err;
4345 }
4346
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004347 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004348 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004349 break;
4350 nid = cfg->inputs[idx].pin;
4351 err = stac92xx_add_jack_mode_control(codec, nid, idx);
4352 if (err < 0)
4353 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01004354 }
Matt Porter403d1942005-11-29 15:00:51 +01004355
Mattc7d4b2f2005-06-27 14:59:41 +02004356 return 0;
4357}
4358
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004359/* add playback controls for Speaker and HP outputs */
4360static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
4361 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02004362{
4363 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004364 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02004365
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004366 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
4367 spec->hp_dacs, AUTO_PIN_HP_OUT);
4368 if (err < 0)
4369 return err;
4370
4371 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
4372 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
4373 if (err < 0)
4374 return err;
4375
Mattc7d4b2f2005-06-27 14:59:41 +02004376 return 0;
4377}
4378
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004379/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004380static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004381 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004382};
4383
4384/* create mono mux for mono out on capable codecs */
4385static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
4386{
4387 struct sigmatel_spec *spec = codec->spec;
4388 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
4389 int i, num_cons;
4390 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
4391
4392 num_cons = snd_hda_get_connections(codec,
4393 spec->mono_nid,
4394 con_lst,
4395 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004396 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004397 return -EINVAL;
4398
Takashi Iwai10a20af2010-09-09 16:28:02 +02004399 for (i = 0; i < num_cons; i++)
4400 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
4401 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004402
4403 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
4404 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004405}
4406
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004407/* create PC beep volume controls */
4408static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
4409 hda_nid_t nid)
4410{
4411 struct sigmatel_spec *spec = codec->spec;
4412 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004413 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
4414
4415 if (spec->anabeep_nid == nid)
4416 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004417
4418 /* check for mute support for the the amp */
4419 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004420 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004421 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004422 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4423 if (err < 0)
4424 return err;
4425 }
4426
4427 /* check to see if there is volume support for the amp */
4428 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4429 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004430 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004431 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4432 if (err < 0)
4433 return err;
4434 }
4435 return 0;
4436}
4437
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004438#ifdef CONFIG_SND_HDA_INPUT_BEEP
4439#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
4440
4441static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
4442 struct snd_ctl_elem_value *ucontrol)
4443{
4444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4445 ucontrol->value.integer.value[0] = codec->beep->enabled;
4446 return 0;
4447}
4448
4449static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
4450 struct snd_ctl_elem_value *ucontrol)
4451{
4452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004453 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004454}
4455
Takashi Iwai2b635362011-05-02 12:33:43 +02004456static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4458 .info = stac92xx_dig_beep_switch_info,
4459 .get = stac92xx_dig_beep_switch_get,
4460 .put = stac92xx_dig_beep_switch_put,
4461};
4462
4463static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
4464{
4465 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004466 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004467}
4468#endif
4469
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004470static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
4471{
4472 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02004473 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004474
4475 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004476 hda_nid_t nid;
4477 unsigned int wcaps;
4478 unsigned long val;
4479
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004480 nid = spec->mux_nids[i];
4481 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02004482 if (!(wcaps & AC_WCAP_OUT_AMP))
4483 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004484
Takashi Iwai667067d2009-08-13 18:14:42 +02004485 /* check whether already the same control was created as
4486 * normal Capture Volume.
4487 */
4488 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4489 for (j = 0; j < spec->num_caps; j++) {
4490 if (spec->capvols[j] == val)
4491 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004492 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004493 if (j < spec->num_caps)
4494 continue;
4495
4496 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
4497 "Mux Capture Volume", val);
4498 if (err < 0)
4499 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004500 }
4501 return 0;
4502};
4503
Takashi Iwaiea734962011-01-17 11:29:34 +01004504static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04004505 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02004506};
4507
4508static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
4509{
4510 struct sigmatel_spec *spec = codec->spec;
4511 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01004512 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004513 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04004514 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02004515
4516 num_cons = snd_hda_get_connections(codec,
4517 spec->smux_nids[0],
4518 con_lst,
4519 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004520 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02004521 return -EINVAL;
4522
Matthew Ranostay65973632008-09-16 10:39:37 -04004523 if (!labels)
4524 labels = stac92xx_spdif_labels;
4525
Takashi Iwai10a20af2010-09-09 16:28:02 +02004526 for (i = 0; i < num_cons; i++)
4527 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004528
4529 return 0;
4530}
4531
Matt Porter8b657272006-10-26 17:12:59 +02004532/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004533static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02004534 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
4535 "Digital Mic 3", "Digital Mic 4"
4536};
4537
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004538static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
4539 int idx)
4540{
4541 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4542 int nums;
4543 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
4544 if (idx >= 0 && idx < nums)
4545 return conn[idx];
4546 return 0;
4547}
4548
Takashi Iwai8d087c72011-06-28 12:45:47 +02004549/* look for NID recursively */
4550#define get_connection_index(codec, mux, nid) \
4551 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004552
Takashi Iwai667067d2009-08-13 18:14:42 +02004553/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02004554/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02004555static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004556 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02004557{
4558 unsigned int caps, nums;
4559 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02004560 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02004561
Takashi Iwai96f845d2009-08-29 00:49:36 +02004562 if (direction == HDA_OUTPUT)
4563 caps = AC_WCAP_OUT_AMP;
4564 else
4565 caps = AC_WCAP_IN_AMP;
4566 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02004567 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004568 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02004569 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
4570 if (!nums)
4571 return 0;
4572 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004573 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
4574 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02004575 if (err < 0)
4576 return err;
4577 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02004578}
4579
Matt Porter8b657272006-10-26 17:12:59 +02004580/* create playback/capture controls for input pins on dmic capable codecs */
4581static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
4582 const struct auto_pin_cfg *cfg)
4583{
4584 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02004585 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004586 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004587 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02004588 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02004589
Takashi Iwai10a20af2010-09-09 16:28:02 +02004590 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02004591
Matt Porter8b657272006-10-26 17:12:59 +02004592 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01004593 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004594 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01004595 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02004596
Takashi Iwai667067d2009-08-13 18:14:42 +02004597 nid = spec->dmic_nids[i];
4598 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
4599 continue;
4600 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02004601 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
4602 continue;
4603
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004604 index = get_connection_index(codec, spec->dmux_nids[0], nid);
4605 if (index < 0)
4606 continue;
4607
Takashi Iwai201e06f2011-11-16 15:33:26 +01004608 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4609 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02004610 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01004611 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
4612 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02004613
Takashi Iwai10a20af2010-09-09 16:28:02 +02004614 err = create_elem_capture_vol(codec, nid, label, type_idx,
4615 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004616 if (err < 0)
4617 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004618 if (!err) {
4619 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02004620 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02004621 if (err < 0)
4622 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004623 if (!err) {
4624 nid = get_connected_node(codec,
4625 spec->dmux_nids[0], index);
4626 if (nid)
4627 err = create_elem_capture_vol(codec,
4628 nid, label,
4629 type_idx, HDA_INPUT);
4630 if (err < 0)
4631 return err;
4632 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02004633 }
Matt Porter8b657272006-10-26 17:12:59 +02004634 }
4635
4636 return 0;
4637}
4638
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004639static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02004640 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004641{
4642 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004643 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004644
4645 if (!nid)
4646 return 0;
4647 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004648 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004649 switch (snd_hda_get_input_pin_attr(cfg)) {
4650 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004651 if (*fixed)
4652 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004653 if (type != AC_JACK_MIC_IN)
4654 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004655 *fixed = nid;
4656 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004657 case INPUT_PIN_ATTR_UNUSED:
4658 break;
4659 case INPUT_PIN_ATTR_DOCK:
4660 if (*dock)
4661 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004662 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
4663 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004664 *dock = nid;
4665 break;
4666 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004667 if (*ext)
4668 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004669 if (type != AC_JACK_MIC_IN)
4670 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004671 *ext = nid;
4672 break;
4673 }
4674 return 0;
4675}
4676
4677static int set_mic_route(struct hda_codec *codec,
4678 struct sigmatel_mic_route *mic,
4679 hda_nid_t pin)
4680{
4681 struct sigmatel_spec *spec = codec->spec;
4682 struct auto_pin_cfg *cfg = &spec->autocfg;
4683 int i;
4684
4685 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02004686 if (pin == 0)
4687 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004688 for (i = 0; i < cfg->num_inputs; i++) {
4689 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004690 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004691 }
Takashi Iwai86e29592010-09-09 14:50:17 +02004692 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004693 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004694 i = get_connection_index(codec, spec->mux_nids[0], pin);
4695 if (i < 0)
4696 return -1;
4697 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02004698 mic->dmux_idx = -1;
4699 if (spec->dmux_nids)
4700 mic->dmux_idx = get_connection_index(codec,
4701 spec->dmux_nids[0],
4702 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004703 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004704 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004705 i = get_connection_index(codec, spec->dmux_nids[0], pin);
4706 if (i < 0)
4707 return -1;
4708 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02004709 mic->mux_idx = -1;
4710 if (spec->mux_nids)
4711 mic->mux_idx = get_connection_index(codec,
4712 spec->mux_nids[0],
4713 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004714 }
4715 return 0;
4716}
4717
4718/* return non-zero if the device is for automatic mic switch */
4719static int stac_check_auto_mic(struct hda_codec *codec)
4720{
4721 struct sigmatel_spec *spec = codec->spec;
4722 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02004723 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004724 int i;
4725
Charles Chin99077902010-09-17 10:22:32 +02004726 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004727 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02004728 if (check_mic_pin(codec, cfg->inputs[i].pin,
4729 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004730 return 0;
4731 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02004732 if (check_mic_pin(codec, spec->dmic_nids[i],
4733 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004734 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01004735 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02004736 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004737 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004738 return 0; /* no unsol support */
4739 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02004740 set_mic_route(codec, &spec->int_mic, fixed) ||
4741 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004742 return 0; /* something is wrong */
4743 return 1;
4744}
4745
Mattc7d4b2f2005-06-27 14:59:41 +02004746/* create playback/capture controls for input pins */
4747static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
4748{
4749 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004750 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02004751 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004752 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02004753
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004754 for (i = 0; i < cfg->num_inputs; i++) {
4755 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004756 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02004757
Takashi Iwai314634b2006-09-21 11:56:18 +02004758 index = -1;
4759 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004760 index = get_connection_index(codec, spec->mux_nids[j],
4761 nid);
4762 if (index >= 0)
4763 break;
Mattc7d4b2f2005-06-27 14:59:41 +02004764 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004765 if (index < 0)
4766 continue;
4767
Takashi Iwai10a20af2010-09-09 16:28:02 +02004768 label = hda_get_autocfg_input_label(codec, cfg, i);
4769 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004770
Takashi Iwai667067d2009-08-13 18:14:42 +02004771 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004772 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02004773 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004774 if (err < 0)
4775 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004776 }
Takashi Iwai5207e102009-07-30 13:09:08 +02004777 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02004778
Steve Longerbeam7b043892007-05-03 20:50:03 +02004779 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02004780 /*
4781 * Set the current input for the muxes.
4782 * The STAC9221 has two input muxes with identical source
4783 * NID lists. Hopefully this won't get confused.
4784 */
4785 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004786 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
4787 AC_VERB_SET_CONNECT_SEL,
4788 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004789 }
4790 }
4791
Mattc7d4b2f2005-06-27 14:59:41 +02004792 return 0;
4793}
4794
Mattc7d4b2f2005-06-27 14:59:41 +02004795static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
4796{
4797 struct sigmatel_spec *spec = codec->spec;
4798 int i;
4799
4800 for (i = 0; i < spec->autocfg.line_outs; i++) {
4801 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4802 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
4803 }
4804}
4805
4806static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
4807{
4808 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004809 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004810
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004811 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4812 hda_nid_t pin;
4813 pin = spec->autocfg.hp_pins[i];
4814 if (pin) /* connect to front */
4815 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
4816 }
4817 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
4818 hda_nid_t pin;
4819 pin = spec->autocfg.speaker_pins[i];
4820 if (pin) /* connect to front */
4821 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
4822 }
Mattc7d4b2f2005-06-27 14:59:41 +02004823}
4824
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01004825static int is_dual_headphones(struct hda_codec *codec)
4826{
4827 struct sigmatel_spec *spec = codec->spec;
4828 int i, valid_hps;
4829
4830 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
4831 spec->autocfg.hp_outs <= 1)
4832 return 0;
4833 valid_hps = 0;
4834 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4835 hda_nid_t nid = spec->autocfg.hp_pins[i];
4836 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
4837 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
4838 continue;
4839 valid_hps++;
4840 }
4841 return (valid_hps > 1);
4842}
4843
4844
Charles Chin9009b0e2011-11-03 10:27:27 +01004845static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02004846{
4847 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01004848 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004849 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02004850 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02004851
Matt Porter8b657272006-10-26 17:12:59 +02004852 if ((err = snd_hda_parse_pin_def_config(codec,
4853 &spec->autocfg,
4854 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004855 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004856 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01004857 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02004858
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004859 /* If we have no real line-out pin and multiple hp-outs, HPs should
4860 * be set up as multi-channel outputs.
4861 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01004862 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004863 /* Copy hp_outs to line_outs, backup line_outs in
4864 * speaker_outs so that the following routines can handle
4865 * HP pins as primary outputs.
4866 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004867 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004868 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
4869 sizeof(spec->autocfg.line_out_pins));
4870 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
4871 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
4872 sizeof(spec->autocfg.hp_pins));
4873 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004874 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
4875 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004876 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004877 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01004878 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004879 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
4880 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004881 u32 caps = query_amp_caps(codec,
4882 spec->autocfg.mono_out_pin, dir);
4883 hda_nid_t conn_list[1];
4884
4885 /* get the mixer node and then the mono mux if it exists */
4886 if (snd_hda_get_connections(codec,
4887 spec->autocfg.mono_out_pin, conn_list, 1) &&
4888 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004889 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01004890
4891 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004892 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004893 /* LR swap check, some stac925x have a mux that
4894 * changes the DACs output path instead of the
4895 * mono-mux path.
4896 */
4897 if (wid_type == AC_WID_AUD_SEL &&
4898 !(wcaps & AC_WCAP_LR_SWAP))
4899 spec->mono_nid = conn_list[0];
4900 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004901 if (dir) {
4902 hda_nid_t nid = spec->autocfg.mono_out_pin;
4903
4904 /* most mono outs have a least a mute/unmute switch */
4905 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
4906 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
4907 "Mono Playback Switch",
4908 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01004909 if (err < 0)
4910 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004911 /* check for volume support for the amp */
4912 if ((caps & AC_AMPCAP_NUM_STEPS)
4913 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4914 err = stac92xx_add_control(spec,
4915 STAC_CTL_WIDGET_VOL,
4916 "Mono Playback Volume",
4917 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
4918 if (err < 0)
4919 return err;
4920 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01004921 }
4922
4923 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
4924 AC_PINCTL_OUT_EN);
4925 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004926
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004927 if (!spec->multiout.num_dacs) {
4928 err = stac92xx_auto_fill_dac_nids(codec);
4929 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02004930 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01004931 err = stac92xx_auto_create_multi_out_ctls(codec,
4932 &spec->autocfg);
4933 if (err < 0)
4934 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004935 }
Mattc7d4b2f2005-06-27 14:59:41 +02004936
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004937 /* setup analog beep controls */
4938 if (spec->anabeep_nid > 0) {
4939 err = stac92xx_auto_create_beep_ctls(codec,
4940 spec->anabeep_nid);
4941 if (err < 0)
4942 return err;
4943 }
4944
4945 /* setup digital beep controls and input device */
4946#ifdef CONFIG_SND_HDA_INPUT_BEEP
4947 if (spec->digbeep_nid > 0) {
4948 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004949 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004950
4951 err = stac92xx_auto_create_beep_ctls(codec, nid);
4952 if (err < 0)
4953 return err;
4954 err = snd_hda_attach_beep_device(codec, nid);
4955 if (err < 0)
4956 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01004957 if (codec->beep) {
4958 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01004959 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01004960 /* if no beep switch is available, make its own one */
4961 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4962 if (!(caps & AC_AMPCAP_MUTE)) {
4963 err = stac92xx_beep_switch_ctl(codec);
4964 if (err < 0)
4965 return err;
4966 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004967 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004968 }
4969#endif
4970
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004971 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004972 if (err < 0)
4973 return err;
4974
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004975 /* All output parsing done, now restore the swapped hp pins */
4976 if (hp_swap) {
4977 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
4978 sizeof(spec->autocfg.hp_pins));
4979 spec->autocfg.hp_outs = spec->autocfg.line_outs;
4980 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
4981 spec->autocfg.line_outs = 0;
4982 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004983
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004984 if (stac_check_auto_mic(codec)) {
4985 spec->auto_mic = 1;
4986 /* only one capture for auto-mic */
4987 spec->num_adcs = 1;
4988 spec->num_caps = 1;
4989 spec->num_muxes = 1;
4990 }
4991
Takashi Iwai6479c632009-07-28 18:20:25 +02004992 for (i = 0; i < spec->num_caps; i++) {
4993 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
4994 spec->capsws[i], i);
4995 if (err < 0)
4996 return err;
4997 }
4998
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004999 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02005000 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005001 return err;
5002
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005003 if (spec->mono_nid > 0) {
5004 err = stac92xx_auto_create_mono_output_ctls(codec);
5005 if (err < 0)
5006 return err;
5007 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005008 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02005009 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
5010 &spec->autocfg)) < 0)
5011 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02005012 if (spec->num_muxes > 0) {
5013 err = stac92xx_auto_create_mux_input_ctls(codec);
5014 if (err < 0)
5015 return err;
5016 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02005017 if (spec->num_smuxes > 0) {
5018 err = stac92xx_auto_create_spdif_mux_ctls(codec);
5019 if (err < 0)
5020 return err;
5021 }
Matt Porter8b657272006-10-26 17:12:59 +02005022
Takashi Iwaie3c75962009-01-23 11:57:22 +01005023 err = stac92xx_add_input_source(spec);
5024 if (err < 0)
5025 return err;
5026
Mattc7d4b2f2005-06-27 14:59:41 +02005027 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01005028 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02005029 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02005030
Charles Chin9009b0e2011-11-03 10:27:27 +01005031 /* find digital out and in converters */
5032 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
5033 unsigned int wid_caps = get_wcaps(codec, i);
5034 if (wid_caps & AC_WCAP_DIGITAL) {
5035 switch (get_wcaps_type(wid_caps)) {
5036 case AC_WID_AUD_OUT:
5037 if (!dig_out)
5038 dig_out = i;
5039 break;
5040 case AC_WID_AUD_IN:
5041 if (!dig_in)
5042 dig_in = i;
5043 break;
5044 }
5045 }
5046 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005047 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005048 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005049 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01005050 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02005051
Takashi Iwai603c4012008-07-30 15:01:44 +02005052 if (spec->kctls.list)
5053 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005054
5055 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05005056 if (!spec->dinput_mux)
5057 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005058 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01005059 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02005060 return 1;
5061}
5062
Takashi Iwai82bc9552006-03-21 11:24:42 +01005063/* add playback controls for HP output */
5064static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
5065 struct auto_pin_cfg *cfg)
5066{
5067 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005068 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01005069
5070 if (! pin)
5071 return 0;
5072
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005073 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01005074 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005075
5076 return 0;
5077}
5078
Richard Fish160ea0d2006-09-06 13:58:25 +02005079/* add playback controls for LFE output */
5080static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
5081 struct auto_pin_cfg *cfg)
5082{
5083 struct sigmatel_spec *spec = codec->spec;
5084 int err;
5085 hda_nid_t lfe_pin = 0x0;
5086 int i;
5087
5088 /*
5089 * search speaker outs and line outs for a mono speaker pin
5090 * with an amp. If one is found, add LFE controls
5091 * for it.
5092 */
5093 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
5094 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005095 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005096 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5097 if (wcaps == AC_WCAP_OUT_AMP)
5098 /* found a mono speaker with an amp, must be lfe */
5099 lfe_pin = pin;
5100 }
5101
5102 /* if speaker_outs is 0, then speakers may be in line_outs */
5103 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
5104 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
5105 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005106 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01005107 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01005108 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01005109 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02005110 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5111 if (wcaps == AC_WCAP_OUT_AMP)
5112 /* found a mono speaker with an amp,
5113 must be lfe */
5114 lfe_pin = pin;
5115 }
5116 }
5117 }
5118
5119 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01005120 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02005121 if (err < 0)
5122 return err;
5123 }
5124
5125 return 0;
5126}
5127
Mattc7d4b2f2005-06-27 14:59:41 +02005128static int stac9200_parse_auto_config(struct hda_codec *codec)
5129{
5130 struct sigmatel_spec *spec = codec->spec;
5131 int err;
5132
Kailang Yangdf694da2005-12-05 19:42:22 +01005133 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02005134 return err;
5135
5136 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
5137 return err;
5138
Takashi Iwai82bc9552006-03-21 11:24:42 +01005139 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
5140 return err;
5141
Richard Fish160ea0d2006-09-06 13:58:25 +02005142 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
5143 return err;
5144
Takashi Iwai355a0ec2008-11-11 16:46:19 +01005145 if (spec->num_muxes > 0) {
5146 err = stac92xx_auto_create_mux_input_ctls(codec);
5147 if (err < 0)
5148 return err;
5149 }
5150
Takashi Iwaie3c75962009-01-23 11:57:22 +01005151 err = stac92xx_add_input_source(spec);
5152 if (err < 0)
5153 return err;
5154
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005155 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02005156 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005157 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02005158 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02005159
Takashi Iwai603c4012008-07-30 15:01:44 +02005160 if (spec->kctls.list)
5161 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02005162
5163 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02005164 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02005165
5166 return 1;
5167}
5168
Sam Revitch62fe78e2006-05-10 15:09:17 +02005169/*
5170 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
5171 * funky external mute control using GPIO pins.
5172 */
5173
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005174static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005175 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02005176{
5177 unsigned int gpiostate, gpiomask, gpiodir;
5178
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005179 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
5180
Sam Revitch62fe78e2006-05-10 15:09:17 +02005181 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5182 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005183 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02005184
5185 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5186 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005187 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005188
5189 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5190 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005191 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02005192
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005193 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005194 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
5195
5196 snd_hda_codec_write(codec, codec->afg, 0,
5197 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005198 snd_hda_codec_read(codec, codec->afg, 0,
5199 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005200
5201 msleep(1);
5202
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01005203 snd_hda_codec_read(codec, codec->afg, 0,
5204 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005205}
5206
Takashi Iwai3a938972011-10-28 01:16:55 +02005207static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005208 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005209{
Takashi Iwai3a938972011-10-28 01:16:55 +02005210 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005211
Takashi Iwai3a938972011-10-28 01:16:55 +02005212 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005213 if (!event)
5214 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02005215 event->action = type;
5216 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005217
Takashi Iwai3a938972011-10-28 01:16:55 +02005218 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005219}
5220
David Henningsson29adc4b2012-09-25 11:31:00 +02005221static void handle_unsol_event(struct hda_codec *codec,
5222 struct hda_jack_tbl *event);
5223
Takashi Iwai62558ce2009-07-29 14:23:09 +02005224/* check if given nid is a valid pin and no other events are assigned
5225 * to it. If OK, assign the event, set the unsol flag, and returns 1.
5226 * Otherwise, returns zero.
5227 */
5228static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
5229 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02005230{
Takashi Iwai3a938972011-10-28 01:16:55 +02005231 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005232
Takashi Iwaie35d9d62011-05-17 11:28:16 +02005233 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02005234 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02005235 event = snd_hda_jack_tbl_new(codec, nid);
5236 if (!event)
5237 return -ENOMEM;
5238 if (event->action && event->action != type)
5239 return 0;
5240 event->action = type;
David Henningsson29adc4b2012-09-25 11:31:00 +02005241 event->callback = handle_unsol_event;
Takashi Iwai3a938972011-10-28 01:16:55 +02005242 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02005243 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02005244}
5245
Takashi Iwaib4ead012012-01-23 18:23:36 +01005246static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005247{
5248 int i;
5249 for (i = 0; i < cfg->hp_outs; i++)
5250 if (cfg->hp_pins[i] == nid)
5251 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01005252 for (i = 0; i < cfg->line_outs; i++)
5253 if (cfg->line_out_pins[i] == nid)
5254 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005255 return 0; /* nid is not a HP-Out */
5256};
5257
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005258static void stac92xx_power_down(struct hda_codec *codec)
5259{
5260 struct sigmatel_spec *spec = codec->spec;
5261
5262 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02005263 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005264 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005265 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005266 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005267 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5268}
5269
Takashi Iwaif73d3582008-11-25 08:21:51 +01005270static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5271 int enable);
5272
Takashi Iwaibc759722013-01-11 17:40:31 +01005273static inline bool get_int_hint(struct hda_codec *codec, const char *key,
5274 int *valp)
Takashi Iwai014c41f2009-12-27 13:53:24 +01005275{
Takashi Iwaibc759722013-01-11 17:40:31 +01005276 return !snd_hda_get_int_hint(codec, key, valp);
Takashi Iwai014c41f2009-12-27 13:53:24 +01005277}
5278
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005279/* override some hints from the hwdep entry */
5280static void stac_store_hints(struct hda_codec *codec)
5281{
5282 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005283 int val;
5284
5285 val = snd_hda_get_bool_hint(codec, "hp_detect");
5286 if (val >= 0)
5287 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01005288 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005289 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
5290 spec->gpio_mask;
5291 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01005292 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
5293 spec->gpio_mask &= spec->gpio_mask;
5294 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
5295 spec->gpio_dir &= spec->gpio_mask;
5296 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
5297 spec->eapd_mask &= spec->gpio_mask;
5298 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
5299 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005300 val = snd_hda_get_bool_hint(codec, "eapd_switch");
5301 if (val >= 0)
5302 spec->eapd_switch = val;
5303}
5304
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005305static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
5306 const hda_nid_t *pins)
5307{
5308 while (num_pins--)
5309 stac_issue_unsol_event(codec, *pins++);
5310}
5311
5312/* fake event to set up pins */
5313static void stac_fake_hp_events(struct hda_codec *codec)
5314{
5315 struct sigmatel_spec *spec = codec->spec;
5316
5317 if (spec->autocfg.hp_outs)
5318 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
5319 spec->autocfg.hp_pins);
5320 if (spec->autocfg.line_outs &&
5321 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
5322 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
5323 spec->autocfg.line_out_pins);
5324}
5325
Mattc7d4b2f2005-06-27 14:59:41 +02005326static int stac92xx_init(struct hda_codec *codec)
5327{
5328 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005329 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005330 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01005331 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005332
David Henningsson5e68fb32012-08-16 14:11:09 +02005333 if (spec->init)
5334 snd_hda_sequence_write(codec, spec->init);
Mattc7d4b2f2005-06-27 14:59:41 +02005335
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005336 snd_hda_apply_verbs(codec);
5337
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005338 /* power down adcs initially */
5339 if (spec->powerdown_adcs)
5340 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005341 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005342 spec->adc_nids[i], 0,
5343 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005344
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005345 /* override some hints */
5346 stac_store_hints(codec);
5347
Takashi Iwaif73d3582008-11-25 08:21:51 +01005348 /* set up GPIO */
5349 gpio = spec->gpio_data;
5350 /* turn on EAPD statically when spec->eapd_switch isn't set.
5351 * otherwise, unsol event will turn it on/off dynamically
5352 */
5353 if (!spec->eapd_switch)
5354 gpio |= spec->eapd_mask;
5355 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
5356
Takashi Iwai82bc9552006-03-21 11:24:42 +01005357 /* set up pins */
5358 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02005359 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005360 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005361 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005362 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005363 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02005364 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
5365 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005366 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02005367 for (i = 0; i < cfg->line_outs; i++) {
5368 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005369 enable_pin_detect(codec, nid, STAC_LO_EVENT);
5370 }
5371 }
5372
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01005373 /* force to enable the first line-out; the others are set up
5374 * in unsol_event
5375 */
5376 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005377 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005378 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005379 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005380 } else {
5381 stac92xx_auto_init_multi_out(codec);
5382 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005383 for (i = 0; i < cfg->hp_outs; i++)
5384 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005385 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005386 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02005387 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005388 if (spec->dmux_nids)
5389 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02005390 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005391 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
5392 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02005393 if (enable_pin_detect(codec, spec->dock_mic.pin,
5394 STAC_MIC_EVENT))
5395 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005396 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005397 for (i = 0; i < cfg->num_inputs; i++) {
5398 hda_nid_t nid = cfg->inputs[i].pin;
5399 int type = cfg->inputs[i].type;
5400 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02005401 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005402 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02005403 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005404 pinctl |= AC_PINCTL_IN_EN;
5405 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5406 } else {
5407 pinctl = snd_hda_codec_read(codec, nid, 0,
5408 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5409 /* if PINCTL already set then skip */
5410 /* Also, if both INPUT and OUTPUT are set,
5411 * it must be a BIOS bug; need to override, too
5412 */
5413 if (!(pinctl & AC_PINCTL_IN_EN) ||
5414 (pinctl & AC_PINCTL_OUT_EN)) {
5415 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005416 pinctl |= AC_PINCTL_IN_EN;
5417 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01005418 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005419 }
5420 conf = snd_hda_codec_get_pincfg(codec, nid);
5421 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
5422 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
5423 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01005424 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01005425 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005426 for (i = 0; i < spec->num_dmics; i++)
5427 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
5428 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005429 if (cfg->dig_out_pins[0])
5430 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01005431 AC_PINCTL_OUT_EN);
5432 if (cfg->dig_in_pin)
5433 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
5434 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005435 for (i = 0; i < spec->num_pwrs; i++) {
5436 hda_nid_t nid = spec->pwr_nids[i];
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005437 unsigned int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005438
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005439 def_conf = snd_hda_codec_get_pincfg(codec, nid);
5440 def_conf = get_defcfg_connect(def_conf);
5441 if (def_conf == AC_JACK_PORT_NONE) {
5442 /* power off unused ports */
5443 stac_toggle_power_map(codec, nid, 0);
5444 continue;
5445 }
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005446 if (def_conf == AC_JACK_PORT_FIXED) {
5447 /* no need for jack detection for fixed pins */
5448 stac_toggle_power_map(codec, nid, 1);
5449 continue;
5450 }
Takashi Iwaieb632122008-12-19 16:39:48 +01005451 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01005452 /* or when the VREF is used for controlling LED */
5453 if (!spec->hp_detect ||
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005454 spec->vref_mute_led_nid == nid ||
5455 !is_jack_detectable(codec, nid)) {
Takashi Iwaieb632122008-12-19 16:39:48 +01005456 stac_toggle_power_map(codec, nid, 1);
5457 continue;
5458 }
5459
Takashi Iwaib4ead012012-01-23 18:23:36 +01005460 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01005461 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005462
Takashi Iwaif73d3582008-11-25 08:21:51 +01005463 pinctl = snd_hda_codec_read(codec, nid, 0,
5464 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5465 /* outputs are only ports capable of power management
5466 * any attempts on powering down a input port cause the
5467 * referenced VREF to act quirky.
5468 */
Takashi Iwaieb632122008-12-19 16:39:48 +01005469 if (pinctl & AC_PINCTL_IN_EN) {
5470 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005471 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01005472 }
Charles Chinafef2cf2011-11-11 08:05:28 +01005473 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02005474 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01005475 continue;
5476 }
5477 /* none of the above, turn the port OFF */
5478 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005479 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01005480
Takashi Iwaic21bd022010-02-08 15:16:08 +01005481 /* sync mute LED */
Takashi Iwai1f43f6c2012-07-31 10:40:05 +02005482 if (spec->gpio_led) {
5483 if (spec->vmaster_mute.hook)
5484 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5485 else /* the very first init call doesn't have vmaster yet */
5486 stac92xx_update_led_status(codec, false);
5487 }
Takashi Iwaic8822462012-05-15 09:11:36 +02005488
5489 /* sync the power-map */
5490 if (spec->num_pwrs)
5491 snd_hda_codec_write(codec, codec->afg, 0,
5492 AC_VERB_IDT_SET_POWER_MAP,
5493 spec->power_map_bits);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005494 if (spec->dac_list)
5495 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02005496 return 0;
5497}
5498
Takashi Iwai603c4012008-07-30 15:01:44 +02005499static void stac92xx_free_kctls(struct hda_codec *codec)
5500{
5501 struct sigmatel_spec *spec = codec->spec;
5502
5503 if (spec->kctls.list) {
5504 struct snd_kcontrol_new *kctl = spec->kctls.list;
5505 int i;
5506 for (i = 0; i < spec->kctls.used; i++)
5507 kfree(kctl[i].name);
5508 }
5509 snd_array_free(&spec->kctls);
5510}
5511
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005512static void stac92xx_shutup_pins(struct hda_codec *codec)
5513{
5514 unsigned int i, def_conf;
5515
5516 if (codec->bus->shutdown)
5517 return;
5518 for (i = 0; i < codec->init_pins.used; i++) {
5519 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
5520 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
5521 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005522 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005523 }
5524}
5525
Takashi Iwai167eae52009-11-06 15:47:50 +01005526static void stac92xx_shutup(struct hda_codec *codec)
5527{
5528 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01005529
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005530 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01005531
5532 if (spec->eapd_mask)
5533 stac_gpio_set(codec, spec->gpio_mask,
5534 spec->gpio_dir, spec->gpio_data &
5535 ~spec->eapd_mask);
5536}
5537
Matt2f2f4252005-04-13 14:45:30 +02005538static void stac92xx_free(struct hda_codec *codec)
5539{
Mattc7d4b2f2005-06-27 14:59:41 +02005540 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005541
5542 if (! spec)
5543 return;
5544
Mattc7d4b2f2005-06-27 14:59:41 +02005545 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005546 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02005547}
5548
Matt4e550962005-07-04 17:51:39 +02005549static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
5550 unsigned int flag)
5551{
Takashi Iwai8ce84192009-01-22 16:59:20 +01005552 unsigned int old_ctl, pin_ctl;
5553
5554 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02005555 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02005556
Takashi Iwaif9acba42007-05-29 18:01:06 +02005557 if (pin_ctl & AC_PINCTL_IN_EN) {
5558 /*
5559 * we need to check the current set-up direction of
5560 * shared input pins since they can be switched via
5561 * "xxx as Output" mixer switch
5562 */
5563 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005564 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02005565 return;
5566 }
5567
Takashi Iwai8ce84192009-01-22 16:59:20 +01005568 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02005569 /* if setting pin direction bits, clear the current
5570 direction bits first */
5571 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
5572 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
5573
Takashi Iwai8ce84192009-01-22 16:59:20 +01005574 pin_ctl |= flag;
5575 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005576 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02005577}
5578
5579static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
5580 unsigned int flag)
5581{
5582 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
5583 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01005584 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005585 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02005586}
5587
Takashi Iwaid56757a2009-11-18 08:00:14 +01005588static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02005589{
5590 if (!nid)
5591 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01005592 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02005593}
5594
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005595static void stac92xx_line_out_detect(struct hda_codec *codec,
5596 int presence)
5597{
5598 struct sigmatel_spec *spec = codec->spec;
5599 struct auto_pin_cfg *cfg = &spec->autocfg;
5600 int i;
5601
David Henningsson042b92c2012-08-22 16:10:43 +02005602 if (cfg->speaker_outs == 0)
5603 return;
5604
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005605 for (i = 0; i < cfg->line_outs; i++) {
5606 if (presence)
5607 break;
5608 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
5609 if (presence) {
5610 unsigned int pinctl;
5611 pinctl = snd_hda_codec_read(codec,
5612 cfg->line_out_pins[i], 0,
5613 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5614 if (pinctl & AC_PINCTL_IN_EN)
5615 presence = 0; /* mic- or line-input */
5616 }
5617 }
5618
5619 if (presence) {
5620 /* disable speakers */
5621 for (i = 0; i < cfg->speaker_outs; i++)
5622 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
5623 AC_PINCTL_OUT_EN);
5624 if (spec->eapd_mask && spec->eapd_switch)
5625 stac_gpio_set(codec, spec->gpio_mask,
5626 spec->gpio_dir, spec->gpio_data &
5627 ~spec->eapd_mask);
5628 } else {
5629 /* enable speakers */
5630 for (i = 0; i < cfg->speaker_outs; i++)
5631 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
5632 AC_PINCTL_OUT_EN);
5633 if (spec->eapd_mask && spec->eapd_switch)
5634 stac_gpio_set(codec, spec->gpio_mask,
5635 spec->gpio_dir, spec->gpio_data |
5636 spec->eapd_mask);
5637 }
5638}
5639
Takashi Iwaid7a89432008-11-12 09:48:04 +01005640/* return non-zero if the hp-pin of the given array index isn't
5641 * a jack-detection target
5642 */
5643static int no_hp_sensing(struct sigmatel_spec *spec, int i)
5644{
5645 struct auto_pin_cfg *cfg = &spec->autocfg;
5646
5647 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005648 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005649 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005650 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005651 return 1;
5652 /* ignore if the pin is set as line-out */
5653 if (cfg->hp_pins[i] == spec->hp_switch)
5654 return 1;
5655 return 0;
5656}
5657
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005658static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02005659{
5660 struct sigmatel_spec *spec = codec->spec;
5661 struct auto_pin_cfg *cfg = &spec->autocfg;
5662 int i, presence;
5663
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005664 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005665 if (spec->gpio_mute)
5666 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
5667 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
5668
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005669 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005670 if (presence)
5671 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01005672 if (no_hp_sensing(spec, i))
5673 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005674 presence = get_pin_presence(codec, cfg->hp_pins[i]);
5675 if (presence) {
5676 unsigned int pinctl;
5677 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
5678 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5679 if (pinctl & AC_PINCTL_IN_EN)
5680 presence = 0; /* mic- or line-input */
5681 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005682 }
Matt4e550962005-07-04 17:51:39 +02005683
5684 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005685 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005686 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005687 stac92xx_reset_pinctl(codec, spec->hp_switch,
5688 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005689 for (i = 0; i < cfg->line_outs; i++)
5690 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
5691 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005692 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005693 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005694 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005695 stac92xx_set_pinctl(codec, spec->hp_switch,
5696 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005697 for (i = 0; i < cfg->line_outs; i++)
5698 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
5699 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005700 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005701 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01005702 /* toggle hp outs */
5703 for (i = 0; i < cfg->hp_outs; i++) {
5704 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
5705 if (no_hp_sensing(spec, i))
5706 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01005707 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005708 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01005709#if 0 /* FIXME */
5710/* Resetting the pinctl like below may lead to (a sort of) regressions
5711 * on some devices since they use the HP pin actually for line/speaker
5712 * outs although the default pin config shows a different pin (that is
5713 * wrong and useless).
5714 *
5715 * So, it's basically a problem of default pin configs, likely a BIOS issue.
5716 * But, disabling the code below just works around it, and I'm too tired of
5717 * bug reports with such devices...
5718 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01005719 else
5720 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01005721#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01005722 }
Matt4e550962005-07-04 17:51:39 +02005723}
5724
Takashi Iwaif73d3582008-11-25 08:21:51 +01005725static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5726 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005727{
5728 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005729 unsigned int idx, val;
5730
5731 for (idx = 0; idx < spec->num_pwrs; idx++) {
5732 if (spec->pwr_nids[idx] == nid)
5733 break;
5734 }
5735 if (idx >= spec->num_pwrs)
5736 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005737
Charles Chinafef2cf2011-11-11 08:05:28 +01005738 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005739
Takashi Iwaic8822462012-05-15 09:11:36 +02005740 val = spec->power_map_bits;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005741 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005742 val &= ~idx;
5743 else
5744 val |= idx;
5745
5746 /* power down unused output ports */
Takashi Iwaic8822462012-05-15 09:11:36 +02005747 if (val != spec->power_map_bits) {
5748 spec->power_map_bits = val;
5749 snd_hda_codec_write(codec, codec->afg, 0,
5750 AC_VERB_IDT_SET_POWER_MAP, val);
5751 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005752}
5753
Takashi Iwaif73d3582008-11-25 08:21:51 +01005754static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
5755{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005756 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01005757}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005758
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005759/* get the pin connection (fixed, none, etc) */
5760static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5761{
5762 struct sigmatel_spec *spec = codec->spec;
5763 unsigned int cfg;
5764
5765 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5766 return get_defcfg_connect(cfg);
5767}
5768
5769static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005770 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005771{
5772 struct sigmatel_spec *spec = codec->spec;
5773 int idx, num;
5774 unsigned int def_conf;
5775
5776 for (num = 0; num < num_nids; num++) {
5777 for (idx = 0; idx < spec->num_pins; idx++)
5778 if (spec->pin_nids[idx] == nids[num])
5779 break;
5780 if (idx >= spec->num_pins)
5781 break;
5782 def_conf = stac_get_defcfg_connect(codec, idx);
5783 if (def_conf == AC_JACK_PORT_NONE)
5784 break;
5785 }
5786 return num;
5787}
5788
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005789static void stac92xx_mic_detect(struct hda_codec *codec)
5790{
5791 struct sigmatel_spec *spec = codec->spec;
5792 struct sigmatel_mic_route *mic;
5793
5794 if (get_pin_presence(codec, spec->ext_mic.pin))
5795 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02005796 else if (get_pin_presence(codec, spec->dock_mic.pin))
5797 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005798 else
5799 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02005800 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005801 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
5802 AC_VERB_SET_CONNECT_SEL,
5803 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02005804 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005805 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
5806 AC_VERB_SET_CONNECT_SEL,
5807 mic->mux_idx);
5808}
5809
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005810static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02005811 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02005812{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005813 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005814 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005815
Takashi Iwai3a938972011-10-28 01:16:55 +02005816 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005817 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005818 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02005819 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005820 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005821 case STAC_MIC_EVENT:
5822 stac92xx_mic_detect(codec);
5823 break;
5824 }
5825
Takashi Iwai3a938972011-10-28 01:16:55 +02005826 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005827 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005828 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005829 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005830 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005831 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005832 if (spec->num_pwrs > 0)
5833 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04005834
5835 switch (codec->subsystem_id) {
5836 case 0x103c308f:
5837 if (event->nid == 0xb) {
5838 int pin = AC_PINCTL_IN_EN;
5839
5840 if (get_pin_presence(codec, 0xa)
5841 && get_pin_presence(codec, 0xb))
5842 pin |= AC_PINCTL_VREF_80;
5843 if (!get_pin_presence(codec, 0xb))
5844 pin |= AC_PINCTL_VREF_80;
5845
5846 /* toggle VREF state based on mic + hp pin
5847 * status
5848 */
5849 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
5850 }
5851 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04005852 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005853 case STAC_VREF_EVENT:
5854 data = snd_hda_codec_read(codec, codec->afg, 0,
5855 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005856 /* toggle VREF state based on GPIOx status */
5857 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02005858 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04005859 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02005860 }
5861}
5862
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005863static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
5864{
Takashi Iwai3a938972011-10-28 01:16:55 +02005865 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005866 if (!event)
5867 return;
5868 handle_unsol_event(codec, event);
5869}
5870
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305871static void set_hp_led_gpio(struct hda_codec *codec)
5872{
5873 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01005874 unsigned int gpio;
5875
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005876 if (spec->gpio_led)
5877 return;
5878
Takashi Iwai07f80442010-02-08 15:06:13 +01005879 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
5880 gpio &= AC_GPIO_IO_COUNT;
5881 if (gpio > 3)
5882 spec->gpio_led = 0x08; /* GPIO 3 */
5883 else
5884 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305885}
5886
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005887/*
5888 * This method searches for the mute LED GPIO configuration
5889 * provided as OEM string in SMBIOS. The format of that string
5890 * is HP_Mute_LED_P_G or HP_Mute_LED_P
5891 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
5892 * that corresponds to the NOT muted state of the master volume
5893 * and G is the index of the GPIO to use as the mute LED control (0..9)
5894 * If _G portion is missing it is assigned based on the codec ID
5895 *
5896 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
5897 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305898 *
5899 *
5900 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
5901 * SMBIOS - at least the ones I have seen do not have them - which include
5902 * my own system (HP Pavilion dv6-1110ax) and my cousin's
5903 * HP Pavilion dv9500t CTO.
5904 * Need more information on whether it is true across the entire series.
5905 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005906 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005907static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005908{
5909 struct sigmatel_spec *spec = codec->spec;
5910 const struct dmi_device *dev = NULL;
5911
Takashi Iwai75609312012-05-14 16:52:00 +02005912 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
5913 get_int_hint(codec, "gpio_led_polarity",
5914 &spec->gpio_led_polarity);
5915 return 1;
5916 }
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01005917
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005918 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
5919 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
5920 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005921 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305922 &spec->gpio_led_polarity,
5923 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005924 unsigned int max_gpio;
5925 max_gpio = snd_hda_param_read(codec, codec->afg,
5926 AC_PAR_GPIO_CAP);
5927 max_gpio &= AC_GPIO_IO_COUNT;
5928 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005929 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005930 else
5931 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005932 return 1;
5933 }
5934 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305935 &spec->gpio_led_polarity) == 1) {
5936 set_hp_led_gpio(codec);
5937 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005938 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02005939 /* BIOS bug: unfilled OEM string */
5940 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
5941 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02005942 switch (codec->subsystem_id) {
5943 case 0x103c148a:
5944 spec->gpio_led_polarity = 0;
5945 break;
5946 default:
5947 spec->gpio_led_polarity = 1;
5948 break;
5949 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02005950 return 1;
5951 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005952 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305953
5954 /*
5955 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005956 * we statically set the GPIO - if not a B-series system
5957 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305958 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005959 if (!hp_blike_system(codec->subsystem_id) &&
5960 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305961 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01005962 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305963 return 1;
5964 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005965 }
5966 return 0;
5967}
5968
5969static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08005970{
5971 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005972 case 0x103c1520:
5973 case 0x103c1521:
5974 case 0x103c1523:
5975 case 0x103c1524:
5976 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08005977 case 0x103c1722:
5978 case 0x103c1723:
5979 case 0x103c1724:
5980 case 0x103c1725:
5981 case 0x103c1726:
5982 case 0x103c1727:
5983 case 0x103c1728:
5984 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005985 case 0x103c172a:
5986 case 0x103c172b:
5987 case 0x103c307e:
5988 case 0x103c307f:
5989 case 0x103c3080:
5990 case 0x103c3081:
5991 case 0x103c7007:
5992 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08005993 return 1;
5994 }
5995 return 0;
5996}
5997
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005998#ifdef CONFIG_PROC_FS
5999static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
6000 struct hda_codec *codec, hda_nid_t nid)
6001{
6002 if (nid == codec->afg)
6003 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02006004 snd_hda_codec_read(codec, nid, 0,
6005 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006006}
6007
6008static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
6009 struct hda_codec *codec,
6010 unsigned int verb)
6011{
6012 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
6013 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
6014}
6015
6016/* stac92hd71bxx, stac92hd73xx */
6017static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
6018 struct hda_codec *codec, hda_nid_t nid)
6019{
6020 stac92hd_proc_hook(buffer, codec, nid);
6021 if (nid == codec->afg)
6022 analog_loop_proc_hook(buffer, codec, 0xfa0);
6023}
6024
6025static void stac9205_proc_hook(struct snd_info_buffer *buffer,
6026 struct hda_codec *codec, hda_nid_t nid)
6027{
6028 if (nid == codec->afg)
6029 analog_loop_proc_hook(buffer, codec, 0xfe0);
6030}
6031
6032static void stac927x_proc_hook(struct snd_info_buffer *buffer,
6033 struct hda_codec *codec, hda_nid_t nid)
6034{
6035 if (nid == codec->afg)
6036 analog_loop_proc_hook(buffer, codec, 0xfeb);
6037}
6038#else
6039#define stac92hd_proc_hook NULL
6040#define stac92hd7x_proc_hook NULL
6041#define stac9205_proc_hook NULL
6042#define stac927x_proc_hook NULL
6043#endif
6044
Takashi Iwai2a439522011-07-26 09:52:50 +02006045#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02006046static int stac92xx_resume(struct hda_codec *codec)
6047{
Takashi Iwai2c885872008-11-18 09:36:55 +01006048 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006049 snd_hda_codec_resume_amp(codec);
6050 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01006051 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01006052 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02006053 return 0;
6054}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006055
Takashi Iwai68cb2b52012-07-02 15:20:37 +02006056static int stac92xx_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006057{
6058 stac92xx_shutup(codec);
6059 return 0;
6060}
6061
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006062static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
6063 unsigned int power_state)
6064{
6065 unsigned int afg_power_state = power_state;
6066 struct sigmatel_spec *spec = codec->spec;
6067
6068 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006069 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006070 /* with vref-out pin used for mute led control
6071 * codec AFG is prevented from D3 state
6072 */
6073 afg_power_state = AC_PWRST_D1;
6074 }
6075 /* this delay seems necessary to avoid click noise at power-down */
6076 msleep(100);
6077 }
6078 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
6079 afg_power_state);
6080 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
6081}
Takashi Iwai350eba432012-03-16 16:09:03 +01006082#else
6083#define stac92xx_suspend NULL
6084#define stac92xx_resume NULL
Takashi Iwai350eba432012-03-16 16:09:03 +01006085#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006086#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006087
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006088/* update mute-LED accoring to the master switch */
6089static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006090{
6091 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006092 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01006093
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006094 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006095 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006096
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006097 /* LED state is inverted on these systems */
6098 if (spec->gpio_led_polarity)
6099 muted = !muted;
6100
Takashi Iwaif1a73742011-12-04 13:44:06 +01006101 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006102 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02006103 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006104 else
Takashi Iwai3e843192012-04-19 12:04:03 +02006105 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006106 stac_gpio_set(codec, spec->gpio_mask,
6107 spec->gpio_dir, spec->gpio_data);
6108 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01006109 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01006110 stac_vrefout_set(codec, spec->vref_mute_led_nid,
6111 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006112 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006113}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05006114
Takashi Iwai2b635362011-05-02 12:33:43 +02006115static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02006116 .build_controls = stac92xx_build_controls,
6117 .build_pcms = stac92xx_build_pcms,
6118 .init = stac92xx_init,
6119 .free = stac92xx_free,
David Henningsson29adc4b2012-09-25 11:31:00 +02006120 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02006121#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05006122 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02006123 .resume = stac92xx_resume,
6124#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01006125 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02006126};
6127
Takashi Iwai361dab32012-05-09 14:35:27 +02006128static int alloc_stac_spec(struct hda_codec *codec, int num_pins,
6129 const hda_nid_t *pin_nids)
6130{
6131 struct sigmatel_spec *spec;
6132
6133 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6134 if (!spec)
6135 return -ENOMEM;
6136 codec->spec = spec;
6137 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
6138 spec->num_pins = num_pins;
6139 spec->pin_nids = pin_nids;
6140 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
6141 return 0;
6142}
6143
Matt2f2f4252005-04-13 14:45:30 +02006144static int patch_stac9200(struct hda_codec *codec)
6145{
6146 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006147 int err;
Matt2f2f4252005-04-13 14:45:30 +02006148
Takashi Iwai361dab32012-05-09 14:35:27 +02006149 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids),
6150 stac9200_pin_nids);
6151 if (err < 0)
6152 return err;
Matt2f2f4252005-04-13 14:45:30 +02006153
Takashi Iwai361dab32012-05-09 14:35:27 +02006154 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006155 spec->linear_tone_beep = 1;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006156
6157 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
6158 stac9200_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006159
6160 spec->multiout.max_channels = 2;
6161 spec->multiout.num_dacs = 1;
6162 spec->multiout.dac_nids = stac9200_dac_nids;
6163 spec->adc_nids = stac9200_adc_nids;
6164 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02006165 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02006166 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006167 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006168 spec->num_pwrs = 0;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006169 snd_hda_add_verbs(codec, stac9200_eapd_init);
Mattc7d4b2f2005-06-27 14:59:41 +02006170
Matt2f2f4252005-04-13 14:45:30 +02006171 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02006172
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006173 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai117f2572008-03-18 09:53:23 +01006174
Mattc7d4b2f2005-06-27 14:59:41 +02006175 err = stac9200_parse_auto_config(codec);
6176 if (err < 0) {
6177 stac92xx_free(codec);
6178 return err;
6179 }
Matt2f2f4252005-04-13 14:45:30 +02006180
6181 codec->patch_ops = stac92xx_patch_ops;
6182
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01006183 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6184
Matt2f2f4252005-04-13 14:45:30 +02006185 return 0;
6186}
6187
Tobin Davis8e21c342007-01-08 11:04:17 +01006188static int patch_stac925x(struct hda_codec *codec)
6189{
6190 struct sigmatel_spec *spec;
6191 int err;
6192
Takashi Iwai361dab32012-05-09 14:35:27 +02006193 err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids),
6194 stac925x_pin_nids);
6195 if (err < 0)
6196 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01006197
Takashi Iwai361dab32012-05-09 14:35:27 +02006198 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006199 spec->linear_tone_beep = 1;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02006200
Takashi Iwaid2077d42013-01-14 14:20:16 +01006201 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
6202 stac925x_fixups);
Tobin Davis8e21c342007-01-08 11:04:17 +01006203
6204 spec->multiout.max_channels = 2;
6205 spec->multiout.num_dacs = 1;
6206 spec->multiout.dac_nids = stac925x_dac_nids;
6207 spec->adc_nids = stac925x_adc_nids;
6208 spec->mux_nids = stac925x_mux_nids;
6209 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006210 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006211 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02006212 switch (codec->vendor_id) {
6213 case 0x83847632: /* STAC9202 */
6214 case 0x83847633: /* STAC9202D */
6215 case 0x83847636: /* STAC9251 */
6216 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02006217 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02006218 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006219 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
6220 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02006221 break;
6222 default:
6223 spec->num_dmics = 0;
6224 break;
6225 }
Tobin Davis8e21c342007-01-08 11:04:17 +01006226
Takashi Iwaid2077d42013-01-14 14:20:16 +01006227 snd_hda_add_verbs(codec, stac925x_core_init);
Tobin Davis8e21c342007-01-08 11:04:17 +01006228 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02006229 spec->num_caps = 1;
6230 spec->capvols = stac925x_capvols;
6231 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01006232
Takashi Iwaid2077d42013-01-14 14:20:16 +01006233 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6234
Charles Chin9009b0e2011-11-03 10:27:27 +01006235 err = stac92xx_parse_auto_config(codec);
Takashi Iwaid2077d42013-01-14 14:20:16 +01006236 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006237 err = -EINVAL;
Tobin Davis8e21c342007-01-08 11:04:17 +01006238 if (err < 0) {
6239 stac92xx_free(codec);
6240 return err;
6241 }
6242
6243 codec->patch_ops = stac92xx_patch_ops;
6244
Takashi Iwaid2077d42013-01-14 14:20:16 +01006245 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6246
Tobin Davis8e21c342007-01-08 11:04:17 +01006247 return 0;
6248}
6249
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006250static int patch_stac92hd73xx(struct hda_codec *codec)
6251{
6252 struct sigmatel_spec *spec;
6253 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
Takashi Iwai361dab32012-05-09 14:35:27 +02006254 int err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006255 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006256
Takashi Iwai361dab32012-05-09 14:35:27 +02006257 err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids),
6258 stac92hd73xx_pin_nids);
6259 if (err < 0)
6260 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006261
Takashi Iwai361dab32012-05-09 14:35:27 +02006262 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006263 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02006264 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006265 spec->board_config = snd_hda_check_board_config(codec,
6266 STAC_92HD73XX_MODELS,
6267 stac92hd73xx_models,
6268 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02006269 /* check codec subsystem id if not found */
6270 if (spec->board_config < 0)
6271 spec->board_config =
6272 snd_hda_check_board_codec_sid_config(codec,
6273 STAC_92HD73XX_MODELS, stac92hd73xx_models,
6274 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006275again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006276 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006277 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6278 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006279 else
6280 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006281 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006282
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006283 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006284 conn, STAC92HD73_DAC_COUNT + 2) - 1;
6285
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006286 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006287 printk(KERN_WARNING "hda_codec: Could not determine "
6288 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006289 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006290 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02006291 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006292 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006293 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006294 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006295 break;
6296 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006297 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006298 break;
6299 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006300 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
6301 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006302 }
6303 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006304
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006305 spec->aloopback_mask = 0x01;
6306 spec->aloopback_shift = 8;
6307
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006308 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006309 spec->mux_nids = stac92hd73xx_mux_nids;
6310 spec->adc_nids = stac92hd73xx_adc_nids;
6311 spec->dmic_nids = stac92hd73xx_dmic_nids;
6312 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006313 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006314
6315 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
6316 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01006317 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006318
Takashi Iwai6479c632009-07-28 18:20:25 +02006319 spec->num_caps = STAC92HD73XX_NUM_CAPS;
6320 spec->capvols = stac92hd73xx_capvols;
6321 spec->capsws = stac92hd73xx_capsws;
6322
Matthew Ranostaya7662642008-02-21 07:51:14 +01006323 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006324 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01006325 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006326 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006327 case STAC_DELL_M6_AMIC:
6328 case STAC_DELL_M6_DMIC:
6329 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006330 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006331 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006332
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006333 switch (spec->board_config) {
6334 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01006335 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01006336 spec->num_dmics = 0;
6337 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006338 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01006339 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01006340 spec->num_dmics = 1;
6341 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006342 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01006343 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
6344 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01006345 spec->num_dmics = 1;
6346 break;
6347 }
6348 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02006349 case STAC_ALIENWARE_M17X:
6350 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6351 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6352 spec->eapd_switch = 0;
6353 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006354 default:
6355 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006356 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006357 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02006358 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006359 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006360 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006361 /* GPIO0 High = Enable EAPD */
6362 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6363 spec->gpio_data = 0x01;
6364 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01006365
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006366 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
6367 spec->pwr_nids = stac92hd73xx_pwr_nids;
6368
Charles Chin9009b0e2011-11-03 10:27:27 +01006369 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006370
6371 if (!err) {
6372 if (spec->board_config < 0) {
6373 printk(KERN_WARNING "hda_codec: No auto-config is "
6374 "available, default to model=ref\n");
6375 spec->board_config = STAC_92HD73XX_REF;
6376 goto again;
6377 }
6378 err = -EINVAL;
6379 }
6380
6381 if (err < 0) {
6382 stac92xx_free(codec);
6383 return err;
6384 }
6385
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01006386 if (spec->board_config == STAC_92HD73XX_NO_JD)
6387 spec->hp_detect = 0;
6388
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006389 codec->patch_ops = stac92xx_patch_ops;
6390
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006391 codec->proc_widget_hook = stac92hd7x_proc_hook;
6392
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006393 return 0;
6394}
6395
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006396static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006397{
6398 if (codec->vendor_id != 0x111d7605 &&
6399 codec->vendor_id != 0x111d76d1)
6400 return 0;
6401
6402 switch (codec->subsystem_id) {
6403 case 0x103c1618:
6404 case 0x103c1619:
6405 case 0x103c161a:
6406 case 0x103c161b:
6407 case 0x103c161c:
6408 case 0x103c161d:
6409 case 0x103c161e:
6410 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006411
6412 case 0x103c162a:
6413 case 0x103c162b:
6414
6415 case 0x103c1630:
6416 case 0x103c1631:
6417
6418 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006419 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006420 case 0x103c1635:
6421
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006422 case 0x103c3587:
6423 case 0x103c3588:
6424 case 0x103c3589:
6425 case 0x103c358a:
6426
6427 case 0x103c3667:
6428 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006429 case 0x103c3669:
6430
6431 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006432 }
6433 return 0;
6434}
6435
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006436static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
6437{
6438 struct sigmatel_spec *spec = codec->spec;
6439 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
6440 int i;
6441
6442 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
6443 spec->auto_pin_cnt++;
6444
6445 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
6446 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
6447 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
6448 if (nid == stac92hd83xxx_dmic_nids[i]) {
6449 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
6450 spec->auto_dmic_cnt++;
6451 }
6452 }
6453 }
6454}
6455
6456static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
6457{
6458 struct sigmatel_spec *spec = codec->spec;
6459
6460 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
6461 spec->auto_adc_cnt++;
6462}
6463
6464static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
6465{
6466 int i, j;
6467 struct sigmatel_spec *spec = codec->spec;
6468
6469 for (i = 0; i < spec->auto_adc_cnt; i++) {
6470 if (get_connection_index(codec,
6471 spec->auto_adc_nids[i], nid) >= 0) {
6472 /* mux and volume for adc_nids[i] */
6473 if (!spec->auto_mux_nids[i]) {
6474 spec->auto_mux_nids[i] = nid;
6475 /* 92hd codecs capture volume is in mux */
6476 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
6477 3, 0, HDA_OUTPUT);
6478 }
6479 for (j = 0; j < spec->auto_dmic_cnt; j++) {
6480 if (get_connection_index(codec, nid,
6481 spec->auto_dmic_nids[j]) >= 0) {
6482 /* dmux for adc_nids[i] */
6483 if (!spec->auto_dmux_nids[i])
6484 spec->auto_dmux_nids[i] = nid;
6485 break;
6486 }
6487 }
6488 break;
6489 }
6490 }
6491}
6492
6493static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
6494{
6495 hda_nid_t nid, end_nid;
6496 unsigned int wid_caps, wid_type;
6497 struct sigmatel_spec *spec = codec->spec;
6498
6499 end_nid = codec->start_nid + codec->num_nodes;
6500
6501 for (nid = codec->start_nid; nid < end_nid; nid++) {
6502 wid_caps = get_wcaps(codec, nid);
6503 wid_type = get_wcaps_type(wid_caps);
6504
6505 if (wid_type == AC_WID_PIN)
6506 stac92hd8x_add_pin(codec, nid);
6507
6508 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
6509 stac92hd8x_add_adc(codec, nid);
6510 }
6511
6512 for (nid = codec->start_nid; nid < end_nid; nid++) {
6513 wid_caps = get_wcaps(codec, nid);
6514 wid_type = get_wcaps_type(wid_caps);
6515
6516 if (wid_type == AC_WID_AUD_SEL)
6517 stac92hd8x_add_mux(codec, nid);
6518 }
6519
6520 spec->pin_nids = spec->auto_pin_nids;
6521 spec->num_pins = spec->auto_pin_cnt;
6522 spec->adc_nids = spec->auto_adc_nids;
6523 spec->num_adcs = spec->auto_adc_cnt;
6524 spec->capvols = spec->auto_capvols;
6525 spec->capsws = spec->auto_capvols;
6526 spec->num_caps = spec->auto_adc_cnt;
6527 spec->mux_nids = spec->auto_mux_nids;
6528 spec->num_muxes = spec->auto_adc_cnt;
6529 spec->dmux_nids = spec->auto_dmux_nids;
6530 spec->num_dmuxes = spec->auto_adc_cnt;
6531 spec->dmic_nids = spec->auto_dmic_nids;
6532 spec->num_dmics = spec->auto_dmic_cnt;
6533}
6534
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006535static int patch_stac92hd83xxx(struct hda_codec *codec)
6536{
6537 struct sigmatel_spec *spec;
Takashi Iwaia3e19972012-07-26 08:17:20 +02006538 int default_polarity = -1; /* no default cfg */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006539 int err;
6540
Takashi Iwai361dab32012-05-09 14:35:27 +02006541 err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */
6542 if (err < 0)
6543 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006544
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006545 if (hp_bnb2011_with_dock(codec)) {
6546 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
6547 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
6548 }
6549
Takashi Iwaic36b5b02012-08-28 09:20:13 -07006550 codec->epss = 0; /* longer delay needed for D3 */
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006551 stac92hd8x_fill_auto_spec(codec);
6552
Takashi Iwai361dab32012-05-09 14:35:27 +02006553 spec = codec->spec;
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01006554 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006555 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006556 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006557 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006558 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006559 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006560 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006561
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006562 spec->board_config = snd_hda_check_board_config(codec,
6563 STAC_92HD83XXX_MODELS,
6564 stac92hd83xxx_models,
6565 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006566 /* check codec subsystem id if not found */
6567 if (spec->board_config < 0)
6568 spec->board_config =
6569 snd_hda_check_board_codec_sid_config(codec,
6570 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
6571 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006572again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006573 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006574 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6575 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006576 else
6577 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006578 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006579
Takashi Iwaib4e81872009-11-18 17:20:24 +01006580 codec->patch_ops = stac92xx_patch_ops;
6581
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006582 switch (spec->board_config) {
6583 case STAC_HP_ZEPHYR:
6584 spec->init = stac92hd83xxx_hp_zephyr_init;
6585 break;
Takashi Iwaia3e19972012-07-26 08:17:20 +02006586 case STAC_92HD83XXX_HP_LED:
Takashi Iwaiff8a1e22012-07-31 10:16:59 +02006587 default_polarity = 0;
6588 break;
6589 case STAC_92HD83XXX_HP_INV_LED:
Takashi Iwaia3e19972012-07-26 08:17:20 +02006590 default_polarity = 1;
6591 break;
Takashi Iwai62cbde12012-09-14 11:58:54 +02006592 case STAC_92HD83XXX_HP_MIC_LED:
6593 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
6594 break;
David Henningsson8d032a82012-10-09 12:48:40 +02006595 case STAC_92HD83XXX_HEADSET_JACK:
6596 spec->headset_jack = 1;
6597 break;
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006598 }
6599
Takashi Iwaia3e19972012-07-26 08:17:20 +02006600 if (find_mute_led_cfg(codec, default_polarity))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01006601 snd_printd("mute LED gpio %d polarity %d\n",
6602 spec->gpio_led,
6603 spec->gpio_led_polarity);
6604
Takashi Iwaib4e81872009-11-18 17:20:24 +01006605 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006606 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006607 spec->gpio_mask |= spec->gpio_led;
6608 spec->gpio_dir |= spec->gpio_led;
6609 spec->gpio_data |= spec->gpio_led;
6610 } else {
6611 codec->patch_ops.set_power_state =
6612 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006613 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006614 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006615
Takashi Iwai62cbde12012-09-14 11:58:54 +02006616 if (spec->mic_mute_led_gpio) {
6617 spec->gpio_mask |= spec->mic_mute_led_gpio;
6618 spec->gpio_dir |= spec->mic_mute_led_gpio;
6619 spec->mic_mute_led_on = true;
6620 spec->gpio_data |= spec->mic_mute_led_gpio;
6621 }
6622
Charles Chin9009b0e2011-11-03 10:27:27 +01006623 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006624 if (!err) {
6625 if (spec->board_config < 0) {
6626 printk(KERN_WARNING "hda_codec: No auto-config is "
6627 "available, default to model=ref\n");
6628 spec->board_config = STAC_92HD83XXX_REF;
6629 goto again;
6630 }
6631 err = -EINVAL;
6632 }
6633
6634 if (err < 0) {
6635 stac92xx_free(codec);
6636 return err;
6637 }
6638
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006639 codec->proc_widget_hook = stac92hd_proc_hook;
6640
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006641 return 0;
6642}
6643
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006644static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
6645 hda_nid_t dig0pin)
6646{
6647 struct sigmatel_spec *spec = codec->spec;
6648 int idx;
6649
6650 for (idx = 0; idx < spec->num_pins; idx++)
6651 if (spec->pin_nids[idx] == dig0pin)
6652 break;
6653 if ((idx + 2) >= spec->num_pins)
6654 return 0;
6655
6656 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006657 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006658 return 2;
6659
6660 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006661 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006662 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01006663 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006664 return 1;
6665 else
6666 return 0;
6667}
6668
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006669/* HP dv7 bass switch - GPIO5 */
6670#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
6671static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
6672 struct snd_ctl_elem_value *ucontrol)
6673{
6674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6675 struct sigmatel_spec *spec = codec->spec;
6676 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
6677 return 0;
6678}
6679
6680static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
6681 struct snd_ctl_elem_value *ucontrol)
6682{
6683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6684 struct sigmatel_spec *spec = codec->spec;
6685 unsigned int gpio_data;
6686
6687 gpio_data = (spec->gpio_data & ~0x20) |
6688 (ucontrol->value.integer.value[0] ? 0x20 : 0);
6689 if (gpio_data == spec->gpio_data)
6690 return 0;
6691 spec->gpio_data = gpio_data;
6692 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
6693 return 1;
6694}
6695
Takashi Iwai2b635362011-05-02 12:33:43 +02006696static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6698 .info = stac_hp_bass_gpio_info,
6699 .get = stac_hp_bass_gpio_get,
6700 .put = stac_hp_bass_gpio_put,
6701};
6702
6703static int stac_add_hp_bass_switch(struct hda_codec *codec)
6704{
6705 struct sigmatel_spec *spec = codec->spec;
6706
6707 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
6708 "Bass Speaker Playback Switch", 0))
6709 return -ENOMEM;
6710
6711 spec->gpio_mask |= 0x20;
6712 spec->gpio_dir |= 0x20;
6713 spec->gpio_data |= 0x20;
6714 return 0;
6715}
6716
Matthew Ranostaye035b842007-11-06 11:53:55 +01006717static int patch_stac92hd71bxx(struct hda_codec *codec)
6718{
6719 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02006720 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Takashi Iwai361dab32012-05-09 14:35:27 +02006721 int err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006722
Takashi Iwai361dab32012-05-09 14:35:27 +02006723 err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS,
6724 stac92hd71bxx_pin_nids_4port);
6725 if (err < 0)
6726 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006727
Takashi Iwai361dab32012-05-09 14:35:27 +02006728 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006729 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006730 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006731 switch (codec->vendor_id) {
6732 case 0x111d76b6:
6733 case 0x111d76b7:
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006734 break;
6735 case 0x111d7603:
6736 case 0x111d7608:
6737 /* On 92HD75Bx 0x27 isn't a pin nid */
6738 spec->num_pins--;
6739 /* fallthrough */
6740 default:
6741 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
6742 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006743 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006744
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006745 snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
6746 stac92hd71bxx_fixups);
6747
6748 /* GPIO0 = EAPD */
6749 spec->gpio_mask = 0x01;
6750 spec->gpio_dir = 0x01;
6751 spec->gpio_data = 0x01;
Takashi Iwai41c3b642008-11-18 10:45:15 +01006752
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006753 spec->dmic_nids = stac92hd71bxx_dmic_nids;
6754 spec->dmux_nids = stac92hd71bxx_dmux_nids;
6755
Takashi Iwai6479c632009-07-28 18:20:25 +02006756 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
6757 spec->capvols = stac92hd71bxx_capvols;
6758 spec->capsws = stac92hd71bxx_capsws;
6759
Matthew Ranostay541eee82007-12-14 12:08:04 +01006760 switch (codec->vendor_id) {
6761 case 0x111d76b6: /* 4 Port without Analog Mixer */
6762 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02006763 unmute_init++;
6764 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006765 case 0x111d76b4: /* 6 Port without Analog Mixer */
6766 case 0x111d76b5:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006767 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006768 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006769 stac92hd71bxx_dmic_nids,
6770 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01006771 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006772 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006773 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006774 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006775 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006776
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006777 /* disable VSW */
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006778 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01006779 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
6780 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02006781 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006782 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006783 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006784 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006785 break;
6786 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006787 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006788 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006789
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006790 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006791 default:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006792 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006793 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006794 stac92hd71bxx_dmic_nids,
6795 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02006796 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01006797 }
6798
David Henningsson5e68fb32012-08-16 14:11:09 +02006799 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006800 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
David Henningsson5e68fb32012-08-16 14:11:09 +02006801
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006802 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
6803 snd_hda_sequence_write_cache(codec, unmute_init);
6804
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006805 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04006806 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01006807 spec->aloopback_shift = 0;
6808
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006809 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006810 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006811 spec->mux_nids = stac92hd71bxx_mux_nids;
6812 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006813 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006814 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006815
6816 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
6817 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02006818 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006819 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006820
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006821 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01006822
Takashi Iwai86d190e2009-05-26 15:18:58 +02006823 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006824 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006825 spec->gpio_mask |= spec->gpio_led;
6826 spec->gpio_dir |= spec->gpio_led;
6827 spec->gpio_data |= spec->gpio_led;
6828 } else {
6829 codec->patch_ops.set_power_state =
6830 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006831 }
Takashi Iwai86d190e2009-05-26 15:18:58 +02006832 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04006833
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006834 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006835
Charles Chin9009b0e2011-11-03 10:27:27 +01006836 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006837 if (!err)
Matthew Ranostaye035b842007-11-06 11:53:55 +01006838 err = -EINVAL;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006839 if (err < 0) {
6840 stac92xx_free(codec);
6841 return err;
6842 }
6843
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006844 codec->proc_widget_hook = stac92hd7x_proc_hook;
6845
Takashi Iwai0f6fcb72013-01-14 17:05:25 +01006846 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6847
Matthew Ranostaye035b842007-11-06 11:53:55 +01006848 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006849}
Matthew Ranostaye035b842007-11-06 11:53:55 +01006850
Matt2f2f4252005-04-13 14:45:30 +02006851static int patch_stac922x(struct hda_codec *codec)
6852{
6853 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006854 int err;
Matt2f2f4252005-04-13 14:45:30 +02006855
Takashi Iwai361dab32012-05-09 14:35:27 +02006856 err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids),
6857 stac922x_pin_nids);
6858 if (err < 0)
6859 return err;
Matt2f2f4252005-04-13 14:45:30 +02006860
Takashi Iwai361dab32012-05-09 14:35:27 +02006861 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006862 spec->linear_tone_beep = 1;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02006863
Takashi Iwai0a427842013-01-14 15:20:13 +01006864 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
6865 stac922x_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006866
Matt2f2f4252005-04-13 14:45:30 +02006867 spec->adc_nids = stac922x_adc_nids;
6868 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006869 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006870 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006871 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006872 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02006873
Takashi Iwai6479c632009-07-28 18:20:25 +02006874 spec->num_caps = STAC922X_NUM_CAPS;
6875 spec->capvols = stac922x_capvols;
6876 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02006877
6878 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02006879
Takashi Iwai0a427842013-01-14 15:20:13 +01006880 snd_hda_add_verbs(codec, stac922x_core_init);
6881
6882 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6883
Charles Chin9009b0e2011-11-03 10:27:27 +01006884 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0a427842013-01-14 15:20:13 +01006885 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006886 err = -EINVAL;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006887 if (err < 0) {
6888 stac92xx_free(codec);
6889 return err;
6890 }
6891
6892 codec->patch_ops = stac92xx_patch_ops;
6893
Takashi Iwai807a46362007-05-29 19:01:37 +02006894 /* Fix Mux capture level; max to 2 */
6895 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6896 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6897 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6898 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6899 (0 << AC_AMPCAP_MUTE_SHIFT));
6900
Takashi Iwai0a427842013-01-14 15:20:13 +01006901 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6902
Matt Porter3cc08dc2006-01-23 15:27:49 +01006903 return 0;
6904}
6905
6906static int patch_stac927x(struct hda_codec *codec)
6907{
6908 struct sigmatel_spec *spec;
6909 int err;
6910
Takashi Iwai361dab32012-05-09 14:35:27 +02006911 err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids),
6912 stac927x_pin_nids);
6913 if (err < 0)
6914 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006915
Takashi Iwai361dab32012-05-09 14:35:27 +02006916 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006917 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006918 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwai29ac8362013-01-14 16:03:38 +01006919
6920 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
6921 stac927x_fixups);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006922
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006923 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006924 spec->adc_nids = stac927x_adc_nids;
6925 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6926 spec->mux_nids = stac927x_mux_nids;
6927 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006928 spec->smux_nids = stac927x_smux_nids;
6929 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006930 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006931 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006932 spec->multiout.dac_nids = spec->dac_nids;
6933
Takashi Iwai29ac8362013-01-14 16:03:38 +01006934 /* GPIO0 High = Enable EAPD */
6935 spec->eapd_mask = spec->gpio_mask = 0x01;
6936 spec->gpio_dir = spec->gpio_data = 0x01;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006937
Takashi Iwai29ac8362013-01-14 16:03:38 +01006938 spec->num_dmics = 0;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006939
Takashi Iwai6479c632009-07-28 18:20:25 +02006940 spec->num_caps = STAC927X_NUM_CAPS;
6941 spec->capvols = stac927x_capvols;
6942 spec->capsws = stac927x_capsws;
6943
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006944 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006945 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006946 spec->aloopback_mask = 0x40;
6947 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006948 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006949
Takashi Iwai29ac8362013-01-14 16:03:38 +01006950 if (!spec->volknob_init)
6951 snd_hda_add_verbs(codec, stac927x_core_init);
6952
6953 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6954
Charles Chin9009b0e2011-11-03 10:27:27 +01006955 err = stac92xx_parse_auto_config(codec);
Takashi Iwai29ac8362013-01-14 16:03:38 +01006956 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006957 err = -EINVAL;
Mattc7d4b2f2005-06-27 14:59:41 +02006958 if (err < 0) {
6959 stac92xx_free(codec);
6960 return err;
6961 }
Matt2f2f4252005-04-13 14:45:30 +02006962
6963 codec->patch_ops = stac92xx_patch_ops;
6964
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006965 codec->proc_widget_hook = stac927x_proc_hook;
6966
Takashi Iwai52987652008-01-16 16:09:47 +01006967 /*
6968 * !!FIXME!!
6969 * The STAC927x seem to require fairly long delays for certain
6970 * command sequences. With too short delays (even if the answer
6971 * is set to RIRB properly), it results in the silence output
6972 * on some hardwares like Dell.
6973 *
6974 * The below flag enables the longer delay (see get_response
6975 * in hda_intel.c).
6976 */
6977 codec->bus->needs_damn_long_delay = 1;
6978
Takashi Iwai29ac8362013-01-14 16:03:38 +01006979 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwaie28d8322008-12-17 13:48:29 +01006980
Matt2f2f4252005-04-13 14:45:30 +02006981 return 0;
6982}
6983
Matt Porterf3302a52006-07-31 12:49:34 +02006984static int patch_stac9205(struct hda_codec *codec)
6985{
6986 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006987 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006988
Takashi Iwai361dab32012-05-09 14:35:27 +02006989 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids),
6990 stac9205_pin_nids);
6991 if (err < 0)
6992 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02006993
Takashi Iwai361dab32012-05-09 14:35:27 +02006994 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006995 spec->linear_tone_beep = 1;
Takashi Iwaife6322c2013-01-14 14:46:51 +01006996
6997 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
6998 stac9205_fixups);
Matt Porterf3302a52006-07-31 12:49:34 +02006999
Matthew Ranostay1cd22242008-07-18 18:20:52 +02007000 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02007001 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02007002 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02007003 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01007004 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02007005 spec->smux_nids = stac9205_smux_nids;
7006 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02007007 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02007008 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007009 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01007010 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01007011 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007012
Takashi Iwaife6322c2013-01-14 14:46:51 +01007013 snd_hda_add_verbs(codec, stac9205_core_init);
Takashi Iwaid78d7a92009-03-02 14:26:25 +01007014 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02007015
Takashi Iwai6479c632009-07-28 18:20:25 +02007016 spec->num_caps = STAC9205_NUM_CAPS;
7017 spec->capvols = stac9205_capvols;
7018 spec->capsws = stac9205_capsws;
7019
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007020 spec->aloopback_mask = 0x40;
7021 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02007022 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02007023
Takashi Iwaife6322c2013-01-14 14:46:51 +01007024 /* GPIO0 High = EAPD */
7025 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
7026 spec->gpio_data = 0x01;
Matt Porter33382402006-12-18 13:17:28 +01007027
Takashi Iwaife6322c2013-01-14 14:46:51 +01007028 /* Turn on/off EAPD per HP plugging */
7029 spec->eapd_switch = 1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01007030
Takashi Iwaife6322c2013-01-14 14:46:51 +01007031 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Matthew Ranostay87d48362007-07-17 11:52:24 +02007032
Charles Chin9009b0e2011-11-03 10:27:27 +01007033 err = stac92xx_parse_auto_config(codec);
Takashi Iwaife6322c2013-01-14 14:46:51 +01007034 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01007035 err = -EINVAL;
Matt Porterf3302a52006-07-31 12:49:34 +02007036 if (err < 0) {
7037 stac92xx_free(codec);
7038 return err;
7039 }
7040
7041 codec->patch_ops = stac92xx_patch_ops;
7042
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01007043 codec->proc_widget_hook = stac9205_proc_hook;
7044
Takashi Iwaife6322c2013-01-14 14:46:51 +01007045 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7046
Matt Porterf3302a52006-07-31 12:49:34 +02007047 return 0;
7048}
7049
Matt2f2f4252005-04-13 14:45:30 +02007050/*
Guillaume Munch6d859062006-08-22 17:15:47 +02007051 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01007052 */
7053
Takashi Iwai2b635362011-05-02 12:33:43 +02007054static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02007055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01007056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
7057 {}
7058};
7059
Takashi Iwai2b635362011-05-02 12:33:43 +02007060static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007061 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
7062 0x11, 0x13, 0x14,
7063};
7064
Takashi Iwai2b635362011-05-02 12:33:43 +02007065static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007066 0x8 /*,0x6*/
7067};
7068
Takashi Iwai2b635362011-05-02 12:33:43 +02007069static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007070 0x15
7071};
7072
Takashi Iwai2b635362011-05-02 12:33:43 +02007073static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02007074 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7075};
7076#define stac9872_capsws stac9872_capvols
7077
Takashi Iwaifc268c12013-01-14 14:29:36 +01007078static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
7079 { 0x0a, 0x03211020 },
7080 { 0x0b, 0x411111f0 },
7081 { 0x0c, 0x411111f0 },
7082 { 0x0d, 0x03a15030 },
7083 { 0x0e, 0x411111f0 },
7084 { 0x0f, 0x90170110 },
7085 { 0x11, 0x411111f0 },
7086 { 0x13, 0x411111f0 },
7087 { 0x14, 0x90a7013e },
7088 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007089};
7090
Takashi Iwaifc268c12013-01-14 14:29:36 +01007091static const struct hda_model_fixup stac9872_models[] = {
7092 { .id = STAC_9872_VAIO, .name = "vaio" },
7093 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01007094};
7095
Takashi Iwaifc268c12013-01-14 14:29:36 +01007096static const struct hda_fixup stac9872_fixups[] = {
7097 [STAC_9872_VAIO] = {
7098 .type = HDA_FIXUP_PINS,
7099 .v.pins = stac9872_vaio_pin_configs,
7100 },
Takashi Iwai307282c2009-03-12 18:17:58 +01007101};
7102
Takashi Iwaifc268c12013-01-14 14:29:36 +01007103static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02007104 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
7105 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01007106 {} /* terminator */
7107};
7108
Guillaume Munch6d859062006-08-22 17:15:47 +02007109static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01007110{
7111 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01007112 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01007113
Takashi Iwai361dab32012-05-09 14:35:27 +02007114 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids),
7115 stac9872_pin_nids);
7116 if (err < 0)
7117 return err;
7118
7119 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01007120 spec->linear_tone_beep = 1;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007121
Takashi Iwaifc268c12013-01-14 14:29:36 +01007122 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
7123 stac9872_fixups);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007124
Takashi Iwai1e137f92009-01-21 07:41:22 +01007125 spec->multiout.dac_nids = spec->dac_nids;
7126 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
7127 spec->adc_nids = stac9872_adc_nids;
7128 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
7129 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02007130 spec->num_caps = 1;
7131 spec->capvols = stac9872_capvols;
7132 spec->capsws = stac9872_capsws;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007133 snd_hda_add_verbs(codec, stac9872_core_init);
7134
7135 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007136
Charles Chin9009b0e2011-11-03 10:27:27 +01007137 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01007138 if (err < 0) {
7139 stac92xx_free(codec);
7140 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01007141 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01007142 spec->input_mux = &spec->private_imux;
7143 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007144
7145 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7146
Takashi Iwaidb064e52006-03-16 16:04:58 +01007147 return 0;
7148}
7149
7150
7151/*
Matt2f2f4252005-04-13 14:45:30 +02007152 * patch entries
7153 */
Takashi Iwai2b635362011-05-02 12:33:43 +02007154static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02007155 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
7156 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
7157 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
7158 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
7159 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
7160 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
7161 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02007162 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
7163 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
7164 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
7165 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
7166 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
7167 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01007168 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
7169 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
7170 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
7171 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
7172 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
7173 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
7174 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
7175 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
7176 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
7177 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01007178 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
7179 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
7180 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
7181 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
7182 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
7183 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02007184 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
7185 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02007186 /* The following does not take into account .id=0x83847661 when subsys =
7187 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
7188 * currently not fully supported.
7189 */
7190 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
7191 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
7192 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01007193 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02007194 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
7195 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
7196 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
7197 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
7198 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
7199 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
7200 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
7201 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007202 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007203 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01007204 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007205 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04007206 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02007207 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
7208 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01007209 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
7210 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
7211 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
7212 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007213 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01007214 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
7215 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007216 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01007217 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7218 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7219 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7220 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7221 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7222 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7223 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7224 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02007225 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
7226 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
7227 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
7228 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
7229 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
7230 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
7231 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
7232 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
7233 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
7234 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
7235 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
7236 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
7237 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
7238 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
7239 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02007240 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007241 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06007242 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
7243 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007244 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01007245 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
7246 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
7247 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
7248 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
7249 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
7250 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
7251 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
7252 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
7253 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
7254 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
7255 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
7256 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02007257 {} /* terminator */
7258};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01007259
7260MODULE_ALIAS("snd-hda-codec-id:8384*");
7261MODULE_ALIAS("snd-hda-codec-id:111d*");
7262
7263MODULE_LICENSE("GPL");
7264MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
7265
7266static struct hda_codec_preset_list sigmatel_list = {
7267 .preset = snd_hda_preset_sigmatel,
7268 .owner = THIS_MODULE,
7269};
7270
7271static int __init patch_sigmatel_init(void)
7272{
7273 return snd_hda_add_codec_preset(&sigmatel_list);
7274}
7275
7276static void __exit patch_sigmatel_exit(void)
7277{
7278 snd_hda_delete_codec_preset(&sigmatel_list);
7279}
7280
7281module_init(patch_sigmatel_init)
7282module_exit(patch_sigmatel_exit)