blob: 796dfd1ca235ea28921288cee50e4fb7a84ef57d [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 {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100111 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100112 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100113 STAC_DELL_M4_1,
114 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500115 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400116 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200117 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100118 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100119 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400120 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100121 STAC_92HD71BXX_MODELS
122};
123
124enum {
Tobin Davis8e21c342007-01-08 11:04:17 +0100125 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200126 STAC_M1,
127 STAC_M1_2,
128 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100129 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200130 STAC_M3,
131 STAC_M5,
132 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100133 STAC_925x_MODELS
134};
135
136enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100137 STAC_D945_REF,
138 STAC_D945GTP3,
139 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200140 STAC_INTEL_MAC_V1,
141 STAC_INTEL_MAC_V2,
142 STAC_INTEL_MAC_V3,
143 STAC_INTEL_MAC_V4,
144 STAC_INTEL_MAC_V5,
Takashi Iwai0a427842013-01-14 15:20:13 +0100145 STAC_INTEL_MAC_AUTO,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300146 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200147 STAC_922X_DELL_D81,
148 STAC_922X_DELL_D82,
149 STAC_922X_DELL_M81,
150 STAC_922X_DELL_M82,
Takashi Iwai0a427842013-01-14 15:20:13 +0100151 STAC_922X_INTEL_MAC_GPIO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100152 STAC_922X_MODELS
153};
154
155enum {
Takashi Iwaie28d8322008-12-17 13:48:29 +0100156 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100157 STAC_D965_REF,
158 STAC_D965_3ST,
159 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200160 STAC_D965_5ST_NO_FP,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100161 STAC_D965_VERBS,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200162 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100163 STAC_DELL_BIOS,
Takashi Iwai29ac8362013-01-14 16:03:38 +0100164 STAC_DELL_BIOS_SPDIF,
165 STAC_927X_DELL_DMIC,
Takashi Iwai54930532009-10-11 17:38:29 +0200166 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100167 STAC_927X_MODELS
168};
Matt Porter403d1942005-11-29 15:00:51 +0100169
Takashi Iwai307282c2009-03-12 18:17:58 +0100170enum {
Takashi Iwai307282c2009-03-12 18:17:58 +0100171 STAC_9872_VAIO,
172 STAC_9872_MODELS
173};
174
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200175struct sigmatel_mic_route {
176 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200177 signed char mux_idx;
178 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200179};
180
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600181#define MAX_PINS_NUM 16
182#define MAX_ADCS_NUM 4
183#define MAX_DMICS_NUM 4
184
Matt2f2f4252005-04-13 14:45:30 +0200185struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100186 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200187 unsigned int num_mixers;
188
Matt Porter403d1942005-11-29 15:00:51 +0100189 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500190 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200191 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100192 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100193 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400194 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100195 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200196 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100197 unsigned int linear_tone_beep:1;
David Henningsson8d032a82012-10-09 12:48:40 +0200198 unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
Takashi Iwai29ac8362013-01-14 16:03:38 +0100199 unsigned int volknob_init:1; /* special volume-knob initialization */
Mattc7d4b2f2005-06-27 14:59:41 +0200200
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100201 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200202 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100203 unsigned int gpio_mask;
204 unsigned int gpio_dir;
205 unsigned int gpio_data;
206 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200207 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100208 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100209 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500210 unsigned int vref_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100211
Takashi Iwai62cbde12012-09-14 11:58:54 +0200212 unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
213 bool mic_mute_led_on; /* current mic mute state */
214
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200215 /* stream */
216 unsigned int stream_delay;
217
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100218 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200219 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100220 unsigned char aloopback_mask;
221 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200222
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100223 /* power management */
Takashi Iwaic8822462012-05-15 09:11:36 +0200224 unsigned int power_map_bits;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100225 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200226 const hda_nid_t *pwr_nids;
227 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100228
Matt2f2f4252005-04-13 14:45:30 +0200229 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100230 struct hda_input_mux *mono_mux;
231 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200232 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100233 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100234 hda_nid_t hp_dacs[5];
235 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200236
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100237 int volume_offset;
238
Matt2f2f4252005-04-13 14:45:30 +0200239 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200240 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200241 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200242 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200243 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200244 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200245 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200246 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100247 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200248 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200249 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200250 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200251
Takashi Iwai2b635362011-05-02 12:33:43 +0200252 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
253 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200254 unsigned int num_caps; /* number of capture volume/switch elements */
255
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200256 struct sigmatel_mic_route ext_mic;
257 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200258 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200259
Takashi Iwaiea734962011-01-17 11:29:34 +0100260 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200261
Mattdabbed62005-06-14 10:19:34 +0200262 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100263 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200264 hda_nid_t anabeep_nid;
265 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200266
Matt2f2f4252005-04-13 14:45:30 +0200267 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200268 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200269 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200270
271 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200272 const struct hda_verb *init;
273 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200274
275 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200276 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100277 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200278 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100279 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200280 struct hda_input_mux *sinput_mux;
281 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400282 unsigned int cur_amux;
283 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200284 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200285
Matt Porter403d1942005-11-29 15:00:51 +0100286 /* i/o switches */
287 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200288 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100289 hda_nid_t line_switch; /* shared line-in for input and output */
290 hda_nid_t mic_switch; /* shared mic-in for input and output */
291 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200292 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200293
Mattc7d4b2f2005-06-27 14:59:41 +0200294 struct hda_pcm pcm_rec[2]; /* PCM information */
295
296 /* dynamic controls and input_mux */
297 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200298 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200299 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200300 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200301 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100302 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600303
304 /* auto spec */
305 unsigned auto_pin_cnt;
306 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
307 unsigned auto_adc_cnt;
308 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
309 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
310 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
311 unsigned long auto_capvols[MAX_ADCS_NUM];
312 unsigned auto_dmic_cnt;
313 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100314
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100315 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200316};
317
Takashi Iwaic8822462012-05-15 09:11:36 +0200318#define AC_VERB_IDT_SET_POWER_MAP 0x7ec
319#define AC_VERB_IDT_GET_POWER_MAP 0xfec
320
Takashi Iwai2b635362011-05-02 12:33:43 +0200321static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200322 0x03,
323};
324
Takashi Iwai2b635362011-05-02 12:33:43 +0200325static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200326 0x0c,
327};
328
Takashi Iwai2b635362011-05-02 12:33:43 +0200329static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200330 0x02,
331};
332
Takashi Iwai2b635362011-05-02 12:33:43 +0200333static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100334 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
335 0x0f, 0x10, 0x11
336};
337
Takashi Iwai2b635362011-05-02 12:33:43 +0200338static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400339 0x26, 0,
340};
341
Takashi Iwai2b635362011-05-02 12:33:43 +0200342static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100343 0x1a, 0x1b
344};
345
346#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200347static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100348 0x13, 0x14, 0
349};
350
351#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100352
Takashi Iwai2b635362011-05-02 12:33:43 +0200353static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200354 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100355};
356
Takashi Iwai2b635362011-05-02 12:33:43 +0200357static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100358 0x20, 0x21,
359};
360
Takashi Iwai2b635362011-05-02 12:33:43 +0200361static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200362 0x22, 0x23,
363};
364
Takashi Iwai6479c632009-07-28 18:20:25 +0200365#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200366static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200367 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
368 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
369};
370#define stac92hd73xx_capsws stac92hd73xx_capvols
371
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200372#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200373
Charles Chinafef2cf2011-11-11 08:05:28 +0100374static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
375 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
376 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200377};
378
Takashi Iwai2b635362011-05-02 12:33:43 +0200379static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400380 0x1e, 0,
381};
382
Takashi Iwai2b635362011-05-02 12:33:43 +0200383static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600384 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200385};
386
Takashi Iwai2b635362011-05-02 12:33:43 +0200387static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100388 0x0a, 0x0d, 0x0f
389};
390
Takashi Iwai2b635362011-05-02 12:33:43 +0200391static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100392 0x12, 0x13,
393};
394
Takashi Iwai2b635362011-05-02 12:33:43 +0200395static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100396 0x1a, 0x1b
397};
398
Takashi Iwai2b635362011-05-02 12:33:43 +0200399static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400400 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100401};
402
Takashi Iwai2b635362011-05-02 12:33:43 +0200403static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200404 0x24, 0x25,
405};
406
Matthew Ranostaye035b842007-11-06 11:53:55 +0100407#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200408static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100409 0x18, 0x19, 0
410};
411
Takashi Iwai2b635362011-05-02 12:33:43 +0200412static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
413 0x18, 0
414};
415
416static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400417 0x22, 0
418};
419
Takashi Iwai6479c632009-07-28 18:20:25 +0200420#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200421static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200422 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
423 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
424};
425#define stac92hd71bxx_capsws stac92hd71bxx_capvols
426
Takashi Iwai2b635362011-05-02 12:33:43 +0200427static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100428 0x03,
429};
430
Takashi Iwai2b635362011-05-02 12:33:43 +0200431static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100432 0x0f,
433};
434
Takashi Iwai2b635362011-05-02 12:33:43 +0200435static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100436 0x02,
437};
438
Takashi Iwaif6e98522007-10-16 14:27:04 +0200439#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200440static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200441 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200442};
443
Takashi Iwai2b635362011-05-02 12:33:43 +0200444static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100445 0x14,
446};
447
Takashi Iwai2b635362011-05-02 12:33:43 +0200448static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200449 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
450};
Takashi Iwai2b635362011-05-02 12:33:43 +0200451static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200452 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
453};
454
Takashi Iwai2b635362011-05-02 12:33:43 +0200455static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200456 0x06, 0x07,
457};
458
Takashi Iwai2b635362011-05-02 12:33:43 +0200459static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200460 0x12, 0x13,
461};
462
Takashi Iwai6479c632009-07-28 18:20:25 +0200463#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200464static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200465 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
466 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
467};
468#define stac922x_capsws stac922x_capvols
469
Takashi Iwai2b635362011-05-02 12:33:43 +0200470static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500471 0x1f, 0,
472};
473
Takashi Iwai2b635362011-05-02 12:33:43 +0200474static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100475 0x07, 0x08, 0x09
476};
477
Takashi Iwai2b635362011-05-02 12:33:43 +0200478static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100479 0x15, 0x16, 0x17
480};
481
Takashi Iwai2b635362011-05-02 12:33:43 +0200482static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200483 0x21,
484};
485
Takashi Iwai2b635362011-05-02 12:33:43 +0200486static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100487 0x02, 0x03, 0x04, 0x05, 0x06, 0
488};
489
Takashi Iwai2b635362011-05-02 12:33:43 +0200490static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100491 0x1b,
492};
493
Matthew Ranostay7f168592007-10-18 17:38:17 +0200494#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200495static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200496 0x13, 0x14, 0
497};
498
Takashi Iwai6479c632009-07-28 18:20:25 +0200499#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200500static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200501 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
502 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
503 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
504};
Takashi Iwai2b635362011-05-02 12:33:43 +0200505static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200506 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
507 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
508 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
509};
510
Takashi Iwaiea734962011-01-17 11:29:34 +0100511static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400512 "Digital Playback", "ADAT", "Analog Mux 1",
513 "Analog Mux 2", "Analog Mux 3"
514};
515
Takashi Iwai2b635362011-05-02 12:33:43 +0200516static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200517 0x12, 0x13
518};
519
Takashi Iwai2b635362011-05-02 12:33:43 +0200520static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200521 0x19, 0x1a
522};
523
Takashi Iwai2b635362011-05-02 12:33:43 +0200524static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100525 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100526};
527
Takashi Iwai2b635362011-05-02 12:33:43 +0200528static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200529 0x21,
530};
531
Takashi Iwaif6e98522007-10-16 14:27:04 +0200532#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200533static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200534 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200535};
536
Takashi Iwai6479c632009-07-28 18:20:25 +0200537#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200538static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200539 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
540 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
541};
Takashi Iwai2b635362011-05-02 12:33:43 +0200542static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200543 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
544 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
545};
546
Takashi Iwai2b635362011-05-02 12:33:43 +0200547static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200548 0x08, 0x09, 0x0d, 0x0e,
549 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200550};
551
Takashi Iwai2b635362011-05-02 12:33:43 +0200552static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100553 0x07, 0x08, 0x0a, 0x0b,
554 0x0c, 0x0d, 0x10, 0x11,
555};
556
Takashi Iwai2b635362011-05-02 12:33:43 +0200557static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200558 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
559 0x0f, 0x10, 0x11, 0x15, 0x1b,
560};
561
Takashi Iwai2b635362011-05-02 12:33:43 +0200562static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100563 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
564 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200565 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100566};
567
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500568#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200569static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500570 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
571 0x00, 0x14, 0x18, 0x19, 0x1e,
572 0x1f, 0x20, 0x27
573};
Takashi Iwai2b635362011-05-02 12:33:43 +0200574static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100575 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
576 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500577 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100578};
579
Takashi Iwai2b635362011-05-02 12:33:43 +0200580static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100581 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
582 0x0f, 0x10, 0x11, 0x12, 0x13,
583 0x14, 0x21, 0x22, 0x23,
584};
585
Takashi Iwai2b635362011-05-02 12:33:43 +0200586static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200587 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
588 0x0f, 0x14, 0x16, 0x17, 0x18,
589 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200590};
591
Matt Porter8b657272006-10-26 17:12:59 +0200592static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_info *uinfo)
594{
595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
596 struct sigmatel_spec *spec = codec->spec;
597 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
598}
599
600static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
601 struct snd_ctl_elem_value *ucontrol)
602{
603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
604 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100605 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200606
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100607 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200608 return 0;
609}
610
611static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_value *ucontrol)
613{
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100616 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200617
618 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100619 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200620}
621
Matthew Ranostayd9737752008-09-07 12:03:41 +0200622static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_info *uinfo)
624{
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 struct sigmatel_spec *spec = codec->spec;
627 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
628}
629
630static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 struct sigmatel_spec *spec = codec->spec;
635 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
636
637 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
638 return 0;
639}
640
641static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400646 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200647 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400648 int err, val;
649 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200650
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400651 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200652 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400653 if (err < 0)
654 return err;
655
656 if (spec->spdif_mute) {
657 if (smux_idx == 0)
658 nid = spec->multiout.dig_out_nid;
659 else
660 nid = codec->slave_dig_outs[smux_idx - 1];
661 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100662 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400663 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100664 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400665 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100666 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
667 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400668 }
669 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200670}
671
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500672static int stac_vrefout_set(struct hda_codec *codec,
673 hda_nid_t nid, unsigned int new_vref)
674{
675 int error, pinctl;
676
677 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
678 pinctl = snd_hda_codec_read(codec, nid, 0,
679 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
680
681 if (pinctl < 0)
682 return pinctl;
683
684 pinctl &= 0xff;
685 pinctl &= ~AC_PINCTL_VREFEN;
686 pinctl |= (new_vref & AC_PINCTL_VREFEN);
687
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200688 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500689 if (error < 0)
690 return error;
691
692 return 1;
693}
694
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200695static unsigned int stac92xx_vref_set(struct hda_codec *codec,
696 hda_nid_t nid, unsigned int new_vref)
697{
Takashi Iwaib8621512009-06-22 08:00:10 +0200698 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200699 unsigned int pincfg;
700 pincfg = snd_hda_codec_read(codec, nid, 0,
701 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
702
703 pincfg &= 0xff;
704 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
705 pincfg |= new_vref;
706
707 if (new_vref == AC_PINCTL_VREF_HIZ)
708 pincfg |= AC_PINCTL_OUT_EN;
709 else
710 pincfg |= AC_PINCTL_IN_EN;
711
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200712 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200713 if (error < 0)
714 return error;
715 else
716 return 1;
717}
718
719static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
720{
721 unsigned int vref;
722 vref = snd_hda_codec_read(codec, nid, 0,
723 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
724 vref &= AC_PINCTL_VREFEN;
725 return vref;
726}
727
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100728static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200729{
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200732 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200733}
734
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100735static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200736{
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
740
741 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
742 return 0;
743}
744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100745static int stac92xx_mux_enum_put(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);
Takashi Iwai5207e102009-07-30 13:09:08 +0200750 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600751 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200752
Takashi Iwai5207e102009-07-30 13:09:08 +0200753 idx = ucontrol->value.enumerated.item[0];
754 if (idx >= imux->num_items)
755 idx = imux->num_items - 1;
756 prev_idx = spec->cur_mux[adc_idx];
757 if (prev_idx == idx)
758 return 0;
759 if (idx < spec->num_analog_muxes) {
760 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
761 AC_VERB_SET_CONNECT_SEL,
762 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600763 if (prev_idx >= spec->num_analog_muxes &&
764 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200765 imux = spec->dinput_mux;
766 /* 0 = analog */
767 snd_hda_codec_write_cache(codec,
768 spec->dmux_nids[adc_idx], 0,
769 AC_VERB_SET_CONNECT_SEL,
770 imux->items[0].index);
771 }
772 } else {
773 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600774 /* first dimux item is hardcoded to select analog imux,
775 * so lets skip it
776 */
777 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200778 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
779 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600780 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200781 }
782 spec->cur_mux[adc_idx] = idx;
783 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200784}
785
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100786static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
787 struct snd_ctl_elem_info *uinfo)
788{
789 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
790 struct sigmatel_spec *spec = codec->spec;
791 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
792}
793
794static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
796{
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 struct sigmatel_spec *spec = codec->spec;
799
800 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
801 return 0;
802}
803
804static int stac92xx_mono_mux_enum_put(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 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
811 spec->mono_nid, &spec->cur_mmux);
812}
813
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200814#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
815
816static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
817 struct snd_ctl_elem_value *ucontrol)
818{
819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100820 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200821 struct sigmatel_spec *spec = codec->spec;
822
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100823 ucontrol->value.integer.value[0] = !!(spec->aloopback &
824 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200825 return 0;
826}
827
828static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
829 struct snd_ctl_elem_value *ucontrol)
830{
831 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
832 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200834 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100835 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200836
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 idx_val = spec->aloopback_mask << idx;
838 if (ucontrol->value.integer.value[0])
839 val = spec->aloopback | idx_val;
840 else
841 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100842 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200843 return 0;
844
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100845 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200846
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100847 /* Only return the bits defined by the shift value of the
848 * first two bytes of the mask
849 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200850 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100851 kcontrol->private_value & 0xFFFF, 0x0);
852 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200853
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100854 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200855 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100856 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200857 } else {
858 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100859 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200860 }
861
862 snd_hda_codec_write_cache(codec, codec->afg, 0,
863 kcontrol->private_value >> 16, dac_mode);
864
865 return 1;
866}
867
Takashi Iwai2b635362011-05-02 12:33:43 +0200868static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200869 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200870 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200871 {}
872};
873
Takashi Iwai2b635362011-05-02 12:33:43 +0200874static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200875 /* set dac0mux for dac converter */
876 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
877 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
878 {}
879};
880
Takashi Iwai2b635362011-05-02 12:33:43 +0200881static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100882 /* set master volume to max value without distortion
883 * and direct control */
884 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100885 {}
886};
887
Takashi Iwai2b635362011-05-02 12:33:43 +0200888static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100889 /* set master volume and direct control */
890 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100891 {}
892};
893
Takashi Iwai2b635362011-05-02 12:33:43 +0200894static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200895 /* power state controls amps */
896 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200897 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200898};
899
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600900static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
901 { 0x22, 0x785, 0x43 },
902 { 0x22, 0x782, 0xe0 },
903 { 0x22, 0x795, 0x00 },
904 {}
905};
906
Takashi Iwai2b635362011-05-02 12:33:43 +0200907static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100908 /* set master volume and direct control */
909 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200910 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100911};
912
Takashi Iwai2b635362011-05-02 12:33:43 +0200913static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500914 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
915 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100916 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
917 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100918 {}
919};
920
Takashi Iwai2b635362011-05-02 12:33:43 +0200921static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100922 /* set dac0mux for dac converter */
923 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100924 /* mute the master volume */
925 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100926 {}
927};
928
Takashi Iwai2b635362011-05-02 12:33:43 +0200929static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200930 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200931 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200932 {}
933};
934
Takashi Iwai2b635362011-05-02 12:33:43 +0200935static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200936 /* unmute node 0x1b */
937 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
938 /* select node 0x03 as DAC */
939 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
940 {}
941};
942
Takashi Iwai2b635362011-05-02 12:33:43 +0200943static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200944 /* don't set delta bit */
945 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
946 /* 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 stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100954 /* set master volume and direct control */
955 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200956 /* enable analog pc beep path */
957 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100958 {}
959};
960
Takashi Iwai2b635362011-05-02 12:33:43 +0200961static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200962 /* don't set delta bit */
963 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
964 /* enable analog pc beep path */
965 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
966 {}
967};
968
Takashi Iwai2b635362011-05-02 12:33:43 +0200969static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200970 /* set master volume and direct control */
971 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200972 /* enable analog pc beep path */
973 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200974 {}
975};
976
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100977#define STAC_MONO_MUX \
978 { \
979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
980 .name = "Mono Mux", \
981 .count = 1, \
982 .info = stac92xx_mono_mux_enum_info, \
983 .get = stac92xx_mono_mux_enum_get, \
984 .put = stac92xx_mono_mux_enum_put, \
985 }
986
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100987#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200988 { \
989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
990 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100991 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200992 .info = stac92xx_aloopback_info, \
993 .get = stac92xx_aloopback_get, \
994 .put = stac92xx_aloopback_put, \
995 .private_value = verb_read | (verb_write << 16), \
996 }
997
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200998#define DC_BIAS(xname, idx, nid) \
999 { \
1000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1001 .name = xname, \
1002 .index = idx, \
1003 .info = stac92xx_dc_bias_info, \
1004 .get = stac92xx_dc_bias_get, \
1005 .put = stac92xx_dc_bias_put, \
1006 .private_value = nid, \
1007 }
1008
Takashi Iwai2b635362011-05-02 12:33:43 +02001009static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001010 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001012 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001014 { } /* end */
1015};
1016
Takashi Iwai2b635362011-05-02 12:33:43 +02001017static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001018 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1019 {}
1020};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001021
Takashi Iwai2b635362011-05-02 12:33:43 +02001022static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001023 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1024 {}
1025};
1026
Takashi Iwai2b635362011-05-02 12:33:43 +02001027static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1029 {}
1030};
1031
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001032
Takashi Iwai2b635362011-05-02 12:33:43 +02001033static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001034 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1035};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001036
Takashi Iwai2b635362011-05-02 12:33:43 +02001037static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001038 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1039 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001040 { } /* end */
1041};
1042
Takashi Iwai2b635362011-05-02 12:33:43 +02001043static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001044 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1045 {}
1046};
1047
Takashi Iwai2b635362011-05-02 12:33:43 +02001048static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001049 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1050 {}
1051};
1052
Takashi Iwai1697055e2007-12-18 18:05:52 +01001053static struct snd_kcontrol_new stac_dmux_mixer = {
1054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1055 .name = "Digital Input Source",
1056 /* count set later */
1057 .info = stac92xx_dmux_enum_info,
1058 .get = stac92xx_dmux_enum_get,
1059 .put = stac92xx_dmux_enum_put,
1060};
1061
Matthew Ranostayd9737752008-09-07 12:03:41 +02001062static struct snd_kcontrol_new stac_smux_mixer = {
1063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001064 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001065 /* count set later */
1066 .info = stac92xx_smux_enum_info,
1067 .get = stac92xx_smux_enum_get,
1068 .put = stac92xx_smux_enum_put,
1069};
1070
Takashi Iwai9322ca52012-02-03 14:28:01 +01001071static const char * const slave_pfxs[] = {
1072 "Front", "Surround", "Center", "LFE", "Side",
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01001073 "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001074 NULL
1075};
1076
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001077static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1078
1079static void stac92xx_vmaster_hook(void *private_data, int val)
1080{
1081 stac92xx_update_led_status(private_data, val);
1082}
1083
Takashi Iwai603c4012008-07-30 15:01:44 +02001084static void stac92xx_free_kctls(struct hda_codec *codec);
1085
Matt2f2f4252005-04-13 14:45:30 +02001086static int stac92xx_build_controls(struct hda_codec *codec)
1087{
1088 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001089 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001090 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001091 int i;
Matt2f2f4252005-04-13 14:45:30 +02001092
Takashi Iwai6479c632009-07-28 18:20:25 +02001093 if (spec->mixer) {
1094 err = snd_hda_add_new_ctls(codec, spec->mixer);
1095 if (err < 0)
1096 return err;
1097 }
Mattc7d4b2f2005-06-27 14:59:41 +02001098
1099 for (i = 0; i < spec->num_mixers; i++) {
1100 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1101 if (err < 0)
1102 return err;
1103 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001104 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1105 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001106 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001107 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001108 snd_ctl_new1(&stac_dmux_mixer, codec));
1109 if (err < 0)
1110 return err;
1111 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001112 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001113 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1114 struct hda_input_mux *smux = &spec->private_smux;
1115 /* check for mute support on SPDIF out */
1116 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001117 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001118 spec->spdif_mute = 1;
1119 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001120 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001121 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001122 snd_ctl_new1(&stac_smux_mixer, codec));
1123 if (err < 0)
1124 return err;
1125 }
Mattc7d4b2f2005-06-27 14:59:41 +02001126
Mattdabbed62005-06-14 10:19:34 +02001127 if (spec->multiout.dig_out_nid) {
Takashi Iwaidcda5802012-10-12 17:24:51 +02001128 err = snd_hda_create_dig_out_ctls(codec,
1129 spec->multiout.dig_out_nid,
1130 spec->multiout.dig_out_nid,
1131 spec->autocfg.dig_out_type[0]);
Mattdabbed62005-06-14 10:19:34 +02001132 if (err < 0)
1133 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001134 err = snd_hda_create_spdif_share_sw(codec,
1135 &spec->multiout);
1136 if (err < 0)
1137 return err;
1138 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001139 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001140 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001141 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1142 if (err < 0)
1143 return err;
1144 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001145
1146 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001147 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1148 HDA_OUTPUT, vmaster_tlv);
1149 /* correct volume offset */
1150 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1151 /* minimum value is actually mute */
1152 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1153 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1154 vmaster_tlv, slave_pfxs,
1155 "Playback Volume");
1156 if (err < 0)
1157 return err;
1158
1159 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1160 NULL, slave_pfxs,
1161 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001162 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001163 if (err < 0)
1164 return err;
1165
1166 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001167 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001168 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001169 if (err < 0)
1170 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001171 }
1172
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001173 if (spec->aloopback_ctl &&
1174 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1175 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1176 if (err < 0)
1177 return err;
1178 }
1179
Takashi Iwai603c4012008-07-30 15:01:44 +02001180 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001181
Takashi Iwai01a61e12011-10-28 00:03:22 +02001182 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1183 if (err < 0)
1184 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001185
Mattdabbed62005-06-14 10:19:34 +02001186 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001187}
1188
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001189static const struct hda_pintbl ref9200_pin_configs[] = {
1190 { 0x08, 0x01c47010 },
1191 { 0x09, 0x01447010 },
1192 { 0x0d, 0x0221401f },
1193 { 0x0e, 0x01114010 },
1194 { 0x0f, 0x02a19020 },
1195 { 0x10, 0x01a19021 },
1196 { 0x11, 0x90100140 },
1197 { 0x12, 0x01813122 },
1198 {}
Matt2f2f4252005-04-13 14:45:30 +02001199};
1200
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001201static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1202 { 0x08, 0x400000fe },
1203 { 0x09, 0x404500f4 },
1204 { 0x0d, 0x400100f0 },
1205 { 0x0e, 0x90110010 },
1206 { 0x0f, 0x400100f1 },
1207 { 0x10, 0x02a1902e },
1208 { 0x11, 0x500000f2 },
1209 { 0x12, 0x500000f3 },
1210 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001211};
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001212
1213static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1214 { 0x08, 0x400000fe },
1215 { 0x09, 0x404500f4 },
1216 { 0x0d, 0x400100f0 },
1217 { 0x0e, 0x90110010 },
1218 { 0x0f, 0x400100f1 },
1219 { 0x10, 0x02a1902e },
1220 { 0x11, 0x500000f2 },
1221 { 0x12, 0x500000f3 },
1222 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001223};
1224
1225/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001226 STAC 9200 pin configs for
1227 102801A8
1228 102801DE
1229 102801E8
1230*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001231static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1232 { 0x08, 0x400001f0 },
1233 { 0x09, 0x400001f1 },
1234 { 0x0d, 0x02214030 },
1235 { 0x0e, 0x01014010 },
1236 { 0x0f, 0x02a19020 },
1237 { 0x10, 0x01a19021 },
1238 { 0x11, 0x90100140 },
1239 { 0x12, 0x01813122 },
1240 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001241};
1242
1243/*
1244 STAC 9200 pin configs for
1245 102801C0
1246 102801C1
1247*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001248static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1249 { 0x08, 0x400001f0 },
1250 { 0x09, 0x400001f1 },
1251 { 0x0d, 0x0221401f },
1252 { 0x0e, 0x01014010 },
1253 { 0x0f, 0x01813020 },
1254 { 0x10, 0x02a19021 },
1255 { 0x11, 0x90100140 },
1256 { 0x12, 0x400001f2 },
1257 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001258};
1259
1260/*
1261 STAC 9200 pin configs for
1262 102801C4 (Dell Dimension E310)
1263 102801C5
1264 102801C7
1265 102801D9
1266 102801DA
1267 102801E3
1268*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001269static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1270 { 0x08, 0x400001f0 },
1271 { 0x09, 0x400001f1 },
1272 { 0x0d, 0x0221401f },
1273 { 0x0e, 0x01014010 },
1274 { 0x0f, 0x01813020 },
1275 { 0x10, 0x01a19021 },
1276 { 0x11, 0x90100140 },
1277 { 0x12, 0x400001f2 },
1278 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001279};
1280
1281
1282/*
1283 STAC 9200-32 pin configs for
1284 102801B5 (Dell Inspiron 630m)
1285 102801D8 (Dell Inspiron 640m)
1286*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001287static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1288 { 0x08, 0x40c003fa },
1289 { 0x09, 0x03441340 },
1290 { 0x0d, 0x0321121f },
1291 { 0x0e, 0x90170310 },
1292 { 0x0f, 0x408003fb },
1293 { 0x10, 0x03a11020 },
1294 { 0x11, 0x401003fc },
1295 { 0x12, 0x403003fd },
1296 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001297};
1298
1299/*
1300 STAC 9200-32 pin configs for
1301 102801C2 (Dell Latitude D620)
1302 102801C8
1303 102801CC (Dell Latitude D820)
1304 102801D4
1305 102801D6
1306*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001307static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1308 { 0x08, 0x40c003fa },
1309 { 0x09, 0x0144131f },
1310 { 0x0d, 0x0321121f },
1311 { 0x0e, 0x90170310 },
1312 { 0x0f, 0x90a70321 },
1313 { 0x10, 0x03a11020 },
1314 { 0x11, 0x401003fb },
1315 { 0x12, 0x40f000fc },
1316 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001317};
1318
1319/*
1320 STAC 9200-32 pin configs for
1321 102801CE (Dell XPS M1710)
1322 102801CF (Dell Precision M90)
1323*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001324static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1325 { 0x08, 0x40c003fa },
1326 { 0x09, 0x01441340 },
1327 { 0x0d, 0x0421421f },
1328 { 0x0e, 0x90170310 },
1329 { 0x0f, 0x408003fb },
1330 { 0x10, 0x04a1102e },
1331 { 0x11, 0x90170311 },
1332 { 0x12, 0x403003fc },
1333 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001334};
1335
1336/*
1337 STAC 9200-32 pin configs for
1338 102801C9
1339 102801CA
1340 102801CB (Dell Latitude 120L)
1341 102801D3
1342*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001343static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1344 { 0x08, 0x40c003fa },
1345 { 0x09, 0x404003fb },
1346 { 0x0d, 0x0321121f },
1347 { 0x0e, 0x90170310 },
1348 { 0x0f, 0x408003fc },
1349 { 0x10, 0x03a11020 },
1350 { 0x11, 0x401003fd },
1351 { 0x12, 0x403003fe },
1352 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001353};
1354
1355/*
1356 STAC 9200-32 pin configs for
1357 102801BD (Dell Inspiron E1505n)
1358 102801EE
1359 102801EF
1360*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001361static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1362 { 0x08, 0x40c003fa },
1363 { 0x09, 0x01441340 },
1364 { 0x0d, 0x0421121f },
1365 { 0x0e, 0x90170310 },
1366 { 0x0f, 0x408003fb },
1367 { 0x10, 0x04a11020 },
1368 { 0x11, 0x401003fc },
1369 { 0x12, 0x403003fd },
1370 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001371};
1372
1373/*
1374 STAC 9200-32 pin configs for
1375 102801F5 (Dell Inspiron 1501)
1376 102801F6
1377*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001378static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1379 { 0x08, 0x40c003fa },
1380 { 0x09, 0x404003fb },
1381 { 0x0d, 0x0421121f },
1382 { 0x0e, 0x90170310 },
1383 { 0x0f, 0x408003fc },
1384 { 0x10, 0x04a11020 },
1385 { 0x11, 0x401003fd },
1386 { 0x12, 0x403003fe },
1387 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001388};
1389
1390/*
1391 STAC 9200-32
1392 102801CD (Dell Inspiron E1705/9400)
1393*/
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001394static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1395 { 0x08, 0x40c003fa },
1396 { 0x09, 0x01441340 },
1397 { 0x0d, 0x0421121f },
1398 { 0x0e, 0x90170310 },
1399 { 0x0f, 0x90170310 },
1400 { 0x10, 0x04a11020 },
1401 { 0x11, 0x90170310 },
1402 { 0x12, 0x40f003fc },
1403 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001404};
1405
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001406static const struct hda_pintbl oqo9200_pin_configs[] = {
1407 { 0x08, 0x40c000f0 },
1408 { 0x09, 0x404000f1 },
1409 { 0x0d, 0x0221121f },
1410 { 0x0e, 0x02211210 },
1411 { 0x0f, 0x90170111 },
1412 { 0x10, 0x90a70120 },
1413 { 0x11, 0x400000f2 },
1414 { 0x12, 0x400000f3 },
1415 {}
Tobin Davisbf277782008-02-03 20:31:47 +01001416};
1417
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001418
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001419static void stac9200_fixup_panasonic(struct hda_codec *codec,
1420 const struct hda_fixup *fix, int action)
1421{
1422 struct sigmatel_spec *spec = codec->spec;
1423
1424 switch (action) {
1425 case HDA_FIXUP_ACT_PRE_PROBE:
1426 spec->gpio_mask = spec->gpio_dir = 0x09;
1427 spec->gpio_data = 0x00;
1428 break;
1429 case HDA_FIXUP_ACT_PROBE:
1430 /* CF-74 has no headphone detection, and the driver should *NOT*
1431 * do detection and HP/speaker toggle because the hardware does it.
1432 */
1433 spec->hp_detect = 0;
1434 break;
1435 }
1436}
1437
1438
1439static const struct hda_fixup stac9200_fixups[] = {
1440 [STAC_REF] = {
1441 .type = HDA_FIXUP_PINS,
1442 .v.pins = ref9200_pin_configs,
1443 },
1444 [STAC_9200_OQO] = {
1445 .type = HDA_FIXUP_PINS,
1446 .v.pins = oqo9200_pin_configs,
1447 .chained = true,
1448 .chain_id = STAC_9200_EAPD_INIT,
1449 },
1450 [STAC_9200_DELL_D21] = {
1451 .type = HDA_FIXUP_PINS,
1452 .v.pins = dell9200_d21_pin_configs,
1453 },
1454 [STAC_9200_DELL_D22] = {
1455 .type = HDA_FIXUP_PINS,
1456 .v.pins = dell9200_d22_pin_configs,
1457 },
1458 [STAC_9200_DELL_D23] = {
1459 .type = HDA_FIXUP_PINS,
1460 .v.pins = dell9200_d23_pin_configs,
1461 },
1462 [STAC_9200_DELL_M21] = {
1463 .type = HDA_FIXUP_PINS,
1464 .v.pins = dell9200_m21_pin_configs,
1465 },
1466 [STAC_9200_DELL_M22] = {
1467 .type = HDA_FIXUP_PINS,
1468 .v.pins = dell9200_m22_pin_configs,
1469 },
1470 [STAC_9200_DELL_M23] = {
1471 .type = HDA_FIXUP_PINS,
1472 .v.pins = dell9200_m23_pin_configs,
1473 },
1474 [STAC_9200_DELL_M24] = {
1475 .type = HDA_FIXUP_PINS,
1476 .v.pins = dell9200_m24_pin_configs,
1477 },
1478 [STAC_9200_DELL_M25] = {
1479 .type = HDA_FIXUP_PINS,
1480 .v.pins = dell9200_m25_pin_configs,
1481 },
1482 [STAC_9200_DELL_M26] = {
1483 .type = HDA_FIXUP_PINS,
1484 .v.pins = dell9200_m26_pin_configs,
1485 },
1486 [STAC_9200_DELL_M27] = {
1487 .type = HDA_FIXUP_PINS,
1488 .v.pins = dell9200_m27_pin_configs,
1489 },
1490 [STAC_9200_M4] = {
1491 .type = HDA_FIXUP_PINS,
1492 .v.pins = gateway9200_m4_pin_configs,
1493 .chained = true,
1494 .chain_id = STAC_9200_EAPD_INIT,
1495 },
1496 [STAC_9200_M4_2] = {
1497 .type = HDA_FIXUP_PINS,
1498 .v.pins = gateway9200_m4_2_pin_configs,
1499 .chained = true,
1500 .chain_id = STAC_9200_EAPD_INIT,
1501 },
1502 [STAC_9200_PANASONIC] = {
1503 .type = HDA_FIXUP_FUNC,
1504 .v.func = stac9200_fixup_panasonic,
1505 },
1506 [STAC_9200_EAPD_INIT] = {
1507 .type = HDA_FIXUP_VERBS,
1508 .v.verbs = (const struct hda_verb[]) {
1509 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1510 {}
1511 },
1512 },
Matt Porter403d1942005-11-29 15:00:51 +01001513};
1514
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001515static const struct hda_model_fixup stac9200_models[] = {
1516 { .id = STAC_REF, .name = "ref" },
1517 { .id = STAC_9200_OQO, .name = "oqo" },
1518 { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1519 { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1520 { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1521 { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1522 { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1523 { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1524 { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1525 { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1526 { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1527 { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1528 { .id = STAC_9200_M4, .name = "gateway-m4" },
1529 { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1530 { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1531 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001532};
1533
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01001534static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001535 /* SigmaTel reference board */
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1537 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001538 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1539 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001540 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1542 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001544 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1546 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1548 "unknown Dell", STAC_9200_DELL_D22),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1550 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001552 "Dell Latitude D620", STAC_9200_DELL_M22),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1554 "unknown Dell", STAC_9200_DELL_D23),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1556 "unknown Dell", STAC_9200_DELL_D23),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1558 "unknown Dell", STAC_9200_DELL_M22),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1560 "unknown Dell", STAC_9200_DELL_M24),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1562 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001564 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001566 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001568 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001570 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001572 "Dell Precision M90", STAC_9200_DELL_M23),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1574 "unknown Dell", STAC_9200_DELL_M22),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1576 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001578 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001580 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1582 "unknown Dell", STAC_9200_DELL_D23),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1584 "unknown Dell", STAC_9200_DELL_D23),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1586 "unknown Dell", STAC_9200_DELL_D21),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1588 "unknown Dell", STAC_9200_DELL_D23),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1590 "unknown Dell", STAC_9200_DELL_D21),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1592 "unknown Dell", STAC_9200_DELL_M25),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1594 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001596 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1598 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001599 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001600 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001601 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001602 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1603 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1604 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001605 /* OQO Mobile */
1606 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001607 {} /* terminator */
1608};
1609
Takashi Iwaid2077d42013-01-14 14:20:16 +01001610static const struct hda_pintbl ref925x_pin_configs[] = {
1611 { 0x07, 0x40c003f0 },
1612 { 0x08, 0x424503f2 },
1613 { 0x0a, 0x01813022 },
1614 { 0x0b, 0x02a19021 },
1615 { 0x0c, 0x90a70320 },
1616 { 0x0d, 0x02214210 },
1617 { 0x10, 0x01019020 },
1618 { 0x11, 0x9033032e },
1619 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001620};
1621
Takashi Iwaid2077d42013-01-14 14:20:16 +01001622static const struct hda_pintbl stac925xM1_pin_configs[] = {
1623 { 0x07, 0x40c003f4 },
1624 { 0x08, 0x424503f2 },
1625 { 0x0a, 0x400000f3 },
1626 { 0x0b, 0x02a19020 },
1627 { 0x0c, 0x40a000f0 },
1628 { 0x0d, 0x90100210 },
1629 { 0x10, 0x400003f1 },
1630 { 0x11, 0x9033032e },
1631 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001632};
1633
Takashi Iwaid2077d42013-01-14 14:20:16 +01001634static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1635 { 0x07, 0x40c003f4 },
1636 { 0x08, 0x424503f2 },
1637 { 0x0a, 0x400000f3 },
1638 { 0x0b, 0x02a19020 },
1639 { 0x0c, 0x40a000f0 },
1640 { 0x0d, 0x90100210 },
1641 { 0x10, 0x400003f1 },
1642 { 0x11, 0x9033032e },
1643 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001644};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001645
Takashi Iwaid2077d42013-01-14 14:20:16 +01001646static const struct hda_pintbl stac925xM2_pin_configs[] = {
1647 { 0x07, 0x40c003f4 },
1648 { 0x08, 0x424503f2 },
1649 { 0x0a, 0x400000f3 },
1650 { 0x0b, 0x02a19020 },
1651 { 0x0c, 0x40a000f0 },
1652 { 0x0d, 0x90100210 },
1653 { 0x10, 0x400003f1 },
1654 { 0x11, 0x9033032e },
1655 {}
Tobin Davis2c11f952007-05-17 09:36:34 +02001656};
1657
Takashi Iwaid2077d42013-01-14 14:20:16 +01001658static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1659 { 0x07, 0x40c003f4 },
1660 { 0x08, 0x424503f2 },
1661 { 0x0a, 0x400000f3 },
1662 { 0x0b, 0x02a19020 },
1663 { 0x0c, 0x40a000f0 },
1664 { 0x0d, 0x90100210 },
1665 { 0x10, 0x400003f1 },
1666 { 0x11, 0x9033032e },
1667 {}
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001668};
1669
Takashi Iwaid2077d42013-01-14 14:20:16 +01001670static const struct hda_pintbl stac925xM3_pin_configs[] = {
1671 { 0x07, 0x40c003f4 },
1672 { 0x08, 0x424503f2 },
1673 { 0x0a, 0x400000f3 },
1674 { 0x0b, 0x02a19020 },
1675 { 0x0c, 0x40a000f0 },
1676 { 0x0d, 0x90100210 },
1677 { 0x10, 0x400003f1 },
1678 { 0x11, 0x503303f3 },
1679 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001680};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001681
Takashi Iwaid2077d42013-01-14 14:20:16 +01001682static const struct hda_pintbl stac925xM5_pin_configs[] = {
1683 { 0x07, 0x40c003f4 },
1684 { 0x08, 0x424503f2 },
1685 { 0x0a, 0x400000f3 },
1686 { 0x0b, 0x02a19020 },
1687 { 0x0c, 0x40a000f0 },
1688 { 0x0d, 0x90100210 },
1689 { 0x10, 0x400003f1 },
1690 { 0x11, 0x9033032e },
1691 {}
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001692};
1693
Takashi Iwaid2077d42013-01-14 14:20:16 +01001694static const struct hda_pintbl stac925xM6_pin_configs[] = {
1695 { 0x07, 0x40c003f4 },
1696 { 0x08, 0x424503f2 },
1697 { 0x0a, 0x400000f3 },
1698 { 0x0b, 0x02a19020 },
1699 { 0x0c, 0x40a000f0 },
1700 { 0x0d, 0x90100210 },
1701 { 0x10, 0x400003f1 },
1702 { 0x11, 0x90330320 },
1703 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001704};
1705
Takashi Iwaid2077d42013-01-14 14:20:16 +01001706static const struct hda_fixup stac925x_fixups[] = {
1707 [STAC_REF] = {
1708 .type = HDA_FIXUP_PINS,
1709 .v.pins = ref925x_pin_configs,
1710 },
1711 [STAC_M1] = {
1712 .type = HDA_FIXUP_PINS,
1713 .v.pins = stac925xM1_pin_configs,
1714 },
1715 [STAC_M1_2] = {
1716 .type = HDA_FIXUP_PINS,
1717 .v.pins = stac925xM1_2_pin_configs,
1718 },
1719 [STAC_M2] = {
1720 .type = HDA_FIXUP_PINS,
1721 .v.pins = stac925xM2_pin_configs,
1722 },
1723 [STAC_M2_2] = {
1724 .type = HDA_FIXUP_PINS,
1725 .v.pins = stac925xM2_2_pin_configs,
1726 },
1727 [STAC_M3] = {
1728 .type = HDA_FIXUP_PINS,
1729 .v.pins = stac925xM3_pin_configs,
1730 },
1731 [STAC_M5] = {
1732 .type = HDA_FIXUP_PINS,
1733 .v.pins = stac925xM5_pin_configs,
1734 },
1735 [STAC_M6] = {
1736 .type = HDA_FIXUP_PINS,
1737 .v.pins = stac925xM6_pin_configs,
1738 },
Tobin Davis8e21c342007-01-08 11:04:17 +01001739};
1740
Takashi Iwaid2077d42013-01-14 14:20:16 +01001741static const struct hda_model_fixup stac925x_models[] = {
1742 { .id = STAC_REF, .name = "ref" },
1743 { .id = STAC_M1, .name = "m1" },
1744 { .id = STAC_M1_2, .name = "m1-2" },
1745 { .id = STAC_M2, .name = "m2" },
1746 { .id = STAC_M2_2, .name = "m2-2" },
1747 { .id = STAC_M3, .name = "m3" },
1748 { .id = STAC_M5, .name = "m5" },
1749 { .id = STAC_M6, .name = "m6" },
1750 {}
Tobin Davis8e21c342007-01-08 11:04:17 +01001751};
1752
Takashi Iwaid2077d42013-01-14 14:20:16 +01001753static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1754 /* SigmaTel reference board */
1755 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1756 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1757 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1758
1759 /* Default table for unknown ID */
1760 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1761
1762 /* gateway machines are checked via codec ssid */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001763 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1764 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1765 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1766 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001767 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001768 /* Not sure about the brand name for those */
1769 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1770 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1771 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1772 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001773 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001774};
1775
Takashi Iwai2b635362011-05-02 12:33:43 +02001776static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001777 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1778 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1779 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001780 0x01452050,
1781};
1782
Takashi Iwai2b635362011-05-02 12:33:43 +02001783static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001784 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001785 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001786 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1787 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001788};
1789
Takashi Iwai2b635362011-05-02 12:33:43 +02001790static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001791 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1792 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1793 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1794 0x904601b0,
1795};
1796
Takashi Iwai2b635362011-05-02 12:33:43 +02001797static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001798 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001799 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001800};
1801
Takashi Iwai2b635362011-05-02 12:33:43 +02001802static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001803 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001804 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1805 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1806 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001807 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001808 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001809 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001810};
1811
Takashi Iwaiea734962011-01-17 11:29:34 +01001812static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001813 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001814 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001815 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001816 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001817 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1818 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1819 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001820 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001821 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001822};
1823
Takashi Iwai2b635362011-05-02 12:33:43 +02001824static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001825 /* SigmaTel reference board */
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001827 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001828 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1829 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1831 "Intel DG45ID", STAC_92HD73XX_INTEL),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1833 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001835 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001837 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001839 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001841 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001843 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001845 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001847 "unknown Dell", STAC_DELL_M6_DMIC),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1849 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001851 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1853 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1855 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1857 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001859 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001861 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001862 {} /* terminator */
1863};
1864
Takashi Iwai2b635362011-05-02 12:33:43 +02001865static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001866 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1867 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001868 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1869 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001870 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001871 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001872 {} /* terminator */
1873};
1874
Takashi Iwai2b635362011-05-02 12:33:43 +02001875static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001876 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1877 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001878 0x01451160, 0x98560170,
1879};
1880
Takashi Iwai2b635362011-05-02 12:33:43 +02001881static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001882 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1883 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001884 0x40f000f0, 0x40f000f0,
1885};
1886
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001887static const unsigned int dell_vostro_3500_pin_configs[10] = {
1888 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1889 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1890 0x400000f4, 0x400000f5,
1891};
1892
Takashi Iwai2b635362011-05-02 12:33:43 +02001893static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001894 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1895 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1896 0x40f000f0, 0x40f000f0,
1897};
1898
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001899static const unsigned int hp_zephyr_pin_configs[10] = {
1900 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1901 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1902 0, 0,
1903};
1904
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001905static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1906 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1907 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1908 0x40f000f0, 0x40f000f0,
1909};
1910
Takashi Iwai2b635362011-05-02 12:33:43 +02001911static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001912 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001913 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001914 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001915 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001916 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001917 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001918 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001919};
1920
Takashi Iwaiea734962011-01-17 11:29:34 +01001921static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001922 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001923 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001924 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001925 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001926 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001927 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001928 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001929 [STAC_HP_ZEPHYR] = "hp-zephyr",
Takashi Iwaia3e19972012-07-26 08:17:20 +02001930 [STAC_92HD83XXX_HP_LED] = "hp-led",
Takashi Iwaiff8a1e22012-07-31 10:16:59 +02001931 [STAC_92HD83XXX_HP_INV_LED] = "hp-inv-led",
Takashi Iwai62cbde12012-09-14 11:58:54 +02001932 [STAC_92HD83XXX_HP_MIC_LED] = "hp-mic-led",
David Henningsson8d032a82012-10-09 12:48:40 +02001933 [STAC_92HD83XXX_HEADSET_JACK] = "headset-jack",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001934};
1935
Takashi Iwai2b635362011-05-02 12:33:43 +02001936static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001937 /* SigmaTel reference board */
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001939 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001940 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1941 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001942 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1943 "unknown Dell", STAC_DELL_S14),
David Henningsson8d032a82012-10-09 12:48:40 +02001944 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
1945 "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
1947 "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
1949 "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
1951 "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
1953 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
1955 "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
1957 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
1959 "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
1961 "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1963 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001964 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1965 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1967 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1969 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
Takashi Iwai8ae58652012-12-13 14:33:42 +01001971 "HP Pavilion dv7", STAC_HP_DV7_4000),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001972 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1973 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1975 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Takashi Iwai62cbde12012-09-14 11:58:54 +02001976 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
1977 "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001978 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1979 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1981 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1983 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1985 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1987 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1989 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1991 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1993 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1995 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1997 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1999 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2001 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2003 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2005 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002006 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2007 "HP", STAC_HP_ZEPHYR),
Takashi Iwaia3e19972012-07-26 08:17:20 +02002008 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2009 "HP Mini", STAC_92HD83XXX_HP_LED),
Gustavo Maciel Dias Vieira5afc13a2012-10-26 12:51:53 -02002010 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2011 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06002012 {} /* terminator */
2013};
2014
2015static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2017 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02002018 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002019};
2020
Takashi Iwai2b635362011-05-02 12:33:43 +02002021static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002022 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04002023 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05002024 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
2025 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01002026};
2027
Takashi Iwai2b635362011-05-02 12:33:43 +02002028static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01002029 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01002030 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05002031 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
2032 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01002033};
2034
Takashi Iwai2b635362011-05-02 12:33:43 +02002035static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01002036 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
2037 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05002038 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
2039 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01002040};
2041
Takashi Iwai2b635362011-05-02 12:33:43 +02002042static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002043 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
2044 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05002045 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
2046 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002047};
2048
Takashi Iwai2b635362011-05-02 12:33:43 +02002049static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002050 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01002051 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
2052 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002053 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04002054 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002055 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01002056 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002057 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04002058 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01002059};
2060
Takashi Iwaiea734962011-01-17 11:29:34 +01002061static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002062 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01002063 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01002064 [STAC_DELL_M4_1] = "dell-m4-1",
2065 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002066 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04002067 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002068 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01002069 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002070 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04002071 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01002072};
2073
Takashi Iwai2b635362011-05-02 12:33:43 +02002074static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01002075 /* SigmaTel reference board */
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2077 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002078 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2079 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04002080 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
2081 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01002082 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2083 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01002084 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2085 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002086 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02002087 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002088 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2089 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002090 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2091 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04002092 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01002093 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01002094 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01002095 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02002096 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2097 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05302098 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2099 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11002100 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2101 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02002102 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2103 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01002104 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2105 "unknown Dell", STAC_DELL_M4_1),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2107 "unknown Dell", STAC_DELL_M4_1),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2109 "unknown Dell", STAC_DELL_M4_1),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2111 "unknown Dell", STAC_DELL_M4_1),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2113 "unknown Dell", STAC_DELL_M4_1),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2115 "unknown Dell", STAC_DELL_M4_1),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2117 "unknown Dell", STAC_DELL_M4_1),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2119 "unknown Dell", STAC_DELL_M4_2),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2121 "unknown Dell", STAC_DELL_M4_2),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2123 "unknown Dell", STAC_DELL_M4_2),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2125 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05002126 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2127 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01002128 {} /* terminator */
2129};
2130
Takashi Iwai0a427842013-01-14 15:20:13 +01002131static const struct hda_pintbl ref922x_pin_configs[] = {
2132 { 0x0a, 0x01014010 },
2133 { 0x0b, 0x01016011 },
2134 { 0x0c, 0x01012012 },
2135 { 0x0d, 0x0221401f },
2136 { 0x0e, 0x01813122 },
2137 { 0x0f, 0x01011014 },
2138 { 0x10, 0x01441030 },
2139 { 0x11, 0x01c41030 },
2140 { 0x15, 0x40000100 },
2141 { 0x1b, 0x40000100 },
2142 {}
Matt2f2f4252005-04-13 14:45:30 +02002143};
2144
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002145/*
2146 STAC 922X pin configs for
2147 102801A7
2148 102801AB
2149 102801A9
2150 102801D1
2151 102801D2
2152*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002153static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2154 { 0x0a, 0x02214030 },
2155 { 0x0b, 0x01a19021 },
2156 { 0x0c, 0x01111012 },
2157 { 0x0d, 0x01114010 },
2158 { 0x0e, 0x02a19020 },
2159 { 0x0f, 0x01117011 },
2160 { 0x10, 0x400001f0 },
2161 { 0x11, 0x400001f1 },
2162 { 0x15, 0x01813122 },
2163 { 0x1b, 0x400001f2 },
2164 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002165};
2166
2167/*
2168 STAC 922X pin configs for
2169 102801AC
2170 102801D0
2171*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002172static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2173 { 0x0a, 0x02214030 },
2174 { 0x0b, 0x01a19021 },
2175 { 0x0c, 0x01111012 },
2176 { 0x0d, 0x01114010 },
2177 { 0x0e, 0x02a19020 },
2178 { 0x0f, 0x01117011 },
2179 { 0x10, 0x01451140 },
2180 { 0x11, 0x400001f0 },
2181 { 0x15, 0x01813122 },
2182 { 0x1b, 0x400001f1 },
2183 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002184};
2185
2186/*
2187 STAC 922X pin configs for
2188 102801BF
2189*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002190static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2191 { 0x0a, 0x0321101f },
2192 { 0x0b, 0x01112024 },
2193 { 0x0c, 0x01111222 },
2194 { 0x0d, 0x91174220 },
2195 { 0x0e, 0x03a11050 },
2196 { 0x0f, 0x01116221 },
2197 { 0x10, 0x90a70330 },
2198 { 0x11, 0x01452340 },
2199 { 0x15, 0x40C003f1 },
2200 { 0x1b, 0x405003f0 },
2201 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002202};
2203
2204/*
2205 STAC 9221 A1 pin configs for
2206 102801D7 (Dell XPS M1210)
2207*/
Takashi Iwai0a427842013-01-14 15:20:13 +01002208static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2209 { 0x0a, 0x02211211 },
2210 { 0x0b, 0x408103ff },
2211 { 0x0c, 0x02a1123e },
2212 { 0x0d, 0x90100310 },
2213 { 0x0e, 0x408003f1 },
2214 { 0x0f, 0x0221121f },
2215 { 0x10, 0x03451340 },
2216 { 0x11, 0x40c003f2 },
2217 { 0x15, 0x508003f3 },
2218 { 0x1b, 0x405003f4 },
2219 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002220};
2221
Takashi Iwai0a427842013-01-14 15:20:13 +01002222static const struct hda_pintbl d945gtp3_pin_configs[] = {
2223 { 0x0a, 0x0221401f },
2224 { 0x0b, 0x01a19022 },
2225 { 0x0c, 0x01813021 },
2226 { 0x0d, 0x01014010 },
2227 { 0x0e, 0x40000100 },
2228 { 0x0f, 0x40000100 },
2229 { 0x10, 0x40000100 },
2230 { 0x11, 0x40000100 },
2231 { 0x15, 0x02a19120 },
2232 { 0x1b, 0x40000100 },
2233 {}
Matt Porter403d1942005-11-29 15:00:51 +01002234};
2235
Takashi Iwai0a427842013-01-14 15:20:13 +01002236static const struct hda_pintbl d945gtp5_pin_configs[] = {
2237 { 0x0a, 0x0221401f },
2238 { 0x0b, 0x01011012 },
2239 { 0x0c, 0x01813024 },
2240 { 0x0d, 0x01014010 },
2241 { 0x0e, 0x01a19021 },
2242 { 0x0f, 0x01016011 },
2243 { 0x10, 0x01452130 },
2244 { 0x11, 0x40000100 },
2245 { 0x15, 0x02a19320 },
2246 { 0x1b, 0x40000100 },
2247 {}
Matt Porter403d1942005-11-29 15:00:51 +01002248};
2249
Takashi Iwai0a427842013-01-14 15:20:13 +01002250static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2251 { 0x0a, 0x0121e21f },
2252 { 0x0b, 0x400000ff },
2253 { 0x0c, 0x9017e110 },
2254 { 0x0d, 0x400000fd },
2255 { 0x0e, 0x400000fe },
2256 { 0x0f, 0x0181e020 },
2257 { 0x10, 0x1145e030 },
2258 { 0x11, 0x11c5e240 },
2259 { 0x15, 0x400000fc },
2260 { 0x1b, 0x400000fb },
2261 {}
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002262};
2263
Takashi Iwai0a427842013-01-14 15:20:13 +01002264static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2265 { 0x0a, 0x0121e21f },
2266 { 0x0b, 0x90a7012e },
2267 { 0x0c, 0x9017e110 },
2268 { 0x0d, 0x400000fd },
2269 { 0x0e, 0x400000fe },
2270 { 0x0f, 0x0181e020 },
2271 { 0x10, 0x1145e230 },
2272 { 0x11, 0x500000fa },
2273 { 0x15, 0x400000fc },
2274 { 0x1b, 0x400000fb },
2275 {}
Sylvain FORETf16928f2007-04-27 14:22:36 +02002276};
2277
Takashi Iwai0a427842013-01-14 15:20:13 +01002278static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2279 { 0x0a, 0x0121e21f },
2280 { 0x0b, 0x90a7012e },
2281 { 0x0c, 0x9017e110 },
2282 { 0x0d, 0x400000fd },
2283 { 0x0e, 0x400000fe },
2284 { 0x0f, 0x0181e020 },
2285 { 0x10, 0x1145e230 },
2286 { 0x11, 0x11c5e240 },
2287 { 0x15, 0x400000fc },
2288 { 0x1b, 0x400000fb },
2289 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002290};
2291
Takashi Iwai0a427842013-01-14 15:20:13 +01002292static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2293 { 0x0a, 0x0321e21f },
2294 { 0x0b, 0x03a1e02e },
2295 { 0x0c, 0x9017e110 },
2296 { 0x0d, 0x9017e11f },
2297 { 0x0e, 0x400000fe },
2298 { 0x0f, 0x0381e020 },
2299 { 0x10, 0x1345e230 },
2300 { 0x11, 0x13c5e240 },
2301 { 0x15, 0x400000fc },
2302 { 0x1b, 0x400000fb },
2303 {}
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002304};
2305
Takashi Iwai0a427842013-01-14 15:20:13 +01002306static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2307 { 0x0a, 0x0321e21f },
2308 { 0x0b, 0x03a1e02e },
2309 { 0x0c, 0x9017e110 },
2310 { 0x0d, 0x9017e11f },
2311 { 0x0e, 0x400000fe },
2312 { 0x0f, 0x0381e020 },
2313 { 0x10, 0x1345e230 },
2314 { 0x11, 0x13c5e240 },
2315 { 0x15, 0x400000fc },
2316 { 0x1b, 0x400000fb },
2317 {}
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002318};
2319
Takashi Iwai0a427842013-01-14 15:20:13 +01002320static const struct hda_pintbl ecs202_pin_configs[] = {
2321 { 0x0a, 0x0221401f },
2322 { 0x0b, 0x02a19020 },
2323 { 0x0c, 0x01a19020 },
2324 { 0x0d, 0x01114010 },
2325 { 0x0e, 0x408000f0 },
2326 { 0x0f, 0x01813022 },
2327 { 0x10, 0x074510a0 },
2328 { 0x11, 0x40c400f1 },
2329 { 0x15, 0x9037012e },
2330 { 0x1b, 0x40e000f2 },
2331 {}
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002332};
Takashi Iwai76c08822007-06-19 12:17:42 +02002333
Takashi Iwai0a427842013-01-14 15:20:13 +01002334/* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2335static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2336 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2337 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2338 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2339 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2340 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2341 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2342 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2343 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2344 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2345 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2346 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2347 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2348 {}
2349};
2350
2351static const struct hda_fixup stac922x_fixups[];
2352
2353/* remap the fixup from codec SSID and apply it */
2354static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2355 const struct hda_fixup *fix,
2356 int action)
2357{
2358 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2359 return;
2360 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2361 stac922x_fixups);
2362 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2363 snd_hda_apply_fixup(codec, action);
2364}
2365
2366static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2367 const struct hda_fixup *fix,
2368 int action)
2369{
2370 struct sigmatel_spec *spec = codec->spec;
2371
2372 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2373 spec->gpio_mask = spec->gpio_dir = 0x03;
2374 spec->gpio_data = 0x03;
2375 }
2376}
2377
2378static const struct hda_fixup stac922x_fixups[] = {
2379 [STAC_D945_REF] = {
2380 .type = HDA_FIXUP_PINS,
2381 .v.pins = ref922x_pin_configs,
2382 },
2383 [STAC_D945GTP3] = {
2384 .type = HDA_FIXUP_PINS,
2385 .v.pins = d945gtp3_pin_configs,
2386 },
2387 [STAC_D945GTP5] = {
2388 .type = HDA_FIXUP_PINS,
2389 .v.pins = d945gtp5_pin_configs,
2390 },
2391 [STAC_INTEL_MAC_AUTO] = {
2392 .type = HDA_FIXUP_FUNC,
2393 .v.func = stac922x_fixup_intel_mac_auto,
2394 },
2395 [STAC_INTEL_MAC_V1] = {
2396 .type = HDA_FIXUP_PINS,
2397 .v.pins = intel_mac_v1_pin_configs,
2398 .chained = true,
2399 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2400 },
2401 [STAC_INTEL_MAC_V2] = {
2402 .type = HDA_FIXUP_PINS,
2403 .v.pins = intel_mac_v2_pin_configs,
2404 .chained = true,
2405 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2406 },
2407 [STAC_INTEL_MAC_V3] = {
2408 .type = HDA_FIXUP_PINS,
2409 .v.pins = intel_mac_v3_pin_configs,
2410 .chained = true,
2411 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2412 },
2413 [STAC_INTEL_MAC_V4] = {
2414 .type = HDA_FIXUP_PINS,
2415 .v.pins = intel_mac_v4_pin_configs,
2416 .chained = true,
2417 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2418 },
2419 [STAC_INTEL_MAC_V5] = {
2420 .type = HDA_FIXUP_PINS,
2421 .v.pins = intel_mac_v5_pin_configs,
2422 .chained = true,
2423 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2424 },
2425 [STAC_922X_INTEL_MAC_GPIO] = {
2426 .type = HDA_FIXUP_FUNC,
2427 .v.func = stac922x_fixup_intel_mac_gpio,
2428 },
2429 [STAC_ECS_202] = {
2430 .type = HDA_FIXUP_PINS,
2431 .v.pins = ecs202_pin_configs,
2432 },
2433 [STAC_922X_DELL_D81] = {
2434 .type = HDA_FIXUP_PINS,
2435 .v.pins = dell_922x_d81_pin_configs,
2436 },
2437 [STAC_922X_DELL_D82] = {
2438 .type = HDA_FIXUP_PINS,
2439 .v.pins = dell_922x_d82_pin_configs,
2440 },
2441 [STAC_922X_DELL_M81] = {
2442 .type = HDA_FIXUP_PINS,
2443 .v.pins = dell_922x_m81_pin_configs,
2444 },
2445 [STAC_922X_DELL_M82] = {
2446 .type = HDA_FIXUP_PINS,
2447 .v.pins = dell_922x_m82_pin_configs,
2448 },
2449};
2450
2451static const struct hda_model_fixup stac922x_models[] = {
2452 { .id = STAC_D945_REF, .name = "ref" },
2453 { .id = STAC_D945GTP5, .name = "5stack" },
2454 { .id = STAC_D945GTP3, .name = "3stack" },
2455 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
2456 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
2457 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
2458 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
2459 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
2460 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
2461 { .id = STAC_ECS_202, .name = "ecs202" },
2462 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
2463 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
2464 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
2465 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002466 /* for backward compatibility */
Takashi Iwai0a427842013-01-14 15:20:13 +01002467 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
2468 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
2469 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
2470 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
2471 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
2472 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
2473 {}
Matt Porter403d1942005-11-29 15:00:51 +01002474};
2475
Takashi Iwai0a427842013-01-14 15:20:13 +01002476static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002477 /* SigmaTel reference board */
2478 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2479 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002480 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2481 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002482 /* Intel 945G based systems */
2483 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2484 "Intel D945G", STAC_D945GTP3),
2485 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2486 "Intel D945G", STAC_D945GTP3),
2487 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2488 "Intel D945G", STAC_D945GTP3),
2489 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2490 "Intel D945G", STAC_D945GTP3),
2491 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2492 "Intel D945G", STAC_D945GTP3),
2493 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2494 "Intel D945G", STAC_D945GTP3),
2495 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2496 "Intel D945G", STAC_D945GTP3),
2497 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2498 "Intel D945G", STAC_D945GTP3),
2499 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2500 "Intel D945G", STAC_D945GTP3),
2501 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2502 "Intel D945G", STAC_D945GTP3),
2503 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2504 "Intel D945G", STAC_D945GTP3),
2505 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2506 "Intel D945G", STAC_D945GTP3),
2507 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2508 "Intel D945G", STAC_D945GTP3),
2509 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2510 "Intel D945G", STAC_D945GTP3),
2511 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2512 "Intel D945G", STAC_D945GTP3),
2513 /* Intel D945G 5-stack systems */
2514 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2515 "Intel D945G", STAC_D945GTP5),
2516 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2517 "Intel D945G", STAC_D945GTP5),
2518 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2519 "Intel D945G", STAC_D945GTP5),
2520 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2521 "Intel D945G", STAC_D945GTP5),
2522 /* Intel 945P based systems */
2523 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2524 "Intel D945P", STAC_D945GTP3),
2525 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2526 "Intel D945P", STAC_D945GTP3),
2527 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2528 "Intel D945P", STAC_D945GTP3),
2529 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2530 "Intel D945P", STAC_D945GTP3),
2531 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2532 "Intel D945P", STAC_D945GTP3),
2533 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2534 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002535 /* other intel */
2536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2537 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002538 /* other systems */
Takashi Iwai0a427842013-01-14 15:20:13 +01002539
Nicolas Boichat536319a2008-07-21 22:18:01 +08002540 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwai0a427842013-01-14 15:20:13 +01002541 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
2542
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002543 /* Dell systems */
2544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2545 "unknown Dell", STAC_922X_DELL_D81),
2546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2547 "unknown Dell", STAC_922X_DELL_D81),
2548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2549 "unknown Dell", STAC_922X_DELL_D81),
2550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2551 "unknown Dell", STAC_922X_DELL_D82),
2552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2553 "unknown Dell", STAC_922X_DELL_M81),
2554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2555 "unknown Dell", STAC_922X_DELL_D82),
2556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2557 "unknown Dell", STAC_922X_DELL_D81),
2558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2559 "unknown Dell", STAC_922X_DELL_D81),
2560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2561 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002562 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002563 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002564 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002565 {} /* terminator */
2566};
2567
Takashi Iwai29ac8362013-01-14 16:03:38 +01002568static const struct hda_pintbl ref927x_pin_configs[] = {
2569 { 0x0a, 0x02214020 },
2570 { 0x0b, 0x02a19080 },
2571 { 0x0c, 0x0181304e },
2572 { 0x0d, 0x01014010 },
2573 { 0x0e, 0x01a19040 },
2574 { 0x0f, 0x01011012 },
2575 { 0x10, 0x01016011 },
2576 { 0x11, 0x0101201f },
2577 { 0x12, 0x183301f0 },
2578 { 0x13, 0x18a001f0 },
2579 { 0x14, 0x18a001f0 },
2580 { 0x21, 0x01442070 },
2581 { 0x22, 0x01c42190 },
2582 { 0x23, 0x40000100 },
2583 {}
Matt Porter3cc08dc2006-01-23 15:27:49 +01002584};
2585
Takashi Iwai29ac8362013-01-14 16:03:38 +01002586static const struct hda_pintbl d965_3st_pin_configs[] = {
2587 { 0x0a, 0x0221401f },
2588 { 0x0b, 0x02a19120 },
2589 { 0x0c, 0x40000100 },
2590 { 0x0d, 0x01014011 },
2591 { 0x0e, 0x01a19021 },
2592 { 0x0f, 0x01813024 },
2593 { 0x10, 0x40000100 },
2594 { 0x11, 0x40000100 },
2595 { 0x12, 0x40000100 },
2596 { 0x13, 0x40000100 },
2597 { 0x14, 0x40000100 },
2598 { 0x21, 0x40000100 },
2599 { 0x22, 0x40000100 },
2600 { 0x23, 0x40000100 },
2601 {}
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002602};
2603
Takashi Iwai29ac8362013-01-14 16:03:38 +01002604static const struct hda_pintbl d965_5st_pin_configs[] = {
2605 { 0x0a, 0x02214020 },
2606 { 0x0b, 0x02a19080 },
2607 { 0x0c, 0x0181304e },
2608 { 0x0d, 0x01014010 },
2609 { 0x0e, 0x01a19040 },
2610 { 0x0f, 0x01011012 },
2611 { 0x10, 0x01016011 },
2612 { 0x11, 0x40000100 },
2613 { 0x12, 0x40000100 },
2614 { 0x13, 0x40000100 },
2615 { 0x14, 0x40000100 },
2616 { 0x21, 0x01442070 },
2617 { 0x22, 0x40000100 },
2618 { 0x23, 0x40000100 },
2619 {}
Tobin Davis93ed1502006-09-01 21:03:12 +02002620};
2621
Takashi Iwai29ac8362013-01-14 16:03:38 +01002622static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
2623 { 0x0a, 0x40000100 },
2624 { 0x0b, 0x40000100 },
2625 { 0x0c, 0x0181304e },
2626 { 0x0d, 0x01014010 },
2627 { 0x0e, 0x01a19040 },
2628 { 0x0f, 0x01011012 },
2629 { 0x10, 0x01016011 },
2630 { 0x11, 0x40000100 },
2631 { 0x12, 0x40000100 },
2632 { 0x13, 0x40000100 },
2633 { 0x14, 0x40000100 },
2634 { 0x21, 0x01442070 },
2635 { 0x22, 0x40000100 },
2636 { 0x23, 0x40000100 },
2637 {}
Takashi Iwai679d92e2009-05-24 19:00:08 +02002638};
2639
Takashi Iwai29ac8362013-01-14 16:03:38 +01002640static const struct hda_pintbl dell_3st_pin_configs[] = {
2641 { 0x0a, 0x02211230 },
2642 { 0x0b, 0x02a11220 },
2643 { 0x0c, 0x01a19040 },
2644 { 0x0d, 0x01114210 },
2645 { 0x0e, 0x01111212 },
2646 { 0x0f, 0x01116211 },
2647 { 0x10, 0x01813050 },
2648 { 0x11, 0x01112214 },
2649 { 0x12, 0x403003fa },
2650 { 0x13, 0x90a60040 },
2651 { 0x14, 0x90a60040 },
2652 { 0x21, 0x404003fb },
2653 { 0x22, 0x40c003fc },
2654 { 0x23, 0x40000100 },
2655 {}
Tobin Davis4ff076e2007-08-07 11:48:12 +02002656};
2657
Takashi Iwai29ac8362013-01-14 16:03:38 +01002658static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
2659 const struct hda_fixup *fix, int action)
2660{
2661 struct sigmatel_spec *spec = codec->spec;
2662
2663 /* no jack detecion for ref-no-jd model */
2664 if (action == HDA_FIXUP_ACT_PROBE)
2665 spec->hp_detect = 0;
2666}
2667
2668static void stac927x_fixup_ref(struct hda_codec *codec,
2669 const struct hda_fixup *fix, int action)
2670{
2671 struct sigmatel_spec *spec = codec->spec;
2672
2673 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2674 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
2675 spec->eapd_mask = spec->gpio_mask = 0;
2676 spec->gpio_dir = spec->gpio_data = 0;
2677 }
2678}
2679
2680static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
2681 const struct hda_fixup *fix, int action)
2682{
2683 struct sigmatel_spec *spec = codec->spec;
2684
2685 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2686 return;
2687
2688 if (codec->subsystem_id != 0x1028022f) {
2689 /* GPIO2 High = Enable EAPD */
2690 spec->eapd_mask = spec->gpio_mask = 0x04;
2691 spec->gpio_dir = spec->gpio_data = 0x04;
2692 }
2693 spec->dmic_nids = stac927x_dmic_nids;
2694 spec->num_dmics = STAC927X_NUM_DMICS;
2695
2696 snd_hda_add_verbs(codec, dell_3st_core_init);
2697 spec->volknob_init = 1;
2698 spec->dmux_nids = stac927x_dmux_nids;
2699 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
2700}
2701
2702static void stac927x_fixup_volknob(struct hda_codec *codec,
2703 const struct hda_fixup *fix, int action)
2704{
2705 struct sigmatel_spec *spec = codec->spec;
2706
2707 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2708 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
2709 spec->volknob_init = 1;
2710 }
2711}
2712
2713static const struct hda_fixup stac927x_fixups[] = {
2714 [STAC_D965_REF_NO_JD] = {
2715 .type = HDA_FIXUP_FUNC,
2716 .v.func = stac927x_fixup_ref_no_jd,
2717 .chained = true,
2718 .chain_id = STAC_D965_REF,
2719 },
2720 [STAC_D965_REF] = {
2721 .type = HDA_FIXUP_FUNC,
2722 .v.func = stac927x_fixup_ref,
2723 },
2724 [STAC_D965_3ST] = {
2725 .type = HDA_FIXUP_PINS,
2726 .v.pins = d965_3st_pin_configs,
2727 .chained = true,
2728 .chain_id = STAC_D965_VERBS,
2729 },
2730 [STAC_D965_5ST] = {
2731 .type = HDA_FIXUP_PINS,
2732 .v.pins = d965_5st_pin_configs,
2733 .chained = true,
2734 .chain_id = STAC_D965_VERBS,
2735 },
2736 [STAC_D965_VERBS] = {
2737 .type = HDA_FIXUP_VERBS,
2738 .v.verbs = d965_core_init,
2739 },
2740 [STAC_D965_5ST_NO_FP] = {
2741 .type = HDA_FIXUP_PINS,
2742 .v.pins = d965_5st_no_fp_pin_configs,
2743 },
2744 [STAC_DELL_3ST] = {
2745 .type = HDA_FIXUP_PINS,
2746 .v.pins = dell_3st_pin_configs,
2747 .chained = true,
2748 .chain_id = STAC_927X_DELL_DMIC,
2749 },
2750 [STAC_DELL_BIOS] = {
2751 .type = HDA_FIXUP_PINS,
2752 .v.pins = (const struct hda_pintbl[]) {
2753 /* configure the analog microphone on some laptops */
2754 { 0x0c, 0x90a79130 },
2755 /* correct the front output jack as a hp out */
2756 { 0x0f, 0x0227011f },
2757 /* correct the front input jack as a mic */
2758 { 0x0e, 0x02a79130 },
2759 {}
2760 },
2761 .chained = true,
2762 .chain_id = STAC_927X_DELL_DMIC,
2763 },
2764 [STAC_DELL_BIOS_SPDIF] = {
2765 .type = HDA_FIXUP_PINS,
2766 .v.pins = (const struct hda_pintbl[]) {
2767 /* correct the device field to SPDIF out */
2768 { 0x21, 0x01442070 },
2769 {}
2770 },
2771 .chained = true,
2772 .chain_id = STAC_DELL_BIOS,
2773 },
2774 [STAC_927X_DELL_DMIC] = {
2775 .type = HDA_FIXUP_FUNC,
2776 .v.func = stac927x_fixup_dell_dmic,
2777 },
2778 [STAC_927X_VOLKNOB] = {
2779 .type = HDA_FIXUP_FUNC,
2780 .v.func = stac927x_fixup_volknob,
2781 },
Matt Porter3cc08dc2006-01-23 15:27:49 +01002782};
2783
Takashi Iwai29ac8362013-01-14 16:03:38 +01002784static const struct hda_model_fixup stac927x_models[] = {
2785 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
2786 { .id = STAC_D965_REF, .name = "ref" },
2787 { .id = STAC_D965_3ST, .name = "3stack" },
2788 { .id = STAC_D965_5ST, .name = "5stack" },
2789 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
2790 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
2791 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
2792 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
2793 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002794};
2795
Takashi Iwai29ac8362013-01-14 16:03:38 +01002796static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002797 /* SigmaTel reference board */
2798 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2799 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002800 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2801 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002802 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2804 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002805 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002806 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2807 "Intel D965", STAC_D965_3ST),
2808 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2809 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002810 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002811 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002814 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002816 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01002818 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002820 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2822 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
Takashi Iwai29ac8362013-01-14 16:03:38 +01002823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
Tobin Davis93ed1502006-09-01 21:03:12 +02002824 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002825 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2826 "Intel D965", STAC_D965_5ST),
2827 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2828 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002829 /* volume-knob fixes */
2830 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002831 {} /* terminator */
2832};
2833
Takashi Iwaife6322c2013-01-14 14:46:51 +01002834static const struct hda_pintbl ref9205_pin_configs[] = {
2835 { 0x0a, 0x40000100 },
2836 { 0x0b, 0x40000100 },
2837 { 0x0c, 0x01016011 },
2838 { 0x0d, 0x01014010 },
2839 { 0x0e, 0x01813122 },
2840 { 0x0f, 0x01a19021 },
2841 { 0x14, 0x01019020 },
2842 { 0x16, 0x40000100 },
2843 { 0x17, 0x90a000f0 },
2844 { 0x18, 0x90a000f0 },
2845 { 0x21, 0x01441030 },
2846 { 0x22, 0x01c41030 },
2847 {}
Matt Porterf3302a52006-07-31 12:49:34 +02002848};
2849
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002850/*
2851 STAC 9205 pin configs for
2852 102801F1
2853 102801F2
2854 102801FC
2855 102801FD
2856 10280204
2857 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002858 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002859 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002860*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01002861static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
2862 { 0x0a, 0x0321101F },
2863 { 0x0b, 0x03A11020 },
2864 { 0x0c, 0x400003FA },
2865 { 0x0d, 0x90170310 },
2866 { 0x0e, 0x400003FB },
2867 { 0x0f, 0x400003FC },
2868 { 0x14, 0x400003FD },
2869 { 0x16, 0x40F000F9 },
2870 { 0x17, 0x90A60330 },
2871 { 0x18, 0x400003FF },
2872 { 0x21, 0x0144131F },
2873 { 0x22, 0x40C003FE },
2874 {}
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002875};
2876
2877/*
2878 STAC 9205 pin configs for
2879 102801F9
2880 102801FA
2881 102801FE
2882 102801FF (Dell Precision M4300)
2883 10280206
2884 10280200
2885 10280201
2886*/
Takashi Iwaife6322c2013-01-14 14:46:51 +01002887static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
2888 { 0x0a, 0x0321101f },
2889 { 0x0b, 0x03a11020 },
2890 { 0x0c, 0x90a70330 },
2891 { 0x0d, 0x90170310 },
2892 { 0x0e, 0x400000fe },
2893 { 0x0f, 0x400000ff },
2894 { 0x14, 0x400000fd },
2895 { 0x16, 0x40f000f9 },
2896 { 0x17, 0x400000fa },
2897 { 0x18, 0x400000fc },
2898 { 0x21, 0x0144131f },
2899 { 0x22, 0x40c003f8 },
2900 /* Enable SPDIF in/out */
2901 { 0x1f, 0x01441030 },
2902 { 0x20, 0x1c410030 },
2903 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002904};
2905
Takashi Iwaife6322c2013-01-14 14:46:51 +01002906static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
2907 { 0x0a, 0x0421101f },
2908 { 0x0b, 0x04a11020 },
2909 { 0x0c, 0x400003fa },
2910 { 0x0d, 0x90170310 },
2911 { 0x0e, 0x400003fb },
2912 { 0x0f, 0x400003fc },
2913 { 0x14, 0x400003fd },
2914 { 0x16, 0x400003f9 },
2915 { 0x17, 0x90a60330 },
2916 { 0x18, 0x400003ff },
2917 { 0x21, 0x01441340 },
2918 { 0x22, 0x40c003fe },
2919 {}
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002920};
2921
Takashi Iwaife6322c2013-01-14 14:46:51 +01002922static void stac9205_fixup_ref(struct hda_codec *codec,
2923 const struct hda_fixup *fix, int action)
2924{
2925 struct sigmatel_spec *spec = codec->spec;
2926
2927 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2928 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
2929 /* SPDIF-In enabled */
2930 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
2931 }
2932}
2933
2934static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
2935 unsigned char type, int data);
2936
2937static void stac9205_fixup_dell_m43(struct hda_codec *codec,
2938 const struct hda_fixup *fix, int action)
2939{
2940 struct sigmatel_spec *spec = codec->spec;
2941 int err;
2942
2943 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2944 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
2945
2946 /* Enable unsol response for GPIO4/Dock HP connection */
2947 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
2948 if (err < 0)
2949 return;
2950 snd_hda_codec_write_cache(codec, codec->afg, 0,
2951 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
2952 snd_hda_jack_detect_enable(codec, codec->afg, 0);
2953
2954 spec->gpio_dir = 0x0b;
2955 spec->eapd_mask = 0x01;
2956 spec->gpio_mask = 0x1b;
2957 spec->gpio_mute = 0x10;
2958 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
2959 * GPIO3 Low = DRM
2960 */
2961 spec->gpio_data = 0x01;
2962 }
2963}
2964
2965static void stac9205_fixup_eapd(struct hda_codec *codec,
2966 const struct hda_fixup *fix, int action)
2967{
2968 struct sigmatel_spec *spec = codec->spec;
2969
2970 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2971 spec->eapd_switch = 0;
2972}
2973
2974static const struct hda_fixup stac9205_fixups[] = {
2975 [STAC_9205_REF] = {
2976 .type = HDA_FIXUP_FUNC,
2977 .v.func = stac9205_fixup_ref,
2978 },
2979 [STAC_9205_DELL_M42] = {
2980 .type = HDA_FIXUP_PINS,
2981 .v.pins = dell_9205_m42_pin_configs,
2982 },
2983 [STAC_9205_DELL_M43] = {
2984 .type = HDA_FIXUP_FUNC,
2985 .v.func = stac9205_fixup_dell_m43,
2986 },
2987 [STAC_9205_DELL_M44] = {
2988 .type = HDA_FIXUP_PINS,
2989 .v.pins = dell_9205_m44_pin_configs,
2990 },
2991 [STAC_9205_EAPD] = {
2992 .type = HDA_FIXUP_FUNC,
2993 .v.func = stac9205_fixup_eapd,
2994 },
2995 {}
Matt Porterf3302a52006-07-31 12:49:34 +02002996};
2997
Takashi Iwaife6322c2013-01-14 14:46:51 +01002998static const struct hda_model_fixup stac9205_models[] = {
2999 { .id = STAC_9205_REF, .name = "ref" },
3000 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3001 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3002 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3003 { .id = STAC_9205_EAPD, .name = "eapd" },
3004 {}
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003005};
3006
Takashi Iwaife6322c2013-01-14 14:46:51 +01003007static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003008 /* SigmaTel reference board */
3009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3010 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03003011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3012 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05003013 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3014 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003015 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3017 "unknown Dell", STAC_9205_DELL_M42),
3018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3019 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003020 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02003021 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003022 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3023 "Dell Precision", STAC_9205_DELL_M43),
3024 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3025 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003026 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3027 "unknown Dell", STAC_9205_DELL_M42),
3028 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3029 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003030 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3031 "Dell Precision", STAC_9205_DELL_M43),
3032 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003033 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02003034 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3035 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02003036 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3037 "Dell Precision", STAC_9205_DELL_M43),
3038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3039 "Dell Precision", STAC_9205_DELL_M43),
3040 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3041 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02003042 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3043 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01003044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3045 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01003046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3047 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003048 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08003049 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01003050 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02003051 {} /* terminator */
3052};
3053
Takashi Iwai330ee992009-02-20 14:33:36 +01003054static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003055 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02003056{
3057 int i;
3058 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02003059
Takashi Iwai330ee992009-02-20 14:33:36 +01003060 if (!pincfgs)
3061 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02003062
Matthew Ranostay87d48362007-07-17 11:52:24 +02003063 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01003064 if (spec->pin_nids[i] && pincfgs[i])
3065 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
3066 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01003067}
3068
Matt2f2f4252005-04-13 14:45:30 +02003069/*
3070 * Analog playback callbacks
3071 */
3072static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
3073 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003074 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003075{
3076 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003077 if (spec->stream_delay)
3078 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01003079 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3080 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02003081}
3082
3083static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3084 struct hda_codec *codec,
3085 unsigned int stream_tag,
3086 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003087 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003088{
3089 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01003090 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02003091}
3092
3093static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3094 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003095 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003096{
3097 struct sigmatel_spec *spec = codec->spec;
3098 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3099}
3100
3101/*
Mattdabbed62005-06-14 10:19:34 +02003102 * Digital playback callbacks
3103 */
3104static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3105 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003106 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003107{
3108 struct sigmatel_spec *spec = codec->spec;
3109 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3110}
3111
3112static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3113 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003114 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02003115{
3116 struct sigmatel_spec *spec = codec->spec;
3117 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3118}
3119
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003120static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3121 struct hda_codec *codec,
3122 unsigned int stream_tag,
3123 unsigned int format,
3124 struct snd_pcm_substream *substream)
3125{
3126 struct sigmatel_spec *spec = codec->spec;
3127 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3128 stream_tag, format, substream);
3129}
3130
Takashi Iwai9411e212009-02-13 11:32:28 +01003131static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3132 struct hda_codec *codec,
3133 struct snd_pcm_substream *substream)
3134{
3135 struct sigmatel_spec *spec = codec->spec;
3136 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3137}
3138
Mattdabbed62005-06-14 10:19:34 +02003139
3140/*
Matt2f2f4252005-04-13 14:45:30 +02003141 * Analog capture callbacks
3142 */
3143static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3144 struct hda_codec *codec,
3145 unsigned int stream_tag,
3146 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003147 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003148{
3149 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003150 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003151
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003152 if (spec->powerdown_adcs) {
3153 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003154 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003155 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
3156 }
3157 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02003158 return 0;
3159}
3160
3161static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3162 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003163 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02003164{
3165 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003166 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02003167
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003168 snd_hda_codec_cleanup_stream(codec, nid);
3169 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01003170 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003171 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02003172 return 0;
3173}
3174
Takashi Iwai2b635362011-05-02 12:33:43 +02003175static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02003176 .substreams = 1,
3177 .channels_min = 2,
3178 .channels_max = 2,
3179 /* NID is set in stac92xx_build_pcms */
3180 .ops = {
3181 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003182 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01003183 .prepare = stac92xx_dig_playback_pcm_prepare,
3184 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02003185 },
3186};
3187
Takashi Iwai2b635362011-05-02 12:33:43 +02003188static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02003189 .substreams = 1,
3190 .channels_min = 2,
3191 .channels_max = 2,
3192 /* NID is set in stac92xx_build_pcms */
3193};
3194
Takashi Iwai2b635362011-05-02 12:33:43 +02003195static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02003196 .substreams = 1,
3197 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02003198 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02003199 .nid = 0x02, /* NID to query formats and rates */
3200 .ops = {
3201 .open = stac92xx_playback_pcm_open,
3202 .prepare = stac92xx_playback_pcm_prepare,
3203 .cleanup = stac92xx_playback_pcm_cleanup
3204 },
3205};
3206
Takashi Iwai2b635362011-05-02 12:33:43 +02003207static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01003208 .substreams = 1,
3209 .channels_min = 2,
3210 .channels_max = 2,
3211 .nid = 0x06, /* NID to query formats and rates */
3212 .ops = {
3213 .open = stac92xx_playback_pcm_open,
3214 .prepare = stac92xx_playback_pcm_prepare,
3215 .cleanup = stac92xx_playback_pcm_cleanup
3216 },
3217};
3218
Takashi Iwai2b635362011-05-02 12:33:43 +02003219static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02003220 .channels_min = 2,
3221 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003222 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02003223 .ops = {
3224 .prepare = stac92xx_capture_pcm_prepare,
3225 .cleanup = stac92xx_capture_pcm_cleanup
3226 },
3227};
3228
3229static int stac92xx_build_pcms(struct hda_codec *codec)
3230{
3231 struct sigmatel_spec *spec = codec->spec;
3232 struct hda_pcm *info = spec->pcm_rec;
3233
3234 codec->num_pcms = 1;
3235 codec->pcm_info = info;
3236
Mattc7d4b2f2005-06-27 14:59:41 +02003237 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02003238 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01003239 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3240 spec->multiout.dac_nids[0];
Takashi Iwaiee81abb2012-11-08 17:12:10 +01003241 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3242 spec->autocfg.line_outs == 2)
3243 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
3244 snd_pcm_2_1_chmaps;
3245
Matt2f2f4252005-04-13 14:45:30 +02003246 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003247 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003248 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01003249
3250 if (spec->alt_switch) {
3251 codec->num_pcms++;
3252 info++;
3253 info->name = "STAC92xx Analog Alt";
3254 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
3255 }
Matt2f2f4252005-04-13 14:45:30 +02003256
Mattdabbed62005-06-14 10:19:34 +02003257 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3258 codec->num_pcms++;
3259 info++;
3260 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003261 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02003262 if (spec->multiout.dig_out_nid) {
3263 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
3264 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3265 }
3266 if (spec->dig_in_nid) {
3267 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
3268 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3269 }
3270 }
3271
Matt2f2f4252005-04-13 14:45:30 +02003272 return 0;
3273}
3274
Matt Porter403d1942005-11-29 15:00:51 +01003275static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
3276
3277{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02003278 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01003279}
3280
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003281#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
3282
3283static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
3284 struct snd_ctl_elem_value *ucontrol)
3285{
3286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3287 struct sigmatel_spec *spec = codec->spec;
3288
Takashi Iwaid7a89432008-11-12 09:48:04 +01003289 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003290 return 0;
3291}
3292
Takashi Iwai62558ce2009-07-29 14:23:09 +02003293static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01003294
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003295static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
3296 struct snd_ctl_elem_value *ucontrol)
3297{
3298 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3299 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003300 int nid = kcontrol->private_value;
3301
3302 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003303
Lucas De Marchi25985ed2011-03-30 22:57:33 -03003304 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003305 * switch changes
3306 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02003307 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003308
3309 return 1;
3310}
3311
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003312static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
3313 struct snd_ctl_elem_info *uinfo)
3314{
3315 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02003316 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003317 "Mic In", "Line In", "Line Out"
3318 };
3319
3320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3321 struct sigmatel_spec *spec = codec->spec;
3322 hda_nid_t nid = kcontrol->private_value;
3323
3324 if (nid == spec->mic_switch || nid == spec->line_switch)
3325 i = 3;
3326 else
3327 i = 2;
3328
3329 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3330 uinfo->value.enumerated.items = i;
3331 uinfo->count = 1;
3332 if (uinfo->value.enumerated.item >= i)
3333 uinfo->value.enumerated.item = i-1;
3334 strcpy(uinfo->value.enumerated.name,
3335 texts[uinfo->value.enumerated.item]);
3336
3337 return 0;
3338}
3339
3340static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
3341 struct snd_ctl_elem_value *ucontrol)
3342{
3343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3344 hda_nid_t nid = kcontrol->private_value;
3345 unsigned int vref = stac92xx_vref_get(codec, nid);
3346
Takashi Iwai47408602012-04-20 13:06:53 +02003347 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003348 ucontrol->value.enumerated.item[0] = 0;
3349 else if (vref == AC_PINCTL_VREF_GRD)
3350 ucontrol->value.enumerated.item[0] = 1;
3351 else if (vref == AC_PINCTL_VREF_HIZ)
3352 ucontrol->value.enumerated.item[0] = 2;
3353
3354 return 0;
3355}
3356
3357static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
3358 struct snd_ctl_elem_value *ucontrol)
3359{
3360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3361 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02003362 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003363 hda_nid_t nid = kcontrol->private_value;
3364
3365 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02003366 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003367 else if (ucontrol->value.enumerated.item[0] == 1)
3368 new_vref = AC_PINCTL_VREF_GRD;
3369 else if (ucontrol->value.enumerated.item[0] == 2)
3370 new_vref = AC_PINCTL_VREF_HIZ;
3371 else
3372 return 0;
3373
3374 if (new_vref != stac92xx_vref_get(codec, nid)) {
3375 error = stac92xx_vref_set(codec, nid, new_vref);
3376 return error;
3377 }
3378
3379 return 0;
3380}
3381
3382static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
3383 struct snd_ctl_elem_info *uinfo)
3384{
Takashi Iwai2b635362011-05-02 12:33:43 +02003385 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3387 struct sigmatel_spec *spec = codec->spec;
3388
3389 if (kcontrol->private_value == spec->line_switch)
3390 texts[0] = "Line In";
3391 else
3392 texts[0] = "Mic In";
3393 texts[1] = "Line Out";
3394 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3395 uinfo->value.enumerated.items = 2;
3396 uinfo->count = 1;
3397
3398 if (uinfo->value.enumerated.item >= 2)
3399 uinfo->value.enumerated.item = 1;
3400 strcpy(uinfo->value.enumerated.name,
3401 texts[uinfo->value.enumerated.item]);
3402
3403 return 0;
3404}
Matt Porter403d1942005-11-29 15:00:51 +01003405
3406static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3407{
3408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3409 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003410 hda_nid_t nid = kcontrol->private_value;
3411 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01003412
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003413 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01003414 return 0;
3415}
3416
3417static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3418{
3419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3420 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003421 hda_nid_t nid = kcontrol->private_value;
3422 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3423 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01003424
3425 spec->io_switch[io_idx] = val;
3426
3427 if (val)
3428 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01003429 else {
3430 unsigned int pinctl = AC_PINCTL_IN_EN;
3431 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02003432 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01003433 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3434 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01003435
3436 /* check the auto-mute again: we need to mute/unmute the speaker
3437 * appropriately according to the pin direction
3438 */
3439 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02003440 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01003441
Matt Porter403d1942005-11-29 15:00:51 +01003442 return 1;
3443}
3444
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003445#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
3446
3447static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
3448 struct snd_ctl_elem_value *ucontrol)
3449{
3450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3451 struct sigmatel_spec *spec = codec->spec;
3452
3453 ucontrol->value.integer.value[0] = spec->clfe_swap;
3454 return 0;
3455}
3456
3457static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
3458 struct snd_ctl_elem_value *ucontrol)
3459{
3460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3461 struct sigmatel_spec *spec = codec->spec;
3462 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003463 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003464
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003465 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003466 return 0;
3467
Takashi Iwai68ea7b22007-11-15 15:54:38 +01003468 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003469
3470 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
3471 spec->clfe_swap ? 0x4 : 0x0);
3472
3473 return 1;
3474}
3475
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003476#define STAC_CODEC_HP_SWITCH(xname) \
3477 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3478 .name = xname, \
3479 .index = 0, \
3480 .info = stac92xx_hp_switch_info, \
3481 .get = stac92xx_hp_switch_get, \
3482 .put = stac92xx_hp_switch_put, \
3483 }
3484
Matt Porter403d1942005-11-29 15:00:51 +01003485#define STAC_CODEC_IO_SWITCH(xname, xpval) \
3486 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3487 .name = xname, \
3488 .index = 0, \
3489 .info = stac92xx_io_switch_info, \
3490 .get = stac92xx_io_switch_get, \
3491 .put = stac92xx_io_switch_put, \
3492 .private_value = xpval, \
3493 }
3494
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003495#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
3496 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3497 .name = xname, \
3498 .index = 0, \
3499 .info = stac92xx_clfe_switch_info, \
3500 .get = stac92xx_clfe_switch_get, \
3501 .put = stac92xx_clfe_switch_put, \
3502 .private_value = xpval, \
3503 }
Matt Porter403d1942005-11-29 15:00:51 +01003504
Mattc7d4b2f2005-06-27 14:59:41 +02003505enum {
3506 STAC_CTL_WIDGET_VOL,
3507 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003508 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01003509 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003510 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01003511 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003512 STAC_CTL_WIDGET_CLFE_SWITCH,
3513 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02003514};
3515
Takashi Iwai2b635362011-05-02 12:33:43 +02003516static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02003517 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3518 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003519 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01003520 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003521 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01003522 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003523 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02003524 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02003525};
3526
3527/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01003528static struct snd_kcontrol_new *
3529stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003530 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01003531 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003532 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02003533{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003534 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02003535
Takashi Iwai603c4012008-07-30 15:01:44 +02003536 knew = snd_array_new(&spec->kctls);
3537 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01003538 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003539 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02003540 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01003541 if (!knew->name) {
3542 /* roolback */
3543 memset(knew, 0, sizeof(*knew));
3544 spec->kctls.alloced--;
3545 return NULL;
3546 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01003547 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01003548 return knew;
3549}
3550
Takashi Iwai62cbde12012-09-14 11:58:54 +02003551static struct snd_kcontrol_new *
3552add_control_temp(struct sigmatel_spec *spec,
3553 const struct snd_kcontrol_new *ktemp,
3554 int idx, const char *name,
3555 unsigned long val)
3556{
3557 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
3558 HDA_SUBDEV_AMP_FLAG);
3559 if (!knew)
3560 return NULL;
3561 knew->index = idx;
3562 knew->private_value = val;
3563 return knew;
3564}
3565
Takashi Iwaie3c75962009-01-23 11:57:22 +01003566static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02003567 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01003568 int idx, const char *name,
3569 unsigned long val)
3570{
Takashi Iwai62cbde12012-09-14 11:58:54 +02003571 return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM;
Mattc7d4b2f2005-06-27 14:59:41 +02003572}
3573
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003574static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
3575 int type, int idx, const char *name,
3576 unsigned long val)
3577{
3578 return stac92xx_add_control_temp(spec,
3579 &stac92xx_control_templates[type],
3580 idx, name, val);
3581}
3582
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003583
3584/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003585static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
3586 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003587{
3588 return stac92xx_add_control_idx(spec, type, 0, name, val);
3589}
3590
Takashi Iwai2b635362011-05-02 12:33:43 +02003591static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01003592 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3593 .name = "Input Source",
3594 .info = stac92xx_mux_enum_info,
3595 .get = stac92xx_mux_enum_get,
3596 .put = stac92xx_mux_enum_put,
3597};
3598
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003599static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
3600 hda_nid_t nid, int idx)
3601{
3602 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3603 int control = 0;
3604 struct sigmatel_spec *spec = codec->spec;
3605 char name[22];
3606
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003607 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
David Henningsson8d032a82012-10-09 12:48:40 +02003608 if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf)
3609 != INPUT_PIN_ATTR_DOCK)
3610 return 0;
Takashi Iwai47408602012-04-20 13:06:53 +02003611 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003612 && nid == spec->line_switch)
3613 control = STAC_CTL_WIDGET_IO_SWITCH;
3614 else if (snd_hda_query_pin_caps(codec, nid)
3615 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
3616 control = STAC_CTL_WIDGET_DC_BIAS;
3617 else if (nid == spec->mic_switch)
3618 control = STAC_CTL_WIDGET_IO_SWITCH;
3619 }
3620
3621 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01003622 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3623 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003624 return stac92xx_add_control(codec->spec, control,
3625 strcat(name, " Jack Mode"), nid);
3626 }
3627
3628 return 0;
3629}
3630
Takashi Iwaie3c75962009-01-23 11:57:22 +01003631static int stac92xx_add_input_source(struct sigmatel_spec *spec)
3632{
3633 struct snd_kcontrol_new *knew;
3634 struct hda_input_mux *imux = &spec->private_imux;
3635
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003636 if (spec->auto_mic)
3637 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01003638 if (!spec->num_adcs || imux->num_items <= 1)
3639 return 0; /* no need for input source control */
3640 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01003641 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01003642 if (!knew)
3643 return -ENOMEM;
3644 knew->count = spec->num_adcs;
3645 return 0;
3646}
3647
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003648/* check whether the line-input can be used as line-out */
3649static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01003650{
3651 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003652 struct auto_pin_cfg *cfg = &spec->autocfg;
3653 hda_nid_t nid;
3654 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003655 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01003656
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003657 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3658 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003659 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003660 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003661 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01003662 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003663 if (pincap & AC_PINCAP_OUT)
3664 return nid;
3665 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003666 }
Matt Porter403d1942005-11-29 15:00:51 +01003667 return 0;
3668}
3669
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003670static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
3671
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003672/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003673static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003674{
3675 struct sigmatel_spec *spec = codec->spec;
3676 struct auto_pin_cfg *cfg = &spec->autocfg;
3677 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02003678 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003679
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003680 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003681 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3682 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003683 for (i = 0; i < cfg->num_inputs; i++) {
3684 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02003685 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003686 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003687 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3688 /* some laptops have an internal analog microphone
3689 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003690 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003691 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003692 if (pincap & AC_PINCAP_OUT) {
3693 *dac = get_unassigned_dac(codec, nid);
3694 if (*dac)
3695 return nid;
3696 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003697 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003698 }
3699 return 0;
3700}
Steve Longerbeam7b043892007-05-03 20:50:03 +02003701
3702static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3703{
3704 int i;
3705
3706 for (i = 0; i < spec->multiout.num_dacs; i++) {
3707 if (spec->multiout.dac_nids[i] == nid)
3708 return 1;
3709 }
3710
3711 return 0;
3712}
3713
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003714static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3715{
3716 int i;
3717 if (is_in_dac_nids(spec, nid))
3718 return 1;
3719 for (i = 0; i < spec->autocfg.hp_outs; i++)
3720 if (spec->hp_dacs[i] == nid)
3721 return 1;
3722 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3723 if (spec->speaker_dacs[i] == nid)
3724 return 1;
3725 return 0;
3726}
3727
3728static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3729{
3730 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02003731 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003732 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02003733 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003734 unsigned int wcaps, wtype;
3735
3736 conn_len = snd_hda_get_connections(codec, nid, conn,
3737 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01003738 /* 92HD88: trace back up the link of nids to find the DAC */
3739 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
3740 != AC_WID_AUD_OUT)) {
3741 nid = conn[0];
3742 conn_len = snd_hda_get_connections(codec, nid, conn,
3743 HDA_MAX_CONNECTIONS);
3744 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003745 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01003746 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003747 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003748 /* we check only analog outputs */
3749 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3750 continue;
3751 /* if this route has a free DAC, assign it */
3752 if (!check_all_dac_nids(spec, conn[j])) {
3753 if (conn_len > 1) {
3754 /* select this DAC in the pin's input mux */
3755 snd_hda_codec_write_cache(codec, nid, 0,
3756 AC_VERB_SET_CONNECT_SEL, j);
3757 }
3758 return conn[j];
3759 }
3760 }
David Henningsson48718ea2011-10-05 09:49:05 +02003761
3762 /* if all DACs are already assigned, connect to the primary DAC,
3763 unless we're assigning a secondary headphone */
3764 fallback_dac = spec->multiout.dac_nids[0];
3765 if (spec->multiout.hp_nid) {
3766 for (j = 0; j < cfg->hp_outs; j++)
3767 if (cfg->hp_pins[j] == nid) {
3768 fallback_dac = spec->multiout.hp_nid;
3769 break;
3770 }
3771 }
3772
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003773 if (conn_len > 1) {
3774 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02003775 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003776 snd_hda_codec_write_cache(codec, nid, 0,
3777 AC_VERB_SET_CONNECT_SEL, j);
3778 break;
3779 }
3780 }
3781 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003782 return 0;
3783}
3784
3785static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3786static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3787
Matt Porter3cc08dc2006-01-23 15:27:49 +01003788/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003789 * Fill in the dac_nids table from the parsed pin configuration
3790 * This function only works when every pin in line_out_pins[]
3791 * contains atleast one DAC in its connection list. Some 92xx
3792 * codecs are not connected directly to a DAC, such as the 9200
3793 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003794 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003795static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003796{
3797 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003798 struct auto_pin_cfg *cfg = &spec->autocfg;
3799 int i;
3800 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003801
Mattc7d4b2f2005-06-27 14:59:41 +02003802 for (i = 0; i < cfg->line_outs; i++) {
3803 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003804 dac = get_unassigned_dac(codec, nid);
3805 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003806 if (spec->multiout.num_dacs > 0) {
3807 /* we have already working output pins,
3808 * so let's drop the broken ones again
3809 */
3810 cfg->line_outs = spec->multiout.num_dacs;
3811 break;
3812 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003813 /* error out, no available DAC found */
3814 snd_printk(KERN_ERR
3815 "%s: No available DAC for pin 0x%x\n",
3816 __func__, nid);
3817 return -ENODEV;
3818 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003819 add_spec_dacs(spec, dac);
3820 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003821
Takashi Iwai139e0712009-03-06 12:10:41 +01003822 for (i = 0; i < cfg->hp_outs; i++) {
3823 nid = cfg->hp_pins[i];
3824 dac = get_unassigned_dac(codec, nid);
3825 if (dac) {
3826 if (!spec->multiout.hp_nid)
3827 spec->multiout.hp_nid = dac;
3828 else
3829 add_spec_extra_dacs(spec, dac);
3830 }
3831 spec->hp_dacs[i] = dac;
3832 }
3833
3834 for (i = 0; i < cfg->speaker_outs; i++) {
3835 nid = cfg->speaker_pins[i];
3836 dac = get_unassigned_dac(codec, nid);
3837 if (dac)
3838 add_spec_extra_dacs(spec, dac);
3839 spec->speaker_dacs[i] = dac;
3840 }
3841
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003842 /* add line-in as output */
3843 nid = check_line_out_switch(codec);
3844 if (nid) {
3845 dac = get_unassigned_dac(codec, nid);
3846 if (dac) {
3847 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3848 nid, cfg->line_outs);
3849 cfg->line_out_pins[cfg->line_outs] = nid;
3850 cfg->line_outs++;
3851 spec->line_switch = nid;
3852 add_spec_dacs(spec, dac);
3853 }
3854 }
3855 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003856 nid = check_mic_out_switch(codec, &dac);
3857 if (nid && dac) {
3858 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3859 nid, cfg->line_outs);
3860 cfg->line_out_pins[cfg->line_outs] = nid;
3861 cfg->line_outs++;
3862 spec->mic_switch = nid;
3863 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003864 }
3865
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003866 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003867 spec->multiout.num_dacs,
3868 spec->multiout.dac_nids[0],
3869 spec->multiout.dac_nids[1],
3870 spec->multiout.dac_nids[2],
3871 spec->multiout.dac_nids[3],
3872 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003873
Mattc7d4b2f2005-06-27 14:59:41 +02003874 return 0;
3875}
3876
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003877/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003878static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3879 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003880{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003881 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003882 char name[32];
3883 int err;
3884
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003885 if (!spec->check_volume_offset) {
3886 unsigned int caps, step, nums, db_scale;
3887 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3888 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3889 AC_AMPCAP_STEP_SIZE_SHIFT;
3890 step = (step + 1) * 25; /* in .01dB unit */
3891 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3892 AC_AMPCAP_NUM_STEPS_SHIFT;
3893 db_scale = nums * step;
3894 /* if dB scale is over -64dB, and finer enough,
3895 * let's reduce it to half
3896 */
3897 if (db_scale > 6400 && nums >= 0x1f)
3898 spec->volume_offset = nums / 2;
3899 spec->check_volume_offset = 1;
3900 }
3901
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003902 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003903 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003904 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3905 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003906 if (err < 0)
3907 return err;
3908 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003909 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003910 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3911 if (err < 0)
3912 return err;
3913 return 0;
3914}
3915
Takashi Iwai668b9652009-03-06 10:13:24 +01003916#define create_controls(codec, pfx, nid, chs) \
3917 create_controls_idx(codec, pfx, 0, nid, chs)
3918
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003919static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3920{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003921 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003922 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3923 return 1;
3924 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003925 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3926 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003927 spec->multiout.num_dacs++;
3928 }
3929 return 0;
3930}
3931
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003932static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003933{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003934 int i;
3935 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3936 if (!spec->multiout.extra_out_nid[i]) {
3937 spec->multiout.extra_out_nid[i] = nid;
3938 return 0;
3939 }
3940 }
3941 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3942 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003943}
3944
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003945/* Create output controls
3946 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3947 */
3948static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3949 const hda_nid_t *pins,
3950 const hda_nid_t *dac_nids,
3951 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003952{
Takashi Iwai76624532008-12-19 10:09:47 +01003953 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003954 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003955 "Front", "Surround", NULL /*CLFE*/, "Side"
3956 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003957 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003958 int i, err;
3959 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003960
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003961 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003962 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003963 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003964 spec->hp_detect = 1;
3965 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003966 nid = dac_nids[i];
3967 if (!nid)
3968 continue;
3969 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003970 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003971 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003972 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003973 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003974 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003975 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003976 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003977
3978 wid_caps = get_wcaps(codec, nid);
3979
3980 if (wid_caps & AC_WCAP_LR_SWAP) {
3981 err = stac92xx_add_control(spec,
3982 STAC_CTL_WIDGET_CLFE_SWITCH,
3983 "Swap Center/LFE Playback Switch", nid);
3984
3985 if (err < 0)
3986 return err;
3987 }
3988
Mattc7d4b2f2005-06-27 14:59:41 +02003989 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003990 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003991 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003992 switch (type) {
3993 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003994 name = "Headphone";
3995 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003996 break;
3997 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwaif37bc7a2012-11-08 15:59:23 +01003998 if (num_outs <= 2) {
3999 name = i ? "Bass Speaker" : "Speaker";
4000 idx = 0;
David Henningsson298efee2012-09-06 11:17:58 +02004001 break;
4002 }
4003 /* Fall through in case of multi speaker outs */
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004004 default:
4005 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01004006 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004007 break;
Takashi Iwai76624532008-12-19 10:09:47 +01004008 }
Takashi Iwai668b9652009-03-06 10:13:24 +01004009 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004010 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004011 return err;
4012 }
4013 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004014 return 0;
4015}
4016
Takashi Iwai62cbde12012-09-14 11:58:54 +02004017static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4018 unsigned int dir_mask, unsigned int data);
4019
4020/* hook for controlling mic-mute LED GPIO */
4021static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol,
4022 struct snd_ctl_elem_value *ucontrol)
4023{
4024 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4025 struct sigmatel_spec *spec = codec->spec;
4026 int err;
4027 bool mute;
4028
4029 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4030 if (err <= 0)
4031 return err;
4032 mute = !(ucontrol->value.integer.value[0] &&
4033 ucontrol->value.integer.value[1]);
4034 if (spec->mic_mute_led_on != mute) {
4035 spec->mic_mute_led_on = mute;
4036 if (mute)
4037 spec->gpio_data |= spec->mic_mute_led_gpio;
4038 else
4039 spec->gpio_data &= ~spec->mic_mute_led_gpio;
4040 stac_gpio_set(codec, spec->gpio_mask,
4041 spec->gpio_dir, spec->gpio_data);
4042 }
4043 return err;
4044}
4045
Takashi Iwai6479c632009-07-28 18:20:25 +02004046static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
4047 unsigned long sw, int idx)
4048{
Takashi Iwai62cbde12012-09-14 11:58:54 +02004049 struct sigmatel_spec *spec = codec->spec;
4050 struct snd_kcontrol_new *knew;
Takashi Iwai6479c632009-07-28 18:20:25 +02004051 int err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004052
Takashi Iwai6479c632009-07-28 18:20:25 +02004053 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02004054 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02004055 if (err < 0)
4056 return err;
Takashi Iwai62cbde12012-09-14 11:58:54 +02004057
4058 knew = add_control_temp(spec,
4059 &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE],
4060 idx, "Capture Switch", sw);
4061 if (!knew)
4062 return -ENOMEM;
4063 /* add a LED hook for some HP laptops */
4064 if (spec->mic_mute_led_gpio)
4065 knew->put = stac92xx_capture_sw_put_led;
4066
Takashi Iwai6479c632009-07-28 18:20:25 +02004067 return 0;
4068}
4069
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004070/* add playback controls from the parsed DAC table */
4071static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
4072 const struct auto_pin_cfg *cfg)
4073{
4074 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004075 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004076 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02004077 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004078
4079 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
4080 spec->multiout.dac_nids,
4081 cfg->line_out_type);
4082 if (err < 0)
4083 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004084
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01004085 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004086 err = stac92xx_add_control(spec,
4087 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01004088 "Headphone as Line Out Switch",
4089 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004090 if (err < 0)
4091 return err;
4092 }
4093
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004094 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02004095 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004096 break;
4097 nid = cfg->inputs[idx].pin;
4098 err = stac92xx_add_jack_mode_control(codec, nid, idx);
4099 if (err < 0)
4100 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01004101 }
Matt Porter403d1942005-11-29 15:00:51 +01004102
Mattc7d4b2f2005-06-27 14:59:41 +02004103 return 0;
4104}
4105
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004106/* add playback controls for Speaker and HP outputs */
4107static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
4108 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02004109{
4110 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004111 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02004112
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004113 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
4114 spec->hp_dacs, AUTO_PIN_HP_OUT);
4115 if (err < 0)
4116 return err;
4117
4118 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
4119 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
4120 if (err < 0)
4121 return err;
4122
Mattc7d4b2f2005-06-27 14:59:41 +02004123 return 0;
4124}
4125
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004126/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004127static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004128 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004129};
4130
4131/* create mono mux for mono out on capable codecs */
4132static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
4133{
4134 struct sigmatel_spec *spec = codec->spec;
4135 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
4136 int i, num_cons;
4137 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
4138
4139 num_cons = snd_hda_get_connections(codec,
4140 spec->mono_nid,
4141 con_lst,
4142 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004143 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004144 return -EINVAL;
4145
Takashi Iwai10a20af2010-09-09 16:28:02 +02004146 for (i = 0; i < num_cons; i++)
4147 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
4148 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004149
4150 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
4151 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004152}
4153
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004154/* create PC beep volume controls */
4155static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
4156 hda_nid_t nid)
4157{
4158 struct sigmatel_spec *spec = codec->spec;
4159 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004160 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
4161
4162 if (spec->anabeep_nid == nid)
4163 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004164
4165 /* check for mute support for the the amp */
4166 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004167 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004168 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004169 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4170 if (err < 0)
4171 return err;
4172 }
4173
4174 /* check to see if there is volume support for the amp */
4175 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4176 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004177 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004178 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4179 if (err < 0)
4180 return err;
4181 }
4182 return 0;
4183}
4184
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004185#ifdef CONFIG_SND_HDA_INPUT_BEEP
4186#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
4187
4188static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
4189 struct snd_ctl_elem_value *ucontrol)
4190{
4191 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4192 ucontrol->value.integer.value[0] = codec->beep->enabled;
4193 return 0;
4194}
4195
4196static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
4197 struct snd_ctl_elem_value *ucontrol)
4198{
4199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02004200 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004201}
4202
Takashi Iwai2b635362011-05-02 12:33:43 +02004203static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4205 .info = stac92xx_dig_beep_switch_info,
4206 .get = stac92xx_dig_beep_switch_get,
4207 .put = stac92xx_dig_beep_switch_put,
4208};
4209
4210static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
4211{
4212 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01004213 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004214}
4215#endif
4216
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004217static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
4218{
4219 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02004220 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004221
4222 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004223 hda_nid_t nid;
4224 unsigned int wcaps;
4225 unsigned long val;
4226
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004227 nid = spec->mux_nids[i];
4228 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02004229 if (!(wcaps & AC_WCAP_OUT_AMP))
4230 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004231
Takashi Iwai667067d2009-08-13 18:14:42 +02004232 /* check whether already the same control was created as
4233 * normal Capture Volume.
4234 */
4235 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4236 for (j = 0; j < spec->num_caps; j++) {
4237 if (spec->capvols[j] == val)
4238 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004239 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004240 if (j < spec->num_caps)
4241 continue;
4242
4243 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
4244 "Mux Capture Volume", val);
4245 if (err < 0)
4246 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004247 }
4248 return 0;
4249};
4250
Takashi Iwaiea734962011-01-17 11:29:34 +01004251static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04004252 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02004253};
4254
4255static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
4256{
4257 struct sigmatel_spec *spec = codec->spec;
4258 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01004259 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004260 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04004261 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02004262
4263 num_cons = snd_hda_get_connections(codec,
4264 spec->smux_nids[0],
4265 con_lst,
4266 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004267 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02004268 return -EINVAL;
4269
Matthew Ranostay65973632008-09-16 10:39:37 -04004270 if (!labels)
4271 labels = stac92xx_spdif_labels;
4272
Takashi Iwai10a20af2010-09-09 16:28:02 +02004273 for (i = 0; i < num_cons; i++)
4274 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004275
4276 return 0;
4277}
4278
Matt Porter8b657272006-10-26 17:12:59 +02004279/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01004280static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02004281 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
4282 "Digital Mic 3", "Digital Mic 4"
4283};
4284
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004285static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
4286 int idx)
4287{
4288 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4289 int nums;
4290 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
4291 if (idx >= 0 && idx < nums)
4292 return conn[idx];
4293 return 0;
4294}
4295
Takashi Iwai8d087c72011-06-28 12:45:47 +02004296/* look for NID recursively */
4297#define get_connection_index(codec, mux, nid) \
4298 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004299
Takashi Iwai667067d2009-08-13 18:14:42 +02004300/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02004301/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02004302static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004303 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02004304{
4305 unsigned int caps, nums;
4306 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02004307 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02004308
Takashi Iwai96f845d2009-08-29 00:49:36 +02004309 if (direction == HDA_OUTPUT)
4310 caps = AC_WCAP_OUT_AMP;
4311 else
4312 caps = AC_WCAP_IN_AMP;
4313 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02004314 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004315 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02004316 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
4317 if (!nums)
4318 return 0;
4319 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004320 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
4321 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02004322 if (err < 0)
4323 return err;
4324 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02004325}
4326
Matt Porter8b657272006-10-26 17:12:59 +02004327/* create playback/capture controls for input pins on dmic capable codecs */
4328static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
4329 const struct auto_pin_cfg *cfg)
4330{
4331 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02004332 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004333 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004334 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02004335 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02004336
Takashi Iwai10a20af2010-09-09 16:28:02 +02004337 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02004338
Matt Porter8b657272006-10-26 17:12:59 +02004339 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01004340 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004341 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01004342 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02004343
Takashi Iwai667067d2009-08-13 18:14:42 +02004344 nid = spec->dmic_nids[i];
4345 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
4346 continue;
4347 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02004348 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
4349 continue;
4350
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004351 index = get_connection_index(codec, spec->dmux_nids[0], nid);
4352 if (index < 0)
4353 continue;
4354
Takashi Iwai201e06f2011-11-16 15:33:26 +01004355 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4356 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02004357 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01004358 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
4359 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02004360
Takashi Iwai10a20af2010-09-09 16:28:02 +02004361 err = create_elem_capture_vol(codec, nid, label, type_idx,
4362 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004363 if (err < 0)
4364 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02004365 if (!err) {
4366 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02004367 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02004368 if (err < 0)
4369 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06004370 if (!err) {
4371 nid = get_connected_node(codec,
4372 spec->dmux_nids[0], index);
4373 if (nid)
4374 err = create_elem_capture_vol(codec,
4375 nid, label,
4376 type_idx, HDA_INPUT);
4377 if (err < 0)
4378 return err;
4379 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02004380 }
Matt Porter8b657272006-10-26 17:12:59 +02004381 }
4382
4383 return 0;
4384}
4385
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004386static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02004387 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004388{
4389 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004390 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004391
4392 if (!nid)
4393 return 0;
4394 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004395 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004396 switch (snd_hda_get_input_pin_attr(cfg)) {
4397 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004398 if (*fixed)
4399 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004400 if (type != AC_JACK_MIC_IN)
4401 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004402 *fixed = nid;
4403 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004404 case INPUT_PIN_ATTR_UNUSED:
4405 break;
4406 case INPUT_PIN_ATTR_DOCK:
4407 if (*dock)
4408 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004409 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
4410 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02004411 *dock = nid;
4412 break;
4413 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004414 if (*ext)
4415 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02004416 if (type != AC_JACK_MIC_IN)
4417 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004418 *ext = nid;
4419 break;
4420 }
4421 return 0;
4422}
4423
4424static int set_mic_route(struct hda_codec *codec,
4425 struct sigmatel_mic_route *mic,
4426 hda_nid_t pin)
4427{
4428 struct sigmatel_spec *spec = codec->spec;
4429 struct auto_pin_cfg *cfg = &spec->autocfg;
4430 int i;
4431
4432 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02004433 if (pin == 0)
4434 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004435 for (i = 0; i < cfg->num_inputs; i++) {
4436 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004437 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004438 }
Takashi Iwai86e29592010-09-09 14:50:17 +02004439 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004440 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004441 i = get_connection_index(codec, spec->mux_nids[0], pin);
4442 if (i < 0)
4443 return -1;
4444 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02004445 mic->dmux_idx = -1;
4446 if (spec->dmux_nids)
4447 mic->dmux_idx = get_connection_index(codec,
4448 spec->dmux_nids[0],
4449 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004450 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004451 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004452 i = get_connection_index(codec, spec->dmux_nids[0], pin);
4453 if (i < 0)
4454 return -1;
4455 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02004456 mic->mux_idx = -1;
4457 if (spec->mux_nids)
4458 mic->mux_idx = get_connection_index(codec,
4459 spec->mux_nids[0],
4460 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004461 }
4462 return 0;
4463}
4464
4465/* return non-zero if the device is for automatic mic switch */
4466static int stac_check_auto_mic(struct hda_codec *codec)
4467{
4468 struct sigmatel_spec *spec = codec->spec;
4469 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02004470 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004471 int i;
4472
Charles Chin99077902010-09-17 10:22:32 +02004473 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004474 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02004475 if (check_mic_pin(codec, cfg->inputs[i].pin,
4476 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004477 return 0;
4478 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02004479 if (check_mic_pin(codec, spec->dmic_nids[i],
4480 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004481 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01004482 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02004483 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004484 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004485 return 0; /* no unsol support */
4486 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02004487 set_mic_route(codec, &spec->int_mic, fixed) ||
4488 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004489 return 0; /* something is wrong */
4490 return 1;
4491}
4492
Mattc7d4b2f2005-06-27 14:59:41 +02004493/* create playback/capture controls for input pins */
4494static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
4495{
4496 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004497 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02004498 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004499 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02004500
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004501 for (i = 0; i < cfg->num_inputs; i++) {
4502 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02004503 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02004504
Takashi Iwai314634b2006-09-21 11:56:18 +02004505 index = -1;
4506 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02004507 index = get_connection_index(codec, spec->mux_nids[j],
4508 nid);
4509 if (index >= 0)
4510 break;
Mattc7d4b2f2005-06-27 14:59:41 +02004511 }
Takashi Iwai667067d2009-08-13 18:14:42 +02004512 if (index < 0)
4513 continue;
4514
Takashi Iwai10a20af2010-09-09 16:28:02 +02004515 label = hda_get_autocfg_input_label(codec, cfg, i);
4516 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004517
Takashi Iwai667067d2009-08-13 18:14:42 +02004518 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02004519 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02004520 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02004521 if (err < 0)
4522 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02004523 }
Takashi Iwai5207e102009-07-30 13:09:08 +02004524 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02004525
Steve Longerbeam7b043892007-05-03 20:50:03 +02004526 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02004527 /*
4528 * Set the current input for the muxes.
4529 * The STAC9221 has two input muxes with identical source
4530 * NID lists. Hopefully this won't get confused.
4531 */
4532 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004533 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
4534 AC_VERB_SET_CONNECT_SEL,
4535 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004536 }
4537 }
4538
Mattc7d4b2f2005-06-27 14:59:41 +02004539 return 0;
4540}
4541
Mattc7d4b2f2005-06-27 14:59:41 +02004542static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
4543{
4544 struct sigmatel_spec *spec = codec->spec;
4545 int i;
4546
4547 for (i = 0; i < spec->autocfg.line_outs; i++) {
4548 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4549 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
4550 }
4551}
4552
4553static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
4554{
4555 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004556 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004557
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004558 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4559 hda_nid_t pin;
4560 pin = spec->autocfg.hp_pins[i];
4561 if (pin) /* connect to front */
4562 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
4563 }
4564 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
4565 hda_nid_t pin;
4566 pin = spec->autocfg.speaker_pins[i];
4567 if (pin) /* connect to front */
4568 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
4569 }
Mattc7d4b2f2005-06-27 14:59:41 +02004570}
4571
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01004572static int is_dual_headphones(struct hda_codec *codec)
4573{
4574 struct sigmatel_spec *spec = codec->spec;
4575 int i, valid_hps;
4576
4577 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
4578 spec->autocfg.hp_outs <= 1)
4579 return 0;
4580 valid_hps = 0;
4581 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4582 hda_nid_t nid = spec->autocfg.hp_pins[i];
4583 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
4584 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
4585 continue;
4586 valid_hps++;
4587 }
4588 return (valid_hps > 1);
4589}
4590
4591
Charles Chin9009b0e2011-11-03 10:27:27 +01004592static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02004593{
4594 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01004595 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004596 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02004597 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02004598
Matt Porter8b657272006-10-26 17:12:59 +02004599 if ((err = snd_hda_parse_pin_def_config(codec,
4600 &spec->autocfg,
4601 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004602 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004603 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01004604 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02004605
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004606 /* If we have no real line-out pin and multiple hp-outs, HPs should
4607 * be set up as multi-channel outputs.
4608 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01004609 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004610 /* Copy hp_outs to line_outs, backup line_outs in
4611 * speaker_outs so that the following routines can handle
4612 * HP pins as primary outputs.
4613 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004614 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004615 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
4616 sizeof(spec->autocfg.line_out_pins));
4617 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
4618 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
4619 sizeof(spec->autocfg.hp_pins));
4620 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004621 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
4622 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004623 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004624 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01004625 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004626 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
4627 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004628 u32 caps = query_amp_caps(codec,
4629 spec->autocfg.mono_out_pin, dir);
4630 hda_nid_t conn_list[1];
4631
4632 /* get the mixer node and then the mono mux if it exists */
4633 if (snd_hda_get_connections(codec,
4634 spec->autocfg.mono_out_pin, conn_list, 1) &&
4635 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02004636 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01004637
4638 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02004639 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01004640 /* LR swap check, some stac925x have a mux that
4641 * changes the DACs output path instead of the
4642 * mono-mux path.
4643 */
4644 if (wid_type == AC_WID_AUD_SEL &&
4645 !(wcaps & AC_WCAP_LR_SWAP))
4646 spec->mono_nid = conn_list[0];
4647 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004648 if (dir) {
4649 hda_nid_t nid = spec->autocfg.mono_out_pin;
4650
4651 /* most mono outs have a least a mute/unmute switch */
4652 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
4653 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
4654 "Mono Playback Switch",
4655 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01004656 if (err < 0)
4657 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004658 /* check for volume support for the amp */
4659 if ((caps & AC_AMPCAP_NUM_STEPS)
4660 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4661 err = stac92xx_add_control(spec,
4662 STAC_CTL_WIDGET_VOL,
4663 "Mono Playback Volume",
4664 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
4665 if (err < 0)
4666 return err;
4667 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01004668 }
4669
4670 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
4671 AC_PINCTL_OUT_EN);
4672 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01004673
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004674 if (!spec->multiout.num_dacs) {
4675 err = stac92xx_auto_fill_dac_nids(codec);
4676 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02004677 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01004678 err = stac92xx_auto_create_multi_out_ctls(codec,
4679 &spec->autocfg);
4680 if (err < 0)
4681 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004682 }
Mattc7d4b2f2005-06-27 14:59:41 +02004683
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004684 /* setup analog beep controls */
4685 if (spec->anabeep_nid > 0) {
4686 err = stac92xx_auto_create_beep_ctls(codec,
4687 spec->anabeep_nid);
4688 if (err < 0)
4689 return err;
4690 }
4691
4692 /* setup digital beep controls and input device */
4693#ifdef CONFIG_SND_HDA_INPUT_BEEP
4694 if (spec->digbeep_nid > 0) {
4695 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004696 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004697
4698 err = stac92xx_auto_create_beep_ctls(codec, nid);
4699 if (err < 0)
4700 return err;
4701 err = snd_hda_attach_beep_device(codec, nid);
4702 if (err < 0)
4703 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01004704 if (codec->beep) {
4705 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01004706 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01004707 /* if no beep switch is available, make its own one */
4708 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4709 if (!(caps & AC_AMPCAP_MUTE)) {
4710 err = stac92xx_beep_switch_ctl(codec);
4711 if (err < 0)
4712 return err;
4713 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01004714 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004715 }
4716#endif
4717
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004718 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004719 if (err < 0)
4720 return err;
4721
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004722 /* All output parsing done, now restore the swapped hp pins */
4723 if (hp_swap) {
4724 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
4725 sizeof(spec->autocfg.hp_pins));
4726 spec->autocfg.hp_outs = spec->autocfg.line_outs;
4727 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
4728 spec->autocfg.line_outs = 0;
4729 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004730
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004731 if (stac_check_auto_mic(codec)) {
4732 spec->auto_mic = 1;
4733 /* only one capture for auto-mic */
4734 spec->num_adcs = 1;
4735 spec->num_caps = 1;
4736 spec->num_muxes = 1;
4737 }
4738
Takashi Iwai6479c632009-07-28 18:20:25 +02004739 for (i = 0; i < spec->num_caps; i++) {
4740 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
4741 spec->capsws[i], i);
4742 if (err < 0)
4743 return err;
4744 }
4745
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01004746 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02004747 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004748 return err;
4749
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004750 if (spec->mono_nid > 0) {
4751 err = stac92xx_auto_create_mono_output_ctls(codec);
4752 if (err < 0)
4753 return err;
4754 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004755 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02004756 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
4757 &spec->autocfg)) < 0)
4758 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02004759 if (spec->num_muxes > 0) {
4760 err = stac92xx_auto_create_mux_input_ctls(codec);
4761 if (err < 0)
4762 return err;
4763 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02004764 if (spec->num_smuxes > 0) {
4765 err = stac92xx_auto_create_spdif_mux_ctls(codec);
4766 if (err < 0)
4767 return err;
4768 }
Matt Porter8b657272006-10-26 17:12:59 +02004769
Takashi Iwaie3c75962009-01-23 11:57:22 +01004770 err = stac92xx_add_input_source(spec);
4771 if (err < 0)
4772 return err;
4773
Mattc7d4b2f2005-06-27 14:59:41 +02004774 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01004775 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02004776 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02004777
Charles Chin9009b0e2011-11-03 10:27:27 +01004778 /* find digital out and in converters */
4779 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
4780 unsigned int wid_caps = get_wcaps(codec, i);
4781 if (wid_caps & AC_WCAP_DIGITAL) {
4782 switch (get_wcaps_type(wid_caps)) {
4783 case AC_WID_AUD_OUT:
4784 if (!dig_out)
4785 dig_out = i;
4786 break;
4787 case AC_WID_AUD_IN:
4788 if (!dig_in)
4789 dig_in = i;
4790 break;
4791 }
4792 }
4793 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004794 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01004795 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004796 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01004797 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02004798
Takashi Iwai603c4012008-07-30 15:01:44 +02004799 if (spec->kctls.list)
4800 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004801
4802 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05004803 if (!spec->dinput_mux)
4804 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004805 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01004806 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02004807 return 1;
4808}
4809
Takashi Iwai82bc9552006-03-21 11:24:42 +01004810/* add playback controls for HP output */
4811static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4812 struct auto_pin_cfg *cfg)
4813{
4814 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004815 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01004816
4817 if (! pin)
4818 return 0;
4819
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004820 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01004821 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004822
4823 return 0;
4824}
4825
Richard Fish160ea0d2006-09-06 13:58:25 +02004826/* add playback controls for LFE output */
4827static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4828 struct auto_pin_cfg *cfg)
4829{
4830 struct sigmatel_spec *spec = codec->spec;
4831 int err;
4832 hda_nid_t lfe_pin = 0x0;
4833 int i;
4834
4835 /*
4836 * search speaker outs and line outs for a mono speaker pin
4837 * with an amp. If one is found, add LFE controls
4838 * for it.
4839 */
4840 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4841 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004842 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004843 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4844 if (wcaps == AC_WCAP_OUT_AMP)
4845 /* found a mono speaker with an amp, must be lfe */
4846 lfe_pin = pin;
4847 }
4848
4849 /* if speaker_outs is 0, then speakers may be in line_outs */
4850 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4851 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4852 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004853 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004854 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004855 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004856 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004857 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4858 if (wcaps == AC_WCAP_OUT_AMP)
4859 /* found a mono speaker with an amp,
4860 must be lfe */
4861 lfe_pin = pin;
4862 }
4863 }
4864 }
4865
4866 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004867 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004868 if (err < 0)
4869 return err;
4870 }
4871
4872 return 0;
4873}
4874
Mattc7d4b2f2005-06-27 14:59:41 +02004875static int stac9200_parse_auto_config(struct hda_codec *codec)
4876{
4877 struct sigmatel_spec *spec = codec->spec;
4878 int err;
4879
Kailang Yangdf694da2005-12-05 19:42:22 +01004880 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004881 return err;
4882
4883 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4884 return err;
4885
Takashi Iwai82bc9552006-03-21 11:24:42 +01004886 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4887 return err;
4888
Richard Fish160ea0d2006-09-06 13:58:25 +02004889 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4890 return err;
4891
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004892 if (spec->num_muxes > 0) {
4893 err = stac92xx_auto_create_mux_input_ctls(codec);
4894 if (err < 0)
4895 return err;
4896 }
4897
Takashi Iwaie3c75962009-01-23 11:57:22 +01004898 err = stac92xx_add_input_source(spec);
4899 if (err < 0)
4900 return err;
4901
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004902 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004903 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004904 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004905 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004906
Takashi Iwai603c4012008-07-30 15:01:44 +02004907 if (spec->kctls.list)
4908 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004909
4910 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004911 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004912
4913 return 1;
4914}
4915
Sam Revitch62fe78e2006-05-10 15:09:17 +02004916/*
4917 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4918 * funky external mute control using GPIO pins.
4919 */
4920
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004921static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004922 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004923{
4924 unsigned int gpiostate, gpiomask, gpiodir;
4925
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004926 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4927
Sam Revitch62fe78e2006-05-10 15:09:17 +02004928 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4929 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004930 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004931
4932 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4933 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004934 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004935
4936 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4937 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004938 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004939
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004940 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004941 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4942
4943 snd_hda_codec_write(codec, codec->afg, 0,
4944 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004945 snd_hda_codec_read(codec, codec->afg, 0,
4946 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004947
4948 msleep(1);
4949
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004950 snd_hda_codec_read(codec, codec->afg, 0,
4951 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004952}
4953
Takashi Iwai3a938972011-10-28 01:16:55 +02004954static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004955 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004956{
Takashi Iwai3a938972011-10-28 01:16:55 +02004957 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004958
Takashi Iwai3a938972011-10-28 01:16:55 +02004959 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004960 if (!event)
4961 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02004962 event->action = type;
4963 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004964
Takashi Iwai3a938972011-10-28 01:16:55 +02004965 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004966}
4967
David Henningsson29adc4b2012-09-25 11:31:00 +02004968static void handle_unsol_event(struct hda_codec *codec,
4969 struct hda_jack_tbl *event);
4970
Takashi Iwai62558ce2009-07-29 14:23:09 +02004971/* check if given nid is a valid pin and no other events are assigned
4972 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4973 * Otherwise, returns zero.
4974 */
4975static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4976 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004977{
Takashi Iwai3a938972011-10-28 01:16:55 +02004978 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004979
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004980 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004981 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02004982 event = snd_hda_jack_tbl_new(codec, nid);
4983 if (!event)
4984 return -ENOMEM;
4985 if (event->action && event->action != type)
4986 return 0;
4987 event->action = type;
David Henningsson29adc4b2012-09-25 11:31:00 +02004988 event->callback = handle_unsol_event;
Takashi Iwai3a938972011-10-28 01:16:55 +02004989 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004990 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004991}
4992
Takashi Iwaib4ead012012-01-23 18:23:36 +01004993static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004994{
4995 int i;
4996 for (i = 0; i < cfg->hp_outs; i++)
4997 if (cfg->hp_pins[i] == nid)
4998 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01004999 for (i = 0; i < cfg->line_outs; i++)
5000 if (cfg->line_out_pins[i] == nid)
5001 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005002 return 0; /* nid is not a HP-Out */
5003};
5004
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005005static void stac92xx_power_down(struct hda_codec *codec)
5006{
5007 struct sigmatel_spec *spec = codec->spec;
5008
5009 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02005010 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005011 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005012 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005013 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01005014 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5015}
5016
Takashi Iwaif73d3582008-11-25 08:21:51 +01005017static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5018 int enable);
5019
Takashi Iwaibc759722013-01-11 17:40:31 +01005020static inline bool get_int_hint(struct hda_codec *codec, const char *key,
5021 int *valp)
Takashi Iwai014c41f2009-12-27 13:53:24 +01005022{
Takashi Iwaibc759722013-01-11 17:40:31 +01005023 return !snd_hda_get_int_hint(codec, key, valp);
Takashi Iwai014c41f2009-12-27 13:53:24 +01005024}
5025
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005026/* override some hints from the hwdep entry */
5027static void stac_store_hints(struct hda_codec *codec)
5028{
5029 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005030 int val;
5031
5032 val = snd_hda_get_bool_hint(codec, "hp_detect");
5033 if (val >= 0)
5034 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01005035 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005036 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
5037 spec->gpio_mask;
5038 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01005039 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
5040 spec->gpio_mask &= spec->gpio_mask;
5041 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
5042 spec->gpio_dir &= spec->gpio_mask;
5043 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
5044 spec->eapd_mask &= spec->gpio_mask;
5045 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
5046 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005047 val = snd_hda_get_bool_hint(codec, "eapd_switch");
5048 if (val >= 0)
5049 spec->eapd_switch = val;
5050}
5051
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005052static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
5053 const hda_nid_t *pins)
5054{
5055 while (num_pins--)
5056 stac_issue_unsol_event(codec, *pins++);
5057}
5058
5059/* fake event to set up pins */
5060static void stac_fake_hp_events(struct hda_codec *codec)
5061{
5062 struct sigmatel_spec *spec = codec->spec;
5063
5064 if (spec->autocfg.hp_outs)
5065 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
5066 spec->autocfg.hp_pins);
5067 if (spec->autocfg.line_outs &&
5068 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
5069 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
5070 spec->autocfg.line_out_pins);
5071}
5072
Mattc7d4b2f2005-06-27 14:59:41 +02005073static int stac92xx_init(struct hda_codec *codec)
5074{
5075 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005076 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005077 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01005078 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02005079
David Henningsson5e68fb32012-08-16 14:11:09 +02005080 if (spec->init)
5081 snd_hda_sequence_write(codec, spec->init);
Mattc7d4b2f2005-06-27 14:59:41 +02005082
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005083 snd_hda_apply_verbs(codec);
5084
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005085 /* power down adcs initially */
5086 if (spec->powerdown_adcs)
5087 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005088 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005089 spec->adc_nids[i], 0,
5090 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005091
Takashi Iwai6565e4f2009-03-02 14:38:35 +01005092 /* override some hints */
5093 stac_store_hints(codec);
5094
Takashi Iwaif73d3582008-11-25 08:21:51 +01005095 /* set up GPIO */
5096 gpio = spec->gpio_data;
5097 /* turn on EAPD statically when spec->eapd_switch isn't set.
5098 * otherwise, unsol event will turn it on/off dynamically
5099 */
5100 if (!spec->eapd_switch)
5101 gpio |= spec->eapd_mask;
5102 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
5103
Takashi Iwai82bc9552006-03-21 11:24:42 +01005104 /* set up pins */
5105 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02005106 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005107 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005108 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005109 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005110 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02005111 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
5112 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005113 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02005114 for (i = 0; i < cfg->line_outs; i++) {
5115 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005116 enable_pin_detect(codec, nid, STAC_LO_EVENT);
5117 }
5118 }
5119
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01005120 /* force to enable the first line-out; the others are set up
5121 * in unsol_event
5122 */
5123 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005124 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005125 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005126 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005127 } else {
5128 stac92xx_auto_init_multi_out(codec);
5129 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005130 for (i = 0; i < cfg->hp_outs; i++)
5131 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01005132 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005133 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02005134 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02005135 if (spec->dmux_nids)
5136 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02005137 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005138 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
5139 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02005140 if (enable_pin_detect(codec, spec->dock_mic.pin,
5141 STAC_MIC_EVENT))
5142 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005143 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005144 for (i = 0; i < cfg->num_inputs; i++) {
5145 hda_nid_t nid = cfg->inputs[i].pin;
5146 int type = cfg->inputs[i].type;
5147 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02005148 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005149 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02005150 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005151 pinctl |= AC_PINCTL_IN_EN;
5152 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5153 } else {
5154 pinctl = snd_hda_codec_read(codec, nid, 0,
5155 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5156 /* if PINCTL already set then skip */
5157 /* Also, if both INPUT and OUTPUT are set,
5158 * it must be a BIOS bug; need to override, too
5159 */
5160 if (!(pinctl & AC_PINCTL_IN_EN) ||
5161 (pinctl & AC_PINCTL_OUT_EN)) {
5162 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01005163 pinctl |= AC_PINCTL_IN_EN;
5164 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01005165 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02005166 }
5167 conf = snd_hda_codec_get_pincfg(codec, nid);
5168 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
5169 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
5170 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01005171 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01005172 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005173 for (i = 0; i < spec->num_dmics; i++)
5174 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
5175 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005176 if (cfg->dig_out_pins[0])
5177 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01005178 AC_PINCTL_OUT_EN);
5179 if (cfg->dig_in_pin)
5180 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
5181 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005182 for (i = 0; i < spec->num_pwrs; i++) {
5183 hda_nid_t nid = spec->pwr_nids[i];
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005184 unsigned int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005185
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005186 def_conf = snd_hda_codec_get_pincfg(codec, nid);
5187 def_conf = get_defcfg_connect(def_conf);
5188 if (def_conf == AC_JACK_PORT_NONE) {
5189 /* power off unused ports */
5190 stac_toggle_power_map(codec, nid, 0);
5191 continue;
5192 }
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02005193 if (def_conf == AC_JACK_PORT_FIXED) {
5194 /* no need for jack detection for fixed pins */
5195 stac_toggle_power_map(codec, nid, 1);
5196 continue;
5197 }
Takashi Iwaieb632122008-12-19 16:39:48 +01005198 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01005199 /* or when the VREF is used for controlling LED */
5200 if (!spec->hp_detect ||
Takashi Iwaibfc89de2012-05-15 09:02:26 +02005201 spec->vref_mute_led_nid == nid ||
5202 !is_jack_detectable(codec, nid)) {
Takashi Iwaieb632122008-12-19 16:39:48 +01005203 stac_toggle_power_map(codec, nid, 1);
5204 continue;
5205 }
5206
Takashi Iwaib4ead012012-01-23 18:23:36 +01005207 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01005208 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02005209
Takashi Iwaif73d3582008-11-25 08:21:51 +01005210 pinctl = snd_hda_codec_read(codec, nid, 0,
5211 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5212 /* outputs are only ports capable of power management
5213 * any attempts on powering down a input port cause the
5214 * referenced VREF to act quirky.
5215 */
Takashi Iwaieb632122008-12-19 16:39:48 +01005216 if (pinctl & AC_PINCTL_IN_EN) {
5217 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005218 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01005219 }
Charles Chinafef2cf2011-11-11 08:05:28 +01005220 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02005221 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01005222 continue;
5223 }
5224 /* none of the above, turn the port OFF */
5225 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005226 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01005227
Takashi Iwaic21bd022010-02-08 15:16:08 +01005228 /* sync mute LED */
Takashi Iwai1f43f6c2012-07-31 10:40:05 +02005229 if (spec->gpio_led) {
5230 if (spec->vmaster_mute.hook)
5231 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5232 else /* the very first init call doesn't have vmaster yet */
5233 stac92xx_update_led_status(codec, false);
5234 }
Takashi Iwaic8822462012-05-15 09:11:36 +02005235
5236 /* sync the power-map */
5237 if (spec->num_pwrs)
5238 snd_hda_codec_write(codec, codec->afg, 0,
5239 AC_VERB_IDT_SET_POWER_MAP,
5240 spec->power_map_bits);
Takashi Iwaif73d3582008-11-25 08:21:51 +01005241 if (spec->dac_list)
5242 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02005243 return 0;
5244}
5245
Takashi Iwai603c4012008-07-30 15:01:44 +02005246static void stac92xx_free_kctls(struct hda_codec *codec)
5247{
5248 struct sigmatel_spec *spec = codec->spec;
5249
5250 if (spec->kctls.list) {
5251 struct snd_kcontrol_new *kctl = spec->kctls.list;
5252 int i;
5253 for (i = 0; i < spec->kctls.used; i++)
5254 kfree(kctl[i].name);
5255 }
5256 snd_array_free(&spec->kctls);
5257}
5258
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005259static void stac92xx_shutup_pins(struct hda_codec *codec)
5260{
5261 unsigned int i, def_conf;
5262
5263 if (codec->bus->shutdown)
5264 return;
5265 for (i = 0; i < codec->init_pins.used; i++) {
5266 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
5267 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
5268 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005269 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005270 }
5271}
5272
Takashi Iwai167eae52009-11-06 15:47:50 +01005273static void stac92xx_shutup(struct hda_codec *codec)
5274{
5275 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01005276
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005277 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01005278
5279 if (spec->eapd_mask)
5280 stac_gpio_set(codec, spec->gpio_mask,
5281 spec->gpio_dir, spec->gpio_data &
5282 ~spec->eapd_mask);
5283}
5284
Matt2f2f4252005-04-13 14:45:30 +02005285static void stac92xx_free(struct hda_codec *codec)
5286{
Mattc7d4b2f2005-06-27 14:59:41 +02005287 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005288
5289 if (! spec)
5290 return;
5291
Mattc7d4b2f2005-06-27 14:59:41 +02005292 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005293 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02005294}
5295
Matt4e550962005-07-04 17:51:39 +02005296static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
5297 unsigned int flag)
5298{
Takashi Iwai8ce84192009-01-22 16:59:20 +01005299 unsigned int old_ctl, pin_ctl;
5300
5301 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02005302 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02005303
Takashi Iwaif9acba42007-05-29 18:01:06 +02005304 if (pin_ctl & AC_PINCTL_IN_EN) {
5305 /*
5306 * we need to check the current set-up direction of
5307 * shared input pins since they can be switched via
5308 * "xxx as Output" mixer switch
5309 */
5310 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005311 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02005312 return;
5313 }
5314
Takashi Iwai8ce84192009-01-22 16:59:20 +01005315 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02005316 /* if setting pin direction bits, clear the current
5317 direction bits first */
5318 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
5319 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
5320
Takashi Iwai8ce84192009-01-22 16:59:20 +01005321 pin_ctl |= flag;
5322 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005323 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02005324}
5325
5326static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
5327 unsigned int flag)
5328{
5329 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
5330 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01005331 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02005332 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02005333}
5334
Takashi Iwaid56757a2009-11-18 08:00:14 +01005335static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02005336{
5337 if (!nid)
5338 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01005339 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02005340}
5341
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005342static void stac92xx_line_out_detect(struct hda_codec *codec,
5343 int presence)
5344{
5345 struct sigmatel_spec *spec = codec->spec;
5346 struct auto_pin_cfg *cfg = &spec->autocfg;
5347 int i;
5348
David Henningsson042b92c2012-08-22 16:10:43 +02005349 if (cfg->speaker_outs == 0)
5350 return;
5351
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005352 for (i = 0; i < cfg->line_outs; i++) {
5353 if (presence)
5354 break;
5355 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
5356 if (presence) {
5357 unsigned int pinctl;
5358 pinctl = snd_hda_codec_read(codec,
5359 cfg->line_out_pins[i], 0,
5360 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5361 if (pinctl & AC_PINCTL_IN_EN)
5362 presence = 0; /* mic- or line-input */
5363 }
5364 }
5365
5366 if (presence) {
5367 /* disable speakers */
5368 for (i = 0; i < cfg->speaker_outs; i++)
5369 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
5370 AC_PINCTL_OUT_EN);
5371 if (spec->eapd_mask && spec->eapd_switch)
5372 stac_gpio_set(codec, spec->gpio_mask,
5373 spec->gpio_dir, spec->gpio_data &
5374 ~spec->eapd_mask);
5375 } else {
5376 /* enable speakers */
5377 for (i = 0; i < cfg->speaker_outs; i++)
5378 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
5379 AC_PINCTL_OUT_EN);
5380 if (spec->eapd_mask && spec->eapd_switch)
5381 stac_gpio_set(codec, spec->gpio_mask,
5382 spec->gpio_dir, spec->gpio_data |
5383 spec->eapd_mask);
5384 }
5385}
5386
Takashi Iwaid7a89432008-11-12 09:48:04 +01005387/* return non-zero if the hp-pin of the given array index isn't
5388 * a jack-detection target
5389 */
5390static int no_hp_sensing(struct sigmatel_spec *spec, int i)
5391{
5392 struct auto_pin_cfg *cfg = &spec->autocfg;
5393
5394 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005395 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005396 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005397 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005398 return 1;
5399 /* ignore if the pin is set as line-out */
5400 if (cfg->hp_pins[i] == spec->hp_switch)
5401 return 1;
5402 return 0;
5403}
5404
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005405static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02005406{
5407 struct sigmatel_spec *spec = codec->spec;
5408 struct auto_pin_cfg *cfg = &spec->autocfg;
5409 int i, presence;
5410
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005411 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005412 if (spec->gpio_mute)
5413 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
5414 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
5415
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005416 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005417 if (presence)
5418 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01005419 if (no_hp_sensing(spec, i))
5420 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005421 presence = get_pin_presence(codec, cfg->hp_pins[i]);
5422 if (presence) {
5423 unsigned int pinctl;
5424 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
5425 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5426 if (pinctl & AC_PINCTL_IN_EN)
5427 presence = 0; /* mic- or line-input */
5428 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005429 }
Matt4e550962005-07-04 17:51:39 +02005430
5431 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005432 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005433 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005434 stac92xx_reset_pinctl(codec, spec->hp_switch,
5435 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005436 for (i = 0; i < cfg->line_outs; i++)
5437 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
5438 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005439 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01005440 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02005441 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005442 stac92xx_set_pinctl(codec, spec->hp_switch,
5443 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005444 for (i = 0; i < cfg->line_outs; i++)
5445 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
5446 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02005447 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005448 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01005449 /* toggle hp outs */
5450 for (i = 0; i < cfg->hp_outs; i++) {
5451 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
5452 if (no_hp_sensing(spec, i))
5453 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01005454 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01005455 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01005456#if 0 /* FIXME */
5457/* Resetting the pinctl like below may lead to (a sort of) regressions
5458 * on some devices since they use the HP pin actually for line/speaker
5459 * outs although the default pin config shows a different pin (that is
5460 * wrong and useless).
5461 *
5462 * So, it's basically a problem of default pin configs, likely a BIOS issue.
5463 * But, disabling the code below just works around it, and I'm too tired of
5464 * bug reports with such devices...
5465 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01005466 else
5467 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01005468#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01005469 }
Matt4e550962005-07-04 17:51:39 +02005470}
5471
Takashi Iwaif73d3582008-11-25 08:21:51 +01005472static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5473 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005474{
5475 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005476 unsigned int idx, val;
5477
5478 for (idx = 0; idx < spec->num_pwrs; idx++) {
5479 if (spec->pwr_nids[idx] == nid)
5480 break;
5481 }
5482 if (idx >= spec->num_pwrs)
5483 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005484
Charles Chinafef2cf2011-11-11 08:05:28 +01005485 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005486
Takashi Iwaic8822462012-05-15 09:11:36 +02005487 val = spec->power_map_bits;
Takashi Iwaif73d3582008-11-25 08:21:51 +01005488 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005489 val &= ~idx;
5490 else
5491 val |= idx;
5492
5493 /* power down unused output ports */
Takashi Iwaic8822462012-05-15 09:11:36 +02005494 if (val != spec->power_map_bits) {
5495 spec->power_map_bits = val;
5496 snd_hda_codec_write(codec, codec->afg, 0,
5497 AC_VERB_IDT_SET_POWER_MAP, val);
5498 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005499}
5500
Takashi Iwaif73d3582008-11-25 08:21:51 +01005501static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
5502{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01005503 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01005504}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005505
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005506/* get the pin connection (fixed, none, etc) */
5507static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5508{
5509 struct sigmatel_spec *spec = codec->spec;
5510 unsigned int cfg;
5511
5512 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5513 return get_defcfg_connect(cfg);
5514}
5515
5516static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005517 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005518{
5519 struct sigmatel_spec *spec = codec->spec;
5520 int idx, num;
5521 unsigned int def_conf;
5522
5523 for (num = 0; num < num_nids; num++) {
5524 for (idx = 0; idx < spec->num_pins; idx++)
5525 if (spec->pin_nids[idx] == nids[num])
5526 break;
5527 if (idx >= spec->num_pins)
5528 break;
5529 def_conf = stac_get_defcfg_connect(codec, idx);
5530 if (def_conf == AC_JACK_PORT_NONE)
5531 break;
5532 }
5533 return num;
5534}
5535
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005536static void stac92xx_mic_detect(struct hda_codec *codec)
5537{
5538 struct sigmatel_spec *spec = codec->spec;
5539 struct sigmatel_mic_route *mic;
5540
5541 if (get_pin_presence(codec, spec->ext_mic.pin))
5542 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02005543 else if (get_pin_presence(codec, spec->dock_mic.pin))
5544 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005545 else
5546 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02005547 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005548 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
5549 AC_VERB_SET_CONNECT_SEL,
5550 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02005551 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005552 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
5553 AC_VERB_SET_CONNECT_SEL,
5554 mic->mux_idx);
5555}
5556
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005557static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02005558 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02005559{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005560 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005561 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005562
Takashi Iwai3a938972011-10-28 01:16:55 +02005563 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02005564 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005565 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02005566 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005567 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005568 case STAC_MIC_EVENT:
5569 stac92xx_mic_detect(codec);
5570 break;
5571 }
5572
Takashi Iwai3a938972011-10-28 01:16:55 +02005573 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005574 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02005575 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02005576 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04005577 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005578 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005579 if (spec->num_pwrs > 0)
5580 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04005581
5582 switch (codec->subsystem_id) {
5583 case 0x103c308f:
5584 if (event->nid == 0xb) {
5585 int pin = AC_PINCTL_IN_EN;
5586
5587 if (get_pin_presence(codec, 0xa)
5588 && get_pin_presence(codec, 0xb))
5589 pin |= AC_PINCTL_VREF_80;
5590 if (!get_pin_presence(codec, 0xb))
5591 pin |= AC_PINCTL_VREF_80;
5592
5593 /* toggle VREF state based on mic + hp pin
5594 * status
5595 */
5596 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
5597 }
5598 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04005599 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005600 case STAC_VREF_EVENT:
5601 data = snd_hda_codec_read(codec, codec->afg, 0,
5602 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005603 /* toggle VREF state based on GPIOx status */
5604 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02005605 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04005606 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02005607 }
5608}
5609
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005610static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
5611{
Takashi Iwai3a938972011-10-28 01:16:55 +02005612 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02005613 if (!event)
5614 return;
5615 handle_unsol_event(codec, event);
5616}
5617
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305618static int hp_blike_system(u32 subsystem_id);
5619
5620static void set_hp_led_gpio(struct hda_codec *codec)
5621{
5622 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01005623 unsigned int gpio;
5624
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005625 if (spec->gpio_led)
5626 return;
5627
Takashi Iwai07f80442010-02-08 15:06:13 +01005628 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
5629 gpio &= AC_GPIO_IO_COUNT;
5630 if (gpio > 3)
5631 spec->gpio_led = 0x08; /* GPIO 3 */
5632 else
5633 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305634}
5635
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005636/*
5637 * This method searches for the mute LED GPIO configuration
5638 * provided as OEM string in SMBIOS. The format of that string
5639 * is HP_Mute_LED_P_G or HP_Mute_LED_P
5640 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
5641 * that corresponds to the NOT muted state of the master volume
5642 * and G is the index of the GPIO to use as the mute LED control (0..9)
5643 * If _G portion is missing it is assigned based on the codec ID
5644 *
5645 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
5646 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305647 *
5648 *
5649 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
5650 * SMBIOS - at least the ones I have seen do not have them - which include
5651 * my own system (HP Pavilion dv6-1110ax) and my cousin's
5652 * HP Pavilion dv9500t CTO.
5653 * Need more information on whether it is true across the entire series.
5654 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005655 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005656static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005657{
5658 struct sigmatel_spec *spec = codec->spec;
5659 const struct dmi_device *dev = NULL;
5660
Takashi Iwai75609312012-05-14 16:52:00 +02005661 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
5662 get_int_hint(codec, "gpio_led_polarity",
5663 &spec->gpio_led_polarity);
5664 return 1;
5665 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005666 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
5667 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
5668 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005669 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305670 &spec->gpio_led_polarity,
5671 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005672 unsigned int max_gpio;
5673 max_gpio = snd_hda_param_read(codec, codec->afg,
5674 AC_PAR_GPIO_CAP);
5675 max_gpio &= AC_GPIO_IO_COUNT;
5676 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005677 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005678 else
5679 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005680 return 1;
5681 }
5682 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305683 &spec->gpio_led_polarity) == 1) {
5684 set_hp_led_gpio(codec);
5685 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005686 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02005687 /* BIOS bug: unfilled OEM string */
5688 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
5689 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02005690 switch (codec->subsystem_id) {
5691 case 0x103c148a:
5692 spec->gpio_led_polarity = 0;
5693 break;
5694 default:
5695 spec->gpio_led_polarity = 1;
5696 break;
5697 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02005698 return 1;
5699 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005700 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305701
5702 /*
5703 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005704 * we statically set the GPIO - if not a B-series system
5705 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305706 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005707 if (!hp_blike_system(codec->subsystem_id) &&
5708 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305709 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01005710 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305711 return 1;
5712 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005713 }
5714 return 0;
5715}
5716
5717static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08005718{
5719 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005720 case 0x103c1520:
5721 case 0x103c1521:
5722 case 0x103c1523:
5723 case 0x103c1524:
5724 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08005725 case 0x103c1722:
5726 case 0x103c1723:
5727 case 0x103c1724:
5728 case 0x103c1725:
5729 case 0x103c1726:
5730 case 0x103c1727:
5731 case 0x103c1728:
5732 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005733 case 0x103c172a:
5734 case 0x103c172b:
5735 case 0x103c307e:
5736 case 0x103c307f:
5737 case 0x103c3080:
5738 case 0x103c3081:
5739 case 0x103c7007:
5740 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08005741 return 1;
5742 }
5743 return 0;
5744}
5745
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005746#ifdef CONFIG_PROC_FS
5747static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
5748 struct hda_codec *codec, hda_nid_t nid)
5749{
5750 if (nid == codec->afg)
5751 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02005752 snd_hda_codec_read(codec, nid, 0,
5753 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005754}
5755
5756static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
5757 struct hda_codec *codec,
5758 unsigned int verb)
5759{
5760 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
5761 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
5762}
5763
5764/* stac92hd71bxx, stac92hd73xx */
5765static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
5766 struct hda_codec *codec, hda_nid_t nid)
5767{
5768 stac92hd_proc_hook(buffer, codec, nid);
5769 if (nid == codec->afg)
5770 analog_loop_proc_hook(buffer, codec, 0xfa0);
5771}
5772
5773static void stac9205_proc_hook(struct snd_info_buffer *buffer,
5774 struct hda_codec *codec, hda_nid_t nid)
5775{
5776 if (nid == codec->afg)
5777 analog_loop_proc_hook(buffer, codec, 0xfe0);
5778}
5779
5780static void stac927x_proc_hook(struct snd_info_buffer *buffer,
5781 struct hda_codec *codec, hda_nid_t nid)
5782{
5783 if (nid == codec->afg)
5784 analog_loop_proc_hook(buffer, codec, 0xfeb);
5785}
5786#else
5787#define stac92hd_proc_hook NULL
5788#define stac92hd7x_proc_hook NULL
5789#define stac9205_proc_hook NULL
5790#define stac927x_proc_hook NULL
5791#endif
5792
Takashi Iwai2a439522011-07-26 09:52:50 +02005793#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02005794static int stac92xx_resume(struct hda_codec *codec)
5795{
Takashi Iwai2c885872008-11-18 09:36:55 +01005796 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005797 snd_hda_codec_resume_amp(codec);
5798 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01005799 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005800 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02005801 return 0;
5802}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005803
Takashi Iwai68cb2b52012-07-02 15:20:37 +02005804static int stac92xx_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005805{
5806 stac92xx_shutup(codec);
5807 return 0;
5808}
5809
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005810static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5811 unsigned int power_state)
5812{
5813 unsigned int afg_power_state = power_state;
5814 struct sigmatel_spec *spec = codec->spec;
5815
5816 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005817 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005818 /* with vref-out pin used for mute led control
5819 * codec AFG is prevented from D3 state
5820 */
5821 afg_power_state = AC_PWRST_D1;
5822 }
5823 /* this delay seems necessary to avoid click noise at power-down */
5824 msleep(100);
5825 }
5826 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5827 afg_power_state);
5828 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5829}
Takashi Iwai350eba432012-03-16 16:09:03 +01005830#else
5831#define stac92xx_suspend NULL
5832#define stac92xx_resume NULL
Takashi Iwai350eba432012-03-16 16:09:03 +01005833#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005834#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005835
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005836/* update mute-LED accoring to the master switch */
5837static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005838{
5839 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005840 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005841
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005842 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005843 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005844
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005845 /* LED state is inverted on these systems */
5846 if (spec->gpio_led_polarity)
5847 muted = !muted;
5848
Takashi Iwaif1a73742011-12-04 13:44:06 +01005849 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005850 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02005851 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005852 else
Takashi Iwai3e843192012-04-19 12:04:03 +02005853 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005854 stac_gpio_set(codec, spec->gpio_mask,
5855 spec->gpio_dir, spec->gpio_data);
5856 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005857 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005858 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5859 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005860 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005861}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05005862
Takashi Iwai2b635362011-05-02 12:33:43 +02005863static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005864 .build_controls = stac92xx_build_controls,
5865 .build_pcms = stac92xx_build_pcms,
5866 .init = stac92xx_init,
5867 .free = stac92xx_free,
David Henningsson29adc4b2012-09-25 11:31:00 +02005868 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02005869#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005870 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005871 .resume = stac92xx_resume,
5872#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005873 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005874};
5875
Takashi Iwai361dab32012-05-09 14:35:27 +02005876static int alloc_stac_spec(struct hda_codec *codec, int num_pins,
5877 const hda_nid_t *pin_nids)
5878{
5879 struct sigmatel_spec *spec;
5880
5881 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5882 if (!spec)
5883 return -ENOMEM;
5884 codec->spec = spec;
5885 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
5886 spec->num_pins = num_pins;
5887 spec->pin_nids = pin_nids;
5888 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
5889 return 0;
5890}
5891
Matt2f2f4252005-04-13 14:45:30 +02005892static int patch_stac9200(struct hda_codec *codec)
5893{
5894 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005895 int err;
Matt2f2f4252005-04-13 14:45:30 +02005896
Takashi Iwai361dab32012-05-09 14:35:27 +02005897 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids),
5898 stac9200_pin_nids);
5899 if (err < 0)
5900 return err;
Matt2f2f4252005-04-13 14:45:30 +02005901
Takashi Iwai361dab32012-05-09 14:35:27 +02005902 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005903 spec->linear_tone_beep = 1;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005904
5905 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
5906 stac9200_fixups);
Matt2f2f4252005-04-13 14:45:30 +02005907
5908 spec->multiout.max_channels = 2;
5909 spec->multiout.num_dacs = 1;
5910 spec->multiout.dac_nids = stac9200_dac_nids;
5911 spec->adc_nids = stac9200_adc_nids;
5912 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005913 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005914 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005915 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005916 spec->num_pwrs = 0;
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005917 snd_hda_add_verbs(codec, stac9200_eapd_init);
Mattc7d4b2f2005-06-27 14:59:41 +02005918
Matt2f2f4252005-04-13 14:45:30 +02005919 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005920
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005921 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwai117f2572008-03-18 09:53:23 +01005922
Mattc7d4b2f2005-06-27 14:59:41 +02005923 err = stac9200_parse_auto_config(codec);
5924 if (err < 0) {
5925 stac92xx_free(codec);
5926 return err;
5927 }
Matt2f2f4252005-04-13 14:45:30 +02005928
5929 codec->patch_ops = stac92xx_patch_ops;
5930
Takashi Iwaid39a3ae2013-01-14 14:06:26 +01005931 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
5932
Matt2f2f4252005-04-13 14:45:30 +02005933 return 0;
5934}
5935
Tobin Davis8e21c342007-01-08 11:04:17 +01005936static int patch_stac925x(struct hda_codec *codec)
5937{
5938 struct sigmatel_spec *spec;
5939 int err;
5940
Takashi Iwai361dab32012-05-09 14:35:27 +02005941 err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids),
5942 stac925x_pin_nids);
5943 if (err < 0)
5944 return err;
Tobin Davis8e21c342007-01-08 11:04:17 +01005945
Takashi Iwai361dab32012-05-09 14:35:27 +02005946 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005947 spec->linear_tone_beep = 1;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005948
Takashi Iwaid2077d42013-01-14 14:20:16 +01005949 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
5950 stac925x_fixups);
Tobin Davis8e21c342007-01-08 11:04:17 +01005951
5952 spec->multiout.max_channels = 2;
5953 spec->multiout.num_dacs = 1;
5954 spec->multiout.dac_nids = stac925x_dac_nids;
5955 spec->adc_nids = stac925x_adc_nids;
5956 spec->mux_nids = stac925x_mux_nids;
5957 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005958 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005959 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005960 switch (codec->vendor_id) {
5961 case 0x83847632: /* STAC9202 */
5962 case 0x83847633: /* STAC9202D */
5963 case 0x83847636: /* STAC9251 */
5964 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005965 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005966 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005967 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5968 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005969 break;
5970 default:
5971 spec->num_dmics = 0;
5972 break;
5973 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005974
Takashi Iwaid2077d42013-01-14 14:20:16 +01005975 snd_hda_add_verbs(codec, stac925x_core_init);
Tobin Davis8e21c342007-01-08 11:04:17 +01005976 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005977 spec->num_caps = 1;
5978 spec->capvols = stac925x_capvols;
5979 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005980
Takashi Iwaid2077d42013-01-14 14:20:16 +01005981 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
5982
Charles Chin9009b0e2011-11-03 10:27:27 +01005983 err = stac92xx_parse_auto_config(codec);
Takashi Iwaid2077d42013-01-14 14:20:16 +01005984 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005985 err = -EINVAL;
Tobin Davis8e21c342007-01-08 11:04:17 +01005986 if (err < 0) {
5987 stac92xx_free(codec);
5988 return err;
5989 }
5990
5991 codec->patch_ops = stac92xx_patch_ops;
5992
Takashi Iwaid2077d42013-01-14 14:20:16 +01005993 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
5994
Tobin Davis8e21c342007-01-08 11:04:17 +01005995 return 0;
5996}
5997
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005998static int patch_stac92hd73xx(struct hda_codec *codec)
5999{
6000 struct sigmatel_spec *spec;
6001 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
Takashi Iwai361dab32012-05-09 14:35:27 +02006002 int err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006003 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006004
Takashi Iwai361dab32012-05-09 14:35:27 +02006005 err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids),
6006 stac92hd73xx_pin_nids);
6007 if (err < 0)
6008 return err;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006009
Takashi Iwai361dab32012-05-09 14:35:27 +02006010 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006011 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02006012 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006013 spec->board_config = snd_hda_check_board_config(codec,
6014 STAC_92HD73XX_MODELS,
6015 stac92hd73xx_models,
6016 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02006017 /* check codec subsystem id if not found */
6018 if (spec->board_config < 0)
6019 spec->board_config =
6020 snd_hda_check_board_codec_sid_config(codec,
6021 STAC_92HD73XX_MODELS, stac92hd73xx_models,
6022 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006023again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006024 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006025 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6026 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006027 else
6028 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006029 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006030
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006031 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006032 conn, STAC92HD73_DAC_COUNT + 2) - 1;
6033
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006034 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006035 printk(KERN_WARNING "hda_codec: Could not determine "
6036 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006037 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006038 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02006039 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006040 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006041 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006042 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006043 break;
6044 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006045 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006046 break;
6047 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006048 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
6049 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006050 }
6051 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006052
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006053 spec->aloopback_mask = 0x01;
6054 spec->aloopback_shift = 8;
6055
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006056 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006057 spec->mux_nids = stac92hd73xx_mux_nids;
6058 spec->adc_nids = stac92hd73xx_adc_nids;
6059 spec->dmic_nids = stac92hd73xx_dmic_nids;
6060 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006061 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006062
6063 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
6064 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01006065 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006066
Takashi Iwai6479c632009-07-28 18:20:25 +02006067 spec->num_caps = STAC92HD73XX_NUM_CAPS;
6068 spec->capvols = stac92hd73xx_capvols;
6069 spec->capsws = stac92hd73xx_capsws;
6070
Matthew Ranostaya7662642008-02-21 07:51:14 +01006071 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006072 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01006073 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006074 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006075 case STAC_DELL_M6_AMIC:
6076 case STAC_DELL_M6_DMIC:
6077 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006078 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006079 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05006080
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006081 switch (spec->board_config) {
6082 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01006083 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01006084 spec->num_dmics = 0;
6085 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006086 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01006087 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01006088 spec->num_dmics = 1;
6089 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01006090 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01006091 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
6092 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01006093 spec->num_dmics = 1;
6094 break;
6095 }
6096 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02006097 case STAC_ALIENWARE_M17X:
6098 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6099 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6100 spec->eapd_switch = 0;
6101 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006102 default:
6103 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04006104 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006105 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02006106 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01006107 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006108 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006109 /* GPIO0 High = Enable EAPD */
6110 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6111 spec->gpio_data = 0x01;
6112 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01006113
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006114 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
6115 spec->pwr_nids = stac92hd73xx_pwr_nids;
6116
Charles Chin9009b0e2011-11-03 10:27:27 +01006117 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006118
6119 if (!err) {
6120 if (spec->board_config < 0) {
6121 printk(KERN_WARNING "hda_codec: No auto-config is "
6122 "available, default to model=ref\n");
6123 spec->board_config = STAC_92HD73XX_REF;
6124 goto again;
6125 }
6126 err = -EINVAL;
6127 }
6128
6129 if (err < 0) {
6130 stac92xx_free(codec);
6131 return err;
6132 }
6133
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01006134 if (spec->board_config == STAC_92HD73XX_NO_JD)
6135 spec->hp_detect = 0;
6136
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006137 codec->patch_ops = stac92xx_patch_ops;
6138
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006139 codec->proc_widget_hook = stac92hd7x_proc_hook;
6140
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006141 return 0;
6142}
6143
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006144static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006145{
6146 if (codec->vendor_id != 0x111d7605 &&
6147 codec->vendor_id != 0x111d76d1)
6148 return 0;
6149
6150 switch (codec->subsystem_id) {
6151 case 0x103c1618:
6152 case 0x103c1619:
6153 case 0x103c161a:
6154 case 0x103c161b:
6155 case 0x103c161c:
6156 case 0x103c161d:
6157 case 0x103c161e:
6158 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006159
6160 case 0x103c162a:
6161 case 0x103c162b:
6162
6163 case 0x103c1630:
6164 case 0x103c1631:
6165
6166 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006167 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006168 case 0x103c1635:
6169
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006170 case 0x103c3587:
6171 case 0x103c3588:
6172 case 0x103c3589:
6173 case 0x103c358a:
6174
6175 case 0x103c3667:
6176 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006177 case 0x103c3669:
6178
6179 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05006180 }
6181 return 0;
6182}
6183
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006184static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
6185{
6186 struct sigmatel_spec *spec = codec->spec;
6187 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
6188 int i;
6189
6190 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
6191 spec->auto_pin_cnt++;
6192
6193 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
6194 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
6195 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
6196 if (nid == stac92hd83xxx_dmic_nids[i]) {
6197 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
6198 spec->auto_dmic_cnt++;
6199 }
6200 }
6201 }
6202}
6203
6204static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
6205{
6206 struct sigmatel_spec *spec = codec->spec;
6207
6208 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
6209 spec->auto_adc_cnt++;
6210}
6211
6212static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
6213{
6214 int i, j;
6215 struct sigmatel_spec *spec = codec->spec;
6216
6217 for (i = 0; i < spec->auto_adc_cnt; i++) {
6218 if (get_connection_index(codec,
6219 spec->auto_adc_nids[i], nid) >= 0) {
6220 /* mux and volume for adc_nids[i] */
6221 if (!spec->auto_mux_nids[i]) {
6222 spec->auto_mux_nids[i] = nid;
6223 /* 92hd codecs capture volume is in mux */
6224 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
6225 3, 0, HDA_OUTPUT);
6226 }
6227 for (j = 0; j < spec->auto_dmic_cnt; j++) {
6228 if (get_connection_index(codec, nid,
6229 spec->auto_dmic_nids[j]) >= 0) {
6230 /* dmux for adc_nids[i] */
6231 if (!spec->auto_dmux_nids[i])
6232 spec->auto_dmux_nids[i] = nid;
6233 break;
6234 }
6235 }
6236 break;
6237 }
6238 }
6239}
6240
6241static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
6242{
6243 hda_nid_t nid, end_nid;
6244 unsigned int wid_caps, wid_type;
6245 struct sigmatel_spec *spec = codec->spec;
6246
6247 end_nid = codec->start_nid + codec->num_nodes;
6248
6249 for (nid = codec->start_nid; nid < end_nid; nid++) {
6250 wid_caps = get_wcaps(codec, nid);
6251 wid_type = get_wcaps_type(wid_caps);
6252
6253 if (wid_type == AC_WID_PIN)
6254 stac92hd8x_add_pin(codec, nid);
6255
6256 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
6257 stac92hd8x_add_adc(codec, nid);
6258 }
6259
6260 for (nid = codec->start_nid; nid < end_nid; nid++) {
6261 wid_caps = get_wcaps(codec, nid);
6262 wid_type = get_wcaps_type(wid_caps);
6263
6264 if (wid_type == AC_WID_AUD_SEL)
6265 stac92hd8x_add_mux(codec, nid);
6266 }
6267
6268 spec->pin_nids = spec->auto_pin_nids;
6269 spec->num_pins = spec->auto_pin_cnt;
6270 spec->adc_nids = spec->auto_adc_nids;
6271 spec->num_adcs = spec->auto_adc_cnt;
6272 spec->capvols = spec->auto_capvols;
6273 spec->capsws = spec->auto_capvols;
6274 spec->num_caps = spec->auto_adc_cnt;
6275 spec->mux_nids = spec->auto_mux_nids;
6276 spec->num_muxes = spec->auto_adc_cnt;
6277 spec->dmux_nids = spec->auto_dmux_nids;
6278 spec->num_dmuxes = spec->auto_adc_cnt;
6279 spec->dmic_nids = spec->auto_dmic_nids;
6280 spec->num_dmics = spec->auto_dmic_cnt;
6281}
6282
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006283static int patch_stac92hd83xxx(struct hda_codec *codec)
6284{
6285 struct sigmatel_spec *spec;
Takashi Iwaia3e19972012-07-26 08:17:20 +02006286 int default_polarity = -1; /* no default cfg */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006287 int err;
6288
Takashi Iwai361dab32012-05-09 14:35:27 +02006289 err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */
6290 if (err < 0)
6291 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006292
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06006293 if (hp_bnb2011_with_dock(codec)) {
6294 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
6295 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
6296 }
6297
Takashi Iwaic36b5b02012-08-28 09:20:13 -07006298 codec->epss = 0; /* longer delay needed for D3 */
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06006299 stac92hd8x_fill_auto_spec(codec);
6300
Takashi Iwai361dab32012-05-09 14:35:27 +02006301 spec = codec->spec;
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01006302 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006303 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006304 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006305 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006306 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006307 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006308 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006309
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006310 spec->board_config = snd_hda_check_board_config(codec,
6311 STAC_92HD83XXX_MODELS,
6312 stac92hd83xxx_models,
6313 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006314 /* check codec subsystem id if not found */
6315 if (spec->board_config < 0)
6316 spec->board_config =
6317 snd_hda_check_board_codec_sid_config(codec,
6318 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
6319 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006320again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006321 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006322 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6323 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006324 else
6325 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006326 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006327
Takashi Iwaib4e81872009-11-18 17:20:24 +01006328 codec->patch_ops = stac92xx_patch_ops;
6329
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006330 switch (spec->board_config) {
6331 case STAC_HP_ZEPHYR:
6332 spec->init = stac92hd83xxx_hp_zephyr_init;
6333 break;
Takashi Iwaia3e19972012-07-26 08:17:20 +02006334 case STAC_92HD83XXX_HP_LED:
Takashi Iwaiff8a1e22012-07-31 10:16:59 +02006335 default_polarity = 0;
6336 break;
6337 case STAC_92HD83XXX_HP_INV_LED:
Takashi Iwaia3e19972012-07-26 08:17:20 +02006338 default_polarity = 1;
6339 break;
Takashi Iwai62cbde12012-09-14 11:58:54 +02006340 case STAC_92HD83XXX_HP_MIC_LED:
6341 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
6342 break;
David Henningsson8d032a82012-10-09 12:48:40 +02006343 case STAC_92HD83XXX_HEADSET_JACK:
6344 spec->headset_jack = 1;
6345 break;
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06006346 }
6347
Takashi Iwaia3e19972012-07-26 08:17:20 +02006348 if (find_mute_led_cfg(codec, default_polarity))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01006349 snd_printd("mute LED gpio %d polarity %d\n",
6350 spec->gpio_led,
6351 spec->gpio_led_polarity);
6352
Takashi Iwaib4e81872009-11-18 17:20:24 +01006353 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006354 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006355 spec->gpio_mask |= spec->gpio_led;
6356 spec->gpio_dir |= spec->gpio_led;
6357 spec->gpio_data |= spec->gpio_led;
6358 } else {
6359 codec->patch_ops.set_power_state =
6360 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006361 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006362 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01006363
Takashi Iwai62cbde12012-09-14 11:58:54 +02006364 if (spec->mic_mute_led_gpio) {
6365 spec->gpio_mask |= spec->mic_mute_led_gpio;
6366 spec->gpio_dir |= spec->mic_mute_led_gpio;
6367 spec->mic_mute_led_on = true;
6368 spec->gpio_data |= spec->mic_mute_led_gpio;
6369 }
6370
Charles Chin9009b0e2011-11-03 10:27:27 +01006371 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006372 if (!err) {
6373 if (spec->board_config < 0) {
6374 printk(KERN_WARNING "hda_codec: No auto-config is "
6375 "available, default to model=ref\n");
6376 spec->board_config = STAC_92HD83XXX_REF;
6377 goto again;
6378 }
6379 err = -EINVAL;
6380 }
6381
6382 if (err < 0) {
6383 stac92xx_free(codec);
6384 return err;
6385 }
6386
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006387 codec->proc_widget_hook = stac92hd_proc_hook;
6388
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006389 return 0;
6390}
6391
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006392static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
6393 hda_nid_t dig0pin)
6394{
6395 struct sigmatel_spec *spec = codec->spec;
6396 int idx;
6397
6398 for (idx = 0; idx < spec->num_pins; idx++)
6399 if (spec->pin_nids[idx] == dig0pin)
6400 break;
6401 if ((idx + 2) >= spec->num_pins)
6402 return 0;
6403
6404 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006405 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006406 return 2;
6407
6408 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01006409 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006410 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01006411 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006412 return 1;
6413 else
6414 return 0;
6415}
6416
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006417/* HP dv7 bass switch - GPIO5 */
6418#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
6419static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
6420 struct snd_ctl_elem_value *ucontrol)
6421{
6422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6423 struct sigmatel_spec *spec = codec->spec;
6424 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
6425 return 0;
6426}
6427
6428static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
6429 struct snd_ctl_elem_value *ucontrol)
6430{
6431 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6432 struct sigmatel_spec *spec = codec->spec;
6433 unsigned int gpio_data;
6434
6435 gpio_data = (spec->gpio_data & ~0x20) |
6436 (ucontrol->value.integer.value[0] ? 0x20 : 0);
6437 if (gpio_data == spec->gpio_data)
6438 return 0;
6439 spec->gpio_data = gpio_data;
6440 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
6441 return 1;
6442}
6443
Takashi Iwai2b635362011-05-02 12:33:43 +02006444static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6446 .info = stac_hp_bass_gpio_info,
6447 .get = stac_hp_bass_gpio_get,
6448 .put = stac_hp_bass_gpio_put,
6449};
6450
6451static int stac_add_hp_bass_switch(struct hda_codec *codec)
6452{
6453 struct sigmatel_spec *spec = codec->spec;
6454
6455 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
6456 "Bass Speaker Playback Switch", 0))
6457 return -ENOMEM;
6458
6459 spec->gpio_mask |= 0x20;
6460 spec->gpio_dir |= 0x20;
6461 spec->gpio_data |= 0x20;
6462 return 0;
6463}
6464
Matthew Ranostaye035b842007-11-06 11:53:55 +01006465static int patch_stac92hd71bxx(struct hda_codec *codec)
6466{
6467 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02006468 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01006469 unsigned int pin_cfg;
Takashi Iwai361dab32012-05-09 14:35:27 +02006470 int err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006471
Takashi Iwai361dab32012-05-09 14:35:27 +02006472 err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS,
6473 stac92hd71bxx_pin_nids_4port);
6474 if (err < 0)
6475 return err;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006476
Takashi Iwai361dab32012-05-09 14:35:27 +02006477 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006478 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006479 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006480 switch (codec->vendor_id) {
6481 case 0x111d76b6:
6482 case 0x111d76b7:
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05006483 break;
6484 case 0x111d7603:
6485 case 0x111d7608:
6486 /* On 92HD75Bx 0x27 isn't a pin nid */
6487 spec->num_pins--;
6488 /* fallthrough */
6489 default:
6490 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
6491 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006492 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006493 spec->board_config = snd_hda_check_board_config(codec,
6494 STAC_92HD71BXX_MODELS,
6495 stac92hd71bxx_models,
6496 stac92hd71bxx_cfg_tbl);
6497again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006498 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006499 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6500 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006501 else
6502 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006503 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006504
Takashi Iwaifc64b262009-09-14 15:33:01 +02006505 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01006506 /* GPIO0 = EAPD */
6507 spec->gpio_mask = 0x01;
6508 spec->gpio_dir = 0x01;
6509 spec->gpio_data = 0x01;
6510 }
6511
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006512 spec->dmic_nids = stac92hd71bxx_dmic_nids;
6513 spec->dmux_nids = stac92hd71bxx_dmux_nids;
6514
Takashi Iwai6479c632009-07-28 18:20:25 +02006515 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
6516 spec->capvols = stac92hd71bxx_capvols;
6517 spec->capsws = stac92hd71bxx_capsws;
6518
Matthew Ranostay541eee82007-12-14 12:08:04 +01006519 switch (codec->vendor_id) {
6520 case 0x111d76b6: /* 4 Port without Analog Mixer */
6521 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02006522 unmute_init++;
6523 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006524 case 0x111d76b4: /* 6 Port without Analog Mixer */
6525 case 0x111d76b5:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006526 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006527 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006528 stac92hd71bxx_dmic_nids,
6529 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01006530 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006531 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01006532 switch (spec->board_config) {
6533 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04006534 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai3a938972011-10-28 01:16:55 +02006535 err = stac_add_event(codec, codec->afg,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006536 STAC_VREF_EVENT, 0x02);
6537 if (err < 0)
6538 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006539 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04006540 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai3a938972011-10-28 01:16:55 +02006541 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04006542 spec->gpio_mask |= 0x02;
6543 break;
6544 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006545 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006546 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006547 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006548
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006549 /* disable VSW */
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006550 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01006551 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
6552 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02006553 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006554 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02006555 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006556 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006557 break;
6558 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01006559 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006560 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006561
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006562 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01006563 default:
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04006564 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006565 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006566 stac92hd71bxx_dmic_nids,
6567 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02006568 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01006569 }
6570
David Henningsson5e68fb32012-08-16 14:11:09 +02006571 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
6572 spec->init = stac92hd71bxx_core_init;
6573
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05006574 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
6575 snd_hda_sequence_write_cache(codec, unmute_init);
6576
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006577 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04006578 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01006579 spec->aloopback_shift = 0;
6580
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02006581 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006582 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006583 spec->mux_nids = stac92hd71bxx_mux_nids;
6584 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02006585 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006586 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006587
6588 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
6589 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02006590 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05006591 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006592
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05306593 snd_printdd("Found board config: %d\n", spec->board_config);
6594
Matthew Ranostay6a14f582008-09-12 12:02:30 -04006595 switch (spec->board_config) {
6596 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04006597 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01006598 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04006599 stac92xx_auto_set_pinctl(codec, 0x0e,
6600 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05006601 /* fallthru */
6602 case STAC_DELL_M4_2:
6603 spec->num_dmics = 0;
6604 spec->num_smuxes = 0;
6605 spec->num_dmuxes = 0;
6606 break;
6607 case STAC_DELL_M4_1:
6608 case STAC_DELL_M4_3:
6609 spec->num_dmics = 1;
6610 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01006611 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04006612 break;
James Gardiner514bf542009-05-03 04:00:44 -04006613 case STAC_HP_DV4_1222NR:
6614 spec->num_dmics = 1;
6615 /* I don't know if it needs 1 or 2 smuxes - will wait for
6616 * bug reports to fix if needed
6617 */
6618 spec->num_smuxes = 1;
6619 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04006620 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02006621 case STAC_HP_DV4:
6622 spec->gpio_led = 0x01;
6623 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01006624 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01006625 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01006626 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02006627 /* HP dv6 gives the headphone pin as a line-out. Thus we
6628 * need to set hp_detect flag here to force to enable HP
6629 * detection.
6630 */
6631 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01006632 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01006633 case STAC_HP_HDX:
6634 spec->num_dmics = 1;
6635 spec->num_dmuxes = 1;
6636 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02006637 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006638 break;
6639 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01006640
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006641 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01006642 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
6643 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
6644 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
6645 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
6646 /* It was changed in the BIOS to just satisfy MS DTM.
6647 * Lets turn it back into slaved HP
6648 */
6649 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
6650 | (AC_JACK_HP_OUT <<
6651 AC_DEFCFG_DEVICE_SHIFT);
6652 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
6653 | AC_DEFCFG_SEQUENCE)))
6654 | 0x1f;
6655 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
6656 }
6657 }
6658
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06006659 if (find_mute_led_cfg(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01006660 snd_printd("mute LED gpio %d polarity %d\n",
6661 spec->gpio_led,
6662 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01006663
Takashi Iwai86d190e2009-05-26 15:18:58 +02006664 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01006665 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006666 spec->gpio_mask |= spec->gpio_led;
6667 spec->gpio_dir |= spec->gpio_led;
6668 spec->gpio_data |= spec->gpio_led;
6669 } else {
6670 codec->patch_ops.set_power_state =
6671 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05006672 }
Takashi Iwai86d190e2009-05-26 15:18:58 +02006673 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04006674
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01006675 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01006676
Charles Chin9009b0e2011-11-03 10:27:27 +01006677 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01006678 if (!err) {
6679 if (spec->board_config < 0) {
6680 printk(KERN_WARNING "hda_codec: No auto-config is "
6681 "available, default to model=ref\n");
6682 spec->board_config = STAC_92HD71BXX_REF;
6683 goto again;
6684 }
6685 err = -EINVAL;
6686 }
6687
6688 if (err < 0) {
6689 stac92xx_free(codec);
6690 return err;
6691 }
6692
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006693 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02006694 if (spec->board_config == STAC_HP_DV4 ||
6695 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01006696 unsigned int cap;
6697 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
6698 cap &= AC_GPIO_IO_COUNT;
6699 if (cap >= 6)
6700 stac_add_hp_bass_switch(codec);
6701 }
6702
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006703 codec->proc_widget_hook = stac92hd7x_proc_hook;
6704
Matthew Ranostaye035b842007-11-06 11:53:55 +01006705 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006706}
Matthew Ranostaye035b842007-11-06 11:53:55 +01006707
Matt2f2f4252005-04-13 14:45:30 +02006708static int patch_stac922x(struct hda_codec *codec)
6709{
6710 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02006711 int err;
Matt2f2f4252005-04-13 14:45:30 +02006712
Takashi Iwai361dab32012-05-09 14:35:27 +02006713 err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids),
6714 stac922x_pin_nids);
6715 if (err < 0)
6716 return err;
Matt2f2f4252005-04-13 14:45:30 +02006717
Takashi Iwai361dab32012-05-09 14:35:27 +02006718 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006719 spec->linear_tone_beep = 1;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02006720
Takashi Iwai0a427842013-01-14 15:20:13 +01006721 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
6722 stac922x_fixups);
Matt2f2f4252005-04-13 14:45:30 +02006723
Matt2f2f4252005-04-13 14:45:30 +02006724 spec->adc_nids = stac922x_adc_nids;
6725 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006726 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006727 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006728 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006729 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02006730
Takashi Iwai6479c632009-07-28 18:20:25 +02006731 spec->num_caps = STAC922X_NUM_CAPS;
6732 spec->capvols = stac922x_capvols;
6733 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02006734
6735 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02006736
Takashi Iwai0a427842013-01-14 15:20:13 +01006737 snd_hda_add_verbs(codec, stac922x_core_init);
6738
6739 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6740
Charles Chin9009b0e2011-11-03 10:27:27 +01006741 err = stac92xx_parse_auto_config(codec);
Takashi Iwai0a427842013-01-14 15:20:13 +01006742 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006743 err = -EINVAL;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006744 if (err < 0) {
6745 stac92xx_free(codec);
6746 return err;
6747 }
6748
6749 codec->patch_ops = stac92xx_patch_ops;
6750
Takashi Iwai807a46362007-05-29 19:01:37 +02006751 /* Fix Mux capture level; max to 2 */
6752 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6753 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6754 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6755 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6756 (0 << AC_AMPCAP_MUTE_SHIFT));
6757
Takashi Iwai0a427842013-01-14 15:20:13 +01006758 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6759
Matt Porter3cc08dc2006-01-23 15:27:49 +01006760 return 0;
6761}
6762
6763static int patch_stac927x(struct hda_codec *codec)
6764{
6765 struct sigmatel_spec *spec;
6766 int err;
6767
Takashi Iwai361dab32012-05-09 14:35:27 +02006768 err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids),
6769 stac927x_pin_nids);
6770 if (err < 0)
6771 return err;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006772
Takashi Iwai361dab32012-05-09 14:35:27 +02006773 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006774 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006775 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwai29ac8362013-01-14 16:03:38 +01006776
6777 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
6778 stac927x_fixups);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006779
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006780 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006781 spec->adc_nids = stac927x_adc_nids;
6782 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6783 spec->mux_nids = stac927x_mux_nids;
6784 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006785 spec->smux_nids = stac927x_smux_nids;
6786 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006787 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006788 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006789 spec->multiout.dac_nids = spec->dac_nids;
6790
Takashi Iwai29ac8362013-01-14 16:03:38 +01006791 /* GPIO0 High = Enable EAPD */
6792 spec->eapd_mask = spec->gpio_mask = 0x01;
6793 spec->gpio_dir = spec->gpio_data = 0x01;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006794
Takashi Iwai29ac8362013-01-14 16:03:38 +01006795 spec->num_dmics = 0;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006796
Takashi Iwai6479c632009-07-28 18:20:25 +02006797 spec->num_caps = STAC927X_NUM_CAPS;
6798 spec->capvols = stac927x_capvols;
6799 spec->capsws = stac927x_capsws;
6800
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006801 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006802 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006803 spec->aloopback_mask = 0x40;
6804 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006805 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006806
Takashi Iwai29ac8362013-01-14 16:03:38 +01006807 if (!spec->volknob_init)
6808 snd_hda_add_verbs(codec, stac927x_core_init);
6809
6810 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6811
Charles Chin9009b0e2011-11-03 10:27:27 +01006812 err = stac92xx_parse_auto_config(codec);
Takashi Iwai29ac8362013-01-14 16:03:38 +01006813 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006814 err = -EINVAL;
Mattc7d4b2f2005-06-27 14:59:41 +02006815 if (err < 0) {
6816 stac92xx_free(codec);
6817 return err;
6818 }
Matt2f2f4252005-04-13 14:45:30 +02006819
6820 codec->patch_ops = stac92xx_patch_ops;
6821
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006822 codec->proc_widget_hook = stac927x_proc_hook;
6823
Takashi Iwai52987652008-01-16 16:09:47 +01006824 /*
6825 * !!FIXME!!
6826 * The STAC927x seem to require fairly long delays for certain
6827 * command sequences. With too short delays (even if the answer
6828 * is set to RIRB properly), it results in the silence output
6829 * on some hardwares like Dell.
6830 *
6831 * The below flag enables the longer delay (see get_response
6832 * in hda_intel.c).
6833 */
6834 codec->bus->needs_damn_long_delay = 1;
6835
Takashi Iwai29ac8362013-01-14 16:03:38 +01006836 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
Takashi Iwaie28d8322008-12-17 13:48:29 +01006837
Matt2f2f4252005-04-13 14:45:30 +02006838 return 0;
6839}
6840
Matt Porterf3302a52006-07-31 12:49:34 +02006841static int patch_stac9205(struct hda_codec *codec)
6842{
6843 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006844 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006845
Takashi Iwai361dab32012-05-09 14:35:27 +02006846 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids),
6847 stac9205_pin_nids);
6848 if (err < 0)
6849 return err;
Matt Porterf3302a52006-07-31 12:49:34 +02006850
Takashi Iwai361dab32012-05-09 14:35:27 +02006851 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006852 spec->linear_tone_beep = 1;
Takashi Iwaife6322c2013-01-14 14:46:51 +01006853
6854 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
6855 stac9205_fixups);
Matt Porterf3302a52006-07-31 12:49:34 +02006856
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006857 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006858 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006859 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006860 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006861 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006862 spec->smux_nids = stac9205_smux_nids;
6863 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006864 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006865 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006866 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006867 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006868 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006869
Takashi Iwaife6322c2013-01-14 14:46:51 +01006870 snd_hda_add_verbs(codec, stac9205_core_init);
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006871 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006872
Takashi Iwai6479c632009-07-28 18:20:25 +02006873 spec->num_caps = STAC9205_NUM_CAPS;
6874 spec->capvols = stac9205_capvols;
6875 spec->capsws = stac9205_capsws;
6876
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006877 spec->aloopback_mask = 0x40;
6878 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006879 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006880
Takashi Iwaife6322c2013-01-14 14:46:51 +01006881 /* GPIO0 High = EAPD */
6882 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6883 spec->gpio_data = 0x01;
Matt Porter33382402006-12-18 13:17:28 +01006884
Takashi Iwaife6322c2013-01-14 14:46:51 +01006885 /* Turn on/off EAPD per HP plugging */
6886 spec->eapd_switch = 1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006887
Takashi Iwaife6322c2013-01-14 14:46:51 +01006888 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Matthew Ranostay87d48362007-07-17 11:52:24 +02006889
Charles Chin9009b0e2011-11-03 10:27:27 +01006890 err = stac92xx_parse_auto_config(codec);
Takashi Iwaife6322c2013-01-14 14:46:51 +01006891 if (!err)
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006892 err = -EINVAL;
Matt Porterf3302a52006-07-31 12:49:34 +02006893 if (err < 0) {
6894 stac92xx_free(codec);
6895 return err;
6896 }
6897
6898 codec->patch_ops = stac92xx_patch_ops;
6899
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006900 codec->proc_widget_hook = stac9205_proc_hook;
6901
Takashi Iwaife6322c2013-01-14 14:46:51 +01006902 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6903
Matt Porterf3302a52006-07-31 12:49:34 +02006904 return 0;
6905}
6906
Matt2f2f4252005-04-13 14:45:30 +02006907/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006908 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006909 */
6910
Takashi Iwai2b635362011-05-02 12:33:43 +02006911static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6914 {}
6915};
6916
Takashi Iwai2b635362011-05-02 12:33:43 +02006917static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006918 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6919 0x11, 0x13, 0x14,
6920};
6921
Takashi Iwai2b635362011-05-02 12:33:43 +02006922static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006923 0x8 /*,0x6*/
6924};
6925
Takashi Iwai2b635362011-05-02 12:33:43 +02006926static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006927 0x15
6928};
6929
Takashi Iwai2b635362011-05-02 12:33:43 +02006930static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006931 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6932};
6933#define stac9872_capsws stac9872_capvols
6934
Takashi Iwaifc268c12013-01-14 14:29:36 +01006935static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
6936 { 0x0a, 0x03211020 },
6937 { 0x0b, 0x411111f0 },
6938 { 0x0c, 0x411111f0 },
6939 { 0x0d, 0x03a15030 },
6940 { 0x0e, 0x411111f0 },
6941 { 0x0f, 0x90170110 },
6942 { 0x11, 0x411111f0 },
6943 { 0x13, 0x411111f0 },
6944 { 0x14, 0x90a7013e },
6945 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01006946};
6947
Takashi Iwaifc268c12013-01-14 14:29:36 +01006948static const struct hda_model_fixup stac9872_models[] = {
6949 { .id = STAC_9872_VAIO, .name = "vaio" },
6950 {}
Takashi Iwai307282c2009-03-12 18:17:58 +01006951};
6952
Takashi Iwaifc268c12013-01-14 14:29:36 +01006953static const struct hda_fixup stac9872_fixups[] = {
6954 [STAC_9872_VAIO] = {
6955 .type = HDA_FIXUP_PINS,
6956 .v.pins = stac9872_vaio_pin_configs,
6957 },
Takashi Iwai307282c2009-03-12 18:17:58 +01006958};
6959
Takashi Iwaifc268c12013-01-14 14:29:36 +01006960static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006961 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6962 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006963 {} /* terminator */
6964};
6965
Guillaume Munch6d859062006-08-22 17:15:47 +02006966static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006967{
6968 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006969 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006970
Takashi Iwai361dab32012-05-09 14:35:27 +02006971 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids),
6972 stac9872_pin_nids);
6973 if (err < 0)
6974 return err;
6975
6976 spec = codec->spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006977 spec->linear_tone_beep = 1;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006978
Takashi Iwaifc268c12013-01-14 14:29:36 +01006979 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
6980 stac9872_fixups);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006981
Takashi Iwai1e137f92009-01-21 07:41:22 +01006982 spec->multiout.dac_nids = spec->dac_nids;
6983 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6984 spec->adc_nids = stac9872_adc_nids;
6985 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6986 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai6479c632009-07-28 18:20:25 +02006987 spec->num_caps = 1;
6988 spec->capvols = stac9872_capvols;
6989 spec->capsws = stac9872_capsws;
Takashi Iwaifc268c12013-01-14 14:29:36 +01006990 snd_hda_add_verbs(codec, stac9872_core_init);
6991
6992 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006993
Charles Chin9009b0e2011-11-03 10:27:27 +01006994 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01006995 if (err < 0) {
6996 stac92xx_free(codec);
6997 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006998 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006999 spec->input_mux = &spec->private_imux;
7000 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaifc268c12013-01-14 14:29:36 +01007001
7002 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7003
Takashi Iwaidb064e52006-03-16 16:04:58 +01007004 return 0;
7005}
7006
7007
7008/*
Matt2f2f4252005-04-13 14:45:30 +02007009 * patch entries
7010 */
Takashi Iwai2b635362011-05-02 12:33:43 +02007011static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02007012 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
7013 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
7014 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
7015 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
7016 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
7017 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
7018 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02007019 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
7020 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
7021 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
7022 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
7023 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
7024 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01007025 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
7026 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
7027 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
7028 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
7029 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
7030 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
7031 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
7032 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
7033 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
7034 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01007035 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
7036 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
7037 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
7038 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
7039 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
7040 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02007041 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
7042 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02007043 /* The following does not take into account .id=0x83847661 when subsys =
7044 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
7045 * currently not fully supported.
7046 */
7047 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
7048 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
7049 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01007050 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02007051 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
7052 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
7053 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
7054 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
7055 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
7056 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
7057 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
7058 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007059 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007060 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01007061 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02007062 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04007063 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02007064 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
7065 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01007066 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
7067 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
7068 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
7069 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02007070 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01007071 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
7072 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01007073 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01007074 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7075 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7076 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7077 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7078 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7079 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7080 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7081 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02007082 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
7083 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
7084 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
7085 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
7086 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
7087 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
7088 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
7089 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
7090 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
7091 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
7092 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
7093 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
7094 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
7095 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
7096 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02007097 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007098 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06007099 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
7100 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02007101 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01007102 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
7103 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
7104 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
7105 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
7106 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
7107 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
7108 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
7109 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
7110 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
7111 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
7112 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
7113 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02007114 {} /* terminator */
7115};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01007116
7117MODULE_ALIAS("snd-hda-codec-id:8384*");
7118MODULE_ALIAS("snd-hda-codec-id:111d*");
7119
7120MODULE_LICENSE("GPL");
7121MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
7122
7123static struct hda_codec_preset_list sigmatel_list = {
7124 .preset = snd_hda_preset_sigmatel,
7125 .owner = THIS_MODULE,
7126};
7127
7128static int __init patch_sigmatel_init(void)
7129{
7130 return snd_hda_add_codec_preset(&sigmatel_list);
7131}
7132
7133static void __exit patch_sigmatel_exit(void)
7134{
7135 snd_hda_delete_codec_preset(&sigmatel_list);
7136}
7137
7138module_init(patch_sigmatel_init)
7139module_exit(patch_sigmatel_exit)