blob: 5a29699c6fdb05f98fb40ae708d4b56ebd7c08a3 [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>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include "hda_codec.h"
34#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010035#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Matt4e550962005-07-04 17:51:39 +020038#define NUM_CONTROL_ALLOC 32
Matthew Ranostayc39555d2008-11-14 17:46:22 -050039
40#define STAC_VREF_EVENT 0x00
41#define STAC_INSERT_EVENT 0x10
Matthew Ranostaya64135a2008-01-10 16:55:06 +010042#define STAC_PWR_EVENT 0x20
43#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
46 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010047 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020048 STAC_9200_DELL_D21,
49 STAC_9200_DELL_D22,
50 STAC_9200_DELL_D23,
51 STAC_9200_DELL_M21,
52 STAC_9200_DELL_M22,
53 STAC_9200_DELL_M23,
54 STAC_9200_DELL_M24,
55 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020058 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010059 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010060 STAC_9200_MODELS
61};
62
63enum {
64 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020065 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020066 STAC_9205_DELL_M43,
67 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_9205_MODELS
69};
70
71enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010072 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010073 STAC_DELL_M6,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050074 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010075 STAC_92HD73XX_MODELS
76};
77
78enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020079 STAC_92HD83XXX_REF,
80 STAC_92HD83XXX_MODELS
81};
82
83enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010084 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010085 STAC_DELL_M4_1,
86 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050087 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040088 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010089 STAC_92HD71BXX_MODELS
90};
91
92enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010093 STAC_925x_REF,
94 STAC_M2_2,
95 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020096 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010097 STAC_925x_MODELS
98};
99
100enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100101 STAC_D945_REF,
102 STAC_D945GTP3,
103 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200104 STAC_INTEL_MAC_V1,
105 STAC_INTEL_MAC_V2,
106 STAC_INTEL_MAC_V3,
107 STAC_INTEL_MAC_V4,
108 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800109 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
110 * is given, one of the above models will be
111 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200112 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100113 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100114 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100115 STAC_MACBOOK_PRO_V1,
116 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200117 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200118 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300119 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200120 STAC_922X_DELL_D81,
121 STAC_922X_DELL_D82,
122 STAC_922X_DELL_M81,
123 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100124 STAC_922X_MODELS
125};
126
127enum {
128 STAC_D965_REF,
129 STAC_D965_3ST,
130 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200131 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100132 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100133 STAC_927X_MODELS
134};
Matt Porter403d1942005-11-29 15:00:51 +0100135
Matt2f2f4252005-04-13 14:45:30 +0200136struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100137 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200138 unsigned int num_mixers;
139
Matt Porter403d1942005-11-29 15:00:51 +0100140 int board_config;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -0500141 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200142 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100143 unsigned int line_switch: 1;
144 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100145 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100146 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400147 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200148
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100149 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200150 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100151 unsigned int gpio_mask;
152 unsigned int gpio_dir;
153 unsigned int gpio_data;
154 unsigned int gpio_mute;
155
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200156 /* stream */
157 unsigned int stream_delay;
158
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100159 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100160 unsigned char aloopback_mask;
161 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200162
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100163 /* power management */
164 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200165 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100166 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100167 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100168
Matt2f2f4252005-04-13 14:45:30 +0200169 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100170 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400171 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100172 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200173 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100174 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200175
176 /* capture */
177 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200178 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200179 hda_nid_t *mux_nids;
180 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200181 hda_nid_t *dmic_nids;
182 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100183 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100184 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200185 hda_nid_t *smux_nids;
186 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400187 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200188
Mattdabbed62005-06-14 10:19:34 +0200189 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100190 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200191 hda_nid_t anabeep_nid;
192 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200193
Matt2f2f4252005-04-13 14:45:30 +0200194 /* pin widgets */
195 hda_nid_t *pin_nids;
196 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200197 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200198 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200199
200 /* codec specific stuff */
201 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100202 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200203
204 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200205 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100206 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200207 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100208 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200209 struct hda_input_mux *sinput_mux;
210 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400211 unsigned int cur_amux;
212 hda_nid_t *amp_nids;
213 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200214 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200215
Matt Porter403d1942005-11-29 15:00:51 +0100216 /* i/o switches */
217 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200218 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100219 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200220 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200221
Mattc7d4b2f2005-06-27 14:59:41 +0200222 struct hda_pcm pcm_rec[2]; /* PCM information */
223
224 /* dynamic controls and input_mux */
225 struct auto_pin_cfg autocfg;
226 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100227 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200228 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200229 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200230 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400231 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100232 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200233};
234
235static hda_nid_t stac9200_adc_nids[1] = {
236 0x03,
237};
238
239static hda_nid_t stac9200_mux_nids[1] = {
240 0x0c,
241};
242
243static hda_nid_t stac9200_dac_nids[1] = {
244 0x02,
245};
246
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100247static hda_nid_t stac92hd73xx_pwr_nids[8] = {
248 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
249 0x0f, 0x10, 0x11
250};
251
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400252static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
253 0x26, 0,
254};
255
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100256static hda_nid_t stac92hd73xx_adc_nids[2] = {
257 0x1a, 0x1b
258};
259
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400260#define DELL_M6_AMP 2
261static hda_nid_t stac92hd73xx_amp_nids[3] = {
262 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400263};
264
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100265#define STAC92HD73XX_NUM_DMICS 2
266static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
267 0x13, 0x14, 0
268};
269
270#define STAC92HD73_DAC_COUNT 5
271static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
272 0x15, 0x16, 0x17, 0x18, 0x19,
273};
274
275static hda_nid_t stac92hd73xx_mux_nids[4] = {
276 0x28, 0x29, 0x2a, 0x2b,
277};
278
279static hda_nid_t stac92hd73xx_dmux_nids[2] = {
280 0x20, 0x21,
281};
282
Matthew Ranostayd9737752008-09-07 12:03:41 +0200283static hda_nid_t stac92hd73xx_smux_nids[2] = {
284 0x22, 0x23,
285};
286
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200287#define STAC92HD83XXX_NUM_DMICS 2
288static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
289 0x11, 0x12, 0
290};
291
292#define STAC92HD81_DAC_COUNT 2
293#define STAC92HD83_DAC_COUNT 3
294static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
295 0x13, 0x14, 0x22,
296};
297
298static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
299 0x17, 0x18,
300};
301
302static hda_nid_t stac92hd83xxx_adc_nids[2] = {
303 0x15, 0x16,
304};
305
306static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
307 0xa, 0xb, 0xd, 0xe,
308};
309
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400310static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
311 0x1e, 0,
312};
313
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200314static unsigned int stac92hd83xxx_pwr_mapping[4] = {
315 0x03, 0x0c, 0x10, 0x40,
316};
317
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100318static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
319 0x0a, 0x0d, 0x0f
320};
321
Matthew Ranostaye035b842007-11-06 11:53:55 +0100322static hda_nid_t stac92hd71bxx_adc_nids[2] = {
323 0x12, 0x13,
324};
325
326static hda_nid_t stac92hd71bxx_mux_nids[2] = {
327 0x1a, 0x1b
328};
329
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400330static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
331 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100332};
333
Matthew Ranostayd9737752008-09-07 12:03:41 +0200334static hda_nid_t stac92hd71bxx_smux_nids[2] = {
335 0x24, 0x25,
336};
337
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100338static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100339 0x10, /*0x11, */
340};
341
342#define STAC92HD71BXX_NUM_DMICS 2
343static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
344 0x18, 0x19, 0
345};
346
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400347static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
348 0x22, 0
349};
350
Tobin Davis8e21c342007-01-08 11:04:17 +0100351static hda_nid_t stac925x_adc_nids[1] = {
352 0x03,
353};
354
355static hda_nid_t stac925x_mux_nids[1] = {
356 0x0f,
357};
358
359static hda_nid_t stac925x_dac_nids[1] = {
360 0x02,
361};
362
Takashi Iwaif6e98522007-10-16 14:27:04 +0200363#define STAC925X_NUM_DMICS 1
364static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
365 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200366};
367
Takashi Iwai1697055e2007-12-18 18:05:52 +0100368static hda_nid_t stac925x_dmux_nids[1] = {
369 0x14,
370};
371
Matt2f2f4252005-04-13 14:45:30 +0200372static hda_nid_t stac922x_adc_nids[2] = {
373 0x06, 0x07,
374};
375
376static hda_nid_t stac922x_mux_nids[2] = {
377 0x12, 0x13,
378};
379
Matt Porter3cc08dc2006-01-23 15:27:49 +0100380static hda_nid_t stac927x_adc_nids[3] = {
381 0x07, 0x08, 0x09
382};
383
384static hda_nid_t stac927x_mux_nids[3] = {
385 0x15, 0x16, 0x17
386};
387
Matthew Ranostayd9737752008-09-07 12:03:41 +0200388static hda_nid_t stac927x_smux_nids[1] = {
389 0x21,
390};
391
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100392static hda_nid_t stac927x_dac_nids[6] = {
393 0x02, 0x03, 0x04, 0x05, 0x06, 0
394};
395
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100396static hda_nid_t stac927x_dmux_nids[1] = {
397 0x1b,
398};
399
Matthew Ranostay7f168592007-10-18 17:38:17 +0200400#define STAC927X_NUM_DMICS 2
401static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
402 0x13, 0x14, 0
403};
404
Matthew Ranostay65973632008-09-16 10:39:37 -0400405static const char *stac927x_spdif_labels[5] = {
406 "Digital Playback", "ADAT", "Analog Mux 1",
407 "Analog Mux 2", "Analog Mux 3"
408};
409
Matt Porterf3302a52006-07-31 12:49:34 +0200410static hda_nid_t stac9205_adc_nids[2] = {
411 0x12, 0x13
412};
413
414static hda_nid_t stac9205_mux_nids[2] = {
415 0x19, 0x1a
416};
417
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100418static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100419 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100420};
421
Matthew Ranostayd9737752008-09-07 12:03:41 +0200422static hda_nid_t stac9205_smux_nids[1] = {
423 0x21,
424};
425
Takashi Iwaif6e98522007-10-16 14:27:04 +0200426#define STAC9205_NUM_DMICS 2
427static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
428 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200429};
430
Mattc7d4b2f2005-06-27 14:59:41 +0200431static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200432 0x08, 0x09, 0x0d, 0x0e,
433 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200434};
435
Tobin Davis8e21c342007-01-08 11:04:17 +0100436static hda_nid_t stac925x_pin_nids[8] = {
437 0x07, 0x08, 0x0a, 0x0b,
438 0x0c, 0x0d, 0x10, 0x11,
439};
440
Matt2f2f4252005-04-13 14:45:30 +0200441static hda_nid_t stac922x_pin_nids[10] = {
442 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
443 0x0f, 0x10, 0x11, 0x15, 0x1b,
444};
445
Matthew Ranostaya7662642008-02-21 07:51:14 +0100446static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100447 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
448 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200449 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100450};
451
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200452static hda_nid_t stac92hd83xxx_pin_nids[14] = {
453 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
454 0x0f, 0x10, 0x11, 0x12, 0x13,
455 0x1d, 0x1e, 0x1f, 0x20
456};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400457static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100458 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
459 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400460 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100461};
462
Matt Porter3cc08dc2006-01-23 15:27:49 +0100463static hda_nid_t stac927x_pin_nids[14] = {
464 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
465 0x0f, 0x10, 0x11, 0x12, 0x13,
466 0x14, 0x21, 0x22, 0x23,
467};
468
Matt Porterf3302a52006-07-31 12:49:34 +0200469static hda_nid_t stac9205_pin_nids[12] = {
470 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
471 0x0f, 0x14, 0x16, 0x17, 0x18,
472 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200473};
474
Matthew Ranostay89385032008-09-11 09:49:39 -0400475#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
476
477static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct sigmatel_spec *spec = codec->spec;
482 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
483
484 kcontrol->private_value ^= get_amp_nid(kcontrol);
485 kcontrol->private_value |= nid;
486
487 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
488}
489
490static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_value *ucontrol)
492{
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct sigmatel_spec *spec = codec->spec;
495 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
496
497 kcontrol->private_value ^= get_amp_nid(kcontrol);
498 kcontrol->private_value |= nid;
499
500 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
501}
502
Matt Porter8b657272006-10-26 17:12:59 +0200503static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_info *uinfo)
505{
506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
507 struct sigmatel_spec *spec = codec->spec;
508 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
509}
510
511static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
512 struct snd_ctl_elem_value *ucontrol)
513{
514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
515 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100516 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200517
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100518 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200519 return 0;
520}
521
522static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
523 struct snd_ctl_elem_value *ucontrol)
524{
525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
526 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100527 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200528
529 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100530 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200531}
532
Matthew Ranostayd9737752008-09-07 12:03:41 +0200533static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_info *uinfo)
535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct sigmatel_spec *spec = codec->spec;
538 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
539}
540
541static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
542 struct snd_ctl_elem_value *ucontrol)
543{
544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
545 struct sigmatel_spec *spec = codec->spec;
546 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
547
548 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
549 return 0;
550}
551
552static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
553 struct snd_ctl_elem_value *ucontrol)
554{
555 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
556 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400557 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200558 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400559 int err, val;
560 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200561
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400562 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200563 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400564 if (err < 0)
565 return err;
566
567 if (spec->spdif_mute) {
568 if (smux_idx == 0)
569 nid = spec->multiout.dig_out_nid;
570 else
571 nid = codec->slave_dig_outs[smux_idx - 1];
572 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
573 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400574 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100575 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400576 /* un/mute SPDIF out */
577 snd_hda_codec_write_cache(codec, nid, 0,
578 AC_VERB_SET_AMP_GAIN_MUTE, val);
579 }
580 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200581}
582
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100583static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200584{
585 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
586 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200587 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200588}
589
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100590static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200591{
592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 struct sigmatel_spec *spec = codec->spec;
594 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
595
596 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
597 return 0;
598}
599
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100600static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200601{
602 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
603 struct sigmatel_spec *spec = codec->spec;
604 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
605
Mattc7d4b2f2005-06-27 14:59:41 +0200606 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200607 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
608}
609
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100610static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_info *uinfo)
612{
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct sigmatel_spec *spec = codec->spec;
615 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
616}
617
618static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_value *ucontrol)
620{
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 struct sigmatel_spec *spec = codec->spec;
623
624 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
625 return 0;
626}
627
628static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
629 struct snd_ctl_elem_value *ucontrol)
630{
631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
632 struct sigmatel_spec *spec = codec->spec;
633
634 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
635 spec->mono_nid, &spec->cur_mmux);
636}
637
Matthew Ranostay89385032008-09-11 09:49:39 -0400638static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
639 struct snd_ctl_elem_info *uinfo)
640{
641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
642 struct sigmatel_spec *spec = codec->spec;
643 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
644}
645
646static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
647 struct snd_ctl_elem_value *ucontrol)
648{
649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
650 struct sigmatel_spec *spec = codec->spec;
651
652 ucontrol->value.enumerated.item[0] = spec->cur_amux;
653 return 0;
654}
655
656static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
657 struct snd_ctl_elem_value *ucontrol)
658{
659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
660 struct sigmatel_spec *spec = codec->spec;
661 struct snd_kcontrol *ctl =
662 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
663 if (!ctl)
664 return -EINVAL;
665
666 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
667 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
668
669 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
670 0, &spec->cur_amux);
671}
672
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200673#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
674
675static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
676 struct snd_ctl_elem_value *ucontrol)
677{
678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100679 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200680 struct sigmatel_spec *spec = codec->spec;
681
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100682 ucontrol->value.integer.value[0] = !!(spec->aloopback &
683 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200684 return 0;
685}
686
687static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
688 struct snd_ctl_elem_value *ucontrol)
689{
690 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
691 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100692 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200693 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100694 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200695
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100696 idx_val = spec->aloopback_mask << idx;
697 if (ucontrol->value.integer.value[0])
698 val = spec->aloopback | idx_val;
699 else
700 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100701 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200702 return 0;
703
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100704 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200705
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100706 /* Only return the bits defined by the shift value of the
707 * first two bytes of the mask
708 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200709 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100710 kcontrol->private_value & 0xFFFF, 0x0);
711 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200712
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200714 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100715 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200716 } else {
717 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100718 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200719 }
720
721 snd_hda_codec_write_cache(codec, codec->afg, 0,
722 kcontrol->private_value >> 16, dac_mode);
723
724 return 1;
725}
726
Mattc7d4b2f2005-06-27 14:59:41 +0200727static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200728 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200729 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200730 {}
731};
732
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200733static struct hda_verb stac9200_eapd_init[] = {
734 /* set dac0mux for dac converter */
735 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
736 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
737 {}
738};
739
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100740static struct hda_verb stac92hd73xx_6ch_core_init[] = {
741 /* set master volume and direct control */
742 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
743 /* setup audio connections */
744 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
745 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
746 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
747 /* setup adcs to point to mixer */
748 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
749 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100750 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
751 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
752 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
753 /* setup import muxs */
754 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
755 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
756 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
757 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
758 {}
759};
760
Matthew Ranostayd654a662008-03-14 08:46:51 +0100761static struct hda_verb dell_eq_core_init[] = {
762 /* set master volume to max value without distortion
763 * and direct control */
764 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
765 /* setup audio connections */
766 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400767 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
768 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100769 /* setup adcs to point to mixer */
770 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
771 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
772 /* setup import muxs */
773 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
774 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
775 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
776 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
777 {}
778};
779
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100780static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500781 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100782 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100783 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
784 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100785 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
786 /* setup adcs to point to mixer */
787 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
788 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
789 /* setup import muxs */
790 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
791 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
792 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
793 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
794 {}
795};
796
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100797static struct hda_verb stac92hd73xx_8ch_core_init[] = {
798 /* set master volume and direct control */
799 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
800 /* setup audio connections */
801 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
802 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
803 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
804 /* connect hp ports to dac3 */
805 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
806 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
807 /* setup adcs to point to mixer */
808 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
809 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100810 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
811 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
812 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
813 /* setup import muxs */
814 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
818 {}
819};
820
821static struct hda_verb stac92hd73xx_10ch_core_init[] = {
822 /* set master volume and direct control */
823 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
824 /* setup audio connections */
825 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
826 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
827 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
828 /* dac3 is connected to import3 mux */
829 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
830 /* connect hp ports to dac4 */
831 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
832 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
833 /* setup adcs to point to mixer */
834 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
835 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 /* setup import muxs */
840 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
844 {}
845};
846
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200847static struct hda_verb stac92hd83xxx_core_init[] = {
848 /* start of config #1 */
849 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
850
851 /* start of config #2 */
852 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
853 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
854 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
855
856 /* power state controls amps */
857 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
858};
859
Matthew Ranostaye035b842007-11-06 11:53:55 +0100860static struct hda_verb stac92hd71bxx_core_init[] = {
861 /* set master volume and direct control */
862 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
863 /* connect headphone jack to dac1 */
864 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100865 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
866 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
867 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
868 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100869};
870
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400871#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100872static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200873 /* start of config #1 */
874
875 /* connect port 0f to audio mixer */
876 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200877 /* unmute right and left channels for node 0x0f */
878 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
879 /* start of config #2 */
880
Matthew Ranostay541eee82007-12-14 12:08:04 +0100881 /* set master volume and direct control */
882 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
883 /* connect headphone jack to dac1 */
884 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200885 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100886 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
887 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100888 {}
889};
890
Tobin Davis8e21c342007-01-08 11:04:17 +0100891static struct hda_verb stac925x_core_init[] = {
892 /* set dac0mux for dac converter */
893 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
894 {}
895};
896
Mattc7d4b2f2005-06-27 14:59:41 +0200897static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200898 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200899 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200900 {}
901};
902
Tobin Davis93ed1502006-09-01 21:03:12 +0200903static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200904 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200905 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200906 /* unmute node 0x1b */
907 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
908 /* select node 0x03 as DAC */
909 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
910 {}
911};
912
Matt Porter3cc08dc2006-01-23 15:27:49 +0100913static struct hda_verb stac927x_core_init[] = {
914 /* set master volume and direct control */
915 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200916 /* enable analog pc beep path */
917 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100918 {}
919};
920
Matt Porterf3302a52006-07-31 12:49:34 +0200921static struct hda_verb stac9205_core_init[] = {
922 /* set master volume and direct control */
923 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200924 /* enable analog pc beep path */
925 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200926 {}
927};
928
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100929#define STAC_MONO_MUX \
930 { \
931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
932 .name = "Mono Mux", \
933 .count = 1, \
934 .info = stac92xx_mono_mux_enum_info, \
935 .get = stac92xx_mono_mux_enum_get, \
936 .put = stac92xx_mono_mux_enum_put, \
937 }
938
Matthew Ranostay89385032008-09-11 09:49:39 -0400939#define STAC_AMP_MUX \
940 { \
941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
942 .name = "Amp Selector Capture Switch", \
943 .count = 1, \
944 .info = stac92xx_amp_mux_enum_info, \
945 .get = stac92xx_amp_mux_enum_get, \
946 .put = stac92xx_amp_mux_enum_put, \
947 }
948
949#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
950 { \
951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
952 .name = xname, \
953 .index = 0, \
954 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
955 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
956 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
957 .info = stac92xx_amp_volume_info, \
958 .get = stac92xx_amp_volume_get, \
959 .put = stac92xx_amp_volume_put, \
960 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
961 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
962 }
963
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200964#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200965 { \
966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
967 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200968 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200969 .info = stac92xx_mux_enum_info, \
970 .get = stac92xx_mux_enum_get, \
971 .put = stac92xx_mux_enum_put, \
972 }
973
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100974#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200975 { \
976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
977 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100978 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200979 .info = stac92xx_aloopback_info, \
980 .get = stac92xx_aloopback_get, \
981 .put = stac92xx_aloopback_put, \
982 .private_value = verb_read | (verb_write << 16), \
983 }
984
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100985static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200986 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
987 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200988 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200989 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
990 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200991 { } /* end */
992};
993
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400994#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100995static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400996 /* start of config #1 */
997 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
998 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
999
1000 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1001 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1002
1003 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1004 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1005
1006 /* start of config #2 */
1007 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1008 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1009
1010 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1011 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1012
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001013 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1014
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001015 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1016 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1017
1018 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1019 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1020
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001021 { } /* end */
1022};
1023
1024static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001025 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1026
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001027 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1028 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1029
1030 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1032
1033 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1034 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1035
1036 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1037 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1038
1039 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1040 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1041
1042 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1043 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1044
1045 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1046 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1047 { } /* end */
1048};
1049
1050static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001051 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1052
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001053 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1055
1056 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1058
1059 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1060 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1061
1062 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1063 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1064
1065 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1066 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1069 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1070
1071 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1072 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1073 { } /* end */
1074};
1075
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001076
1077static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1080
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1083
1084 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1085 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1086
1087 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1088 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1089
1090 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1091 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1092
1093 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1094 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1095
1096 /*
1097 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1098 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1099 */
1100 { } /* end */
1101};
1102
Matthew Ranostay541eee82007-12-14 12:08:04 +01001103static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001104 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001105 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001106
Matthew Ranostay9b359472007-11-07 13:03:12 +01001107 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1108 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001109
1110 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001112 /* analog pc-beep replaced with digital beep support */
1113 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001114 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1115 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001116 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001117
Matthew Ranostay687cb982008-10-11 13:52:43 -04001118 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1119 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001120
Matthew Ranostay687cb982008-10-11 13:52:43 -04001121 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1122 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001123
1124 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1125 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1126
1127 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1128 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001129 { } /* end */
1130};
1131
Matthew Ranostay541eee82007-12-14 12:08:04 +01001132static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001133 STAC_INPUT_SOURCE(2),
1134 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1135
Matthew Ranostay541eee82007-12-14 12:08:04 +01001136 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001138
1139 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001141 { } /* end */
1142};
1143
Tobin Davis8e21c342007-01-08 11:04:17 +01001144static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001145 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001146 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001147 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001148 { } /* end */
1149};
1150
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001151static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001152 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001153 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001154
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001157
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160 { } /* end */
1161};
1162
1163/* This needs to be generated dynamically based on sequence */
1164static struct snd_kcontrol_new stac922x_mixer[] = {
1165 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001166 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001168
1169 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001171 { } /* end */
1172};
1173
1174
1175static struct snd_kcontrol_new stac927x_mixer[] = {
1176 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001177 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001178
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001181
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001184
1185 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001187 { } /* end */
1188};
1189
Takashi Iwai1697055e2007-12-18 18:05:52 +01001190static struct snd_kcontrol_new stac_dmux_mixer = {
1191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1192 .name = "Digital Input Source",
1193 /* count set later */
1194 .info = stac92xx_dmux_enum_info,
1195 .get = stac92xx_dmux_enum_get,
1196 .put = stac92xx_dmux_enum_put,
1197};
1198
Matthew Ranostayd9737752008-09-07 12:03:41 +02001199static struct snd_kcontrol_new stac_smux_mixer = {
1200 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001201 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001202 /* count set later */
1203 .info = stac92xx_smux_enum_info,
1204 .get = stac92xx_smux_enum_get,
1205 .put = stac92xx_smux_enum_put,
1206};
1207
Takashi Iwai2134ea42008-01-10 16:53:55 +01001208static const char *slave_vols[] = {
1209 "Front Playback Volume",
1210 "Surround Playback Volume",
1211 "Center Playback Volume",
1212 "LFE Playback Volume",
1213 "Side Playback Volume",
1214 "Headphone Playback Volume",
1215 "Headphone Playback Volume",
1216 "Speaker Playback Volume",
1217 "External Speaker Playback Volume",
1218 "Speaker2 Playback Volume",
1219 NULL
1220};
1221
1222static const char *slave_sws[] = {
1223 "Front Playback Switch",
1224 "Surround Playback Switch",
1225 "Center Playback Switch",
1226 "LFE Playback Switch",
1227 "Side Playback Switch",
1228 "Headphone Playback Switch",
1229 "Headphone Playback Switch",
1230 "Speaker Playback Switch",
1231 "External Speaker Playback Switch",
1232 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001233 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001234 NULL
1235};
1236
Matt2f2f4252005-04-13 14:45:30 +02001237static int stac92xx_build_controls(struct hda_codec *codec)
1238{
1239 struct sigmatel_spec *spec = codec->spec;
1240 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001241 int i;
Matt2f2f4252005-04-13 14:45:30 +02001242
1243 err = snd_hda_add_new_ctls(codec, spec->mixer);
1244 if (err < 0)
1245 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001246
1247 for (i = 0; i < spec->num_mixers; i++) {
1248 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1249 if (err < 0)
1250 return err;
1251 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001252 if (spec->num_dmuxes > 0) {
1253 stac_dmux_mixer.count = spec->num_dmuxes;
1254 err = snd_ctl_add(codec->bus->card,
1255 snd_ctl_new1(&stac_dmux_mixer, codec));
1256 if (err < 0)
1257 return err;
1258 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001259 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001260 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1261 struct hda_input_mux *smux = &spec->private_smux;
1262 /* check for mute support on SPDIF out */
1263 if (wcaps & AC_WCAP_OUT_AMP) {
1264 smux->items[smux->num_items].label = "Off";
1265 smux->items[smux->num_items].index = 0;
1266 smux->num_items++;
1267 spec->spdif_mute = 1;
1268 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001269 stac_smux_mixer.count = spec->num_smuxes;
1270 err = snd_ctl_add(codec->bus->card,
1271 snd_ctl_new1(&stac_smux_mixer, codec));
1272 if (err < 0)
1273 return err;
1274 }
Mattc7d4b2f2005-06-27 14:59:41 +02001275
Mattdabbed62005-06-14 10:19:34 +02001276 if (spec->multiout.dig_out_nid) {
1277 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1278 if (err < 0)
1279 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001280 err = snd_hda_create_spdif_share_sw(codec,
1281 &spec->multiout);
1282 if (err < 0)
1283 return err;
1284 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001285 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001286 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001287 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1288 if (err < 0)
1289 return err;
1290 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001291
1292 /* if we have no master control, let's create it */
1293 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001294 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001295 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001296 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001297 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001298 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001299 if (err < 0)
1300 return err;
1301 }
1302 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1303 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1304 NULL, slave_sws);
1305 if (err < 0)
1306 return err;
1307 }
1308
Mattdabbed62005-06-14 10:19:34 +02001309 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001310}
1311
Matt Porter403d1942005-11-29 15:00:51 +01001312static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001313 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001314 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1315};
1316
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001317/*
1318 STAC 9200 pin configs for
1319 102801A8
1320 102801DE
1321 102801E8
1322*/
1323static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001324 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1325 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001326};
1327
1328/*
1329 STAC 9200 pin configs for
1330 102801C0
1331 102801C1
1332*/
1333static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001334 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1335 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001336};
1337
1338/*
1339 STAC 9200 pin configs for
1340 102801C4 (Dell Dimension E310)
1341 102801C5
1342 102801C7
1343 102801D9
1344 102801DA
1345 102801E3
1346*/
1347static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001348 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1349 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001350};
1351
1352
1353/*
1354 STAC 9200-32 pin configs for
1355 102801B5 (Dell Inspiron 630m)
1356 102801D8 (Dell Inspiron 640m)
1357*/
1358static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001359 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1360 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001361};
1362
1363/*
1364 STAC 9200-32 pin configs for
1365 102801C2 (Dell Latitude D620)
1366 102801C8
1367 102801CC (Dell Latitude D820)
1368 102801D4
1369 102801D6
1370*/
1371static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001372 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1373 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001374};
1375
1376/*
1377 STAC 9200-32 pin configs for
1378 102801CE (Dell XPS M1710)
1379 102801CF (Dell Precision M90)
1380*/
1381static unsigned int dell9200_m23_pin_configs[8] = {
1382 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1383 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1384};
1385
1386/*
1387 STAC 9200-32 pin configs for
1388 102801C9
1389 102801CA
1390 102801CB (Dell Latitude 120L)
1391 102801D3
1392*/
1393static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001394 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1395 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001396};
1397
1398/*
1399 STAC 9200-32 pin configs for
1400 102801BD (Dell Inspiron E1505n)
1401 102801EE
1402 102801EF
1403*/
1404static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001405 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1406 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001407};
1408
1409/*
1410 STAC 9200-32 pin configs for
1411 102801F5 (Dell Inspiron 1501)
1412 102801F6
1413*/
1414static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001415 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1416 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001417};
1418
1419/*
1420 STAC 9200-32
1421 102801CD (Dell Inspiron E1705/9400)
1422*/
1423static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001424 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1425 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001426};
1427
Tobin Davisbf277782008-02-03 20:31:47 +01001428static unsigned int oqo9200_pin_configs[8] = {
1429 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1430 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1431};
1432
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001433
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001434static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1435 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001436 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001437 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1438 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1439 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1440 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1441 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1442 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1443 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1444 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1445 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1446 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001447 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001448};
1449
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001450static const char *stac9200_models[STAC_9200_MODELS] = {
1451 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001452 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001453 [STAC_9200_DELL_D21] = "dell-d21",
1454 [STAC_9200_DELL_D22] = "dell-d22",
1455 [STAC_9200_DELL_D23] = "dell-d23",
1456 [STAC_9200_DELL_M21] = "dell-m21",
1457 [STAC_9200_DELL_M22] = "dell-m22",
1458 [STAC_9200_DELL_M23] = "dell-m23",
1459 [STAC_9200_DELL_M24] = "dell-m24",
1460 [STAC_9200_DELL_M25] = "dell-m25",
1461 [STAC_9200_DELL_M26] = "dell-m26",
1462 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001463 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001464 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001465};
1466
1467static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1468 /* SigmaTel reference board */
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1470 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001471 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1473 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001475 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1477 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1479 "unknown Dell", STAC_9200_DELL_D22),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1481 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001483 "Dell Latitude D620", STAC_9200_DELL_M22),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1485 "unknown Dell", STAC_9200_DELL_D23),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1487 "unknown Dell", STAC_9200_DELL_D23),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1489 "unknown Dell", STAC_9200_DELL_M22),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1491 "unknown Dell", STAC_9200_DELL_M24),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1493 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001495 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001497 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001499 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001501 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 "Dell Precision M90", STAC_9200_DELL_M23),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1505 "unknown Dell", STAC_9200_DELL_M22),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1507 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001509 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001511 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1513 "unknown Dell", STAC_9200_DELL_D23),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1515 "unknown Dell", STAC_9200_DELL_D23),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1517 "unknown Dell", STAC_9200_DELL_D21),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1519 "unknown Dell", STAC_9200_DELL_D23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1521 "unknown Dell", STAC_9200_DELL_D21),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1523 "unknown Dell", STAC_9200_DELL_M25),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1525 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001527 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1529 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001530 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001531 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001532 /* Gateway machines needs EAPD to be set on resume */
1533 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1534 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1535 STAC_9200_GATEWAY),
1536 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1537 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001538 /* OQO Mobile */
1539 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001540 {} /* terminator */
1541};
1542
Tobin Davis8e21c342007-01-08 11:04:17 +01001543static unsigned int ref925x_pin_configs[8] = {
1544 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001545 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001546};
1547
1548static unsigned int stac925x_MA6_pin_configs[8] = {
1549 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1550 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1551};
1552
Tobin Davis2c11f952007-05-17 09:36:34 +02001553static unsigned int stac925x_PA6_pin_configs[8] = {
1554 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1555 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1556};
1557
Tobin Davis8e21c342007-01-08 11:04:17 +01001558static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001559 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1560 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001561};
1562
1563static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1564 [STAC_REF] = ref925x_pin_configs,
1565 [STAC_M2_2] = stac925xM2_2_pin_configs,
1566 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001567 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001568};
1569
1570static const char *stac925x_models[STAC_925x_MODELS] = {
1571 [STAC_REF] = "ref",
1572 [STAC_M2_2] = "m2-2",
1573 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001574 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001575};
1576
1577static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1578 /* SigmaTel reference board */
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001580 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001581 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1582 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1583 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001584 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001585 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1586 {} /* terminator */
1587};
1588
Matthew Ranostaya7662642008-02-21 07:51:14 +01001589static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001590 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1591 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1592 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001593 0x01452050,
1594};
1595
1596static unsigned int dell_m6_pin_configs[13] = {
1597 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001598 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001599 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1600 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001601};
1602
1603static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001604 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1605 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001606 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001607};
1608
1609static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1610 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001611 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001612 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001613};
1614
1615static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1616 /* SigmaTel reference board */
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001618 "DFI LanParty", STAC_92HD73XX_REF),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1620 "unknown Dell", STAC_DELL_M6),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1622 "unknown Dell", STAC_DELL_M6),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1624 "unknown Dell", STAC_DELL_M6),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1626 "unknown Dell", STAC_DELL_M6),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1628 "unknown Dell", STAC_DELL_M6),
1629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1630 "unknown Dell", STAC_DELL_M6),
1631 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1632 "unknown Dell", STAC_DELL_M6),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001633 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1634 "Dell Studio 15", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001635 {} /* terminator */
1636};
1637
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001638static unsigned int ref92hd83xxx_pin_configs[14] = {
1639 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1640 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1641 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1642 0x01451160, 0x98560170,
1643};
1644
1645static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1646 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1647};
1648
1649static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1650 [STAC_92HD83XXX_REF] = "ref",
1651};
1652
1653static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1654 /* SigmaTel reference board */
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1656 "DFI LanParty", STAC_92HD71BXX_REF),
1657};
1658
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001659static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001660 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001661 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001662 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001663};
1664
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001665static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001666 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001667 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001668 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001669};
1670
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001671static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001672 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1673 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001674 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001675};
1676
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001677static unsigned int dell_m4_3_pin_configs[11] = {
1678 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1679 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1680 0x40f000f0, 0x044413b0, 0x044413b0,
1681};
1682
Matthew Ranostaye035b842007-11-06 11:53:55 +01001683static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1684 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001685 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1686 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001687 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001688 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001689};
1690
1691static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1692 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001693 [STAC_DELL_M4_1] = "dell-m4-1",
1694 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001695 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001696 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001697};
1698
1699static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1700 /* SigmaTel reference board */
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1702 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001703 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1704 "HP dv5", STAC_HP_M4),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1706 "HP dv7", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001707 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1708 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1710 "unknown Dell", STAC_DELL_M4_1),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1712 "unknown Dell", STAC_DELL_M4_1),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1714 "unknown Dell", STAC_DELL_M4_1),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1716 "unknown Dell", STAC_DELL_M4_1),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1718 "unknown Dell", STAC_DELL_M4_1),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1720 "unknown Dell", STAC_DELL_M4_1),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1722 "unknown Dell", STAC_DELL_M4_1),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1724 "unknown Dell", STAC_DELL_M4_2),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1726 "unknown Dell", STAC_DELL_M4_2),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1728 "unknown Dell", STAC_DELL_M4_2),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1730 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001731 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1732 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001733 {} /* terminator */
1734};
1735
Matt Porter403d1942005-11-29 15:00:51 +01001736static unsigned int ref922x_pin_configs[10] = {
1737 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1738 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001739 0x40000100, 0x40000100,
1740};
1741
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001742/*
1743 STAC 922X pin configs for
1744 102801A7
1745 102801AB
1746 102801A9
1747 102801D1
1748 102801D2
1749*/
1750static unsigned int dell_922x_d81_pin_configs[10] = {
1751 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1752 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1753 0x01813122, 0x400001f2,
1754};
1755
1756/*
1757 STAC 922X pin configs for
1758 102801AC
1759 102801D0
1760*/
1761static unsigned int dell_922x_d82_pin_configs[10] = {
1762 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1763 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1764 0x01813122, 0x400001f1,
1765};
1766
1767/*
1768 STAC 922X pin configs for
1769 102801BF
1770*/
1771static unsigned int dell_922x_m81_pin_configs[10] = {
1772 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1773 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1774 0x40C003f1, 0x405003f0,
1775};
1776
1777/*
1778 STAC 9221 A1 pin configs for
1779 102801D7 (Dell XPS M1210)
1780*/
1781static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001782 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1783 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001784 0x508003f3, 0x405003f4,
1785};
1786
Matt Porter403d1942005-11-29 15:00:51 +01001787static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001788 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001789 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1790 0x02a19120, 0x40000100,
1791};
1792
1793static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001794 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1795 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001796 0x02a19320, 0x40000100,
1797};
1798
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001799static unsigned int intel_mac_v1_pin_configs[10] = {
1800 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1801 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001802 0x400000fc, 0x400000fb,
1803};
1804
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001805static unsigned int intel_mac_v2_pin_configs[10] = {
1806 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1807 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001808 0x400000fc, 0x400000fb,
1809};
1810
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001811static unsigned int intel_mac_v3_pin_configs[10] = {
1812 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1813 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1814 0x400000fc, 0x400000fb,
1815};
1816
1817static unsigned int intel_mac_v4_pin_configs[10] = {
1818 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1819 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1820 0x400000fc, 0x400000fb,
1821};
1822
1823static unsigned int intel_mac_v5_pin_configs[10] = {
1824 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1825 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1826 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001827};
1828
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001829static unsigned int ecs202_pin_configs[10] = {
1830 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1831 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1832 0x9037012e, 0x40e000f2,
1833};
Takashi Iwai76c08822007-06-19 12:17:42 +02001834
Takashi Iwai19039bd2006-06-28 15:52:16 +02001835static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001836 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001837 [STAC_D945GTP3] = d945gtp3_pin_configs,
1838 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001839 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1840 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1841 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1842 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1843 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001844 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001845 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001846 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1847 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1848 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1849 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1850 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1851 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001852 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001853 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1854 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1855 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1856 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001857};
1858
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001859static const char *stac922x_models[STAC_922X_MODELS] = {
1860 [STAC_D945_REF] = "ref",
1861 [STAC_D945GTP5] = "5stack",
1862 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001863 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1864 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1865 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1866 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1867 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001868 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001869 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001870 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001871 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001872 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1873 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001874 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001875 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001876 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001877 [STAC_922X_DELL_D81] = "dell-d81",
1878 [STAC_922X_DELL_D82] = "dell-d82",
1879 [STAC_922X_DELL_M81] = "dell-m81",
1880 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001881};
1882
1883static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1884 /* SigmaTel reference board */
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1886 "DFI LanParty", STAC_D945_REF),
1887 /* Intel 945G based systems */
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1893 "Intel D945G", STAC_D945GTP3),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1895 "Intel D945G", STAC_D945GTP3),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1899 "Intel D945G", STAC_D945GTP3),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1901 "Intel D945G", STAC_D945GTP3),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1903 "Intel D945G", STAC_D945GTP3),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1913 "Intel D945G", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1915 "Intel D945G", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1917 "Intel D945G", STAC_D945GTP3),
1918 /* Intel D945G 5-stack systems */
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1920 "Intel D945G", STAC_D945GTP5),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1922 "Intel D945G", STAC_D945GTP5),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1924 "Intel D945G", STAC_D945GTP5),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1926 "Intel D945G", STAC_D945GTP5),
1927 /* Intel 945P based systems */
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1929 "Intel D945P", STAC_D945GTP3),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1931 "Intel D945P", STAC_D945GTP3),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1933 "Intel D945P", STAC_D945GTP3),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1935 "Intel D945P", STAC_D945GTP3),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1937 "Intel D945P", STAC_D945GTP3),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1939 "Intel D945P", STAC_D945GTP5),
1940 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001941 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001942 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001943 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001944 /* Dell systems */
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1946 "unknown Dell", STAC_922X_DELL_D81),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1948 "unknown Dell", STAC_922X_DELL_D81),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1950 "unknown Dell", STAC_922X_DELL_D81),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1952 "unknown Dell", STAC_922X_DELL_D82),
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1954 "unknown Dell", STAC_922X_DELL_M81),
1955 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1956 "unknown Dell", STAC_922X_DELL_D82),
1957 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1958 "unknown Dell", STAC_922X_DELL_D81),
1959 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1960 "unknown Dell", STAC_922X_DELL_D81),
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1962 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001963 /* ECS/PC Chips boards */
1964 SND_PCI_QUIRK(0x1019, 0x2144,
1965 "ECS/PC chips", STAC_ECS_202),
1966 SND_PCI_QUIRK(0x1019, 0x2608,
1967 "ECS/PC chips", STAC_ECS_202),
1968 SND_PCI_QUIRK(0x1019, 0x2633,
1969 "ECS/PC chips P17G/1333", STAC_ECS_202),
1970 SND_PCI_QUIRK(0x1019, 0x2811,
1971 "ECS/PC chips", STAC_ECS_202),
1972 SND_PCI_QUIRK(0x1019, 0x2812,
1973 "ECS/PC chips", STAC_ECS_202),
1974 SND_PCI_QUIRK(0x1019, 0x2813,
1975 "ECS/PC chips", STAC_ECS_202),
1976 SND_PCI_QUIRK(0x1019, 0x2814,
1977 "ECS/PC chips", STAC_ECS_202),
1978 SND_PCI_QUIRK(0x1019, 0x2815,
1979 "ECS/PC chips", STAC_ECS_202),
1980 SND_PCI_QUIRK(0x1019, 0x2816,
1981 "ECS/PC chips", STAC_ECS_202),
1982 SND_PCI_QUIRK(0x1019, 0x2817,
1983 "ECS/PC chips", STAC_ECS_202),
1984 SND_PCI_QUIRK(0x1019, 0x2818,
1985 "ECS/PC chips", STAC_ECS_202),
1986 SND_PCI_QUIRK(0x1019, 0x2819,
1987 "ECS/PC chips", STAC_ECS_202),
1988 SND_PCI_QUIRK(0x1019, 0x2820,
1989 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001990 {} /* terminator */
1991};
1992
Matt Porter3cc08dc2006-01-23 15:27:49 +01001993static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001994 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1995 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1996 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1997 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001998};
1999
Tobin Davis93ed1502006-09-01 21:03:12 +02002000static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002001 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2002 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2003 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2004 0x40000100, 0x40000100
2005};
2006
Tobin Davis93ed1502006-09-01 21:03:12 +02002007static unsigned int d965_5st_pin_configs[14] = {
2008 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2009 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2010 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2011 0x40000100, 0x40000100
2012};
2013
Tobin Davis4ff076e2007-08-07 11:48:12 +02002014static unsigned int dell_3st_pin_configs[14] = {
2015 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2016 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002017 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002018 0x40c003fc, 0x40000100
2019};
2020
Tobin Davis93ed1502006-09-01 21:03:12 +02002021static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002022 [STAC_D965_REF] = ref927x_pin_configs,
2023 [STAC_D965_3ST] = d965_3st_pin_configs,
2024 [STAC_D965_5ST] = d965_5st_pin_configs,
2025 [STAC_DELL_3ST] = dell_3st_pin_configs,
2026 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002027};
2028
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002029static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002030 [STAC_D965_REF] = "ref",
2031 [STAC_D965_3ST] = "3stack",
2032 [STAC_D965_5ST] = "5stack",
2033 [STAC_DELL_3ST] = "dell-3stack",
2034 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002035};
2036
2037static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2038 /* SigmaTel reference board */
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2040 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002041 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002044 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002061 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002062 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002066 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002075 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002085 {} /* terminator */
2086};
2087
Matt Porterf3302a52006-07-31 12:49:34 +02002088static unsigned int ref9205_pin_configs[12] = {
2089 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002090 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002091 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002092};
2093
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002094/*
2095 STAC 9205 pin configs for
2096 102801F1
2097 102801F2
2098 102801FC
2099 102801FD
2100 10280204
2101 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002102 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002103*/
2104static unsigned int dell_9205_m42_pin_configs[12] = {
2105 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2106 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2107 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2108};
2109
2110/*
2111 STAC 9205 pin configs for
2112 102801F9
2113 102801FA
2114 102801FE
2115 102801FF (Dell Precision M4300)
2116 10280206
2117 10280200
2118 10280201
2119*/
2120static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002121 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2122 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2123 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2124};
2125
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002126static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002127 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2128 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2129 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2130};
2131
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002132static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002133 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002134 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2135 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2136 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002137};
2138
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002139static const char *stac9205_models[STAC_9205_MODELS] = {
2140 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002141 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002142 [STAC_9205_DELL_M43] = "dell-m43",
2143 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002144};
2145
2146static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2147 /* SigmaTel reference board */
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2149 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2151 "unknown Dell", STAC_9205_DELL_M42),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2153 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002155 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2157 "Dell Precision", STAC_9205_DELL_M43),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2159 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2161 "unknown Dell", STAC_9205_DELL_M42),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2163 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2165 "Dell Precision", STAC_9205_DELL_M43),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002167 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2169 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2171 "Dell Precision", STAC_9205_DELL_M43),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2173 "Dell Precision", STAC_9205_DELL_M43),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2175 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2177 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2179 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002180 {} /* terminator */
2181};
2182
Richard Fish11b44bb2006-08-23 18:31:34 +02002183static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2184{
2185 int i;
2186 struct sigmatel_spec *spec = codec->spec;
2187
2188 if (! spec->bios_pin_configs) {
2189 spec->bios_pin_configs = kcalloc(spec->num_pins,
2190 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2191 if (! spec->bios_pin_configs)
2192 return -ENOMEM;
2193 }
2194
2195 for (i = 0; i < spec->num_pins; i++) {
2196 hda_nid_t nid = spec->pin_nids[i];
2197 unsigned int pin_cfg;
2198
2199 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2200 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2201 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2202 nid, pin_cfg);
2203 spec->bios_pin_configs[i] = pin_cfg;
2204 }
2205
2206 return 0;
2207}
2208
Matthew Ranostay87d48362007-07-17 11:52:24 +02002209static void stac92xx_set_config_reg(struct hda_codec *codec,
2210 hda_nid_t pin_nid, unsigned int pin_config)
2211{
2212 int i;
2213 snd_hda_codec_write(codec, pin_nid, 0,
2214 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2215 pin_config & 0x000000ff);
2216 snd_hda_codec_write(codec, pin_nid, 0,
2217 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2218 (pin_config & 0x0000ff00) >> 8);
2219 snd_hda_codec_write(codec, pin_nid, 0,
2220 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2221 (pin_config & 0x00ff0000) >> 16);
2222 snd_hda_codec_write(codec, pin_nid, 0,
2223 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2224 pin_config >> 24);
2225 i = snd_hda_codec_read(codec, pin_nid, 0,
2226 AC_VERB_GET_CONFIG_DEFAULT,
2227 0x00);
2228 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2229 pin_nid, i);
2230}
2231
Matt2f2f4252005-04-13 14:45:30 +02002232static void stac92xx_set_config_regs(struct hda_codec *codec)
2233{
2234 int i;
2235 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002236
Matthew Ranostay87d48362007-07-17 11:52:24 +02002237 if (!spec->pin_configs)
2238 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002239
Matthew Ranostay87d48362007-07-17 11:52:24 +02002240 for (i = 0; i < spec->num_pins; i++)
2241 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2242 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002243}
Matt2f2f4252005-04-13 14:45:30 +02002244
Matt2f2f4252005-04-13 14:45:30 +02002245/*
2246 * Analog playback callbacks
2247 */
2248static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2249 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002250 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002251{
2252 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002253 if (spec->stream_delay)
2254 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002255 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2256 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002257}
2258
2259static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec,
2261 unsigned int stream_tag,
2262 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002263 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002264{
2265 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002266 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002267}
2268
2269static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2270 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002271 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002272{
2273 struct sigmatel_spec *spec = codec->spec;
2274 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2275}
2276
2277/*
Mattdabbed62005-06-14 10:19:34 +02002278 * Digital playback callbacks
2279 */
2280static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2281 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002282 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002283{
2284 struct sigmatel_spec *spec = codec->spec;
2285 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2286}
2287
2288static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2289 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002290 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002291{
2292 struct sigmatel_spec *spec = codec->spec;
2293 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2294}
2295
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002296static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2297 struct hda_codec *codec,
2298 unsigned int stream_tag,
2299 unsigned int format,
2300 struct snd_pcm_substream *substream)
2301{
2302 struct sigmatel_spec *spec = codec->spec;
2303 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2304 stream_tag, format, substream);
2305}
2306
Mattdabbed62005-06-14 10:19:34 +02002307
2308/*
Matt2f2f4252005-04-13 14:45:30 +02002309 * Analog capture callbacks
2310 */
2311static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
2313 unsigned int stream_tag,
2314 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002315 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002316{
2317 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002318 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002319
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002320 if (spec->powerdown_adcs) {
2321 msleep(40);
2322 snd_hda_codec_write_cache(codec, nid, 0,
2323 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2324 }
2325 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002326 return 0;
2327}
2328
2329static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002331 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002332{
2333 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002334 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002335
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002336 snd_hda_codec_cleanup_stream(codec, nid);
2337 if (spec->powerdown_adcs)
2338 snd_hda_codec_write_cache(codec, nid, 0,
2339 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002340 return 0;
2341}
2342
Mattdabbed62005-06-14 10:19:34 +02002343static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2344 .substreams = 1,
2345 .channels_min = 2,
2346 .channels_max = 2,
2347 /* NID is set in stac92xx_build_pcms */
2348 .ops = {
2349 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002350 .close = stac92xx_dig_playback_pcm_close,
2351 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002352 },
2353};
2354
2355static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2356 .substreams = 1,
2357 .channels_min = 2,
2358 .channels_max = 2,
2359 /* NID is set in stac92xx_build_pcms */
2360};
2361
Matt2f2f4252005-04-13 14:45:30 +02002362static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2363 .substreams = 1,
2364 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002365 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002366 .nid = 0x02, /* NID to query formats and rates */
2367 .ops = {
2368 .open = stac92xx_playback_pcm_open,
2369 .prepare = stac92xx_playback_pcm_prepare,
2370 .cleanup = stac92xx_playback_pcm_cleanup
2371 },
2372};
2373
Matt Porter3cc08dc2006-01-23 15:27:49 +01002374static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2375 .substreams = 1,
2376 .channels_min = 2,
2377 .channels_max = 2,
2378 .nid = 0x06, /* NID to query formats and rates */
2379 .ops = {
2380 .open = stac92xx_playback_pcm_open,
2381 .prepare = stac92xx_playback_pcm_prepare,
2382 .cleanup = stac92xx_playback_pcm_cleanup
2383 },
2384};
2385
Matt2f2f4252005-04-13 14:45:30 +02002386static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002387 .channels_min = 2,
2388 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002389 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002390 .ops = {
2391 .prepare = stac92xx_capture_pcm_prepare,
2392 .cleanup = stac92xx_capture_pcm_cleanup
2393 },
2394};
2395
2396static int stac92xx_build_pcms(struct hda_codec *codec)
2397{
2398 struct sigmatel_spec *spec = codec->spec;
2399 struct hda_pcm *info = spec->pcm_rec;
2400
2401 codec->num_pcms = 1;
2402 codec->pcm_info = info;
2403
Mattc7d4b2f2005-06-27 14:59:41 +02002404 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002405 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002406 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002407 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002408 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002409
2410 if (spec->alt_switch) {
2411 codec->num_pcms++;
2412 info++;
2413 info->name = "STAC92xx Analog Alt";
2414 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2415 }
Matt2f2f4252005-04-13 14:45:30 +02002416
Mattdabbed62005-06-14 10:19:34 +02002417 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2418 codec->num_pcms++;
2419 info++;
2420 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002421 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002422 if (spec->multiout.dig_out_nid) {
2423 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2424 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2425 }
2426 if (spec->dig_in_nid) {
2427 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2428 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2429 }
2430 }
2431
Matt2f2f4252005-04-13 14:45:30 +02002432 return 0;
2433}
2434
Takashi Iwaic960a032006-03-23 17:06:28 +01002435static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2436{
2437 unsigned int pincap = snd_hda_param_read(codec, nid,
2438 AC_PAR_PIN_CAP);
2439 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2440 if (pincap & AC_PINCAP_VREF_100)
2441 return AC_PINCTL_VREF_100;
2442 if (pincap & AC_PINCAP_VREF_80)
2443 return AC_PINCTL_VREF_80;
2444 if (pincap & AC_PINCAP_VREF_50)
2445 return AC_PINCTL_VREF_50;
2446 if (pincap & AC_PINCAP_VREF_GRD)
2447 return AC_PINCTL_VREF_GRD;
2448 return 0;
2449}
2450
Matt Porter403d1942005-11-29 15:00:51 +01002451static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2452
2453{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002454 snd_hda_codec_write_cache(codec, nid, 0,
2455 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002456}
2457
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002458#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2459
2460static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2461 struct snd_ctl_elem_value *ucontrol)
2462{
2463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2464 struct sigmatel_spec *spec = codec->spec;
2465
Takashi Iwaid7a89432008-11-12 09:48:04 +01002466 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002467 return 0;
2468}
2469
2470static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2471 struct snd_ctl_elem_value *ucontrol)
2472{
2473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2474 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002475 int nid = kcontrol->private_value;
2476
2477 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002478
2479 /* check to be sure that the ports are upto date with
2480 * switch changes
2481 */
2482 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2483
2484 return 1;
2485}
2486
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002487#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002488
2489static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2490{
2491 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2492 struct sigmatel_spec *spec = codec->spec;
2493 int io_idx = kcontrol-> private_value & 0xff;
2494
2495 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2496 return 0;
2497}
2498
2499static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2500{
2501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2502 struct sigmatel_spec *spec = codec->spec;
2503 hda_nid_t nid = kcontrol->private_value >> 8;
2504 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002505 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002506
2507 spec->io_switch[io_idx] = val;
2508
2509 if (val)
2510 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002511 else {
2512 unsigned int pinctl = AC_PINCTL_IN_EN;
2513 if (io_idx) /* set VREF for mic */
2514 pinctl |= stac92xx_get_vref(codec, nid);
2515 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2516 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002517
2518 /* check the auto-mute again: we need to mute/unmute the speaker
2519 * appropriately according to the pin direction
2520 */
2521 if (spec->hp_detect)
2522 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2523
Matt Porter403d1942005-11-29 15:00:51 +01002524 return 1;
2525}
2526
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002527#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2528
2529static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2530 struct snd_ctl_elem_value *ucontrol)
2531{
2532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2533 struct sigmatel_spec *spec = codec->spec;
2534
2535 ucontrol->value.integer.value[0] = spec->clfe_swap;
2536 return 0;
2537}
2538
2539static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2540 struct snd_ctl_elem_value *ucontrol)
2541{
2542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2543 struct sigmatel_spec *spec = codec->spec;
2544 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002545 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002546
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002547 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002548 return 0;
2549
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002550 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002551
2552 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2553 spec->clfe_swap ? 0x4 : 0x0);
2554
2555 return 1;
2556}
2557
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002558#define STAC_CODEC_HP_SWITCH(xname) \
2559 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2560 .name = xname, \
2561 .index = 0, \
2562 .info = stac92xx_hp_switch_info, \
2563 .get = stac92xx_hp_switch_get, \
2564 .put = stac92xx_hp_switch_put, \
2565 }
2566
Matt Porter403d1942005-11-29 15:00:51 +01002567#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2568 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2569 .name = xname, \
2570 .index = 0, \
2571 .info = stac92xx_io_switch_info, \
2572 .get = stac92xx_io_switch_get, \
2573 .put = stac92xx_io_switch_put, \
2574 .private_value = xpval, \
2575 }
2576
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002577#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2578 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2579 .name = xname, \
2580 .index = 0, \
2581 .info = stac92xx_clfe_switch_info, \
2582 .get = stac92xx_clfe_switch_get, \
2583 .put = stac92xx_clfe_switch_put, \
2584 .private_value = xpval, \
2585 }
Matt Porter403d1942005-11-29 15:00:51 +01002586
Mattc7d4b2f2005-06-27 14:59:41 +02002587enum {
2588 STAC_CTL_WIDGET_VOL,
2589 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002590 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002591 STAC_CTL_WIDGET_AMP_MUX,
2592 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002593 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002594 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002595 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002596};
2597
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002598static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002599 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2600 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002601 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002602 STAC_AMP_MUX,
2603 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002604 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002605 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002606 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002607};
2608
2609/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002610static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2611 struct snd_kcontrol_new *ktemp,
2612 int idx, const char *name,
2613 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002614{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002615 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002616
2617 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2618 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2619
2620 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2621 if (! knew)
2622 return -ENOMEM;
2623 if (spec->kctl_alloc) {
2624 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2625 kfree(spec->kctl_alloc);
2626 }
2627 spec->kctl_alloc = knew;
2628 spec->num_kctl_alloc = num;
2629 }
2630
2631 knew = &spec->kctl_alloc[spec->num_kctl_used];
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002632 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002633 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002634 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002635 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002636 return -ENOMEM;
2637 knew->private_value = val;
2638 spec->num_kctl_used++;
2639 return 0;
2640}
2641
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002642static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2643 int type, int idx, const char *name,
2644 unsigned long val)
2645{
2646 return stac92xx_add_control_temp(spec,
2647 &stac92xx_control_templates[type],
2648 idx, name, val);
2649}
2650
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002651
2652/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002653static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2654 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002655{
2656 return stac92xx_add_control_idx(spec, type, 0, name, val);
2657}
2658
Matt Porter403d1942005-11-29 15:00:51 +01002659/* flag inputs as additional dynamic lineouts */
2660static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2661{
2662 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002663 unsigned int wcaps, wtype;
2664 int i, num_dacs = 0;
2665
2666 /* use the wcaps cache to count all DACs available for line-outs */
2667 for (i = 0; i < codec->num_nodes; i++) {
2668 wcaps = codec->wcaps[i];
2669 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002670
Steve Longerbeam7b043892007-05-03 20:50:03 +02002671 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2672 num_dacs++;
2673 }
Matt Porter403d1942005-11-29 15:00:51 +01002674
Steve Longerbeam7b043892007-05-03 20:50:03 +02002675 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2676
Matt Porter403d1942005-11-29 15:00:51 +01002677 switch (cfg->line_outs) {
2678 case 3:
2679 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002680 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002681 cfg->line_out_pins[cfg->line_outs] =
2682 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002683 spec->line_switch = 1;
2684 cfg->line_outs++;
2685 }
2686 break;
2687 case 2:
2688 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002689 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002690 cfg->line_out_pins[cfg->line_outs] =
2691 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002692 spec->line_switch = 1;
2693 cfg->line_outs++;
2694 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002695 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002696 cfg->line_out_pins[cfg->line_outs] =
2697 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002698 spec->mic_switch = 1;
2699 cfg->line_outs++;
2700 }
2701 break;
2702 case 1:
2703 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002704 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002705 cfg->line_out_pins[cfg->line_outs] =
2706 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002707 spec->line_switch = 1;
2708 cfg->line_outs++;
2709 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002710 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002711 cfg->line_out_pins[cfg->line_outs] =
2712 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002713 spec->mic_switch = 1;
2714 cfg->line_outs++;
2715 }
2716 break;
2717 }
2718
2719 return 0;
2720}
2721
Steve Longerbeam7b043892007-05-03 20:50:03 +02002722
2723static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2724{
2725 int i;
2726
2727 for (i = 0; i < spec->multiout.num_dacs; i++) {
2728 if (spec->multiout.dac_nids[i] == nid)
2729 return 1;
2730 }
2731
2732 return 0;
2733}
2734
Matt Porter3cc08dc2006-01-23 15:27:49 +01002735/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002736 * Fill in the dac_nids table from the parsed pin configuration
2737 * This function only works when every pin in line_out_pins[]
2738 * contains atleast one DAC in its connection list. Some 92xx
2739 * codecs are not connected directly to a DAC, such as the 9200
2740 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002741 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002742static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002743 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002744{
2745 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002746 int i, j, conn_len = 0;
2747 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2748 unsigned int wcaps, wtype;
2749
Mattc7d4b2f2005-06-27 14:59:41 +02002750 for (i = 0; i < cfg->line_outs; i++) {
2751 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002752 conn_len = snd_hda_get_connections(codec, nid, conn,
2753 HDA_MAX_CONNECTIONS);
2754 for (j = 0; j < conn_len; j++) {
2755 wcaps = snd_hda_param_read(codec, conn[j],
2756 AC_PAR_AUDIO_WIDGET_CAP);
2757 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002758 if (wtype != AC_WID_AUD_OUT ||
2759 (wcaps & AC_WCAP_DIGITAL))
2760 continue;
2761 /* conn[j] is a DAC routed to this line-out */
2762 if (!is_in_dac_nids(spec, conn[j]))
2763 break;
2764 }
2765
2766 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002767 if (spec->multiout.num_dacs > 0) {
2768 /* we have already working output pins,
2769 * so let's drop the broken ones again
2770 */
2771 cfg->line_outs = spec->multiout.num_dacs;
2772 break;
2773 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002774 /* error out, no available DAC found */
2775 snd_printk(KERN_ERR
2776 "%s: No available DAC for pin 0x%x\n",
2777 __func__, nid);
2778 return -ENODEV;
2779 }
2780
2781 spec->multiout.dac_nids[i] = conn[j];
2782 spec->multiout.num_dacs++;
2783 if (conn_len > 1) {
2784 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002785 snd_hda_codec_write_cache(codec, nid, 0,
2786 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002787
2788 }
Mattc7d4b2f2005-06-27 14:59:41 +02002789 }
2790
Steve Longerbeam7b043892007-05-03 20:50:03 +02002791 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2792 spec->multiout.num_dacs,
2793 spec->multiout.dac_nids[0],
2794 spec->multiout.dac_nids[1],
2795 spec->multiout.dac_nids[2],
2796 spec->multiout.dac_nids[3],
2797 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002798 return 0;
2799}
2800
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002801/* create volume control/switch for the given prefx type */
2802static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2803{
2804 char name[32];
2805 int err;
2806
2807 sprintf(name, "%s Playback Volume", pfx);
2808 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2809 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2810 if (err < 0)
2811 return err;
2812 sprintf(name, "%s Playback Switch", pfx);
2813 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2814 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2815 if (err < 0)
2816 return err;
2817 return 0;
2818}
2819
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002820static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2821{
2822 if (!spec->multiout.hp_nid)
2823 spec->multiout.hp_nid = nid;
2824 else if (spec->multiout.num_dacs > 4) {
2825 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2826 return 1;
2827 } else {
2828 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2829 spec->multiout.num_dacs++;
2830 }
2831 return 0;
2832}
2833
2834static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2835{
2836 if (is_in_dac_nids(spec, nid))
2837 return 1;
2838 if (spec->multiout.hp_nid == nid)
2839 return 1;
2840 return 0;
2841}
2842
Mattc7d4b2f2005-06-27 14:59:41 +02002843/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002844static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002845 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002846{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002847 static const char *chname[4] = {
2848 "Front", "Surround", NULL /*CLFE*/, "Side"
2849 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002850 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002851 int i, err;
2852
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002853 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002854 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002855
2856
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002857 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002858 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002859 continue;
2860
2861 nid = spec->multiout.dac_nids[i];
2862
2863 if (i == 2) {
2864 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002865 err = create_controls(spec, "Center", nid, 1);
2866 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002867 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002868 err = create_controls(spec, "LFE", nid, 2);
2869 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002870 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002871
2872 wid_caps = get_wcaps(codec, nid);
2873
2874 if (wid_caps & AC_WCAP_LR_SWAP) {
2875 err = stac92xx_add_control(spec,
2876 STAC_CTL_WIDGET_CLFE_SWITCH,
2877 "Swap Center/LFE Playback Switch", nid);
2878
2879 if (err < 0)
2880 return err;
2881 }
2882
Mattc7d4b2f2005-06-27 14:59:41 +02002883 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002884 err = create_controls(spec, chname[i], nid, 3);
2885 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002886 return err;
2887 }
2888 }
2889
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002890 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2891 cfg->hp_outs && !spec->multiout.hp_nid)
2892 spec->multiout.hp_nid = nid;
2893
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002894 if (cfg->hp_outs > 1) {
2895 err = stac92xx_add_control(spec,
2896 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002897 "Headphone as Line Out Switch",
2898 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002899 if (err < 0)
2900 return err;
2901 }
2902
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002903 if (spec->line_switch) {
2904 nid = cfg->input_pins[AUTO_PIN_LINE];
2905 pincap = snd_hda_param_read(codec, nid,
2906 AC_PAR_PIN_CAP);
2907 if (pincap & AC_PINCAP_OUT) {
2908 err = stac92xx_add_control(spec,
2909 STAC_CTL_WIDGET_IO_SWITCH,
2910 "Line In as Output Switch", nid << 8);
2911 if (err < 0)
2912 return err;
2913 }
2914 }
Matt Porter403d1942005-11-29 15:00:51 +01002915
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002916 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002917 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002918 unsigned int mic_pin = AUTO_PIN_MIC;
2919again:
2920 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002921 def_conf = snd_hda_codec_read(codec, nid, 0,
2922 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002923 /* some laptops have an internal analog microphone
2924 * which can't be used as a output */
2925 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2926 pincap = snd_hda_param_read(codec, nid,
2927 AC_PAR_PIN_CAP);
2928 if (pincap & AC_PINCAP_OUT) {
2929 err = stac92xx_add_control(spec,
2930 STAC_CTL_WIDGET_IO_SWITCH,
2931 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002932 nid = snd_hda_codec_read(codec, nid, 0,
2933 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2934 if (!check_in_dac_nids(spec, nid))
2935 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002936 if (err < 0)
2937 return err;
2938 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002939 } else if (mic_pin == AUTO_PIN_MIC) {
2940 mic_pin = AUTO_PIN_FRONT_MIC;
2941 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002942 }
2943 }
Matt Porter403d1942005-11-29 15:00:51 +01002944
Mattc7d4b2f2005-06-27 14:59:41 +02002945 return 0;
2946}
2947
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002948/* add playback controls for Speaker and HP outputs */
2949static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2950 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002951{
2952 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002953 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002954 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002955
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002956 old_num_dacs = spec->multiout.num_dacs;
2957 for (i = 0; i < cfg->hp_outs; i++) {
2958 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2959 if (wid_caps & AC_WCAP_UNSOL_CAP)
2960 spec->hp_detect = 1;
2961 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2962 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2963 if (check_in_dac_nids(spec, nid))
2964 nid = 0;
2965 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002966 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002967 add_spec_dacs(spec, nid);
2968 }
2969 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002970 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002971 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2972 if (check_in_dac_nids(spec, nid))
2973 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002974 if (! nid)
2975 continue;
2976 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002977 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002978 for (i = 0; i < cfg->line_outs; i++) {
2979 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2980 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2981 if (check_in_dac_nids(spec, nid))
2982 nid = 0;
2983 if (! nid)
2984 continue;
2985 add_spec_dacs(spec, nid);
2986 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002987 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2988 static const char *pfxs[] = {
2989 "Speaker", "External Speaker", "Speaker2",
2990 };
2991 err = create_controls(spec, pfxs[i - old_num_dacs],
2992 spec->multiout.dac_nids[i], 3);
2993 if (err < 0)
2994 return err;
2995 }
2996 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002997 err = create_controls(spec, "Headphone",
2998 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002999 if (err < 0)
3000 return err;
3001 }
Mattc7d4b2f2005-06-27 14:59:41 +02003002
3003 return 0;
3004}
3005
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003006/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003007static const char *stac92xx_mono_labels[4] = {
3008 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003009};
3010
3011/* create mono mux for mono out on capable codecs */
3012static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3013{
3014 struct sigmatel_spec *spec = codec->spec;
3015 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3016 int i, num_cons;
3017 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3018
3019 num_cons = snd_hda_get_connections(codec,
3020 spec->mono_nid,
3021 con_lst,
3022 HDA_MAX_NUM_INPUTS);
3023 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3024 return -EINVAL;
3025
3026 for (i = 0; i < num_cons; i++) {
3027 mono_mux->items[mono_mux->num_items].label =
3028 stac92xx_mono_labels[i];
3029 mono_mux->items[mono_mux->num_items].index = i;
3030 mono_mux->num_items++;
3031 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003032
3033 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3034 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003035}
3036
Matthew Ranostay89385032008-09-11 09:49:39 -04003037/* labels for amp mux outputs */
3038static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003039 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003040};
3041
3042/* create amp out controls mux on capable codecs */
3043static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3044{
3045 struct sigmatel_spec *spec = codec->spec;
3046 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3047 int i, err;
3048
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003049 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003050 amp_mux->items[amp_mux->num_items].label =
3051 stac92xx_amp_labels[i];
3052 amp_mux->items[amp_mux->num_items].index = i;
3053 amp_mux->num_items++;
3054 }
3055
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003056 if (spec->num_amps > 1) {
3057 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3058 "Amp Selector Capture Switch", 0);
3059 if (err < 0)
3060 return err;
3061 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003062 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3063 "Amp Capture Volume",
3064 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3065}
3066
3067
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003068/* create PC beep volume controls */
3069static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3070 hda_nid_t nid)
3071{
3072 struct sigmatel_spec *spec = codec->spec;
3073 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3074 int err;
3075
3076 /* check for mute support for the the amp */
3077 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3078 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3079 "PC Beep Playback Switch",
3080 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3081 if (err < 0)
3082 return err;
3083 }
3084
3085 /* check to see if there is volume support for the amp */
3086 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3087 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3088 "PC Beep Playback Volume",
3089 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3090 if (err < 0)
3091 return err;
3092 }
3093 return 0;
3094}
3095
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003096#ifdef CONFIG_SND_HDA_INPUT_BEEP
3097#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3098
3099static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3100 struct snd_ctl_elem_value *ucontrol)
3101{
3102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3103 ucontrol->value.integer.value[0] = codec->beep->enabled;
3104 return 0;
3105}
3106
3107static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3108 struct snd_ctl_elem_value *ucontrol)
3109{
3110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3111 int enabled = !!ucontrol->value.integer.value[0];
3112 if (codec->beep->enabled != enabled) {
3113 codec->beep->enabled = enabled;
3114 return 1;
3115 }
3116 return 0;
3117}
3118
3119static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3121 .info = stac92xx_dig_beep_switch_info,
3122 .get = stac92xx_dig_beep_switch_get,
3123 .put = stac92xx_dig_beep_switch_put,
3124};
3125
3126static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3127{
3128 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3129 0, "PC Beep Playback Switch", 0);
3130}
3131#endif
3132
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003133static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3134{
3135 struct sigmatel_spec *spec = codec->spec;
3136 int wcaps, nid, i, err = 0;
3137
3138 for (i = 0; i < spec->num_muxes; i++) {
3139 nid = spec->mux_nids[i];
3140 wcaps = get_wcaps(codec, nid);
3141
3142 if (wcaps & AC_WCAP_OUT_AMP) {
3143 err = stac92xx_add_control_idx(spec,
3144 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3145 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3146 if (err < 0)
3147 return err;
3148 }
3149 }
3150 return 0;
3151};
3152
Matthew Ranostayd9737752008-09-07 12:03:41 +02003153static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003154 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003155};
3156
3157static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3158{
3159 struct sigmatel_spec *spec = codec->spec;
3160 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003161 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003162 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003163 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003164
3165 num_cons = snd_hda_get_connections(codec,
3166 spec->smux_nids[0],
3167 con_lst,
3168 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003169 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003170 return -EINVAL;
3171
Matthew Ranostay65973632008-09-16 10:39:37 -04003172 if (!labels)
3173 labels = stac92xx_spdif_labels;
3174
Matthew Ranostayd9737752008-09-07 12:03:41 +02003175 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003176 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003177 spdif_mux->items[spdif_mux->num_items].index = i;
3178 spdif_mux->num_items++;
3179 }
3180
3181 return 0;
3182}
3183
Matt Porter8b657272006-10-26 17:12:59 +02003184/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003185static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003186 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3187 "Digital Mic 3", "Digital Mic 4"
3188};
3189
3190/* create playback/capture controls for input pins on dmic capable codecs */
3191static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3192 const struct auto_pin_cfg *cfg)
3193{
3194 struct sigmatel_spec *spec = codec->spec;
3195 struct hda_input_mux *dimux = &spec->private_dimux;
3196 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003197 int err, i, j;
3198 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003199
3200 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3201 dimux->items[dimux->num_items].index = 0;
3202 dimux->num_items++;
3203
3204 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003205 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003206 int index;
3207 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003208 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003209 unsigned int def_conf;
3210
3211 def_conf = snd_hda_codec_read(codec,
3212 spec->dmic_nids[i],
3213 0,
3214 AC_VERB_GET_CONFIG_DEFAULT,
3215 0);
3216 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3217 continue;
3218
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003219 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003220 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003221 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003222 con_lst,
3223 HDA_MAX_NUM_INPUTS);
3224 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003225 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003226 index = j;
3227 goto found;
3228 }
3229 continue;
3230found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003231 wcaps = get_wcaps(codec, nid) &
3232 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003233
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003234 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003235 sprintf(name, "%s Capture Volume",
3236 stac92xx_dmic_labels[dimux->num_items]);
3237
3238 err = stac92xx_add_control(spec,
3239 STAC_CTL_WIDGET_VOL,
3240 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003241 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3242 (wcaps & AC_WCAP_OUT_AMP) ?
3243 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003244 if (err < 0)
3245 return err;
3246 }
3247
Matt Porter8b657272006-10-26 17:12:59 +02003248 dimux->items[dimux->num_items].label =
3249 stac92xx_dmic_labels[dimux->num_items];
3250 dimux->items[dimux->num_items].index = index;
3251 dimux->num_items++;
3252 }
3253
3254 return 0;
3255}
3256
Mattc7d4b2f2005-06-27 14:59:41 +02003257/* create playback/capture controls for input pins */
3258static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3259{
3260 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003261 struct hda_input_mux *imux = &spec->private_imux;
3262 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3263 int i, j, k;
3264
3265 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003266 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003267
Takashi Iwai314634b2006-09-21 11:56:18 +02003268 if (!cfg->input_pins[i])
3269 continue;
3270 index = -1;
3271 for (j = 0; j < spec->num_muxes; j++) {
3272 int num_cons;
3273 num_cons = snd_hda_get_connections(codec,
3274 spec->mux_nids[j],
3275 con_lst,
3276 HDA_MAX_NUM_INPUTS);
3277 for (k = 0; k < num_cons; k++)
3278 if (con_lst[k] == cfg->input_pins[i]) {
3279 index = k;
3280 goto found;
3281 }
Mattc7d4b2f2005-06-27 14:59:41 +02003282 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003283 continue;
3284 found:
3285 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3286 imux->items[imux->num_items].index = index;
3287 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003288 }
3289
Steve Longerbeam7b043892007-05-03 20:50:03 +02003290 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003291 /*
3292 * Set the current input for the muxes.
3293 * The STAC9221 has two input muxes with identical source
3294 * NID lists. Hopefully this won't get confused.
3295 */
3296 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003297 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3298 AC_VERB_SET_CONNECT_SEL,
3299 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003300 }
3301 }
3302
Mattc7d4b2f2005-06-27 14:59:41 +02003303 return 0;
3304}
3305
Mattc7d4b2f2005-06-27 14:59:41 +02003306static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3307{
3308 struct sigmatel_spec *spec = codec->spec;
3309 int i;
3310
3311 for (i = 0; i < spec->autocfg.line_outs; i++) {
3312 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3313 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3314 }
3315}
3316
3317static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3318{
3319 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003320 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003321
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003322 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3323 hda_nid_t pin;
3324 pin = spec->autocfg.hp_pins[i];
3325 if (pin) /* connect to front */
3326 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3327 }
3328 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3329 hda_nid_t pin;
3330 pin = spec->autocfg.speaker_pins[i];
3331 if (pin) /* connect to front */
3332 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3333 }
Mattc7d4b2f2005-06-27 14:59:41 +02003334}
3335
Matt Porter3cc08dc2006-01-23 15:27:49 +01003336static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
Mattc7d4b2f2005-06-27 14:59:41 +02003337{
3338 struct sigmatel_spec *spec = codec->spec;
3339 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003340 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003341
Matt Porter8b657272006-10-26 17:12:59 +02003342 if ((err = snd_hda_parse_pin_def_config(codec,
3343 &spec->autocfg,
3344 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003345 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003346 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003347 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003348
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003349 /* If we have no real line-out pin and multiple hp-outs, HPs should
3350 * be set up as multi-channel outputs.
3351 */
3352 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3353 spec->autocfg.hp_outs > 1) {
3354 /* Copy hp_outs to line_outs, backup line_outs in
3355 * speaker_outs so that the following routines can handle
3356 * HP pins as primary outputs.
3357 */
3358 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3359 sizeof(spec->autocfg.line_out_pins));
3360 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3361 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3362 sizeof(spec->autocfg.hp_pins));
3363 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3364 hp_speaker_swap = 1;
3365 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003366 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003367 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3368 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003369 u32 caps = query_amp_caps(codec,
3370 spec->autocfg.mono_out_pin, dir);
3371 hda_nid_t conn_list[1];
3372
3373 /* get the mixer node and then the mono mux if it exists */
3374 if (snd_hda_get_connections(codec,
3375 spec->autocfg.mono_out_pin, conn_list, 1) &&
3376 snd_hda_get_connections(codec, conn_list[0],
3377 conn_list, 1)) {
3378
3379 int wcaps = get_wcaps(codec, conn_list[0]);
3380 int wid_type = (wcaps & AC_WCAP_TYPE)
3381 >> AC_WCAP_TYPE_SHIFT;
3382 /* LR swap check, some stac925x have a mux that
3383 * changes the DACs output path instead of the
3384 * mono-mux path.
3385 */
3386 if (wid_type == AC_WID_AUD_SEL &&
3387 !(wcaps & AC_WCAP_LR_SWAP))
3388 spec->mono_nid = conn_list[0];
3389 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003390 if (dir) {
3391 hda_nid_t nid = spec->autocfg.mono_out_pin;
3392
3393 /* most mono outs have a least a mute/unmute switch */
3394 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3395 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3396 "Mono Playback Switch",
3397 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003398 if (err < 0)
3399 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003400 /* check for volume support for the amp */
3401 if ((caps & AC_AMPCAP_NUM_STEPS)
3402 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3403 err = stac92xx_add_control(spec,
3404 STAC_CTL_WIDGET_VOL,
3405 "Mono Playback Volume",
3406 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3407 if (err < 0)
3408 return err;
3409 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003410 }
3411
3412 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3413 AC_PINCTL_OUT_EN);
3414 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003415
Matt Porter403d1942005-11-29 15:00:51 +01003416 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3417 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003418 if (spec->multiout.num_dacs == 0)
3419 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3420 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003421
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003422 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3423
3424 if (err < 0)
3425 return err;
3426
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003427 /* setup analog beep controls */
3428 if (spec->anabeep_nid > 0) {
3429 err = stac92xx_auto_create_beep_ctls(codec,
3430 spec->anabeep_nid);
3431 if (err < 0)
3432 return err;
3433 }
3434
3435 /* setup digital beep controls and input device */
3436#ifdef CONFIG_SND_HDA_INPUT_BEEP
3437 if (spec->digbeep_nid > 0) {
3438 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003439 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003440
3441 err = stac92xx_auto_create_beep_ctls(codec, nid);
3442 if (err < 0)
3443 return err;
3444 err = snd_hda_attach_beep_device(codec, nid);
3445 if (err < 0)
3446 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003447 /* if no beep switch is available, make its own one */
3448 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3449 if (codec->beep &&
3450 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3451 err = stac92xx_beep_switch_ctl(codec);
3452 if (err < 0)
3453 return err;
3454 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003455 }
3456#endif
3457
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003458 if (hp_speaker_swap == 1) {
3459 /* Restore the hp_outs and line_outs */
3460 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3461 sizeof(spec->autocfg.line_out_pins));
3462 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3463 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3464 sizeof(spec->autocfg.speaker_pins));
3465 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3466 memset(spec->autocfg.speaker_pins, 0,
3467 sizeof(spec->autocfg.speaker_pins));
3468 spec->autocfg.speaker_outs = 0;
3469 }
3470
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003471 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3472
3473 if (err < 0)
3474 return err;
3475
3476 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3477
3478 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003479 return err;
3480
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003481 if (spec->mono_nid > 0) {
3482 err = stac92xx_auto_create_mono_output_ctls(codec);
3483 if (err < 0)
3484 return err;
3485 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003486 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003487 err = stac92xx_auto_create_amp_output_ctls(codec);
3488 if (err < 0)
3489 return err;
3490 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003491 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003492 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3493 &spec->autocfg)) < 0)
3494 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003495 if (spec->num_muxes > 0) {
3496 err = stac92xx_auto_create_mux_input_ctls(codec);
3497 if (err < 0)
3498 return err;
3499 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003500 if (spec->num_smuxes > 0) {
3501 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3502 if (err < 0)
3503 return err;
3504 }
Matt Porter8b657272006-10-26 17:12:59 +02003505
Mattc7d4b2f2005-06-27 14:59:41 +02003506 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003507 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003508 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003509
Takashi Iwai82bc9552006-03-21 11:24:42 +01003510 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003511 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003512 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003513 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003514
3515 if (spec->kctl_alloc)
3516 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3517
3518 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003519 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003520 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003521 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003522 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003523 return 1;
3524}
3525
Takashi Iwai82bc9552006-03-21 11:24:42 +01003526/* add playback controls for HP output */
3527static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3528 struct auto_pin_cfg *cfg)
3529{
3530 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003531 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003532 unsigned int wid_caps;
3533
3534 if (! pin)
3535 return 0;
3536
3537 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003538 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003539 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003540
3541 return 0;
3542}
3543
Richard Fish160ea0d2006-09-06 13:58:25 +02003544/* add playback controls for LFE output */
3545static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3546 struct auto_pin_cfg *cfg)
3547{
3548 struct sigmatel_spec *spec = codec->spec;
3549 int err;
3550 hda_nid_t lfe_pin = 0x0;
3551 int i;
3552
3553 /*
3554 * search speaker outs and line outs for a mono speaker pin
3555 * with an amp. If one is found, add LFE controls
3556 * for it.
3557 */
3558 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3559 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003560 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003561 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3562 if (wcaps == AC_WCAP_OUT_AMP)
3563 /* found a mono speaker with an amp, must be lfe */
3564 lfe_pin = pin;
3565 }
3566
3567 /* if speaker_outs is 0, then speakers may be in line_outs */
3568 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3569 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3570 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003571 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003572 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003573 AC_VERB_GET_CONFIG_DEFAULT,
3574 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003575 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003576 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003577 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3578 if (wcaps == AC_WCAP_OUT_AMP)
3579 /* found a mono speaker with an amp,
3580 must be lfe */
3581 lfe_pin = pin;
3582 }
3583 }
3584 }
3585
3586 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003587 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003588 if (err < 0)
3589 return err;
3590 }
3591
3592 return 0;
3593}
3594
Mattc7d4b2f2005-06-27 14:59:41 +02003595static int stac9200_parse_auto_config(struct hda_codec *codec)
3596{
3597 struct sigmatel_spec *spec = codec->spec;
3598 int err;
3599
Kailang Yangdf694da2005-12-05 19:42:22 +01003600 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003601 return err;
3602
3603 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3604 return err;
3605
Takashi Iwai82bc9552006-03-21 11:24:42 +01003606 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3607 return err;
3608
Richard Fish160ea0d2006-09-06 13:58:25 +02003609 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3610 return err;
3611
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003612 if (spec->num_muxes > 0) {
3613 err = stac92xx_auto_create_mux_input_ctls(codec);
3614 if (err < 0)
3615 return err;
3616 }
3617
Takashi Iwai82bc9552006-03-21 11:24:42 +01003618 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003619 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003620 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003621 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003622
3623 if (spec->kctl_alloc)
3624 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3625
3626 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003627 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003628
3629 return 1;
3630}
3631
Sam Revitch62fe78e2006-05-10 15:09:17 +02003632/*
3633 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3634 * funky external mute control using GPIO pins.
3635 */
3636
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003637static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003638 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003639{
3640 unsigned int gpiostate, gpiomask, gpiodir;
3641
3642 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3643 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003644 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003645
3646 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3647 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003648 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003649
3650 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3651 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003652 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003653
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003654 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003655 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3656
3657 snd_hda_codec_write(codec, codec->afg, 0,
3658 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003659 snd_hda_codec_read(codec, codec->afg, 0,
3660 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003661
3662 msleep(1);
3663
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003664 snd_hda_codec_read(codec, codec->afg, 0,
3665 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003666}
3667
Takashi Iwai314634b2006-09-21 11:56:18 +02003668static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3669 unsigned int event)
3670{
3671 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003672 snd_hda_codec_write_cache(codec, nid, 0,
3673 AC_VERB_SET_UNSOLICITED_ENABLE,
3674 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003675}
3676
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003677static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3678{
3679 int i;
3680 for (i = 0; i < cfg->hp_outs; i++)
3681 if (cfg->hp_pins[i] == nid)
3682 return 1; /* nid is a HP-Out */
3683
3684 return 0; /* nid is not a HP-Out */
3685};
3686
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003687static void stac92xx_power_down(struct hda_codec *codec)
3688{
3689 struct sigmatel_spec *spec = codec->spec;
3690
3691 /* power down inactive DACs */
3692 hda_nid_t *dac;
3693 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003694 if (!is_in_dac_nids(spec, *dac) &&
3695 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003696 snd_hda_codec_write_cache(codec, *dac, 0,
3697 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3698}
3699
Takashi Iwaif73d3582008-11-25 08:21:51 +01003700static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3701 int enable);
3702
Mattc7d4b2f2005-06-27 14:59:41 +02003703static int stac92xx_init(struct hda_codec *codec)
3704{
3705 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003706 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003707 unsigned int gpio;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003708 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003709
Mattc7d4b2f2005-06-27 14:59:41 +02003710 snd_hda_sequence_write(codec, spec->init);
3711
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003712 /* power down adcs initially */
3713 if (spec->powerdown_adcs)
3714 for (i = 0; i < spec->num_adcs; i++)
3715 snd_hda_codec_write_cache(codec,
3716 spec->adc_nids[i], 0,
3717 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003718
3719 /* set up GPIO */
3720 gpio = spec->gpio_data;
3721 /* turn on EAPD statically when spec->eapd_switch isn't set.
3722 * otherwise, unsol event will turn it on/off dynamically
3723 */
3724 if (!spec->eapd_switch)
3725 gpio |= spec->eapd_mask;
3726 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3727
Takashi Iwai82bc9552006-03-21 11:24:42 +01003728 /* set up pins */
3729 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003730 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003731 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003732 enable_pin_detect(codec, cfg->hp_pins[i],
3733 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003734 /* force to enable the first line-out; the others are set up
3735 * in unsol_event
3736 */
3737 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3738 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003739 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003740 /* fake event to set up pins */
3741 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3742 } else {
3743 stac92xx_auto_init_multi_out(codec);
3744 stac92xx_auto_init_hp_out(codec);
3745 }
3746 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003747 hda_nid_t nid = cfg->input_pins[i];
3748 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003749 unsigned int pinctl;
3750 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3751 /* for mic pins, force to initialize */
3752 pinctl = stac92xx_get_vref(codec, nid);
3753 } else {
3754 pinctl = snd_hda_codec_read(codec, nid, 0,
3755 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3756 /* if PINCTL already set then skip */
3757 if (pinctl & AC_PINCTL_IN_EN)
3758 continue;
3759 }
3760 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003761 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3762 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003763 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003764 for (i = 0; i < spec->num_dmics; i++)
3765 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3766 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003767 if (cfg->dig_out_pin)
3768 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3769 AC_PINCTL_OUT_EN);
3770 if (cfg->dig_in_pin)
3771 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3772 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003773 for (i = 0; i < spec->num_pwrs; i++) {
3774 hda_nid_t nid = spec->pwr_nids[i];
3775 int pinctl, def_conf;
3776 int event = STAC_PWR_EVENT;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003777
Takashi Iwaif73d3582008-11-25 08:21:51 +01003778 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3779 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003780
Takashi Iwaif73d3582008-11-25 08:21:51 +01003781 pinctl = snd_hda_codec_read(codec, nid, 0,
3782 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3783 /* outputs are only ports capable of power management
3784 * any attempts on powering down a input port cause the
3785 * referenced VREF to act quirky.
3786 */
3787 if (pinctl & AC_PINCTL_IN_EN)
3788 continue;
3789 def_conf = snd_hda_codec_read(codec, nid, 0,
3790 AC_VERB_GET_CONFIG_DEFAULT, 0);
3791 def_conf = get_defcfg_connect(def_conf);
3792 /* skip any ports that don't have jacks since presence
3793 * detection is useless */
3794 if (def_conf != AC_JACK_PORT_COMPLEX) {
3795 if (def_conf != AC_JACK_PORT_NONE)
3796 stac_toggle_power_map(codec, nid, 1);
3797 continue;
3798 }
3799 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3800 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3801 }
3802 if (spec->dac_list)
3803 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02003804 return 0;
3805}
3806
Matt2f2f4252005-04-13 14:45:30 +02003807static void stac92xx_free(struct hda_codec *codec)
3808{
Mattc7d4b2f2005-06-27 14:59:41 +02003809 struct sigmatel_spec *spec = codec->spec;
3810 int i;
3811
3812 if (! spec)
3813 return;
3814
3815 if (spec->kctl_alloc) {
3816 for (i = 0; i < spec->num_kctl_used; i++)
3817 kfree(spec->kctl_alloc[i].name);
3818 kfree(spec->kctl_alloc);
3819 }
3820
Richard Fish11b44bb2006-08-23 18:31:34 +02003821 if (spec->bios_pin_configs)
3822 kfree(spec->bios_pin_configs);
3823
Mattc7d4b2f2005-06-27 14:59:41 +02003824 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003825 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003826}
3827
Matt4e550962005-07-04 17:51:39 +02003828static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3829 unsigned int flag)
3830{
3831 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3832 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003833
Takashi Iwaif9acba42007-05-29 18:01:06 +02003834 if (pin_ctl & AC_PINCTL_IN_EN) {
3835 /*
3836 * we need to check the current set-up direction of
3837 * shared input pins since they can be switched via
3838 * "xxx as Output" mixer switch
3839 */
3840 struct sigmatel_spec *spec = codec->spec;
3841 struct auto_pin_cfg *cfg = &spec->autocfg;
3842 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3843 spec->line_switch) ||
3844 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3845 spec->mic_switch))
3846 return;
3847 }
3848
Steve Longerbeam7b043892007-05-03 20:50:03 +02003849 /* if setting pin direction bits, clear the current
3850 direction bits first */
3851 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3852 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3853
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003854 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003855 AC_VERB_SET_PIN_WIDGET_CONTROL,
3856 pin_ctl | flag);
3857}
3858
3859static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3860 unsigned int flag)
3861{
3862 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3863 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003864 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003865 AC_VERB_SET_PIN_WIDGET_CONTROL,
3866 pin_ctl & ~flag);
3867}
3868
Jiang Zhe40c1d302007-11-12 13:05:16 +01003869static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003870{
3871 if (!nid)
3872 return 0;
3873 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003874 & (1 << 31)) {
3875 unsigned int pinctl;
3876 pinctl = snd_hda_codec_read(codec, nid, 0,
3877 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3878 if (pinctl & AC_PINCTL_IN_EN)
3879 return 0; /* mic- or line-input */
3880 else
3881 return 1; /* HP-output */
3882 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003883 return 0;
3884}
3885
Takashi Iwaid7a89432008-11-12 09:48:04 +01003886/* return non-zero if the hp-pin of the given array index isn't
3887 * a jack-detection target
3888 */
3889static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3890{
3891 struct auto_pin_cfg *cfg = &spec->autocfg;
3892
3893 /* ignore sensing of shared line and mic jacks */
3894 if (spec->line_switch &&
3895 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3896 return 1;
3897 if (spec->mic_switch &&
3898 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3899 return 1;
3900 /* ignore if the pin is set as line-out */
3901 if (cfg->hp_pins[i] == spec->hp_switch)
3902 return 1;
3903 return 0;
3904}
3905
Takashi Iwai314634b2006-09-21 11:56:18 +02003906static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003907{
3908 struct sigmatel_spec *spec = codec->spec;
3909 struct auto_pin_cfg *cfg = &spec->autocfg;
3910 int i, presence;
3911
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003912 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003913 if (spec->gpio_mute)
3914 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3915 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3916
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003917 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003918 if (presence)
3919 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003920 if (no_hp_sensing(spec, i))
3921 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003922 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003923 }
Matt4e550962005-07-04 17:51:39 +02003924
3925 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003926 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003927 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003928 stac92xx_reset_pinctl(codec, spec->hp_switch,
3929 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003930 for (i = 0; i < cfg->line_outs; i++)
3931 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3932 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003933 for (i = 0; i < cfg->speaker_outs; i++)
3934 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3935 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003936 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003937 stac_gpio_set(codec, spec->gpio_mask,
3938 spec->gpio_dir, spec->gpio_data &
3939 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003940 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003941 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003942 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003943 stac92xx_set_pinctl(codec, spec->hp_switch,
3944 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003945 for (i = 0; i < cfg->line_outs; i++)
3946 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3947 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003948 for (i = 0; i < cfg->speaker_outs; i++)
3949 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3950 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003951 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003952 stac_gpio_set(codec, spec->gpio_mask,
3953 spec->gpio_dir, spec->gpio_data |
3954 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003955 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01003956 /* toggle hp outs */
3957 for (i = 0; i < cfg->hp_outs; i++) {
3958 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3959 if (no_hp_sensing(spec, i))
3960 continue;
3961 if (presence)
3962 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3963 else
3964 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3965 }
Matt4e550962005-07-04 17:51:39 +02003966}
3967
Takashi Iwaif73d3582008-11-25 08:21:51 +01003968static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3969 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003970{
3971 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003972 unsigned int idx, val;
3973
3974 for (idx = 0; idx < spec->num_pwrs; idx++) {
3975 if (spec->pwr_nids[idx] == nid)
3976 break;
3977 }
3978 if (idx >= spec->num_pwrs)
3979 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003980
3981 /* several codecs have two power down bits */
3982 if (spec->pwr_mapping)
3983 idx = spec->pwr_mapping[idx];
3984 else
3985 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003986
Takashi Iwaif73d3582008-11-25 08:21:51 +01003987 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
3988 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003989 val &= ~idx;
3990 else
3991 val |= idx;
3992
3993 /* power down unused output ports */
3994 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003995}
3996
3997static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
3998{
3999 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4000}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004001
Takashi Iwai314634b2006-09-21 11:56:18 +02004002static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4003{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004004 struct sigmatel_spec *spec = codec->spec;
4005 int idx = res >> 26 & 0x0f;
4006
Matthew Ranostay72474be2008-10-09 09:32:17 -04004007 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004008 case STAC_HP_EVENT:
4009 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004010 /* fallthru */
4011 case STAC_PWR_EVENT:
4012 if (spec->num_pwrs > 0)
4013 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004014 break;
4015 case STAC_VREF_EVENT: {
4016 int data = snd_hda_codec_read(codec, codec->afg, 0,
4017 AC_VERB_GET_GPIO_DATA, 0);
4018 /* toggle VREF state based on GPIOx status */
4019 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4020 !!(data & (1 << idx)));
4021 break;
4022 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004023 }
4024}
4025
Takashi Iwaicb53c622007-08-10 17:21:45 +02004026#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004027static int stac92xx_resume(struct hda_codec *codec)
4028{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004029 struct sigmatel_spec *spec = codec->spec;
4030
Richard Fish11b44bb2006-08-23 18:31:34 +02004031 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004032 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004033 stac_gpio_set(codec, spec->gpio_mask,
4034 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004035 snd_hda_codec_resume_amp(codec);
4036 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004037 /* power down inactive DACs */
4038 if (spec->dac_list)
4039 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004040 /* invoke unsolicited event to reset the HP state */
4041 if (spec->hp_detect)
4042 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02004043 return 0;
4044}
4045#endif
4046
Matt2f2f4252005-04-13 14:45:30 +02004047static struct hda_codec_ops stac92xx_patch_ops = {
4048 .build_controls = stac92xx_build_controls,
4049 .build_pcms = stac92xx_build_pcms,
4050 .init = stac92xx_init,
4051 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004052 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004053#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004054 .resume = stac92xx_resume,
4055#endif
Matt2f2f4252005-04-13 14:45:30 +02004056};
4057
4058static int patch_stac9200(struct hda_codec *codec)
4059{
4060 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004061 int err;
Matt2f2f4252005-04-13 14:45:30 +02004062
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004063 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004064 if (spec == NULL)
4065 return -ENOMEM;
4066
4067 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004068 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004069 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004070 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4071 stac9200_models,
4072 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004073 if (spec->board_config < 0) {
4074 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4075 err = stac92xx_save_bios_config_regs(codec);
4076 if (err < 0) {
4077 stac92xx_free(codec);
4078 return err;
4079 }
4080 spec->pin_configs = spec->bios_pin_configs;
4081 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004082 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4083 stac92xx_set_config_regs(codec);
4084 }
Matt2f2f4252005-04-13 14:45:30 +02004085
4086 spec->multiout.max_channels = 2;
4087 spec->multiout.num_dacs = 1;
4088 spec->multiout.dac_nids = stac9200_dac_nids;
4089 spec->adc_nids = stac9200_adc_nids;
4090 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004091 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004092 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004093 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004094 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004095
Tobin Davisbf277782008-02-03 20:31:47 +01004096 if (spec->board_config == STAC_9200_GATEWAY ||
4097 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004098 spec->init = stac9200_eapd_init;
4099 else
4100 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004101 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004102
Takashi Iwai117f2572008-03-18 09:53:23 +01004103 if (spec->board_config == STAC_9200_PANASONIC) {
4104 spec->gpio_mask = spec->gpio_dir = 0x09;
4105 spec->gpio_data = 0x00;
4106 }
4107
Mattc7d4b2f2005-06-27 14:59:41 +02004108 err = stac9200_parse_auto_config(codec);
4109 if (err < 0) {
4110 stac92xx_free(codec);
4111 return err;
4112 }
Matt2f2f4252005-04-13 14:45:30 +02004113
4114 codec->patch_ops = stac92xx_patch_ops;
4115
4116 return 0;
4117}
4118
Tobin Davis8e21c342007-01-08 11:04:17 +01004119static int patch_stac925x(struct hda_codec *codec)
4120{
4121 struct sigmatel_spec *spec;
4122 int err;
4123
4124 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4125 if (spec == NULL)
4126 return -ENOMEM;
4127
4128 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004129 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004130 spec->pin_nids = stac925x_pin_nids;
4131 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4132 stac925x_models,
4133 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004134 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004135 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004136 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4137 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004138 err = stac92xx_save_bios_config_regs(codec);
4139 if (err < 0) {
4140 stac92xx_free(codec);
4141 return err;
4142 }
4143 spec->pin_configs = spec->bios_pin_configs;
4144 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4145 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4146 stac92xx_set_config_regs(codec);
4147 }
4148
4149 spec->multiout.max_channels = 2;
4150 spec->multiout.num_dacs = 1;
4151 spec->multiout.dac_nids = stac925x_dac_nids;
4152 spec->adc_nids = stac925x_adc_nids;
4153 spec->mux_nids = stac925x_mux_nids;
4154 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004155 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004156 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004157 switch (codec->vendor_id) {
4158 case 0x83847632: /* STAC9202 */
4159 case 0x83847633: /* STAC9202D */
4160 case 0x83847636: /* STAC9251 */
4161 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004162 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004163 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004164 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4165 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004166 break;
4167 default:
4168 spec->num_dmics = 0;
4169 break;
4170 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004171
4172 spec->init = stac925x_core_init;
4173 spec->mixer = stac925x_mixer;
4174
4175 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004176 if (!err) {
4177 if (spec->board_config < 0) {
4178 printk(KERN_WARNING "hda_codec: No auto-config is "
4179 "available, default to model=ref\n");
4180 spec->board_config = STAC_925x_REF;
4181 goto again;
4182 }
4183 err = -EINVAL;
4184 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004185 if (err < 0) {
4186 stac92xx_free(codec);
4187 return err;
4188 }
4189
4190 codec->patch_ops = stac92xx_patch_ops;
4191
4192 return 0;
4193}
4194
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004195static struct hda_input_mux stac92hd73xx_dmux = {
4196 .num_items = 4,
4197 .items = {
4198 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004199 { "Digital Mic 1", 0x09 },
4200 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004201 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004202 }
4203};
4204
4205static int patch_stac92hd73xx(struct hda_codec *codec)
4206{
4207 struct sigmatel_spec *spec;
4208 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4209 int err = 0;
4210
4211 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4212 if (spec == NULL)
4213 return -ENOMEM;
4214
4215 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004216 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004217 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4218 spec->pin_nids = stac92hd73xx_pin_nids;
4219 spec->board_config = snd_hda_check_board_config(codec,
4220 STAC_92HD73XX_MODELS,
4221 stac92hd73xx_models,
4222 stac92hd73xx_cfg_tbl);
4223again:
4224 if (spec->board_config < 0) {
4225 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4226 " STAC92HD73XX, using BIOS defaults\n");
4227 err = stac92xx_save_bios_config_regs(codec);
4228 if (err < 0) {
4229 stac92xx_free(codec);
4230 return err;
4231 }
4232 spec->pin_configs = spec->bios_pin_configs;
4233 } else {
4234 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4235 stac92xx_set_config_regs(codec);
4236 }
4237
4238 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4239 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4240
4241 if (spec->multiout.num_dacs < 0) {
4242 printk(KERN_WARNING "hda_codec: Could not determine "
4243 "number of channels defaulting to DAC count\n");
4244 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4245 }
4246
4247 switch (spec->multiout.num_dacs) {
4248 case 0x3: /* 6 Channel */
4249 spec->mixer = stac92hd73xx_6ch_mixer;
4250 spec->init = stac92hd73xx_6ch_core_init;
4251 break;
4252 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004253 spec->mixer = stac92hd73xx_8ch_mixer;
4254 spec->init = stac92hd73xx_8ch_core_init;
4255 break;
4256 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004257 spec->mixer = stac92hd73xx_10ch_mixer;
4258 spec->init = stac92hd73xx_10ch_core_init;
4259 };
4260
4261 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4262 spec->aloopback_mask = 0x01;
4263 spec->aloopback_shift = 8;
4264
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004265 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004266 spec->mux_nids = stac92hd73xx_mux_nids;
4267 spec->adc_nids = stac92hd73xx_adc_nids;
4268 spec->dmic_nids = stac92hd73xx_dmic_nids;
4269 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004270 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004271 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004272 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004273
4274 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4275 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004276 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004277 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4278 sizeof(stac92hd73xx_dmux));
4279
Matthew Ranostaya7662642008-02-21 07:51:14 +01004280 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004281 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004282 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004283 /* fallthru */
4284 case STAC_DELL_M6:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004285 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004286 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4287 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004288 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004289 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004290
4291 if (!spec->init)
4292 spec->init = dell_m6_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004293 switch (codec->subsystem_id) {
4294 case 0x1028025e: /* Analog Mics */
4295 case 0x1028025f:
4296 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4297 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004298 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004299 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004300 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004301 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004302 case 0x10280254:
4303 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004304 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4305 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004306 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004307 break;
4308 case 0x10280256: /* Both */
4309 case 0x10280057:
4310 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4311 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4312 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004313 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004314 break;
4315 }
4316 break;
4317 default:
4318 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004319 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004320 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004321 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004322 if (spec->board_config > STAC_92HD73XX_REF) {
4323 /* GPIO0 High = Enable EAPD */
4324 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4325 spec->gpio_data = 0x01;
4326 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004327 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004328
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004329 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4330 spec->pwr_nids = stac92hd73xx_pwr_nids;
4331
Matthew Ranostayd9737752008-09-07 12:03:41 +02004332 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004333
4334 if (!err) {
4335 if (spec->board_config < 0) {
4336 printk(KERN_WARNING "hda_codec: No auto-config is "
4337 "available, default to model=ref\n");
4338 spec->board_config = STAC_92HD73XX_REF;
4339 goto again;
4340 }
4341 err = -EINVAL;
4342 }
4343
4344 if (err < 0) {
4345 stac92xx_free(codec);
4346 return err;
4347 }
4348
4349 codec->patch_ops = stac92xx_patch_ops;
4350
4351 return 0;
4352}
4353
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004354static struct hda_input_mux stac92hd83xxx_dmux = {
4355 .num_items = 3,
4356 .items = {
4357 { "Analog Inputs", 0x03 },
4358 { "Digital Mic 1", 0x04 },
4359 { "Digital Mic 2", 0x05 },
4360 }
4361};
4362
4363static int patch_stac92hd83xxx(struct hda_codec *codec)
4364{
4365 struct sigmatel_spec *spec;
4366 int err;
4367
4368 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4369 if (spec == NULL)
4370 return -ENOMEM;
4371
4372 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004373 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004374 spec->mono_nid = 0x19;
4375 spec->digbeep_nid = 0x21;
4376 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4377 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4378 spec->adc_nids = stac92hd83xxx_adc_nids;
4379 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4380 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4381 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4382 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4383
4384 spec->init = stac92hd83xxx_core_init;
4385 switch (codec->vendor_id) {
4386 case 0x111d7605:
4387 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4388 break;
4389 default:
4390 spec->num_pwrs--;
4391 spec->init++; /* switch to config #2 */
4392 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4393 }
4394
4395 spec->mixer = stac92hd83xxx_mixer;
4396 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4397 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4398 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4399 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4400 spec->dinput_mux = &stac92hd83xxx_dmux;
4401 spec->pin_nids = stac92hd83xxx_pin_nids;
4402 spec->board_config = snd_hda_check_board_config(codec,
4403 STAC_92HD83XXX_MODELS,
4404 stac92hd83xxx_models,
4405 stac92hd83xxx_cfg_tbl);
4406again:
4407 if (spec->board_config < 0) {
4408 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4409 " STAC92HD83XXX, using BIOS defaults\n");
4410 err = stac92xx_save_bios_config_regs(codec);
4411 if (err < 0) {
4412 stac92xx_free(codec);
4413 return err;
4414 }
4415 spec->pin_configs = spec->bios_pin_configs;
4416 } else {
4417 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4418 stac92xx_set_config_regs(codec);
4419 }
4420
4421 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4422 if (!err) {
4423 if (spec->board_config < 0) {
4424 printk(KERN_WARNING "hda_codec: No auto-config is "
4425 "available, default to model=ref\n");
4426 spec->board_config = STAC_92HD83XXX_REF;
4427 goto again;
4428 }
4429 err = -EINVAL;
4430 }
4431
4432 if (err < 0) {
4433 stac92xx_free(codec);
4434 return err;
4435 }
4436
4437 codec->patch_ops = stac92xx_patch_ops;
4438
4439 return 0;
4440}
4441
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004442#ifdef SND_HDA_NEEDS_RESUME
4443static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4444{
4445 struct sigmatel_spec *spec = codec->spec;
4446 int i;
4447 snd_hda_codec_write_cache(codec, codec->afg, 0,
4448 AC_VERB_SET_POWER_STATE, pwr);
4449
4450 msleep(1);
4451 for (i = 0; i < spec->num_adcs; i++) {
4452 snd_hda_codec_write_cache(codec,
4453 spec->adc_nids[i], 0,
4454 AC_VERB_SET_POWER_STATE, pwr);
4455 }
4456};
4457
4458static int stac92hd71xx_resume(struct hda_codec *codec)
4459{
4460 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4461 return stac92xx_resume(codec);
4462}
4463
4464static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4465{
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004466 struct sigmatel_spec *spec = codec->spec;
4467
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004468 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004469 if (spec->eapd_mask)
4470 stac_gpio_set(codec, spec->gpio_mask,
4471 spec->gpio_dir, spec->gpio_data &
4472 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004473 return 0;
4474};
4475
4476#endif
4477
4478static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4479 .build_controls = stac92xx_build_controls,
4480 .build_pcms = stac92xx_build_pcms,
4481 .init = stac92xx_init,
4482 .free = stac92xx_free,
4483 .unsol_event = stac92xx_unsol_event,
4484#ifdef SND_HDA_NEEDS_RESUME
4485 .resume = stac92hd71xx_resume,
4486 .suspend = stac92hd71xx_suspend,
4487#endif
4488};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004489
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004490static struct hda_input_mux stac92hd71bxx_dmux = {
4491 .num_items = 4,
4492 .items = {
4493 { "Analog Inputs", 0x00 },
4494 { "Mixer", 0x01 },
4495 { "Digital Mic 1", 0x02 },
4496 { "Digital Mic 2", 0x03 },
4497 }
4498};
4499
Matthew Ranostaye035b842007-11-06 11:53:55 +01004500static int patch_stac92hd71bxx(struct hda_codec *codec)
4501{
4502 struct sigmatel_spec *spec;
4503 int err = 0;
4504
4505 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4506 if (spec == NULL)
4507 return -ENOMEM;
4508
4509 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004510 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004511 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004512 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004513 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004514 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4515 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004516 spec->board_config = snd_hda_check_board_config(codec,
4517 STAC_92HD71BXX_MODELS,
4518 stac92hd71bxx_models,
4519 stac92hd71bxx_cfg_tbl);
4520again:
4521 if (spec->board_config < 0) {
4522 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4523 " STAC92HD71BXX, using BIOS defaults\n");
4524 err = stac92xx_save_bios_config_regs(codec);
4525 if (err < 0) {
4526 stac92xx_free(codec);
4527 return err;
4528 }
4529 spec->pin_configs = spec->bios_pin_configs;
4530 } else {
4531 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4532 stac92xx_set_config_regs(codec);
4533 }
4534
Takashi Iwai41c3b642008-11-18 10:45:15 +01004535 if (spec->board_config > STAC_92HD71BXX_REF) {
4536 /* GPIO0 = EAPD */
4537 spec->gpio_mask = 0x01;
4538 spec->gpio_dir = 0x01;
4539 spec->gpio_data = 0x01;
4540 }
4541
Matthew Ranostay541eee82007-12-14 12:08:04 +01004542 switch (codec->vendor_id) {
4543 case 0x111d76b6: /* 4 Port without Analog Mixer */
4544 case 0x111d76b7:
4545 case 0x111d76b4: /* 6 Port without Analog Mixer */
4546 case 0x111d76b5:
4547 spec->mixer = stac92hd71bxx_mixer;
4548 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004549 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004550 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004551 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004552 switch (spec->board_config) {
4553 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004554 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004555 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004556 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4557 snd_hda_codec_write_cache(codec, codec->afg, 0,
4558 AC_VERB_SET_UNSOLICITED_ENABLE,
4559 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4560 spec->gpio_mask |= 0x02;
4561 break;
4562 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004563 if ((codec->revision_id & 0xf) == 0 ||
4564 (codec->revision_id & 0xf) == 1) {
4565#ifdef SND_HDA_NEEDS_RESUME
4566 codec->patch_ops = stac92hd71bxx_patch_ops;
4567#endif
4568 spec->stream_delay = 40; /* 40 milliseconds */
4569 }
4570
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004571 /* no output amps */
4572 spec->num_pwrs = 0;
4573 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004574 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004575
4576 /* disable VSW */
4577 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4578 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4579 break;
4580 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004581 if ((codec->revision_id & 0xf) == 1) {
4582#ifdef SND_HDA_NEEDS_RESUME
4583 codec->patch_ops = stac92hd71bxx_patch_ops;
4584#endif
4585 spec->stream_delay = 40; /* 40 milliseconds */
4586 }
4587
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004588 /* no output amps */
4589 spec->num_pwrs = 0;
4590 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004591 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004592 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004593 spec->mixer = stac92hd71bxx_analog_mixer;
4594 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004595 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004596 }
4597
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004598 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004599 spec->aloopback_shift = 0;
4600
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004601 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004602 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004603 spec->mux_nids = stac92hd71bxx_mux_nids;
4604 spec->adc_nids = stac92hd71bxx_adc_nids;
4605 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004606 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004607 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004608 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004609
4610 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4611 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004612
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004613 switch (spec->board_config) {
4614 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004615 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004616 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4617 stac92xx_auto_set_pinctl(codec, 0x0e,
4618 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004619 /* fallthru */
4620 case STAC_DELL_M4_2:
4621 spec->num_dmics = 0;
4622 spec->num_smuxes = 0;
4623 spec->num_dmuxes = 0;
4624 break;
4625 case STAC_DELL_M4_1:
4626 case STAC_DELL_M4_3:
4627 spec->num_dmics = 1;
4628 spec->num_smuxes = 0;
4629 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004630 break;
4631 default:
4632 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4633 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4634 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4635 };
4636
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004637 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004638 spec->multiout.hp_nid = 0x11;
4639 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004640 if (spec->dinput_mux)
4641 spec->private_dimux.num_items +=
4642 spec->num_dmics -
4643 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004644
4645 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4646 if (!err) {
4647 if (spec->board_config < 0) {
4648 printk(KERN_WARNING "hda_codec: No auto-config is "
4649 "available, default to model=ref\n");
4650 spec->board_config = STAC_92HD71BXX_REF;
4651 goto again;
4652 }
4653 err = -EINVAL;
4654 }
4655
4656 if (err < 0) {
4657 stac92xx_free(codec);
4658 return err;
4659 }
4660
Matthew Ranostaye035b842007-11-06 11:53:55 +01004661 return 0;
4662};
4663
Matt2f2f4252005-04-13 14:45:30 +02004664static int patch_stac922x(struct hda_codec *codec)
4665{
4666 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004667 int err;
Matt2f2f4252005-04-13 14:45:30 +02004668
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004669 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004670 if (spec == NULL)
4671 return -ENOMEM;
4672
4673 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004674 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004675 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004676 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4677 stac922x_models,
4678 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004679 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004680 spec->gpio_mask = spec->gpio_dir = 0x03;
4681 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004682 /* Intel Macs have all same PCI SSID, so we need to check
4683 * codec SSID to distinguish the exact models
4684 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004685 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004686 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004687
4688 case 0x106b0800:
4689 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004690 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004691 case 0x106b0600:
4692 case 0x106b0700:
4693 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004694 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004695 case 0x106b0e00:
4696 case 0x106b0f00:
4697 case 0x106b1600:
4698 case 0x106b1700:
4699 case 0x106b0200:
4700 case 0x106b1e00:
4701 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004702 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004703 case 0x106b1a00:
4704 case 0x00000100:
4705 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004706 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004707 case 0x106b0a00:
4708 case 0x106b2200:
4709 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004710 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004711 default:
4712 spec->board_config = STAC_INTEL_MAC_V3;
4713 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004714 }
4715 }
4716
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004717 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004718 if (spec->board_config < 0) {
4719 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4720 "using BIOS defaults\n");
4721 err = stac92xx_save_bios_config_regs(codec);
4722 if (err < 0) {
4723 stac92xx_free(codec);
4724 return err;
4725 }
4726 spec->pin_configs = spec->bios_pin_configs;
4727 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004728 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4729 stac92xx_set_config_regs(codec);
4730 }
Matt2f2f4252005-04-13 14:45:30 +02004731
Matt2f2f4252005-04-13 14:45:30 +02004732 spec->adc_nids = stac922x_adc_nids;
4733 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004734 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004735 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004736 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004737 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004738
4739 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004740 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004741
4742 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004743
Matt Porter3cc08dc2006-01-23 15:27:49 +01004744 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004745 if (!err) {
4746 if (spec->board_config < 0) {
4747 printk(KERN_WARNING "hda_codec: No auto-config is "
4748 "available, default to model=ref\n");
4749 spec->board_config = STAC_D945_REF;
4750 goto again;
4751 }
4752 err = -EINVAL;
4753 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004754 if (err < 0) {
4755 stac92xx_free(codec);
4756 return err;
4757 }
4758
4759 codec->patch_ops = stac92xx_patch_ops;
4760
Takashi Iwai807a46362007-05-29 19:01:37 +02004761 /* Fix Mux capture level; max to 2 */
4762 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4763 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4764 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4765 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4766 (0 << AC_AMPCAP_MUTE_SHIFT));
4767
Matt Porter3cc08dc2006-01-23 15:27:49 +01004768 return 0;
4769}
4770
4771static int patch_stac927x(struct hda_codec *codec)
4772{
4773 struct sigmatel_spec *spec;
4774 int err;
4775
4776 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4777 if (spec == NULL)
4778 return -ENOMEM;
4779
4780 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004781 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004782 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004783 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4784 stac927x_models,
4785 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004786 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004787 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4788 if (spec->board_config < 0)
4789 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4790 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004791 err = stac92xx_save_bios_config_regs(codec);
4792 if (err < 0) {
4793 stac92xx_free(codec);
4794 return err;
4795 }
4796 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004797 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004798 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4799 stac92xx_set_config_regs(codec);
4800 }
4801
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004802 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004803 spec->adc_nids = stac927x_adc_nids;
4804 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4805 spec->mux_nids = stac927x_mux_nids;
4806 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004807 spec->smux_nids = stac927x_smux_nids;
4808 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004809 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004810 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004811 spec->multiout.dac_nids = spec->dac_nids;
4812
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004813 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004814 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004815 case STAC_D965_5ST:
4816 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004817 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004818 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004819 spec->num_dmics = 0;
4820
Tobin Davis93ed1502006-09-01 21:03:12 +02004821 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004822 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004823 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004824 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004825 switch (codec->subsystem_id) {
4826 case 0x10280209:
4827 case 0x1028022e:
4828 /* correct the device field to SPDIF out */
4829 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4830 break;
4831 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004832 /* configure the analog microphone on some laptops */
4833 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004834 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004835 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004836 /* correct the front input jack as a mic */
4837 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4838 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004839 case STAC_DELL_3ST:
4840 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004841 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004842 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004843 spec->dmic_nids = stac927x_dmic_nids;
4844 spec->num_dmics = STAC927X_NUM_DMICS;
4845
Tobin Davis93ed1502006-09-01 21:03:12 +02004846 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004847 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004848 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004849 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004850 break;
4851 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004852 if (spec->board_config > STAC_D965_REF) {
4853 /* GPIO0 High = Enable EAPD */
4854 spec->eapd_mask = spec->gpio_mask = 0x01;
4855 spec->gpio_dir = spec->gpio_data = 0x01;
4856 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004857 spec->num_dmics = 0;
4858
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004859 spec->init = stac927x_core_init;
4860 spec->mixer = stac927x_mixer;
4861 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004862
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004863 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004864 spec->aloopback_mask = 0x40;
4865 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004866 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004867
Matt Porter3cc08dc2006-01-23 15:27:49 +01004868 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004869 if (!err) {
4870 if (spec->board_config < 0) {
4871 printk(KERN_WARNING "hda_codec: No auto-config is "
4872 "available, default to model=ref\n");
4873 spec->board_config = STAC_D965_REF;
4874 goto again;
4875 }
4876 err = -EINVAL;
4877 }
Mattc7d4b2f2005-06-27 14:59:41 +02004878 if (err < 0) {
4879 stac92xx_free(codec);
4880 return err;
4881 }
Matt2f2f4252005-04-13 14:45:30 +02004882
4883 codec->patch_ops = stac92xx_patch_ops;
4884
Takashi Iwai52987652008-01-16 16:09:47 +01004885 /*
4886 * !!FIXME!!
4887 * The STAC927x seem to require fairly long delays for certain
4888 * command sequences. With too short delays (even if the answer
4889 * is set to RIRB properly), it results in the silence output
4890 * on some hardwares like Dell.
4891 *
4892 * The below flag enables the longer delay (see get_response
4893 * in hda_intel.c).
4894 */
4895 codec->bus->needs_damn_long_delay = 1;
4896
Matt2f2f4252005-04-13 14:45:30 +02004897 return 0;
4898}
4899
Matt Porterf3302a52006-07-31 12:49:34 +02004900static int patch_stac9205(struct hda_codec *codec)
4901{
4902 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004903 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004904
4905 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4906 if (spec == NULL)
4907 return -ENOMEM;
4908
4909 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004910 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004911 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004912 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4913 stac9205_models,
4914 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004915 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004916 if (spec->board_config < 0) {
4917 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4918 err = stac92xx_save_bios_config_regs(codec);
4919 if (err < 0) {
4920 stac92xx_free(codec);
4921 return err;
4922 }
4923 spec->pin_configs = spec->bios_pin_configs;
4924 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004925 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4926 stac92xx_set_config_regs(codec);
4927 }
4928
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004929 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004930 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004931 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004932 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004933 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004934 spec->smux_nids = stac9205_smux_nids;
4935 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004936 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004937 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004938 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004939 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004940 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004941
4942 spec->init = stac9205_core_init;
4943 spec->mixer = stac9205_mixer;
4944
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004945 spec->aloopback_mask = 0x40;
4946 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004947 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02004948 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004949
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004950 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004951 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004952 /* Enable SPDIF in/out */
4953 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4954 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004955
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004956 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004957 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004958 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4959 snd_hda_codec_write_cache(codec, codec->afg, 0,
4960 AC_VERB_SET_UNSOLICITED_ENABLE,
4961 (AC_USRSP_EN | STAC_HP_EVENT));
4962
4963 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004964 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004965 spec->gpio_mask = 0x1b;
4966 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004967 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004968 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004969 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004970 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004971 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004972 case STAC_9205_REF:
4973 /* SPDIF-In enabled */
4974 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004975 default:
4976 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004977 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004978 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004979 break;
4980 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004981
Matt Porterf3302a52006-07-31 12:49:34 +02004982 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004983 if (!err) {
4984 if (spec->board_config < 0) {
4985 printk(KERN_WARNING "hda_codec: No auto-config is "
4986 "available, default to model=ref\n");
4987 spec->board_config = STAC_9205_REF;
4988 goto again;
4989 }
4990 err = -EINVAL;
4991 }
Matt Porterf3302a52006-07-31 12:49:34 +02004992 if (err < 0) {
4993 stac92xx_free(codec);
4994 return err;
4995 }
4996
4997 codec->patch_ops = stac92xx_patch_ops;
4998
4999 return 0;
5000}
5001
Matt2f2f4252005-04-13 14:45:30 +02005002/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005003 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005004 */
5005
Guillaume Munch99ccc562006-08-16 19:35:12 +02005006/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005007static hda_nid_t vaio_dacs[] = { 0x2 };
5008#define VAIO_HP_DAC 0x5
5009static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5010static hda_nid_t vaio_mux_nids[] = { 0x15 };
5011
5012static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005013 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005014 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005015 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005016 { "Mic Jack", 0x1 },
5017 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005018 { "PCM", 0x3 },
5019 }
5020};
5021
5022static struct hda_verb vaio_init[] = {
5023 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005024 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005025 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5026 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5027 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005030 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5031 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5035 {}
5036};
5037
Guillaume Munch6d859062006-08-22 17:15:47 +02005038static struct hda_verb vaio_ar_init[] = {
5039 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5040 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5041 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5042 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5043/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5044 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005046 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5047 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5048/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5049 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5052 {}
5053};
5054
Takashi Iwaidb064e52006-03-16 16:04:58 +01005055/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005056static struct hda_bind_ctls vaio_bind_master_vol = {
5057 .ops = &snd_hda_bind_vol,
5058 .values = {
5059 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5060 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5061 0
5062 },
5063};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005064
5065/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005066static struct hda_bind_ctls vaio_bind_master_sw = {
5067 .ops = &snd_hda_bind_sw,
5068 .values = {
5069 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5070 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5071 0,
5072 },
5073};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005074
5075static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005076 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5077 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005078 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5079 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5080 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5081 {
5082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5083 .name = "Capture Source",
5084 .count = 1,
5085 .info = stac92xx_mux_enum_info,
5086 .get = stac92xx_mux_enum_get,
5087 .put = stac92xx_mux_enum_put,
5088 },
5089 {}
5090};
5091
Guillaume Munch6d859062006-08-22 17:15:47 +02005092static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005093 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5094 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02005095 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5096 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5097 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5098 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5099 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5100 {
5101 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5102 .name = "Capture Source",
5103 .count = 1,
5104 .info = stac92xx_mux_enum_info,
5105 .get = stac92xx_mux_enum_get,
5106 .put = stac92xx_mux_enum_put,
5107 },
5108 {}
5109};
5110
5111static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005112 .build_controls = stac92xx_build_controls,
5113 .build_pcms = stac92xx_build_pcms,
5114 .init = stac92xx_init,
5115 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005116#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005117 .resume = stac92xx_resume,
5118#endif
5119};
5120
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005121static int stac9872_vaio_init(struct hda_codec *codec)
5122{
5123 int err;
5124
5125 err = stac92xx_init(codec);
5126 if (err < 0)
5127 return err;
5128 if (codec->patch_ops.unsol_event)
5129 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5130 return 0;
5131}
5132
5133static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5134{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005135 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005136 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5137 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5138 } else {
5139 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5140 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5141 }
5142}
5143
5144static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5145{
5146 switch (res >> 26) {
5147 case STAC_HP_EVENT:
5148 stac9872_vaio_hp_detect(codec, res);
5149 break;
5150 }
5151}
5152
5153static struct hda_codec_ops stac9872_vaio_patch_ops = {
5154 .build_controls = stac92xx_build_controls,
5155 .build_pcms = stac92xx_build_pcms,
5156 .init = stac9872_vaio_init,
5157 .free = stac92xx_free,
5158 .unsol_event = stac9872_vaio_unsol_event,
5159#ifdef CONFIG_PM
5160 .resume = stac92xx_resume,
5161#endif
5162};
5163
Guillaume Munch6d859062006-08-22 17:15:47 +02005164enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5165 CXD9872RD_VAIO,
5166 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5167 STAC9872AK_VAIO,
5168 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5169 STAC9872K_VAIO,
5170 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005171 CXD9872AKD_VAIO,
5172 STAC_9872_MODELS,
5173};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005174
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005175static const char *stac9872_models[STAC_9872_MODELS] = {
5176 [CXD9872RD_VAIO] = "vaio",
5177 [CXD9872AKD_VAIO] = "vaio-ar",
5178};
5179
5180static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5181 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5182 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5183 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005184 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005185 {}
5186};
5187
Guillaume Munch6d859062006-08-22 17:15:47 +02005188static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005189{
5190 struct sigmatel_spec *spec;
5191 int board_config;
5192
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005193 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5194 stac9872_models,
5195 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005196 if (board_config < 0)
5197 /* unknown config, let generic-parser do its job... */
5198 return snd_hda_parse_generic_codec(codec);
5199
5200 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5201 if (spec == NULL)
5202 return -ENOMEM;
5203
5204 codec->spec = spec;
5205 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005206 case CXD9872RD_VAIO:
5207 case STAC9872AK_VAIO:
5208 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005209 spec->mixer = vaio_mixer;
5210 spec->init = vaio_init;
5211 spec->multiout.max_channels = 2;
5212 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5213 spec->multiout.dac_nids = vaio_dacs;
5214 spec->multiout.hp_nid = VAIO_HP_DAC;
5215 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5216 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005217 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005218 spec->input_mux = &vaio_mux;
5219 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005220 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005221 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005222
5223 case CXD9872AKD_VAIO:
5224 spec->mixer = vaio_ar_mixer;
5225 spec->init = vaio_ar_init;
5226 spec->multiout.max_channels = 2;
5227 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5228 spec->multiout.dac_nids = vaio_dacs;
5229 spec->multiout.hp_nid = VAIO_HP_DAC;
5230 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005231 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005232 spec->adc_nids = vaio_adcs;
5233 spec->input_mux = &vaio_mux;
5234 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005235 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005236 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005237 }
5238
Takashi Iwaidb064e52006-03-16 16:04:58 +01005239 return 0;
5240}
5241
5242
5243/*
Matt2f2f4252005-04-13 14:45:30 +02005244 * patch entries
5245 */
5246struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5247 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5248 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5249 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5250 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5251 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5252 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5253 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005254 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5255 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5256 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5257 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5258 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5259 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005260 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5261 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5262 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5263 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5264 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5265 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5266 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5267 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5268 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5269 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005270 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5271 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5272 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5273 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5274 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5275 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005276 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5277 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005278 /* The following does not take into account .id=0x83847661 when subsys =
5279 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5280 * currently not fully supported.
5281 */
5282 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5283 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5284 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005285 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5286 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5287 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5288 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5289 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5290 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5291 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5292 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005293 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005294 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5295 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005296 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005297 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5298 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005299 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005300 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5301 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5302 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5303 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5304 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5305 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5306 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5307 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005308 {} /* terminator */
5309};