blob: 217ee1f344b873a4bb0354780339085141cf761c [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 {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010053 STAC_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010054 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010055 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020056 STAC_9200_DELL_D21,
57 STAC_9200_DELL_D22,
58 STAC_9200_DELL_D23,
59 STAC_9200_DELL_M21,
60 STAC_9200_DELL_M22,
61 STAC_9200_DELL_M23,
62 STAC_9200_DELL_M24,
63 STAC_9200_DELL_M25,
64 STAC_9200_DELL_M26,
65 STAC_9200_DELL_M27,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +020066 STAC_9200_M4,
67 STAC_9200_M4_2,
Takashi Iwai117f2572008-03-18 09:53:23 +010068 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_9200_MODELS
70};
71
72enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010073 STAC_9205_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010074 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020075 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020076 STAC_9205_DELL_M43,
77 STAC_9205_DELL_M44,
Takashi Iwaid9a42682009-01-22 17:40:18 +010078 STAC_9205_EAPD,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010079 STAC_9205_MODELS
80};
81
82enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010083 STAC_92HD73XX_AUTO,
Takashi Iwai9e43f0d2008-12-17 14:51:01 +010084 STAC_92HD73XX_NO_JD, /* no jack-detection */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010085 STAC_92HD73XX_REF,
Wu Fengguangae709442009-08-19 17:05:11 +080086 STAC_92HD73XX_INTEL,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010087 STAC_DELL_M6_AMIC,
88 STAC_DELL_M6_DMIC,
89 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050090 STAC_DELL_EQ,
Takashi Iwai842ae632009-09-02 07:43:08 +020091 STAC_ALIENWARE_M17X,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010092 STAC_92HD73XX_MODELS
93};
94
95enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +010096 STAC_92HD83XXX_AUTO,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020097 STAC_92HD83XXX_REF,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -050098 STAC_92HD83XXX_PWR_REF,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -050099 STAC_DELL_S14,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +0100100 STAC_DELL_VOSTRO_3500,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -0500101 STAC_92HD83XXX_HP_cNB11_INTQUAD,
Steven Eastland48315592010-08-06 15:07:35 -0600102 STAC_HP_DV7_4000,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600103 STAC_HP_ZEPHYR,
Takashi Iwaia3e19972012-07-26 08:17:20 +0200104 STAC_92HD83XXX_HP_LED,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200105 STAC_92HD83XXX_MODELS
106};
107
108enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100109 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100110 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100111 STAC_DELL_M4_1,
112 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500113 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400114 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200115 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100116 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100117 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400118 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100119 STAC_92HD71BXX_MODELS
120};
121
122enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100123 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100124 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200125 STAC_M1,
126 STAC_M1_2,
127 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100128 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200129 STAC_M3,
130 STAC_M5,
131 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100132 STAC_925x_MODELS
133};
134
135enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100136 STAC_922X_AUTO,
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,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800145 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
146 * is given, one of the above models will be
147 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200148 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100149 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100150 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100151 STAC_MACBOOK_PRO_V1,
152 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200153 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200154 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300155 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200156 STAC_922X_DELL_D81,
157 STAC_922X_DELL_D82,
158 STAC_922X_DELL_M81,
159 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100160 STAC_922X_MODELS
161};
162
163enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100164 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100165 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100166 STAC_D965_REF,
167 STAC_D965_3ST,
168 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200169 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200170 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100171 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200172 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100173 STAC_927X_MODELS
174};
Matt Porter403d1942005-11-29 15:00:51 +0100175
Takashi Iwai307282c2009-03-12 18:17:58 +0100176enum {
177 STAC_9872_AUTO,
178 STAC_9872_VAIO,
179 STAC_9872_MODELS
180};
181
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200182struct sigmatel_mic_route {
183 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200184 signed char mux_idx;
185 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200186};
187
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600188#define MAX_PINS_NUM 16
189#define MAX_ADCS_NUM 4
190#define MAX_DMICS_NUM 4
191
Matt2f2f4252005-04-13 14:45:30 +0200192struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100193 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200194 unsigned int num_mixers;
195
Matt Porter403d1942005-11-29 15:00:51 +0100196 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500197 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200198 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100199 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100200 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400201 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100202 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200203 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100204 unsigned int linear_tone_beep:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200205
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100206 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200207 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100208 unsigned int gpio_mask;
209 unsigned int gpio_dir;
210 unsigned int gpio_data;
211 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200212 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100213 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100214 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500215 unsigned int vref_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100216
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200217 /* stream */
218 unsigned int stream_delay;
219
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100220 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200221 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100222 unsigned char aloopback_mask;
223 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200224
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100225 /* power management */
Takashi Iwaic8822462012-05-15 09:11:36 +0200226 unsigned int power_map_bits;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100227 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200228 const hda_nid_t *pwr_nids;
229 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100230
Matt2f2f4252005-04-13 14:45:30 +0200231 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100232 struct hda_input_mux *mono_mux;
233 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200234 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100235 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100236 hda_nid_t hp_dacs[5];
237 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200238
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100239 int volume_offset;
240
Matt2f2f4252005-04-13 14:45:30 +0200241 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200242 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200243 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200244 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200245 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200246 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200247 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200248 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100249 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200250 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200251 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200252 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200253
Takashi Iwai2b635362011-05-02 12:33:43 +0200254 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
255 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200256 unsigned int num_caps; /* number of capture volume/switch elements */
257
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200258 struct sigmatel_mic_route ext_mic;
259 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200260 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200261
Takashi Iwaiea734962011-01-17 11:29:34 +0100262 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200263
Mattdabbed62005-06-14 10:19:34 +0200264 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100265 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200266 hda_nid_t anabeep_nid;
267 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200268
Matt2f2f4252005-04-13 14:45:30 +0200269 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200270 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200271 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200272
273 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200274 const struct hda_verb *init;
275 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200276
277 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200278 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100279 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200280 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100281 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200282 struct hda_input_mux *sinput_mux;
283 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400284 unsigned int cur_amux;
285 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200286 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200287
Matt Porter403d1942005-11-29 15:00:51 +0100288 /* i/o switches */
289 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200290 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100291 hda_nid_t line_switch; /* shared line-in for input and output */
292 hda_nid_t mic_switch; /* shared mic-in for input and output */
293 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200294 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200295
Mattc7d4b2f2005-06-27 14:59:41 +0200296 struct hda_pcm pcm_rec[2]; /* PCM information */
297
298 /* dynamic controls and input_mux */
299 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200300 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200301 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200302 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200303 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100304 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600305
306 /* auto spec */
307 unsigned auto_pin_cnt;
308 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
309 unsigned auto_adc_cnt;
310 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
311 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
312 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
313 unsigned long auto_capvols[MAX_ADCS_NUM];
314 unsigned auto_dmic_cnt;
315 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100316
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100317 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200318};
319
Takashi Iwaic8822462012-05-15 09:11:36 +0200320#define AC_VERB_IDT_SET_POWER_MAP 0x7ec
321#define AC_VERB_IDT_GET_POWER_MAP 0xfec
322
Takashi Iwai2b635362011-05-02 12:33:43 +0200323static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200324 0x03,
325};
326
Takashi Iwai2b635362011-05-02 12:33:43 +0200327static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200328 0x0c,
329};
330
Takashi Iwai2b635362011-05-02 12:33:43 +0200331static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200332 0x02,
333};
334
Takashi Iwai2b635362011-05-02 12:33:43 +0200335static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100336 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
337 0x0f, 0x10, 0x11
338};
339
Takashi Iwai2b635362011-05-02 12:33:43 +0200340static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400341 0x26, 0,
342};
343
Takashi Iwai2b635362011-05-02 12:33:43 +0200344static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345 0x1a, 0x1b
346};
347
348#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200349static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100350 0x13, 0x14, 0
351};
352
353#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100354
Takashi Iwai2b635362011-05-02 12:33:43 +0200355static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200356 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100357};
358
Takashi Iwai2b635362011-05-02 12:33:43 +0200359static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100360 0x20, 0x21,
361};
362
Takashi Iwai2b635362011-05-02 12:33:43 +0200363static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200364 0x22, 0x23,
365};
366
Takashi Iwai6479c632009-07-28 18:20:25 +0200367#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200368static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200369 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
370 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
371};
372#define stac92hd73xx_capsws stac92hd73xx_capvols
373
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200374#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200375
Charles Chinafef2cf2011-11-11 08:05:28 +0100376static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
377 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
378 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200379};
380
Takashi Iwai2b635362011-05-02 12:33:43 +0200381static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400382 0x1e, 0,
383};
384
Takashi Iwai2b635362011-05-02 12:33:43 +0200385static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600386 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200387};
388
Takashi Iwai2b635362011-05-02 12:33:43 +0200389static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100390 0x0a, 0x0d, 0x0f
391};
392
Takashi Iwai2b635362011-05-02 12:33:43 +0200393static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100394 0x12, 0x13,
395};
396
Takashi Iwai2b635362011-05-02 12:33:43 +0200397static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100398 0x1a, 0x1b
399};
400
Takashi Iwai2b635362011-05-02 12:33:43 +0200401static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400402 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100403};
404
Takashi Iwai2b635362011-05-02 12:33:43 +0200405static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200406 0x24, 0x25,
407};
408
Matthew Ranostaye035b842007-11-06 11:53:55 +0100409#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200410static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100411 0x18, 0x19, 0
412};
413
Takashi Iwai2b635362011-05-02 12:33:43 +0200414static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
415 0x18, 0
416};
417
418static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400419 0x22, 0
420};
421
Takashi Iwai6479c632009-07-28 18:20:25 +0200422#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200423static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200424 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
426};
427#define stac92hd71bxx_capsws stac92hd71bxx_capvols
428
Takashi Iwai2b635362011-05-02 12:33:43 +0200429static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100430 0x03,
431};
432
Takashi Iwai2b635362011-05-02 12:33:43 +0200433static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100434 0x0f,
435};
436
Takashi Iwai2b635362011-05-02 12:33:43 +0200437static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100438 0x02,
439};
440
Takashi Iwaif6e98522007-10-16 14:27:04 +0200441#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200442static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200443 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200444};
445
Takashi Iwai2b635362011-05-02 12:33:43 +0200446static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100447 0x14,
448};
449
Takashi Iwai2b635362011-05-02 12:33:43 +0200450static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200451 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
452};
Takashi Iwai2b635362011-05-02 12:33:43 +0200453static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200454 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
455};
456
Takashi Iwai2b635362011-05-02 12:33:43 +0200457static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200458 0x06, 0x07,
459};
460
Takashi Iwai2b635362011-05-02 12:33:43 +0200461static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200462 0x12, 0x13,
463};
464
Takashi Iwai6479c632009-07-28 18:20:25 +0200465#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200466static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200467 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
468 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
469};
470#define stac922x_capsws stac922x_capvols
471
Takashi Iwai2b635362011-05-02 12:33:43 +0200472static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500473 0x1f, 0,
474};
475
Takashi Iwai2b635362011-05-02 12:33:43 +0200476static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100477 0x07, 0x08, 0x09
478};
479
Takashi Iwai2b635362011-05-02 12:33:43 +0200480static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100481 0x15, 0x16, 0x17
482};
483
Takashi Iwai2b635362011-05-02 12:33:43 +0200484static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200485 0x21,
486};
487
Takashi Iwai2b635362011-05-02 12:33:43 +0200488static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100489 0x02, 0x03, 0x04, 0x05, 0x06, 0
490};
491
Takashi Iwai2b635362011-05-02 12:33:43 +0200492static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100493 0x1b,
494};
495
Matthew Ranostay7f168592007-10-18 17:38:17 +0200496#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200497static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200498 0x13, 0x14, 0
499};
500
Takashi Iwai6479c632009-07-28 18:20:25 +0200501#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200502static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200503 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
504 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
506};
Takashi Iwai2b635362011-05-02 12:33:43 +0200507static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200508 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
509 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
511};
512
Takashi Iwaiea734962011-01-17 11:29:34 +0100513static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400514 "Digital Playback", "ADAT", "Analog Mux 1",
515 "Analog Mux 2", "Analog Mux 3"
516};
517
Takashi Iwai2b635362011-05-02 12:33:43 +0200518static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200519 0x12, 0x13
520};
521
Takashi Iwai2b635362011-05-02 12:33:43 +0200522static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200523 0x19, 0x1a
524};
525
Takashi Iwai2b635362011-05-02 12:33:43 +0200526static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100527 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100528};
529
Takashi Iwai2b635362011-05-02 12:33:43 +0200530static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200531 0x21,
532};
533
Takashi Iwaif6e98522007-10-16 14:27:04 +0200534#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200535static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200536 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200537};
538
Takashi Iwai6479c632009-07-28 18:20:25 +0200539#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200540static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200541 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
542 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
543};
Takashi Iwai2b635362011-05-02 12:33:43 +0200544static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200545 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
546 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
547};
548
Takashi Iwai2b635362011-05-02 12:33:43 +0200549static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200550 0x08, 0x09, 0x0d, 0x0e,
551 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200552};
553
Takashi Iwai2b635362011-05-02 12:33:43 +0200554static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100555 0x07, 0x08, 0x0a, 0x0b,
556 0x0c, 0x0d, 0x10, 0x11,
557};
558
Takashi Iwai2b635362011-05-02 12:33:43 +0200559static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200560 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
561 0x0f, 0x10, 0x11, 0x15, 0x1b,
562};
563
Takashi Iwai2b635362011-05-02 12:33:43 +0200564static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200567 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100568};
569
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500570#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200571static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500572 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
573 0x00, 0x14, 0x18, 0x19, 0x1e,
574 0x1f, 0x20, 0x27
575};
Takashi Iwai2b635362011-05-02 12:33:43 +0200576static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500579 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100580};
581
Takashi Iwai2b635362011-05-02 12:33:43 +0200582static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x10, 0x11, 0x12, 0x13,
585 0x14, 0x21, 0x22, 0x23,
586};
587
Takashi Iwai2b635362011-05-02 12:33:43 +0200588static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200589 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
590 0x0f, 0x14, 0x16, 0x17, 0x18,
591 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200592};
593
Matt Porter8b657272006-10-26 17:12:59 +0200594static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
595 struct snd_ctl_elem_info *uinfo)
596{
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 struct sigmatel_spec *spec = codec->spec;
599 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
600}
601
602static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_value *ucontrol)
604{
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100607 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200608
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100609 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200610 return 0;
611}
612
613static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
615{
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100618 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200619
620 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100621 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200622}
623
Matthew Ranostayd9737752008-09-07 12:03:41 +0200624static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_info *uinfo)
626{
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
629 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
630}
631
632static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
634{
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
638
639 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
640 return 0;
641}
642
643static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
645{
646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
647 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400648 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200649 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400650 int err, val;
651 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200652
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400653 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200654 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400655 if (err < 0)
656 return err;
657
658 if (spec->spdif_mute) {
659 if (smux_idx == 0)
660 nid = spec->multiout.dig_out_nid;
661 else
662 nid = codec->slave_dig_outs[smux_idx - 1];
663 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100664 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400665 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100666 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400667 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100668 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
669 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400670 }
671 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200672}
673
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500674static int stac_vrefout_set(struct hda_codec *codec,
675 hda_nid_t nid, unsigned int new_vref)
676{
677 int error, pinctl;
678
679 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
680 pinctl = snd_hda_codec_read(codec, nid, 0,
681 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
682
683 if (pinctl < 0)
684 return pinctl;
685
686 pinctl &= 0xff;
687 pinctl &= ~AC_PINCTL_VREFEN;
688 pinctl |= (new_vref & AC_PINCTL_VREFEN);
689
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200690 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500691 if (error < 0)
692 return error;
693
694 return 1;
695}
696
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200697static unsigned int stac92xx_vref_set(struct hda_codec *codec,
698 hda_nid_t nid, unsigned int new_vref)
699{
Takashi Iwaib8621512009-06-22 08:00:10 +0200700 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200701 unsigned int pincfg;
702 pincfg = snd_hda_codec_read(codec, nid, 0,
703 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
704
705 pincfg &= 0xff;
706 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
707 pincfg |= new_vref;
708
709 if (new_vref == AC_PINCTL_VREF_HIZ)
710 pincfg |= AC_PINCTL_OUT_EN;
711 else
712 pincfg |= AC_PINCTL_IN_EN;
713
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200714 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200715 if (error < 0)
716 return error;
717 else
718 return 1;
719}
720
721static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
722{
723 unsigned int vref;
724 vref = snd_hda_codec_read(codec, nid, 0,
725 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
726 vref &= AC_PINCTL_VREFEN;
727 return vref;
728}
729
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100730static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200731{
732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
733 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200734 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200735}
736
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100737static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200738{
739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
740 struct sigmatel_spec *spec = codec->spec;
741 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
742
743 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
744 return 0;
745}
746
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100747static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200748{
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 struct sigmatel_spec *spec = codec->spec;
751 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200752 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600753 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200754
Takashi Iwai5207e102009-07-30 13:09:08 +0200755 idx = ucontrol->value.enumerated.item[0];
756 if (idx >= imux->num_items)
757 idx = imux->num_items - 1;
758 prev_idx = spec->cur_mux[adc_idx];
759 if (prev_idx == idx)
760 return 0;
761 if (idx < spec->num_analog_muxes) {
762 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
763 AC_VERB_SET_CONNECT_SEL,
764 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600765 if (prev_idx >= spec->num_analog_muxes &&
766 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200767 imux = spec->dinput_mux;
768 /* 0 = analog */
769 snd_hda_codec_write_cache(codec,
770 spec->dmux_nids[adc_idx], 0,
771 AC_VERB_SET_CONNECT_SEL,
772 imux->items[0].index);
773 }
774 } else {
775 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600776 /* first dimux item is hardcoded to select analog imux,
777 * so lets skip it
778 */
779 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200780 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
781 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600782 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200783 }
784 spec->cur_mux[adc_idx] = idx;
785 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200786}
787
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100788static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
789 struct snd_ctl_elem_info *uinfo)
790{
791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
792 struct sigmatel_spec *spec = codec->spec;
793 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
794}
795
796static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
797 struct snd_ctl_elem_value *ucontrol)
798{
799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
800 struct sigmatel_spec *spec = codec->spec;
801
802 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
803 return 0;
804}
805
806static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
807 struct snd_ctl_elem_value *ucontrol)
808{
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 struct sigmatel_spec *spec = codec->spec;
811
812 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
813 spec->mono_nid, &spec->cur_mmux);
814}
815
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200816#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
817
818static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
819 struct snd_ctl_elem_value *ucontrol)
820{
821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100822 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200823 struct sigmatel_spec *spec = codec->spec;
824
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100825 ucontrol->value.integer.value[0] = !!(spec->aloopback &
826 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200827 return 0;
828}
829
830static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
831 struct snd_ctl_elem_value *ucontrol)
832{
833 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
834 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100835 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200836 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100837 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200838
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100839 idx_val = spec->aloopback_mask << idx;
840 if (ucontrol->value.integer.value[0])
841 val = spec->aloopback | idx_val;
842 else
843 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100844 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200845 return 0;
846
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100847 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200848
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100849 /* Only return the bits defined by the shift value of the
850 * first two bytes of the mask
851 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200852 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100853 kcontrol->private_value & 0xFFFF, 0x0);
854 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200855
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100856 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200857 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100858 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200859 } else {
860 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100861 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200862 }
863
864 snd_hda_codec_write_cache(codec, codec->afg, 0,
865 kcontrol->private_value >> 16, dac_mode);
866
867 return 1;
868}
869
Takashi Iwai2b635362011-05-02 12:33:43 +0200870static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200871 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200872 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200873 {}
874};
875
Takashi Iwai2b635362011-05-02 12:33:43 +0200876static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200877 /* set dac0mux for dac converter */
878 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
879 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
880 {}
881};
882
Takashi Iwai2b635362011-05-02 12:33:43 +0200883static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100884 /* set master volume to max value without distortion
885 * and direct control */
886 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100887 {}
888};
889
Takashi Iwai2b635362011-05-02 12:33:43 +0200890static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100891 /* set master volume and direct control */
892 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100893 {}
894};
895
Takashi Iwai2b635362011-05-02 12:33:43 +0200896static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200897 /* power state controls amps */
898 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200899 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200900};
901
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600902static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
903 { 0x22, 0x785, 0x43 },
904 { 0x22, 0x782, 0xe0 },
905 { 0x22, 0x795, 0x00 },
906 {}
907};
908
Takashi Iwai2b635362011-05-02 12:33:43 +0200909static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100910 /* set master volume and direct control */
911 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200912 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100913};
914
Takashi Iwai2b635362011-05-02 12:33:43 +0200915static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500916 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
917 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100918 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
919 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100920 {}
921};
922
Takashi Iwai2b635362011-05-02 12:33:43 +0200923static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100924 /* set dac0mux for dac converter */
925 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100926 /* mute the master volume */
927 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100928 {}
929};
930
Takashi Iwai2b635362011-05-02 12:33:43 +0200931static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200932 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200933 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200934 {}
935};
936
Takashi Iwai2b635362011-05-02 12:33:43 +0200937static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200938 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200939 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200940 /* unmute node 0x1b */
941 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
942 /* select node 0x03 as DAC */
943 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
944 {}
945};
946
Takashi Iwai2b635362011-05-02 12:33:43 +0200947static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200948 /* don't set delta bit */
949 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
950 /* unmute node 0x1b */
951 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
952 /* select node 0x03 as DAC */
953 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
954 {}
955};
956
Takashi Iwai2b635362011-05-02 12:33:43 +0200957static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100958 /* set master volume and direct control */
959 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200960 /* enable analog pc beep path */
961 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100962 {}
963};
964
Takashi Iwai2b635362011-05-02 12:33:43 +0200965static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200966 /* don't set delta bit */
967 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
968 /* enable analog pc beep path */
969 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
970 {}
971};
972
Takashi Iwai2b635362011-05-02 12:33:43 +0200973static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200974 /* set master volume and direct control */
975 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200976 /* enable analog pc beep path */
977 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200978 {}
979};
980
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100981#define STAC_MONO_MUX \
982 { \
983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
984 .name = "Mono Mux", \
985 .count = 1, \
986 .info = stac92xx_mono_mux_enum_info, \
987 .get = stac92xx_mono_mux_enum_get, \
988 .put = stac92xx_mono_mux_enum_put, \
989 }
990
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100991#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200992 { \
993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
994 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100995 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200996 .info = stac92xx_aloopback_info, \
997 .get = stac92xx_aloopback_get, \
998 .put = stac92xx_aloopback_put, \
999 .private_value = verb_read | (verb_write << 16), \
1000 }
1001
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02001002#define DC_BIAS(xname, idx, nid) \
1003 { \
1004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1005 .name = xname, \
1006 .index = idx, \
1007 .info = stac92xx_dc_bias_info, \
1008 .get = stac92xx_dc_bias_get, \
1009 .put = stac92xx_dc_bias_put, \
1010 .private_value = nid, \
1011 }
1012
Takashi Iwai2b635362011-05-02 12:33:43 +02001013static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001014 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1015 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001016 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1017 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001018 { } /* end */
1019};
1020
Takashi Iwai2b635362011-05-02 12:33:43 +02001021static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001022 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1023 {}
1024};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001025
Takashi Iwai2b635362011-05-02 12:33:43 +02001026static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1028 {}
1029};
1030
Takashi Iwai2b635362011-05-02 12:33:43 +02001031static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001032 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1033 {}
1034};
1035
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001036
Takashi Iwai2b635362011-05-02 12:33:43 +02001037static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001038 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1039};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001040
Takashi Iwai2b635362011-05-02 12:33:43 +02001041static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001042 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1043 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001044 { } /* end */
1045};
1046
Takashi Iwai2b635362011-05-02 12:33:43 +02001047static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001048 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1049 {}
1050};
1051
Takashi Iwai2b635362011-05-02 12:33:43 +02001052static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001053 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1054 {}
1055};
1056
Takashi Iwai1697055e2007-12-18 18:05:52 +01001057static struct snd_kcontrol_new stac_dmux_mixer = {
1058 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1059 .name = "Digital Input Source",
1060 /* count set later */
1061 .info = stac92xx_dmux_enum_info,
1062 .get = stac92xx_dmux_enum_get,
1063 .put = stac92xx_dmux_enum_put,
1064};
1065
Matthew Ranostayd9737752008-09-07 12:03:41 +02001066static struct snd_kcontrol_new stac_smux_mixer = {
1067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001068 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001069 /* count set later */
1070 .info = stac92xx_smux_enum_info,
1071 .get = stac92xx_smux_enum_get,
1072 .put = stac92xx_smux_enum_put,
1073};
1074
Takashi Iwai9322ca52012-02-03 14:28:01 +01001075static const char * const slave_pfxs[] = {
1076 "Front", "Surround", "Center", "LFE", "Side",
1077 "Headphone", "Speaker", "IEC958",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001078 NULL
1079};
1080
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001081static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1082
1083static void stac92xx_vmaster_hook(void *private_data, int val)
1084{
1085 stac92xx_update_led_status(private_data, val);
1086}
1087
Takashi Iwai603c4012008-07-30 15:01:44 +02001088static void stac92xx_free_kctls(struct hda_codec *codec);
1089
Matt2f2f4252005-04-13 14:45:30 +02001090static int stac92xx_build_controls(struct hda_codec *codec)
1091{
1092 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001093 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001094 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001095 int i;
Matt2f2f4252005-04-13 14:45:30 +02001096
Takashi Iwai6479c632009-07-28 18:20:25 +02001097 if (spec->mixer) {
1098 err = snd_hda_add_new_ctls(codec, spec->mixer);
1099 if (err < 0)
1100 return err;
1101 }
Mattc7d4b2f2005-06-27 14:59:41 +02001102
1103 for (i = 0; i < spec->num_mixers; i++) {
1104 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1105 if (err < 0)
1106 return err;
1107 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001108 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1109 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001110 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001111 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001112 snd_ctl_new1(&stac_dmux_mixer, codec));
1113 if (err < 0)
1114 return err;
1115 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001116 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001117 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1118 struct hda_input_mux *smux = &spec->private_smux;
1119 /* check for mute support on SPDIF out */
1120 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001121 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001122 spec->spdif_mute = 1;
1123 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001124 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001125 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001126 snd_ctl_new1(&stac_smux_mixer, codec));
1127 if (err < 0)
1128 return err;
1129 }
Mattc7d4b2f2005-06-27 14:59:41 +02001130
Mattdabbed62005-06-14 10:19:34 +02001131 if (spec->multiout.dig_out_nid) {
Stephen Warren74b654c2011-06-01 11:14:18 -06001132 err = snd_hda_create_spdif_out_ctls(codec,
1133 spec->multiout.dig_out_nid,
1134 spec->multiout.dig_out_nid);
Mattdabbed62005-06-14 10:19:34 +02001135 if (err < 0)
1136 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001137 err = snd_hda_create_spdif_share_sw(codec,
1138 &spec->multiout);
1139 if (err < 0)
1140 return err;
1141 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001142 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001143 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001144 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1145 if (err < 0)
1146 return err;
1147 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001148
1149 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001150 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1151 HDA_OUTPUT, vmaster_tlv);
1152 /* correct volume offset */
1153 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1154 /* minimum value is actually mute */
1155 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1156 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1157 vmaster_tlv, slave_pfxs,
1158 "Playback Volume");
1159 if (err < 0)
1160 return err;
1161
1162 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1163 NULL, slave_pfxs,
1164 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001165 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001166 if (err < 0)
1167 return err;
1168
1169 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001170 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001171 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001172 if (err < 0)
1173 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001174 }
1175
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001176 if (spec->aloopback_ctl &&
1177 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1178 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1179 if (err < 0)
1180 return err;
1181 }
1182
Takashi Iwai603c4012008-07-30 15:01:44 +02001183 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001184
Takashi Iwai01a61e12011-10-28 00:03:22 +02001185 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1186 if (err < 0)
1187 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001188
Mattdabbed62005-06-14 10:19:34 +02001189 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001190}
1191
Takashi Iwai2b635362011-05-02 12:33:43 +02001192static const unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001193 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001194 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1195};
1196
Takashi Iwai2b635362011-05-02 12:33:43 +02001197static const unsigned int gateway9200_m4_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001198 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1199 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1200};
Takashi Iwai2b635362011-05-02 12:33:43 +02001201static const unsigned int gateway9200_m4_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001202 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1203 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1204};
1205
1206/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001207 STAC 9200 pin configs for
1208 102801A8
1209 102801DE
1210 102801E8
1211*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001212static const unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001213 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1214 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001215};
1216
1217/*
1218 STAC 9200 pin configs for
1219 102801C0
1220 102801C1
1221*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001222static const unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001223 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1224 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001225};
1226
1227/*
1228 STAC 9200 pin configs for
1229 102801C4 (Dell Dimension E310)
1230 102801C5
1231 102801C7
1232 102801D9
1233 102801DA
1234 102801E3
1235*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001236static const unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001237 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1238 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001239};
1240
1241
1242/*
1243 STAC 9200-32 pin configs for
1244 102801B5 (Dell Inspiron 630m)
1245 102801D8 (Dell Inspiron 640m)
1246*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001247static const unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001248 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1249 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001250};
1251
1252/*
1253 STAC 9200-32 pin configs for
1254 102801C2 (Dell Latitude D620)
1255 102801C8
1256 102801CC (Dell Latitude D820)
1257 102801D4
1258 102801D6
1259*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001260static const unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001261 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1262 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001263};
1264
1265/*
1266 STAC 9200-32 pin configs for
1267 102801CE (Dell XPS M1710)
1268 102801CF (Dell Precision M90)
1269*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001270static const unsigned int dell9200_m23_pin_configs[8] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001271 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1272 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1273};
1274
1275/*
1276 STAC 9200-32 pin configs for
1277 102801C9
1278 102801CA
1279 102801CB (Dell Latitude 120L)
1280 102801D3
1281*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001282static const unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001283 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1284 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001285};
1286
1287/*
1288 STAC 9200-32 pin configs for
1289 102801BD (Dell Inspiron E1505n)
1290 102801EE
1291 102801EF
1292*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001293static const unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001294 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1295 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001296};
1297
1298/*
1299 STAC 9200-32 pin configs for
1300 102801F5 (Dell Inspiron 1501)
1301 102801F6
1302*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001303static const unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001304 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1305 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001306};
1307
1308/*
1309 STAC 9200-32
1310 102801CD (Dell Inspiron E1705/9400)
1311*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001312static const unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001313 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1314 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001315};
1316
Takashi Iwai2b635362011-05-02 12:33:43 +02001317static const unsigned int oqo9200_pin_configs[8] = {
Tobin Davisbf277782008-02-03 20:31:47 +01001318 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1319 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1320};
1321
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001322
Takashi Iwai2b635362011-05-02 12:33:43 +02001323static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001324 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001325 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001326 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1327 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1328 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1329 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1330 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1331 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1332 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1333 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1334 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1335 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001336 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1337 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001338 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001339};
1340
Takashi Iwaiea734962011-01-17 11:29:34 +01001341static const char * const stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001342 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001343 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001344 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001345 [STAC_9200_DELL_D21] = "dell-d21",
1346 [STAC_9200_DELL_D22] = "dell-d22",
1347 [STAC_9200_DELL_D23] = "dell-d23",
1348 [STAC_9200_DELL_M21] = "dell-m21",
1349 [STAC_9200_DELL_M22] = "dell-m22",
1350 [STAC_9200_DELL_M23] = "dell-m23",
1351 [STAC_9200_DELL_M24] = "dell-m24",
1352 [STAC_9200_DELL_M25] = "dell-m25",
1353 [STAC_9200_DELL_M26] = "dell-m26",
1354 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001355 [STAC_9200_M4] = "gateway-m4",
1356 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001357 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001358};
1359
Takashi Iwai2b635362011-05-02 12:33:43 +02001360static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001361 /* SigmaTel reference board */
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1363 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001364 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1365 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001366 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1368 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001370 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1372 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1374 "unknown Dell", STAC_9200_DELL_D22),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1376 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001378 "Dell Latitude D620", STAC_9200_DELL_M22),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1380 "unknown Dell", STAC_9200_DELL_D23),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1382 "unknown Dell", STAC_9200_DELL_D23),
1383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1384 "unknown Dell", STAC_9200_DELL_M22),
1385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1386 "unknown Dell", STAC_9200_DELL_M24),
1387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1388 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001390 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001392 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001394 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001396 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398 "Dell Precision M90", STAC_9200_DELL_M23),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1400 "unknown Dell", STAC_9200_DELL_M22),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1402 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001404 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001406 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1408 "unknown Dell", STAC_9200_DELL_D23),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1410 "unknown Dell", STAC_9200_DELL_D23),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1412 "unknown Dell", STAC_9200_DELL_D21),
1413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1414 "unknown Dell", STAC_9200_DELL_D23),
1415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1416 "unknown Dell", STAC_9200_DELL_D21),
1417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1418 "unknown Dell", STAC_9200_DELL_M25),
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1420 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001421 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001422 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1423 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1424 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001425 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001426 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001427 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001428 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1429 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1430 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001431 /* OQO Mobile */
1432 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001433 {} /* terminator */
1434};
1435
Takashi Iwai2b635362011-05-02 12:33:43 +02001436static const unsigned int ref925x_pin_configs[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001437 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001438 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001439};
1440
Takashi Iwai2b635362011-05-02 12:33:43 +02001441static const unsigned int stac925xM1_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001442 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1443 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001444};
1445
Takashi Iwai2b635362011-05-02 12:33:43 +02001446static const unsigned int stac925xM1_2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001447 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1448 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1449};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001450
Takashi Iwai2b635362011-05-02 12:33:43 +02001451static const unsigned int stac925xM2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001452 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1453 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001454};
1455
Takashi Iwai2b635362011-05-02 12:33:43 +02001456static const unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001457 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1458 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1459};
1460
Takashi Iwai2b635362011-05-02 12:33:43 +02001461static const unsigned int stac925xM3_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001462 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1463 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1464};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001465
Takashi Iwai2b635362011-05-02 12:33:43 +02001466static const unsigned int stac925xM5_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001467 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1468 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1469};
1470
Takashi Iwai2b635362011-05-02 12:33:43 +02001471static const unsigned int stac925xM6_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001472 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1473 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001474};
1475
Takashi Iwai2b635362011-05-02 12:33:43 +02001476static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001477 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001478 [STAC_M1] = stac925xM1_pin_configs,
1479 [STAC_M1_2] = stac925xM1_2_pin_configs,
1480 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001481 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001482 [STAC_M3] = stac925xM3_pin_configs,
1483 [STAC_M5] = stac925xM5_pin_configs,
1484 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001485};
1486
Takashi Iwaiea734962011-01-17 11:29:34 +01001487static const char * const stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001488 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001489 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001490 [STAC_M1] = "m1",
1491 [STAC_M1_2] = "m1-2",
1492 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001493 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001494 [STAC_M3] = "m3",
1495 [STAC_M5] = "m5",
1496 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001497};
1498
Takashi Iwai2b635362011-05-02 12:33:43 +02001499static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001500 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1501 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1502 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1503 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001504 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001505 /* Not sure about the brand name for those */
1506 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1507 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1508 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1509 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001510 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001511};
1512
Takashi Iwai2b635362011-05-02 12:33:43 +02001513static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001514 /* SigmaTel reference board */
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001516 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001517 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001518
1519 /* Default table for unknown ID */
1520 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1521
Tobin Davis8e21c342007-01-08 11:04:17 +01001522 {} /* terminator */
1523};
1524
Takashi Iwai2b635362011-05-02 12:33:43 +02001525static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001526 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1527 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1528 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001529 0x01452050,
1530};
1531
Takashi Iwai2b635362011-05-02 12:33:43 +02001532static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001533 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001534 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001535 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1536 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001537};
1538
Takashi Iwai2b635362011-05-02 12:33:43 +02001539static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001540 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1541 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1542 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1543 0x904601b0,
1544};
1545
Takashi Iwai2b635362011-05-02 12:33:43 +02001546static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001547 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001548 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001549};
1550
Takashi Iwai2b635362011-05-02 12:33:43 +02001551static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001552 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001553 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1554 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1555 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001556 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001557 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001558 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001559};
1560
Takashi Iwaiea734962011-01-17 11:29:34 +01001561static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001562 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001563 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001564 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001565 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001566 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1567 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1568 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001569 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001570 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001571};
1572
Takashi Iwai2b635362011-05-02 12:33:43 +02001573static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001574 /* SigmaTel reference board */
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001576 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001577 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1578 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001579 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1580 "Intel DG45ID", STAC_92HD73XX_INTEL),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1582 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001584 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001586 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001588 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001590 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001592 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001594 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001596 "unknown Dell", STAC_DELL_M6_DMIC),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1598 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001600 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1602 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1604 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1606 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001608 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001610 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001611 {} /* terminator */
1612};
1613
Takashi Iwai2b635362011-05-02 12:33:43 +02001614static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1616 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1618 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001620 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001621 {} /* terminator */
1622};
1623
Takashi Iwai2b635362011-05-02 12:33:43 +02001624static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001625 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1626 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001627 0x01451160, 0x98560170,
1628};
1629
Takashi Iwai2b635362011-05-02 12:33:43 +02001630static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001631 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1632 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001633 0x40f000f0, 0x40f000f0,
1634};
1635
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001636static const unsigned int dell_vostro_3500_pin_configs[10] = {
1637 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1638 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1639 0x400000f4, 0x400000f5,
1640};
1641
Takashi Iwai2b635362011-05-02 12:33:43 +02001642static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001643 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1644 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1645 0x40f000f0, 0x40f000f0,
1646};
1647
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001648static const unsigned int hp_zephyr_pin_configs[10] = {
1649 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1650 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1651 0, 0,
1652};
1653
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001654static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1655 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1656 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1657 0x40f000f0, 0x40f000f0,
1658};
1659
Takashi Iwai2b635362011-05-02 12:33:43 +02001660static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001661 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001662 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001663 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001664 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001665 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001666 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001667 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001668};
1669
Takashi Iwaiea734962011-01-17 11:29:34 +01001670static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001671 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001672 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001673 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001674 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001675 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001676 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001677 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001678 [STAC_HP_ZEPHYR] = "hp-zephyr",
Takashi Iwaia3e19972012-07-26 08:17:20 +02001679 [STAC_92HD83XXX_HP_LED] = "hp-led",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001680};
1681
Takashi Iwai2b635362011-05-02 12:33:43 +02001682static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001683 /* SigmaTel reference board */
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001685 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001686 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1687 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001688 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1689 "unknown Dell", STAC_DELL_S14),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1691 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001692 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1693 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1695 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1697 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1699 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1701 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1703 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1705 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1707 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1709 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1711 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1715 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1717 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1719 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1721 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1723 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1725 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1727 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1729 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1731 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001732 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1733 "HP", STAC_HP_ZEPHYR),
Takashi Iwaia3e19972012-07-26 08:17:20 +02001734 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
1735 "HP Mini", STAC_92HD83XXX_HP_LED),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001736 {} /* terminator */
1737};
1738
1739static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1741 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001742 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001743};
1744
Takashi Iwai2b635362011-05-02 12:33:43 +02001745static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001746 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001747 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001748 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1749 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001750};
1751
Takashi Iwai2b635362011-05-02 12:33:43 +02001752static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001753 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001754 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001755 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1756 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001757};
1758
Takashi Iwai2b635362011-05-02 12:33:43 +02001759static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001760 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1761 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001762 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1763 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001764};
1765
Takashi Iwai2b635362011-05-02 12:33:43 +02001766static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001767 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1768 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001769 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1770 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001771};
1772
Takashi Iwai2b635362011-05-02 12:33:43 +02001773static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001774 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001775 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1776 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001777 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001778 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001779 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001780 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001781 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001782 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001783};
1784
Takashi Iwaiea734962011-01-17 11:29:34 +01001785static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001786 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001787 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001788 [STAC_DELL_M4_1] = "dell-m4-1",
1789 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001790 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001791 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001792 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001793 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001794 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001795 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001796};
1797
Takashi Iwai2b635362011-05-02 12:33:43 +02001798static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001799 /* SigmaTel reference board */
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1801 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001802 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1803 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001804 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1805 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001806 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1807 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001808 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1809 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001810 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001811 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001812 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1813 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001814 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1815 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001816 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001817 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001818 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001819 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001820 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1821 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301822 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1823 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11001824 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1825 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001826 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1827 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1829 "unknown Dell", STAC_DELL_M4_1),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1831 "unknown Dell", STAC_DELL_M4_1),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1833 "unknown Dell", STAC_DELL_M4_1),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1835 "unknown Dell", STAC_DELL_M4_1),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1837 "unknown Dell", STAC_DELL_M4_1),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1839 "unknown Dell", STAC_DELL_M4_1),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1841 "unknown Dell", STAC_DELL_M4_1),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1843 "unknown Dell", STAC_DELL_M4_2),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1845 "unknown Dell", STAC_DELL_M4_2),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1847 "unknown Dell", STAC_DELL_M4_2),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1849 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1851 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001852 {} /* terminator */
1853};
1854
Takashi Iwai2b635362011-05-02 12:33:43 +02001855static const unsigned int ref922x_pin_configs[10] = {
Matt Porter403d1942005-11-29 15:00:51 +01001856 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1857 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001858 0x40000100, 0x40000100,
1859};
1860
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001861/*
1862 STAC 922X pin configs for
1863 102801A7
1864 102801AB
1865 102801A9
1866 102801D1
1867 102801D2
1868*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001869static const unsigned int dell_922x_d81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001870 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1871 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1872 0x01813122, 0x400001f2,
1873};
1874
1875/*
1876 STAC 922X pin configs for
1877 102801AC
1878 102801D0
1879*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001880static const unsigned int dell_922x_d82_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001881 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1882 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1883 0x01813122, 0x400001f1,
1884};
1885
1886/*
1887 STAC 922X pin configs for
1888 102801BF
1889*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001890static const unsigned int dell_922x_m81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001891 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1892 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1893 0x40C003f1, 0x405003f0,
1894};
1895
1896/*
1897 STAC 9221 A1 pin configs for
1898 102801D7 (Dell XPS M1210)
1899*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001900static const unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001901 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1902 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001903 0x508003f3, 0x405003f4,
1904};
1905
Takashi Iwai2b635362011-05-02 12:33:43 +02001906static const unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001907 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001908 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1909 0x02a19120, 0x40000100,
1910};
1911
Takashi Iwai2b635362011-05-02 12:33:43 +02001912static const unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001913 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1914 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001915 0x02a19320, 0x40000100,
1916};
1917
Takashi Iwai2b635362011-05-02 12:33:43 +02001918static const unsigned int intel_mac_v1_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001919 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1920 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001921 0x400000fc, 0x400000fb,
1922};
1923
Takashi Iwai2b635362011-05-02 12:33:43 +02001924static const unsigned int intel_mac_v2_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001925 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1926 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001927 0x400000fc, 0x400000fb,
1928};
1929
Takashi Iwai2b635362011-05-02 12:33:43 +02001930static const unsigned int intel_mac_v3_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001931 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1932 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1933 0x400000fc, 0x400000fb,
1934};
1935
Takashi Iwai2b635362011-05-02 12:33:43 +02001936static const unsigned int intel_mac_v4_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001937 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1938 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1939 0x400000fc, 0x400000fb,
1940};
1941
Takashi Iwai2b635362011-05-02 12:33:43 +02001942static const unsigned int intel_mac_v5_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001943 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1944 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1945 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001946};
1947
Takashi Iwai2b635362011-05-02 12:33:43 +02001948static const unsigned int ecs202_pin_configs[10] = {
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001949 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1950 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1951 0x9037012e, 0x40e000f2,
1952};
Takashi Iwai76c08822007-06-19 12:17:42 +02001953
Takashi Iwai2b635362011-05-02 12:33:43 +02001954static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001955 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001956 [STAC_D945GTP3] = d945gtp3_pin_configs,
1957 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001958 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1959 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1960 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1961 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1962 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001963 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001964 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001965 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1966 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1967 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1968 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1969 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1970 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001971 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001972 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1973 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1974 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1975 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001976};
1977
Takashi Iwaiea734962011-01-17 11:29:34 +01001978static const char * const stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001979 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001980 [STAC_D945_REF] = "ref",
1981 [STAC_D945GTP5] = "5stack",
1982 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001983 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1984 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1985 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1986 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1987 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001988 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001989 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001990 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001991 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001992 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1993 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001994 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001995 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001996 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001997 [STAC_922X_DELL_D81] = "dell-d81",
1998 [STAC_922X_DELL_D82] = "dell-d82",
1999 [STAC_922X_DELL_M81] = "dell-m81",
2000 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002001};
2002
Takashi Iwai2b635362011-05-02 12:33:43 +02002003static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002004 /* SigmaTel reference board */
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2006 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002007 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2008 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002009 /* Intel 945G based systems */
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2033 "Intel D945G", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2035 "Intel D945G", STAC_D945GTP3),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2037 "Intel D945G", STAC_D945GTP3),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2039 "Intel D945G", STAC_D945GTP3),
2040 /* Intel D945G 5-stack systems */
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2042 "Intel D945G", STAC_D945GTP5),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2044 "Intel D945G", STAC_D945GTP5),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2046 "Intel D945G", STAC_D945GTP5),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2048 "Intel D945G", STAC_D945GTP5),
2049 /* Intel 945P based systems */
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2051 "Intel D945P", STAC_D945GTP3),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2053 "Intel D945P", STAC_D945GTP3),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2055 "Intel D945P", STAC_D945GTP3),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2057 "Intel D945P", STAC_D945GTP3),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2059 "Intel D945P", STAC_D945GTP3),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2061 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002062 /* other intel */
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2064 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002065 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002066 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002067 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002068 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002069 /* Dell systems */
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2071 "unknown Dell", STAC_922X_DELL_D81),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2073 "unknown Dell", STAC_922X_DELL_D81),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2075 "unknown Dell", STAC_922X_DELL_D81),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2077 "unknown Dell", STAC_922X_DELL_D82),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2079 "unknown Dell", STAC_922X_DELL_M81),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2081 "unknown Dell", STAC_922X_DELL_D82),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2083 "unknown Dell", STAC_922X_DELL_D81),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2085 "unknown Dell", STAC_922X_DELL_D81),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2087 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002088 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002089 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002090 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002091 {} /* terminator */
2092};
2093
Takashi Iwai2b635362011-05-02 12:33:43 +02002094static const unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002095 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2096 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2097 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2098 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002099};
2100
Takashi Iwai2b635362011-05-02 12:33:43 +02002101static const unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002102 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2103 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2104 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2105 0x40000100, 0x40000100
2106};
2107
Takashi Iwai2b635362011-05-02 12:33:43 +02002108static const unsigned int d965_5st_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002109 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2110 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2111 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2112 0x40000100, 0x40000100
2113};
2114
Takashi Iwai2b635362011-05-02 12:33:43 +02002115static const unsigned int d965_5st_no_fp_pin_configs[14] = {
Takashi Iwai679d92e2009-05-24 19:00:08 +02002116 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2117 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2118 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2119 0x40000100, 0x40000100
2120};
2121
Takashi Iwai2b635362011-05-02 12:33:43 +02002122static const unsigned int dell_3st_pin_configs[14] = {
Tobin Davis4ff076e2007-08-07 11:48:12 +02002123 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2124 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002125 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002126 0x40c003fc, 0x40000100
2127};
2128
Takashi Iwai2b635362011-05-02 12:33:43 +02002129static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002130 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002131 [STAC_D965_REF] = ref927x_pin_configs,
2132 [STAC_D965_3ST] = d965_3st_pin_configs,
2133 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002134 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002135 [STAC_DELL_3ST] = dell_3st_pin_configs,
2136 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002137 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002138};
2139
Takashi Iwaiea734962011-01-17 11:29:34 +01002140static const char * const stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002141 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002142 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002143 [STAC_D965_REF] = "ref",
2144 [STAC_D965_3ST] = "3stack",
2145 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002146 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002147 [STAC_DELL_3ST] = "dell-3stack",
2148 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002149 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002150};
2151
Takashi Iwai2b635362011-05-02 12:33:43 +02002152static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002153 /* SigmaTel reference board */
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2155 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002156 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2157 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002158 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002161 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002162 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2163 "Intel D965", STAC_D965_3ST),
2164 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2165 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002166 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002170 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002180 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002181 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2182 "Intel D965", STAC_D965_5ST),
2183 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2184 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002185 /* volume-knob fixes */
2186 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002187 {} /* terminator */
2188};
2189
Takashi Iwai2b635362011-05-02 12:33:43 +02002190static const unsigned int ref9205_pin_configs[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +02002191 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002192 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002193 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002194};
2195
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002196/*
2197 STAC 9205 pin configs for
2198 102801F1
2199 102801F2
2200 102801FC
2201 102801FD
2202 10280204
2203 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002204 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002205 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002206*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002207static const unsigned int dell_9205_m42_pin_configs[12] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002208 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2209 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2210 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2211};
2212
2213/*
2214 STAC 9205 pin configs for
2215 102801F9
2216 102801FA
2217 102801FE
2218 102801FF (Dell Precision M4300)
2219 10280206
2220 10280200
2221 10280201
2222*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002223static const unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002224 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2225 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2226 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2227};
2228
Takashi Iwai2b635362011-05-02 12:33:43 +02002229static const unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002230 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2231 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2232 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2233};
2234
Takashi Iwai2b635362011-05-02 12:33:43 +02002235static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002236 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002237 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2238 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2239 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002240 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002241};
2242
Takashi Iwaiea734962011-01-17 11:29:34 +01002243static const char * const stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002244 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002245 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002246 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002247 [STAC_9205_DELL_M43] = "dell-m43",
2248 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002249 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002250};
2251
Takashi Iwai2b635362011-05-02 12:33:43 +02002252static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002253 /* SigmaTel reference board */
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2255 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002256 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2257 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002258 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2259 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002260 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2262 "unknown Dell", STAC_9205_DELL_M42),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2264 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002266 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2268 "Dell Precision", STAC_9205_DELL_M43),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2270 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2272 "unknown Dell", STAC_9205_DELL_M42),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2274 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2276 "Dell Precision", STAC_9205_DELL_M43),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002278 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2280 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2282 "Dell Precision", STAC_9205_DELL_M43),
2283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2284 "Dell Precision", STAC_9205_DELL_M43),
2285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2286 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2288 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2290 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2292 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002293 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002294 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002295 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002296 {} /* terminator */
2297};
2298
Takashi Iwai330ee992009-02-20 14:33:36 +01002299static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002300 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002301{
2302 int i;
2303 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002304
Takashi Iwai330ee992009-02-20 14:33:36 +01002305 if (!pincfgs)
2306 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002307
Matthew Ranostay87d48362007-07-17 11:52:24 +02002308 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002309 if (spec->pin_nids[i] && pincfgs[i])
2310 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2311 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002312}
2313
Matt2f2f4252005-04-13 14:45:30 +02002314/*
2315 * Analog playback callbacks
2316 */
2317static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2318 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002319 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002320{
2321 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002322 if (spec->stream_delay)
2323 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002324 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2325 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002326}
2327
2328static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2329 struct hda_codec *codec,
2330 unsigned int stream_tag,
2331 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002332 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002333{
2334 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002335 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002336}
2337
2338static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2339 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002340 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002341{
2342 struct sigmatel_spec *spec = codec->spec;
2343 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2344}
2345
2346/*
Mattdabbed62005-06-14 10:19:34 +02002347 * Digital playback callbacks
2348 */
2349static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2350 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002351 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002352{
2353 struct sigmatel_spec *spec = codec->spec;
2354 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2355}
2356
2357static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2358 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002359 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002360{
2361 struct sigmatel_spec *spec = codec->spec;
2362 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2363}
2364
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002365static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2366 struct hda_codec *codec,
2367 unsigned int stream_tag,
2368 unsigned int format,
2369 struct snd_pcm_substream *substream)
2370{
2371 struct sigmatel_spec *spec = codec->spec;
2372 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2373 stream_tag, format, substream);
2374}
2375
Takashi Iwai9411e212009-02-13 11:32:28 +01002376static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2377 struct hda_codec *codec,
2378 struct snd_pcm_substream *substream)
2379{
2380 struct sigmatel_spec *spec = codec->spec;
2381 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2382}
2383
Mattdabbed62005-06-14 10:19:34 +02002384
2385/*
Matt2f2f4252005-04-13 14:45:30 +02002386 * Analog capture callbacks
2387 */
2388static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2389 struct hda_codec *codec,
2390 unsigned int stream_tag,
2391 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002392 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002393{
2394 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002395 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002396
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002397 if (spec->powerdown_adcs) {
2398 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002399 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002400 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2401 }
2402 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002403 return 0;
2404}
2405
2406static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2407 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002408 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002409{
2410 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002411 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002412
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002413 snd_hda_codec_cleanup_stream(codec, nid);
2414 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002415 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002416 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002417 return 0;
2418}
2419
Takashi Iwai2b635362011-05-02 12:33:43 +02002420static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02002421 .substreams = 1,
2422 .channels_min = 2,
2423 .channels_max = 2,
2424 /* NID is set in stac92xx_build_pcms */
2425 .ops = {
2426 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002427 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002428 .prepare = stac92xx_dig_playback_pcm_prepare,
2429 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002430 },
2431};
2432
Takashi Iwai2b635362011-05-02 12:33:43 +02002433static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02002434 .substreams = 1,
2435 .channels_min = 2,
2436 .channels_max = 2,
2437 /* NID is set in stac92xx_build_pcms */
2438};
2439
Takashi Iwai2b635362011-05-02 12:33:43 +02002440static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02002441 .substreams = 1,
2442 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002443 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002444 .nid = 0x02, /* NID to query formats and rates */
2445 .ops = {
2446 .open = stac92xx_playback_pcm_open,
2447 .prepare = stac92xx_playback_pcm_prepare,
2448 .cleanup = stac92xx_playback_pcm_cleanup
2449 },
2450};
2451
Takashi Iwai2b635362011-05-02 12:33:43 +02002452static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002453 .substreams = 1,
2454 .channels_min = 2,
2455 .channels_max = 2,
2456 .nid = 0x06, /* NID to query formats and rates */
2457 .ops = {
2458 .open = stac92xx_playback_pcm_open,
2459 .prepare = stac92xx_playback_pcm_prepare,
2460 .cleanup = stac92xx_playback_pcm_cleanup
2461 },
2462};
2463
Takashi Iwai2b635362011-05-02 12:33:43 +02002464static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002465 .channels_min = 2,
2466 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002467 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002468 .ops = {
2469 .prepare = stac92xx_capture_pcm_prepare,
2470 .cleanup = stac92xx_capture_pcm_cleanup
2471 },
2472};
2473
2474static int stac92xx_build_pcms(struct hda_codec *codec)
2475{
2476 struct sigmatel_spec *spec = codec->spec;
2477 struct hda_pcm *info = spec->pcm_rec;
2478
2479 codec->num_pcms = 1;
2480 codec->pcm_info = info;
2481
Mattc7d4b2f2005-06-27 14:59:41 +02002482 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002483 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002484 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2485 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002486 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002487 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002488 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002489
2490 if (spec->alt_switch) {
2491 codec->num_pcms++;
2492 info++;
2493 info->name = "STAC92xx Analog Alt";
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2495 }
Matt2f2f4252005-04-13 14:45:30 +02002496
Mattdabbed62005-06-14 10:19:34 +02002497 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2498 codec->num_pcms++;
2499 info++;
2500 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002501 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002502 if (spec->multiout.dig_out_nid) {
2503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2505 }
2506 if (spec->dig_in_nid) {
2507 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2508 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2509 }
2510 }
2511
Matt2f2f4252005-04-13 14:45:30 +02002512 return 0;
2513}
2514
Matt Porter403d1942005-11-29 15:00:51 +01002515static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2516
2517{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02002518 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002519}
2520
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002521#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2522
2523static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2524 struct snd_ctl_elem_value *ucontrol)
2525{
2526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2527 struct sigmatel_spec *spec = codec->spec;
2528
Takashi Iwaid7a89432008-11-12 09:48:04 +01002529 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002530 return 0;
2531}
2532
Takashi Iwai62558ce2009-07-29 14:23:09 +02002533static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002534
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002535static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2536 struct snd_ctl_elem_value *ucontrol)
2537{
2538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2539 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002540 int nid = kcontrol->private_value;
2541
2542 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002543
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002544 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002545 * switch changes
2546 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002547 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002548
2549 return 1;
2550}
2551
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002552static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2553 struct snd_ctl_elem_info *uinfo)
2554{
2555 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02002556 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002557 "Mic In", "Line In", "Line Out"
2558 };
2559
2560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2561 struct sigmatel_spec *spec = codec->spec;
2562 hda_nid_t nid = kcontrol->private_value;
2563
2564 if (nid == spec->mic_switch || nid == spec->line_switch)
2565 i = 3;
2566 else
2567 i = 2;
2568
2569 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2570 uinfo->value.enumerated.items = i;
2571 uinfo->count = 1;
2572 if (uinfo->value.enumerated.item >= i)
2573 uinfo->value.enumerated.item = i-1;
2574 strcpy(uinfo->value.enumerated.name,
2575 texts[uinfo->value.enumerated.item]);
2576
2577 return 0;
2578}
2579
2580static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2581 struct snd_ctl_elem_value *ucontrol)
2582{
2583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2584 hda_nid_t nid = kcontrol->private_value;
2585 unsigned int vref = stac92xx_vref_get(codec, nid);
2586
Takashi Iwai47408602012-04-20 13:06:53 +02002587 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002588 ucontrol->value.enumerated.item[0] = 0;
2589 else if (vref == AC_PINCTL_VREF_GRD)
2590 ucontrol->value.enumerated.item[0] = 1;
2591 else if (vref == AC_PINCTL_VREF_HIZ)
2592 ucontrol->value.enumerated.item[0] = 2;
2593
2594 return 0;
2595}
2596
2597static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2598 struct snd_ctl_elem_value *ucontrol)
2599{
2600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2601 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002602 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002603 hda_nid_t nid = kcontrol->private_value;
2604
2605 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02002606 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002607 else if (ucontrol->value.enumerated.item[0] == 1)
2608 new_vref = AC_PINCTL_VREF_GRD;
2609 else if (ucontrol->value.enumerated.item[0] == 2)
2610 new_vref = AC_PINCTL_VREF_HIZ;
2611 else
2612 return 0;
2613
2614 if (new_vref != stac92xx_vref_get(codec, nid)) {
2615 error = stac92xx_vref_set(codec, nid, new_vref);
2616 return error;
2617 }
2618
2619 return 0;
2620}
2621
2622static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2623 struct snd_ctl_elem_info *uinfo)
2624{
Takashi Iwai2b635362011-05-02 12:33:43 +02002625 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2627 struct sigmatel_spec *spec = codec->spec;
2628
2629 if (kcontrol->private_value == spec->line_switch)
2630 texts[0] = "Line In";
2631 else
2632 texts[0] = "Mic In";
2633 texts[1] = "Line Out";
2634 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2635 uinfo->value.enumerated.items = 2;
2636 uinfo->count = 1;
2637
2638 if (uinfo->value.enumerated.item >= 2)
2639 uinfo->value.enumerated.item = 1;
2640 strcpy(uinfo->value.enumerated.name,
2641 texts[uinfo->value.enumerated.item]);
2642
2643 return 0;
2644}
Matt Porter403d1942005-11-29 15:00:51 +01002645
2646static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2647{
2648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2649 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002650 hda_nid_t nid = kcontrol->private_value;
2651 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002652
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002653 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002654 return 0;
2655}
2656
2657static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2658{
2659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2660 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002661 hda_nid_t nid = kcontrol->private_value;
2662 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2663 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002664
2665 spec->io_switch[io_idx] = val;
2666
2667 if (val)
2668 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002669 else {
2670 unsigned int pinctl = AC_PINCTL_IN_EN;
2671 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02002672 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002673 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2674 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002675
2676 /* check the auto-mute again: we need to mute/unmute the speaker
2677 * appropriately according to the pin direction
2678 */
2679 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002680 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002681
Matt Porter403d1942005-11-29 15:00:51 +01002682 return 1;
2683}
2684
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002685#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2686
2687static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2688 struct snd_ctl_elem_value *ucontrol)
2689{
2690 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2691 struct sigmatel_spec *spec = codec->spec;
2692
2693 ucontrol->value.integer.value[0] = spec->clfe_swap;
2694 return 0;
2695}
2696
2697static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2698 struct snd_ctl_elem_value *ucontrol)
2699{
2700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2701 struct sigmatel_spec *spec = codec->spec;
2702 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002703 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002704
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002705 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002706 return 0;
2707
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002708 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002709
2710 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2711 spec->clfe_swap ? 0x4 : 0x0);
2712
2713 return 1;
2714}
2715
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002716#define STAC_CODEC_HP_SWITCH(xname) \
2717 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2718 .name = xname, \
2719 .index = 0, \
2720 .info = stac92xx_hp_switch_info, \
2721 .get = stac92xx_hp_switch_get, \
2722 .put = stac92xx_hp_switch_put, \
2723 }
2724
Matt Porter403d1942005-11-29 15:00:51 +01002725#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2726 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2727 .name = xname, \
2728 .index = 0, \
2729 .info = stac92xx_io_switch_info, \
2730 .get = stac92xx_io_switch_get, \
2731 .put = stac92xx_io_switch_put, \
2732 .private_value = xpval, \
2733 }
2734
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002735#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2737 .name = xname, \
2738 .index = 0, \
2739 .info = stac92xx_clfe_switch_info, \
2740 .get = stac92xx_clfe_switch_get, \
2741 .put = stac92xx_clfe_switch_put, \
2742 .private_value = xpval, \
2743 }
Matt Porter403d1942005-11-29 15:00:51 +01002744
Mattc7d4b2f2005-06-27 14:59:41 +02002745enum {
2746 STAC_CTL_WIDGET_VOL,
2747 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002748 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002749 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002750 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002751 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002752 STAC_CTL_WIDGET_CLFE_SWITCH,
2753 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002754};
2755
Takashi Iwai2b635362011-05-02 12:33:43 +02002756static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002757 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2758 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002759 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002760 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002761 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002762 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002763 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002764 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002765};
2766
2767/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002768static struct snd_kcontrol_new *
2769stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002770 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002771 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002772 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002773{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002774 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002775
Takashi Iwai603c4012008-07-30 15:01:44 +02002776 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2777 knew = snd_array_new(&spec->kctls);
2778 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002779 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002780 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002781 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002782 if (!knew->name) {
2783 /* roolback */
2784 memset(knew, 0, sizeof(*knew));
2785 spec->kctls.alloced--;
2786 return NULL;
2787 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002788 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002789 return knew;
2790}
2791
2792static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002793 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01002794 int idx, const char *name,
2795 unsigned long val)
2796{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002797 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002798 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002799 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002800 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002801 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002802 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002803 return 0;
2804}
2805
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002806static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2807 int type, int idx, const char *name,
2808 unsigned long val)
2809{
2810 return stac92xx_add_control_temp(spec,
2811 &stac92xx_control_templates[type],
2812 idx, name, val);
2813}
2814
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002815
2816/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002817static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2818 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002819{
2820 return stac92xx_add_control_idx(spec, type, 0, name, val);
2821}
2822
Takashi Iwai2b635362011-05-02 12:33:43 +02002823static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01002824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2825 .name = "Input Source",
2826 .info = stac92xx_mux_enum_info,
2827 .get = stac92xx_mux_enum_get,
2828 .put = stac92xx_mux_enum_put,
2829};
2830
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002831static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2832 hda_nid_t nid, int idx)
2833{
2834 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2835 int control = 0;
2836 struct sigmatel_spec *spec = codec->spec;
2837 char name[22];
2838
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002839 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwai47408602012-04-20 13:06:53 +02002840 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002841 && nid == spec->line_switch)
2842 control = STAC_CTL_WIDGET_IO_SWITCH;
2843 else if (snd_hda_query_pin_caps(codec, nid)
2844 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2845 control = STAC_CTL_WIDGET_DC_BIAS;
2846 else if (nid == spec->mic_switch)
2847 control = STAC_CTL_WIDGET_IO_SWITCH;
2848 }
2849
2850 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01002851 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
2852 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002853 return stac92xx_add_control(codec->spec, control,
2854 strcat(name, " Jack Mode"), nid);
2855 }
2856
2857 return 0;
2858}
2859
Takashi Iwaie3c75962009-01-23 11:57:22 +01002860static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2861{
2862 struct snd_kcontrol_new *knew;
2863 struct hda_input_mux *imux = &spec->private_imux;
2864
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002865 if (spec->auto_mic)
2866 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002867 if (!spec->num_adcs || imux->num_items <= 1)
2868 return 0; /* no need for input source control */
2869 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002870 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002871 if (!knew)
2872 return -ENOMEM;
2873 knew->count = spec->num_adcs;
2874 return 0;
2875}
2876
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002877/* check whether the line-input can be used as line-out */
2878static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002879{
2880 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002881 struct auto_pin_cfg *cfg = &spec->autocfg;
2882 hda_nid_t nid;
2883 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002884 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002885
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002886 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2887 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002888 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02002889 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002890 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01002891 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002892 if (pincap & AC_PINCAP_OUT)
2893 return nid;
2894 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002895 }
Matt Porter403d1942005-11-29 15:00:51 +01002896 return 0;
2897}
2898
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002899static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2900
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002901/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002902static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002903{
2904 struct sigmatel_spec *spec = codec->spec;
2905 struct auto_pin_cfg *cfg = &spec->autocfg;
2906 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02002907 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002908
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002909 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002910 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2911 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002912 for (i = 0; i < cfg->num_inputs; i++) {
2913 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02002914 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002915 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002916 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2917 /* some laptops have an internal analog microphone
2918 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002919 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002920 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002921 if (pincap & AC_PINCAP_OUT) {
2922 *dac = get_unassigned_dac(codec, nid);
2923 if (*dac)
2924 return nid;
2925 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002926 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002927 }
2928 return 0;
2929}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002930
2931static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2932{
2933 int i;
2934
2935 for (i = 0; i < spec->multiout.num_dacs; i++) {
2936 if (spec->multiout.dac_nids[i] == nid)
2937 return 1;
2938 }
2939
2940 return 0;
2941}
2942
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002943static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2944{
2945 int i;
2946 if (is_in_dac_nids(spec, nid))
2947 return 1;
2948 for (i = 0; i < spec->autocfg.hp_outs; i++)
2949 if (spec->hp_dacs[i] == nid)
2950 return 1;
2951 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2952 if (spec->speaker_dacs[i] == nid)
2953 return 1;
2954 return 0;
2955}
2956
2957static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2958{
2959 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02002960 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002961 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02002962 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002963 unsigned int wcaps, wtype;
2964
2965 conn_len = snd_hda_get_connections(codec, nid, conn,
2966 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002967 /* 92HD88: trace back up the link of nids to find the DAC */
2968 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2969 != AC_WID_AUD_OUT)) {
2970 nid = conn[0];
2971 conn_len = snd_hda_get_connections(codec, nid, conn,
2972 HDA_MAX_CONNECTIONS);
2973 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002974 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002975 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002976 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002977 /* we check only analog outputs */
2978 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2979 continue;
2980 /* if this route has a free DAC, assign it */
2981 if (!check_all_dac_nids(spec, conn[j])) {
2982 if (conn_len > 1) {
2983 /* select this DAC in the pin's input mux */
2984 snd_hda_codec_write_cache(codec, nid, 0,
2985 AC_VERB_SET_CONNECT_SEL, j);
2986 }
2987 return conn[j];
2988 }
2989 }
David Henningsson48718ea2011-10-05 09:49:05 +02002990
2991 /* if all DACs are already assigned, connect to the primary DAC,
2992 unless we're assigning a secondary headphone */
2993 fallback_dac = spec->multiout.dac_nids[0];
2994 if (spec->multiout.hp_nid) {
2995 for (j = 0; j < cfg->hp_outs; j++)
2996 if (cfg->hp_pins[j] == nid) {
2997 fallback_dac = spec->multiout.hp_nid;
2998 break;
2999 }
3000 }
3001
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003002 if (conn_len > 1) {
3003 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02003004 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01003005 snd_hda_codec_write_cache(codec, nid, 0,
3006 AC_VERB_SET_CONNECT_SEL, j);
3007 break;
3008 }
3009 }
3010 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003011 return 0;
3012}
3013
3014static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3015static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3016
Matt Porter3cc08dc2006-01-23 15:27:49 +01003017/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003018 * Fill in the dac_nids table from the parsed pin configuration
3019 * This function only works when every pin in line_out_pins[]
3020 * contains atleast one DAC in its connection list. Some 92xx
3021 * codecs are not connected directly to a DAC, such as the 9200
3022 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003023 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003024static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003025{
3026 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003027 struct auto_pin_cfg *cfg = &spec->autocfg;
3028 int i;
3029 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003030
Mattc7d4b2f2005-06-27 14:59:41 +02003031 for (i = 0; i < cfg->line_outs; i++) {
3032 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003033 dac = get_unassigned_dac(codec, nid);
3034 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003035 if (spec->multiout.num_dacs > 0) {
3036 /* we have already working output pins,
3037 * so let's drop the broken ones again
3038 */
3039 cfg->line_outs = spec->multiout.num_dacs;
3040 break;
3041 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003042 /* error out, no available DAC found */
3043 snd_printk(KERN_ERR
3044 "%s: No available DAC for pin 0x%x\n",
3045 __func__, nid);
3046 return -ENODEV;
3047 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003048 add_spec_dacs(spec, dac);
3049 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003050
Takashi Iwai139e0712009-03-06 12:10:41 +01003051 for (i = 0; i < cfg->hp_outs; i++) {
3052 nid = cfg->hp_pins[i];
3053 dac = get_unassigned_dac(codec, nid);
3054 if (dac) {
3055 if (!spec->multiout.hp_nid)
3056 spec->multiout.hp_nid = dac;
3057 else
3058 add_spec_extra_dacs(spec, dac);
3059 }
3060 spec->hp_dacs[i] = dac;
3061 }
3062
3063 for (i = 0; i < cfg->speaker_outs; i++) {
3064 nid = cfg->speaker_pins[i];
3065 dac = get_unassigned_dac(codec, nid);
3066 if (dac)
3067 add_spec_extra_dacs(spec, dac);
3068 spec->speaker_dacs[i] = dac;
3069 }
3070
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003071 /* add line-in as output */
3072 nid = check_line_out_switch(codec);
3073 if (nid) {
3074 dac = get_unassigned_dac(codec, nid);
3075 if (dac) {
3076 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3077 nid, cfg->line_outs);
3078 cfg->line_out_pins[cfg->line_outs] = nid;
3079 cfg->line_outs++;
3080 spec->line_switch = nid;
3081 add_spec_dacs(spec, dac);
3082 }
3083 }
3084 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003085 nid = check_mic_out_switch(codec, &dac);
3086 if (nid && dac) {
3087 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3088 nid, cfg->line_outs);
3089 cfg->line_out_pins[cfg->line_outs] = nid;
3090 cfg->line_outs++;
3091 spec->mic_switch = nid;
3092 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003093 }
3094
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003095 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003096 spec->multiout.num_dacs,
3097 spec->multiout.dac_nids[0],
3098 spec->multiout.dac_nids[1],
3099 spec->multiout.dac_nids[2],
3100 spec->multiout.dac_nids[3],
3101 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003102
Mattc7d4b2f2005-06-27 14:59:41 +02003103 return 0;
3104}
3105
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003106/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003107static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3108 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003109{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003110 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003111 char name[32];
3112 int err;
3113
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003114 if (!spec->check_volume_offset) {
3115 unsigned int caps, step, nums, db_scale;
3116 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3117 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3118 AC_AMPCAP_STEP_SIZE_SHIFT;
3119 step = (step + 1) * 25; /* in .01dB unit */
3120 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3121 AC_AMPCAP_NUM_STEPS_SHIFT;
3122 db_scale = nums * step;
3123 /* if dB scale is over -64dB, and finer enough,
3124 * let's reduce it to half
3125 */
3126 if (db_scale > 6400 && nums >= 0x1f)
3127 spec->volume_offset = nums / 2;
3128 spec->check_volume_offset = 1;
3129 }
3130
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003131 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003132 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003133 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3134 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003135 if (err < 0)
3136 return err;
3137 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003138 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003139 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3140 if (err < 0)
3141 return err;
3142 return 0;
3143}
3144
Takashi Iwai668b9652009-03-06 10:13:24 +01003145#define create_controls(codec, pfx, nid, chs) \
3146 create_controls_idx(codec, pfx, 0, nid, chs)
3147
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003148static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3149{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003150 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003151 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3152 return 1;
3153 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003154 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3155 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003156 spec->multiout.num_dacs++;
3157 }
3158 return 0;
3159}
3160
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003161static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003162{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003163 int i;
3164 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3165 if (!spec->multiout.extra_out_nid[i]) {
3166 spec->multiout.extra_out_nid[i] = nid;
3167 return 0;
3168 }
3169 }
3170 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3171 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003172}
3173
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003174/* Create output controls
3175 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3176 */
3177static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3178 const hda_nid_t *pins,
3179 const hda_nid_t *dac_nids,
3180 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003181{
Takashi Iwai76624532008-12-19 10:09:47 +01003182 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003183 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003184 "Front", "Surround", NULL /*CLFE*/, "Side"
3185 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003186 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003187 int i, err;
3188 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003189
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003190 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003191 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003192 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003193 spec->hp_detect = 1;
3194 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003195 nid = dac_nids[i];
3196 if (!nid)
3197 continue;
3198 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003199 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003200 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003201 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003202 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003203 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003204 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003205 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003206
3207 wid_caps = get_wcaps(codec, nid);
3208
3209 if (wid_caps & AC_WCAP_LR_SWAP) {
3210 err = stac92xx_add_control(spec,
3211 STAC_CTL_WIDGET_CLFE_SWITCH,
3212 "Swap Center/LFE Playback Switch", nid);
3213
3214 if (err < 0)
3215 return err;
3216 }
3217
Mattc7d4b2f2005-06-27 14:59:41 +02003218 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003219 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003220 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003221 switch (type) {
3222 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003223 name = "Headphone";
3224 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003225 break;
3226 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003227 name = "Speaker";
3228 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003229 break;
3230 default:
3231 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003232 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003233 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003234 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003235 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003236 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003237 return err;
3238 }
3239 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003240 return 0;
3241}
3242
Takashi Iwai6479c632009-07-28 18:20:25 +02003243static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3244 unsigned long sw, int idx)
3245{
3246 int err;
3247 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003248 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003249 if (err < 0)
3250 return err;
3251 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003252 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003253 if (err < 0)
3254 return err;
3255 return 0;
3256}
3257
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003258/* add playback controls from the parsed DAC table */
3259static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3260 const struct auto_pin_cfg *cfg)
3261{
3262 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003263 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003264 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003265 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003266
3267 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3268 spec->multiout.dac_nids,
3269 cfg->line_out_type);
3270 if (err < 0)
3271 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003272
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003273 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003274 err = stac92xx_add_control(spec,
3275 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003276 "Headphone as Line Out Switch",
3277 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003278 if (err < 0)
3279 return err;
3280 }
3281
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003282 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003283 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003284 break;
3285 nid = cfg->inputs[idx].pin;
3286 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3287 if (err < 0)
3288 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003289 }
Matt Porter403d1942005-11-29 15:00:51 +01003290
Mattc7d4b2f2005-06-27 14:59:41 +02003291 return 0;
3292}
3293
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003294/* add playback controls for Speaker and HP outputs */
3295static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3296 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003297{
3298 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003299 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003300
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003301 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3302 spec->hp_dacs, AUTO_PIN_HP_OUT);
3303 if (err < 0)
3304 return err;
3305
3306 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3307 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3308 if (err < 0)
3309 return err;
3310
Mattc7d4b2f2005-06-27 14:59:41 +02003311 return 0;
3312}
3313
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003314/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003315static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003316 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003317};
3318
3319/* create mono mux for mono out on capable codecs */
3320static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3321{
3322 struct sigmatel_spec *spec = codec->spec;
3323 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3324 int i, num_cons;
3325 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3326
3327 num_cons = snd_hda_get_connections(codec,
3328 spec->mono_nid,
3329 con_lst,
3330 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003331 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003332 return -EINVAL;
3333
Takashi Iwai10a20af2010-09-09 16:28:02 +02003334 for (i = 0; i < num_cons; i++)
3335 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3336 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003337
3338 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3339 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003340}
3341
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003342/* create PC beep volume controls */
3343static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3344 hda_nid_t nid)
3345{
3346 struct sigmatel_spec *spec = codec->spec;
3347 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003348 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3349
3350 if (spec->anabeep_nid == nid)
3351 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003352
3353 /* check for mute support for the the amp */
3354 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003355 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003356 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003357 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3358 if (err < 0)
3359 return err;
3360 }
3361
3362 /* check to see if there is volume support for the amp */
3363 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3364 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003365 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003366 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3367 if (err < 0)
3368 return err;
3369 }
3370 return 0;
3371}
3372
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003373#ifdef CONFIG_SND_HDA_INPUT_BEEP
3374#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3375
3376static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3377 struct snd_ctl_elem_value *ucontrol)
3378{
3379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3380 ucontrol->value.integer.value[0] = codec->beep->enabled;
3381 return 0;
3382}
3383
3384static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3385 struct snd_ctl_elem_value *ucontrol)
3386{
3387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003388 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003389}
3390
Takashi Iwai2b635362011-05-02 12:33:43 +02003391static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3393 .info = stac92xx_dig_beep_switch_info,
3394 .get = stac92xx_dig_beep_switch_get,
3395 .put = stac92xx_dig_beep_switch_put,
3396};
3397
3398static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3399{
3400 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003401 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003402}
3403#endif
3404
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003405static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3406{
3407 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003408 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003409
3410 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003411 hda_nid_t nid;
3412 unsigned int wcaps;
3413 unsigned long val;
3414
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003415 nid = spec->mux_nids[i];
3416 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003417 if (!(wcaps & AC_WCAP_OUT_AMP))
3418 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003419
Takashi Iwai667067d2009-08-13 18:14:42 +02003420 /* check whether already the same control was created as
3421 * normal Capture Volume.
3422 */
3423 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3424 for (j = 0; j < spec->num_caps; j++) {
3425 if (spec->capvols[j] == val)
3426 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003427 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003428 if (j < spec->num_caps)
3429 continue;
3430
3431 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3432 "Mux Capture Volume", val);
3433 if (err < 0)
3434 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003435 }
3436 return 0;
3437};
3438
Takashi Iwaiea734962011-01-17 11:29:34 +01003439static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003440 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003441};
3442
3443static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3444{
3445 struct sigmatel_spec *spec = codec->spec;
3446 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01003447 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003448 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003449 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003450
3451 num_cons = snd_hda_get_connections(codec,
3452 spec->smux_nids[0],
3453 con_lst,
3454 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003455 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003456 return -EINVAL;
3457
Matthew Ranostay65973632008-09-16 10:39:37 -04003458 if (!labels)
3459 labels = stac92xx_spdif_labels;
3460
Takashi Iwai10a20af2010-09-09 16:28:02 +02003461 for (i = 0; i < num_cons; i++)
3462 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02003463
3464 return 0;
3465}
3466
Matt Porter8b657272006-10-26 17:12:59 +02003467/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003468static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003469 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3470 "Digital Mic 3", "Digital Mic 4"
3471};
3472
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003473static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3474 int idx)
3475{
3476 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3477 int nums;
3478 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3479 if (idx >= 0 && idx < nums)
3480 return conn[idx];
3481 return 0;
3482}
3483
Takashi Iwai8d087c72011-06-28 12:45:47 +02003484/* look for NID recursively */
3485#define get_connection_index(codec, mux, nid) \
3486 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003487
Takashi Iwai667067d2009-08-13 18:14:42 +02003488/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003489/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003490static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003491 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003492{
3493 unsigned int caps, nums;
3494 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003495 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003496
Takashi Iwai96f845d2009-08-29 00:49:36 +02003497 if (direction == HDA_OUTPUT)
3498 caps = AC_WCAP_OUT_AMP;
3499 else
3500 caps = AC_WCAP_IN_AMP;
3501 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003502 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003503 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003504 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3505 if (!nums)
3506 return 0;
3507 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003508 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3509 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02003510 if (err < 0)
3511 return err;
3512 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003513}
3514
Matt Porter8b657272006-10-26 17:12:59 +02003515/* create playback/capture controls for input pins on dmic capable codecs */
3516static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3517 const struct auto_pin_cfg *cfg)
3518{
3519 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003520 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003521 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003522 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02003523 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003524
Takashi Iwai10a20af2010-09-09 16:28:02 +02003525 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02003526
Matt Porter8b657272006-10-26 17:12:59 +02003527 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003528 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003529 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01003530 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02003531
Takashi Iwai667067d2009-08-13 18:14:42 +02003532 nid = spec->dmic_nids[i];
3533 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3534 continue;
3535 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003536 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3537 continue;
3538
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003539 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3540 if (index < 0)
3541 continue;
3542
Takashi Iwai201e06f2011-11-16 15:33:26 +01003543 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3544 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02003545 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01003546 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3547 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02003548
Takashi Iwai10a20af2010-09-09 16:28:02 +02003549 err = create_elem_capture_vol(codec, nid, label, type_idx,
3550 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003551 if (err < 0)
3552 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003553 if (!err) {
3554 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02003555 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003556 if (err < 0)
3557 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003558 if (!err) {
3559 nid = get_connected_node(codec,
3560 spec->dmux_nids[0], index);
3561 if (nid)
3562 err = create_elem_capture_vol(codec,
3563 nid, label,
3564 type_idx, HDA_INPUT);
3565 if (err < 0)
3566 return err;
3567 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02003568 }
Matt Porter8b657272006-10-26 17:12:59 +02003569 }
3570
3571 return 0;
3572}
3573
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003574static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02003575 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003576{
3577 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003578 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003579
3580 if (!nid)
3581 return 0;
3582 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003583 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003584 switch (snd_hda_get_input_pin_attr(cfg)) {
3585 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003586 if (*fixed)
3587 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003588 if (type != AC_JACK_MIC_IN)
3589 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003590 *fixed = nid;
3591 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003592 case INPUT_PIN_ATTR_UNUSED:
3593 break;
3594 case INPUT_PIN_ATTR_DOCK:
3595 if (*dock)
3596 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003597 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3598 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003599 *dock = nid;
3600 break;
3601 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003602 if (*ext)
3603 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003604 if (type != AC_JACK_MIC_IN)
3605 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003606 *ext = nid;
3607 break;
3608 }
3609 return 0;
3610}
3611
3612static int set_mic_route(struct hda_codec *codec,
3613 struct sigmatel_mic_route *mic,
3614 hda_nid_t pin)
3615{
3616 struct sigmatel_spec *spec = codec->spec;
3617 struct auto_pin_cfg *cfg = &spec->autocfg;
3618 int i;
3619
3620 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02003621 if (pin == 0)
3622 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003623 for (i = 0; i < cfg->num_inputs; i++) {
3624 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003625 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003626 }
Takashi Iwai86e29592010-09-09 14:50:17 +02003627 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003628 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003629 i = get_connection_index(codec, spec->mux_nids[0], pin);
3630 if (i < 0)
3631 return -1;
3632 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003633 mic->dmux_idx = -1;
3634 if (spec->dmux_nids)
3635 mic->dmux_idx = get_connection_index(codec,
3636 spec->dmux_nids[0],
3637 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003638 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003639 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003640 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3641 if (i < 0)
3642 return -1;
3643 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003644 mic->mux_idx = -1;
3645 if (spec->mux_nids)
3646 mic->mux_idx = get_connection_index(codec,
3647 spec->mux_nids[0],
3648 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003649 }
3650 return 0;
3651}
3652
3653/* return non-zero if the device is for automatic mic switch */
3654static int stac_check_auto_mic(struct hda_codec *codec)
3655{
3656 struct sigmatel_spec *spec = codec->spec;
3657 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02003658 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003659 int i;
3660
Charles Chin99077902010-09-17 10:22:32 +02003661 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003662 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02003663 if (check_mic_pin(codec, cfg->inputs[i].pin,
3664 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003665 return 0;
3666 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02003667 if (check_mic_pin(codec, spec->dmic_nids[i],
3668 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003669 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01003670 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02003671 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003672 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003673 return 0; /* no unsol support */
3674 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02003675 set_mic_route(codec, &spec->int_mic, fixed) ||
3676 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003677 return 0; /* something is wrong */
3678 return 1;
3679}
3680
Mattc7d4b2f2005-06-27 14:59:41 +02003681/* create playback/capture controls for input pins */
3682static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3683{
3684 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003685 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003686 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003687 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02003688
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003689 for (i = 0; i < cfg->num_inputs; i++) {
3690 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003691 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02003692
Takashi Iwai314634b2006-09-21 11:56:18 +02003693 index = -1;
3694 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003695 index = get_connection_index(codec, spec->mux_nids[j],
3696 nid);
3697 if (index >= 0)
3698 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003699 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003700 if (index < 0)
3701 continue;
3702
Takashi Iwai10a20af2010-09-09 16:28:02 +02003703 label = hda_get_autocfg_input_label(codec, cfg, i);
3704 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003705
Takashi Iwai667067d2009-08-13 18:14:42 +02003706 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003707 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003708 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003709 if (err < 0)
3710 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003711 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003712 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003713
Steve Longerbeam7b043892007-05-03 20:50:03 +02003714 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003715 /*
3716 * Set the current input for the muxes.
3717 * The STAC9221 has two input muxes with identical source
3718 * NID lists. Hopefully this won't get confused.
3719 */
3720 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003721 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3722 AC_VERB_SET_CONNECT_SEL,
3723 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003724 }
3725 }
3726
Mattc7d4b2f2005-06-27 14:59:41 +02003727 return 0;
3728}
3729
Mattc7d4b2f2005-06-27 14:59:41 +02003730static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3731{
3732 struct sigmatel_spec *spec = codec->spec;
3733 int i;
3734
3735 for (i = 0; i < spec->autocfg.line_outs; i++) {
3736 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3737 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3738 }
3739}
3740
3741static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3742{
3743 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003744 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003745
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003746 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3747 hda_nid_t pin;
3748 pin = spec->autocfg.hp_pins[i];
3749 if (pin) /* connect to front */
3750 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3751 }
3752 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3753 hda_nid_t pin;
3754 pin = spec->autocfg.speaker_pins[i];
3755 if (pin) /* connect to front */
3756 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3757 }
Mattc7d4b2f2005-06-27 14:59:41 +02003758}
3759
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003760static int is_dual_headphones(struct hda_codec *codec)
3761{
3762 struct sigmatel_spec *spec = codec->spec;
3763 int i, valid_hps;
3764
3765 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3766 spec->autocfg.hp_outs <= 1)
3767 return 0;
3768 valid_hps = 0;
3769 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3770 hda_nid_t nid = spec->autocfg.hp_pins[i];
3771 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3772 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3773 continue;
3774 valid_hps++;
3775 }
3776 return (valid_hps > 1);
3777}
3778
3779
Charles Chin9009b0e2011-11-03 10:27:27 +01003780static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003781{
3782 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01003783 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003784 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003785 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003786
Matt Porter8b657272006-10-26 17:12:59 +02003787 if ((err = snd_hda_parse_pin_def_config(codec,
3788 &spec->autocfg,
3789 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003790 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003791 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003792 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003793
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003794 /* If we have no real line-out pin and multiple hp-outs, HPs should
3795 * be set up as multi-channel outputs.
3796 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003797 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003798 /* Copy hp_outs to line_outs, backup line_outs in
3799 * speaker_outs so that the following routines can handle
3800 * HP pins as primary outputs.
3801 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003802 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003803 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3804 sizeof(spec->autocfg.line_out_pins));
3805 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3806 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3807 sizeof(spec->autocfg.hp_pins));
3808 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003809 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3810 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003811 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003812 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003813 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003814 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3815 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003816 u32 caps = query_amp_caps(codec,
3817 spec->autocfg.mono_out_pin, dir);
3818 hda_nid_t conn_list[1];
3819
3820 /* get the mixer node and then the mono mux if it exists */
3821 if (snd_hda_get_connections(codec,
3822 spec->autocfg.mono_out_pin, conn_list, 1) &&
3823 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003824 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003825
3826 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003827 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003828 /* LR swap check, some stac925x have a mux that
3829 * changes the DACs output path instead of the
3830 * mono-mux path.
3831 */
3832 if (wid_type == AC_WID_AUD_SEL &&
3833 !(wcaps & AC_WCAP_LR_SWAP))
3834 spec->mono_nid = conn_list[0];
3835 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003836 if (dir) {
3837 hda_nid_t nid = spec->autocfg.mono_out_pin;
3838
3839 /* most mono outs have a least a mute/unmute switch */
3840 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3841 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3842 "Mono Playback Switch",
3843 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003844 if (err < 0)
3845 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003846 /* check for volume support for the amp */
3847 if ((caps & AC_AMPCAP_NUM_STEPS)
3848 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3849 err = stac92xx_add_control(spec,
3850 STAC_CTL_WIDGET_VOL,
3851 "Mono Playback Volume",
3852 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3853 if (err < 0)
3854 return err;
3855 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003856 }
3857
3858 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3859 AC_PINCTL_OUT_EN);
3860 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003861
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003862 if (!spec->multiout.num_dacs) {
3863 err = stac92xx_auto_fill_dac_nids(codec);
3864 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003865 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003866 err = stac92xx_auto_create_multi_out_ctls(codec,
3867 &spec->autocfg);
3868 if (err < 0)
3869 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003870 }
Mattc7d4b2f2005-06-27 14:59:41 +02003871
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003872 /* setup analog beep controls */
3873 if (spec->anabeep_nid > 0) {
3874 err = stac92xx_auto_create_beep_ctls(codec,
3875 spec->anabeep_nid);
3876 if (err < 0)
3877 return err;
3878 }
3879
3880 /* setup digital beep controls and input device */
3881#ifdef CONFIG_SND_HDA_INPUT_BEEP
3882 if (spec->digbeep_nid > 0) {
3883 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003884 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003885
3886 err = stac92xx_auto_create_beep_ctls(codec, nid);
3887 if (err < 0)
3888 return err;
3889 err = snd_hda_attach_beep_device(codec, nid);
3890 if (err < 0)
3891 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003892 if (codec->beep) {
3893 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003894 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003895 /* if no beep switch is available, make its own one */
3896 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3897 if (!(caps & AC_AMPCAP_MUTE)) {
3898 err = stac92xx_beep_switch_ctl(codec);
3899 if (err < 0)
3900 return err;
3901 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003902 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003903 }
3904#endif
3905
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003906 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003907 if (err < 0)
3908 return err;
3909
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003910 /* All output parsing done, now restore the swapped hp pins */
3911 if (hp_swap) {
3912 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3913 sizeof(spec->autocfg.hp_pins));
3914 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3915 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3916 spec->autocfg.line_outs = 0;
3917 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003918
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003919 if (stac_check_auto_mic(codec)) {
3920 spec->auto_mic = 1;
3921 /* only one capture for auto-mic */
3922 spec->num_adcs = 1;
3923 spec->num_caps = 1;
3924 spec->num_muxes = 1;
3925 }
3926
Takashi Iwai6479c632009-07-28 18:20:25 +02003927 for (i = 0; i < spec->num_caps; i++) {
3928 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3929 spec->capsws[i], i);
3930 if (err < 0)
3931 return err;
3932 }
3933
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003934 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003935 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003936 return err;
3937
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003938 if (spec->mono_nid > 0) {
3939 err = stac92xx_auto_create_mono_output_ctls(codec);
3940 if (err < 0)
3941 return err;
3942 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003943 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003944 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3945 &spec->autocfg)) < 0)
3946 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003947 if (spec->num_muxes > 0) {
3948 err = stac92xx_auto_create_mux_input_ctls(codec);
3949 if (err < 0)
3950 return err;
3951 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003952 if (spec->num_smuxes > 0) {
3953 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3954 if (err < 0)
3955 return err;
3956 }
Matt Porter8b657272006-10-26 17:12:59 +02003957
Takashi Iwaie3c75962009-01-23 11:57:22 +01003958 err = stac92xx_add_input_source(spec);
3959 if (err < 0)
3960 return err;
3961
Mattc7d4b2f2005-06-27 14:59:41 +02003962 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003963 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003964 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003965
Charles Chin9009b0e2011-11-03 10:27:27 +01003966 /* find digital out and in converters */
3967 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3968 unsigned int wid_caps = get_wcaps(codec, i);
3969 if (wid_caps & AC_WCAP_DIGITAL) {
3970 switch (get_wcaps_type(wid_caps)) {
3971 case AC_WID_AUD_OUT:
3972 if (!dig_out)
3973 dig_out = i;
3974 break;
3975 case AC_WID_AUD_IN:
3976 if (!dig_in)
3977 dig_in = i;
3978 break;
3979 }
3980 }
3981 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003982 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003983 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003984 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003985 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003986
Takashi Iwai603c4012008-07-30 15:01:44 +02003987 if (spec->kctls.list)
3988 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003989
3990 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003991 if (!spec->dinput_mux)
3992 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003993 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003994 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003995 return 1;
3996}
3997
Takashi Iwai82bc9552006-03-21 11:24:42 +01003998/* add playback controls for HP output */
3999static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4000 struct auto_pin_cfg *cfg)
4001{
4002 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004003 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01004004
4005 if (! pin)
4006 return 0;
4007
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004008 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01004009 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004010
4011 return 0;
4012}
4013
Richard Fish160ea0d2006-09-06 13:58:25 +02004014/* add playback controls for LFE output */
4015static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4016 struct auto_pin_cfg *cfg)
4017{
4018 struct sigmatel_spec *spec = codec->spec;
4019 int err;
4020 hda_nid_t lfe_pin = 0x0;
4021 int i;
4022
4023 /*
4024 * search speaker outs and line outs for a mono speaker pin
4025 * with an amp. If one is found, add LFE controls
4026 * for it.
4027 */
4028 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4029 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004030 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004031 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4032 if (wcaps == AC_WCAP_OUT_AMP)
4033 /* found a mono speaker with an amp, must be lfe */
4034 lfe_pin = pin;
4035 }
4036
4037 /* if speaker_outs is 0, then speakers may be in line_outs */
4038 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4039 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4040 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004041 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004042 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004043 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004044 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004045 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4046 if (wcaps == AC_WCAP_OUT_AMP)
4047 /* found a mono speaker with an amp,
4048 must be lfe */
4049 lfe_pin = pin;
4050 }
4051 }
4052 }
4053
4054 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004055 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004056 if (err < 0)
4057 return err;
4058 }
4059
4060 return 0;
4061}
4062
Mattc7d4b2f2005-06-27 14:59:41 +02004063static int stac9200_parse_auto_config(struct hda_codec *codec)
4064{
4065 struct sigmatel_spec *spec = codec->spec;
4066 int err;
4067
Kailang Yangdf694da2005-12-05 19:42:22 +01004068 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004069 return err;
4070
4071 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4072 return err;
4073
Takashi Iwai82bc9552006-03-21 11:24:42 +01004074 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4075 return err;
4076
Richard Fish160ea0d2006-09-06 13:58:25 +02004077 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4078 return err;
4079
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004080 if (spec->num_muxes > 0) {
4081 err = stac92xx_auto_create_mux_input_ctls(codec);
4082 if (err < 0)
4083 return err;
4084 }
4085
Takashi Iwaie3c75962009-01-23 11:57:22 +01004086 err = stac92xx_add_input_source(spec);
4087 if (err < 0)
4088 return err;
4089
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004090 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004091 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004092 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004093 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004094
Takashi Iwai603c4012008-07-30 15:01:44 +02004095 if (spec->kctls.list)
4096 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004097
4098 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004099 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004100
4101 return 1;
4102}
4103
Sam Revitch62fe78e2006-05-10 15:09:17 +02004104/*
4105 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4106 * funky external mute control using GPIO pins.
4107 */
4108
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004109static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004110 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004111{
4112 unsigned int gpiostate, gpiomask, gpiodir;
4113
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004114 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4115
Sam Revitch62fe78e2006-05-10 15:09:17 +02004116 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4117 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004118 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004119
4120 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4121 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004122 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004123
4124 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4125 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004126 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004127
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004128 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004129 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4130
4131 snd_hda_codec_write(codec, codec->afg, 0,
4132 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004133 snd_hda_codec_read(codec, codec->afg, 0,
4134 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004135
4136 msleep(1);
4137
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004138 snd_hda_codec_read(codec, codec->afg, 0,
4139 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004140}
4141
Takashi Iwai3a938972011-10-28 01:16:55 +02004142static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004143 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004144{
Takashi Iwai3a938972011-10-28 01:16:55 +02004145 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004146
Takashi Iwai3a938972011-10-28 01:16:55 +02004147 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004148 if (!event)
4149 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02004150 event->action = type;
4151 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004152
Takashi Iwai3a938972011-10-28 01:16:55 +02004153 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004154}
4155
Takashi Iwai62558ce2009-07-29 14:23:09 +02004156/* check if given nid is a valid pin and no other events are assigned
4157 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4158 * Otherwise, returns zero.
4159 */
4160static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4161 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004162{
Takashi Iwai3a938972011-10-28 01:16:55 +02004163 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004164
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004165 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004166 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02004167 event = snd_hda_jack_tbl_new(codec, nid);
4168 if (!event)
4169 return -ENOMEM;
4170 if (event->action && event->action != type)
4171 return 0;
4172 event->action = type;
4173 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004174 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004175}
4176
Takashi Iwaib4ead012012-01-23 18:23:36 +01004177static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004178{
4179 int i;
4180 for (i = 0; i < cfg->hp_outs; i++)
4181 if (cfg->hp_pins[i] == nid)
4182 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01004183 for (i = 0; i < cfg->line_outs; i++)
4184 if (cfg->line_out_pins[i] == nid)
4185 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004186 return 0; /* nid is not a HP-Out */
4187};
4188
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004189static void stac92xx_power_down(struct hda_codec *codec)
4190{
4191 struct sigmatel_spec *spec = codec->spec;
4192
4193 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02004194 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004195 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004196 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004197 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004198 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4199}
4200
Takashi Iwaif73d3582008-11-25 08:21:51 +01004201static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4202 int enable);
4203
Takashi Iwai014c41f2009-12-27 13:53:24 +01004204static inline int get_int_hint(struct hda_codec *codec, const char *key,
4205 int *valp)
4206{
4207 const char *p;
4208 p = snd_hda_get_hint(codec, key);
4209 if (p) {
4210 unsigned long val;
4211 if (!strict_strtoul(p, 0, &val)) {
4212 *valp = val;
4213 return 1;
4214 }
4215 }
4216 return 0;
4217}
4218
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004219/* override some hints from the hwdep entry */
4220static void stac_store_hints(struct hda_codec *codec)
4221{
4222 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004223 int val;
4224
4225 val = snd_hda_get_bool_hint(codec, "hp_detect");
4226 if (val >= 0)
4227 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004228 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004229 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4230 spec->gpio_mask;
4231 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004232 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4233 spec->gpio_mask &= spec->gpio_mask;
4234 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4235 spec->gpio_dir &= spec->gpio_mask;
4236 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4237 spec->eapd_mask &= spec->gpio_mask;
4238 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4239 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004240 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4241 if (val >= 0)
4242 spec->eapd_switch = val;
4243}
4244
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004245static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4246 const hda_nid_t *pins)
4247{
4248 while (num_pins--)
4249 stac_issue_unsol_event(codec, *pins++);
4250}
4251
4252/* fake event to set up pins */
4253static void stac_fake_hp_events(struct hda_codec *codec)
4254{
4255 struct sigmatel_spec *spec = codec->spec;
4256
4257 if (spec->autocfg.hp_outs)
4258 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4259 spec->autocfg.hp_pins);
4260 if (spec->autocfg.line_outs &&
4261 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4262 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4263 spec->autocfg.line_out_pins);
4264}
4265
Mattc7d4b2f2005-06-27 14:59:41 +02004266static int stac92xx_init(struct hda_codec *codec)
4267{
4268 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004269 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004270 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004271 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004272
Mattc7d4b2f2005-06-27 14:59:41 +02004273 snd_hda_sequence_write(codec, spec->init);
4274
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004275 /* power down adcs initially */
4276 if (spec->powerdown_adcs)
4277 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004278 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004279 spec->adc_nids[i], 0,
4280 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004281
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004282 /* override some hints */
4283 stac_store_hints(codec);
4284
Takashi Iwaif73d3582008-11-25 08:21:51 +01004285 /* set up GPIO */
4286 gpio = spec->gpio_data;
4287 /* turn on EAPD statically when spec->eapd_switch isn't set.
4288 * otherwise, unsol event will turn it on/off dynamically
4289 */
4290 if (!spec->eapd_switch)
4291 gpio |= spec->eapd_mask;
4292 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4293
Takashi Iwai82bc9552006-03-21 11:24:42 +01004294 /* set up pins */
4295 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004296 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004297 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004298 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004299 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004300 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004301 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4302 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004303 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004304 for (i = 0; i < cfg->line_outs; i++) {
4305 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004306 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4307 }
4308 }
4309
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004310 /* force to enable the first line-out; the others are set up
4311 * in unsol_event
4312 */
4313 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004314 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004315 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004316 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004317 } else {
4318 stac92xx_auto_init_multi_out(codec);
4319 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004320 for (i = 0; i < cfg->hp_outs; i++)
4321 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004322 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004323 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004324 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004325 if (spec->dmux_nids)
4326 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004327 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004328 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4329 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02004330 if (enable_pin_detect(codec, spec->dock_mic.pin,
4331 STAC_MIC_EVENT))
4332 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004333 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004334 for (i = 0; i < cfg->num_inputs; i++) {
4335 hda_nid_t nid = cfg->inputs[i].pin;
4336 int type = cfg->inputs[i].type;
4337 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02004338 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004339 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02004340 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004341 pinctl |= AC_PINCTL_IN_EN;
4342 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4343 } else {
4344 pinctl = snd_hda_codec_read(codec, nid, 0,
4345 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4346 /* if PINCTL already set then skip */
4347 /* Also, if both INPUT and OUTPUT are set,
4348 * it must be a BIOS bug; need to override, too
4349 */
4350 if (!(pinctl & AC_PINCTL_IN_EN) ||
4351 (pinctl & AC_PINCTL_OUT_EN)) {
4352 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004353 pinctl |= AC_PINCTL_IN_EN;
4354 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004355 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004356 }
4357 conf = snd_hda_codec_get_pincfg(codec, nid);
4358 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4359 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4360 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01004361 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004362 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004363 for (i = 0; i < spec->num_dmics; i++)
4364 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4365 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004366 if (cfg->dig_out_pins[0])
4367 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004368 AC_PINCTL_OUT_EN);
4369 if (cfg->dig_in_pin)
4370 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4371 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004372 for (i = 0; i < spec->num_pwrs; i++) {
4373 hda_nid_t nid = spec->pwr_nids[i];
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02004374 unsigned int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004375
Takashi Iwaibfc89de2012-05-15 09:02:26 +02004376 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4377 def_conf = get_defcfg_connect(def_conf);
4378 if (def_conf == AC_JACK_PORT_NONE) {
4379 /* power off unused ports */
4380 stac_toggle_power_map(codec, nid, 0);
4381 continue;
4382 }
Takashi Iwai6e1c39c2012-06-26 17:35:10 +02004383 if (def_conf == AC_JACK_PORT_FIXED) {
4384 /* no need for jack detection for fixed pins */
4385 stac_toggle_power_map(codec, nid, 1);
4386 continue;
4387 }
Takashi Iwaieb632122008-12-19 16:39:48 +01004388 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01004389 /* or when the VREF is used for controlling LED */
4390 if (!spec->hp_detect ||
Takashi Iwaibfc89de2012-05-15 09:02:26 +02004391 spec->vref_mute_led_nid == nid ||
4392 !is_jack_detectable(codec, nid)) {
Takashi Iwaieb632122008-12-19 16:39:48 +01004393 stac_toggle_power_map(codec, nid, 1);
4394 continue;
4395 }
4396
Takashi Iwaib4ead012012-01-23 18:23:36 +01004397 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004398 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004399
Takashi Iwaif73d3582008-11-25 08:21:51 +01004400 pinctl = snd_hda_codec_read(codec, nid, 0,
4401 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4402 /* outputs are only ports capable of power management
4403 * any attempts on powering down a input port cause the
4404 * referenced VREF to act quirky.
4405 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004406 if (pinctl & AC_PINCTL_IN_EN) {
4407 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004408 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004409 }
Charles Chinafef2cf2011-11-11 08:05:28 +01004410 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004411 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01004412 continue;
4413 }
4414 /* none of the above, turn the port OFF */
4415 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004416 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004417
Takashi Iwai01a61e12011-10-28 00:03:22 +02004418 snd_hda_jack_report_sync(codec);
4419
Takashi Iwaic21bd022010-02-08 15:16:08 +01004420 /* sync mute LED */
Takashi Iwaid2f344b2012-03-12 16:59:58 +01004421 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
Takashi Iwaic8822462012-05-15 09:11:36 +02004422
4423 /* sync the power-map */
4424 if (spec->num_pwrs)
4425 snd_hda_codec_write(codec, codec->afg, 0,
4426 AC_VERB_IDT_SET_POWER_MAP,
4427 spec->power_map_bits);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004428 if (spec->dac_list)
4429 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004430 return 0;
4431}
4432
Takashi Iwai603c4012008-07-30 15:01:44 +02004433static void stac92xx_free_kctls(struct hda_codec *codec)
4434{
4435 struct sigmatel_spec *spec = codec->spec;
4436
4437 if (spec->kctls.list) {
4438 struct snd_kcontrol_new *kctl = spec->kctls.list;
4439 int i;
4440 for (i = 0; i < spec->kctls.used; i++)
4441 kfree(kctl[i].name);
4442 }
4443 snd_array_free(&spec->kctls);
4444}
4445
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004446static void stac92xx_shutup_pins(struct hda_codec *codec)
4447{
4448 unsigned int i, def_conf;
4449
4450 if (codec->bus->shutdown)
4451 return;
4452 for (i = 0; i < codec->init_pins.used; i++) {
4453 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4454 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4455 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004456 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004457 }
4458}
4459
Takashi Iwai167eae52009-11-06 15:47:50 +01004460static void stac92xx_shutup(struct hda_codec *codec)
4461{
4462 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004463
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004464 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004465
4466 if (spec->eapd_mask)
4467 stac_gpio_set(codec, spec->gpio_mask,
4468 spec->gpio_dir, spec->gpio_data &
4469 ~spec->eapd_mask);
4470}
4471
Matt2f2f4252005-04-13 14:45:30 +02004472static void stac92xx_free(struct hda_codec *codec)
4473{
Mattc7d4b2f2005-06-27 14:59:41 +02004474 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004475
4476 if (! spec)
4477 return;
4478
Takashi Iwai167eae52009-11-06 15:47:50 +01004479 stac92xx_shutup(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02004480
Mattc7d4b2f2005-06-27 14:59:41 +02004481 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004482 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004483}
4484
Matt4e550962005-07-04 17:51:39 +02004485static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4486 unsigned int flag)
4487{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004488 unsigned int old_ctl, pin_ctl;
4489
4490 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004491 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004492
Takashi Iwaif9acba42007-05-29 18:01:06 +02004493 if (pin_ctl & AC_PINCTL_IN_EN) {
4494 /*
4495 * we need to check the current set-up direction of
4496 * shared input pins since they can be switched via
4497 * "xxx as Output" mixer switch
4498 */
4499 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004500 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004501 return;
4502 }
4503
Takashi Iwai8ce84192009-01-22 16:59:20 +01004504 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004505 /* if setting pin direction bits, clear the current
4506 direction bits first */
4507 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4508 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4509
Takashi Iwai8ce84192009-01-22 16:59:20 +01004510 pin_ctl |= flag;
4511 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004512 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004513}
4514
4515static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4516 unsigned int flag)
4517{
4518 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4519 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004520 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004521 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004522}
4523
Takashi Iwaid56757a2009-11-18 08:00:14 +01004524static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004525{
4526 if (!nid)
4527 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004528 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004529}
4530
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004531static void stac92xx_line_out_detect(struct hda_codec *codec,
4532 int presence)
4533{
4534 struct sigmatel_spec *spec = codec->spec;
4535 struct auto_pin_cfg *cfg = &spec->autocfg;
4536 int i;
4537
4538 for (i = 0; i < cfg->line_outs; i++) {
4539 if (presence)
4540 break;
4541 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4542 if (presence) {
4543 unsigned int pinctl;
4544 pinctl = snd_hda_codec_read(codec,
4545 cfg->line_out_pins[i], 0,
4546 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4547 if (pinctl & AC_PINCTL_IN_EN)
4548 presence = 0; /* mic- or line-input */
4549 }
4550 }
4551
4552 if (presence) {
4553 /* disable speakers */
4554 for (i = 0; i < cfg->speaker_outs; i++)
4555 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4556 AC_PINCTL_OUT_EN);
4557 if (spec->eapd_mask && spec->eapd_switch)
4558 stac_gpio_set(codec, spec->gpio_mask,
4559 spec->gpio_dir, spec->gpio_data &
4560 ~spec->eapd_mask);
4561 } else {
4562 /* enable speakers */
4563 for (i = 0; i < cfg->speaker_outs; i++)
4564 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4565 AC_PINCTL_OUT_EN);
4566 if (spec->eapd_mask && spec->eapd_switch)
4567 stac_gpio_set(codec, spec->gpio_mask,
4568 spec->gpio_dir, spec->gpio_data |
4569 spec->eapd_mask);
4570 }
4571}
4572
Takashi Iwaid7a89432008-11-12 09:48:04 +01004573/* return non-zero if the hp-pin of the given array index isn't
4574 * a jack-detection target
4575 */
4576static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4577{
4578 struct auto_pin_cfg *cfg = &spec->autocfg;
4579
4580 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004581 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004582 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004583 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004584 return 1;
4585 /* ignore if the pin is set as line-out */
4586 if (cfg->hp_pins[i] == spec->hp_switch)
4587 return 1;
4588 return 0;
4589}
4590
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004591static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004592{
4593 struct sigmatel_spec *spec = codec->spec;
4594 struct auto_pin_cfg *cfg = &spec->autocfg;
4595 int i, presence;
4596
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004597 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004598 if (spec->gpio_mute)
4599 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4600 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4601
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004602 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004603 if (presence)
4604 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004605 if (no_hp_sensing(spec, i))
4606 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004607 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4608 if (presence) {
4609 unsigned int pinctl;
4610 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4611 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4612 if (pinctl & AC_PINCTL_IN_EN)
4613 presence = 0; /* mic- or line-input */
4614 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004615 }
Matt4e550962005-07-04 17:51:39 +02004616
4617 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004618 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004619 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004620 stac92xx_reset_pinctl(codec, spec->hp_switch,
4621 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004622 for (i = 0; i < cfg->line_outs; i++)
4623 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4624 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004625 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004626 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004627 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004628 stac92xx_set_pinctl(codec, spec->hp_switch,
4629 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004630 for (i = 0; i < cfg->line_outs; i++)
4631 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4632 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004633 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004634 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004635 /* toggle hp outs */
4636 for (i = 0; i < cfg->hp_outs; i++) {
4637 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4638 if (no_hp_sensing(spec, i))
4639 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01004640 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004641 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004642#if 0 /* FIXME */
4643/* Resetting the pinctl like below may lead to (a sort of) regressions
4644 * on some devices since they use the HP pin actually for line/speaker
4645 * outs although the default pin config shows a different pin (that is
4646 * wrong and useless).
4647 *
4648 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4649 * But, disabling the code below just works around it, and I'm too tired of
4650 * bug reports with such devices...
4651 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004652 else
4653 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004654#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004655 }
Matt4e550962005-07-04 17:51:39 +02004656}
4657
Takashi Iwaif73d3582008-11-25 08:21:51 +01004658static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4659 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004660{
4661 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004662 unsigned int idx, val;
4663
4664 for (idx = 0; idx < spec->num_pwrs; idx++) {
4665 if (spec->pwr_nids[idx] == nid)
4666 break;
4667 }
4668 if (idx >= spec->num_pwrs)
4669 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004670
Charles Chinafef2cf2011-11-11 08:05:28 +01004671 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004672
Takashi Iwaic8822462012-05-15 09:11:36 +02004673 val = spec->power_map_bits;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004674 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004675 val &= ~idx;
4676 else
4677 val |= idx;
4678
4679 /* power down unused output ports */
Takashi Iwaic8822462012-05-15 09:11:36 +02004680 if (val != spec->power_map_bits) {
4681 spec->power_map_bits = val;
4682 snd_hda_codec_write(codec, codec->afg, 0,
4683 AC_VERB_IDT_SET_POWER_MAP, val);
4684 }
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004685}
4686
Takashi Iwaif73d3582008-11-25 08:21:51 +01004687static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4688{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004689 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004690}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004691
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004692/* get the pin connection (fixed, none, etc) */
4693static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4694{
4695 struct sigmatel_spec *spec = codec->spec;
4696 unsigned int cfg;
4697
4698 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4699 return get_defcfg_connect(cfg);
4700}
4701
4702static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004703 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004704{
4705 struct sigmatel_spec *spec = codec->spec;
4706 int idx, num;
4707 unsigned int def_conf;
4708
4709 for (num = 0; num < num_nids; num++) {
4710 for (idx = 0; idx < spec->num_pins; idx++)
4711 if (spec->pin_nids[idx] == nids[num])
4712 break;
4713 if (idx >= spec->num_pins)
4714 break;
4715 def_conf = stac_get_defcfg_connect(codec, idx);
4716 if (def_conf == AC_JACK_PORT_NONE)
4717 break;
4718 }
4719 return num;
4720}
4721
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004722static void stac92xx_mic_detect(struct hda_codec *codec)
4723{
4724 struct sigmatel_spec *spec = codec->spec;
4725 struct sigmatel_mic_route *mic;
4726
4727 if (get_pin_presence(codec, spec->ext_mic.pin))
4728 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02004729 else if (get_pin_presence(codec, spec->dock_mic.pin))
4730 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004731 else
4732 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004733 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004734 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4735 AC_VERB_SET_CONNECT_SEL,
4736 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004737 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004738 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4739 AC_VERB_SET_CONNECT_SEL,
4740 mic->mux_idx);
4741}
4742
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004743static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02004744 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02004745{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004746 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004747 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004748
Takashi Iwai3a938972011-10-28 01:16:55 +02004749 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004750 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004751 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004752 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004753 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004754 case STAC_MIC_EVENT:
4755 stac92xx_mic_detect(codec);
4756 break;
4757 }
4758
Takashi Iwai3a938972011-10-28 01:16:55 +02004759 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004760 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004761 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004762 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004763 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004764 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004765 if (spec->num_pwrs > 0)
4766 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004767
4768 switch (codec->subsystem_id) {
4769 case 0x103c308f:
4770 if (event->nid == 0xb) {
4771 int pin = AC_PINCTL_IN_EN;
4772
4773 if (get_pin_presence(codec, 0xa)
4774 && get_pin_presence(codec, 0xb))
4775 pin |= AC_PINCTL_VREF_80;
4776 if (!get_pin_presence(codec, 0xb))
4777 pin |= AC_PINCTL_VREF_80;
4778
4779 /* toggle VREF state based on mic + hp pin
4780 * status
4781 */
4782 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4783 }
4784 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004785 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004786 case STAC_VREF_EVENT:
4787 data = snd_hda_codec_read(codec, codec->afg, 0,
4788 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004789 /* toggle VREF state based on GPIOx status */
4790 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02004791 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004792 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004793 }
4794}
4795
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004796static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4797{
Takashi Iwai3a938972011-10-28 01:16:55 +02004798 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004799 if (!event)
4800 return;
4801 handle_unsol_event(codec, event);
4802}
4803
4804static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4805{
Takashi Iwai3a938972011-10-28 01:16:55 +02004806 struct hda_jack_tbl *event;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004807 int tag;
4808
4809 tag = (res >> 26) & 0x7f;
Takashi Iwai3a938972011-10-28 01:16:55 +02004810 event = snd_hda_jack_tbl_get_from_tag(codec, tag);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004811 if (!event)
4812 return;
Takashi Iwai3a938972011-10-28 01:16:55 +02004813 event->jack_dirty = 1;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004814 handle_unsol_event(codec, event);
Takashi Iwai01a61e12011-10-28 00:03:22 +02004815 snd_hda_jack_report_sync(codec);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004816}
4817
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304818static int hp_blike_system(u32 subsystem_id);
4819
4820static void set_hp_led_gpio(struct hda_codec *codec)
4821{
4822 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004823 unsigned int gpio;
4824
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004825 if (spec->gpio_led)
4826 return;
4827
Takashi Iwai07f80442010-02-08 15:06:13 +01004828 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4829 gpio &= AC_GPIO_IO_COUNT;
4830 if (gpio > 3)
4831 spec->gpio_led = 0x08; /* GPIO 3 */
4832 else
4833 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304834}
4835
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004836/*
4837 * This method searches for the mute LED GPIO configuration
4838 * provided as OEM string in SMBIOS. The format of that string
4839 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4840 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4841 * that corresponds to the NOT muted state of the master volume
4842 * and G is the index of the GPIO to use as the mute LED control (0..9)
4843 * If _G portion is missing it is assigned based on the codec ID
4844 *
4845 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4846 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304847 *
4848 *
4849 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4850 * SMBIOS - at least the ones I have seen do not have them - which include
4851 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4852 * HP Pavilion dv9500t CTO.
4853 * Need more information on whether it is true across the entire series.
4854 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004855 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004856static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004857{
4858 struct sigmatel_spec *spec = codec->spec;
4859 const struct dmi_device *dev = NULL;
4860
Takashi Iwai75609312012-05-14 16:52:00 +02004861 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4862 get_int_hint(codec, "gpio_led_polarity",
4863 &spec->gpio_led_polarity);
4864 return 1;
4865 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004866 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4867 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4868 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004869 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304870 &spec->gpio_led_polarity,
4871 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004872 unsigned int max_gpio;
4873 max_gpio = snd_hda_param_read(codec, codec->afg,
4874 AC_PAR_GPIO_CAP);
4875 max_gpio &= AC_GPIO_IO_COUNT;
4876 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004877 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01004878 else
4879 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004880 return 1;
4881 }
4882 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304883 &spec->gpio_led_polarity) == 1) {
4884 set_hp_led_gpio(codec);
4885 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004886 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004887 /* BIOS bug: unfilled OEM string */
4888 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4889 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02004890 switch (codec->subsystem_id) {
4891 case 0x103c148a:
4892 spec->gpio_led_polarity = 0;
4893 break;
4894 default:
4895 spec->gpio_led_polarity = 1;
4896 break;
4897 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004898 return 1;
4899 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004900 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304901
4902 /*
4903 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004904 * we statically set the GPIO - if not a B-series system
4905 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304906 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004907 if (!hp_blike_system(codec->subsystem_id) &&
4908 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304909 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004910 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304911 return 1;
4912 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004913 }
4914 return 0;
4915}
4916
4917static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004918{
4919 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004920 case 0x103c1520:
4921 case 0x103c1521:
4922 case 0x103c1523:
4923 case 0x103c1524:
4924 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004925 case 0x103c1722:
4926 case 0x103c1723:
4927 case 0x103c1724:
4928 case 0x103c1725:
4929 case 0x103c1726:
4930 case 0x103c1727:
4931 case 0x103c1728:
4932 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004933 case 0x103c172a:
4934 case 0x103c172b:
4935 case 0x103c307e:
4936 case 0x103c307f:
4937 case 0x103c3080:
4938 case 0x103c3081:
4939 case 0x103c7007:
4940 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004941 return 1;
4942 }
4943 return 0;
4944}
4945
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004946#ifdef CONFIG_PROC_FS
4947static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4948 struct hda_codec *codec, hda_nid_t nid)
4949{
4950 if (nid == codec->afg)
4951 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
Takashi Iwaic8822462012-05-15 09:11:36 +02004952 snd_hda_codec_read(codec, nid, 0,
4953 AC_VERB_IDT_GET_POWER_MAP, 0));
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004954}
4955
4956static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4957 struct hda_codec *codec,
4958 unsigned int verb)
4959{
4960 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4961 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4962}
4963
4964/* stac92hd71bxx, stac92hd73xx */
4965static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4966 struct hda_codec *codec, hda_nid_t nid)
4967{
4968 stac92hd_proc_hook(buffer, codec, nid);
4969 if (nid == codec->afg)
4970 analog_loop_proc_hook(buffer, codec, 0xfa0);
4971}
4972
4973static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4974 struct hda_codec *codec, hda_nid_t nid)
4975{
4976 if (nid == codec->afg)
4977 analog_loop_proc_hook(buffer, codec, 0xfe0);
4978}
4979
4980static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4981 struct hda_codec *codec, hda_nid_t nid)
4982{
4983 if (nid == codec->afg)
4984 analog_loop_proc_hook(buffer, codec, 0xfeb);
4985}
4986#else
4987#define stac92hd_proc_hook NULL
4988#define stac92hd7x_proc_hook NULL
4989#define stac9205_proc_hook NULL
4990#define stac927x_proc_hook NULL
4991#endif
4992
Takashi Iwai2a439522011-07-26 09:52:50 +02004993#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02004994static int stac92xx_resume(struct hda_codec *codec)
4995{
Takashi Iwai2c885872008-11-18 09:36:55 +01004996 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004997 snd_hda_codec_resume_amp(codec);
4998 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004999 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01005000 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02005001 return 0;
5002}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005003
Takashi Iwai68cb2b52012-07-02 15:20:37 +02005004static int stac92xx_suspend(struct hda_codec *codec)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005005{
5006 stac92xx_shutup(codec);
5007 return 0;
5008}
5009
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005010static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5011 unsigned int power_state)
5012{
5013 unsigned int afg_power_state = power_state;
5014 struct sigmatel_spec *spec = codec->spec;
5015
5016 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005017 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005018 /* with vref-out pin used for mute led control
5019 * codec AFG is prevented from D3 state
5020 */
5021 afg_power_state = AC_PWRST_D1;
5022 }
5023 /* this delay seems necessary to avoid click noise at power-down */
5024 msleep(100);
5025 }
5026 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5027 afg_power_state);
5028 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5029}
Takashi Iwai350eba432012-03-16 16:09:03 +01005030#else
5031#define stac92xx_suspend NULL
5032#define stac92xx_resume NULL
Takashi Iwai350eba432012-03-16 16:09:03 +01005033#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005034#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005035
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005036/* update mute-LED accoring to the master switch */
5037static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005038{
5039 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005040 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005041
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005042 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005043 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005044
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005045 /* LED state is inverted on these systems */
5046 if (spec->gpio_led_polarity)
5047 muted = !muted;
5048
Takashi Iwaif1a73742011-12-04 13:44:06 +01005049 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005050 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02005051 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005052 else
Takashi Iwai3e843192012-04-19 12:04:03 +02005053 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005054 stac_gpio_set(codec, spec->gpio_mask,
5055 spec->gpio_dir, spec->gpio_data);
5056 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005057 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005058 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5059 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005060 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005061}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05005062
Takashi Iwai2b635362011-05-02 12:33:43 +02005063static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005064 .build_controls = stac92xx_build_controls,
5065 .build_pcms = stac92xx_build_pcms,
5066 .init = stac92xx_init,
5067 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02005068 .unsol_event = stac92xx_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02005069#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005070 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005071 .resume = stac92xx_resume,
5072#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005073 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005074};
5075
5076static int patch_stac9200(struct hda_codec *codec)
5077{
5078 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005079 int err;
Matt2f2f4252005-04-13 14:45:30 +02005080
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005081 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005082 if (spec == NULL)
5083 return -ENOMEM;
5084
Takashi Iwaia252c812009-12-25 22:56:20 +01005085 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005086 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005087 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005088 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005089 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005090 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5091 stac9200_models,
5092 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005093 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005094 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5095 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005096 else
5097 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005098 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005099
5100 spec->multiout.max_channels = 2;
5101 spec->multiout.num_dacs = 1;
5102 spec->multiout.dac_nids = stac9200_dac_nids;
5103 spec->adc_nids = stac9200_adc_nids;
5104 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005105 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005106 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005107 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005108 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005109
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005110 if (spec->board_config == STAC_9200_M4 ||
5111 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005112 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005113 spec->init = stac9200_eapd_init;
5114 else
5115 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005116 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005117
Takashi Iwai117f2572008-03-18 09:53:23 +01005118 if (spec->board_config == STAC_9200_PANASONIC) {
5119 spec->gpio_mask = spec->gpio_dir = 0x09;
5120 spec->gpio_data = 0x00;
5121 }
5122
Mattc7d4b2f2005-06-27 14:59:41 +02005123 err = stac9200_parse_auto_config(codec);
5124 if (err < 0) {
5125 stac92xx_free(codec);
5126 return err;
5127 }
Matt2f2f4252005-04-13 14:45:30 +02005128
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005129 /* CF-74 has no headphone detection, and the driver should *NOT*
5130 * do detection and HP/speaker toggle because the hardware does it.
5131 */
5132 if (spec->board_config == STAC_9200_PANASONIC)
5133 spec->hp_detect = 0;
5134
Matt2f2f4252005-04-13 14:45:30 +02005135 codec->patch_ops = stac92xx_patch_ops;
5136
5137 return 0;
5138}
5139
Tobin Davis8e21c342007-01-08 11:04:17 +01005140static int patch_stac925x(struct hda_codec *codec)
5141{
5142 struct sigmatel_spec *spec;
5143 int err;
5144
5145 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5146 if (spec == NULL)
5147 return -ENOMEM;
5148
Takashi Iwaia252c812009-12-25 22:56:20 +01005149 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005150 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005151 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005152 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005153 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005154
5155 /* Check first for codec ID */
5156 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5157 STAC_925x_MODELS,
5158 stac925x_models,
5159 stac925x_codec_id_cfg_tbl);
5160
5161 /* Now checks for PCI ID, if codec ID is not found */
5162 if (spec->board_config < 0)
5163 spec->board_config = snd_hda_check_board_config(codec,
5164 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005165 stac925x_models,
5166 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005167 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005168 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005169 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5170 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005171 else
5172 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005173 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005174
5175 spec->multiout.max_channels = 2;
5176 spec->multiout.num_dacs = 1;
5177 spec->multiout.dac_nids = stac925x_dac_nids;
5178 spec->adc_nids = stac925x_adc_nids;
5179 spec->mux_nids = stac925x_mux_nids;
5180 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005181 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005182 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005183 switch (codec->vendor_id) {
5184 case 0x83847632: /* STAC9202 */
5185 case 0x83847633: /* STAC9202D */
5186 case 0x83847636: /* STAC9251 */
5187 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005188 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005189 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005190 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5191 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005192 break;
5193 default:
5194 spec->num_dmics = 0;
5195 break;
5196 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005197
5198 spec->init = stac925x_core_init;
5199 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005200 spec->num_caps = 1;
5201 spec->capvols = stac925x_capvols;
5202 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005203
Charles Chin9009b0e2011-11-03 10:27:27 +01005204 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005205 if (!err) {
5206 if (spec->board_config < 0) {
5207 printk(KERN_WARNING "hda_codec: No auto-config is "
5208 "available, default to model=ref\n");
5209 spec->board_config = STAC_925x_REF;
5210 goto again;
5211 }
5212 err = -EINVAL;
5213 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005214 if (err < 0) {
5215 stac92xx_free(codec);
5216 return err;
5217 }
5218
5219 codec->patch_ops = stac92xx_patch_ops;
5220
5221 return 0;
5222}
5223
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005224static int patch_stac92hd73xx(struct hda_codec *codec)
5225{
5226 struct sigmatel_spec *spec;
5227 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5228 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005229 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005230
5231 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5232 if (spec == NULL)
5233 return -ENOMEM;
5234
Takashi Iwaia252c812009-12-25 22:56:20 +01005235 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005236 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005237 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005238 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005239 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5240 spec->pin_nids = stac92hd73xx_pin_nids;
5241 spec->board_config = snd_hda_check_board_config(codec,
5242 STAC_92HD73XX_MODELS,
5243 stac92hd73xx_models,
5244 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005245 /* check codec subsystem id if not found */
5246 if (spec->board_config < 0)
5247 spec->board_config =
5248 snd_hda_check_board_codec_sid_config(codec,
5249 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5250 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005251again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005252 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005253 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5254 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005255 else
5256 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005257 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005258
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005259 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005260 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5261
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005262 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005263 printk(KERN_WARNING "hda_codec: Could not determine "
5264 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005265 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005266 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005267 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005268 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005269 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005270 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005271 break;
5272 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005273 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005274 break;
5275 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005276 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5277 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005278 }
5279 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005280
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005281 spec->aloopback_mask = 0x01;
5282 spec->aloopback_shift = 8;
5283
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005284 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005285 spec->mux_nids = stac92hd73xx_mux_nids;
5286 spec->adc_nids = stac92hd73xx_adc_nids;
5287 spec->dmic_nids = stac92hd73xx_dmic_nids;
5288 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005289 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005290
5291 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5292 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005293 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005294
Takashi Iwai6479c632009-07-28 18:20:25 +02005295 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5296 spec->capvols = stac92hd73xx_capvols;
5297 spec->capsws = stac92hd73xx_capsws;
5298
Matthew Ranostaya7662642008-02-21 07:51:14 +01005299 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005300 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005301 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005302 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005303 case STAC_DELL_M6_AMIC:
5304 case STAC_DELL_M6_DMIC:
5305 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005306 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005307 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005308
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005309 switch (spec->board_config) {
5310 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005311 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005312 spec->num_dmics = 0;
5313 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005314 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005315 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005316 spec->num_dmics = 1;
5317 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005318 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005319 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5320 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005321 spec->num_dmics = 1;
5322 break;
5323 }
5324 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005325 case STAC_ALIENWARE_M17X:
5326 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5327 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5328 spec->eapd_switch = 0;
5329 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005330 default:
5331 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005332 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005333 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005334 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005335 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005336 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005337 /* GPIO0 High = Enable EAPD */
5338 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5339 spec->gpio_data = 0x01;
5340 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005341
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005342 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5343 spec->pwr_nids = stac92hd73xx_pwr_nids;
5344
Charles Chin9009b0e2011-11-03 10:27:27 +01005345 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005346
5347 if (!err) {
5348 if (spec->board_config < 0) {
5349 printk(KERN_WARNING "hda_codec: No auto-config is "
5350 "available, default to model=ref\n");
5351 spec->board_config = STAC_92HD73XX_REF;
5352 goto again;
5353 }
5354 err = -EINVAL;
5355 }
5356
5357 if (err < 0) {
5358 stac92xx_free(codec);
5359 return err;
5360 }
5361
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005362 if (spec->board_config == STAC_92HD73XX_NO_JD)
5363 spec->hp_detect = 0;
5364
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005365 codec->patch_ops = stac92xx_patch_ops;
5366
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005367 codec->proc_widget_hook = stac92hd7x_proc_hook;
5368
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005369 return 0;
5370}
5371
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005372static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005373{
5374 if (codec->vendor_id != 0x111d7605 &&
5375 codec->vendor_id != 0x111d76d1)
5376 return 0;
5377
5378 switch (codec->subsystem_id) {
5379 case 0x103c1618:
5380 case 0x103c1619:
5381 case 0x103c161a:
5382 case 0x103c161b:
5383 case 0x103c161c:
5384 case 0x103c161d:
5385 case 0x103c161e:
5386 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005387
5388 case 0x103c162a:
5389 case 0x103c162b:
5390
5391 case 0x103c1630:
5392 case 0x103c1631:
5393
5394 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005395 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005396 case 0x103c1635:
5397
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005398 case 0x103c3587:
5399 case 0x103c3588:
5400 case 0x103c3589:
5401 case 0x103c358a:
5402
5403 case 0x103c3667:
5404 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005405 case 0x103c3669:
5406
5407 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005408 }
5409 return 0;
5410}
5411
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005412static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5413{
5414 struct sigmatel_spec *spec = codec->spec;
5415 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5416 int i;
5417
5418 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5419 spec->auto_pin_cnt++;
5420
5421 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5422 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5423 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5424 if (nid == stac92hd83xxx_dmic_nids[i]) {
5425 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5426 spec->auto_dmic_cnt++;
5427 }
5428 }
5429 }
5430}
5431
5432static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5433{
5434 struct sigmatel_spec *spec = codec->spec;
5435
5436 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5437 spec->auto_adc_cnt++;
5438}
5439
5440static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5441{
5442 int i, j;
5443 struct sigmatel_spec *spec = codec->spec;
5444
5445 for (i = 0; i < spec->auto_adc_cnt; i++) {
5446 if (get_connection_index(codec,
5447 spec->auto_adc_nids[i], nid) >= 0) {
5448 /* mux and volume for adc_nids[i] */
5449 if (!spec->auto_mux_nids[i]) {
5450 spec->auto_mux_nids[i] = nid;
5451 /* 92hd codecs capture volume is in mux */
5452 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5453 3, 0, HDA_OUTPUT);
5454 }
5455 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5456 if (get_connection_index(codec, nid,
5457 spec->auto_dmic_nids[j]) >= 0) {
5458 /* dmux for adc_nids[i] */
5459 if (!spec->auto_dmux_nids[i])
5460 spec->auto_dmux_nids[i] = nid;
5461 break;
5462 }
5463 }
5464 break;
5465 }
5466 }
5467}
5468
5469static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5470{
5471 hda_nid_t nid, end_nid;
5472 unsigned int wid_caps, wid_type;
5473 struct sigmatel_spec *spec = codec->spec;
5474
5475 end_nid = codec->start_nid + codec->num_nodes;
5476
5477 for (nid = codec->start_nid; nid < end_nid; nid++) {
5478 wid_caps = get_wcaps(codec, nid);
5479 wid_type = get_wcaps_type(wid_caps);
5480
5481 if (wid_type == AC_WID_PIN)
5482 stac92hd8x_add_pin(codec, nid);
5483
5484 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5485 stac92hd8x_add_adc(codec, nid);
5486 }
5487
5488 for (nid = codec->start_nid; nid < end_nid; nid++) {
5489 wid_caps = get_wcaps(codec, nid);
5490 wid_type = get_wcaps_type(wid_caps);
5491
5492 if (wid_type == AC_WID_AUD_SEL)
5493 stac92hd8x_add_mux(codec, nid);
5494 }
5495
5496 spec->pin_nids = spec->auto_pin_nids;
5497 spec->num_pins = spec->auto_pin_cnt;
5498 spec->adc_nids = spec->auto_adc_nids;
5499 spec->num_adcs = spec->auto_adc_cnt;
5500 spec->capvols = spec->auto_capvols;
5501 spec->capsws = spec->auto_capvols;
5502 spec->num_caps = spec->auto_adc_cnt;
5503 spec->mux_nids = spec->auto_mux_nids;
5504 spec->num_muxes = spec->auto_adc_cnt;
5505 spec->dmux_nids = spec->auto_dmux_nids;
5506 spec->num_dmuxes = spec->auto_adc_cnt;
5507 spec->dmic_nids = spec->auto_dmic_nids;
5508 spec->num_dmics = spec->auto_dmic_cnt;
5509}
5510
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005511static int patch_stac92hd83xxx(struct hda_codec *codec)
5512{
5513 struct sigmatel_spec *spec;
Takashi Iwaia3e19972012-07-26 08:17:20 +02005514 int default_polarity = -1; /* no default cfg */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005515 int err;
5516
5517 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5518 if (spec == NULL)
5519 return -ENOMEM;
5520
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005521 if (hp_bnb2011_with_dock(codec)) {
5522 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5523 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5524 }
5525
Takashi Iwaia252c812009-12-25 22:56:20 +01005526 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005527 codec->spec = spec;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005528
5529 stac92hd8x_fill_auto_spec(codec);
5530
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01005531 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005532 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005533 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005534 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005535 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005536 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005537 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005538
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005539 spec->board_config = snd_hda_check_board_config(codec,
5540 STAC_92HD83XXX_MODELS,
5541 stac92hd83xxx_models,
5542 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005543 /* check codec subsystem id if not found */
5544 if (spec->board_config < 0)
5545 spec->board_config =
5546 snd_hda_check_board_codec_sid_config(codec,
5547 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
5548 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005549again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005550 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005551 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5552 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005553 else
5554 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005555 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005556
Takashi Iwaib4e81872009-11-18 17:20:24 +01005557 codec->patch_ops = stac92xx_patch_ops;
5558
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005559 switch (spec->board_config) {
5560 case STAC_HP_ZEPHYR:
5561 spec->init = stac92hd83xxx_hp_zephyr_init;
5562 break;
Takashi Iwaia3e19972012-07-26 08:17:20 +02005563 case STAC_92HD83XXX_HP_LED:
5564 default_polarity = 1;
5565 break;
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005566 }
5567
Takashi Iwaia3e19972012-07-26 08:17:20 +02005568 if (find_mute_led_cfg(codec, default_polarity))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005569 snd_printd("mute LED gpio %d polarity %d\n",
5570 spec->gpio_led,
5571 spec->gpio_led_polarity);
5572
Takashi Iwaib4e81872009-11-18 17:20:24 +01005573 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005574 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005575 spec->gpio_mask |= spec->gpio_led;
5576 spec->gpio_dir |= spec->gpio_led;
5577 spec->gpio_data |= spec->gpio_led;
5578 } else {
5579 codec->patch_ops.set_power_state =
5580 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005581 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005582 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005583
Charles Chin9009b0e2011-11-03 10:27:27 +01005584 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005585 if (!err) {
5586 if (spec->board_config < 0) {
5587 printk(KERN_WARNING "hda_codec: No auto-config is "
5588 "available, default to model=ref\n");
5589 spec->board_config = STAC_92HD83XXX_REF;
5590 goto again;
5591 }
5592 err = -EINVAL;
5593 }
5594
5595 if (err < 0) {
5596 stac92xx_free(codec);
5597 return err;
5598 }
5599
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005600 codec->proc_widget_hook = stac92hd_proc_hook;
5601
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005602 return 0;
5603}
5604
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005605static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5606 hda_nid_t dig0pin)
5607{
5608 struct sigmatel_spec *spec = codec->spec;
5609 int idx;
5610
5611 for (idx = 0; idx < spec->num_pins; idx++)
5612 if (spec->pin_nids[idx] == dig0pin)
5613 break;
5614 if ((idx + 2) >= spec->num_pins)
5615 return 0;
5616
5617 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005618 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005619 return 2;
5620
5621 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005622 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005623 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005624 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005625 return 1;
5626 else
5627 return 0;
5628}
5629
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005630/* HP dv7 bass switch - GPIO5 */
5631#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5632static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5633 struct snd_ctl_elem_value *ucontrol)
5634{
5635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5636 struct sigmatel_spec *spec = codec->spec;
5637 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5638 return 0;
5639}
5640
5641static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5642 struct snd_ctl_elem_value *ucontrol)
5643{
5644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5645 struct sigmatel_spec *spec = codec->spec;
5646 unsigned int gpio_data;
5647
5648 gpio_data = (spec->gpio_data & ~0x20) |
5649 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5650 if (gpio_data == spec->gpio_data)
5651 return 0;
5652 spec->gpio_data = gpio_data;
5653 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5654 return 1;
5655}
5656
Takashi Iwai2b635362011-05-02 12:33:43 +02005657static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5659 .info = stac_hp_bass_gpio_info,
5660 .get = stac_hp_bass_gpio_get,
5661 .put = stac_hp_bass_gpio_put,
5662};
5663
5664static int stac_add_hp_bass_switch(struct hda_codec *codec)
5665{
5666 struct sigmatel_spec *spec = codec->spec;
5667
5668 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5669 "Bass Speaker Playback Switch", 0))
5670 return -ENOMEM;
5671
5672 spec->gpio_mask |= 0x20;
5673 spec->gpio_dir |= 0x20;
5674 spec->gpio_data |= 0x20;
5675 return 0;
5676}
5677
Matthew Ranostaye035b842007-11-06 11:53:55 +01005678static int patch_stac92hd71bxx(struct hda_codec *codec)
5679{
5680 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02005681 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005682 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005683 int err = 0;
5684
5685 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5686 if (spec == NULL)
5687 return -ENOMEM;
5688
Takashi Iwaia252c812009-12-25 22:56:20 +01005689 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005690 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005691 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005692 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005693 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5694 switch (codec->vendor_id) {
5695 case 0x111d76b6:
5696 case 0x111d76b7:
5697 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5698 break;
5699 case 0x111d7603:
5700 case 0x111d7608:
5701 /* On 92HD75Bx 0x27 isn't a pin nid */
5702 spec->num_pins--;
5703 /* fallthrough */
5704 default:
5705 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5706 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005707 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005708 spec->board_config = snd_hda_check_board_config(codec,
5709 STAC_92HD71BXX_MODELS,
5710 stac92hd71bxx_models,
5711 stac92hd71bxx_cfg_tbl);
5712again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005713 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005714 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5715 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005716 else
5717 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005718 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005719
Takashi Iwaifc64b262009-09-14 15:33:01 +02005720 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005721 /* GPIO0 = EAPD */
5722 spec->gpio_mask = 0x01;
5723 spec->gpio_dir = 0x01;
5724 spec->gpio_data = 0x01;
5725 }
5726
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005727 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5728 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5729
Takashi Iwai6479c632009-07-28 18:20:25 +02005730 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5731 spec->capvols = stac92hd71bxx_capvols;
5732 spec->capsws = stac92hd71bxx_capsws;
5733
Matthew Ranostay541eee82007-12-14 12:08:04 +01005734 switch (codec->vendor_id) {
5735 case 0x111d76b6: /* 4 Port without Analog Mixer */
5736 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005737 unmute_init++;
5738 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005739 case 0x111d76b4: /* 6 Port without Analog Mixer */
5740 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005741 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005742 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005743 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005744 stac92hd71bxx_dmic_nids,
5745 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005746 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005747 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005748 switch (spec->board_config) {
5749 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005750 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai3a938972011-10-28 01:16:55 +02005751 err = stac_add_event(codec, codec->afg,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005752 STAC_VREF_EVENT, 0x02);
5753 if (err < 0)
5754 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005755 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005756 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai3a938972011-10-28 01:16:55 +02005757 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005758 spec->gpio_mask |= 0x02;
5759 break;
5760 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005761 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005762 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005763 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005764
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005765 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005766 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005767 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005768 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5769 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02005770 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005771 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005772 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005773 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005774 break;
5775 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005776 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005777 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005778
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005779 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005780 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005781 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005782 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005783 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005784 stac92hd71bxx_dmic_nids,
5785 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005786 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005787 }
5788
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005789 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5790 snd_hda_sequence_write_cache(codec, unmute_init);
5791
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005792 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005793 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005794 spec->aloopback_shift = 0;
5795
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005796 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005797 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005798 spec->mux_nids = stac92hd71bxx_mux_nids;
5799 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005800 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005801 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005802
5803 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5804 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005805 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005806 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005807
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305808 snd_printdd("Found board config: %d\n", spec->board_config);
5809
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005810 switch (spec->board_config) {
5811 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005812 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005813 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005814 stac92xx_auto_set_pinctl(codec, 0x0e,
5815 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005816 /* fallthru */
5817 case STAC_DELL_M4_2:
5818 spec->num_dmics = 0;
5819 spec->num_smuxes = 0;
5820 spec->num_dmuxes = 0;
5821 break;
5822 case STAC_DELL_M4_1:
5823 case STAC_DELL_M4_3:
5824 spec->num_dmics = 1;
5825 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005826 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005827 break;
James Gardiner514bf542009-05-03 04:00:44 -04005828 case STAC_HP_DV4_1222NR:
5829 spec->num_dmics = 1;
5830 /* I don't know if it needs 1 or 2 smuxes - will wait for
5831 * bug reports to fix if needed
5832 */
5833 spec->num_smuxes = 1;
5834 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005835 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005836 case STAC_HP_DV4:
5837 spec->gpio_led = 0x01;
5838 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005839 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005840 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005841 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005842 /* HP dv6 gives the headphone pin as a line-out. Thus we
5843 * need to set hp_detect flag here to force to enable HP
5844 * detection.
5845 */
5846 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005847 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005848 case STAC_HP_HDX:
5849 spec->num_dmics = 1;
5850 spec->num_dmuxes = 1;
5851 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005852 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005853 break;
5854 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005855
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005856 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005857 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5858 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5859 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5860 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5861 /* It was changed in the BIOS to just satisfy MS DTM.
5862 * Lets turn it back into slaved HP
5863 */
5864 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5865 | (AC_JACK_HP_OUT <<
5866 AC_DEFCFG_DEVICE_SHIFT);
5867 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5868 | AC_DEFCFG_SEQUENCE)))
5869 | 0x1f;
5870 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5871 }
5872 }
5873
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005874 if (find_mute_led_cfg(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005875 snd_printd("mute LED gpio %d polarity %d\n",
5876 spec->gpio_led,
5877 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005878
Takashi Iwai86d190e2009-05-26 15:18:58 +02005879 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005880 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005881 spec->gpio_mask |= spec->gpio_led;
5882 spec->gpio_dir |= spec->gpio_led;
5883 spec->gpio_data |= spec->gpio_led;
5884 } else {
5885 codec->patch_ops.set_power_state =
5886 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005887 }
Takashi Iwai86d190e2009-05-26 15:18:58 +02005888 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005889
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005890 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005891
Charles Chin9009b0e2011-11-03 10:27:27 +01005892 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005893 if (!err) {
5894 if (spec->board_config < 0) {
5895 printk(KERN_WARNING "hda_codec: No auto-config is "
5896 "available, default to model=ref\n");
5897 spec->board_config = STAC_92HD71BXX_REF;
5898 goto again;
5899 }
5900 err = -EINVAL;
5901 }
5902
5903 if (err < 0) {
5904 stac92xx_free(codec);
5905 return err;
5906 }
5907
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005908 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005909 if (spec->board_config == STAC_HP_DV4 ||
5910 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005911 unsigned int cap;
5912 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5913 cap &= AC_GPIO_IO_COUNT;
5914 if (cap >= 6)
5915 stac_add_hp_bass_switch(codec);
5916 }
5917
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005918 codec->proc_widget_hook = stac92hd7x_proc_hook;
5919
Matthew Ranostaye035b842007-11-06 11:53:55 +01005920 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005921}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005922
Matt2f2f4252005-04-13 14:45:30 +02005923static int patch_stac922x(struct hda_codec *codec)
5924{
5925 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005926 int err;
Matt2f2f4252005-04-13 14:45:30 +02005927
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005928 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005929 if (spec == NULL)
5930 return -ENOMEM;
5931
Takashi Iwaia252c812009-12-25 22:56:20 +01005932 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005933 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005934 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005935 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005936 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005937 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5938 stac922x_models,
5939 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005940 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005941 spec->gpio_mask = spec->gpio_dir = 0x03;
5942 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005943 /* Intel Macs have all same PCI SSID, so we need to check
5944 * codec SSID to distinguish the exact models
5945 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005946 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005947 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005948
5949 case 0x106b0800:
5950 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005951 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005952 case 0x106b0600:
5953 case 0x106b0700:
5954 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005955 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005956 case 0x106b0e00:
5957 case 0x106b0f00:
5958 case 0x106b1600:
5959 case 0x106b1700:
5960 case 0x106b0200:
5961 case 0x106b1e00:
5962 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005963 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005964 case 0x106b1a00:
5965 case 0x00000100:
5966 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005967 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005968 case 0x106b0a00:
5969 case 0x106b2200:
5970 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005971 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005972 default:
5973 spec->board_config = STAC_INTEL_MAC_V3;
5974 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005975 }
5976 }
5977
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005978 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005979 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005980 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5981 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005982 else
5983 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005984 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005985
Matt2f2f4252005-04-13 14:45:30 +02005986 spec->adc_nids = stac922x_adc_nids;
5987 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005988 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005989 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005990 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005991 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005992
5993 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005994
5995 spec->num_caps = STAC922X_NUM_CAPS;
5996 spec->capvols = stac922x_capvols;
5997 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005998
5999 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02006000
Charles Chin9009b0e2011-11-03 10:27:27 +01006001 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006002 if (!err) {
6003 if (spec->board_config < 0) {
6004 printk(KERN_WARNING "hda_codec: No auto-config is "
6005 "available, default to model=ref\n");
6006 spec->board_config = STAC_D945_REF;
6007 goto again;
6008 }
6009 err = -EINVAL;
6010 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006011 if (err < 0) {
6012 stac92xx_free(codec);
6013 return err;
6014 }
6015
6016 codec->patch_ops = stac92xx_patch_ops;
6017
Takashi Iwai807a46362007-05-29 19:01:37 +02006018 /* Fix Mux capture level; max to 2 */
6019 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6020 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6021 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6022 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6023 (0 << AC_AMPCAP_MUTE_SHIFT));
6024
Matt Porter3cc08dc2006-01-23 15:27:49 +01006025 return 0;
6026}
6027
6028static int patch_stac927x(struct hda_codec *codec)
6029{
6030 struct sigmatel_spec *spec;
6031 int err;
6032
6033 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6034 if (spec == NULL)
6035 return -ENOMEM;
6036
Takashi Iwaia252c812009-12-25 22:56:20 +01006037 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006038 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006039 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006040 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006041 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006042 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006043 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6044 stac927x_models,
6045 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006046 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006047 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006048 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6049 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006050 else
6051 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006052 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006053
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006054 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006055 spec->adc_nids = stac927x_adc_nids;
6056 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6057 spec->mux_nids = stac927x_mux_nids;
6058 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006059 spec->smux_nids = stac927x_smux_nids;
6060 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006061 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006062 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006063 spec->multiout.dac_nids = spec->dac_nids;
6064
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006065 if (spec->board_config != STAC_D965_REF) {
6066 /* GPIO0 High = Enable EAPD */
6067 spec->eapd_mask = spec->gpio_mask = 0x01;
6068 spec->gpio_dir = spec->gpio_data = 0x01;
6069 }
6070
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006071 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02006072 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006073 case STAC_D965_5ST:
6074 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006075 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02006076 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006077 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006078 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006079 switch (codec->subsystem_id) {
6080 case 0x10280209:
6081 case 0x1028022e:
6082 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006083 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006084 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006085 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01006086 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01006087 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01006088 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006089 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006090 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01006091 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006092 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006093 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006094 if (codec->subsystem_id != 0x1028022f) {
6095 /* GPIO2 High = Enable EAPD */
6096 spec->eapd_mask = spec->gpio_mask = 0x04;
6097 spec->gpio_dir = spec->gpio_data = 0x04;
6098 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006099 spec->dmic_nids = stac927x_dmic_nids;
6100 spec->num_dmics = STAC927X_NUM_DMICS;
6101
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02006102 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006103 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006104 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006105 break;
Takashi Iwai54930532009-10-11 17:38:29 +02006106 case STAC_927X_VOLKNOB:
6107 spec->num_dmics = 0;
6108 spec->init = stac927x_volknob_core_init;
6109 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006110 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006111 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006112 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006113 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006114 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006115
Takashi Iwai6479c632009-07-28 18:20:25 +02006116 spec->num_caps = STAC927X_NUM_CAPS;
6117 spec->capvols = stac927x_capvols;
6118 spec->capsws = stac927x_capsws;
6119
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006120 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006121 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006122 spec->aloopback_mask = 0x40;
6123 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006124 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006125
Charles Chin9009b0e2011-11-03 10:27:27 +01006126 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006127 if (!err) {
6128 if (spec->board_config < 0) {
6129 printk(KERN_WARNING "hda_codec: No auto-config is "
6130 "available, default to model=ref\n");
6131 spec->board_config = STAC_D965_REF;
6132 goto again;
6133 }
6134 err = -EINVAL;
6135 }
Mattc7d4b2f2005-06-27 14:59:41 +02006136 if (err < 0) {
6137 stac92xx_free(codec);
6138 return err;
6139 }
Matt2f2f4252005-04-13 14:45:30 +02006140
6141 codec->patch_ops = stac92xx_patch_ops;
6142
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006143 codec->proc_widget_hook = stac927x_proc_hook;
6144
Takashi Iwai52987652008-01-16 16:09:47 +01006145 /*
6146 * !!FIXME!!
6147 * The STAC927x seem to require fairly long delays for certain
6148 * command sequences. With too short delays (even if the answer
6149 * is set to RIRB properly), it results in the silence output
6150 * on some hardwares like Dell.
6151 *
6152 * The below flag enables the longer delay (see get_response
6153 * in hda_intel.c).
6154 */
6155 codec->bus->needs_damn_long_delay = 1;
6156
Takashi Iwaie28d8322008-12-17 13:48:29 +01006157 /* no jack detecion for ref-no-jd model */
6158 if (spec->board_config == STAC_D965_REF_NO_JD)
6159 spec->hp_detect = 0;
6160
Matt2f2f4252005-04-13 14:45:30 +02006161 return 0;
6162}
6163
Matt Porterf3302a52006-07-31 12:49:34 +02006164static int patch_stac9205(struct hda_codec *codec)
6165{
6166 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006167 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006168
6169 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6170 if (spec == NULL)
6171 return -ENOMEM;
6172
Takashi Iwaia252c812009-12-25 22:56:20 +01006173 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006174 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006175 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006176 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006177 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006178 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6179 stac9205_models,
6180 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006181 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006182 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006183 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6184 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006185 else
6186 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006187 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006188
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006189 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006190 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006191 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006192 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006193 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006194 spec->smux_nids = stac9205_smux_nids;
6195 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006196 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006197 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006198 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006199 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006200 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006201
6202 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006203 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006204
Takashi Iwai6479c632009-07-28 18:20:25 +02006205 spec->num_caps = STAC9205_NUM_CAPS;
6206 spec->capvols = stac9205_capvols;
6207 spec->capsws = stac9205_capsws;
6208
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006209 spec->aloopback_mask = 0x40;
6210 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006211 /* Turn on/off EAPD per HP plugging */
6212 if (spec->board_config != STAC_9205_EAPD)
6213 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006214 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006215
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006216 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006217 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006218 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006219 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6220 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006221
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006222 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwai3a938972011-10-28 01:16:55 +02006223 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006224 if (err < 0)
6225 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006226 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006227 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
Takashi Iwai3a938972011-10-28 01:16:55 +02006228 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006229
6230 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006231 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006232 spec->gpio_mask = 0x1b;
6233 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006234 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006235 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006236 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006237 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006238 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006239 case STAC_9205_REF:
6240 /* SPDIF-In enabled */
6241 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006242 default:
6243 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006244 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006245 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006246 break;
6247 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006248
Charles Chin9009b0e2011-11-03 10:27:27 +01006249 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006250 if (!err) {
6251 if (spec->board_config < 0) {
6252 printk(KERN_WARNING "hda_codec: No auto-config is "
6253 "available, default to model=ref\n");
6254 spec->board_config = STAC_9205_REF;
6255 goto again;
6256 }
6257 err = -EINVAL;
6258 }
Matt Porterf3302a52006-07-31 12:49:34 +02006259 if (err < 0) {
6260 stac92xx_free(codec);
6261 return err;
6262 }
6263
6264 codec->patch_ops = stac92xx_patch_ops;
6265
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006266 codec->proc_widget_hook = stac9205_proc_hook;
6267
Matt Porterf3302a52006-07-31 12:49:34 +02006268 return 0;
6269}
6270
Matt2f2f4252005-04-13 14:45:30 +02006271/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006272 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006273 */
6274
Takashi Iwai2b635362011-05-02 12:33:43 +02006275static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6278 {}
6279};
6280
Takashi Iwai2b635362011-05-02 12:33:43 +02006281static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006282 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6283 0x11, 0x13, 0x14,
6284};
6285
Takashi Iwai2b635362011-05-02 12:33:43 +02006286static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006287 0x8 /*,0x6*/
6288};
6289
Takashi Iwai2b635362011-05-02 12:33:43 +02006290static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006291 0x15
6292};
6293
Takashi Iwai2b635362011-05-02 12:33:43 +02006294static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006295 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6296};
6297#define stac9872_capsws stac9872_capvols
6298
Takashi Iwai2b635362011-05-02 12:33:43 +02006299static const unsigned int stac9872_vaio_pin_configs[9] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006300 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6301 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6302 0x90a7013e
6303};
6304
Takashi Iwaiea734962011-01-17 11:29:34 +01006305static const char * const stac9872_models[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006306 [STAC_9872_AUTO] = "auto",
6307 [STAC_9872_VAIO] = "vaio",
6308};
6309
Takashi Iwai2b635362011-05-02 12:33:43 +02006310static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006311 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6312};
6313
Takashi Iwai2b635362011-05-02 12:33:43 +02006314static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006315 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6316 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006317 {} /* terminator */
6318};
6319
Guillaume Munch6d859062006-08-22 17:15:47 +02006320static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006321{
6322 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006323 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006324
Takashi Iwaidb064e52006-03-16 16:04:58 +01006325 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6326 if (spec == NULL)
6327 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006328 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006329 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006330 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006331 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6332 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006333
6334 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6335 stac9872_models,
6336 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006337 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006338 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6339 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006340 else
6341 stac92xx_set_config_regs(codec,
6342 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006343
Takashi Iwai1e137f92009-01-21 07:41:22 +01006344 spec->multiout.dac_nids = spec->dac_nids;
6345 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6346 spec->adc_nids = stac9872_adc_nids;
6347 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6348 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006349 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006350 spec->num_caps = 1;
6351 spec->capvols = stac9872_capvols;
6352 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006353
Charles Chin9009b0e2011-11-03 10:27:27 +01006354 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01006355 if (err < 0) {
6356 stac92xx_free(codec);
6357 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006358 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006359 spec->input_mux = &spec->private_imux;
6360 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006361 return 0;
6362}
6363
6364
6365/*
Matt2f2f4252005-04-13 14:45:30 +02006366 * patch entries
6367 */
Takashi Iwai2b635362011-05-02 12:33:43 +02006368static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006369 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6370 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6371 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6372 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6373 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6374 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6375 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006376 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6377 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6378 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6379 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6380 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6381 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006382 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6383 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6384 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6385 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6386 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6387 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6388 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6389 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6390 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6391 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006392 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6393 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6394 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6395 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6396 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6397 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006398 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6399 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006400 /* The following does not take into account .id=0x83847661 when subsys =
6401 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6402 * currently not fully supported.
6403 */
6404 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6405 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6406 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006407 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006408 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6409 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6410 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6411 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6412 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6413 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6414 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6415 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006416 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006417 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006418 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006419 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006420 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02006421 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6422 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006423 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6424 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6425 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6426 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006427 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006428 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6429 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006430 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006431 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6432 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6433 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6434 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6435 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6436 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6437 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6438 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02006439 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6440 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6441 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6442 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6443 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6444 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6445 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6446 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6447 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6448 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6449 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6450 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6451 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6452 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6453 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02006454 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006455 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06006456 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6457 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006458 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01006459 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6460 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6461 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6462 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6463 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6464 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6465 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6466 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6467 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6468 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6469 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6470 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02006471 {} /* terminator */
6472};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006473
6474MODULE_ALIAS("snd-hda-codec-id:8384*");
6475MODULE_ALIAS("snd-hda-codec-id:111d*");
6476
6477MODULE_LICENSE("GPL");
6478MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6479
6480static struct hda_codec_preset_list sigmatel_list = {
6481 .preset = snd_hda_preset_sigmatel,
6482 .owner = THIS_MODULE,
6483};
6484
6485static int __init patch_sigmatel_init(void)
6486{
6487 return snd_hda_add_codec_preset(&sigmatel_list);
6488}
6489
6490static void __exit patch_sigmatel_exit(void)
6491{
6492 snd_hda_delete_codec_preset(&sigmatel_list);
6493}
6494
6495module_init(patch_sigmatel_init)
6496module_exit(patch_sigmatel_exit)