blob: baf1edde244d45c5bfdb45ea80afbbb9e9686470 [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,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200104 STAC_92HD83XXX_MODELS
105};
106
107enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100108 STAC_92HD71BXX_AUTO,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100109 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +0100110 STAC_DELL_M4_1,
111 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -0500112 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -0400113 STAC_HP_M4,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +0200114 STAC_HP_DV4,
Takashi Iwai1b0652e2009-01-14 08:27:35 +0100115 STAC_HP_DV5,
Christoph Plattnerae6241f2009-03-08 23:19:05 +0100116 STAC_HP_HDX,
James Gardiner514bf542009-05-03 04:00:44 -0400117 STAC_HP_DV4_1222NR,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100118 STAC_92HD71BXX_MODELS
119};
120
121enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100122 STAC_925x_AUTO,
Tobin Davis8e21c342007-01-08 11:04:17 +0100123 STAC_925x_REF,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200124 STAC_M1,
125 STAC_M1_2,
126 STAC_M2,
Tobin Davis8e21c342007-01-08 11:04:17 +0100127 STAC_M2_2,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +0200128 STAC_M3,
129 STAC_M5,
130 STAC_M6,
Tobin Davis8e21c342007-01-08 11:04:17 +0100131 STAC_925x_MODELS
132};
133
134enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100135 STAC_922X_AUTO,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100136 STAC_D945_REF,
137 STAC_D945GTP3,
138 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200139 STAC_INTEL_MAC_V1,
140 STAC_INTEL_MAC_V2,
141 STAC_INTEL_MAC_V3,
142 STAC_INTEL_MAC_V4,
143 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800144 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
145 * is given, one of the above models will be
146 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200147 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100148 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100149 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100150 STAC_MACBOOK_PRO_V1,
151 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200152 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200153 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300154 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200155 STAC_922X_DELL_D81,
156 STAC_922X_DELL_D82,
157 STAC_922X_DELL_M81,
158 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100159 STAC_922X_MODELS
160};
161
162enum {
Takashi Iwai1607b8e2009-02-26 16:50:43 +0100163 STAC_927X_AUTO,
Takashi Iwaie28d8322008-12-17 13:48:29 +0100164 STAC_D965_REF_NO_JD, /* no jack-detection */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100165 STAC_D965_REF,
166 STAC_D965_3ST,
167 STAC_D965_5ST,
Takashi Iwai679d92e2009-05-24 19:00:08 +0200168 STAC_D965_5ST_NO_FP,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200169 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100170 STAC_DELL_BIOS,
Takashi Iwai54930532009-10-11 17:38:29 +0200171 STAC_927X_VOLKNOB,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100172 STAC_927X_MODELS
173};
Matt Porter403d1942005-11-29 15:00:51 +0100174
Takashi Iwai307282c2009-03-12 18:17:58 +0100175enum {
176 STAC_9872_AUTO,
177 STAC_9872_VAIO,
178 STAC_9872_MODELS
179};
180
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200181struct sigmatel_mic_route {
182 hda_nid_t pin;
Takashi Iwai02d33322009-10-01 16:38:11 +0200183 signed char mux_idx;
184 signed char dmux_idx;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200185};
186
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600187#define MAX_PINS_NUM 16
188#define MAX_ADCS_NUM 4
189#define MAX_DMICS_NUM 4
190
Matt2f2f4252005-04-13 14:45:30 +0200191struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100192 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200193 unsigned int num_mixers;
194
Matt Porter403d1942005-11-29 15:00:51 +0100195 int board_config;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -0500196 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200197 unsigned int surr_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100198 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100199 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400200 unsigned int spdif_mute: 1;
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100201 unsigned int check_volume_offset:1;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200202 unsigned int auto_mic:1;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +0100203 unsigned int linear_tone_beep:1;
Mattc7d4b2f2005-06-27 14:59:41 +0200204
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100205 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200206 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100207 unsigned int gpio_mask;
208 unsigned int gpio_dir;
209 unsigned int gpio_data;
210 unsigned int gpio_mute;
Takashi Iwai86d190e2009-05-26 15:18:58 +0200211 unsigned int gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +0100212 unsigned int gpio_led_polarity;
Takashi Iwaif1a73742011-12-04 13:44:06 +0100213 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500214 unsigned int vref_led;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100215
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200216 /* stream */
217 unsigned int stream_delay;
218
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100219 /* analog loopback */
Takashi Iwai2b635362011-05-02 12:33:43 +0200220 const struct snd_kcontrol_new *aloopback_ctl;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100221 unsigned char aloopback_mask;
222 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200223
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100224 /* power management */
225 unsigned int num_pwrs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200226 const hda_nid_t *pwr_nids;
227 const hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100228
Matt2f2f4252005-04-13 14:45:30 +0200229 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100230 struct hda_input_mux *mono_mux;
231 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200232 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100233 hda_nid_t dac_nids[5];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100234 hda_nid_t hp_dacs[5];
235 hda_nid_t speaker_dacs[5];
Matt2f2f4252005-04-13 14:45:30 +0200236
Takashi Iwai7c7767e2009-01-20 15:28:38 +0100237 int volume_offset;
238
Matt2f2f4252005-04-13 14:45:30 +0200239 /* capture */
Takashi Iwai2b635362011-05-02 12:33:43 +0200240 const hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200241 unsigned int num_adcs;
Takashi Iwai2b635362011-05-02 12:33:43 +0200242 const hda_nid_t *mux_nids;
Mattdabbed62005-06-14 10:19:34 +0200243 unsigned int num_muxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200244 const hda_nid_t *dmic_nids;
Matt Porter8b657272006-10-26 17:12:59 +0200245 unsigned int num_dmics;
Takashi Iwai2b635362011-05-02 12:33:43 +0200246 const hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100247 unsigned int num_dmuxes;
Takashi Iwai2b635362011-05-02 12:33:43 +0200248 const hda_nid_t *smux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200249 unsigned int num_smuxes;
Takashi Iwai5207e102009-07-30 13:09:08 +0200250 unsigned int num_analog_muxes;
Takashi Iwai6479c632009-07-28 18:20:25 +0200251
Takashi Iwai2b635362011-05-02 12:33:43 +0200252 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
253 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
Takashi Iwai6479c632009-07-28 18:20:25 +0200254 unsigned int num_caps; /* number of capture volume/switch elements */
255
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200256 struct sigmatel_mic_route ext_mic;
257 struct sigmatel_mic_route int_mic;
Charles Chin99077902010-09-17 10:22:32 +0200258 struct sigmatel_mic_route dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +0200259
Takashi Iwaiea734962011-01-17 11:29:34 +0100260 const char * const *spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200261
Mattdabbed62005-06-14 10:19:34 +0200262 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100263 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200264 hda_nid_t anabeep_nid;
265 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200266
Matt2f2f4252005-04-13 14:45:30 +0200267 /* pin widgets */
Takashi Iwai2b635362011-05-02 12:33:43 +0200268 const hda_nid_t *pin_nids;
Matt2f2f4252005-04-13 14:45:30 +0200269 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200270
271 /* codec specific stuff */
Takashi Iwai2b635362011-05-02 12:33:43 +0200272 const struct hda_verb *init;
273 const struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200274
275 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200276 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100277 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200278 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100279 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200280 struct hda_input_mux *sinput_mux;
281 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400282 unsigned int cur_amux;
283 hda_nid_t *amp_nids;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200284 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200285
Matt Porter403d1942005-11-29 15:00:51 +0100286 /* i/o switches */
287 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200288 unsigned int clfe_swap;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +0100289 hda_nid_t line_switch; /* shared line-in for input and output */
290 hda_nid_t mic_switch; /* shared mic-in for input and output */
291 hda_nid_t hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200292 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200293
Mattc7d4b2f2005-06-27 14:59:41 +0200294 struct hda_pcm pcm_rec[2]; /* PCM information */
295
296 /* dynamic controls and input_mux */
297 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200298 struct snd_array kctls;
Matt Porter8b657272006-10-26 17:12:59 +0200299 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200300 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200301 struct hda_input_mux private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100302 struct hda_input_mux private_mono_mux;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600303
304 /* auto spec */
305 unsigned auto_pin_cnt;
306 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
307 unsigned auto_adc_cnt;
308 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
309 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
310 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
311 unsigned long auto_capvols[MAX_ADCS_NUM];
312 unsigned auto_dmic_cnt;
313 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
Takashi Iwai2faa3bf2012-03-12 12:30:22 +0100314
Takashi Iwaid2f344b2012-03-12 16:59:58 +0100315 struct hda_vmaster_mute_hook vmaster_mute;
Matt2f2f4252005-04-13 14:45:30 +0200316};
317
Takashi Iwai2b635362011-05-02 12:33:43 +0200318static const hda_nid_t stac9200_adc_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200319 0x03,
320};
321
Takashi Iwai2b635362011-05-02 12:33:43 +0200322static const hda_nid_t stac9200_mux_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200323 0x0c,
324};
325
Takashi Iwai2b635362011-05-02 12:33:43 +0200326static const hda_nid_t stac9200_dac_nids[1] = {
Matt2f2f4252005-04-13 14:45:30 +0200327 0x02,
328};
329
Takashi Iwai2b635362011-05-02 12:33:43 +0200330static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100331 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
332 0x0f, 0x10, 0x11
333};
334
Takashi Iwai2b635362011-05-02 12:33:43 +0200335static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400336 0x26, 0,
337};
338
Takashi Iwai2b635362011-05-02 12:33:43 +0200339static const hda_nid_t stac92hd73xx_adc_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100340 0x1a, 0x1b
341};
342
343#define STAC92HD73XX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200344static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100345 0x13, 0x14, 0
346};
347
348#define STAC92HD73_DAC_COUNT 5
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100349
Takashi Iwai2b635362011-05-02 12:33:43 +0200350static const hda_nid_t stac92hd73xx_mux_nids[2] = {
Takashi Iwaie2aec172009-09-02 01:00:05 +0200351 0x20, 0x21,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100352};
353
Takashi Iwai2b635362011-05-02 12:33:43 +0200354static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100355 0x20, 0x21,
356};
357
Takashi Iwai2b635362011-05-02 12:33:43 +0200358static const hda_nid_t stac92hd73xx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200359 0x22, 0x23,
360};
361
Takashi Iwai6479c632009-07-28 18:20:25 +0200362#define STAC92HD73XX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200363static const unsigned long stac92hd73xx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200364 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
365 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
366};
367#define stac92hd73xx_capsws stac92hd73xx_capvols
368
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200369#define STAC92HD83_DAC_COUNT 3
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200370
Charles Chinafef2cf2011-11-11 08:05:28 +0100371static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
372 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
373 0x0f, 0x10
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200374};
375
Takashi Iwai2b635362011-05-02 12:33:43 +0200376static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400377 0x1e, 0,
378};
379
Takashi Iwai2b635362011-05-02 12:33:43 +0200380static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
Vitaliy Kulikov699d8992011-03-10 13:43:35 -0600381 0x11, 0x20,
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +0200382};
383
Takashi Iwai2b635362011-05-02 12:33:43 +0200384static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100385 0x0a, 0x0d, 0x0f
386};
387
Takashi Iwai2b635362011-05-02 12:33:43 +0200388static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100389 0x12, 0x13,
390};
391
Takashi Iwai2b635362011-05-02 12:33:43 +0200392static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100393 0x1a, 0x1b
394};
395
Takashi Iwai2b635362011-05-02 12:33:43 +0200396static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400397 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100398};
399
Takashi Iwai2b635362011-05-02 12:33:43 +0200400static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200401 0x24, 0x25,
402};
403
Matthew Ranostaye035b842007-11-06 11:53:55 +0100404#define STAC92HD71BXX_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200405static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100406 0x18, 0x19, 0
407};
408
Takashi Iwai2b635362011-05-02 12:33:43 +0200409static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
410 0x18, 0
411};
412
413static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400414 0x22, 0
415};
416
Takashi Iwai6479c632009-07-28 18:20:25 +0200417#define STAC92HD71BXX_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200418static const unsigned long stac92hd71bxx_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200419 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
420 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
421};
422#define stac92hd71bxx_capsws stac92hd71bxx_capvols
423
Takashi Iwai2b635362011-05-02 12:33:43 +0200424static const hda_nid_t stac925x_adc_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100425 0x03,
426};
427
Takashi Iwai2b635362011-05-02 12:33:43 +0200428static const hda_nid_t stac925x_mux_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100429 0x0f,
430};
431
Takashi Iwai2b635362011-05-02 12:33:43 +0200432static const hda_nid_t stac925x_dac_nids[1] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100433 0x02,
434};
435
Takashi Iwaif6e98522007-10-16 14:27:04 +0200436#define STAC925X_NUM_DMICS 1
Takashi Iwai2b635362011-05-02 12:33:43 +0200437static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200438 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200439};
440
Takashi Iwai2b635362011-05-02 12:33:43 +0200441static const hda_nid_t stac925x_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100442 0x14,
443};
444
Takashi Iwai2b635362011-05-02 12:33:43 +0200445static const unsigned long stac925x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200446 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
447};
Takashi Iwai2b635362011-05-02 12:33:43 +0200448static const unsigned long stac925x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200449 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
450};
451
Takashi Iwai2b635362011-05-02 12:33:43 +0200452static const hda_nid_t stac922x_adc_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200453 0x06, 0x07,
454};
455
Takashi Iwai2b635362011-05-02 12:33:43 +0200456static const hda_nid_t stac922x_mux_nids[2] = {
Matt2f2f4252005-04-13 14:45:30 +0200457 0x12, 0x13,
458};
459
Takashi Iwai6479c632009-07-28 18:20:25 +0200460#define STAC922X_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200461static const unsigned long stac922x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200462 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
463 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
464};
465#define stac922x_capsws stac922x_capvols
466
Takashi Iwai2b635362011-05-02 12:33:43 +0200467static const hda_nid_t stac927x_slave_dig_outs[2] = {
Matthew Ranostay45c1d852009-02-04 17:49:41 -0500468 0x1f, 0,
469};
470
Takashi Iwai2b635362011-05-02 12:33:43 +0200471static const hda_nid_t stac927x_adc_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100472 0x07, 0x08, 0x09
473};
474
Takashi Iwai2b635362011-05-02 12:33:43 +0200475static const hda_nid_t stac927x_mux_nids[3] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100476 0x15, 0x16, 0x17
477};
478
Takashi Iwai2b635362011-05-02 12:33:43 +0200479static const hda_nid_t stac927x_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200480 0x21,
481};
482
Takashi Iwai2b635362011-05-02 12:33:43 +0200483static const hda_nid_t stac927x_dac_nids[6] = {
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100484 0x02, 0x03, 0x04, 0x05, 0x06, 0
485};
486
Takashi Iwai2b635362011-05-02 12:33:43 +0200487static const hda_nid_t stac927x_dmux_nids[1] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100488 0x1b,
489};
490
Matthew Ranostay7f168592007-10-18 17:38:17 +0200491#define STAC927X_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200492static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
Matthew Ranostay7f168592007-10-18 17:38:17 +0200493 0x13, 0x14, 0
494};
495
Takashi Iwai6479c632009-07-28 18:20:25 +0200496#define STAC927X_NUM_CAPS 3
Takashi Iwai2b635362011-05-02 12:33:43 +0200497static const unsigned long stac927x_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200498 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
500 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
501};
Takashi Iwai2b635362011-05-02 12:33:43 +0200502static const unsigned long stac927x_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200503 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
505 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
506};
507
Takashi Iwaiea734962011-01-17 11:29:34 +0100508static const char * const stac927x_spdif_labels[5] = {
Matthew Ranostay65973632008-09-16 10:39:37 -0400509 "Digital Playback", "ADAT", "Analog Mux 1",
510 "Analog Mux 2", "Analog Mux 3"
511};
512
Takashi Iwai2b635362011-05-02 12:33:43 +0200513static const hda_nid_t stac9205_adc_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200514 0x12, 0x13
515};
516
Takashi Iwai2b635362011-05-02 12:33:43 +0200517static const hda_nid_t stac9205_mux_nids[2] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200518 0x19, 0x1a
519};
520
Takashi Iwai2b635362011-05-02 12:33:43 +0200521static const hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100522 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100523};
524
Takashi Iwai2b635362011-05-02 12:33:43 +0200525static const hda_nid_t stac9205_smux_nids[1] = {
Matthew Ranostayd9737752008-09-07 12:03:41 +0200526 0x21,
527};
528
Takashi Iwaif6e98522007-10-16 14:27:04 +0200529#define STAC9205_NUM_DMICS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200530static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
Takashi Iwaif6e98522007-10-16 14:27:04 +0200531 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200532};
533
Takashi Iwai6479c632009-07-28 18:20:25 +0200534#define STAC9205_NUM_CAPS 2
Takashi Iwai2b635362011-05-02 12:33:43 +0200535static const unsigned long stac9205_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200536 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
537 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
538};
Takashi Iwai2b635362011-05-02 12:33:43 +0200539static const unsigned long stac9205_capsws[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +0200540 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
541 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
542};
543
Takashi Iwai2b635362011-05-02 12:33:43 +0200544static const hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200545 0x08, 0x09, 0x0d, 0x0e,
546 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200547};
548
Takashi Iwai2b635362011-05-02 12:33:43 +0200549static const hda_nid_t stac925x_pin_nids[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100550 0x07, 0x08, 0x0a, 0x0b,
551 0x0c, 0x0d, 0x10, 0x11,
552};
553
Takashi Iwai2b635362011-05-02 12:33:43 +0200554static const hda_nid_t stac922x_pin_nids[10] = {
Matt2f2f4252005-04-13 14:45:30 +0200555 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
556 0x0f, 0x10, 0x11, 0x15, 0x1b,
557};
558
Takashi Iwai2b635362011-05-02 12:33:43 +0200559static const hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100560 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
561 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200562 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100563};
564
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500565#define STAC92HD71BXX_NUM_PINS 13
Takashi Iwai2b635362011-05-02 12:33:43 +0200566static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500567 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
568 0x00, 0x14, 0x18, 0x19, 0x1e,
569 0x1f, 0x20, 0x27
570};
Takashi Iwai2b635362011-05-02 12:33:43 +0200571static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100572 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
573 0x0f, 0x14, 0x18, 0x19, 0x1e,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -0500574 0x1f, 0x20, 0x27
Matthew Ranostaye035b842007-11-06 11:53:55 +0100575};
576
Takashi Iwai2b635362011-05-02 12:33:43 +0200577static const hda_nid_t stac927x_pin_nids[14] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100578 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
579 0x0f, 0x10, 0x11, 0x12, 0x13,
580 0x14, 0x21, 0x22, 0x23,
581};
582
Takashi Iwai2b635362011-05-02 12:33:43 +0200583static const hda_nid_t stac9205_pin_nids[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200584 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
585 0x0f, 0x14, 0x16, 0x17, 0x18,
586 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200587};
588
Matt Porter8b657272006-10-26 17:12:59 +0200589static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_info *uinfo)
591{
592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 struct sigmatel_spec *spec = codec->spec;
594 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
595}
596
597static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_value *ucontrol)
599{
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100602 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200603
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100604 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200605 return 0;
606}
607
608static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
610{
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100613 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200614
615 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100616 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200617}
618
Matthew Ranostayd9737752008-09-07 12:03:41 +0200619static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
620 struct snd_ctl_elem_info *uinfo)
621{
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 struct sigmatel_spec *spec = codec->spec;
624 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
625}
626
627static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_value *ucontrol)
629{
630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
631 struct sigmatel_spec *spec = codec->spec;
632 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
633
634 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
635 return 0;
636}
637
638static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
639 struct snd_ctl_elem_value *ucontrol)
640{
641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
642 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400643 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200644 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400645 int err, val;
646 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200647
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400648 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200649 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400650 if (err < 0)
651 return err;
652
653 if (spec->spdif_mute) {
654 if (smux_idx == 0)
655 nid = spec->multiout.dig_out_nid;
656 else
657 nid = codec->slave_dig_outs[smux_idx - 1];
658 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100659 val = HDA_AMP_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400660 else
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100661 val = 0;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400662 /* un/mute SPDIF out */
Takashi Iwaic9b46f92008-12-01 11:42:09 +0100663 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
664 HDA_AMP_MUTE, val);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400665 }
666 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200667}
668
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500669static int stac_vrefout_set(struct hda_codec *codec,
670 hda_nid_t nid, unsigned int new_vref)
671{
672 int error, pinctl;
673
674 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
675 pinctl = snd_hda_codec_read(codec, nid, 0,
676 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
677
678 if (pinctl < 0)
679 return pinctl;
680
681 pinctl &= 0xff;
682 pinctl &= ~AC_PINCTL_VREFEN;
683 pinctl |= (new_vref & AC_PINCTL_VREFEN);
684
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200685 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -0500686 if (error < 0)
687 return error;
688
689 return 1;
690}
691
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200692static unsigned int stac92xx_vref_set(struct hda_codec *codec,
693 hda_nid_t nid, unsigned int new_vref)
694{
Takashi Iwaib8621512009-06-22 08:00:10 +0200695 int error;
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200696 unsigned int pincfg;
697 pincfg = snd_hda_codec_read(codec, nid, 0,
698 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
699
700 pincfg &= 0xff;
701 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
702 pincfg |= new_vref;
703
704 if (new_vref == AC_PINCTL_VREF_HIZ)
705 pincfg |= AC_PINCTL_OUT_EN;
706 else
707 pincfg |= AC_PINCTL_IN_EN;
708
Takashi Iwaicdd03ce2012-04-20 12:34:50 +0200709 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200710 if (error < 0)
711 return error;
712 else
713 return 1;
714}
715
716static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
717{
718 unsigned int vref;
719 vref = snd_hda_codec_read(codec, nid, 0,
720 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
721 vref &= AC_PINCTL_VREFEN;
722 return vref;
723}
724
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100725static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200726{
727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
728 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200729 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200730}
731
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100732static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200733{
734 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
735 struct sigmatel_spec *spec = codec->spec;
736 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
737
738 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
739 return 0;
740}
741
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100742static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200743{
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 struct sigmatel_spec *spec = codec->spec;
746 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai5207e102009-07-30 13:09:08 +0200747 const struct hda_input_mux *imux = spec->input_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600748 unsigned int idx, prev_idx, didx;
Matt2f2f4252005-04-13 14:45:30 +0200749
Takashi Iwai5207e102009-07-30 13:09:08 +0200750 idx = ucontrol->value.enumerated.item[0];
751 if (idx >= imux->num_items)
752 idx = imux->num_items - 1;
753 prev_idx = spec->cur_mux[adc_idx];
754 if (prev_idx == idx)
755 return 0;
756 if (idx < spec->num_analog_muxes) {
757 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
758 AC_VERB_SET_CONNECT_SEL,
759 imux->items[idx].index);
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600760 if (prev_idx >= spec->num_analog_muxes &&
761 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
Takashi Iwai5207e102009-07-30 13:09:08 +0200762 imux = spec->dinput_mux;
763 /* 0 = analog */
764 snd_hda_codec_write_cache(codec,
765 spec->dmux_nids[adc_idx], 0,
766 AC_VERB_SET_CONNECT_SEL,
767 imux->items[0].index);
768 }
769 } else {
770 imux = spec->dinput_mux;
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600771 /* first dimux item is hardcoded to select analog imux,
772 * so lets skip it
773 */
774 didx = idx - spec->num_analog_muxes + 1;
Takashi Iwai5207e102009-07-30 13:09:08 +0200775 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
776 AC_VERB_SET_CONNECT_SEL,
Vitaliy Kulikov094a4242011-03-09 19:47:43 -0600777 imux->items[didx].index);
Takashi Iwai5207e102009-07-30 13:09:08 +0200778 }
779 spec->cur_mux[adc_idx] = idx;
780 return 1;
Matt2f2f4252005-04-13 14:45:30 +0200781}
782
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100783static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
784 struct snd_ctl_elem_info *uinfo)
785{
786 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
787 struct sigmatel_spec *spec = codec->spec;
788 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
789}
790
791static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
792 struct snd_ctl_elem_value *ucontrol)
793{
794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
795 struct sigmatel_spec *spec = codec->spec;
796
797 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
798 return 0;
799}
800
801static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
803{
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
806
807 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
808 spec->mono_nid, &spec->cur_mmux);
809}
810
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200811#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
812
813static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
814 struct snd_ctl_elem_value *ucontrol)
815{
816 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100817 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200818 struct sigmatel_spec *spec = codec->spec;
819
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100820 ucontrol->value.integer.value[0] = !!(spec->aloopback &
821 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200822 return 0;
823}
824
825static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
826 struct snd_ctl_elem_value *ucontrol)
827{
828 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
829 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100830 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200831 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100832 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200833
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100834 idx_val = spec->aloopback_mask << idx;
835 if (ucontrol->value.integer.value[0])
836 val = spec->aloopback | idx_val;
837 else
838 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100839 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200840 return 0;
841
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100842 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200843
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100844 /* Only return the bits defined by the shift value of the
845 * first two bytes of the mask
846 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200847 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100848 kcontrol->private_value & 0xFFFF, 0x0);
849 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200850
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100851 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200852 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100853 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200854 } else {
855 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100856 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200857 }
858
859 snd_hda_codec_write_cache(codec, codec->afg, 0,
860 kcontrol->private_value >> 16, dac_mode);
861
862 return 1;
863}
864
Takashi Iwai2b635362011-05-02 12:33:43 +0200865static const struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200866 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200867 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200868 {}
869};
870
Takashi Iwai2b635362011-05-02 12:33:43 +0200871static const struct hda_verb stac9200_eapd_init[] = {
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200872 /* set dac0mux for dac converter */
873 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
874 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
875 {}
876};
877
Takashi Iwai2b635362011-05-02 12:33:43 +0200878static const struct hda_verb dell_eq_core_init[] = {
Matthew Ranostayd654a662008-03-14 08:46:51 +0100879 /* set master volume to max value without distortion
880 * and direct control */
881 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100882 {}
883};
884
Takashi Iwai2b635362011-05-02 12:33:43 +0200885static const struct hda_verb stac92hd73xx_core_init[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100886 /* set master volume and direct control */
887 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100888 {}
889};
890
Takashi Iwai2b635362011-05-02 12:33:43 +0200891static const struct hda_verb stac92hd83xxx_core_init[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200892 /* power state controls amps */
893 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200894 {}
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200895};
896
Vitaliy Kulikov5556e142012-02-27 16:47:37 -0600897static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
898 { 0x22, 0x785, 0x43 },
899 { 0x22, 0x782, 0xe0 },
900 { 0x22, 0x795, 0x00 },
901 {}
902};
903
Takashi Iwai2b635362011-05-02 12:33:43 +0200904static const struct hda_verb stac92hd71bxx_core_init[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100905 /* set master volume and direct control */
906 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -0200907 {}
Matthew Ranostay541eee82007-12-14 12:08:04 +0100908};
909
Takashi Iwai2b635362011-05-02 12:33:43 +0200910static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
Matthew Ranostayca8d33f2009-01-26 09:33:52 -0500911 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
912 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100913 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
914 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100915 {}
916};
917
Takashi Iwai2b635362011-05-02 12:33:43 +0200918static const struct hda_verb stac925x_core_init[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +0100919 /* set dac0mux for dac converter */
920 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaic9280d62009-01-15 17:31:00 +0100921 /* mute the master volume */
922 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Tobin Davis8e21c342007-01-08 11:04:17 +0100923 {}
924};
925
Takashi Iwai2b635362011-05-02 12:33:43 +0200926static const struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200927 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200928 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200929 {}
930};
931
Takashi Iwai2b635362011-05-02 12:33:43 +0200932static const struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200933 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200934 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200935 /* unmute node 0x1b */
936 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
937 /* select node 0x03 as DAC */
938 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
939 {}
940};
941
Takashi Iwai2b635362011-05-02 12:33:43 +0200942static const struct hda_verb dell_3st_core_init[] = {
Takashi Iwaiccca7cd2009-10-13 15:32:21 +0200943 /* don't set delta bit */
944 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
945 /* unmute node 0x1b */
946 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
947 /* select node 0x03 as DAC */
948 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
949 {}
950};
951
Takashi Iwai2b635362011-05-02 12:33:43 +0200952static const struct hda_verb stac927x_core_init[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100953 /* set master volume and direct control */
954 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200955 /* enable analog pc beep path */
956 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100957 {}
958};
959
Takashi Iwai2b635362011-05-02 12:33:43 +0200960static const struct hda_verb stac927x_volknob_core_init[] = {
Takashi Iwai54930532009-10-11 17:38:29 +0200961 /* don't set delta bit */
962 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
963 /* enable analog pc beep path */
964 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
965 {}
966};
967
Takashi Iwai2b635362011-05-02 12:33:43 +0200968static const struct hda_verb stac9205_core_init[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200969 /* set master volume and direct control */
970 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200971 /* enable analog pc beep path */
972 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200973 {}
974};
975
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100976#define STAC_MONO_MUX \
977 { \
978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
979 .name = "Mono Mux", \
980 .count = 1, \
981 .info = stac92xx_mono_mux_enum_info, \
982 .get = stac92xx_mono_mux_enum_get, \
983 .put = stac92xx_mono_mux_enum_put, \
984 }
985
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100986#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200987 { \
988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
989 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100990 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200991 .info = stac92xx_aloopback_info, \
992 .get = stac92xx_aloopback_get, \
993 .put = stac92xx_aloopback_put, \
994 .private_value = verb_read | (verb_write << 16), \
995 }
996
Nickolas Lloyd2fc99892009-05-15 15:33:30 +0200997#define DC_BIAS(xname, idx, nid) \
998 { \
999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1000 .name = xname, \
1001 .index = idx, \
1002 .info = stac92xx_dc_bias_info, \
1003 .get = stac92xx_dc_bias_get, \
1004 .put = stac92xx_dc_bias_put, \
1005 .private_value = nid, \
1006 }
1007
Takashi Iwai2b635362011-05-02 12:33:43 +02001008static const struct snd_kcontrol_new stac9200_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001009 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1010 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001011 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1012 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +02001013 { } /* end */
1014};
1015
Takashi Iwai2b635362011-05-02 12:33:43 +02001016static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1018 {}
1019};
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001020
Takashi Iwai2b635362011-05-02 12:33:43 +02001021static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001022 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1023 {}
1024};
1025
Takashi Iwai2b635362011-05-02 12:33:43 +02001026static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1028 {}
1029};
1030
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001031
Takashi Iwai2b635362011-05-02 12:33:43 +02001032static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001033 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1034};
Matthew Ranostay541eee82007-12-14 12:08:04 +01001035
Takashi Iwai2b635362011-05-02 12:33:43 +02001036static const struct snd_kcontrol_new stac925x_mixer[] = {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001037 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1038 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001039 { } /* end */
1040};
1041
Takashi Iwai2b635362011-05-02 12:33:43 +02001042static const struct snd_kcontrol_new stac9205_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001043 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1044 {}
1045};
1046
Takashi Iwai2b635362011-05-02 12:33:43 +02001047static const struct snd_kcontrol_new stac927x_loopback[] = {
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001048 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1049 {}
1050};
1051
Takashi Iwai1697055e2007-12-18 18:05:52 +01001052static struct snd_kcontrol_new stac_dmux_mixer = {
1053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1054 .name = "Digital Input Source",
1055 /* count set later */
1056 .info = stac92xx_dmux_enum_info,
1057 .get = stac92xx_dmux_enum_get,
1058 .put = stac92xx_dmux_enum_put,
1059};
1060
Matthew Ranostayd9737752008-09-07 12:03:41 +02001061static struct snd_kcontrol_new stac_smux_mixer = {
1062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001063 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001064 /* count set later */
1065 .info = stac92xx_smux_enum_info,
1066 .get = stac92xx_smux_enum_get,
1067 .put = stac92xx_smux_enum_put,
1068};
1069
Takashi Iwai9322ca52012-02-03 14:28:01 +01001070static const char * const slave_pfxs[] = {
1071 "Front", "Surround", "Center", "LFE", "Side",
1072 "Headphone", "Speaker", "IEC958",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001073 NULL
1074};
1075
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001076static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1077
1078static void stac92xx_vmaster_hook(void *private_data, int val)
1079{
1080 stac92xx_update_led_status(private_data, val);
1081}
1082
Takashi Iwai603c4012008-07-30 15:01:44 +02001083static void stac92xx_free_kctls(struct hda_codec *codec);
1084
Matt2f2f4252005-04-13 14:45:30 +02001085static int stac92xx_build_controls(struct hda_codec *codec)
1086{
1087 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001088 unsigned int vmaster_tlv[4];
Matt2f2f4252005-04-13 14:45:30 +02001089 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001090 int i;
Matt2f2f4252005-04-13 14:45:30 +02001091
Takashi Iwai6479c632009-07-28 18:20:25 +02001092 if (spec->mixer) {
1093 err = snd_hda_add_new_ctls(codec, spec->mixer);
1094 if (err < 0)
1095 return err;
1096 }
Mattc7d4b2f2005-06-27 14:59:41 +02001097
1098 for (i = 0; i < spec->num_mixers; i++) {
1099 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1100 if (err < 0)
1101 return err;
1102 }
Takashi Iwai5207e102009-07-30 13:09:08 +02001103 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1104 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
Takashi Iwai1697055e2007-12-18 18:05:52 +01001105 stac_dmux_mixer.count = spec->num_dmuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001106 err = snd_hda_ctl_add(codec, 0,
Takashi Iwai1697055e2007-12-18 18:05:52 +01001107 snd_ctl_new1(&stac_dmux_mixer, codec));
1108 if (err < 0)
1109 return err;
1110 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001111 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001112 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1113 struct hda_input_mux *smux = &spec->private_smux;
1114 /* check for mute support on SPDIF out */
1115 if (wcaps & AC_WCAP_OUT_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +02001116 snd_hda_add_imux_item(smux, "Off", 0, NULL);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001117 spec->spdif_mute = 1;
1118 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001119 stac_smux_mixer.count = spec->num_smuxes;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01001120 err = snd_hda_ctl_add(codec, 0,
Matthew Ranostayd9737752008-09-07 12:03:41 +02001121 snd_ctl_new1(&stac_smux_mixer, codec));
1122 if (err < 0)
1123 return err;
1124 }
Mattc7d4b2f2005-06-27 14:59:41 +02001125
Mattdabbed62005-06-14 10:19:34 +02001126 if (spec->multiout.dig_out_nid) {
Stephen Warren74b654c2011-06-01 11:14:18 -06001127 err = snd_hda_create_spdif_out_ctls(codec,
1128 spec->multiout.dig_out_nid,
1129 spec->multiout.dig_out_nid);
Mattdabbed62005-06-14 10:19:34 +02001130 if (err < 0)
1131 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001132 err = snd_hda_create_spdif_share_sw(codec,
1133 &spec->multiout);
1134 if (err < 0)
1135 return err;
1136 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001137 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001138 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001139 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1140 if (err < 0)
1141 return err;
1142 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001143
1144 /* if we have no master control, let's create it */
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001145 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1146 HDA_OUTPUT, vmaster_tlv);
1147 /* correct volume offset */
1148 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1149 /* minimum value is actually mute */
1150 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1151 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1152 vmaster_tlv, slave_pfxs,
1153 "Playback Volume");
1154 if (err < 0)
1155 return err;
1156
1157 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1158 NULL, slave_pfxs,
1159 "Playback Switch", true,
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001160 &spec->vmaster_mute.sw_kctl);
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01001161 if (err < 0)
1162 return err;
1163
1164 if (spec->gpio_led) {
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001165 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
Takashi Iwaif29735c2012-03-13 07:55:10 +01001166 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
Takashi Iwaid2f344b2012-03-12 16:59:58 +01001167 if (err < 0)
1168 return err;
Takashi Iwai2134ea42008-01-10 16:53:55 +01001169 }
1170
Takashi Iwaid78d7a92009-03-02 14:26:25 +01001171 if (spec->aloopback_ctl &&
1172 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1173 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1174 if (err < 0)
1175 return err;
1176 }
1177
Takashi Iwai603c4012008-07-30 15:01:44 +02001178 stac92xx_free_kctls(codec); /* no longer needed */
Takashi Iwaie4973e12008-11-18 09:32:42 +01001179
Takashi Iwai01a61e12011-10-28 00:03:22 +02001180 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1181 if (err < 0)
1182 return err;
Takashi Iwaie4973e12008-11-18 09:32:42 +01001183
Mattdabbed62005-06-14 10:19:34 +02001184 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001185}
1186
Takashi Iwai2b635362011-05-02 12:33:43 +02001187static const unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001188 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001189 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1190};
1191
Takashi Iwai2b635362011-05-02 12:33:43 +02001192static const unsigned int gateway9200_m4_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001193 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1194 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1195};
Takashi Iwai2b635362011-05-02 12:33:43 +02001196static const unsigned int gateway9200_m4_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001197 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1198 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1199};
1200
1201/*
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001202 STAC 9200 pin configs for
1203 102801A8
1204 102801DE
1205 102801E8
1206*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001207static const unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001208 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1209 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001210};
1211
1212/*
1213 STAC 9200 pin configs for
1214 102801C0
1215 102801C1
1216*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001217static const unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001218 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1219 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001220};
1221
1222/*
1223 STAC 9200 pin configs for
1224 102801C4 (Dell Dimension E310)
1225 102801C5
1226 102801C7
1227 102801D9
1228 102801DA
1229 102801E3
1230*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001231static const unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001232 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1233 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001234};
1235
1236
1237/*
1238 STAC 9200-32 pin configs for
1239 102801B5 (Dell Inspiron 630m)
1240 102801D8 (Dell Inspiron 640m)
1241*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001242static const unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001243 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1244 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001245};
1246
1247/*
1248 STAC 9200-32 pin configs for
1249 102801C2 (Dell Latitude D620)
1250 102801C8
1251 102801CC (Dell Latitude D820)
1252 102801D4
1253 102801D6
1254*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001255static const unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001256 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1257 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001258};
1259
1260/*
1261 STAC 9200-32 pin configs for
1262 102801CE (Dell XPS M1710)
1263 102801CF (Dell Precision M90)
1264*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001265static const unsigned int dell9200_m23_pin_configs[8] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001266 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1267 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1268};
1269
1270/*
1271 STAC 9200-32 pin configs for
1272 102801C9
1273 102801CA
1274 102801CB (Dell Latitude 120L)
1275 102801D3
1276*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001277static const unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001278 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1279 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001280};
1281
1282/*
1283 STAC 9200-32 pin configs for
1284 102801BD (Dell Inspiron E1505n)
1285 102801EE
1286 102801EF
1287*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001288static const unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001289 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1290 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001291};
1292
1293/*
1294 STAC 9200-32 pin configs for
1295 102801F5 (Dell Inspiron 1501)
1296 102801F6
1297*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001298static const unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001299 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1300 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001301};
1302
1303/*
1304 STAC 9200-32
1305 102801CD (Dell Inspiron E1705/9400)
1306*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001307static const unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001308 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1309 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001310};
1311
Takashi Iwai2b635362011-05-02 12:33:43 +02001312static const unsigned int oqo9200_pin_configs[8] = {
Tobin Davisbf277782008-02-03 20:31:47 +01001313 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1314 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1315};
1316
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001317
Takashi Iwai2b635362011-05-02 12:33:43 +02001318static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001319 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001320 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001321 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1322 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1323 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1324 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1325 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1326 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1327 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1328 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1329 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1330 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001331 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1332 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001333 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001334};
1335
Takashi Iwaiea734962011-01-17 11:29:34 +01001336static const char * const stac9200_models[STAC_9200_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001337 [STAC_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001338 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001339 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001340 [STAC_9200_DELL_D21] = "dell-d21",
1341 [STAC_9200_DELL_D22] = "dell-d22",
1342 [STAC_9200_DELL_D23] = "dell-d23",
1343 [STAC_9200_DELL_M21] = "dell-m21",
1344 [STAC_9200_DELL_M22] = "dell-m22",
1345 [STAC_9200_DELL_M23] = "dell-m23",
1346 [STAC_9200_DELL_M24] = "dell-m24",
1347 [STAC_9200_DELL_M25] = "dell-m25",
1348 [STAC_9200_DELL_M26] = "dell-m26",
1349 [STAC_9200_DELL_M27] = "dell-m27",
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001350 [STAC_9200_M4] = "gateway-m4",
1351 [STAC_9200_M4_2] = "gateway-m4-2",
Takashi Iwai117f2572008-03-18 09:53:23 +01001352 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001353};
1354
Takashi Iwai2b635362011-05-02 12:33:43 +02001355static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001356 /* SigmaTel reference board */
1357 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1358 "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001359 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1360 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001361 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1363 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001365 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1367 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1369 "unknown Dell", STAC_9200_DELL_D22),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1371 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001373 "Dell Latitude D620", STAC_9200_DELL_M22),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1375 "unknown Dell", STAC_9200_DELL_D23),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1377 "unknown Dell", STAC_9200_DELL_D23),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1379 "unknown Dell", STAC_9200_DELL_M22),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1381 "unknown Dell", STAC_9200_DELL_M24),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1383 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001385 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001387 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001389 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001391 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001393 "Dell Precision M90", STAC_9200_DELL_M23),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1395 "unknown Dell", STAC_9200_DELL_M22),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1397 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001401 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1403 "unknown Dell", STAC_9200_DELL_D23),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1405 "unknown Dell", STAC_9200_DELL_D23),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1407 "unknown Dell", STAC_9200_DELL_D21),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1409 "unknown Dell", STAC_9200_DELL_D23),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1411 "unknown Dell", STAC_9200_DELL_D21),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1413 "unknown Dell", STAC_9200_DELL_M25),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1415 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001417 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1419 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001420 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001421 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001422 /* Gateway machines needs EAPD to be set on resume */
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001423 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1424 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1425 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
Tobin Davisbf277782008-02-03 20:31:47 +01001426 /* OQO Mobile */
1427 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001428 {} /* terminator */
1429};
1430
Takashi Iwai2b635362011-05-02 12:33:43 +02001431static const unsigned int ref925x_pin_configs[8] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001432 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001433 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001434};
1435
Takashi Iwai2b635362011-05-02 12:33:43 +02001436static const unsigned int stac925xM1_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001437 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1438 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001439};
1440
Takashi Iwai2b635362011-05-02 12:33:43 +02001441static const unsigned int stac925xM1_2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001442 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1443 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1444};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001445
Takashi Iwai2b635362011-05-02 12:33:43 +02001446static const unsigned int stac925xM2_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001447 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1448 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
Tobin Davis2c11f952007-05-17 09:36:34 +02001449};
1450
Takashi Iwai2b635362011-05-02 12:33:43 +02001451static const unsigned int stac925xM2_2_pin_configs[8] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001452 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1453 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1454};
1455
Takashi Iwai2b635362011-05-02 12:33:43 +02001456static const unsigned int stac925xM3_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001457 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1458 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1459};
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001460
Takashi Iwai2b635362011-05-02 12:33:43 +02001461static const unsigned int stac925xM5_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001462 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1463 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1464};
1465
Takashi Iwai2b635362011-05-02 12:33:43 +02001466static const unsigned int stac925xM6_pin_configs[8] = {
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001467 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1468 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
Tobin Davis8e21c342007-01-08 11:04:17 +01001469};
1470
Takashi Iwai2b635362011-05-02 12:33:43 +02001471static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001472 [STAC_REF] = ref925x_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001473 [STAC_M1] = stac925xM1_pin_configs,
1474 [STAC_M1_2] = stac925xM1_2_pin_configs,
1475 [STAC_M2] = stac925xM2_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001476 [STAC_M2_2] = stac925xM2_2_pin_configs,
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001477 [STAC_M3] = stac925xM3_pin_configs,
1478 [STAC_M5] = stac925xM5_pin_configs,
1479 [STAC_M6] = stac925xM6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001480};
1481
Takashi Iwaiea734962011-01-17 11:29:34 +01001482static const char * const stac925x_models[STAC_925x_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001483 [STAC_925x_AUTO] = "auto",
Tobin Davis8e21c342007-01-08 11:04:17 +01001484 [STAC_REF] = "ref",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001485 [STAC_M1] = "m1",
1486 [STAC_M1_2] = "m1-2",
1487 [STAC_M2] = "m2",
Tobin Davis8e21c342007-01-08 11:04:17 +01001488 [STAC_M2_2] = "m2-2",
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001489 [STAC_M3] = "m3",
1490 [STAC_M5] = "m5",
1491 [STAC_M6] = "m6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001492};
1493
Takashi Iwai2b635362011-05-02 12:33:43 +02001494static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02001495 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1496 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1497 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1498 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001499 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001500 /* Not sure about the brand name for those */
1501 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1502 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1503 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1504 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001505 {} /* terminator */
Tobin Davis8e21c342007-01-08 11:04:17 +01001506};
1507
Takashi Iwai2b635362011-05-02 12:33:43 +02001508static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
Tobin Davis8e21c342007-01-08 11:04:17 +01001509 /* SigmaTel reference board */
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001511 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001512 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02001513
1514 /* Default table for unknown ID */
1515 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1516
Tobin Davis8e21c342007-01-08 11:04:17 +01001517 {} /* terminator */
1518};
1519
Takashi Iwai2b635362011-05-02 12:33:43 +02001520static const unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001521 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1522 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1523 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001524 0x01452050,
1525};
1526
Takashi Iwai2b635362011-05-02 12:33:43 +02001527static const unsigned int dell_m6_pin_configs[13] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001528 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001529 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001530 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1531 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001532};
1533
Takashi Iwai2b635362011-05-02 12:33:43 +02001534static const unsigned int alienware_m17x_pin_configs[13] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001535 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1536 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1537 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1538 0x904601b0,
1539};
1540
Takashi Iwai2b635362011-05-02 12:33:43 +02001541static const unsigned int intel_dg45id_pin_configs[13] = {
Alexey Fisher52dc4382009-12-12 11:16:41 +02001542 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
Wu Fengguang4d26f442010-05-07 08:47:54 +08001543 0x01A19250, 0x01011212, 0x01016211
Alexey Fisher52dc4382009-12-12 11:16:41 +02001544};
1545
Takashi Iwai2b635362011-05-02 12:33:43 +02001546static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001547 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001548 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1549 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1550 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001551 [STAC_DELL_EQ] = dell_m6_pin_configs,
Takashi Iwai842ae632009-09-02 07:43:08 +02001552 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
Alexey Fisher52dc4382009-12-12 11:16:41 +02001553 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001554};
1555
Takashi Iwaiea734962011-01-17 11:29:34 +01001556static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001557 [STAC_92HD73XX_AUTO] = "auto",
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01001558 [STAC_92HD73XX_NO_JD] = "no-jd",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001559 [STAC_92HD73XX_REF] = "ref",
Wu Fengguangae709442009-08-19 17:05:11 +08001560 [STAC_92HD73XX_INTEL] = "intel",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001561 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1562 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1563 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001564 [STAC_DELL_EQ] = "dell-eq",
Takashi Iwai842ae632009-09-02 07:43:08 +02001565 [STAC_ALIENWARE_M17X] = "alienware",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001566};
1567
Takashi Iwai2b635362011-05-02 12:33:43 +02001568static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001569 /* SigmaTel reference board */
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001571 "DFI LanParty", STAC_92HD73XX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001572 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1573 "DFI LanParty", STAC_92HD73XX_REF),
Wu Fengguangae709442009-08-19 17:05:11 +08001574 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1575 "Intel DG45ID", STAC_92HD73XX_INTEL),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1577 "Intel DG45FC", STAC_92HD73XX_INTEL),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001579 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001581 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001583 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001585 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001587 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001589 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001591 "unknown Dell", STAC_DELL_M6_DMIC),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1593 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001595 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Joerg Schirottkefa620e92008-12-19 08:13:49 +01001596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1597 "Dell Studio 17", STAC_DELL_M6_DMIC),
Takashi Iwai626f5ce2009-07-28 00:54:39 +02001598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1599 "Dell Studio 1555", STAC_DELL_M6_DMIC),
Daniel J Blueman8ef58372009-11-14 18:20:04 +00001600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1601 "Dell Studio 1557", STAC_DELL_M6_DMIC),
Daniel T Chenaac78da2010-04-21 20:41:52 -04001602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
David Henningssonffe535e2012-01-16 10:52:20 +01001603 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
Daniel T Chen5c1bccf2010-04-22 17:54:45 -04001604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
David Henningssone033ebf2011-05-16 12:09:29 +02001605 "Dell Studio 1558", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001606 {} /* terminator */
1607};
1608
Takashi Iwai2b635362011-05-02 12:33:43 +02001609static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
Takashi Iwai842ae632009-09-02 07:43:08 +02001610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1611 "Alienware M17x", STAC_ALIENWARE_M17X),
Daniel T Chen0defe092010-12-01 19:16:07 -05001612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1613 "Alienware M17x", STAC_ALIENWARE_M17X),
Takashi Iwaidbd1b542011-11-19 11:41:30 +01001614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
Albert Poolb9ecc4e2012-01-19 22:08:50 +01001615 "Alienware M17x R3", STAC_DELL_EQ),
Takashi Iwai842ae632009-09-02 07:43:08 +02001616 {} /* terminator */
1617};
1618
Takashi Iwai2b635362011-05-02 12:33:43 +02001619static const unsigned int ref92hd83xxx_pin_configs[10] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001620 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1621 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001622 0x01451160, 0x98560170,
1623};
1624
Takashi Iwai2b635362011-05-02 12:33:43 +02001625static const unsigned int dell_s14_pin_configs[10] = {
Takashi Iwai69b56552009-09-15 12:37:42 +02001626 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1627 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001628 0x40f000f0, 0x40f000f0,
1629};
1630
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001631static const unsigned int dell_vostro_3500_pin_configs[10] = {
1632 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1633 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1634 0x400000f4, 0x400000f5,
1635};
1636
Takashi Iwai2b635362011-05-02 12:33:43 +02001637static const unsigned int hp_dv7_4000_pin_configs[10] = {
Steven Eastland48315592010-08-06 15:07:35 -06001638 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1639 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1640 0x40f000f0, 0x40f000f0,
1641};
1642
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001643static const unsigned int hp_zephyr_pin_configs[10] = {
1644 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1645 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1646 0, 0,
1647};
1648
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001649static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1650 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1651 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1652 0x40f000f0, 0x40f000f0,
1653};
1654
Takashi Iwai2b635362011-05-02 12:33:43 +02001655static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001656 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001657 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001658 [STAC_DELL_S14] = dell_s14_pin_configs,
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001659 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001660 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
Steven Eastland48315592010-08-06 15:07:35 -06001661 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001662 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001663};
1664
Takashi Iwaiea734962011-01-17 11:29:34 +01001665static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001666 [STAC_92HD83XXX_AUTO] = "auto",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001667 [STAC_92HD83XXX_REF] = "ref",
Matthew Ranostay32ed3f42009-01-22 20:53:29 -05001668 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001669 [STAC_DELL_S14] = "dell-s14",
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001670 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001671 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
Steven Eastland48315592010-08-06 15:07:35 -06001672 [STAC_HP_DV7_4000] = "hp-dv7-4000",
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001673 [STAC_HP_ZEPHYR] = "hp-zephyr",
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001674};
1675
Takashi Iwai2b635362011-05-02 12:33:43 +02001676static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001677 /* SigmaTel reference board */
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Takashi Iwaif9d088b2009-01-13 11:54:49 +01001679 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001680 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1681 "DFI LanParty", STAC_92HD83XXX_REF),
Matthew Ranostay8bb0ac52009-02-12 16:50:01 -05001682 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1683 "unknown Dell", STAC_DELL_S14),
Julian Wollrathf7f9bdf2011-11-09 10:02:40 +01001684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1685 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
Vitaliy Kulikov0c27c182011-07-22 17:50:37 -05001686 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1687 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1689 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1691 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1693 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1695 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1697 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1699 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1701 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1703 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1705 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1707 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1709 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1711 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1715 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1717 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1719 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1721 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1723 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1725 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06001726 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1727 "HP", STAC_HP_ZEPHYR),
1728 {} /* terminator */
1729};
1730
1731static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
1733 "HP", STAC_HP_ZEPHYR),
Herton Ronaldo Krzesinski574f3c42008-12-23 16:53:00 -02001734 {} /* terminator */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001735};
1736
Takashi Iwai2b635362011-05-02 12:33:43 +02001737static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001738 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001739 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001740 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1741 0x00000000
Matthew Ranostaye035b842007-11-06 11:53:55 +01001742};
1743
Takashi Iwai2b635362011-05-02 12:33:43 +02001744static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001745 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001746 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001747 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1748 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001749};
1750
Takashi Iwai2b635362011-05-02 12:33:43 +02001751static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001752 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1753 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001754 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1755 0x00000000
Matthew Ranostaya7662642008-02-21 07:51:14 +01001756};
1757
Takashi Iwai2b635362011-05-02 12:33:43 +02001758static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001759 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1760 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05001761 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1762 0x00000000
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001763};
1764
Takashi Iwai2b635362011-05-02 12:33:43 +02001765static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001766 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001767 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1768 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001769 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001770 [STAC_HP_M4] = NULL,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001771 [STAC_HP_DV4] = NULL,
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001772 [STAC_HP_DV5] = NULL,
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001773 [STAC_HP_HDX] = NULL,
James Gardiner514bf542009-05-03 04:00:44 -04001774 [STAC_HP_DV4_1222NR] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001775};
1776
Takashi Iwaiea734962011-01-17 11:29:34 +01001777static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001778 [STAC_92HD71BXX_AUTO] = "auto",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001779 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001780 [STAC_DELL_M4_1] = "dell-m4-1",
1781 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001782 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001783 [STAC_HP_M4] = "hp-m4",
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001784 [STAC_HP_DV4] = "hp-dv4",
Takashi Iwai1b0652e2009-01-14 08:27:35 +01001785 [STAC_HP_DV5] = "hp-dv5",
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001786 [STAC_HP_HDX] = "hp-hdx",
James Gardiner514bf542009-05-03 04:00:44 -04001787 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001788};
1789
Takashi Iwai2b635362011-05-02 12:33:43 +02001790static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001791 /* SigmaTel reference board */
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1793 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001794 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1795 "DFI LanParty", STAC_92HD71BXX_REF),
James Gardiner514bf542009-05-03 04:00:44 -04001796 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1797 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01001798 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1799 "HP", STAC_HP_DV5),
Takashi Iwai58d83952009-03-13 17:04:34 +01001800 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1801 "HP", STAC_HP_DV5),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001802 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02001803 "HP dv4-7", STAC_HP_DV4),
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001804 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1805 "HP dv4-7", STAC_HP_DV5),
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001806 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1807 "HP HDX", STAC_HP_HDX), /* HDX18 */
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001808 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
Takashi Iwai2ae466f2009-02-16 14:16:36 +01001809 "HP mini 1000", STAC_HP_M4),
Christoph Plattnerae6241f2009-03-08 23:19:05 +01001810 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
Takashi Iwai6fce61a2009-03-10 07:48:57 +01001811 "HP HDX", STAC_HP_HDX), /* HDX16 */
Takashi Iwai6e34c032009-09-14 15:42:18 +02001812 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1813 "HP dv6", STAC_HP_DV5),
Kunal Gangakhedkare3d25302010-03-20 23:08:01 +05301814 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1815 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
Luke Yelavich9b2167d2010-10-06 15:45:46 +11001816 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1817 "HP DV6", STAC_HP_DV5),
Takashi Iwai1972d022009-08-06 08:44:43 +02001818 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1819 "HP", STAC_HP_DV5),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001820 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1821 "unknown Dell", STAC_DELL_M4_1),
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1823 "unknown Dell", STAC_DELL_M4_1),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1825 "unknown Dell", STAC_DELL_M4_1),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1827 "unknown Dell", STAC_DELL_M4_1),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1829 "unknown Dell", STAC_DELL_M4_1),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1831 "unknown Dell", STAC_DELL_M4_1),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1833 "unknown Dell", STAC_DELL_M4_1),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1835 "unknown Dell", STAC_DELL_M4_2),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1837 "unknown Dell", STAC_DELL_M4_2),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1839 "unknown Dell", STAC_DELL_M4_2),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1841 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1843 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001844 {} /* terminator */
1845};
1846
Takashi Iwai2b635362011-05-02 12:33:43 +02001847static const unsigned int ref922x_pin_configs[10] = {
Matt Porter403d1942005-11-29 15:00:51 +01001848 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1849 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001850 0x40000100, 0x40000100,
1851};
1852
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001853/*
1854 STAC 922X pin configs for
1855 102801A7
1856 102801AB
1857 102801A9
1858 102801D1
1859 102801D2
1860*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001861static const unsigned int dell_922x_d81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001862 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1863 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1864 0x01813122, 0x400001f2,
1865};
1866
1867/*
1868 STAC 922X pin configs for
1869 102801AC
1870 102801D0
1871*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001872static const unsigned int dell_922x_d82_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001873 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1874 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1875 0x01813122, 0x400001f1,
1876};
1877
1878/*
1879 STAC 922X pin configs for
1880 102801BF
1881*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001882static const unsigned int dell_922x_m81_pin_configs[10] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001883 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1884 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1885 0x40C003f1, 0x405003f0,
1886};
1887
1888/*
1889 STAC 9221 A1 pin configs for
1890 102801D7 (Dell XPS M1210)
1891*/
Takashi Iwai2b635362011-05-02 12:33:43 +02001892static const unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001893 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1894 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001895 0x508003f3, 0x405003f4,
1896};
1897
Takashi Iwai2b635362011-05-02 12:33:43 +02001898static const unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001899 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001900 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1901 0x02a19120, 0x40000100,
1902};
1903
Takashi Iwai2b635362011-05-02 12:33:43 +02001904static const unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001905 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1906 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001907 0x02a19320, 0x40000100,
1908};
1909
Takashi Iwai2b635362011-05-02 12:33:43 +02001910static const unsigned int intel_mac_v1_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001911 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1912 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001913 0x400000fc, 0x400000fb,
1914};
1915
Takashi Iwai2b635362011-05-02 12:33:43 +02001916static const unsigned int intel_mac_v2_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001917 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1918 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001919 0x400000fc, 0x400000fb,
1920};
1921
Takashi Iwai2b635362011-05-02 12:33:43 +02001922static const unsigned int intel_mac_v3_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001923 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1924 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1925 0x400000fc, 0x400000fb,
1926};
1927
Takashi Iwai2b635362011-05-02 12:33:43 +02001928static const unsigned int intel_mac_v4_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001929 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1930 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1931 0x400000fc, 0x400000fb,
1932};
1933
Takashi Iwai2b635362011-05-02 12:33:43 +02001934static const unsigned int intel_mac_v5_pin_configs[10] = {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001935 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1936 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1937 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001938};
1939
Takashi Iwai2b635362011-05-02 12:33:43 +02001940static const unsigned int ecs202_pin_configs[10] = {
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001941 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1942 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1943 0x9037012e, 0x40e000f2,
1944};
Takashi Iwai76c08822007-06-19 12:17:42 +02001945
Takashi Iwai2b635362011-05-02 12:33:43 +02001946static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001947 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001948 [STAC_D945GTP3] = d945gtp3_pin_configs,
1949 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001950 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1951 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1952 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1953 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1954 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001955 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001956 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001957 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1958 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1959 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1960 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1961 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1962 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001963 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001964 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1965 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1966 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1967 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001968};
1969
Takashi Iwaiea734962011-01-17 11:29:34 +01001970static const char * const stac922x_models[STAC_922X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01001971 [STAC_922X_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001972 [STAC_D945_REF] = "ref",
1973 [STAC_D945GTP5] = "5stack",
1974 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001975 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1976 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1977 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1978 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1979 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001980 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001981 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001982 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001983 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001984 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1985 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001986 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001987 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001988 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001989 [STAC_922X_DELL_D81] = "dell-d81",
1990 [STAC_922X_DELL_D82] = "dell-d82",
1991 [STAC_922X_DELL_M81] = "dell-m81",
1992 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001993};
1994
Takashi Iwai2b635362011-05-02 12:33:43 +02001995static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001996 /* SigmaTel reference board */
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1998 "DFI LanParty", STAC_D945_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05001999 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2000 "DFI LanParty", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002001 /* Intel 945G based systems */
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2003 "Intel D945G", STAC_D945GTP3),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2031 "Intel D945G", STAC_D945GTP3),
2032 /* Intel D945G 5-stack systems */
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2034 "Intel D945G", STAC_D945GTP5),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2036 "Intel D945G", STAC_D945GTP5),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2038 "Intel D945G", STAC_D945GTP5),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2040 "Intel D945G", STAC_D945GTP5),
2041 /* Intel 945P based systems */
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2043 "Intel D945P", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2045 "Intel D945P", STAC_D945GTP3),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2047 "Intel D945P", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2049 "Intel D945P", STAC_D945GTP3),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2051 "Intel D945P", STAC_D945GTP3),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2053 "Intel D945P", STAC_D945GTP5),
Takashi Iwai8056d472009-01-23 09:09:43 +01002054 /* other intel */
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2056 "Intel D945", STAC_D945_REF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002057 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08002058 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002059 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08002060 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002061 /* Dell systems */
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2063 "unknown Dell", STAC_922X_DELL_D81),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2065 "unknown Dell", STAC_922X_DELL_D81),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2067 "unknown Dell", STAC_922X_DELL_D81),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2069 "unknown Dell", STAC_922X_DELL_D82),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2071 "unknown Dell", STAC_922X_DELL_M81),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2073 "unknown Dell", STAC_922X_DELL_D82),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2075 "unknown Dell", STAC_922X_DELL_D81),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2077 "unknown Dell", STAC_922X_DELL_D81),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2079 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03002080 /* ECS/PC Chips boards */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002081 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
Herton Ronaldo Krzesinski8663ae52009-02-08 19:50:34 -02002082 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01002083 {} /* terminator */
2084};
2085
Takashi Iwai2b635362011-05-02 12:33:43 +02002086static const unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002087 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2088 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2089 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2090 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002091};
2092
Takashi Iwai2b635362011-05-02 12:33:43 +02002093static const unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002094 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2095 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2096 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2097 0x40000100, 0x40000100
2098};
2099
Takashi Iwai2b635362011-05-02 12:33:43 +02002100static const unsigned int d965_5st_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002101 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2102 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2103 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2104 0x40000100, 0x40000100
2105};
2106
Takashi Iwai2b635362011-05-02 12:33:43 +02002107static const unsigned int d965_5st_no_fp_pin_configs[14] = {
Takashi Iwai679d92e2009-05-24 19:00:08 +02002108 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2109 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2110 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2111 0x40000100, 0x40000100
2112};
2113
Takashi Iwai2b635362011-05-02 12:33:43 +02002114static const unsigned int dell_3st_pin_configs[14] = {
Tobin Davis4ff076e2007-08-07 11:48:12 +02002115 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2116 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002117 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002118 0x40c003fc, 0x40000100
2119};
2120
Takashi Iwai2b635362011-05-02 12:33:43 +02002121static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaie28d8322008-12-17 13:48:29 +01002122 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002123 [STAC_D965_REF] = ref927x_pin_configs,
2124 [STAC_D965_3ST] = d965_3st_pin_configs,
2125 [STAC_D965_5ST] = d965_5st_pin_configs,
Takashi Iwai679d92e2009-05-24 19:00:08 +02002126 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002127 [STAC_DELL_3ST] = dell_3st_pin_configs,
2128 [STAC_DELL_BIOS] = NULL,
Takashi Iwai54930532009-10-11 17:38:29 +02002129 [STAC_927X_VOLKNOB] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002130};
2131
Takashi Iwaiea734962011-01-17 11:29:34 +01002132static const char * const stac927x_models[STAC_927X_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002133 [STAC_927X_AUTO] = "auto",
Takashi Iwaie28d8322008-12-17 13:48:29 +01002134 [STAC_D965_REF_NO_JD] = "ref-no-jd",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002135 [STAC_D965_REF] = "ref",
2136 [STAC_D965_3ST] = "3stack",
2137 [STAC_D965_5ST] = "5stack",
Takashi Iwai679d92e2009-05-24 19:00:08 +02002138 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002139 [STAC_DELL_3ST] = "dell-3stack",
2140 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwai54930532009-10-11 17:38:29 +02002141 [STAC_927X_VOLKNOB] = "volknob",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002142};
2143
Takashi Iwai2b635362011-05-02 12:33:43 +02002144static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002145 /* SigmaTel reference board */
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2147 "DFI LanParty", STAC_D965_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002148 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2149 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002150 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002153 /* 965 based 3 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002154 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2155 "Intel D965", STAC_D965_3ST),
2156 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2157 "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002158 /* Dell 3 stack systems */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002162 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
Daniel T Chen66668b62010-05-23 20:47:45 -04002164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Chengu Wang84d3dc22009-07-30 19:43:55 +08002167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002172 /* 965 based 5 stack systems */
Takashi Iwaidea0a502009-02-09 17:14:52 +01002173 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2174 "Intel D965", STAC_D965_5ST),
2175 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2176 "Intel D965", STAC_D965_5ST),
Takashi Iwai54930532009-10-11 17:38:29 +02002177 /* volume-knob fixes */
2178 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002179 {} /* terminator */
2180};
2181
Takashi Iwai2b635362011-05-02 12:33:43 +02002182static const unsigned int ref9205_pin_configs[12] = {
Matt Porterf3302a52006-07-31 12:49:34 +02002183 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002184 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002185 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002186};
2187
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002188/*
2189 STAC 9205 pin configs for
2190 102801F1
2191 102801F2
2192 102801FC
2193 102801FD
2194 10280204
2195 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002196 10280228 (Dell Vostro 1500)
Anisse Astier95e70e82009-12-23 17:28:45 +01002197 10280229 (Dell Vostro 1700)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002198*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002199static const unsigned int dell_9205_m42_pin_configs[12] = {
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002200 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2201 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2202 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2203};
2204
2205/*
2206 STAC 9205 pin configs for
2207 102801F9
2208 102801FA
2209 102801FE
2210 102801FF (Dell Precision M4300)
2211 10280206
2212 10280200
2213 10280201
2214*/
Takashi Iwai2b635362011-05-02 12:33:43 +02002215static const unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002216 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2217 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2218 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2219};
2220
Takashi Iwai2b635362011-05-02 12:33:43 +02002221static const unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002222 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2223 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2224 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2225};
2226
Takashi Iwai2b635362011-05-02 12:33:43 +02002227static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002228 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002229 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2230 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2231 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Takashi Iwaid9a42682009-01-22 17:40:18 +01002232 [STAC_9205_EAPD] = NULL,
Matt Porterf3302a52006-07-31 12:49:34 +02002233};
2234
Takashi Iwaiea734962011-01-17 11:29:34 +01002235static const char * const stac9205_models[STAC_9205_MODELS] = {
Takashi Iwai1607b8e2009-02-26 16:50:43 +01002236 [STAC_9205_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002237 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002238 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002239 [STAC_9205_DELL_M43] = "dell-m43",
2240 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaid9a42682009-01-22 17:40:18 +01002241 [STAC_9205_EAPD] = "eapd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002242};
2243
Takashi Iwai2b635362011-05-02 12:33:43 +02002244static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002245 /* SigmaTel reference board */
2246 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2247 "DFI LanParty", STAC_9205_REF),
Herton Ronaldo Krzesinski02358fc2009-07-04 01:44:59 -03002248 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2249 "SigmaTel", STAC_9205_REF),
Matthew Ranostay577aa2c2009-01-22 22:55:44 -05002250 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2251 "DFI LanParty", STAC_9205_REF),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002252 /* Dell */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2254 "unknown Dell", STAC_9205_DELL_M42),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2256 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002258 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2260 "Dell Precision", STAC_9205_DELL_M43),
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2262 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2264 "unknown Dell", STAC_9205_DELL_M42),
2265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2266 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2268 "Dell Precision", STAC_9205_DELL_M43),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002270 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2272 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2274 "Dell Precision", STAC_9205_DELL_M43),
2275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2276 "Dell Precision", STAC_9205_DELL_M43),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2278 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2280 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2282 "Dell Vostro 1500", STAC_9205_DELL_M42),
Anisse Astier95e70e82009-12-23 17:28:45 +01002283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2284 "Dell Vostro 1700", STAC_9205_DELL_M42),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002285 /* Gateway */
Hao Song42b95f02009-07-20 15:01:16 +08002286 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
Takashi Iwaid9a42682009-01-22 17:40:18 +01002287 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
Matt Porterf3302a52006-07-31 12:49:34 +02002288 {} /* terminator */
2289};
2290
Takashi Iwai330ee992009-02-20 14:33:36 +01002291static void stac92xx_set_config_regs(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002292 const unsigned int *pincfgs)
Matt2f2f4252005-04-13 14:45:30 +02002293{
2294 int i;
2295 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002296
Takashi Iwai330ee992009-02-20 14:33:36 +01002297 if (!pincfgs)
2298 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002299
Matthew Ranostay87d48362007-07-17 11:52:24 +02002300 for (i = 0; i < spec->num_pins; i++)
Takashi Iwai330ee992009-02-20 14:33:36 +01002301 if (spec->pin_nids[i] && pincfgs[i])
2302 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2303 pincfgs[i]);
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01002304}
2305
Matt2f2f4252005-04-13 14:45:30 +02002306/*
2307 * Analog playback callbacks
2308 */
2309static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2310 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002311 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002312{
2313 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002314 if (spec->stream_delay)
2315 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002316 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2317 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002318}
2319
2320static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2321 struct hda_codec *codec,
2322 unsigned int stream_tag,
2323 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002324 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002325{
2326 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002327 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002328}
2329
2330static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2331 struct hda_codec *codec,
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;
2335 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2336}
2337
2338/*
Mattdabbed62005-06-14 10:19:34 +02002339 * Digital playback callbacks
2340 */
2341static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2342 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002343 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002344{
2345 struct sigmatel_spec *spec = codec->spec;
2346 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2347}
2348
2349static int stac92xx_dig_playback_pcm_close(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_close(codec, &spec->multiout);
2355}
2356
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002357static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2358 struct hda_codec *codec,
2359 unsigned int stream_tag,
2360 unsigned int format,
2361 struct snd_pcm_substream *substream)
2362{
2363 struct sigmatel_spec *spec = codec->spec;
2364 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2365 stream_tag, format, substream);
2366}
2367
Takashi Iwai9411e212009-02-13 11:32:28 +01002368static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2369 struct hda_codec *codec,
2370 struct snd_pcm_substream *substream)
2371{
2372 struct sigmatel_spec *spec = codec->spec;
2373 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2374}
2375
Mattdabbed62005-06-14 10:19:34 +02002376
2377/*
Matt2f2f4252005-04-13 14:45:30 +02002378 * Analog capture callbacks
2379 */
2380static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2381 struct hda_codec *codec,
2382 unsigned int stream_tag,
2383 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002384 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002385{
2386 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002387 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002388
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002389 if (spec->powerdown_adcs) {
2390 msleep(40);
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002391 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002392 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2393 }
2394 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002395 return 0;
2396}
2397
2398static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2399 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002400 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002401{
2402 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002403 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002404
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002405 snd_hda_codec_cleanup_stream(codec, nid);
2406 if (spec->powerdown_adcs)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01002407 snd_hda_codec_write(codec, nid, 0,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002408 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002409 return 0;
2410}
2411
Takashi Iwai2b635362011-05-02 12:33:43 +02002412static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
Mattdabbed62005-06-14 10:19:34 +02002413 .substreams = 1,
2414 .channels_min = 2,
2415 .channels_max = 2,
2416 /* NID is set in stac92xx_build_pcms */
2417 .ops = {
2418 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002419 .close = stac92xx_dig_playback_pcm_close,
Takashi Iwai9411e212009-02-13 11:32:28 +01002420 .prepare = stac92xx_dig_playback_pcm_prepare,
2421 .cleanup = stac92xx_dig_playback_pcm_cleanup
Mattdabbed62005-06-14 10:19:34 +02002422 },
2423};
2424
Takashi Iwai2b635362011-05-02 12:33:43 +02002425static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
Mattdabbed62005-06-14 10:19:34 +02002426 .substreams = 1,
2427 .channels_min = 2,
2428 .channels_max = 2,
2429 /* NID is set in stac92xx_build_pcms */
2430};
2431
Takashi Iwai2b635362011-05-02 12:33:43 +02002432static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
Matt2f2f4252005-04-13 14:45:30 +02002433 .substreams = 1,
2434 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002435 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002436 .nid = 0x02, /* NID to query formats and rates */
2437 .ops = {
2438 .open = stac92xx_playback_pcm_open,
2439 .prepare = stac92xx_playback_pcm_prepare,
2440 .cleanup = stac92xx_playback_pcm_cleanup
2441 },
2442};
2443
Takashi Iwai2b635362011-05-02 12:33:43 +02002444static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002445 .substreams = 1,
2446 .channels_min = 2,
2447 .channels_max = 2,
2448 .nid = 0x06, /* NID to query formats and rates */
2449 .ops = {
2450 .open = stac92xx_playback_pcm_open,
2451 .prepare = stac92xx_playback_pcm_prepare,
2452 .cleanup = stac92xx_playback_pcm_cleanup
2453 },
2454};
2455
Takashi Iwai2b635362011-05-02 12:33:43 +02002456static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002457 .channels_min = 2,
2458 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002459 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002460 .ops = {
2461 .prepare = stac92xx_capture_pcm_prepare,
2462 .cleanup = stac92xx_capture_pcm_cleanup
2463 },
2464};
2465
2466static int stac92xx_build_pcms(struct hda_codec *codec)
2467{
2468 struct sigmatel_spec *spec = codec->spec;
2469 struct hda_pcm *info = spec->pcm_rec;
2470
2471 codec->num_pcms = 1;
2472 codec->pcm_info = info;
2473
Mattc7d4b2f2005-06-27 14:59:41 +02002474 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002475 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Takashi Iwai00a602d2009-01-23 11:55:42 +01002476 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2477 spec->multiout.dac_nids[0];
Matt2f2f4252005-04-13 14:45:30 +02002478 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002479 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002480 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002481
2482 if (spec->alt_switch) {
2483 codec->num_pcms++;
2484 info++;
2485 info->name = "STAC92xx Analog Alt";
2486 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2487 }
Matt2f2f4252005-04-13 14:45:30 +02002488
Mattdabbed62005-06-14 10:19:34 +02002489 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2490 codec->num_pcms++;
2491 info++;
2492 info->name = "STAC92xx Digital";
Takashi Iwai0852d7a2009-02-11 11:35:15 +01002493 info->pcm_type = spec->autocfg.dig_out_type[0];
Mattdabbed62005-06-14 10:19:34 +02002494 if (spec->multiout.dig_out_nid) {
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2497 }
2498 if (spec->dig_in_nid) {
2499 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2500 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2501 }
2502 }
2503
Matt2f2f4252005-04-13 14:45:30 +02002504 return 0;
2505}
2506
Matt Porter403d1942005-11-29 15:00:51 +01002507static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2508
2509{
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02002510 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002511}
2512
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002513#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2514
2515static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2516 struct snd_ctl_elem_value *ucontrol)
2517{
2518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2519 struct sigmatel_spec *spec = codec->spec;
2520
Takashi Iwaid7a89432008-11-12 09:48:04 +01002521 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002522 return 0;
2523}
2524
Takashi Iwai62558ce2009-07-29 14:23:09 +02002525static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01002526
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002527static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2528 struct snd_ctl_elem_value *ucontrol)
2529{
2530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2531 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002532 int nid = kcontrol->private_value;
2533
2534 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002535
Lucas De Marchi25985ed2011-03-30 22:57:33 -03002536 /* check to be sure that the ports are up to date with
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002537 * switch changes
2538 */
Takashi Iwai62558ce2009-07-29 14:23:09 +02002539 stac_issue_unsol_event(codec, nid);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002540
2541 return 1;
2542}
2543
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002544static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2545 struct snd_ctl_elem_info *uinfo)
2546{
2547 int i;
Takashi Iwai2b635362011-05-02 12:33:43 +02002548 static const char * const texts[] = {
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002549 "Mic In", "Line In", "Line Out"
2550 };
2551
2552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2553 struct sigmatel_spec *spec = codec->spec;
2554 hda_nid_t nid = kcontrol->private_value;
2555
2556 if (nid == spec->mic_switch || nid == spec->line_switch)
2557 i = 3;
2558 else
2559 i = 2;
2560
2561 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2562 uinfo->value.enumerated.items = i;
2563 uinfo->count = 1;
2564 if (uinfo->value.enumerated.item >= i)
2565 uinfo->value.enumerated.item = i-1;
2566 strcpy(uinfo->value.enumerated.name,
2567 texts[uinfo->value.enumerated.item]);
2568
2569 return 0;
2570}
2571
2572static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2573 struct snd_ctl_elem_value *ucontrol)
2574{
2575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2576 hda_nid_t nid = kcontrol->private_value;
2577 unsigned int vref = stac92xx_vref_get(codec, nid);
2578
Takashi Iwai47408602012-04-20 13:06:53 +02002579 if (vref == snd_hda_get_default_vref(codec, nid))
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002580 ucontrol->value.enumerated.item[0] = 0;
2581 else if (vref == AC_PINCTL_VREF_GRD)
2582 ucontrol->value.enumerated.item[0] = 1;
2583 else if (vref == AC_PINCTL_VREF_HIZ)
2584 ucontrol->value.enumerated.item[0] = 2;
2585
2586 return 0;
2587}
2588
2589static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2590 struct snd_ctl_elem_value *ucontrol)
2591{
2592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2593 unsigned int new_vref = 0;
Takashi Iwaib8621512009-06-22 08:00:10 +02002594 int error;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002595 hda_nid_t nid = kcontrol->private_value;
2596
2597 if (ucontrol->value.enumerated.item[0] == 0)
Takashi Iwai47408602012-04-20 13:06:53 +02002598 new_vref = snd_hda_get_default_vref(codec, nid);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002599 else if (ucontrol->value.enumerated.item[0] == 1)
2600 new_vref = AC_PINCTL_VREF_GRD;
2601 else if (ucontrol->value.enumerated.item[0] == 2)
2602 new_vref = AC_PINCTL_VREF_HIZ;
2603 else
2604 return 0;
2605
2606 if (new_vref != stac92xx_vref_get(codec, nid)) {
2607 error = stac92xx_vref_set(codec, nid, new_vref);
2608 return error;
2609 }
2610
2611 return 0;
2612}
2613
2614static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2615 struct snd_ctl_elem_info *uinfo)
2616{
Takashi Iwai2b635362011-05-02 12:33:43 +02002617 char *texts[2];
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2619 struct sigmatel_spec *spec = codec->spec;
2620
2621 if (kcontrol->private_value == spec->line_switch)
2622 texts[0] = "Line In";
2623 else
2624 texts[0] = "Mic In";
2625 texts[1] = "Line Out";
2626 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2627 uinfo->value.enumerated.items = 2;
2628 uinfo->count = 1;
2629
2630 if (uinfo->value.enumerated.item >= 2)
2631 uinfo->value.enumerated.item = 1;
2632 strcpy(uinfo->value.enumerated.name,
2633 texts[uinfo->value.enumerated.item]);
2634
2635 return 0;
2636}
Matt Porter403d1942005-11-29 15:00:51 +01002637
2638static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2639{
2640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2641 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002642 hda_nid_t nid = kcontrol->private_value;
2643 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
Matt Porter403d1942005-11-29 15:00:51 +01002644
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002645 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
Matt Porter403d1942005-11-29 15:00:51 +01002646 return 0;
2647}
2648
2649static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2650{
2651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2652 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002653 hda_nid_t nid = kcontrol->private_value;
2654 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2655 unsigned short val = !!ucontrol->value.enumerated.item[0];
Matt Porter403d1942005-11-29 15:00:51 +01002656
2657 spec->io_switch[io_idx] = val;
2658
2659 if (val)
2660 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002661 else {
2662 unsigned int pinctl = AC_PINCTL_IN_EN;
2663 if (io_idx) /* set VREF for mic */
Takashi Iwai47408602012-04-20 13:06:53 +02002664 pinctl |= snd_hda_get_default_vref(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01002665 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2666 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002667
2668 /* check the auto-mute again: we need to mute/unmute the speaker
2669 * appropriately according to the pin direction
2670 */
2671 if (spec->hp_detect)
Takashi Iwai62558ce2009-07-29 14:23:09 +02002672 stac_issue_unsol_event(codec, nid);
Jiang Zhe40c1d302007-11-12 13:05:16 +01002673
Matt Porter403d1942005-11-29 15:00:51 +01002674 return 1;
2675}
2676
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002677#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2678
2679static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2680 struct snd_ctl_elem_value *ucontrol)
2681{
2682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2683 struct sigmatel_spec *spec = codec->spec;
2684
2685 ucontrol->value.integer.value[0] = spec->clfe_swap;
2686 return 0;
2687}
2688
2689static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2690 struct snd_ctl_elem_value *ucontrol)
2691{
2692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2693 struct sigmatel_spec *spec = codec->spec;
2694 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002695 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002696
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002697 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002698 return 0;
2699
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002700 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002701
2702 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2703 spec->clfe_swap ? 0x4 : 0x0);
2704
2705 return 1;
2706}
2707
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002708#define STAC_CODEC_HP_SWITCH(xname) \
2709 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2710 .name = xname, \
2711 .index = 0, \
2712 .info = stac92xx_hp_switch_info, \
2713 .get = stac92xx_hp_switch_get, \
2714 .put = stac92xx_hp_switch_put, \
2715 }
2716
Matt Porter403d1942005-11-29 15:00:51 +01002717#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2718 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2719 .name = xname, \
2720 .index = 0, \
2721 .info = stac92xx_io_switch_info, \
2722 .get = stac92xx_io_switch_get, \
2723 .put = stac92xx_io_switch_put, \
2724 .private_value = xpval, \
2725 }
2726
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002727#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2728 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2729 .name = xname, \
2730 .index = 0, \
2731 .info = stac92xx_clfe_switch_info, \
2732 .get = stac92xx_clfe_switch_get, \
2733 .put = stac92xx_clfe_switch_put, \
2734 .private_value = xpval, \
2735 }
Matt Porter403d1942005-11-29 15:00:51 +01002736
Mattc7d4b2f2005-06-27 14:59:41 +02002737enum {
2738 STAC_CTL_WIDGET_VOL,
2739 STAC_CTL_WIDGET_MUTE,
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002740 STAC_CTL_WIDGET_MUTE_BEEP,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002741 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002742 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002743 STAC_CTL_WIDGET_IO_SWITCH,
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002744 STAC_CTL_WIDGET_CLFE_SWITCH,
2745 STAC_CTL_WIDGET_DC_BIAS
Mattc7d4b2f2005-06-27 14:59:41 +02002746};
2747
Takashi Iwai2b635362011-05-02 12:33:43 +02002748static const struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002749 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2750 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002751 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002752 STAC_MONO_MUX,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002753 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002754 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002755 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Nickolas Lloyd2fc99892009-05-15 15:33:30 +02002756 DC_BIAS(NULL, 0, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002757};
2758
2759/* add dynamic controls */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002760static struct snd_kcontrol_new *
2761stac_control_new(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002762 const struct snd_kcontrol_new *ktemp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002763 const char *name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002764 unsigned int subdev)
Mattc7d4b2f2005-06-27 14:59:41 +02002765{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002766 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002767
Takashi Iwai603c4012008-07-30 15:01:44 +02002768 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2769 knew = snd_array_new(&spec->kctls);
2770 if (!knew)
Takashi Iwaie3c75962009-01-23 11:57:22 +01002771 return NULL;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002772 *knew = *ktemp;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002773 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002774 if (!knew->name) {
2775 /* roolback */
2776 memset(knew, 0, sizeof(*knew));
2777 spec->kctls.alloced--;
2778 return NULL;
2779 }
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002780 knew->subdevice = subdev;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002781 return knew;
2782}
2783
2784static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
Takashi Iwai2b635362011-05-02 12:33:43 +02002785 const struct snd_kcontrol_new *ktemp,
Takashi Iwaie3c75962009-01-23 11:57:22 +01002786 int idx, const char *name,
2787 unsigned long val)
2788{
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002789 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002790 HDA_SUBDEV_AMP_FLAG);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002791 if (!knew)
Mattc7d4b2f2005-06-27 14:59:41 +02002792 return -ENOMEM;
Takashi Iwaie3c75962009-01-23 11:57:22 +01002793 knew->index = idx;
Mattc7d4b2f2005-06-27 14:59:41 +02002794 knew->private_value = val;
Mattc7d4b2f2005-06-27 14:59:41 +02002795 return 0;
2796}
2797
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002798static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2799 int type, int idx, const char *name,
2800 unsigned long val)
2801{
2802 return stac92xx_add_control_temp(spec,
2803 &stac92xx_control_templates[type],
2804 idx, name, val);
2805}
2806
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002807
2808/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002809static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2810 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002811{
2812 return stac92xx_add_control_idx(spec, type, 0, name, val);
2813}
2814
Takashi Iwai2b635362011-05-02 12:33:43 +02002815static const struct snd_kcontrol_new stac_input_src_temp = {
Takashi Iwaie3c75962009-01-23 11:57:22 +01002816 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2817 .name = "Input Source",
2818 .info = stac92xx_mux_enum_info,
2819 .get = stac92xx_mux_enum_get,
2820 .put = stac92xx_mux_enum_put,
2821};
2822
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002823static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2824 hda_nid_t nid, int idx)
2825{
2826 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2827 int control = 0;
2828 struct sigmatel_spec *spec = codec->spec;
2829 char name[22];
2830
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002831 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwai47408602012-04-20 13:06:53 +02002832 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002833 && nid == spec->line_switch)
2834 control = STAC_CTL_WIDGET_IO_SWITCH;
2835 else if (snd_hda_query_pin_caps(codec, nid)
2836 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2837 control = STAC_CTL_WIDGET_DC_BIAS;
2838 else if (nid == spec->mic_switch)
2839 control = STAC_CTL_WIDGET_IO_SWITCH;
2840 }
2841
2842 if (control) {
Takashi Iwai201e06f2011-11-16 15:33:26 +01002843 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
2844 name, sizeof(name), NULL);
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02002845 return stac92xx_add_control(codec->spec, control,
2846 strcat(name, " Jack Mode"), nid);
2847 }
2848
2849 return 0;
2850}
2851
Takashi Iwaie3c75962009-01-23 11:57:22 +01002852static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2853{
2854 struct snd_kcontrol_new *knew;
2855 struct hda_input_mux *imux = &spec->private_imux;
2856
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02002857 if (spec->auto_mic)
2858 return 0; /* no need for input source */
Takashi Iwaie3c75962009-01-23 11:57:22 +01002859 if (!spec->num_adcs || imux->num_items <= 1)
2860 return 0; /* no need for input source control */
2861 knew = stac_control_new(spec, &stac_input_src_temp,
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01002862 stac_input_src_temp.name, 0);
Takashi Iwaie3c75962009-01-23 11:57:22 +01002863 if (!knew)
2864 return -ENOMEM;
2865 knew->count = spec->num_adcs;
2866 return 0;
2867}
2868
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002869/* check whether the line-input can be used as line-out */
2870static hda_nid_t check_line_out_switch(struct hda_codec *codec)
Matt Porter403d1942005-11-29 15:00:51 +01002871{
2872 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002873 struct auto_pin_cfg *cfg = &spec->autocfg;
2874 hda_nid_t nid;
2875 unsigned int pincap;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002876 int i;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002877
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002878 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2879 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002880 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02002881 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002882 nid = cfg->inputs[i].pin;
Takashi Iwai1327a322009-03-23 13:07:47 +01002883 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002884 if (pincap & AC_PINCAP_OUT)
2885 return nid;
2886 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002887 }
Matt Porter403d1942005-11-29 15:00:51 +01002888 return 0;
2889}
2890
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002891static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2892
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002893/* check whether the mic-input can be used as line-out */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002894static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002895{
2896 struct sigmatel_spec *spec = codec->spec;
2897 struct auto_pin_cfg *cfg = &spec->autocfg;
2898 unsigned int def_conf, pincap;
Takashi Iwai86e29592010-09-09 14:50:17 +02002899 int i;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002900
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002901 *dac = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002902 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2903 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002904 for (i = 0; i < cfg->num_inputs; i++) {
2905 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai86e29592010-09-09 14:50:17 +02002906 if (cfg->inputs[i].type != AUTO_PIN_MIC)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002907 continue;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002908 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2909 /* some laptops have an internal analog microphone
2910 * which can't be used as a output */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02002911 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002912 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02002913 if (pincap & AC_PINCAP_OUT) {
2914 *dac = get_unassigned_dac(codec, nid);
2915 if (*dac)
2916 return nid;
2917 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002918 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002919 }
2920 return 0;
2921}
Steve Longerbeam7b043892007-05-03 20:50:03 +02002922
2923static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2924{
2925 int i;
2926
2927 for (i = 0; i < spec->multiout.num_dacs; i++) {
2928 if (spec->multiout.dac_nids[i] == nid)
2929 return 1;
2930 }
2931
2932 return 0;
2933}
2934
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002935static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2936{
2937 int i;
2938 if (is_in_dac_nids(spec, nid))
2939 return 1;
2940 for (i = 0; i < spec->autocfg.hp_outs; i++)
2941 if (spec->hp_dacs[i] == nid)
2942 return 1;
2943 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2944 if (spec->speaker_dacs[i] == nid)
2945 return 1;
2946 return 0;
2947}
2948
2949static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2950{
2951 struct sigmatel_spec *spec = codec->spec;
David Henningsson48718ea2011-10-05 09:49:05 +02002952 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002953 int j, conn_len;
David Henningsson48718ea2011-10-05 09:49:05 +02002954 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002955 unsigned int wcaps, wtype;
2956
2957 conn_len = snd_hda_get_connections(codec, nid, conn,
2958 HDA_MAX_CONNECTIONS);
Charles Chin36706002010-01-29 12:05:51 +01002959 /* 92HD88: trace back up the link of nids to find the DAC */
2960 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2961 != AC_WID_AUD_OUT)) {
2962 nid = conn[0];
2963 conn_len = snd_hda_get_connections(codec, nid, conn,
2964 HDA_MAX_CONNECTIONS);
2965 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002966 for (j = 0; j < conn_len; j++) {
Takashi Iwai14bafe32009-03-23 16:35:39 +01002967 wcaps = get_wcaps(codec, conn[j]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02002968 wtype = get_wcaps_type(wcaps);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01002969 /* we check only analog outputs */
2970 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2971 continue;
2972 /* if this route has a free DAC, assign it */
2973 if (!check_all_dac_nids(spec, conn[j])) {
2974 if (conn_len > 1) {
2975 /* select this DAC in the pin's input mux */
2976 snd_hda_codec_write_cache(codec, nid, 0,
2977 AC_VERB_SET_CONNECT_SEL, j);
2978 }
2979 return conn[j];
2980 }
2981 }
David Henningsson48718ea2011-10-05 09:49:05 +02002982
2983 /* if all DACs are already assigned, connect to the primary DAC,
2984 unless we're assigning a secondary headphone */
2985 fallback_dac = spec->multiout.dac_nids[0];
2986 if (spec->multiout.hp_nid) {
2987 for (j = 0; j < cfg->hp_outs; j++)
2988 if (cfg->hp_pins[j] == nid) {
2989 fallback_dac = spec->multiout.hp_nid;
2990 break;
2991 }
2992 }
2993
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002994 if (conn_len > 1) {
2995 for (j = 0; j < conn_len; j++) {
David Henningsson48718ea2011-10-05 09:49:05 +02002996 if (conn[j] == fallback_dac) {
Takashi Iwaiee58a7c2009-03-06 12:00:24 +01002997 snd_hda_codec_write_cache(codec, nid, 0,
2998 AC_VERB_SET_CONNECT_SEL, j);
2999 break;
3000 }
3001 }
3002 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003003 return 0;
3004}
3005
3006static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3007static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3008
Matt Porter3cc08dc2006-01-23 15:27:49 +01003009/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02003010 * Fill in the dac_nids table from the parsed pin configuration
3011 * This function only works when every pin in line_out_pins[]
3012 * contains atleast one DAC in its connection list. Some 92xx
3013 * codecs are not connected directly to a DAC, such as the 9200
3014 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01003015 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003016static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003017{
3018 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003019 struct auto_pin_cfg *cfg = &spec->autocfg;
3020 int i;
3021 hda_nid_t nid, dac;
Steve Longerbeam7b043892007-05-03 20:50:03 +02003022
Mattc7d4b2f2005-06-27 14:59:41 +02003023 for (i = 0; i < cfg->line_outs; i++) {
3024 nid = cfg->line_out_pins[i];
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003025 dac = get_unassigned_dac(codec, nid);
3026 if (!dac) {
Takashi Iwaidf802952007-07-02 19:18:00 +02003027 if (spec->multiout.num_dacs > 0) {
3028 /* we have already working output pins,
3029 * so let's drop the broken ones again
3030 */
3031 cfg->line_outs = spec->multiout.num_dacs;
3032 break;
3033 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003034 /* error out, no available DAC found */
3035 snd_printk(KERN_ERR
3036 "%s: No available DAC for pin 0x%x\n",
3037 __func__, nid);
3038 return -ENODEV;
3039 }
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003040 add_spec_dacs(spec, dac);
3041 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02003042
Takashi Iwai139e0712009-03-06 12:10:41 +01003043 for (i = 0; i < cfg->hp_outs; i++) {
3044 nid = cfg->hp_pins[i];
3045 dac = get_unassigned_dac(codec, nid);
3046 if (dac) {
3047 if (!spec->multiout.hp_nid)
3048 spec->multiout.hp_nid = dac;
3049 else
3050 add_spec_extra_dacs(spec, dac);
3051 }
3052 spec->hp_dacs[i] = dac;
3053 }
3054
3055 for (i = 0; i < cfg->speaker_outs; i++) {
3056 nid = cfg->speaker_pins[i];
3057 dac = get_unassigned_dac(codec, nid);
3058 if (dac)
3059 add_spec_extra_dacs(spec, dac);
3060 spec->speaker_dacs[i] = dac;
3061 }
3062
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003063 /* add line-in as output */
3064 nid = check_line_out_switch(codec);
3065 if (nid) {
3066 dac = get_unassigned_dac(codec, nid);
3067 if (dac) {
3068 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3069 nid, cfg->line_outs);
3070 cfg->line_out_pins[cfg->line_outs] = nid;
3071 cfg->line_outs++;
3072 spec->line_switch = nid;
3073 add_spec_dacs(spec, dac);
3074 }
3075 }
3076 /* add mic as output */
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003077 nid = check_mic_out_switch(codec, &dac);
3078 if (nid && dac) {
3079 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3080 nid, cfg->line_outs);
3081 cfg->line_out_pins[cfg->line_outs] = nid;
3082 cfg->line_outs++;
3083 spec->mic_switch = nid;
3084 add_spec_dacs(spec, dac);
Mattc7d4b2f2005-06-27 14:59:41 +02003085 }
3086
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003087 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
Steve Longerbeam7b043892007-05-03 20:50:03 +02003088 spec->multiout.num_dacs,
3089 spec->multiout.dac_nids[0],
3090 spec->multiout.dac_nids[1],
3091 spec->multiout.dac_nids[2],
3092 spec->multiout.dac_nids[3],
3093 spec->multiout.dac_nids[4]);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003094
Mattc7d4b2f2005-06-27 14:59:41 +02003095 return 0;
3096}
3097
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003098/* create volume control/switch for the given prefx type */
Takashi Iwai668b9652009-03-06 10:13:24 +01003099static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3100 int idx, hda_nid_t nid, int chs)
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003101{
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003102 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003103 char name[32];
3104 int err;
3105
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003106 if (!spec->check_volume_offset) {
3107 unsigned int caps, step, nums, db_scale;
3108 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3109 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3110 AC_AMPCAP_STEP_SIZE_SHIFT;
3111 step = (step + 1) * 25; /* in .01dB unit */
3112 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3113 AC_AMPCAP_NUM_STEPS_SHIFT;
3114 db_scale = nums * step;
3115 /* if dB scale is over -64dB, and finer enough,
3116 * let's reduce it to half
3117 */
3118 if (db_scale > 6400 && nums >= 0x1f)
3119 spec->volume_offset = nums / 2;
3120 spec->check_volume_offset = 1;
3121 }
3122
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003123 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003124 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003125 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3126 spec->volume_offset));
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003127 if (err < 0)
3128 return err;
3129 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai668b9652009-03-06 10:13:24 +01003130 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003131 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3132 if (err < 0)
3133 return err;
3134 return 0;
3135}
3136
Takashi Iwai668b9652009-03-06 10:13:24 +01003137#define create_controls(codec, pfx, nid, chs) \
3138 create_controls_idx(codec, pfx, 0, nid, chs)
3139
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003140static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3141{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003142 if (spec->multiout.num_dacs > 4) {
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003143 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3144 return 1;
3145 } else {
Takashi Iwaidda14412011-05-02 11:29:30 +02003146 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3147 spec->dac_nids[spec->multiout.num_dacs] = nid;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003148 spec->multiout.num_dacs++;
3149 }
3150 return 0;
3151}
3152
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003153static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003154{
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003155 int i;
3156 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3157 if (!spec->multiout.extra_out_nid[i]) {
3158 spec->multiout.extra_out_nid[i] = nid;
3159 return 0;
3160 }
3161 }
3162 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3163 return 1;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01003164}
3165
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003166/* Create output controls
3167 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3168 */
3169static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3170 const hda_nid_t *pins,
3171 const hda_nid_t *dac_nids,
3172 int type)
Mattc7d4b2f2005-06-27 14:59:41 +02003173{
Takashi Iwai76624532008-12-19 10:09:47 +01003174 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +01003175 static const char * const chname[4] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +02003176 "Front", "Surround", NULL /*CLFE*/, "Side"
3177 };
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003178 hda_nid_t nid;
Takashi Iwai91589232008-12-19 15:59:40 +01003179 int i, err;
3180 unsigned int wid_caps;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003181
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003182 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003183 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003184 if (is_jack_detectable(codec, pins[i]))
Takashi Iwaiffd0e562009-04-16 12:20:24 +02003185 spec->hp_detect = 1;
3186 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003187 nid = dac_nids[i];
3188 if (!nid)
3189 continue;
3190 if (type != AUTO_PIN_HP_OUT && i == 2) {
Mattc7d4b2f2005-06-27 14:59:41 +02003191 /* Center/LFE */
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003192 err = create_controls(codec, "Center", nid, 1);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003193 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003194 return err;
Takashi Iwai7c7767e2009-01-20 15:28:38 +01003195 err = create_controls(codec, "LFE", nid, 2);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003196 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003197 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003198
3199 wid_caps = get_wcaps(codec, nid);
3200
3201 if (wid_caps & AC_WCAP_LR_SWAP) {
3202 err = stac92xx_add_control(spec,
3203 STAC_CTL_WIDGET_CLFE_SWITCH,
3204 "Swap Center/LFE Playback Switch", nid);
3205
3206 if (err < 0)
3207 return err;
3208 }
3209
Mattc7d4b2f2005-06-27 14:59:41 +02003210 } else {
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003211 const char *name;
Takashi Iwai668b9652009-03-06 10:13:24 +01003212 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003213 switch (type) {
3214 case AUTO_PIN_HP_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003215 name = "Headphone";
3216 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003217 break;
3218 case AUTO_PIN_SPEAKER_OUT:
Takashi Iwai668b9652009-03-06 10:13:24 +01003219 name = "Speaker";
3220 idx = i;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003221 break;
3222 default:
3223 name = chname[i];
Takashi Iwai668b9652009-03-06 10:13:24 +01003224 idx = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003225 break;
Takashi Iwai76624532008-12-19 10:09:47 +01003226 }
Takashi Iwai668b9652009-03-06 10:13:24 +01003227 err = create_controls_idx(codec, name, idx, nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003228 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003229 return err;
3230 }
3231 }
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003232 return 0;
3233}
3234
Takashi Iwai6479c632009-07-28 18:20:25 +02003235static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3236 unsigned long sw, int idx)
3237{
3238 int err;
3239 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003240 "Capture Volume", vol);
Takashi Iwai6479c632009-07-28 18:20:25 +02003241 if (err < 0)
3242 return err;
3243 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
Takashi Iwaibf677bd2009-07-30 09:24:29 +02003244 "Capture Switch", sw);
Takashi Iwai6479c632009-07-28 18:20:25 +02003245 if (err < 0)
3246 return err;
3247 return 0;
3248}
3249
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003250/* add playback controls from the parsed DAC table */
3251static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3252 const struct auto_pin_cfg *cfg)
3253{
3254 struct sigmatel_spec *spec = codec->spec;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003255 hda_nid_t nid;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003256 int err;
Nickolas Lloyd7c922de2009-06-01 11:12:29 +02003257 int idx;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003258
3259 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3260 spec->multiout.dac_nids,
3261 cfg->line_out_type);
3262 if (err < 0)
3263 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003264
Takashi Iwaia9cb5c92008-11-24 07:51:11 +01003265 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003266 err = stac92xx_add_control(spec,
3267 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01003268 "Headphone as Line Out Switch",
3269 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003270 if (err < 0)
3271 return err;
3272 }
3273
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003274 for (idx = 0; idx < cfg->num_inputs; idx++) {
Takashi Iwai86e29592010-09-09 14:50:17 +02003275 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003276 break;
3277 nid = cfg->inputs[idx].pin;
3278 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3279 if (err < 0)
3280 return err;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01003281 }
Matt Porter403d1942005-11-29 15:00:51 +01003282
Mattc7d4b2f2005-06-27 14:59:41 +02003283 return 0;
3284}
3285
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003286/* add playback controls for Speaker and HP outputs */
3287static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3288 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02003289{
3290 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003291 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02003292
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003293 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3294 spec->hp_dacs, AUTO_PIN_HP_OUT);
3295 if (err < 0)
3296 return err;
3297
3298 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3299 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3300 if (err < 0)
3301 return err;
3302
Mattc7d4b2f2005-06-27 14:59:41 +02003303 return 0;
3304}
3305
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003306/* labels for mono mux outputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003307static const char * const stac92xx_mono_labels[4] = {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003308 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003309};
3310
3311/* create mono mux for mono out on capable codecs */
3312static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3313{
3314 struct sigmatel_spec *spec = codec->spec;
3315 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3316 int i, num_cons;
3317 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3318
3319 num_cons = snd_hda_get_connections(codec,
3320 spec->mono_nid,
3321 con_lst,
3322 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003323 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003324 return -EINVAL;
3325
Takashi Iwai10a20af2010-09-09 16:28:02 +02003326 for (i = 0; i < num_cons; i++)
3327 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3328 NULL);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003329
3330 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3331 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003332}
3333
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003334/* create PC beep volume controls */
3335static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3336 hda_nid_t nid)
3337{
3338 struct sigmatel_spec *spec = codec->spec;
3339 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003340 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3341
3342 if (spec->anabeep_nid == nid)
3343 type = STAC_CTL_WIDGET_MUTE;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003344
3345 /* check for mute support for the the amp */
3346 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003347 err = stac92xx_add_control(spec, type,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003348 "Beep Playback Switch",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003349 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3350 if (err < 0)
3351 return err;
3352 }
3353
3354 /* check to see if there is volume support for the amp */
3355 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3356 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003357 "Beep Playback Volume",
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003358 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3359 if (err < 0)
3360 return err;
3361 }
3362 return 0;
3363}
3364
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003365#ifdef CONFIG_SND_HDA_INPUT_BEEP
3366#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3367
3368static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3369 struct snd_ctl_elem_value *ucontrol)
3370{
3371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3372 ucontrol->value.integer.value[0] = codec->beep->enabled;
3373 return 0;
3374}
3375
3376static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3377 struct snd_ctl_elem_value *ucontrol)
3378{
3379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02003380 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003381}
3382
Takashi Iwai2b635362011-05-02 12:33:43 +02003383static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3385 .info = stac92xx_dig_beep_switch_info,
3386 .get = stac92xx_dig_beep_switch_get,
3387 .put = stac92xx_dig_beep_switch_put,
3388};
3389
3390static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3391{
3392 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01003393 0, "Beep Playback Switch", 0);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003394}
3395#endif
3396
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003397static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3398{
3399 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai667067d2009-08-13 18:14:42 +02003400 int i, j, err = 0;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003401
3402 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003403 hda_nid_t nid;
3404 unsigned int wcaps;
3405 unsigned long val;
3406
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003407 nid = spec->mux_nids[i];
3408 wcaps = get_wcaps(codec, nid);
Takashi Iwai667067d2009-08-13 18:14:42 +02003409 if (!(wcaps & AC_WCAP_OUT_AMP))
3410 continue;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003411
Takashi Iwai667067d2009-08-13 18:14:42 +02003412 /* check whether already the same control was created as
3413 * normal Capture Volume.
3414 */
3415 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3416 for (j = 0; j < spec->num_caps; j++) {
3417 if (spec->capvols[j] == val)
3418 break;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003419 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003420 if (j < spec->num_caps)
3421 continue;
3422
3423 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3424 "Mux Capture Volume", val);
3425 if (err < 0)
3426 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003427 }
3428 return 0;
3429};
3430
Takashi Iwaiea734962011-01-17 11:29:34 +01003431static const char * const stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003432 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003433};
3434
3435static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3436{
3437 struct sigmatel_spec *spec = codec->spec;
3438 struct hda_input_mux *spdif_mux = &spec->private_smux;
Takashi Iwaiea734962011-01-17 11:29:34 +01003439 const char * const *labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003440 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003441 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003442
3443 num_cons = snd_hda_get_connections(codec,
3444 spec->smux_nids[0],
3445 con_lst,
3446 HDA_MAX_NUM_INPUTS);
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003447 if (num_cons <= 0)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003448 return -EINVAL;
3449
Matthew Ranostay65973632008-09-16 10:39:37 -04003450 if (!labels)
3451 labels = stac92xx_spdif_labels;
3452
Takashi Iwai10a20af2010-09-09 16:28:02 +02003453 for (i = 0; i < num_cons; i++)
3454 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
Matthew Ranostayd9737752008-09-07 12:03:41 +02003455
3456 return 0;
3457}
3458
Matt Porter8b657272006-10-26 17:12:59 +02003459/* labels for dmic mux inputs */
Takashi Iwaiea734962011-01-17 11:29:34 +01003460static const char * const stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003461 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3462 "Digital Mic 3", "Digital Mic 4"
3463};
3464
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003465static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3466 int idx)
3467{
3468 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3469 int nums;
3470 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3471 if (idx >= 0 && idx < nums)
3472 return conn[idx];
3473 return 0;
3474}
3475
Takashi Iwai8d087c72011-06-28 12:45:47 +02003476/* look for NID recursively */
3477#define get_connection_index(codec, mux, nid) \
3478 snd_hda_get_conn_index(codec, mux, nid, 1)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003479
Takashi Iwai667067d2009-08-13 18:14:42 +02003480/* create a volume assigned to the given pin (only if supported) */
Takashi Iwai96f845d2009-08-29 00:49:36 +02003481/* return 1 if the volume control is created */
Takashi Iwai667067d2009-08-13 18:14:42 +02003482static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003483 const char *label, int idx, int direction)
Takashi Iwai667067d2009-08-13 18:14:42 +02003484{
3485 unsigned int caps, nums;
3486 char name[32];
Takashi Iwai96f845d2009-08-29 00:49:36 +02003487 int err;
Takashi Iwai667067d2009-08-13 18:14:42 +02003488
Takashi Iwai96f845d2009-08-29 00:49:36 +02003489 if (direction == HDA_OUTPUT)
3490 caps = AC_WCAP_OUT_AMP;
3491 else
3492 caps = AC_WCAP_IN_AMP;
3493 if (!(get_wcaps(codec, nid) & caps))
Takashi Iwai667067d2009-08-13 18:14:42 +02003494 return 0;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003495 caps = query_amp_caps(codec, nid, direction);
Takashi Iwai667067d2009-08-13 18:14:42 +02003496 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3497 if (!nums)
3498 return 0;
3499 snprintf(name, sizeof(name), "%s Capture Volume", label);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003500 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3501 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
Takashi Iwai96f845d2009-08-29 00:49:36 +02003502 if (err < 0)
3503 return err;
3504 return 1;
Takashi Iwai667067d2009-08-13 18:14:42 +02003505}
3506
Matt Porter8b657272006-10-26 17:12:59 +02003507/* create playback/capture controls for input pins on dmic capable codecs */
3508static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3509 const struct auto_pin_cfg *cfg)
3510{
3511 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai5207e102009-07-30 13:09:08 +02003512 struct hda_input_mux *imux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003513 struct hda_input_mux *dimux = &spec->private_dimux;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003514 int err, i;
Takashi Iwai5207e102009-07-30 13:09:08 +02003515 unsigned int def_conf;
Matt Porter8b657272006-10-26 17:12:59 +02003516
Takashi Iwai10a20af2010-09-09 16:28:02 +02003517 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
Takashi Iwai5207e102009-07-30 13:09:08 +02003518
Matt Porter8b657272006-10-26 17:12:59 +02003519 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003520 hda_nid_t nid;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003521 int index, type_idx;
Takashi Iwai201e06f2011-11-16 15:33:26 +01003522 char label[32];
Matt Porter8b657272006-10-26 17:12:59 +02003523
Takashi Iwai667067d2009-08-13 18:14:42 +02003524 nid = spec->dmic_nids[i];
3525 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3526 continue;
3527 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Matt Porter8b657272006-10-26 17:12:59 +02003528 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3529 continue;
3530
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003531 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3532 if (index < 0)
3533 continue;
3534
Takashi Iwai201e06f2011-11-16 15:33:26 +01003535 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3536 label, sizeof(label), NULL);
Takashi Iwai10a20af2010-09-09 16:28:02 +02003537 snd_hda_add_imux_item(dimux, label, index, &type_idx);
Takashi Iwai2d7ec122010-12-23 10:16:05 +01003538 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3539 snd_hda_add_imux_item(imux, label, index, &type_idx);
Takashi Iwai5207e102009-07-30 13:09:08 +02003540
Takashi Iwai10a20af2010-09-09 16:28:02 +02003541 err = create_elem_capture_vol(codec, nid, label, type_idx,
3542 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003543 if (err < 0)
3544 return err;
Takashi Iwai96f845d2009-08-29 00:49:36 +02003545 if (!err) {
3546 err = create_elem_capture_vol(codec, nid, label,
Takashi Iwai10a20af2010-09-09 16:28:02 +02003547 type_idx, HDA_OUTPUT);
Takashi Iwai96f845d2009-08-29 00:49:36 +02003548 if (err < 0)
3549 return err;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06003550 if (!err) {
3551 nid = get_connected_node(codec,
3552 spec->dmux_nids[0], index);
3553 if (nid)
3554 err = create_elem_capture_vol(codec,
3555 nid, label,
3556 type_idx, HDA_INPUT);
3557 if (err < 0)
3558 return err;
3559 }
Takashi Iwai96f845d2009-08-29 00:49:36 +02003560 }
Matt Porter8b657272006-10-26 17:12:59 +02003561 }
3562
3563 return 0;
3564}
3565
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003566static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
Charles Chin99077902010-09-17 10:22:32 +02003567 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003568{
3569 unsigned int cfg;
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003570 unsigned int type;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003571
3572 if (!nid)
3573 return 0;
3574 cfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003575 type = get_defcfg_device(cfg);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003576 switch (snd_hda_get_input_pin_attr(cfg)) {
3577 case INPUT_PIN_ATTR_INT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003578 if (*fixed)
3579 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003580 if (type != AC_JACK_MIC_IN)
3581 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003582 *fixed = nid;
3583 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003584 case INPUT_PIN_ATTR_UNUSED:
3585 break;
3586 case INPUT_PIN_ATTR_DOCK:
3587 if (*dock)
3588 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003589 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3590 return 1; /* invalid type */
Takashi Iwai99ae28b2010-09-17 14:42:34 +02003591 *dock = nid;
3592 break;
3593 default:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003594 if (*ext)
3595 return 1; /* already occupied */
Takashi Iwai1f83ac52011-05-17 12:29:09 +02003596 if (type != AC_JACK_MIC_IN)
3597 return 1; /* invalid type */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003598 *ext = nid;
3599 break;
3600 }
3601 return 0;
3602}
3603
3604static int set_mic_route(struct hda_codec *codec,
3605 struct sigmatel_mic_route *mic,
3606 hda_nid_t pin)
3607{
3608 struct sigmatel_spec *spec = codec->spec;
3609 struct auto_pin_cfg *cfg = &spec->autocfg;
3610 int i;
3611
3612 mic->pin = pin;
Charles Chin99077902010-09-17 10:22:32 +02003613 if (pin == 0)
3614 return 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003615 for (i = 0; i < cfg->num_inputs; i++) {
3616 if (pin == cfg->inputs[i].pin)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003617 break;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003618 }
Takashi Iwai86e29592010-09-09 14:50:17 +02003619 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003620 /* analog pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003621 i = get_connection_index(codec, spec->mux_nids[0], pin);
3622 if (i < 0)
3623 return -1;
3624 mic->mux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003625 mic->dmux_idx = -1;
3626 if (spec->dmux_nids)
3627 mic->dmux_idx = get_connection_index(codec,
3628 spec->dmux_nids[0],
3629 spec->mux_nids[0]);
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02003630 } else if (spec->dmux_nids) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003631 /* digital pin */
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003632 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3633 if (i < 0)
3634 return -1;
3635 mic->dmux_idx = i;
Takashi Iwai02d33322009-10-01 16:38:11 +02003636 mic->mux_idx = -1;
3637 if (spec->mux_nids)
3638 mic->mux_idx = get_connection_index(codec,
3639 spec->mux_nids[0],
3640 spec->dmux_nids[0]);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003641 }
3642 return 0;
3643}
3644
3645/* return non-zero if the device is for automatic mic switch */
3646static int stac_check_auto_mic(struct hda_codec *codec)
3647{
3648 struct sigmatel_spec *spec = codec->spec;
3649 struct auto_pin_cfg *cfg = &spec->autocfg;
Charles Chin99077902010-09-17 10:22:32 +02003650 hda_nid_t fixed, ext, dock;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003651 int i;
3652
Charles Chin99077902010-09-17 10:22:32 +02003653 fixed = ext = dock = 0;
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003654 for (i = 0; i < cfg->num_inputs; i++)
Charles Chin99077902010-09-17 10:22:32 +02003655 if (check_mic_pin(codec, cfg->inputs[i].pin,
3656 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003657 return 0;
3658 for (i = 0; i < spec->num_dmics; i++)
Charles Chin99077902010-09-17 10:22:32 +02003659 if (check_mic_pin(codec, spec->dmic_nids[i],
3660 &fixed, &ext, &dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003661 return 0;
Takashi Iwai80c67852011-01-13 08:08:08 +01003662 if (!fixed || (!ext && !dock))
Charles Chin99077902010-09-17 10:22:32 +02003663 return 0; /* no input to switch */
Takashi Iwaie35d9d62011-05-17 11:28:16 +02003664 if (!is_jack_detectable(codec, ext))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003665 return 0; /* no unsol support */
3666 if (set_mic_route(codec, &spec->ext_mic, ext) ||
Charles Chin99077902010-09-17 10:22:32 +02003667 set_mic_route(codec, &spec->int_mic, fixed) ||
3668 set_mic_route(codec, &spec->dock_mic, dock))
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003669 return 0; /* something is wrong */
3670 return 1;
3671}
3672
Mattc7d4b2f2005-06-27 14:59:41 +02003673/* create playback/capture controls for input pins */
3674static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3675{
3676 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003677 struct hda_input_mux *imux = &spec->private_imux;
Takashi Iwai667067d2009-08-13 18:14:42 +02003678 int i, j;
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003679 const char *label;
Mattc7d4b2f2005-06-27 14:59:41 +02003680
Takashi Iwaieea7dc92010-08-30 13:06:15 +02003681 for (i = 0; i < cfg->num_inputs; i++) {
3682 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02003683 int index, err, type_idx;
Mattc7d4b2f2005-06-27 14:59:41 +02003684
Takashi Iwai314634b2006-09-21 11:56:18 +02003685 index = -1;
3686 for (j = 0; j < spec->num_muxes; j++) {
Takashi Iwai667067d2009-08-13 18:14:42 +02003687 index = get_connection_index(codec, spec->mux_nids[j],
3688 nid);
3689 if (index >= 0)
3690 break;
Mattc7d4b2f2005-06-27 14:59:41 +02003691 }
Takashi Iwai667067d2009-08-13 18:14:42 +02003692 if (index < 0)
3693 continue;
3694
Takashi Iwai10a20af2010-09-09 16:28:02 +02003695 label = hda_get_autocfg_input_label(codec, cfg, i);
3696 snd_hda_add_imux_item(imux, label, index, &type_idx);
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003697
Takashi Iwai667067d2009-08-13 18:14:42 +02003698 err = create_elem_capture_vol(codec, nid,
Vitaliy Kulikov263d0322010-09-08 08:56:03 +02003699 label, type_idx,
Takashi Iwai96f845d2009-08-29 00:49:36 +02003700 HDA_INPUT);
Takashi Iwai667067d2009-08-13 18:14:42 +02003701 if (err < 0)
3702 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003703 }
Takashi Iwai5207e102009-07-30 13:09:08 +02003704 spec->num_analog_muxes = imux->num_items;
Mattc7d4b2f2005-06-27 14:59:41 +02003705
Steve Longerbeam7b043892007-05-03 20:50:03 +02003706 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003707 /*
3708 * Set the current input for the muxes.
3709 * The STAC9221 has two input muxes with identical source
3710 * NID lists. Hopefully this won't get confused.
3711 */
3712 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003713 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3714 AC_VERB_SET_CONNECT_SEL,
3715 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003716 }
3717 }
3718
Mattc7d4b2f2005-06-27 14:59:41 +02003719 return 0;
3720}
3721
Mattc7d4b2f2005-06-27 14:59:41 +02003722static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3723{
3724 struct sigmatel_spec *spec = codec->spec;
3725 int i;
3726
3727 for (i = 0; i < spec->autocfg.line_outs; i++) {
3728 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3729 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3730 }
3731}
3732
3733static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3734{
3735 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003736 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003737
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003738 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3739 hda_nid_t pin;
3740 pin = spec->autocfg.hp_pins[i];
3741 if (pin) /* connect to front */
3742 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3743 }
3744 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3745 hda_nid_t pin;
3746 pin = spec->autocfg.speaker_pins[i];
3747 if (pin) /* connect to front */
3748 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3749 }
Mattc7d4b2f2005-06-27 14:59:41 +02003750}
3751
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003752static int is_dual_headphones(struct hda_codec *codec)
3753{
3754 struct sigmatel_spec *spec = codec->spec;
3755 int i, valid_hps;
3756
3757 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3758 spec->autocfg.hp_outs <= 1)
3759 return 0;
3760 valid_hps = 0;
3761 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3762 hda_nid_t nid = spec->autocfg.hp_pins[i];
3763 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3764 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3765 continue;
3766 valid_hps++;
3767 }
3768 return (valid_hps > 1);
3769}
3770
3771
Charles Chin9009b0e2011-11-03 10:27:27 +01003772static int stac92xx_parse_auto_config(struct hda_codec *codec)
Mattc7d4b2f2005-06-27 14:59:41 +02003773{
3774 struct sigmatel_spec *spec = codec->spec;
Charles Chin9009b0e2011-11-03 10:27:27 +01003775 hda_nid_t dig_out = 0, dig_in = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003776 int hp_swap = 0;
Takashi Iwai6479c632009-07-28 18:20:25 +02003777 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003778
Matt Porter8b657272006-10-26 17:12:59 +02003779 if ((err = snd_hda_parse_pin_def_config(codec,
3780 &spec->autocfg,
3781 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003782 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003783 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003784 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003785
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003786 /* If we have no real line-out pin and multiple hp-outs, HPs should
3787 * be set up as multi-channel outputs.
3788 */
Takashi Iwai8af3aeb2009-11-18 14:23:37 +01003789 if (is_dual_headphones(codec)) {
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003790 /* Copy hp_outs to line_outs, backup line_outs in
3791 * speaker_outs so that the following routines can handle
3792 * HP pins as primary outputs.
3793 */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003794 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003795 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3796 sizeof(spec->autocfg.line_out_pins));
3797 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3798 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3799 sizeof(spec->autocfg.hp_pins));
3800 spec->autocfg.line_outs = spec->autocfg.hp_outs;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003801 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3802 spec->autocfg.hp_outs = 0;
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003803 hp_swap = 1;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003804 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003805 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003806 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3807 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003808 u32 caps = query_amp_caps(codec,
3809 spec->autocfg.mono_out_pin, dir);
3810 hda_nid_t conn_list[1];
3811
3812 /* get the mixer node and then the mono mux if it exists */
3813 if (snd_hda_get_connections(codec,
3814 spec->autocfg.mono_out_pin, conn_list, 1) &&
3815 snd_hda_get_connections(codec, conn_list[0],
Jaroslav Kysela16a433d2009-07-22 16:20:40 +02003816 conn_list, 1) > 0) {
Matthew Ranostay09a99952008-01-24 11:49:21 +01003817
3818 int wcaps = get_wcaps(codec, conn_list[0]);
Takashi Iwaia22d5432009-07-27 12:54:26 +02003819 int wid_type = get_wcaps_type(wcaps);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003820 /* LR swap check, some stac925x have a mux that
3821 * changes the DACs output path instead of the
3822 * mono-mux path.
3823 */
3824 if (wid_type == AC_WID_AUD_SEL &&
3825 !(wcaps & AC_WCAP_LR_SWAP))
3826 spec->mono_nid = conn_list[0];
3827 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003828 if (dir) {
3829 hda_nid_t nid = spec->autocfg.mono_out_pin;
3830
3831 /* most mono outs have a least a mute/unmute switch */
3832 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3833 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3834 "Mono Playback Switch",
3835 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003836 if (err < 0)
3837 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003838 /* check for volume support for the amp */
3839 if ((caps & AC_AMPCAP_NUM_STEPS)
3840 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3841 err = stac92xx_add_control(spec,
3842 STAC_CTL_WIDGET_VOL,
3843 "Mono Playback Volume",
3844 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3845 if (err < 0)
3846 return err;
3847 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003848 }
3849
3850 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3851 AC_PINCTL_OUT_EN);
3852 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003853
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003854 if (!spec->multiout.num_dacs) {
3855 err = stac92xx_auto_fill_dac_nids(codec);
3856 if (err < 0)
Takashi Iwai19039bd2006-06-28 15:52:16 +02003857 return err;
Takashi Iwaic9280d62009-01-15 17:31:00 +01003858 err = stac92xx_auto_create_multi_out_ctls(codec,
3859 &spec->autocfg);
3860 if (err < 0)
3861 return err;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01003862 }
Mattc7d4b2f2005-06-27 14:59:41 +02003863
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003864 /* setup analog beep controls */
3865 if (spec->anabeep_nid > 0) {
3866 err = stac92xx_auto_create_beep_ctls(codec,
3867 spec->anabeep_nid);
3868 if (err < 0)
3869 return err;
3870 }
3871
3872 /* setup digital beep controls and input device */
3873#ifdef CONFIG_SND_HDA_INPUT_BEEP
3874 if (spec->digbeep_nid > 0) {
3875 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003876 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003877
3878 err = stac92xx_auto_create_beep_ctls(codec, nid);
3879 if (err < 0)
3880 return err;
3881 err = snd_hda_attach_beep_device(codec, nid);
3882 if (err < 0)
3883 return err;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003884 if (codec->beep) {
3885 /* IDT/STAC codecs have linear beep tone parameter */
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01003886 codec->beep->linear_tone = spec->linear_tone_beep;
Takashi Iwaid8d881d2009-12-22 07:52:49 +01003887 /* if no beep switch is available, make its own one */
3888 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3889 if (!(caps & AC_AMPCAP_MUTE)) {
3890 err = stac92xx_beep_switch_ctl(codec);
3891 if (err < 0)
3892 return err;
3893 }
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003894 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003895 }
3896#endif
3897
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003898 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003899 if (err < 0)
3900 return err;
3901
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003902 /* All output parsing done, now restore the swapped hp pins */
3903 if (hp_swap) {
3904 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3905 sizeof(spec->autocfg.hp_pins));
3906 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3907 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3908 spec->autocfg.line_outs = 0;
3909 }
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003910
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02003911 if (stac_check_auto_mic(codec)) {
3912 spec->auto_mic = 1;
3913 /* only one capture for auto-mic */
3914 spec->num_adcs = 1;
3915 spec->num_caps = 1;
3916 spec->num_muxes = 1;
3917 }
3918
Takashi Iwai6479c632009-07-28 18:20:25 +02003919 for (i = 0; i < spec->num_caps; i++) {
3920 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3921 spec->capsws[i], i);
3922 if (err < 0)
3923 return err;
3924 }
3925
Takashi Iwaidc04d1b2009-03-06 10:00:05 +01003926 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003927 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003928 return err;
3929
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003930 if (spec->mono_nid > 0) {
3931 err = stac92xx_auto_create_mono_output_ctls(codec);
3932 if (err < 0)
3933 return err;
3934 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003935 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003936 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3937 &spec->autocfg)) < 0)
3938 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003939 if (spec->num_muxes > 0) {
3940 err = stac92xx_auto_create_mux_input_ctls(codec);
3941 if (err < 0)
3942 return err;
3943 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003944 if (spec->num_smuxes > 0) {
3945 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3946 if (err < 0)
3947 return err;
3948 }
Matt Porter8b657272006-10-26 17:12:59 +02003949
Takashi Iwaie3c75962009-01-23 11:57:22 +01003950 err = stac92xx_add_input_source(spec);
3951 if (err < 0)
3952 return err;
3953
Mattc7d4b2f2005-06-27 14:59:41 +02003954 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003955 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003956 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003957
Charles Chin9009b0e2011-11-03 10:27:27 +01003958 /* find digital out and in converters */
3959 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3960 unsigned int wid_caps = get_wcaps(codec, i);
3961 if (wid_caps & AC_WCAP_DIGITAL) {
3962 switch (get_wcaps_type(wid_caps)) {
3963 case AC_WID_AUD_OUT:
3964 if (!dig_out)
3965 dig_out = i;
3966 break;
3967 case AC_WID_AUD_IN:
3968 if (!dig_in)
3969 dig_in = i;
3970 break;
3971 }
3972 }
3973 }
Takashi Iwai0852d7a2009-02-11 11:35:15 +01003974 if (spec->autocfg.dig_outs)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003975 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003976 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003977 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003978
Takashi Iwai603c4012008-07-30 15:01:44 +02003979 if (spec->kctls.list)
3980 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02003981
3982 spec->input_mux = &spec->private_imux;
Matthew Ranostayf8ccbf62008-12-20 17:36:28 -05003983 if (!spec->dinput_mux)
3984 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003985 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003986 spec->mono_mux = &spec->private_mono_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003987 return 1;
3988}
3989
Takashi Iwai82bc9552006-03-21 11:24:42 +01003990/* add playback controls for HP output */
3991static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3992 struct auto_pin_cfg *cfg)
3993{
3994 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003995 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003996
3997 if (! pin)
3998 return 0;
3999
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004000 if (is_jack_detectable(codec, pin))
Takashi Iwai82bc9552006-03-21 11:24:42 +01004001 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004002
4003 return 0;
4004}
4005
Richard Fish160ea0d2006-09-06 13:58:25 +02004006/* add playback controls for LFE output */
4007static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4008 struct auto_pin_cfg *cfg)
4009{
4010 struct sigmatel_spec *spec = codec->spec;
4011 int err;
4012 hda_nid_t lfe_pin = 0x0;
4013 int i;
4014
4015 /*
4016 * search speaker outs and line outs for a mono speaker pin
4017 * with an amp. If one is found, add LFE controls
4018 * for it.
4019 */
4020 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4021 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004022 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004023 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4024 if (wcaps == AC_WCAP_OUT_AMP)
4025 /* found a mono speaker with an amp, must be lfe */
4026 lfe_pin = pin;
4027 }
4028
4029 /* if speaker_outs is 0, then speakers may be in line_outs */
4030 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4031 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4032 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004033 unsigned int defcfg;
Takashi Iwai330ee992009-02-20 14:33:36 +01004034 defcfg = snd_hda_codec_get_pincfg(codec, pin);
Harvey Harrison8b551782008-02-29 11:56:48 +01004035 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01004036 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02004037 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4038 if (wcaps == AC_WCAP_OUT_AMP)
4039 /* found a mono speaker with an amp,
4040 must be lfe */
4041 lfe_pin = pin;
4042 }
4043 }
4044 }
4045
4046 if (lfe_pin) {
Takashi Iwai7c7767e2009-01-20 15:28:38 +01004047 err = create_controls(codec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02004048 if (err < 0)
4049 return err;
4050 }
4051
4052 return 0;
4053}
4054
Mattc7d4b2f2005-06-27 14:59:41 +02004055static int stac9200_parse_auto_config(struct hda_codec *codec)
4056{
4057 struct sigmatel_spec *spec = codec->spec;
4058 int err;
4059
Kailang Yangdf694da2005-12-05 19:42:22 +01004060 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02004061 return err;
4062
4063 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4064 return err;
4065
Takashi Iwai82bc9552006-03-21 11:24:42 +01004066 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4067 return err;
4068
Richard Fish160ea0d2006-09-06 13:58:25 +02004069 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4070 return err;
4071
Takashi Iwai355a0ec2008-11-11 16:46:19 +01004072 if (spec->num_muxes > 0) {
4073 err = stac92xx_auto_create_mux_input_ctls(codec);
4074 if (err < 0)
4075 return err;
4076 }
4077
Takashi Iwaie3c75962009-01-23 11:57:22 +01004078 err = stac92xx_add_input_source(spec);
4079 if (err < 0)
4080 return err;
4081
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004082 if (spec->autocfg.dig_outs)
Mattc7d4b2f2005-06-27 14:59:41 +02004083 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004084 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02004085 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02004086
Takashi Iwai603c4012008-07-30 15:01:44 +02004087 if (spec->kctls.list)
4088 spec->mixers[spec->num_mixers++] = spec->kctls.list;
Mattc7d4b2f2005-06-27 14:59:41 +02004089
4090 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02004091 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02004092
4093 return 1;
4094}
4095
Sam Revitch62fe78e2006-05-10 15:09:17 +02004096/*
4097 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4098 * funky external mute control using GPIO pins.
4099 */
4100
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004101static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004102 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02004103{
4104 unsigned int gpiostate, gpiomask, gpiodir;
4105
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004106 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4107
Sam Revitch62fe78e2006-05-10 15:09:17 +02004108 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4109 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004110 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02004111
4112 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4113 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004114 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004115
4116 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4117 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004118 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02004119
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004120 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004121 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4122
4123 snd_hda_codec_write(codec, codec->afg, 0,
4124 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004125 snd_hda_codec_read(codec, codec->afg, 0,
4126 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004127
4128 msleep(1);
4129
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01004130 snd_hda_codec_read(codec, codec->afg, 0,
4131 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004132}
4133
Takashi Iwai3a938972011-10-28 01:16:55 +02004134static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004135 unsigned char type, int data)
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004136{
Takashi Iwai3a938972011-10-28 01:16:55 +02004137 struct hda_jack_tbl *event;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004138
Takashi Iwai3a938972011-10-28 01:16:55 +02004139 event = snd_hda_jack_tbl_new(codec, nid);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004140 if (!event)
4141 return -ENOMEM;
Takashi Iwai3a938972011-10-28 01:16:55 +02004142 event->action = type;
4143 event->private_data = data;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004144
Takashi Iwai3a938972011-10-28 01:16:55 +02004145 return 0;
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004146}
4147
Takashi Iwai62558ce2009-07-29 14:23:09 +02004148/* check if given nid is a valid pin and no other events are assigned
4149 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4150 * Otherwise, returns zero.
4151 */
4152static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4153 unsigned int type)
Takashi Iwai314634b2006-09-21 11:56:18 +02004154{
Takashi Iwai3a938972011-10-28 01:16:55 +02004155 struct hda_jack_tbl *event;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004156
Takashi Iwaie35d9d62011-05-17 11:28:16 +02004157 if (!is_jack_detectable(codec, nid))
Takashi Iwai62558ce2009-07-29 14:23:09 +02004158 return 0;
Takashi Iwai3a938972011-10-28 01:16:55 +02004159 event = snd_hda_jack_tbl_new(codec, nid);
4160 if (!event)
4161 return -ENOMEM;
4162 if (event->action && event->action != type)
4163 return 0;
4164 event->action = type;
4165 snd_hda_jack_detect_enable(codec, nid, 0);
Takashi Iwai62558ce2009-07-29 14:23:09 +02004166 return 1;
Takashi Iwai314634b2006-09-21 11:56:18 +02004167}
4168
Takashi Iwaib4ead012012-01-23 18:23:36 +01004169static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004170{
4171 int i;
4172 for (i = 0; i < cfg->hp_outs; i++)
4173 if (cfg->hp_pins[i] == nid)
4174 return 1; /* nid is a HP-Out */
Takashi Iwaib4ead012012-01-23 18:23:36 +01004175 for (i = 0; i < cfg->line_outs; i++)
4176 if (cfg->line_out_pins[i] == nid)
4177 return 1; /* nid is a line-Out */
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004178 return 0; /* nid is not a HP-Out */
4179};
4180
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004181static void stac92xx_power_down(struct hda_codec *codec)
4182{
4183 struct sigmatel_spec *spec = codec->spec;
4184
4185 /* power down inactive DACs */
Takashi Iwai2b635362011-05-02 12:33:43 +02004186 const hda_nid_t *dac;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004187 for (dac = spec->dac_list; *dac; dac++)
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004188 if (!check_all_dac_nids(spec, *dac))
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004189 snd_hda_codec_write(codec, *dac, 0,
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004190 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4191}
4192
Takashi Iwaif73d3582008-11-25 08:21:51 +01004193static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4194 int enable);
4195
Takashi Iwai014c41f2009-12-27 13:53:24 +01004196static inline int get_int_hint(struct hda_codec *codec, const char *key,
4197 int *valp)
4198{
4199 const char *p;
4200 p = snd_hda_get_hint(codec, key);
4201 if (p) {
4202 unsigned long val;
4203 if (!strict_strtoul(p, 0, &val)) {
4204 *valp = val;
4205 return 1;
4206 }
4207 }
4208 return 0;
4209}
4210
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004211/* override some hints from the hwdep entry */
4212static void stac_store_hints(struct hda_codec *codec)
4213{
4214 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004215 int val;
4216
4217 val = snd_hda_get_bool_hint(codec, "hp_detect");
4218 if (val >= 0)
4219 spec->hp_detect = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004220 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004221 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4222 spec->gpio_mask;
4223 }
Takashi Iwai014c41f2009-12-27 13:53:24 +01004224 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4225 spec->gpio_mask &= spec->gpio_mask;
4226 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4227 spec->gpio_dir &= spec->gpio_mask;
4228 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4229 spec->eapd_mask &= spec->gpio_mask;
4230 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4231 spec->gpio_mute &= spec->gpio_mask;
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004232 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4233 if (val >= 0)
4234 spec->eapd_switch = val;
Takashi Iwai014c41f2009-12-27 13:53:24 +01004235 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4236 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004237 spec->gpio_mask |= spec->gpio_led;
4238 spec->gpio_dir |= spec->gpio_led;
4239 if (spec->gpio_led_polarity)
4240 spec->gpio_data |= spec->gpio_led;
Takashi Iwai043958e2009-12-26 10:36:12 +01004241 }
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004242}
4243
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004244static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4245 const hda_nid_t *pins)
4246{
4247 while (num_pins--)
4248 stac_issue_unsol_event(codec, *pins++);
4249}
4250
4251/* fake event to set up pins */
4252static void stac_fake_hp_events(struct hda_codec *codec)
4253{
4254 struct sigmatel_spec *spec = codec->spec;
4255
4256 if (spec->autocfg.hp_outs)
4257 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4258 spec->autocfg.hp_pins);
4259 if (spec->autocfg.line_outs &&
4260 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4261 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4262 spec->autocfg.line_out_pins);
4263}
4264
Mattc7d4b2f2005-06-27 14:59:41 +02004265static int stac92xx_init(struct hda_codec *codec)
4266{
4267 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004268 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004269 unsigned int gpio;
Takashi Iwaie4973e12008-11-18 09:32:42 +01004270 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02004271
Mattc7d4b2f2005-06-27 14:59:41 +02004272 snd_hda_sequence_write(codec, spec->init);
4273
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004274 /* power down adcs initially */
4275 if (spec->powerdown_adcs)
4276 for (i = 0; i < spec->num_adcs; i++)
Takashi Iwai8c2f7672008-12-01 11:54:35 +01004277 snd_hda_codec_write(codec,
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004278 spec->adc_nids[i], 0,
4279 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004280
Takashi Iwai6565e4f2009-03-02 14:38:35 +01004281 /* override some hints */
4282 stac_store_hints(codec);
4283
Takashi Iwaif73d3582008-11-25 08:21:51 +01004284 /* set up GPIO */
4285 gpio = spec->gpio_data;
4286 /* turn on EAPD statically when spec->eapd_switch isn't set.
4287 * otherwise, unsol event will turn it on/off dynamically
4288 */
4289 if (!spec->eapd_switch)
4290 gpio |= spec->eapd_mask;
4291 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4292
Takashi Iwai82bc9552006-03-21 11:24:42 +01004293 /* set up pins */
4294 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02004295 /* Enable unsolicited responses on the HP widget */
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004296 for (i = 0; i < cfg->hp_outs; i++) {
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004297 hda_nid_t nid = cfg->hp_pins[i];
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004298 enable_pin_detect(codec, nid, STAC_HP_EVENT);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004299 }
Takashi Iwai1c4bdf92009-08-13 08:23:24 +02004300 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4301 cfg->speaker_outs > 0) {
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004302 /* enable pin-detect for line-outs as well */
Takashi Iwai15cfa2b2009-08-03 14:23:33 +02004303 for (i = 0; i < cfg->line_outs; i++) {
4304 hda_nid_t nid = cfg->line_out_pins[i];
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004305 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4306 }
4307 }
4308
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01004309 /* force to enable the first line-out; the others are set up
4310 * in unsol_event
4311 */
4312 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004313 AC_PINCTL_OUT_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004314 /* fake event to set up pins */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004315 stac_fake_hp_events(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004316 } else {
4317 stac92xx_auto_init_multi_out(codec);
4318 stac92xx_auto_init_hp_out(codec);
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004319 for (i = 0; i < cfg->hp_outs; i++)
4320 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
Takashi Iwai82bc9552006-03-21 11:24:42 +01004321 }
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004322 if (spec->auto_mic) {
Takashi Iwai15b4f292009-07-29 16:32:55 +02004323 /* initialize connection to analog input */
Takashi Iwaida2a2aa2009-08-10 07:44:09 +02004324 if (spec->dmux_nids)
4325 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
Takashi Iwai15b4f292009-07-29 16:32:55 +02004326 AC_VERB_SET_CONNECT_SEL, 0);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004327 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4328 stac_issue_unsol_event(codec, spec->ext_mic.pin);
Charles Chin99077902010-09-17 10:22:32 +02004329 if (enable_pin_detect(codec, spec->dock_mic.pin,
4330 STAC_MIC_EVENT))
4331 stac_issue_unsol_event(codec, spec->dock_mic.pin);
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004332 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004333 for (i = 0; i < cfg->num_inputs; i++) {
4334 hda_nid_t nid = cfg->inputs[i].pin;
4335 int type = cfg->inputs[i].type;
4336 unsigned int pinctl, conf;
Takashi Iwai86e29592010-09-09 14:50:17 +02004337 if (type == AUTO_PIN_MIC) {
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004338 /* for mic pins, force to initialize */
Takashi Iwai47408602012-04-20 13:06:53 +02004339 pinctl = snd_hda_get_default_vref(codec, nid);
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004340 pinctl |= AC_PINCTL_IN_EN;
4341 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4342 } else {
4343 pinctl = snd_hda_codec_read(codec, nid, 0,
4344 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4345 /* if PINCTL already set then skip */
4346 /* Also, if both INPUT and OUTPUT are set,
4347 * it must be a BIOS bug; need to override, too
4348 */
4349 if (!(pinctl & AC_PINCTL_IN_EN) ||
4350 (pinctl & AC_PINCTL_OUT_EN)) {
4351 pinctl &= ~AC_PINCTL_OUT_EN;
Takashi Iwai12dde4c2008-12-05 13:09:27 +01004352 pinctl |= AC_PINCTL_IN_EN;
4353 stac92xx_auto_set_pinctl(codec, nid, pinctl);
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01004354 }
Takashi Iwaieea7dc92010-08-30 13:06:15 +02004355 }
4356 conf = snd_hda_codec_get_pincfg(codec, nid);
4357 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4358 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4359 stac_issue_unsol_event(codec, nid);
Takashi Iwaic960a032006-03-23 17:06:28 +01004360 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01004361 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004362 for (i = 0; i < spec->num_dmics; i++)
4363 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4364 AC_PINCTL_IN_EN);
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004365 if (cfg->dig_out_pins[0])
4366 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
Takashi Iwai82bc9552006-03-21 11:24:42 +01004367 AC_PINCTL_OUT_EN);
4368 if (cfg->dig_in_pin)
4369 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4370 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004371 for (i = 0; i < spec->num_pwrs; i++) {
4372 hda_nid_t nid = spec->pwr_nids[i];
4373 int pinctl, def_conf;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004374
Takashi Iwaieb632122008-12-19 16:39:48 +01004375 /* power on when no jack detection is available */
Takashi Iwai542c9a02011-11-29 13:01:30 +01004376 /* or when the VREF is used for controlling LED */
4377 if (!spec->hp_detect ||
Takashi Iwaia0204282011-12-06 13:17:23 +01004378 spec->vref_mute_led_nid == nid) {
Takashi Iwaieb632122008-12-19 16:39:48 +01004379 stac_toggle_power_map(codec, nid, 1);
4380 continue;
4381 }
4382
Takashi Iwaib4ead012012-01-23 18:23:36 +01004383 if (is_nid_out_jack_pin(cfg, nid))
Takashi Iwaif73d3582008-11-25 08:21:51 +01004384 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02004385
Takashi Iwaif73d3582008-11-25 08:21:51 +01004386 pinctl = snd_hda_codec_read(codec, nid, 0,
4387 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4388 /* outputs are only ports capable of power management
4389 * any attempts on powering down a input port cause the
4390 * referenced VREF to act quirky.
4391 */
Takashi Iwaieb632122008-12-19 16:39:48 +01004392 if (pinctl & AC_PINCTL_IN_EN) {
4393 stac_toggle_power_map(codec, nid, 1);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004394 continue;
Takashi Iwaieb632122008-12-19 16:39:48 +01004395 }
Takashi Iwai330ee992009-02-20 14:33:36 +01004396 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004397 def_conf = get_defcfg_connect(def_conf);
4398 /* skip any ports that don't have jacks since presence
4399 * detection is useless */
4400 if (def_conf != AC_JACK_PORT_COMPLEX) {
4401 if (def_conf != AC_JACK_PORT_NONE)
4402 stac_toggle_power_map(codec, nid, 1);
4403 continue;
4404 }
Charles Chinafef2cf2011-11-11 08:05:28 +01004405 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
Takashi Iwai62558ce2009-07-29 14:23:09 +02004406 stac_issue_unsol_event(codec, nid);
Charles Chinafef2cf2011-11-11 08:05:28 +01004407 continue;
4408 }
4409 /* none of the above, turn the port OFF */
4410 stac_toggle_power_map(codec, nid, 0);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004411 }
Takashi Iwaic21bd022010-02-08 15:16:08 +01004412
Takashi Iwai01a61e12011-10-28 00:03:22 +02004413 snd_hda_jack_report_sync(codec);
4414
Takashi Iwaic21bd022010-02-08 15:16:08 +01004415 /* sync mute LED */
Takashi Iwaid2f344b2012-03-12 16:59:58 +01004416 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004417 if (spec->dac_list)
4418 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02004419 return 0;
4420}
4421
Takashi Iwai603c4012008-07-30 15:01:44 +02004422static void stac92xx_free_kctls(struct hda_codec *codec)
4423{
4424 struct sigmatel_spec *spec = codec->spec;
4425
4426 if (spec->kctls.list) {
4427 struct snd_kcontrol_new *kctl = spec->kctls.list;
4428 int i;
4429 for (i = 0; i < spec->kctls.used; i++)
4430 kfree(kctl[i].name);
4431 }
4432 snd_array_free(&spec->kctls);
4433}
4434
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004435static void stac92xx_shutup_pins(struct hda_codec *codec)
4436{
4437 unsigned int i, def_conf;
4438
4439 if (codec->bus->shutdown)
4440 return;
4441 for (i = 0; i < codec->init_pins.used; i++) {
4442 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4443 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4444 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004445 snd_hda_set_pin_ctl(codec, pin->nid, 0);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004446 }
4447}
4448
Takashi Iwai167eae52009-11-06 15:47:50 +01004449static void stac92xx_shutup(struct hda_codec *codec)
4450{
4451 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai167eae52009-11-06 15:47:50 +01004452
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004453 stac92xx_shutup_pins(codec);
Takashi Iwai167eae52009-11-06 15:47:50 +01004454
4455 if (spec->eapd_mask)
4456 stac_gpio_set(codec, spec->gpio_mask,
4457 spec->gpio_dir, spec->gpio_data &
4458 ~spec->eapd_mask);
4459}
4460
Matt2f2f4252005-04-13 14:45:30 +02004461static void stac92xx_free(struct hda_codec *codec)
4462{
Mattc7d4b2f2005-06-27 14:59:41 +02004463 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004464
4465 if (! spec)
4466 return;
4467
Takashi Iwai167eae52009-11-06 15:47:50 +01004468 stac92xx_shutup(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02004469
Mattc7d4b2f2005-06-27 14:59:41 +02004470 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004471 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02004472}
4473
Matt4e550962005-07-04 17:51:39 +02004474static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4475 unsigned int flag)
4476{
Takashi Iwai8ce84192009-01-22 16:59:20 +01004477 unsigned int old_ctl, pin_ctl;
4478
4479 pin_ctl = snd_hda_codec_read(codec, nid,
Matt4e550962005-07-04 17:51:39 +02004480 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02004481
Takashi Iwaif9acba42007-05-29 18:01:06 +02004482 if (pin_ctl & AC_PINCTL_IN_EN) {
4483 /*
4484 * we need to check the current set-up direction of
4485 * shared input pins since they can be switched via
4486 * "xxx as Output" mixer switch
4487 */
4488 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004489 if (nid == spec->line_switch || nid == spec->mic_switch)
Takashi Iwaif9acba42007-05-29 18:01:06 +02004490 return;
4491 }
4492
Takashi Iwai8ce84192009-01-22 16:59:20 +01004493 old_ctl = pin_ctl;
Steve Longerbeam7b043892007-05-03 20:50:03 +02004494 /* if setting pin direction bits, clear the current
4495 direction bits first */
4496 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4497 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4498
Takashi Iwai8ce84192009-01-22 16:59:20 +01004499 pin_ctl |= flag;
4500 if (old_ctl != pin_ctl)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004501 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
Matt4e550962005-07-04 17:51:39 +02004502}
4503
4504static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4505 unsigned int flag)
4506{
4507 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4508 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai8ce84192009-01-22 16:59:20 +01004509 if (pin_ctl & flag)
Takashi Iwaicdd03ce2012-04-20 12:34:50 +02004510 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
Matt4e550962005-07-04 17:51:39 +02004511}
4512
Takashi Iwaid56757a2009-11-18 08:00:14 +01004513static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02004514{
4515 if (!nid)
4516 return 0;
Takashi Iwaia252c812009-12-25 22:56:20 +01004517 return snd_hda_jack_detect(codec, nid);
Takashi Iwai314634b2006-09-21 11:56:18 +02004518}
4519
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004520static void stac92xx_line_out_detect(struct hda_codec *codec,
4521 int presence)
4522{
4523 struct sigmatel_spec *spec = codec->spec;
4524 struct auto_pin_cfg *cfg = &spec->autocfg;
4525 int i;
4526
4527 for (i = 0; i < cfg->line_outs; i++) {
4528 if (presence)
4529 break;
4530 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4531 if (presence) {
4532 unsigned int pinctl;
4533 pinctl = snd_hda_codec_read(codec,
4534 cfg->line_out_pins[i], 0,
4535 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4536 if (pinctl & AC_PINCTL_IN_EN)
4537 presence = 0; /* mic- or line-input */
4538 }
4539 }
4540
4541 if (presence) {
4542 /* disable speakers */
4543 for (i = 0; i < cfg->speaker_outs; i++)
4544 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4545 AC_PINCTL_OUT_EN);
4546 if (spec->eapd_mask && spec->eapd_switch)
4547 stac_gpio_set(codec, spec->gpio_mask,
4548 spec->gpio_dir, spec->gpio_data &
4549 ~spec->eapd_mask);
4550 } else {
4551 /* enable speakers */
4552 for (i = 0; i < cfg->speaker_outs; i++)
4553 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4554 AC_PINCTL_OUT_EN);
4555 if (spec->eapd_mask && spec->eapd_switch)
4556 stac_gpio_set(codec, spec->gpio_mask,
4557 spec->gpio_dir, spec->gpio_data |
4558 spec->eapd_mask);
4559 }
4560}
4561
Takashi Iwaid7a89432008-11-12 09:48:04 +01004562/* return non-zero if the hp-pin of the given array index isn't
4563 * a jack-detection target
4564 */
4565static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4566{
4567 struct auto_pin_cfg *cfg = &spec->autocfg;
4568
4569 /* ignore sensing of shared line and mic jacks */
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004570 if (cfg->hp_pins[i] == spec->line_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004571 return 1;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01004572 if (cfg->hp_pins[i] == spec->mic_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004573 return 1;
4574 /* ignore if the pin is set as line-out */
4575 if (cfg->hp_pins[i] == spec->hp_switch)
4576 return 1;
4577 return 0;
4578}
4579
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004580static void stac92xx_hp_detect(struct hda_codec *codec)
Matt4e550962005-07-04 17:51:39 +02004581{
4582 struct sigmatel_spec *spec = codec->spec;
4583 struct auto_pin_cfg *cfg = &spec->autocfg;
4584 int i, presence;
4585
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004586 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004587 if (spec->gpio_mute)
4588 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4589 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4590
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004591 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004592 if (presence)
4593 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01004594 if (no_hp_sensing(spec, i))
4595 continue;
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004596 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4597 if (presence) {
4598 unsigned int pinctl;
4599 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4600 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4601 if (pinctl & AC_PINCTL_IN_EN)
4602 presence = 0; /* mic- or line-input */
4603 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004604 }
Matt4e550962005-07-04 17:51:39 +02004605
4606 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004607 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004608 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004609 stac92xx_reset_pinctl(codec, spec->hp_switch,
4610 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004611 for (i = 0; i < cfg->line_outs; i++)
4612 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4613 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004614 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01004615 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02004616 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004617 stac92xx_set_pinctl(codec, spec->hp_switch,
4618 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004619 for (i = 0; i < cfg->line_outs; i++)
4620 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4621 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02004622 }
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004623 stac92xx_line_out_detect(codec, presence);
Takashi Iwaid7a89432008-11-12 09:48:04 +01004624 /* toggle hp outs */
4625 for (i = 0; i < cfg->hp_outs; i++) {
4626 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4627 if (no_hp_sensing(spec, i))
4628 continue;
Takashi Iwai7bff1722012-02-29 09:41:17 +01004629 if (1 /*presence*/)
Takashi Iwaid7a89432008-11-12 09:48:04 +01004630 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004631#if 0 /* FIXME */
4632/* Resetting the pinctl like below may lead to (a sort of) regressions
4633 * on some devices since they use the HP pin actually for line/speaker
4634 * outs although the default pin config shows a different pin (that is
4635 * wrong and useless).
4636 *
4637 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4638 * But, disabling the code below just works around it, and I'm too tired of
4639 * bug reports with such devices...
4640 */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004641 else
4642 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
Takashi Iwai8317e0b2009-01-14 07:56:51 +01004643#endif /* FIXME */
Takashi Iwaid7a89432008-11-12 09:48:04 +01004644 }
Matt4e550962005-07-04 17:51:39 +02004645}
4646
Takashi Iwaif73d3582008-11-25 08:21:51 +01004647static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4648 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004649{
4650 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01004651 unsigned int idx, val;
4652
4653 for (idx = 0; idx < spec->num_pwrs; idx++) {
4654 if (spec->pwr_nids[idx] == nid)
4655 break;
4656 }
4657 if (idx >= spec->num_pwrs)
4658 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004659
Charles Chinafef2cf2011-11-11 08:05:28 +01004660 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004661
Takashi Iwaif73d3582008-11-25 08:21:51 +01004662 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4663 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004664 val &= ~idx;
4665 else
4666 val |= idx;
4667
4668 /* power down unused output ports */
4669 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004670}
4671
Takashi Iwaif73d3582008-11-25 08:21:51 +01004672static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4673{
Takashi Iwaie6e3ea22008-12-05 12:54:56 +01004674 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
Takashi Iwaif73d3582008-11-25 08:21:51 +01004675}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004676
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004677/* get the pin connection (fixed, none, etc) */
4678static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4679{
4680 struct sigmatel_spec *spec = codec->spec;
4681 unsigned int cfg;
4682
4683 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4684 return get_defcfg_connect(cfg);
4685}
4686
4687static int stac92xx_connected_ports(struct hda_codec *codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02004688 const hda_nid_t *nids, int num_nids)
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02004689{
4690 struct sigmatel_spec *spec = codec->spec;
4691 int idx, num;
4692 unsigned int def_conf;
4693
4694 for (num = 0; num < num_nids; num++) {
4695 for (idx = 0; idx < spec->num_pins; idx++)
4696 if (spec->pin_nids[idx] == nids[num])
4697 break;
4698 if (idx >= spec->num_pins)
4699 break;
4700 def_conf = stac_get_defcfg_connect(codec, idx);
4701 if (def_conf == AC_JACK_PORT_NONE)
4702 break;
4703 }
4704 return num;
4705}
4706
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004707static void stac92xx_mic_detect(struct hda_codec *codec)
4708{
4709 struct sigmatel_spec *spec = codec->spec;
4710 struct sigmatel_mic_route *mic;
4711
4712 if (get_pin_presence(codec, spec->ext_mic.pin))
4713 mic = &spec->ext_mic;
Charles Chin99077902010-09-17 10:22:32 +02004714 else if (get_pin_presence(codec, spec->dock_mic.pin))
4715 mic = &spec->dock_mic;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004716 else
4717 mic = &spec->int_mic;
Takashi Iwai02d33322009-10-01 16:38:11 +02004718 if (mic->dmux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004719 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4720 AC_VERB_SET_CONNECT_SEL,
4721 mic->dmux_idx);
Takashi Iwai02d33322009-10-01 16:38:11 +02004722 if (mic->mux_idx >= 0)
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004723 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4724 AC_VERB_SET_CONNECT_SEL,
4725 mic->mux_idx);
4726}
4727
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004728static void handle_unsol_event(struct hda_codec *codec,
Takashi Iwai3a938972011-10-28 01:16:55 +02004729 struct hda_jack_tbl *event)
Takashi Iwai314634b2006-09-21 11:56:18 +02004730{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004731 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004732 int data;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004733
Takashi Iwai3a938972011-10-28 01:16:55 +02004734 switch (event->action) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004735 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004736 case STAC_LO_EVENT:
Takashi Iwai16ffe322009-08-04 13:40:54 +02004737 stac92xx_hp_detect(codec);
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004738 break;
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004739 case STAC_MIC_EVENT:
4740 stac92xx_mic_detect(codec);
4741 break;
4742 }
4743
Takashi Iwai3a938972011-10-28 01:16:55 +02004744 switch (event->action) {
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004745 case STAC_HP_EVENT:
Takashi Iwaifefd67f2009-07-30 18:03:05 +02004746 case STAC_LO_EVENT:
Takashi Iwai3d21d3f2009-07-29 14:32:56 +02004747 case STAC_MIC_EVENT:
Matthew Ranostay74aeaab2008-10-25 01:06:04 -04004748 case STAC_INSERT_EVENT:
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004749 case STAC_PWR_EVENT:
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004750 if (spec->num_pwrs > 0)
4751 stac92xx_pin_sense(codec, event->nid);
Matthew Ranostayfd60cc82009-04-06 09:30:46 -04004752
4753 switch (codec->subsystem_id) {
4754 case 0x103c308f:
4755 if (event->nid == 0xb) {
4756 int pin = AC_PINCTL_IN_EN;
4757
4758 if (get_pin_presence(codec, 0xa)
4759 && get_pin_presence(codec, 0xb))
4760 pin |= AC_PINCTL_VREF_80;
4761 if (!get_pin_presence(codec, 0xb))
4762 pin |= AC_PINCTL_VREF_80;
4763
4764 /* toggle VREF state based on mic + hp pin
4765 * status
4766 */
4767 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4768 }
4769 }
Matthew Ranostay72474be2008-10-09 09:32:17 -04004770 break;
Takashi Iwaic6e4c662008-11-25 11:58:19 +01004771 case STAC_VREF_EVENT:
4772 data = snd_hda_codec_read(codec, codec->afg, 0,
4773 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004774 /* toggle VREF state based on GPIOx status */
4775 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
Takashi Iwai3a938972011-10-28 01:16:55 +02004776 !!(data & (1 << event->private_data)));
Matthew Ranostay72474be2008-10-09 09:32:17 -04004777 break;
Takashi Iwai314634b2006-09-21 11:56:18 +02004778 }
4779}
4780
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004781static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4782{
Takashi Iwai3a938972011-10-28 01:16:55 +02004783 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004784 if (!event)
4785 return;
4786 handle_unsol_event(codec, event);
4787}
4788
4789static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4790{
Takashi Iwai3a938972011-10-28 01:16:55 +02004791 struct hda_jack_tbl *event;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004792 int tag;
4793
4794 tag = (res >> 26) & 0x7f;
Takashi Iwai3a938972011-10-28 01:16:55 +02004795 event = snd_hda_jack_tbl_get_from_tag(codec, tag);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004796 if (!event)
4797 return;
Takashi Iwai3a938972011-10-28 01:16:55 +02004798 event->jack_dirty = 1;
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004799 handle_unsol_event(codec, event);
Takashi Iwai01a61e12011-10-28 00:03:22 +02004800 snd_hda_jack_report_sync(codec);
Takashi Iwai1835a0f2011-10-27 22:12:46 +02004801}
4802
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304803static int hp_blike_system(u32 subsystem_id);
4804
4805static void set_hp_led_gpio(struct hda_codec *codec)
4806{
4807 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai07f80442010-02-08 15:06:13 +01004808 unsigned int gpio;
4809
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02004810 if (spec->gpio_led)
4811 return;
4812
Takashi Iwai07f80442010-02-08 15:06:13 +01004813 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4814 gpio &= AC_GPIO_IO_COUNT;
4815 if (gpio > 3)
4816 spec->gpio_led = 0x08; /* GPIO 3 */
4817 else
4818 spec->gpio_led = 0x01; /* GPIO 0 */
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304819}
4820
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004821/*
4822 * This method searches for the mute LED GPIO configuration
4823 * provided as OEM string in SMBIOS. The format of that string
4824 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4825 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4826 * that corresponds to the NOT muted state of the master volume
4827 * and G is the index of the GPIO to use as the mute LED control (0..9)
4828 * If _G portion is missing it is assigned based on the codec ID
4829 *
4830 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4831 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304832 *
4833 *
4834 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4835 * SMBIOS - at least the ones I have seen do not have them - which include
4836 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4837 * HP Pavilion dv9500t CTO.
4838 * Need more information on whether it is true across the entire series.
4839 * -- kunal
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004840 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004841static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004842{
4843 struct sigmatel_spec *spec = codec->spec;
4844 const struct dmi_device *dev = NULL;
4845
4846 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4847 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4848 NULL, dev))) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004849 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304850 &spec->gpio_led_polarity,
4851 &spec->gpio_led) == 2) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01004852 unsigned int max_gpio;
4853 max_gpio = snd_hda_param_read(codec, codec->afg,
4854 AC_PAR_GPIO_CAP);
4855 max_gpio &= AC_GPIO_IO_COUNT;
4856 if (spec->gpio_led < max_gpio)
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004857 spec->gpio_led = 1 << spec->gpio_led;
Takashi Iwaif1a73742011-12-04 13:44:06 +01004858 else
4859 spec->vref_mute_led_nid = spec->gpio_led;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004860 return 1;
4861 }
4862 if (sscanf(dev->name, "HP_Mute_LED_%d",
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304863 &spec->gpio_led_polarity) == 1) {
4864 set_hp_led_gpio(codec);
4865 return 1;
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004866 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004867 /* BIOS bug: unfilled OEM string */
4868 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4869 set_hp_led_gpio(codec);
Gustavo Maciel Dias Vieiraa6a600d2012-01-24 13:27:56 -02004870 switch (codec->subsystem_id) {
4871 case 0x103c148a:
4872 spec->gpio_led_polarity = 0;
4873 break;
4874 default:
4875 spec->gpio_led_polarity = 1;
4876 break;
4877 }
Gustavo Maciel Dias Vieirae2ef36c2011-12-13 11:47:22 -02004878 return 1;
4879 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004880 }
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304881
4882 /*
4883 * Fallback case - if we don't find the DMI strings,
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004884 * we statically set the GPIO - if not a B-series system
4885 * and default polarity is provided
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304886 */
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06004887 if (!hp_blike_system(codec->subsystem_id) &&
4888 (default_polarity == 0 || default_polarity == 1)) {
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304889 set_hp_led_gpio(codec);
Takashi Iwaidce17d42010-02-09 09:25:26 +01004890 spec->gpio_led_polarity = default_polarity;
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05304891 return 1;
4892 }
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004893 }
4894 return 0;
4895}
4896
4897static int hp_blike_system(u32 subsystem_id)
Randy Dunlap78987bd2009-11-05 09:22:30 -08004898{
4899 switch (subsystem_id) {
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004900 case 0x103c1520:
4901 case 0x103c1521:
4902 case 0x103c1523:
4903 case 0x103c1524:
4904 case 0x103c1525:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004905 case 0x103c1722:
4906 case 0x103c1723:
4907 case 0x103c1724:
4908 case 0x103c1725:
4909 case 0x103c1726:
4910 case 0x103c1727:
4911 case 0x103c1728:
4912 case 0x103c1729:
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01004913 case 0x103c172a:
4914 case 0x103c172b:
4915 case 0x103c307e:
4916 case 0x103c307f:
4917 case 0x103c3080:
4918 case 0x103c3081:
4919 case 0x103c7007:
4920 case 0x103c7008:
Randy Dunlap78987bd2009-11-05 09:22:30 -08004921 return 1;
4922 }
4923 return 0;
4924}
4925
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01004926#ifdef CONFIG_PROC_FS
4927static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4928 struct hda_codec *codec, hda_nid_t nid)
4929{
4930 if (nid == codec->afg)
4931 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4932 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4933}
4934
4935static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4936 struct hda_codec *codec,
4937 unsigned int verb)
4938{
4939 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4940 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4941}
4942
4943/* stac92hd71bxx, stac92hd73xx */
4944static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4945 struct hda_codec *codec, hda_nid_t nid)
4946{
4947 stac92hd_proc_hook(buffer, codec, nid);
4948 if (nid == codec->afg)
4949 analog_loop_proc_hook(buffer, codec, 0xfa0);
4950}
4951
4952static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4953 struct hda_codec *codec, hda_nid_t nid)
4954{
4955 if (nid == codec->afg)
4956 analog_loop_proc_hook(buffer, codec, 0xfe0);
4957}
4958
4959static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4960 struct hda_codec *codec, hda_nid_t nid)
4961{
4962 if (nid == codec->afg)
4963 analog_loop_proc_hook(buffer, codec, 0xfeb);
4964}
4965#else
4966#define stac92hd_proc_hook NULL
4967#define stac92hd7x_proc_hook NULL
4968#define stac9205_proc_hook NULL
4969#define stac927x_proc_hook NULL
4970#endif
4971
Takashi Iwai2a439522011-07-26 09:52:50 +02004972#ifdef CONFIG_PM
Mattff6fdc32005-06-27 15:06:52 +02004973static int stac92xx_resume(struct hda_codec *codec)
4974{
Takashi Iwai2c885872008-11-18 09:36:55 +01004975 stac92xx_init(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004976 snd_hda_codec_resume_amp(codec);
4977 snd_hda_codec_resume_cache(codec);
Takashi Iwai2c885872008-11-18 09:36:55 +01004978 /* fake event to set up pins again to override cached values */
Takashi Iwaif2cbba72012-01-11 12:34:11 +01004979 stac_fake_hp_events(codec);
Mattff6fdc32005-06-27 15:06:52 +02004980 return 0;
4981}
Matthew Ranostayc6798d22008-11-18 20:54:17 -05004982
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004983static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4984{
4985 stac92xx_shutup(codec);
4986 return 0;
4987}
4988
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05004989static int stac92xx_pre_resume(struct hda_codec *codec)
4990{
4991 struct sigmatel_spec *spec = codec->spec;
4992
4993 /* sync mute LED */
Takashi Iwaif1a73742011-12-04 13:44:06 +01004994 if (spec->vref_mute_led_nid)
4995 stac_vrefout_set(codec, spec->vref_mute_led_nid,
4996 spec->vref_led);
4997 else if (spec->gpio_led)
4998 stac_gpio_set(codec, spec->gpio_mask,
4999 spec->gpio_dir, spec->gpio_data);
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005000 return 0;
5001}
5002
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005003static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5004 unsigned int power_state)
5005{
5006 unsigned int afg_power_state = power_state;
5007 struct sigmatel_spec *spec = codec->spec;
5008
5009 if (power_state == AC_PWRST_D3) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005010 if (spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005011 /* with vref-out pin used for mute led control
5012 * codec AFG is prevented from D3 state
5013 */
5014 afg_power_state = AC_PWRST_D1;
5015 }
5016 /* this delay seems necessary to avoid click noise at power-down */
5017 msleep(100);
5018 }
5019 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5020 afg_power_state);
5021 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5022}
Takashi Iwai350eba432012-03-16 16:09:03 +01005023#else
5024#define stac92xx_suspend NULL
5025#define stac92xx_resume NULL
5026#define stac92xx_pre_resume NULL
5027#define stac92xx_set_power_state NULL
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005028#endif /* CONFIG_PM */
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005029
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005030/* update mute-LED accoring to the master switch */
5031static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005032{
5033 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005034 int muted = !enabled;
Takashi Iwai6fce61a2009-03-10 07:48:57 +01005035
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005036 if (!spec->gpio_led)
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005037 return;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005038
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005039 /* LED state is inverted on these systems */
5040 if (spec->gpio_led_polarity)
5041 muted = !muted;
5042
Takashi Iwaif1a73742011-12-04 13:44:06 +01005043 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005044 if (muted)
Takashi Iwai3e843192012-04-19 12:04:03 +02005045 spec->gpio_data |= spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005046 else
Takashi Iwai3e843192012-04-19 12:04:03 +02005047 spec->gpio_data &= ~spec->gpio_led;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005048 stac_gpio_set(codec, spec->gpio_mask,
5049 spec->gpio_dir, spec->gpio_data);
5050 } else {
Takashi Iwai2faa3bf2012-03-12 12:30:22 +01005051 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
Takashi Iwaif1a73742011-12-04 13:44:06 +01005052 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5053 spec->vref_led);
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005054 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005055}
Vitaliy Kulikov7df1ce12011-07-25 17:52:57 -05005056
Takashi Iwai2b635362011-05-02 12:33:43 +02005057static const struct hda_codec_ops stac92xx_patch_ops = {
Matt2f2f4252005-04-13 14:45:30 +02005058 .build_controls = stac92xx_build_controls,
5059 .build_pcms = stac92xx_build_pcms,
5060 .init = stac92xx_init,
5061 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02005062 .unsol_event = stac92xx_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +02005063#ifdef CONFIG_PM
Matthew Ranostayc6798d22008-11-18 20:54:17 -05005064 .suspend = stac92xx_suspend,
Mattff6fdc32005-06-27 15:06:52 +02005065 .resume = stac92xx_resume,
5066#endif
Takashi Iwaifb8d1a32009-11-10 16:02:29 +01005067 .reboot_notify = stac92xx_shutup,
Matt2f2f4252005-04-13 14:45:30 +02005068};
5069
5070static int patch_stac9200(struct hda_codec *codec)
5071{
5072 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005073 int err;
Matt2f2f4252005-04-13 14:45:30 +02005074
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005075 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005076 if (spec == NULL)
5077 return -ENOMEM;
5078
Takashi Iwaia252c812009-12-25 22:56:20 +01005079 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005080 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005081 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005082 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005083 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005084 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5085 stac9200_models,
5086 stac9200_cfg_tbl);
Takashi Iwai330ee992009-02-20 14:33:36 +01005087 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005088 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5089 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005090 else
5091 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005092 stac9200_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005093
5094 spec->multiout.max_channels = 2;
5095 spec->multiout.num_dacs = 1;
5096 spec->multiout.dac_nids = stac9200_dac_nids;
5097 spec->adc_nids = stac9200_adc_nids;
5098 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02005099 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02005100 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005101 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005102 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005103
Mauro Carvalho Chehab58eec422008-08-11 10:18:39 +02005104 if (spec->board_config == STAC_9200_M4 ||
5105 spec->board_config == STAC_9200_M4_2 ||
Tobin Davisbf277782008-02-03 20:31:47 +01005106 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02005107 spec->init = stac9200_eapd_init;
5108 else
5109 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02005110 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02005111
Takashi Iwai117f2572008-03-18 09:53:23 +01005112 if (spec->board_config == STAC_9200_PANASONIC) {
5113 spec->gpio_mask = spec->gpio_dir = 0x09;
5114 spec->gpio_data = 0x00;
5115 }
5116
Mattc7d4b2f2005-06-27 14:59:41 +02005117 err = stac9200_parse_auto_config(codec);
5118 if (err < 0) {
5119 stac92xx_free(codec);
5120 return err;
5121 }
Matt2f2f4252005-04-13 14:45:30 +02005122
Takashi Iwai2acc9dc2009-01-09 16:57:14 +01005123 /* CF-74 has no headphone detection, and the driver should *NOT*
5124 * do detection and HP/speaker toggle because the hardware does it.
5125 */
5126 if (spec->board_config == STAC_9200_PANASONIC)
5127 spec->hp_detect = 0;
5128
Matt2f2f4252005-04-13 14:45:30 +02005129 codec->patch_ops = stac92xx_patch_ops;
5130
5131 return 0;
5132}
5133
Tobin Davis8e21c342007-01-08 11:04:17 +01005134static int patch_stac925x(struct hda_codec *codec)
5135{
5136 struct sigmatel_spec *spec;
5137 int err;
5138
5139 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5140 if (spec == NULL)
5141 return -ENOMEM;
5142
Takashi Iwaia252c812009-12-25 22:56:20 +01005143 codec->no_trigger_sense = 1;
Tobin Davis8e21c342007-01-08 11:04:17 +01005144 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005145 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005146 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01005147 spec->pin_nids = stac925x_pin_nids;
Mauro Carvalho Chehab9cb36c22008-08-11 10:18:39 +02005148
5149 /* Check first for codec ID */
5150 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5151 STAC_925x_MODELS,
5152 stac925x_models,
5153 stac925x_codec_id_cfg_tbl);
5154
5155 /* Now checks for PCI ID, if codec ID is not found */
5156 if (spec->board_config < 0)
5157 spec->board_config = snd_hda_check_board_config(codec,
5158 STAC_925x_MODELS,
Tobin Davis8e21c342007-01-08 11:04:17 +01005159 stac925x_models,
5160 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005161 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005162 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005163 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5164 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005165 else
5166 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005167 stac925x_brd_tbl[spec->board_config]);
Tobin Davis8e21c342007-01-08 11:04:17 +01005168
5169 spec->multiout.max_channels = 2;
5170 spec->multiout.num_dacs = 1;
5171 spec->multiout.dac_nids = stac925x_dac_nids;
5172 spec->adc_nids = stac925x_adc_nids;
5173 spec->mux_nids = stac925x_mux_nids;
5174 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005175 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005176 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02005177 switch (codec->vendor_id) {
5178 case 0x83847632: /* STAC9202 */
5179 case 0x83847633: /* STAC9202D */
5180 case 0x83847636: /* STAC9251 */
5181 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02005182 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02005183 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01005184 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5185 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02005186 break;
5187 default:
5188 spec->num_dmics = 0;
5189 break;
5190 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005191
5192 spec->init = stac925x_core_init;
5193 spec->mixer = stac925x_mixer;
Takashi Iwai6479c632009-07-28 18:20:25 +02005194 spec->num_caps = 1;
5195 spec->capvols = stac925x_capvols;
5196 spec->capsws = stac925x_capsws;
Tobin Davis8e21c342007-01-08 11:04:17 +01005197
Charles Chin9009b0e2011-11-03 10:27:27 +01005198 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005199 if (!err) {
5200 if (spec->board_config < 0) {
5201 printk(KERN_WARNING "hda_codec: No auto-config is "
5202 "available, default to model=ref\n");
5203 spec->board_config = STAC_925x_REF;
5204 goto again;
5205 }
5206 err = -EINVAL;
5207 }
Tobin Davis8e21c342007-01-08 11:04:17 +01005208 if (err < 0) {
5209 stac92xx_free(codec);
5210 return err;
5211 }
5212
5213 codec->patch_ops = stac92xx_patch_ops;
5214
5215 return 0;
5216}
5217
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005218static int patch_stac92hd73xx(struct hda_codec *codec)
5219{
5220 struct sigmatel_spec *spec;
5221 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5222 int err = 0;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005223 int num_dacs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005224
5225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5226 if (spec == NULL)
5227 return -ENOMEM;
5228
Takashi Iwaia252c812009-12-25 22:56:20 +01005229 codec->no_trigger_sense = 1;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005230 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005231 spec->linear_tone_beep = 0;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02005232 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005233 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5234 spec->pin_nids = stac92hd73xx_pin_nids;
5235 spec->board_config = snd_hda_check_board_config(codec,
5236 STAC_92HD73XX_MODELS,
5237 stac92hd73xx_models,
5238 stac92hd73xx_cfg_tbl);
Takashi Iwai842ae632009-09-02 07:43:08 +02005239 /* check codec subsystem id if not found */
5240 if (spec->board_config < 0)
5241 spec->board_config =
5242 snd_hda_check_board_codec_sid_config(codec,
5243 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5244 stac92hd73xx_codec_id_cfg_tbl);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005245again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005246 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005247 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5248 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005249 else
5250 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005251 stac92hd73xx_brd_tbl[spec->board_config]);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005252
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005253 num_dacs = snd_hda_get_connections(codec, 0x0a,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005254 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5255
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005256 if (num_dacs < 3 || num_dacs > 5) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005257 printk(KERN_WARNING "hda_codec: Could not determine "
5258 "number of channels defaulting to DAC count\n");
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005259 num_dacs = STAC92HD73_DAC_COUNT;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005260 }
Takashi Iwaie2aec172009-09-02 01:00:05 +02005261 spec->init = stac92hd73xx_core_init;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005262 switch (num_dacs) {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005263 case 0x3: /* 6 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005264 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005265 break;
5266 case 0x4: /* 8 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005267 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005268 break;
5269 case 0x5: /* 10 Channel */
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005270 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5271 break;
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005272 }
5273 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005274
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005275 spec->aloopback_mask = 0x01;
5276 spec->aloopback_shift = 8;
5277
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005278 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005279 spec->mux_nids = stac92hd73xx_mux_nids;
5280 spec->adc_nids = stac92hd73xx_adc_nids;
5281 spec->dmic_nids = stac92hd73xx_dmic_nids;
5282 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005283 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005284
5285 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5286 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01005287 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005288
Takashi Iwai6479c632009-07-28 18:20:25 +02005289 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5290 spec->capvols = stac92hd73xx_capvols;
5291 spec->capsws = stac92hd73xx_capsws;
5292
Matthew Ranostaya7662642008-02-21 07:51:14 +01005293 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005294 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01005295 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005296 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005297 case STAC_DELL_M6_AMIC:
5298 case STAC_DELL_M6_DMIC:
5299 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005300 spec->num_smuxes = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005301 spec->eapd_switch = 0;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05005302
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005303 switch (spec->board_config) {
5304 case STAC_DELL_M6_AMIC: /* Analog Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005305 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005306 spec->num_dmics = 0;
5307 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005308 case STAC_DELL_M6_DMIC: /* Digital Mics */
Takashi Iwai330ee992009-02-20 14:33:36 +01005309 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005310 spec->num_dmics = 1;
5311 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01005312 case STAC_DELL_M6_BOTH: /* Both */
Takashi Iwai330ee992009-02-20 14:33:36 +01005313 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5314 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
Matthew Ranostaya7662642008-02-21 07:51:14 +01005315 spec->num_dmics = 1;
5316 break;
5317 }
5318 break;
Takashi Iwai842ae632009-09-02 07:43:08 +02005319 case STAC_ALIENWARE_M17X:
5320 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5321 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5322 spec->eapd_switch = 0;
5323 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005324 default:
5325 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04005326 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05005327 spec->eapd_switch = 1;
Takashi Iwai5207e102009-07-30 13:09:08 +02005328 break;
Matthew Ranostaya7662642008-02-21 07:51:14 +01005329 }
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02005330 if (spec->board_config != STAC_92HD73XX_REF) {
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04005331 /* GPIO0 High = Enable EAPD */
5332 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5333 spec->gpio_data = 0x01;
5334 }
Matthew Ranostaya7662642008-02-21 07:51:14 +01005335
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005336 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5337 spec->pwr_nids = stac92hd73xx_pwr_nids;
5338
Charles Chin9009b0e2011-11-03 10:27:27 +01005339 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005340
5341 if (!err) {
5342 if (spec->board_config < 0) {
5343 printk(KERN_WARNING "hda_codec: No auto-config is "
5344 "available, default to model=ref\n");
5345 spec->board_config = STAC_92HD73XX_REF;
5346 goto again;
5347 }
5348 err = -EINVAL;
5349 }
5350
5351 if (err < 0) {
5352 stac92xx_free(codec);
5353 return err;
5354 }
5355
Takashi Iwai9e43f0d2008-12-17 14:51:01 +01005356 if (spec->board_config == STAC_92HD73XX_NO_JD)
5357 spec->hp_detect = 0;
5358
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005359 codec->patch_ops = stac92xx_patch_ops;
5360
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005361 codec->proc_widget_hook = stac92hd7x_proc_hook;
5362
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005363 return 0;
5364}
5365
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005366static int hp_bnb2011_with_dock(struct hda_codec *codec)
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005367{
5368 if (codec->vendor_id != 0x111d7605 &&
5369 codec->vendor_id != 0x111d76d1)
5370 return 0;
5371
5372 switch (codec->subsystem_id) {
5373 case 0x103c1618:
5374 case 0x103c1619:
5375 case 0x103c161a:
5376 case 0x103c161b:
5377 case 0x103c161c:
5378 case 0x103c161d:
5379 case 0x103c161e:
5380 case 0x103c161f:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005381
5382 case 0x103c162a:
5383 case 0x103c162b:
5384
5385 case 0x103c1630:
5386 case 0x103c1631:
5387
5388 case 0x103c1633:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005389 case 0x103c1634:
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005390 case 0x103c1635:
5391
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005392 case 0x103c3587:
5393 case 0x103c3588:
5394 case 0x103c3589:
5395 case 0x103c358a:
5396
5397 case 0x103c3667:
5398 case 0x103c3668:
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005399 case 0x103c3669:
5400
5401 return 1;
Vitaliy Kulikov335e3b82010-10-22 18:38:31 -05005402 }
5403 return 0;
5404}
5405
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005406static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5407{
5408 struct sigmatel_spec *spec = codec->spec;
5409 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5410 int i;
5411
5412 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5413 spec->auto_pin_cnt++;
5414
5415 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5416 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5417 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5418 if (nid == stac92hd83xxx_dmic_nids[i]) {
5419 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5420 spec->auto_dmic_cnt++;
5421 }
5422 }
5423 }
5424}
5425
5426static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5427{
5428 struct sigmatel_spec *spec = codec->spec;
5429
5430 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5431 spec->auto_adc_cnt++;
5432}
5433
5434static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5435{
5436 int i, j;
5437 struct sigmatel_spec *spec = codec->spec;
5438
5439 for (i = 0; i < spec->auto_adc_cnt; i++) {
5440 if (get_connection_index(codec,
5441 spec->auto_adc_nids[i], nid) >= 0) {
5442 /* mux and volume for adc_nids[i] */
5443 if (!spec->auto_mux_nids[i]) {
5444 spec->auto_mux_nids[i] = nid;
5445 /* 92hd codecs capture volume is in mux */
5446 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5447 3, 0, HDA_OUTPUT);
5448 }
5449 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5450 if (get_connection_index(codec, nid,
5451 spec->auto_dmic_nids[j]) >= 0) {
5452 /* dmux for adc_nids[i] */
5453 if (!spec->auto_dmux_nids[i])
5454 spec->auto_dmux_nids[i] = nid;
5455 break;
5456 }
5457 }
5458 break;
5459 }
5460 }
5461}
5462
5463static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5464{
5465 hda_nid_t nid, end_nid;
5466 unsigned int wid_caps, wid_type;
5467 struct sigmatel_spec *spec = codec->spec;
5468
5469 end_nid = codec->start_nid + codec->num_nodes;
5470
5471 for (nid = codec->start_nid; nid < end_nid; nid++) {
5472 wid_caps = get_wcaps(codec, nid);
5473 wid_type = get_wcaps_type(wid_caps);
5474
5475 if (wid_type == AC_WID_PIN)
5476 stac92hd8x_add_pin(codec, nid);
5477
5478 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5479 stac92hd8x_add_adc(codec, nid);
5480 }
5481
5482 for (nid = codec->start_nid; nid < end_nid; nid++) {
5483 wid_caps = get_wcaps(codec, nid);
5484 wid_type = get_wcaps_type(wid_caps);
5485
5486 if (wid_type == AC_WID_AUD_SEL)
5487 stac92hd8x_add_mux(codec, nid);
5488 }
5489
5490 spec->pin_nids = spec->auto_pin_nids;
5491 spec->num_pins = spec->auto_pin_cnt;
5492 spec->adc_nids = spec->auto_adc_nids;
5493 spec->num_adcs = spec->auto_adc_cnt;
5494 spec->capvols = spec->auto_capvols;
5495 spec->capsws = spec->auto_capvols;
5496 spec->num_caps = spec->auto_adc_cnt;
5497 spec->mux_nids = spec->auto_mux_nids;
5498 spec->num_muxes = spec->auto_adc_cnt;
5499 spec->dmux_nids = spec->auto_dmux_nids;
5500 spec->num_dmuxes = spec->auto_adc_cnt;
5501 spec->dmic_nids = spec->auto_dmic_nids;
5502 spec->num_dmics = spec->auto_dmic_cnt;
5503}
5504
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005505static int patch_stac92hd83xxx(struct hda_codec *codec)
5506{
5507 struct sigmatel_spec *spec;
5508 int err;
5509
5510 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5511 if (spec == NULL)
5512 return -ENOMEM;
5513
Vitaliy Kulikovcbbf50b2011-01-14 17:21:13 -06005514 if (hp_bnb2011_with_dock(codec)) {
5515 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5516 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5517 }
5518
Takashi Iwaia252c812009-12-25 22:56:20 +01005519 codec->no_trigger_sense = 1;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005520 codec->spec = spec;
Vitaliy Kulikov699d8992011-03-10 13:43:35 -06005521
5522 stac92hd8x_fill_auto_spec(codec);
5523
Takashi Iwai1db7ccdb2010-12-03 15:19:14 +01005524 spec->linear_tone_beep = 0;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005525 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005526 spec->digbeep_nid = 0x21;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005527 spec->pwr_nids = stac92hd83xxx_pwr_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005528 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005529 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005530 spec->init = stac92hd83xxx_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005531
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005532 spec->board_config = snd_hda_check_board_config(codec,
5533 STAC_92HD83XXX_MODELS,
5534 stac92hd83xxx_models,
5535 stac92hd83xxx_cfg_tbl);
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005536 /* check codec subsystem id if not found */
5537 if (spec->board_config < 0)
5538 spec->board_config =
5539 snd_hda_check_board_codec_sid_config(codec,
5540 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
5541 stac92hd83xxx_codec_id_cfg_tbl);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005542again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005543 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005544 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5545 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005546 else
5547 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005548 stac92hd83xxx_brd_tbl[spec->board_config]);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005549
Takashi Iwaib4e81872009-11-18 17:20:24 +01005550 codec->patch_ops = stac92xx_patch_ops;
5551
Vitaliy Kulikov5556e142012-02-27 16:47:37 -06005552 switch (spec->board_config) {
5553 case STAC_HP_ZEPHYR:
5554 spec->init = stac92hd83xxx_hp_zephyr_init;
5555 break;
5556 }
5557
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005558 if (find_mute_led_cfg(codec, -1/*no default cfg*/))
Vitaliy Kulikove108c7b2010-01-28 19:21:07 +01005559 snd_printd("mute LED gpio %d polarity %d\n",
5560 spec->gpio_led,
5561 spec->gpio_led_polarity);
5562
Takashi Iwaib4e81872009-11-18 17:20:24 +01005563 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005564 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005565 spec->gpio_mask |= spec->gpio_led;
5566 spec->gpio_dir |= spec->gpio_led;
5567 spec->gpio_data |= spec->gpio_led;
5568 } else {
5569 codec->patch_ops.set_power_state =
5570 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005571 }
Takashi Iwai350eba432012-03-16 16:09:03 +01005572#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005573 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba432012-03-16 16:09:03 +01005574#endif
Takashi Iwaib4e81872009-11-18 17:20:24 +01005575 }
Takashi Iwaib4e81872009-11-18 17:20:24 +01005576
Charles Chin9009b0e2011-11-03 10:27:27 +01005577 err = stac92xx_parse_auto_config(codec);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005578 if (!err) {
5579 if (spec->board_config < 0) {
5580 printk(KERN_WARNING "hda_codec: No auto-config is "
5581 "available, default to model=ref\n");
5582 spec->board_config = STAC_92HD83XXX_REF;
5583 goto again;
5584 }
5585 err = -EINVAL;
5586 }
5587
5588 if (err < 0) {
5589 stac92xx_free(codec);
5590 return err;
5591 }
5592
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005593 codec->proc_widget_hook = stac92hd_proc_hook;
5594
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005595 return 0;
5596}
5597
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005598static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5599 hda_nid_t dig0pin)
5600{
5601 struct sigmatel_spec *spec = codec->spec;
5602 int idx;
5603
5604 for (idx = 0; idx < spec->num_pins; idx++)
5605 if (spec->pin_nids[idx] == dig0pin)
5606 break;
5607 if ((idx + 2) >= spec->num_pins)
5608 return 0;
5609
5610 /* dig1pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005611 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005612 return 2;
5613
5614 /* dig0pin + dig2pin case */
Takashi Iwai330ee992009-02-20 14:33:36 +01005615 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005616 return 2;
Takashi Iwai330ee992009-02-20 14:33:36 +01005617 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005618 return 1;
5619 else
5620 return 0;
5621}
5622
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005623/* HP dv7 bass switch - GPIO5 */
5624#define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5625static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5626 struct snd_ctl_elem_value *ucontrol)
5627{
5628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5629 struct sigmatel_spec *spec = codec->spec;
5630 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5631 return 0;
5632}
5633
5634static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5635 struct snd_ctl_elem_value *ucontrol)
5636{
5637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5638 struct sigmatel_spec *spec = codec->spec;
5639 unsigned int gpio_data;
5640
5641 gpio_data = (spec->gpio_data & ~0x20) |
5642 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5643 if (gpio_data == spec->gpio_data)
5644 return 0;
5645 spec->gpio_data = gpio_data;
5646 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5647 return 1;
5648}
5649
Takashi Iwai2b635362011-05-02 12:33:43 +02005650static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5652 .info = stac_hp_bass_gpio_info,
5653 .get = stac_hp_bass_gpio_get,
5654 .put = stac_hp_bass_gpio_put,
5655};
5656
5657static int stac_add_hp_bass_switch(struct hda_codec *codec)
5658{
5659 struct sigmatel_spec *spec = codec->spec;
5660
5661 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5662 "Bass Speaker Playback Switch", 0))
5663 return -ENOMEM;
5664
5665 spec->gpio_mask |= 0x20;
5666 spec->gpio_dir |= 0x20;
5667 spec->gpio_data |= 0x20;
5668 return 0;
5669}
5670
Matthew Ranostaye035b842007-11-06 11:53:55 +01005671static int patch_stac92hd71bxx(struct hda_codec *codec)
5672{
5673 struct sigmatel_spec *spec;
Takashi Iwai2b635362011-05-02 12:33:43 +02005674 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005675 unsigned int pin_cfg;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005676 int err = 0;
5677
5678 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5679 if (spec == NULL)
5680 return -ENOMEM;
5681
Takashi Iwaia252c812009-12-25 22:56:20 +01005682 codec->no_trigger_sense = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005683 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005684 spec->linear_tone_beep = 0;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005685 codec->patch_ops = stac92xx_patch_ops;
Herton Ronaldo Krzesinski616f89e2009-02-04 11:23:19 -05005686 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5687 switch (codec->vendor_id) {
5688 case 0x111d76b6:
5689 case 0x111d76b7:
5690 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5691 break;
5692 case 0x111d7603:
5693 case 0x111d7608:
5694 /* On 92HD75Bx 0x27 isn't a pin nid */
5695 spec->num_pins--;
5696 /* fallthrough */
5697 default:
5698 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5699 }
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005700 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005701 spec->board_config = snd_hda_check_board_config(codec,
5702 STAC_92HD71BXX_MODELS,
5703 stac92hd71bxx_models,
5704 stac92hd71bxx_cfg_tbl);
5705again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005706 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005707 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5708 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005709 else
5710 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005711 stac92hd71bxx_brd_tbl[spec->board_config]);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005712
Takashi Iwaifc64b262009-09-14 15:33:01 +02005713 if (spec->board_config != STAC_92HD71BXX_REF) {
Takashi Iwai41c3b642008-11-18 10:45:15 +01005714 /* GPIO0 = EAPD */
5715 spec->gpio_mask = 0x01;
5716 spec->gpio_dir = 0x01;
5717 spec->gpio_data = 0x01;
5718 }
5719
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005720 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5721 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5722
Takashi Iwai6479c632009-07-28 18:20:25 +02005723 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5724 spec->capvols = stac92hd71bxx_capvols;
5725 spec->capsws = stac92hd71bxx_capsws;
5726
Matthew Ranostay541eee82007-12-14 12:08:04 +01005727 switch (codec->vendor_id) {
5728 case 0x111d76b6: /* 4 Port without Analog Mixer */
5729 case 0x111d76b7:
Herton Ronaldo Krzesinski23c7b522009-02-08 19:51:28 -02005730 unmute_init++;
5731 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005732 case 0x111d76b4: /* 6 Port without Analog Mixer */
5733 case 0x111d76b5:
Matthew Ranostay541eee82007-12-14 12:08:04 +01005734 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005735 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005736 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005737 stac92hd71bxx_dmic_nids,
5738 STAC92HD71BXX_NUM_DMICS);
Matthew Ranostay541eee82007-12-14 12:08:04 +01005739 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005740 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01005741 switch (spec->board_config) {
5742 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04005743 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwai3a938972011-10-28 01:16:55 +02005744 err = stac_add_event(codec, codec->afg,
Takashi Iwaic6e4c662008-11-25 11:58:19 +01005745 STAC_VREF_EVENT, 0x02);
5746 if (err < 0)
5747 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01005748 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04005749 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
Takashi Iwai3a938972011-10-28 01:16:55 +02005750 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay72474be2008-10-09 09:32:17 -04005751 spec->gpio_mask |= 0x02;
5752 break;
5753 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005754 if ((codec->revision_id & 0xf) == 0 ||
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005755 (codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005756 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005757
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005758 /* disable VSW */
Takashi Iwai26a27982009-07-29 16:28:09 +02005759 spec->init = stac92hd71bxx_core_init;
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005760 unmute_init++;
Takashi Iwai330ee992009-02-20 14:33:36 +01005761 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5762 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
Takashi Iwai2b635362011-05-02 12:33:43 +02005763 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005764 spec->num_dmics = stac92xx_connected_ports(codec,
Takashi Iwai2b635362011-05-02 12:33:43 +02005765 stac92hd71bxx_dmic_5port_nids,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005766 STAC92HD71BXX_NUM_DMICS - 1);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005767 break;
5768 case 0x111d7603: /* 6 Port with Analog Mixer */
Takashi Iwai8c2f7672008-12-01 11:54:35 +01005769 if ((codec->revision_id & 0xf) == 1)
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005770 spec->stream_delay = 40; /* 40 milliseconds */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005771
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005772 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01005773 default:
Takashi Iwai26a27982009-07-29 16:28:09 +02005774 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04005775 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02005776 spec->num_dmics = stac92xx_connected_ports(codec,
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005777 stac92hd71bxx_dmic_nids,
5778 STAC92HD71BXX_NUM_DMICS);
Takashi Iwai5207e102009-07-30 13:09:08 +02005779 break;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005780 }
5781
Matthew Ranostayca8d33f2009-01-26 09:33:52 -05005782 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5783 snd_hda_sequence_write_cache(codec, unmute_init);
5784
Takashi Iwaid78d7a92009-03-02 14:26:25 +01005785 spec->aloopback_ctl = stac92hd71bxx_loopback;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04005786 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01005787 spec->aloopback_shift = 0;
5788
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02005789 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02005790 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005791 spec->mux_nids = stac92hd71bxx_mux_nids;
5792 spec->adc_nids = stac92hd71bxx_adc_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02005793 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005794 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005795
5796 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5797 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai5207e102009-07-30 13:09:08 +02005798 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Herton Ronaldo Krzesinski6df703a2009-02-04 11:34:22 -05005799 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005800
Kunal Gangakhedkard38cce72010-01-15 21:01:47 +05305801 snd_printdd("Found board config: %d\n", spec->board_config);
5802
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005803 switch (spec->board_config) {
5804 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005805 /* enable internal microphone */
Takashi Iwai330ee992009-02-20 14:33:36 +01005806 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
Matthew Ranostayb9aea712008-10-09 08:37:28 -04005807 stac92xx_auto_set_pinctl(codec, 0x0e,
5808 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05005809 /* fallthru */
5810 case STAC_DELL_M4_2:
5811 spec->num_dmics = 0;
5812 spec->num_smuxes = 0;
5813 spec->num_dmuxes = 0;
5814 break;
5815 case STAC_DELL_M4_1:
5816 case STAC_DELL_M4_3:
5817 spec->num_dmics = 1;
5818 spec->num_smuxes = 0;
Takashi Iwaiea18aa42009-02-27 17:36:33 +01005819 spec->num_dmuxes = 1;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005820 break;
James Gardiner514bf542009-05-03 04:00:44 -04005821 case STAC_HP_DV4_1222NR:
5822 spec->num_dmics = 1;
5823 /* I don't know if it needs 1 or 2 smuxes - will wait for
5824 * bug reports to fix if needed
5825 */
5826 spec->num_smuxes = 1;
5827 spec->num_dmuxes = 1;
James Gardiner514bf542009-05-03 04:00:44 -04005828 /* fallthrough */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005829 case STAC_HP_DV4:
5830 spec->gpio_led = 0x01;
5831 /* fallthrough */
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005832 case STAC_HP_DV5:
Takashi Iwai330ee992009-02-20 14:33:36 +01005833 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005834 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
Takashi Iwai6e34c032009-09-14 15:42:18 +02005835 /* HP dv6 gives the headphone pin as a line-out. Thus we
5836 * need to set hp_detect flag here to force to enable HP
5837 * detection.
5838 */
5839 spec->hp_detect = 1;
Herton Ronaldo Krzesinskie2ea57a2009-02-16 10:23:00 +01005840 break;
Christoph Plattnerae6241f2009-03-08 23:19:05 +01005841 case STAC_HP_HDX:
5842 spec->num_dmics = 1;
5843 spec->num_dmuxes = 1;
5844 spec->num_smuxes = 1;
Takashi Iwai26ebe0a2010-05-11 08:36:29 +02005845 spec->gpio_led = 0x08;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005846 break;
5847 }
Christoph Plattner443e26d2009-03-10 00:05:56 +01005848
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005849 if (hp_blike_system(codec->subsystem_id)) {
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005850 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5851 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5852 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5853 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5854 /* It was changed in the BIOS to just satisfy MS DTM.
5855 * Lets turn it back into slaved HP
5856 */
5857 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5858 | (AC_JACK_HP_OUT <<
5859 AC_DEFCFG_DEVICE_SHIFT);
5860 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5861 | AC_DEFCFG_SEQUENCE)))
5862 | 0x1f;
5863 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5864 }
5865 }
5866
Vitaliy Kulikov6a557c92011-12-12 17:35:13 -06005867 if (find_mute_led_cfg(codec, 1))
Vitaliy Kulikovc357aab2009-12-11 07:51:54 +01005868 snd_printd("mute LED gpio %d polarity %d\n",
5869 spec->gpio_led,
5870 spec->gpio_led_polarity);
Vitaliy Kulikov5bdaaad2009-11-04 07:57:45 +01005871
Takashi Iwai86d190e2009-05-26 15:18:58 +02005872 if (spec->gpio_led) {
Takashi Iwaif1a73742011-12-04 13:44:06 +01005873 if (!spec->vref_mute_led_nid) {
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005874 spec->gpio_mask |= spec->gpio_led;
5875 spec->gpio_dir |= spec->gpio_led;
5876 spec->gpio_data |= spec->gpio_led;
5877 } else {
5878 codec->patch_ops.set_power_state =
5879 stac92xx_set_power_state;
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005880 }
Takashi Iwai350eba432012-03-16 16:09:03 +01005881#ifdef CONFIG_PM
Vitaliy Kulikov45eebda2011-07-26 16:56:20 -05005882 codec->patch_ops.pre_resume = stac92xx_pre_resume;
Takashi Iwai350eba432012-03-16 16:09:03 +01005883#endif
Takashi Iwai86d190e2009-05-26 15:18:58 +02005884 }
Matthew Ranostay6a14f582008-09-12 12:02:30 -04005885
Takashi Iwaic21ca4a2008-12-19 09:26:08 +01005886 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01005887
Charles Chin9009b0e2011-11-03 10:27:27 +01005888 err = stac92xx_parse_auto_config(codec);
Matthew Ranostaye035b842007-11-06 11:53:55 +01005889 if (!err) {
5890 if (spec->board_config < 0) {
5891 printk(KERN_WARNING "hda_codec: No auto-config is "
5892 "available, default to model=ref\n");
5893 spec->board_config = STAC_92HD71BXX_REF;
5894 goto again;
5895 }
5896 err = -EINVAL;
5897 }
5898
5899 if (err < 0) {
5900 stac92xx_free(codec);
5901 return err;
5902 }
5903
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005904 /* enable bass on HP dv7 */
Takashi Iwai2a6ce6e2010-05-12 10:16:20 +02005905 if (spec->board_config == STAC_HP_DV4 ||
5906 spec->board_config == STAC_HP_DV5) {
Takashi Iwai75d1aeb2009-12-22 11:56:32 +01005907 unsigned int cap;
5908 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5909 cap &= AC_GPIO_IO_COUNT;
5910 if (cap >= 6)
5911 stac_add_hp_bass_switch(codec);
5912 }
5913
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01005914 codec->proc_widget_hook = stac92hd7x_proc_hook;
5915
Matthew Ranostaye035b842007-11-06 11:53:55 +01005916 return 0;
Takashi Iwai86d190e2009-05-26 15:18:58 +02005917}
Matthew Ranostaye035b842007-11-06 11:53:55 +01005918
Matt2f2f4252005-04-13 14:45:30 +02005919static int patch_stac922x(struct hda_codec *codec)
5920{
5921 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02005922 int err;
Matt2f2f4252005-04-13 14:45:30 +02005923
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005924 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02005925 if (spec == NULL)
5926 return -ENOMEM;
5927
Takashi Iwaia252c812009-12-25 22:56:20 +01005928 codec->no_trigger_sense = 1;
Matt2f2f4252005-04-13 14:45:30 +02005929 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01005930 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02005931 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02005932 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005933 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5934 stac922x_models,
5935 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08005936 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01005937 spec->gpio_mask = spec->gpio_dir = 0x03;
5938 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005939 /* Intel Macs have all same PCI SSID, so we need to check
5940 * codec SSID to distinguish the exact models
5941 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005942 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005943 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005944
5945 case 0x106b0800:
5946 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02005947 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005948 case 0x106b0600:
5949 case 0x106b0700:
5950 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01005951 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005952 case 0x106b0e00:
5953 case 0x106b0f00:
5954 case 0x106b1600:
5955 case 0x106b1700:
5956 case 0x106b0200:
5957 case 0x106b1e00:
5958 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005959 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005960 case 0x106b1a00:
5961 case 0x00000100:
5962 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02005963 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02005964 case 0x106b0a00:
5965 case 0x106b2200:
5966 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02005967 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08005968 default:
5969 spec->board_config = STAC_INTEL_MAC_V3;
5970 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01005971 }
5972 }
5973
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005974 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01005975 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005976 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5977 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01005978 else
5979 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01005980 stac922x_brd_tbl[spec->board_config]);
Matt2f2f4252005-04-13 14:45:30 +02005981
Matt2f2f4252005-04-13 14:45:30 +02005982 spec->adc_nids = stac922x_adc_nids;
5983 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01005984 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02005985 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02005986 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005987 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02005988
5989 spec->init = stac922x_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02005990
5991 spec->num_caps = STAC922X_NUM_CAPS;
5992 spec->capvols = stac922x_capvols;
5993 spec->capsws = stac922x_capsws;
Mattc7d4b2f2005-06-27 14:59:41 +02005994
5995 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02005996
Charles Chin9009b0e2011-11-03 10:27:27 +01005997 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01005998 if (!err) {
5999 if (spec->board_config < 0) {
6000 printk(KERN_WARNING "hda_codec: No auto-config is "
6001 "available, default to model=ref\n");
6002 spec->board_config = STAC_D945_REF;
6003 goto again;
6004 }
6005 err = -EINVAL;
6006 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006007 if (err < 0) {
6008 stac92xx_free(codec);
6009 return err;
6010 }
6011
6012 codec->patch_ops = stac92xx_patch_ops;
6013
Takashi Iwai807a46362007-05-29 19:01:37 +02006014 /* Fix Mux capture level; max to 2 */
6015 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6016 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6017 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6018 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6019 (0 << AC_AMPCAP_MUTE_SHIFT));
6020
Matt Porter3cc08dc2006-01-23 15:27:49 +01006021 return 0;
6022}
6023
6024static int patch_stac927x(struct hda_codec *codec)
6025{
6026 struct sigmatel_spec *spec;
6027 int err;
6028
6029 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6030 if (spec == NULL)
6031 return -ENOMEM;
6032
Takashi Iwaia252c812009-12-25 22:56:20 +01006033 codec->no_trigger_sense = 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +01006034 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006035 spec->linear_tone_beep = 1;
Matthew Ranostay45c1d852009-02-04 17:49:41 -05006036 codec->slave_dig_outs = stac927x_slave_dig_outs;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006037 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006038 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006039 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6040 stac927x_models,
6041 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006042 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006043 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006044 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6045 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006046 else
6047 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006048 stac927x_brd_tbl[spec->board_config]);
Matt Porter3cc08dc2006-01-23 15:27:49 +01006049
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006050 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006051 spec->adc_nids = stac927x_adc_nids;
6052 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6053 spec->mux_nids = stac927x_mux_nids;
6054 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006055 spec->smux_nids = stac927x_smux_nids;
6056 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04006057 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01006058 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006059 spec->multiout.dac_nids = spec->dac_nids;
6060
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006061 if (spec->board_config != STAC_D965_REF) {
6062 /* GPIO0 High = Enable EAPD */
6063 spec->eapd_mask = spec->gpio_mask = 0x01;
6064 spec->gpio_dir = spec->gpio_data = 0x01;
6065 }
6066
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006067 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02006068 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006069 case STAC_D965_5ST:
6070 /* GPIO0 High = Enable EAPD */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006071 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02006072 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006073 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006074 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006075 switch (codec->subsystem_id) {
6076 case 0x10280209:
6077 case 0x1028022e:
6078 /* correct the device field to SPDIF out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006079 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
Matthew Ranostay780c8be2008-04-14 13:32:27 +02006080 break;
Takashi Iwai86d190e2009-05-26 15:18:58 +02006081 }
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01006082 /* configure the analog microphone on some laptops */
Takashi Iwai330ee992009-02-20 14:33:36 +01006083 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01006084 /* correct the front output jack as a hp out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006085 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006086 /* correct the front input jack as a mic */
Takashi Iwai330ee992009-02-20 14:33:36 +01006087 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01006088 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006089 case STAC_DELL_3ST:
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006090 if (codec->subsystem_id != 0x1028022f) {
6091 /* GPIO2 High = Enable EAPD */
6092 spec->eapd_mask = spec->gpio_mask = 0x04;
6093 spec->gpio_dir = spec->gpio_data = 0x04;
6094 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006095 spec->dmic_nids = stac927x_dmic_nids;
6096 spec->num_dmics = STAC927X_NUM_DMICS;
6097
Takashi Iwaiccca7cd2009-10-13 15:32:21 +02006098 spec->init = dell_3st_core_init;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006099 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006100 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006101 break;
Takashi Iwai54930532009-10-11 17:38:29 +02006102 case STAC_927X_VOLKNOB:
6103 spec->num_dmics = 0;
6104 spec->init = stac927x_volknob_core_init;
6105 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006106 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006107 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006108 spec->init = stac927x_core_init;
Takashi Iwaiaf6ee302009-09-14 15:03:12 +02006109 break;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02006110 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01006111
Takashi Iwai6479c632009-07-28 18:20:25 +02006112 spec->num_caps = STAC927X_NUM_CAPS;
6113 spec->capvols = stac927x_capvols;
6114 spec->capsws = stac927x_capsws;
6115
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006116 spec->num_pwrs = 0;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006117 spec->aloopback_ctl = stac927x_loopback;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006118 spec->aloopback_mask = 0x40;
6119 spec->aloopback_shift = 0;
Matthew Ranostayc0cea0d2008-11-16 11:42:34 -05006120 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01006121
Charles Chin9009b0e2011-11-03 10:27:27 +01006122 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006123 if (!err) {
6124 if (spec->board_config < 0) {
6125 printk(KERN_WARNING "hda_codec: No auto-config is "
6126 "available, default to model=ref\n");
6127 spec->board_config = STAC_D965_REF;
6128 goto again;
6129 }
6130 err = -EINVAL;
6131 }
Mattc7d4b2f2005-06-27 14:59:41 +02006132 if (err < 0) {
6133 stac92xx_free(codec);
6134 return err;
6135 }
Matt2f2f4252005-04-13 14:45:30 +02006136
6137 codec->patch_ops = stac92xx_patch_ops;
6138
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006139 codec->proc_widget_hook = stac927x_proc_hook;
6140
Takashi Iwai52987652008-01-16 16:09:47 +01006141 /*
6142 * !!FIXME!!
6143 * The STAC927x seem to require fairly long delays for certain
6144 * command sequences. With too short delays (even if the answer
6145 * is set to RIRB properly), it results in the silence output
6146 * on some hardwares like Dell.
6147 *
6148 * The below flag enables the longer delay (see get_response
6149 * in hda_intel.c).
6150 */
6151 codec->bus->needs_damn_long_delay = 1;
6152
Takashi Iwaie28d8322008-12-17 13:48:29 +01006153 /* no jack detecion for ref-no-jd model */
6154 if (spec->board_config == STAC_D965_REF_NO_JD)
6155 spec->hp_detect = 0;
6156
Matt2f2f4252005-04-13 14:45:30 +02006157 return 0;
6158}
6159
Matt Porterf3302a52006-07-31 12:49:34 +02006160static int patch_stac9205(struct hda_codec *codec)
6161{
6162 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02006163 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02006164
6165 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6166 if (spec == NULL)
6167 return -ENOMEM;
6168
Takashi Iwaia252c812009-12-25 22:56:20 +01006169 codec->no_trigger_sense = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006170 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006171 spec->linear_tone_beep = 1;
Takashi Iwaia4eed132007-07-06 18:17:04 +02006172 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02006173 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006174 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6175 stac9205_models,
6176 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006177 again:
Takashi Iwai330ee992009-02-20 14:33:36 +01006178 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006179 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6180 codec->chip_name);
Takashi Iwai330ee992009-02-20 14:33:36 +01006181 else
6182 stac92xx_set_config_regs(codec,
Takashi Iwaiaf9f3412008-11-18 10:38:56 +01006183 stac9205_brd_tbl[spec->board_config]);
Matt Porterf3302a52006-07-31 12:49:34 +02006184
Matthew Ranostay1cd22242008-07-18 18:20:52 +02006185 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02006186 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02006187 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02006188 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01006189 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02006190 spec->smux_nids = stac9205_smux_nids;
6191 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02006192 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02006193 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006194 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01006195 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01006196 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02006197
6198 spec->init = stac9205_core_init;
Takashi Iwaid78d7a92009-03-02 14:26:25 +01006199 spec->aloopback_ctl = stac9205_loopback;
Matt Porterf3302a52006-07-31 12:49:34 +02006200
Takashi Iwai6479c632009-07-28 18:20:25 +02006201 spec->num_caps = STAC9205_NUM_CAPS;
6202 spec->capvols = stac9205_capvols;
6203 spec->capsws = stac9205_capsws;
6204
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006205 spec->aloopback_mask = 0x40;
6206 spec->aloopback_shift = 0;
Takashi Iwaid9a42682009-01-22 17:40:18 +01006207 /* Turn on/off EAPD per HP plugging */
6208 if (spec->board_config != STAC_9205_EAPD)
6209 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02006210 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02006211
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006212 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006213 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02006214 /* Enable SPDIF in/out */
Takashi Iwai330ee992009-02-20 14:33:36 +01006215 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6216 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01006217
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006218 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwai3a938972011-10-28 01:16:55 +02006219 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
Takashi Iwaic6e4c662008-11-25 11:58:19 +01006220 if (err < 0)
6221 return err;
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01006222 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006223 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
Takashi Iwai3a938972011-10-28 01:16:55 +02006224 snd_hda_jack_detect_enable(codec, codec->afg, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006225
6226 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006227 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006228 spec->gpio_mask = 0x1b;
6229 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01006230 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006231 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02006232 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006233 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006234 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04006235 case STAC_9205_REF:
6236 /* SPDIF-In enabled */
6237 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006238 default:
6239 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02006240 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01006241 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02006242 break;
6243 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02006244
Charles Chin9009b0e2011-11-03 10:27:27 +01006245 err = stac92xx_parse_auto_config(codec);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01006246 if (!err) {
6247 if (spec->board_config < 0) {
6248 printk(KERN_WARNING "hda_codec: No auto-config is "
6249 "available, default to model=ref\n");
6250 spec->board_config = STAC_9205_REF;
6251 goto again;
6252 }
6253 err = -EINVAL;
6254 }
Matt Porterf3302a52006-07-31 12:49:34 +02006255 if (err < 0) {
6256 stac92xx_free(codec);
6257 return err;
6258 }
6259
6260 codec->patch_ops = stac92xx_patch_ops;
6261
Takashi Iwai2d34e1b2008-11-28 14:35:16 +01006262 codec->proc_widget_hook = stac9205_proc_hook;
6263
Matt Porterf3302a52006-07-31 12:49:34 +02006264 return 0;
6265}
6266
Matt2f2f4252005-04-13 14:45:30 +02006267/*
Guillaume Munch6d859062006-08-22 17:15:47 +02006268 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01006269 */
6270
Takashi Iwai2b635362011-05-02 12:33:43 +02006271static const struct hda_verb stac9872_core_init[] = {
Takashi Iwai1624cb92007-07-05 13:10:51 +02006272 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01006273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6274 {}
6275};
6276
Takashi Iwai2b635362011-05-02 12:33:43 +02006277static const hda_nid_t stac9872_pin_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006278 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6279 0x11, 0x13, 0x14,
6280};
6281
Takashi Iwai2b635362011-05-02 12:33:43 +02006282static const hda_nid_t stac9872_adc_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006283 0x8 /*,0x6*/
6284};
6285
Takashi Iwai2b635362011-05-02 12:33:43 +02006286static const hda_nid_t stac9872_mux_nids[] = {
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006287 0x15
6288};
6289
Takashi Iwai2b635362011-05-02 12:33:43 +02006290static const unsigned long stac9872_capvols[] = {
Takashi Iwai6479c632009-07-28 18:20:25 +02006291 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6292};
6293#define stac9872_capsws stac9872_capvols
6294
Takashi Iwai2b635362011-05-02 12:33:43 +02006295static const unsigned int stac9872_vaio_pin_configs[9] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006296 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6297 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6298 0x90a7013e
6299};
6300
Takashi Iwaiea734962011-01-17 11:29:34 +01006301static const char * const stac9872_models[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006302 [STAC_9872_AUTO] = "auto",
6303 [STAC_9872_VAIO] = "vaio",
6304};
6305
Takashi Iwai2b635362011-05-02 12:33:43 +02006306static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
Takashi Iwai307282c2009-03-12 18:17:58 +01006307 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6308};
6309
Takashi Iwai2b635362011-05-02 12:33:43 +02006310static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
Takashi Iwaib04add92009-07-20 08:01:36 +02006311 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6312 "Sony VAIO F/S", STAC_9872_VAIO),
Takashi Iwai307282c2009-03-12 18:17:58 +01006313 {} /* terminator */
6314};
6315
Guillaume Munch6d859062006-08-22 17:15:47 +02006316static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01006317{
6318 struct sigmatel_spec *spec;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006319 int err;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006320
Takashi Iwaidb064e52006-03-16 16:04:58 +01006321 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6322 if (spec == NULL)
6323 return -ENOMEM;
Takashi Iwaia252c812009-12-25 22:56:20 +01006324 codec->no_trigger_sense = 1;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006325 codec->spec = spec;
Daniel J Blueman1b0e3722010-08-03 11:09:13 +01006326 spec->linear_tone_beep = 1;
Takashi Iwaib04add92009-07-20 08:01:36 +02006327 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6328 spec->pin_nids = stac9872_pin_nids;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006329
6330 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6331 stac9872_models,
6332 stac9872_cfg_tbl);
Takashi Iwai307282c2009-03-12 18:17:58 +01006333 if (spec->board_config < 0)
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006334 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6335 codec->chip_name);
Takashi Iwai307282c2009-03-12 18:17:58 +01006336 else
6337 stac92xx_set_config_regs(codec,
6338 stac9872_brd_tbl[spec->board_config]);
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006339
Takashi Iwai1e137f92009-01-21 07:41:22 +01006340 spec->multiout.dac_nids = spec->dac_nids;
6341 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6342 spec->adc_nids = stac9872_adc_nids;
6343 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6344 spec->mux_nids = stac9872_mux_nids;
Takashi Iwai1e137f92009-01-21 07:41:22 +01006345 spec->init = stac9872_core_init;
Takashi Iwai6479c632009-07-28 18:20:25 +02006346 spec->num_caps = 1;
6347 spec->capvols = stac9872_capvols;
6348 spec->capsws = stac9872_capsws;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006349
Charles Chin9009b0e2011-11-03 10:27:27 +01006350 err = stac92xx_parse_auto_config(codec);
Takashi Iwai1e137f92009-01-21 07:41:22 +01006351 if (err < 0) {
6352 stac92xx_free(codec);
6353 return -EINVAL;
Takashi Iwaicaa10b62009-01-20 17:19:01 +01006354 }
Takashi Iwai1e137f92009-01-21 07:41:22 +01006355 spec->input_mux = &spec->private_imux;
6356 codec->patch_ops = stac92xx_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01006357 return 0;
6358}
6359
6360
6361/*
Matt2f2f4252005-04-13 14:45:30 +02006362 * patch entries
6363 */
Takashi Iwai2b635362011-05-02 12:33:43 +02006364static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
Matt2f2f4252005-04-13 14:45:30 +02006365 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6366 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6367 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6368 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6369 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6370 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6371 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02006372 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6373 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6374 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6375 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6376 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6377 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01006378 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6379 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6380 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6381 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6382 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6383 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6384 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6385 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6386 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6387 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01006388 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6389 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6390 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6391 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6392 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6393 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02006394 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6395 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02006396 /* The following does not take into account .id=0x83847661 when subsys =
6397 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6398 * currently not fully supported.
6399 */
6400 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6401 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6402 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Simos Xenitellisa5c0f882009-06-10 16:33:31 +01006403 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
Matt Porterf3302a52006-07-31 12:49:34 +02006404 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6405 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6406 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6407 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6408 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6409 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6410 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6411 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006412 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006413 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
Vitaliy Kulikova9694fa2010-02-04 08:58:23 +01006414 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02006415 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayff2e7332009-04-01 14:49:48 -04006416 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
Charles Chin8a345a02010-08-10 11:43:25 +02006417 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6418 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
Charles Chin36706002010-01-29 12:05:51 +01006419 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6420 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6421 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6422 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02006423 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01006424 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6425 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01006426 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01006427 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6428 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6429 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6430 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6431 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6432 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6433 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6434 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Charles Chin4d8ec5f2010-08-19 08:06:16 +02006435 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6436 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6437 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6438 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6439 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6440 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6441 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6442 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6443 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6444 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6445 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6446 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6447 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6448 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6449 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
David Henningsson46724c22011-09-20 09:02:22 +02006450 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006451 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikov4dfb8a42011-02-22 17:32:19 -06006452 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6453 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
Vitaliy Kulikovab5a6eb2010-09-08 09:00:17 +02006454 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
Charles Chinad5d8752011-11-02 07:56:58 +01006455 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6456 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6457 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6458 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6459 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6460 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6461 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6462 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6463 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6464 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6465 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6466 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
Matt2f2f4252005-04-13 14:45:30 +02006467 {} /* terminator */
6468};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01006469
6470MODULE_ALIAS("snd-hda-codec-id:8384*");
6471MODULE_ALIAS("snd-hda-codec-id:111d*");
6472
6473MODULE_LICENSE("GPL");
6474MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6475
6476static struct hda_codec_preset_list sigmatel_list = {
6477 .preset = snd_hda_preset_sigmatel,
6478 .owner = THIS_MODULE,
6479};
6480
6481static int __init patch_sigmatel_init(void)
6482{
6483 return snd_hda_add_codec_preset(&sigmatel_list);
6484}
6485
6486static void __exit patch_sigmatel_exit(void)
6487{
6488 snd_hda_delete_codec_preset(&sigmatel_list);
6489}
6490
6491module_init(patch_sigmatel_init)
6492module_exit(patch_sigmatel_exit)