blob: df9b0bc7f8785a82b6ca6ee0649b7c26ddc0659a [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 Ranostaya64135a2008-01-10 16:55:06 +010039#define STAC_PWR_EVENT 0x20
40#define STAC_HP_EVENT 0x30
Matthew Ranostay72474be2008-10-09 09:32:17 -040041#define STAC_VREF_EVENT 0x40
Matt4e550962005-07-04 17:51:39 +020042
Takashi Iwaif5fcc132006-11-24 17:07:44 +010043enum {
44 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010045 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020046 STAC_9200_DELL_D21,
47 STAC_9200_DELL_D22,
48 STAC_9200_DELL_D23,
49 STAC_9200_DELL_M21,
50 STAC_9200_DELL_M22,
51 STAC_9200_DELL_M23,
52 STAC_9200_DELL_M24,
53 STAC_9200_DELL_M25,
54 STAC_9200_DELL_M26,
55 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020056 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010057 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010058 STAC_9200_MODELS
59};
60
61enum {
62 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020063 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020064 STAC_9205_DELL_M43,
65 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010066 STAC_9205_MODELS
67};
68
69enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010070 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010071 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010072 STAC_92HD73XX_MODELS
73};
74
75enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020076 STAC_92HD83XXX_REF,
77 STAC_92HD83XXX_MODELS
78};
79
80enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010081 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010082 STAC_DELL_M4_1,
83 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040084 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010085 STAC_92HD71BXX_MODELS
86};
87
88enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010089 STAC_925x_REF,
90 STAC_M2_2,
91 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020092 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010093 STAC_925x_MODELS
94};
95
96enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010097 STAC_D945_REF,
98 STAC_D945GTP3,
99 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200100 STAC_INTEL_MAC_V1,
101 STAC_INTEL_MAC_V2,
102 STAC_INTEL_MAC_V3,
103 STAC_INTEL_MAC_V4,
104 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800105 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
106 * is given, one of the above models will be
107 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200108 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100109 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100110 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100111 STAC_MACBOOK_PRO_V1,
112 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200113 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200114 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300115 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200116 STAC_922X_DELL_D81,
117 STAC_922X_DELL_D82,
118 STAC_922X_DELL_M81,
119 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100120 STAC_922X_MODELS
121};
122
123enum {
124 STAC_D965_REF,
125 STAC_D965_3ST,
126 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200127 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100128 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100129 STAC_927X_MODELS
130};
Matt Porter403d1942005-11-29 15:00:51 +0100131
Matt2f2f4252005-04-13 14:45:30 +0200132struct sigmatel_spec {
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100133 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200134 unsigned int num_mixers;
135
Matt Porter403d1942005-11-29 15:00:51 +0100136 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200137 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100138 unsigned int line_switch: 1;
139 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100140 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100141 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400142 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200143
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100144 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200145 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100146 unsigned int gpio_mask;
147 unsigned int gpio_dir;
148 unsigned int gpio_data;
149 unsigned int gpio_mute;
150
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200151 /* stream */
152 unsigned int stream_delay;
153
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100154 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100155 unsigned char aloopback_mask;
156 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200157
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100158 /* power management */
159 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200160 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100161 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100162 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100163
Matt2f2f4252005-04-13 14:45:30 +0200164 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100165 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400166 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100167 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200168 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100169 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200170
171 /* capture */
172 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200173 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200174 hda_nid_t *mux_nids;
175 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200176 hda_nid_t *dmic_nids;
177 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100178 hda_nid_t *dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +0100179 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200180 hda_nid_t *smux_nids;
181 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400182 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200183
Mattdabbed62005-06-14 10:19:34 +0200184 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100185 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200186 hda_nid_t anabeep_nid;
187 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200188
Matt2f2f4252005-04-13 14:45:30 +0200189 /* pin widgets */
190 hda_nid_t *pin_nids;
191 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200192 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200193 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200194
195 /* codec specific stuff */
196 struct hda_verb *init;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100197 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200198
199 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200200 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100201 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200202 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100203 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200204 struct hda_input_mux *sinput_mux;
205 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400206 unsigned int cur_amux;
207 hda_nid_t *amp_nids;
208 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200209 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200210
Matt Porter403d1942005-11-29 15:00:51 +0100211 /* i/o switches */
212 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200213 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200214 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200215 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200216
Mattc7d4b2f2005-06-27 14:59:41 +0200217 struct hda_pcm pcm_rec[2]; /* PCM information */
218
219 /* dynamic controls and input_mux */
220 struct auto_pin_cfg autocfg;
221 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100222 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200223 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200224 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200225 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400226 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100227 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200228};
229
230static hda_nid_t stac9200_adc_nids[1] = {
231 0x03,
232};
233
234static hda_nid_t stac9200_mux_nids[1] = {
235 0x0c,
236};
237
238static hda_nid_t stac9200_dac_nids[1] = {
239 0x02,
240};
241
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100242static hda_nid_t stac92hd73xx_pwr_nids[8] = {
243 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
244 0x0f, 0x10, 0x11
245};
246
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400247static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
248 0x26, 0,
249};
250
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100251static hda_nid_t stac92hd73xx_adc_nids[2] = {
252 0x1a, 0x1b
253};
254
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400255#define DELL_M6_AMP 2
256static hda_nid_t stac92hd73xx_amp_nids[3] = {
257 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400258};
259
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100260#define STAC92HD73XX_NUM_DMICS 2
261static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
262 0x13, 0x14, 0
263};
264
265#define STAC92HD73_DAC_COUNT 5
266static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
267 0x15, 0x16, 0x17, 0x18, 0x19,
268};
269
270static hda_nid_t stac92hd73xx_mux_nids[4] = {
271 0x28, 0x29, 0x2a, 0x2b,
272};
273
274static hda_nid_t stac92hd73xx_dmux_nids[2] = {
275 0x20, 0x21,
276};
277
Matthew Ranostayd9737752008-09-07 12:03:41 +0200278static hda_nid_t stac92hd73xx_smux_nids[2] = {
279 0x22, 0x23,
280};
281
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200282#define STAC92HD83XXX_NUM_DMICS 2
283static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
284 0x11, 0x12, 0
285};
286
287#define STAC92HD81_DAC_COUNT 2
288#define STAC92HD83_DAC_COUNT 3
289static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
290 0x13, 0x14, 0x22,
291};
292
293static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
294 0x17, 0x18,
295};
296
297static hda_nid_t stac92hd83xxx_adc_nids[2] = {
298 0x15, 0x16,
299};
300
301static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
302 0xa, 0xb, 0xd, 0xe,
303};
304
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400305static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
306 0x1e, 0,
307};
308
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200309static unsigned int stac92hd83xxx_pwr_mapping[4] = {
310 0x03, 0x0c, 0x10, 0x40,
311};
312
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100313static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
314 0x0a, 0x0d, 0x0f
315};
316
Matthew Ranostaye035b842007-11-06 11:53:55 +0100317static hda_nid_t stac92hd71bxx_adc_nids[2] = {
318 0x12, 0x13,
319};
320
321static hda_nid_t stac92hd71bxx_mux_nids[2] = {
322 0x1a, 0x1b
323};
324
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400325static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
326 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100327};
328
Matthew Ranostayd9737752008-09-07 12:03:41 +0200329static hda_nid_t stac92hd71bxx_smux_nids[2] = {
330 0x24, 0x25,
331};
332
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100333static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100334 0x10, /*0x11, */
335};
336
337#define STAC92HD71BXX_NUM_DMICS 2
338static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
339 0x18, 0x19, 0
340};
341
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400342static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
343 0x22, 0
344};
345
Tobin Davis8e21c342007-01-08 11:04:17 +0100346static hda_nid_t stac925x_adc_nids[1] = {
347 0x03,
348};
349
350static hda_nid_t stac925x_mux_nids[1] = {
351 0x0f,
352};
353
354static hda_nid_t stac925x_dac_nids[1] = {
355 0x02,
356};
357
Takashi Iwaif6e98522007-10-16 14:27:04 +0200358#define STAC925X_NUM_DMICS 1
359static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
360 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200361};
362
Takashi Iwai16970552007-12-18 18:05:52 +0100363static hda_nid_t stac925x_dmux_nids[1] = {
364 0x14,
365};
366
Matt2f2f4252005-04-13 14:45:30 +0200367static hda_nid_t stac922x_adc_nids[2] = {
368 0x06, 0x07,
369};
370
371static hda_nid_t stac922x_mux_nids[2] = {
372 0x12, 0x13,
373};
374
Matt Porter3cc08dc2006-01-23 15:27:49 +0100375static hda_nid_t stac927x_adc_nids[3] = {
376 0x07, 0x08, 0x09
377};
378
379static hda_nid_t stac927x_mux_nids[3] = {
380 0x15, 0x16, 0x17
381};
382
Matthew Ranostayd9737752008-09-07 12:03:41 +0200383static hda_nid_t stac927x_smux_nids[1] = {
384 0x21,
385};
386
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100387static hda_nid_t stac927x_dac_nids[6] = {
388 0x02, 0x03, 0x04, 0x05, 0x06, 0
389};
390
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100391static hda_nid_t stac927x_dmux_nids[1] = {
392 0x1b,
393};
394
Matthew Ranostay7f168592007-10-18 17:38:17 +0200395#define STAC927X_NUM_DMICS 2
396static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
397 0x13, 0x14, 0
398};
399
Matthew Ranostay65973632008-09-16 10:39:37 -0400400static const char *stac927x_spdif_labels[5] = {
401 "Digital Playback", "ADAT", "Analog Mux 1",
402 "Analog Mux 2", "Analog Mux 3"
403};
404
Matt Porterf3302a592006-07-31 12:49:34 +0200405static hda_nid_t stac9205_adc_nids[2] = {
406 0x12, 0x13
407};
408
409static hda_nid_t stac9205_mux_nids[2] = {
410 0x19, 0x1a
411};
412
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100413static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai16970552007-12-18 18:05:52 +0100414 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100415};
416
Matthew Ranostayd9737752008-09-07 12:03:41 +0200417static hda_nid_t stac9205_smux_nids[1] = {
418 0x21,
419};
420
Takashi Iwaif6e98522007-10-16 14:27:04 +0200421#define STAC9205_NUM_DMICS 2
422static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
423 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200424};
425
Mattc7d4b2f2005-06-27 14:59:41 +0200426static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200427 0x08, 0x09, 0x0d, 0x0e,
428 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200429};
430
Tobin Davis8e21c342007-01-08 11:04:17 +0100431static hda_nid_t stac925x_pin_nids[8] = {
432 0x07, 0x08, 0x0a, 0x0b,
433 0x0c, 0x0d, 0x10, 0x11,
434};
435
Matt2f2f4252005-04-13 14:45:30 +0200436static hda_nid_t stac922x_pin_nids[10] = {
437 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
438 0x0f, 0x10, 0x11, 0x15, 0x1b,
439};
440
Matthew Ranostaya7662642008-02-21 07:51:14 +0100441static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100442 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
443 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200444 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100445};
446
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200447static hda_nid_t stac92hd83xxx_pin_nids[14] = {
448 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
449 0x0f, 0x10, 0x11, 0x12, 0x13,
450 0x1d, 0x1e, 0x1f, 0x20
451};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400452static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100453 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
454 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400455 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100456};
457
Matt Porter3cc08dc2006-01-23 15:27:49 +0100458static hda_nid_t stac927x_pin_nids[14] = {
459 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x12, 0x13,
461 0x14, 0x21, 0x22, 0x23,
462};
463
Matt Porterf3302a592006-07-31 12:49:34 +0200464static hda_nid_t stac9205_pin_nids[12] = {
465 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
466 0x0f, 0x14, 0x16, 0x17, 0x18,
467 0x21, 0x22,
Matt Porterf3302a592006-07-31 12:49:34 +0200468};
469
Matthew Ranostay89385032008-09-11 09:49:39 -0400470#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
471
472static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
473 struct snd_ctl_elem_value *ucontrol)
474{
475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
476 struct sigmatel_spec *spec = codec->spec;
477 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
478
479 kcontrol->private_value ^= get_amp_nid(kcontrol);
480 kcontrol->private_value |= nid;
481
482 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
483}
484
485static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_value *ucontrol)
487{
488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
489 struct sigmatel_spec *spec = codec->spec;
490 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
491
492 kcontrol->private_value ^= get_amp_nid(kcontrol);
493 kcontrol->private_value |= nid;
494
495 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
496}
497
Matt Porter8b657272006-10-26 17:12:59 +0200498static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_info *uinfo)
500{
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
502 struct sigmatel_spec *spec = codec->spec;
503 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
504}
505
506static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
508{
509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
510 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100511 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200512
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100513 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200514 return 0;
515}
516
517static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_value *ucontrol)
519{
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100522 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200523
524 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100525 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200526}
527
Matthew Ranostayd9737752008-09-07 12:03:41 +0200528static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_info *uinfo)
530{
531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
532 struct sigmatel_spec *spec = codec->spec;
533 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
534}
535
536static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
538{
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct sigmatel_spec *spec = codec->spec;
541 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
542
543 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
544 return 0;
545}
546
547static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_value *ucontrol)
549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400552 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200553 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400554 int err, val;
555 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200556
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400557 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200558 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400559 if (err < 0)
560 return err;
561
562 if (spec->spdif_mute) {
563 if (smux_idx == 0)
564 nid = spec->multiout.dig_out_nid;
565 else
566 nid = codec->slave_dig_outs[smux_idx - 1];
567 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
568 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400569 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100570 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400571 /* un/mute SPDIF out */
572 snd_hda_codec_write_cache(codec, nid, 0,
573 AC_VERB_SET_AMP_GAIN_MUTE, val);
574 }
575 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200576}
577
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100578static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200579{
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200582 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200583}
584
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100585static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200586{
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 struct sigmatel_spec *spec = codec->spec;
589 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
590
591 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
592 return 0;
593}
594
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100595static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200596{
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 struct sigmatel_spec *spec = codec->spec;
599 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
600
Mattc7d4b2f2005-06-27 14:59:41 +0200601 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200602 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
603}
604
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100605static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
606 struct snd_ctl_elem_info *uinfo)
607{
608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 struct sigmatel_spec *spec = codec->spec;
610 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
611}
612
613static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
615{
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618
619 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
620 return 0;
621}
622
623static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_value *ucontrol)
625{
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628
629 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
630 spec->mono_nid, &spec->cur_mmux);
631}
632
Matthew Ranostay89385032008-09-11 09:49:39 -0400633static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_info *uinfo)
635{
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
639}
640
641static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
643{
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
646
647 ucontrol->value.enumerated.item[0] = spec->cur_amux;
648 return 0;
649}
650
651static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
653{
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 struct snd_kcontrol *ctl =
657 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
658 if (!ctl)
659 return -EINVAL;
660
661 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
662 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
663
664 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
665 0, &spec->cur_amux);
666}
667
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200668#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
669
670static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
672{
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100674 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200675 struct sigmatel_spec *spec = codec->spec;
676
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100677 ucontrol->value.integer.value[0] = !!(spec->aloopback &
678 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200679 return 0;
680}
681
682static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
683 struct snd_ctl_elem_value *ucontrol)
684{
685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
686 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100687 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200688 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100689 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200690
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100691 idx_val = spec->aloopback_mask << idx;
692 if (ucontrol->value.integer.value[0])
693 val = spec->aloopback | idx_val;
694 else
695 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100696 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200697 return 0;
698
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100699 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200700
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100701 /* Only return the bits defined by the shift value of the
702 * first two bytes of the mask
703 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200704 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100705 kcontrol->private_value & 0xFFFF, 0x0);
706 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100708 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200709 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100710 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200711 } else {
712 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100713 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200714 }
715
716 snd_hda_codec_write_cache(codec, codec->afg, 0,
717 kcontrol->private_value >> 16, dac_mode);
718
719 return 1;
720}
721
Mattc7d4b2f2005-06-27 14:59:41 +0200722static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200723 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200724 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200725 {}
726};
727
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200728static struct hda_verb stac9200_eapd_init[] = {
729 /* set dac0mux for dac converter */
730 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
731 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
732 {}
733};
734
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100735static struct hda_verb stac92hd73xx_6ch_core_init[] = {
736 /* set master volume and direct control */
737 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
738 /* setup audio connections */
739 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
740 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
741 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
742 /* setup adcs to point to mixer */
743 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
744 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100745 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
746 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
747 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
748 /* setup import muxs */
749 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
750 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
751 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
752 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
753 {}
754};
755
Matthew Ranostayd654a662008-03-14 08:46:51 +0100756static struct hda_verb dell_eq_core_init[] = {
757 /* set master volume to max value without distortion
758 * and direct control */
759 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
760 /* setup audio connections */
761 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400762 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
763 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100764 /* setup adcs to point to mixer */
765 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
766 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
767 /* setup import muxs */
768 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
772 {}
773};
774
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100775static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200776 /* set master volume to max value without distortion
777 * and direct control */
778 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100779 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100780 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
781 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
783 /* setup adcs to point to mixer */
784 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
786 /* setup import muxs */
787 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
791 {}
792};
793
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100794static struct hda_verb stac92hd73xx_8ch_core_init[] = {
795 /* set master volume and direct control */
796 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
797 /* setup audio connections */
798 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
799 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
800 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
801 /* connect hp ports to dac3 */
802 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
803 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
804 /* setup adcs to point to mixer */
805 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
806 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100807 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
808 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
809 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
810 /* setup import muxs */
811 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
815 {}
816};
817
818static struct hda_verb stac92hd73xx_10ch_core_init[] = {
819 /* set master volume and direct control */
820 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
821 /* setup audio connections */
822 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
823 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
824 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
825 /* dac3 is connected to import3 mux */
826 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
827 /* connect hp ports to dac4 */
828 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
829 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
830 /* setup adcs to point to mixer */
831 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
832 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100833 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
834 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
835 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 /* setup import muxs */
837 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
838 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
839 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
840 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
841 {}
842};
843
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200844static struct hda_verb stac92hd83xxx_core_init[] = {
845 /* start of config #1 */
846 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
847
848 /* start of config #2 */
849 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
850 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
851 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
852
853 /* power state controls amps */
854 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
855};
856
Matthew Ranostaye035b842007-11-06 11:53:55 +0100857static struct hda_verb stac92hd71bxx_core_init[] = {
858 /* set master volume and direct control */
859 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
860 /* connect headphone jack to dac1 */
861 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100862 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
863 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
864 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
865 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100866};
867
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400868#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100869static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200870 /* start of config #1 */
871
872 /* connect port 0f to audio mixer */
873 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200874 /* unmute right and left channels for node 0x0f */
875 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
876 /* start of config #2 */
877
Matthew Ranostay541eee82007-12-14 12:08:04 +0100878 /* set master volume and direct control */
879 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
880 /* connect headphone jack to dac1 */
881 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200882 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100883 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
884 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100885 {}
886};
887
Tobin Davis8e21c342007-01-08 11:04:17 +0100888static struct hda_verb stac925x_core_init[] = {
889 /* set dac0mux for dac converter */
890 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
891 {}
892};
893
Mattc7d4b2f2005-06-27 14:59:41 +0200894static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200895 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200896 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200897 {}
898};
899
Tobin Davis93ed1502006-09-01 21:03:12 +0200900static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200901 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200902 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200903 /* unmute node 0x1b */
904 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
905 /* select node 0x03 as DAC */
906 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
907 {}
908};
909
Matt Porter3cc08dc2006-01-23 15:27:49 +0100910static struct hda_verb stac927x_core_init[] = {
911 /* set master volume and direct control */
912 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200913 /* enable analog pc beep path */
914 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100915 {}
916};
917
Matt Porterf3302a592006-07-31 12:49:34 +0200918static struct hda_verb stac9205_core_init[] = {
919 /* set master volume and direct control */
920 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200921 /* enable analog pc beep path */
922 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a592006-07-31 12:49:34 +0200923 {}
924};
925
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100926#define STAC_MONO_MUX \
927 { \
928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
929 .name = "Mono Mux", \
930 .count = 1, \
931 .info = stac92xx_mono_mux_enum_info, \
932 .get = stac92xx_mono_mux_enum_get, \
933 .put = stac92xx_mono_mux_enum_put, \
934 }
935
Matthew Ranostay89385032008-09-11 09:49:39 -0400936#define STAC_AMP_MUX \
937 { \
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
939 .name = "Amp Selector Capture Switch", \
940 .count = 1, \
941 .info = stac92xx_amp_mux_enum_info, \
942 .get = stac92xx_amp_mux_enum_get, \
943 .put = stac92xx_amp_mux_enum_put, \
944 }
945
946#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
947 { \
948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
949 .name = xname, \
950 .index = 0, \
951 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
952 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
953 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
954 .info = stac92xx_amp_volume_info, \
955 .get = stac92xx_amp_volume_get, \
956 .put = stac92xx_amp_volume_put, \
957 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
958 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
959 }
960
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200961#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200962 { \
963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
964 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200965 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200966 .info = stac92xx_mux_enum_info, \
967 .get = stac92xx_mux_enum_get, \
968 .put = stac92xx_mux_enum_put, \
969 }
970
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100971#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200972 { \
973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
974 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100975 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200976 .info = stac92xx_aloopback_info, \
977 .get = stac92xx_aloopback_get, \
978 .put = stac92xx_aloopback_put, \
979 .private_value = verb_read | (verb_write << 16), \
980 }
981
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100982static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200983 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
984 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200985 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200986 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
987 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200988 { } /* end */
989};
990
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400991#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100992static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400993 /* start of config #1 */
994 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
995 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
996
997 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
998 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
999
1000 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1001 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1002
1003 /* start of config #2 */
1004 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1005 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1006
1007 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1008 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1009
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001010 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1011
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001012 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1014
1015 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1016 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1017
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001018 { } /* end */
1019};
1020
1021static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001022 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1023
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001024 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1025 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1026
1027 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1028 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1029
1030 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1031 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1032
1033 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1034 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1035
1036 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1037 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1038
1039 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1040 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1041
1042 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1043 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1044 { } /* end */
1045};
1046
1047static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001048 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1049
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001050 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1052
1053 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1055
1056 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1058
1059 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1060 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1061
1062 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1063 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1064
1065 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1066 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1069 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1070 { } /* end */
1071};
1072
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001073
1074static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1077
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1080
1081 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1082 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1083
1084 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1085 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1086
1087 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1088 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1089
1090 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1091 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1092
1093 /*
1094 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1095 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1096 */
1097 { } /* end */
1098};
1099
Matthew Ranostay541eee82007-12-14 12:08:04 +01001100static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001101 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001102 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001103
Matthew Ranostay9b359472007-11-07 13:03:12 +01001104 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001106
1107 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1108 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001109 /* analog pc-beep replaced with digital beep support */
1110 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001111 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1112 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001113 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001114
Matthew Ranostay687cb982008-10-11 13:52:43 -04001115 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1116 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001117
Matthew Ranostay687cb982008-10-11 13:52:43 -04001118 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1119 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001120
1121 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1122 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1123
1124 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1125 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001126 { } /* end */
1127};
1128
Matthew Ranostay541eee82007-12-14 12:08:04 +01001129static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001130 STAC_INPUT_SOURCE(2),
1131 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1132
Matthew Ranostay541eee82007-12-14 12:08:04 +01001133 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135
1136 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001138 { } /* end */
1139};
1140
Tobin Davis8e21c342007-01-08 11:04:17 +01001141static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001142 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001143 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001144 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001145 { } /* end */
1146};
1147
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001148static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001149 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001150 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001151
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001154
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001157 { } /* end */
1158};
1159
1160/* This needs to be generated dynamically based on sequence */
1161static struct snd_kcontrol_new stac922x_mixer[] = {
1162 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001163 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001165
1166 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001168 { } /* end */
1169};
1170
1171
1172static struct snd_kcontrol_new stac927x_mixer[] = {
1173 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001174 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001175
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001178
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001181
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a592006-07-31 12:49:34 +02001184 { } /* end */
1185};
1186
Takashi Iwai16970552007-12-18 18:05:52 +01001187static struct snd_kcontrol_new stac_dmux_mixer = {
1188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1189 .name = "Digital Input Source",
1190 /* count set later */
1191 .info = stac92xx_dmux_enum_info,
1192 .get = stac92xx_dmux_enum_get,
1193 .put = stac92xx_dmux_enum_put,
1194};
1195
Matthew Ranostayd9737752008-09-07 12:03:41 +02001196static struct snd_kcontrol_new stac_smux_mixer = {
1197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001198 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001199 /* count set later */
1200 .info = stac92xx_smux_enum_info,
1201 .get = stac92xx_smux_enum_get,
1202 .put = stac92xx_smux_enum_put,
1203};
1204
Takashi Iwai2134ea42008-01-10 16:53:55 +01001205static const char *slave_vols[] = {
1206 "Front Playback Volume",
1207 "Surround Playback Volume",
1208 "Center Playback Volume",
1209 "LFE Playback Volume",
1210 "Side Playback Volume",
1211 "Headphone Playback Volume",
1212 "Headphone Playback Volume",
1213 "Speaker Playback Volume",
1214 "External Speaker Playback Volume",
1215 "Speaker2 Playback Volume",
1216 NULL
1217};
1218
1219static const char *slave_sws[] = {
1220 "Front Playback Switch",
1221 "Surround Playback Switch",
1222 "Center Playback Switch",
1223 "LFE Playback Switch",
1224 "Side Playback Switch",
1225 "Headphone Playback Switch",
1226 "Headphone Playback Switch",
1227 "Speaker Playback Switch",
1228 "External Speaker Playback Switch",
1229 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001230 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001231 NULL
1232};
1233
Matt2f2f4252005-04-13 14:45:30 +02001234static int stac92xx_build_controls(struct hda_codec *codec)
1235{
1236 struct sigmatel_spec *spec = codec->spec;
1237 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001238 int i;
Matt2f2f4252005-04-13 14:45:30 +02001239
1240 err = snd_hda_add_new_ctls(codec, spec->mixer);
1241 if (err < 0)
1242 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001243
1244 for (i = 0; i < spec->num_mixers; i++) {
1245 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1246 if (err < 0)
1247 return err;
1248 }
Takashi Iwai16970552007-12-18 18:05:52 +01001249 if (spec->num_dmuxes > 0) {
1250 stac_dmux_mixer.count = spec->num_dmuxes;
1251 err = snd_ctl_add(codec->bus->card,
1252 snd_ctl_new1(&stac_dmux_mixer, codec));
1253 if (err < 0)
1254 return err;
1255 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001256 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001257 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1258 struct hda_input_mux *smux = &spec->private_smux;
1259 /* check for mute support on SPDIF out */
1260 if (wcaps & AC_WCAP_OUT_AMP) {
1261 smux->items[smux->num_items].label = "Off";
1262 smux->items[smux->num_items].index = 0;
1263 smux->num_items++;
1264 spec->spdif_mute = 1;
1265 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001266 stac_smux_mixer.count = spec->num_smuxes;
1267 err = snd_ctl_add(codec->bus->card,
1268 snd_ctl_new1(&stac_smux_mixer, codec));
1269 if (err < 0)
1270 return err;
1271 }
Mattc7d4b2f2005-06-27 14:59:41 +02001272
Mattdabbed62005-06-14 10:19:34 +02001273 if (spec->multiout.dig_out_nid) {
1274 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1275 if (err < 0)
1276 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001277 err = snd_hda_create_spdif_share_sw(codec,
1278 &spec->multiout);
1279 if (err < 0)
1280 return err;
1281 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001282 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001283 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001284 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1285 if (err < 0)
1286 return err;
1287 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001288
1289 /* if we have no master control, let's create it */
1290 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001291 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001292 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001293 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001294 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001295 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001296 if (err < 0)
1297 return err;
1298 }
1299 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1300 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1301 NULL, slave_sws);
1302 if (err < 0)
1303 return err;
1304 }
1305
Mattdabbed62005-06-14 10:19:34 +02001306 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001307}
1308
Matt Porter403d1942005-11-29 15:00:51 +01001309static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001310 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001311 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1312};
1313
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001314/*
1315 STAC 9200 pin configs for
1316 102801A8
1317 102801DE
1318 102801E8
1319*/
1320static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001321 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1322 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001323};
1324
1325/*
1326 STAC 9200 pin configs for
1327 102801C0
1328 102801C1
1329*/
1330static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001331 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1332 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001333};
1334
1335/*
1336 STAC 9200 pin configs for
1337 102801C4 (Dell Dimension E310)
1338 102801C5
1339 102801C7
1340 102801D9
1341 102801DA
1342 102801E3
1343*/
1344static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001345 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1346 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001347};
1348
1349
1350/*
1351 STAC 9200-32 pin configs for
1352 102801B5 (Dell Inspiron 630m)
1353 102801D8 (Dell Inspiron 640m)
1354*/
1355static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001356 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1357 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001358};
1359
1360/*
1361 STAC 9200-32 pin configs for
1362 102801C2 (Dell Latitude D620)
1363 102801C8
1364 102801CC (Dell Latitude D820)
1365 102801D4
1366 102801D6
1367*/
1368static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001369 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1370 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001371};
1372
1373/*
1374 STAC 9200-32 pin configs for
1375 102801CE (Dell XPS M1710)
1376 102801CF (Dell Precision M90)
1377*/
1378static unsigned int dell9200_m23_pin_configs[8] = {
1379 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1380 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1381};
1382
1383/*
1384 STAC 9200-32 pin configs for
1385 102801C9
1386 102801CA
1387 102801CB (Dell Latitude 120L)
1388 102801D3
1389*/
1390static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001391 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1392 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001393};
1394
1395/*
1396 STAC 9200-32 pin configs for
1397 102801BD (Dell Inspiron E1505n)
1398 102801EE
1399 102801EF
1400*/
1401static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001402 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1403 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001404};
1405
1406/*
1407 STAC 9200-32 pin configs for
1408 102801F5 (Dell Inspiron 1501)
1409 102801F6
1410*/
1411static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001412 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1413 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001414};
1415
1416/*
1417 STAC 9200-32
1418 102801CD (Dell Inspiron E1705/9400)
1419*/
1420static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001421 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1422 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001423};
1424
Tobin Davisbf277782008-02-03 20:31:47 +01001425static unsigned int oqo9200_pin_configs[8] = {
1426 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1427 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1428};
1429
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001430
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001431static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1432 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001433 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001434 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1435 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1436 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1437 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1438 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1439 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1440 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1441 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1442 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1443 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001444 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001445};
1446
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001447static const char *stac9200_models[STAC_9200_MODELS] = {
1448 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001449 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001450 [STAC_9200_DELL_D21] = "dell-d21",
1451 [STAC_9200_DELL_D22] = "dell-d22",
1452 [STAC_9200_DELL_D23] = "dell-d23",
1453 [STAC_9200_DELL_M21] = "dell-m21",
1454 [STAC_9200_DELL_M22] = "dell-m22",
1455 [STAC_9200_DELL_M23] = "dell-m23",
1456 [STAC_9200_DELL_M24] = "dell-m24",
1457 [STAC_9200_DELL_M25] = "dell-m25",
1458 [STAC_9200_DELL_M26] = "dell-m26",
1459 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001460 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001461 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001462};
1463
1464static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1465 /* SigmaTel reference board */
1466 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1467 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001468 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1470 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001472 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1474 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1476 "unknown Dell", STAC_9200_DELL_D22),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1478 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001480 "Dell Latitude D620", STAC_9200_DELL_M22),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1482 "unknown Dell", STAC_9200_DELL_D23),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1484 "unknown Dell", STAC_9200_DELL_D23),
1485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1486 "unknown Dell", STAC_9200_DELL_M22),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1488 "unknown Dell", STAC_9200_DELL_M24),
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1490 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001492 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001493 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001494 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001495 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001496 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001497 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001498 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001499 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001500 "Dell Precision M90", STAC_9200_DELL_M23),
1501 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1502 "unknown Dell", STAC_9200_DELL_M22),
1503 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1504 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001506 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001508 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1510 "unknown Dell", STAC_9200_DELL_D23),
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1512 "unknown Dell", STAC_9200_DELL_D23),
1513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1514 "unknown Dell", STAC_9200_DELL_D21),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1516 "unknown Dell", STAC_9200_DELL_D23),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1518 "unknown Dell", STAC_9200_DELL_D21),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1520 "unknown Dell", STAC_9200_DELL_M25),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1522 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001524 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1526 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001527 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001528 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001529 /* Gateway machines needs EAPD to be set on resume */
1530 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1531 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1532 STAC_9200_GATEWAY),
1533 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1534 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001535 /* OQO Mobile */
1536 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001537 {} /* terminator */
1538};
1539
Tobin Davis8e21c342007-01-08 11:04:17 +01001540static unsigned int ref925x_pin_configs[8] = {
1541 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001542 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001543};
1544
1545static unsigned int stac925x_MA6_pin_configs[8] = {
1546 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1547 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1548};
1549
Tobin Davis2c11f952007-05-17 09:36:34 +02001550static unsigned int stac925x_PA6_pin_configs[8] = {
1551 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1552 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1553};
1554
Tobin Davis8e21c342007-01-08 11:04:17 +01001555static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001556 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1557 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001558};
1559
1560static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1561 [STAC_REF] = ref925x_pin_configs,
1562 [STAC_M2_2] = stac925xM2_2_pin_configs,
1563 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001564 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001565};
1566
1567static const char *stac925x_models[STAC_925x_MODELS] = {
1568 [STAC_REF] = "ref",
1569 [STAC_M2_2] = "m2-2",
1570 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001571 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001572};
1573
1574static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1575 /* SigmaTel reference board */
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001577 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001578 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1579 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1580 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001581 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001582 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1583 {} /* terminator */
1584};
1585
Matthew Ranostaya7662642008-02-21 07:51:14 +01001586static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001587 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1588 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1589 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001590 0x01452050,
1591};
1592
1593static unsigned int dell_m6_pin_configs[13] = {
1594 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001595 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001596 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1597 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001598};
1599
1600static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001601 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1602 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001603};
1604
1605static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1606 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001607 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001608};
1609
1610static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1611 /* SigmaTel reference board */
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001613 "DFI LanParty", STAC_92HD73XX_REF),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1615 "unknown Dell", STAC_DELL_M6),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1617 "unknown Dell", STAC_DELL_M6),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1619 "unknown Dell", STAC_DELL_M6),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1621 "unknown Dell", STAC_DELL_M6),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1623 "unknown Dell", STAC_DELL_M6),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1625 "unknown Dell", STAC_DELL_M6),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1627 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001628 {} /* terminator */
1629};
1630
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001631static unsigned int ref92hd83xxx_pin_configs[14] = {
1632 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1633 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1634 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1635 0x01451160, 0x98560170,
1636};
1637
1638static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1639 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1640};
1641
1642static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1643 [STAC_92HD83XXX_REF] = "ref",
1644};
1645
1646static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1647 /* SigmaTel reference board */
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1649 "DFI LanParty", STAC_92HD71BXX_REF),
1650};
1651
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001652static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001653 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001654 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001655 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001656};
1657
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001658static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001659 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001660 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001661 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001662};
1663
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001664static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001665 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1666 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001667 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001668};
1669
Matthew Ranostaye035b842007-11-06 11:53:55 +01001670static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1671 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001672 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1673 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001674 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001675};
1676
1677static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1678 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001679 [STAC_DELL_M4_1] = "dell-m4-1",
1680 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001681 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001682};
1683
1684static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1685 /* SigmaTel reference board */
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1687 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001688 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1689 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1691 "unknown Dell", STAC_DELL_M4_1),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1693 "unknown Dell", STAC_DELL_M4_1),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1695 "unknown Dell", STAC_DELL_M4_1),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1697 "unknown Dell", STAC_DELL_M4_1),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1699 "unknown Dell", STAC_DELL_M4_1),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1701 "unknown Dell", STAC_DELL_M4_1),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1703 "unknown Dell", STAC_DELL_M4_1),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1705 "unknown Dell", STAC_DELL_M4_2),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1707 "unknown Dell", STAC_DELL_M4_2),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1709 "unknown Dell", STAC_DELL_M4_2),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1711 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001712 {} /* terminator */
1713};
1714
Matt Porter403d1942005-11-29 15:00:51 +01001715static unsigned int ref922x_pin_configs[10] = {
1716 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1717 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001718 0x40000100, 0x40000100,
1719};
1720
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001721/*
1722 STAC 922X pin configs for
1723 102801A7
1724 102801AB
1725 102801A9
1726 102801D1
1727 102801D2
1728*/
1729static unsigned int dell_922x_d81_pin_configs[10] = {
1730 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1731 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1732 0x01813122, 0x400001f2,
1733};
1734
1735/*
1736 STAC 922X pin configs for
1737 102801AC
1738 102801D0
1739*/
1740static unsigned int dell_922x_d82_pin_configs[10] = {
1741 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1742 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1743 0x01813122, 0x400001f1,
1744};
1745
1746/*
1747 STAC 922X pin configs for
1748 102801BF
1749*/
1750static unsigned int dell_922x_m81_pin_configs[10] = {
1751 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1752 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1753 0x40C003f1, 0x405003f0,
1754};
1755
1756/*
1757 STAC 9221 A1 pin configs for
1758 102801D7 (Dell XPS M1210)
1759*/
1760static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001761 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1762 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001763 0x508003f3, 0x405003f4,
1764};
1765
Matt Porter403d1942005-11-29 15:00:51 +01001766static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001767 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001768 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1769 0x02a19120, 0x40000100,
1770};
1771
1772static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001773 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1774 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001775 0x02a19320, 0x40000100,
1776};
1777
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001778static unsigned int intel_mac_v1_pin_configs[10] = {
1779 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1780 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001781 0x400000fc, 0x400000fb,
1782};
1783
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001784static unsigned int intel_mac_v2_pin_configs[10] = {
1785 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1786 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001787 0x400000fc, 0x400000fb,
1788};
1789
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001790static unsigned int intel_mac_v3_pin_configs[10] = {
1791 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1792 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1793 0x400000fc, 0x400000fb,
1794};
1795
1796static unsigned int intel_mac_v4_pin_configs[10] = {
1797 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1798 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1799 0x400000fc, 0x400000fb,
1800};
1801
1802static unsigned int intel_mac_v5_pin_configs[10] = {
1803 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1804 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1805 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001806};
1807
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001808static unsigned int ecs202_pin_configs[10] = {
1809 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1810 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1811 0x9037012e, 0x40e000f2,
1812};
Takashi Iwai76c08822007-06-19 12:17:42 +02001813
Takashi Iwai19039bd2006-06-28 15:52:16 +02001814static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001815 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001816 [STAC_D945GTP3] = d945gtp3_pin_configs,
1817 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001818 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1819 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1820 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1821 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1822 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001823 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001824 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001825 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1826 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1827 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1828 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1829 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1830 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001831 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001832 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1833 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1834 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1835 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001836};
1837
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001838static const char *stac922x_models[STAC_922X_MODELS] = {
1839 [STAC_D945_REF] = "ref",
1840 [STAC_D945GTP5] = "5stack",
1841 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001842 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1843 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1844 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1845 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1846 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001847 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001848 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001849 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001850 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001851 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1852 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001853 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001854 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001855 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001856 [STAC_922X_DELL_D81] = "dell-d81",
1857 [STAC_922X_DELL_D82] = "dell-d82",
1858 [STAC_922X_DELL_M81] = "dell-m81",
1859 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001860};
1861
1862static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1863 /* SigmaTel reference board */
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1865 "DFI LanParty", STAC_D945_REF),
1866 /* Intel 945G based systems */
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1868 "Intel D945G", STAC_D945GTP3),
1869 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1870 "Intel D945G", STAC_D945GTP3),
1871 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1872 "Intel D945G", STAC_D945GTP3),
1873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1874 "Intel D945G", STAC_D945GTP3),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1876 "Intel D945G", STAC_D945GTP3),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1878 "Intel D945G", STAC_D945GTP3),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1880 "Intel D945G", STAC_D945GTP3),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1882 "Intel D945G", STAC_D945GTP3),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1884 "Intel D945G", STAC_D945GTP3),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1886 "Intel D945G", STAC_D945GTP3),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1888 "Intel D945G", STAC_D945GTP3),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1890 "Intel D945G", STAC_D945GTP3),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1892 "Intel D945G", STAC_D945GTP3),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1894 "Intel D945G", STAC_D945GTP3),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1896 "Intel D945G", STAC_D945GTP3),
1897 /* Intel D945G 5-stack systems */
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1899 "Intel D945G", STAC_D945GTP5),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1901 "Intel D945G", STAC_D945GTP5),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1903 "Intel D945G", STAC_D945GTP5),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1905 "Intel D945G", STAC_D945GTP5),
1906 /* Intel 945P based systems */
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1908 "Intel D945P", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1910 "Intel D945P", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1912 "Intel D945P", STAC_D945GTP3),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1914 "Intel D945P", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1916 "Intel D945P", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1918 "Intel D945P", STAC_D945GTP5),
1919 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001920 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001921 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001922 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001923 /* Dell systems */
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1925 "unknown Dell", STAC_922X_DELL_D81),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1927 "unknown Dell", STAC_922X_DELL_D81),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1929 "unknown Dell", STAC_922X_DELL_D81),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1931 "unknown Dell", STAC_922X_DELL_D82),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1933 "unknown Dell", STAC_922X_DELL_M81),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1935 "unknown Dell", STAC_922X_DELL_D82),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1937 "unknown Dell", STAC_922X_DELL_D81),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1939 "unknown Dell", STAC_922X_DELL_D81),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1941 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001942 /* ECS/PC Chips boards */
1943 SND_PCI_QUIRK(0x1019, 0x2144,
1944 "ECS/PC chips", STAC_ECS_202),
1945 SND_PCI_QUIRK(0x1019, 0x2608,
1946 "ECS/PC chips", STAC_ECS_202),
1947 SND_PCI_QUIRK(0x1019, 0x2633,
1948 "ECS/PC chips P17G/1333", STAC_ECS_202),
1949 SND_PCI_QUIRK(0x1019, 0x2811,
1950 "ECS/PC chips", STAC_ECS_202),
1951 SND_PCI_QUIRK(0x1019, 0x2812,
1952 "ECS/PC chips", STAC_ECS_202),
1953 SND_PCI_QUIRK(0x1019, 0x2813,
1954 "ECS/PC chips", STAC_ECS_202),
1955 SND_PCI_QUIRK(0x1019, 0x2814,
1956 "ECS/PC chips", STAC_ECS_202),
1957 SND_PCI_QUIRK(0x1019, 0x2815,
1958 "ECS/PC chips", STAC_ECS_202),
1959 SND_PCI_QUIRK(0x1019, 0x2816,
1960 "ECS/PC chips", STAC_ECS_202),
1961 SND_PCI_QUIRK(0x1019, 0x2817,
1962 "ECS/PC chips", STAC_ECS_202),
1963 SND_PCI_QUIRK(0x1019, 0x2818,
1964 "ECS/PC chips", STAC_ECS_202),
1965 SND_PCI_QUIRK(0x1019, 0x2819,
1966 "ECS/PC chips", STAC_ECS_202),
1967 SND_PCI_QUIRK(0x1019, 0x2820,
1968 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001969 {} /* terminator */
1970};
1971
Matt Porter3cc08dc2006-01-23 15:27:49 +01001972static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001973 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1974 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1975 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1976 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001977};
1978
Tobin Davis93ed1502006-09-01 21:03:12 +02001979static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001980 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1981 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1982 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1983 0x40000100, 0x40000100
1984};
1985
Tobin Davis93ed1502006-09-01 21:03:12 +02001986static unsigned int d965_5st_pin_configs[14] = {
1987 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1988 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1989 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1990 0x40000100, 0x40000100
1991};
1992
Tobin Davis4ff076e2007-08-07 11:48:12 +02001993static unsigned int dell_3st_pin_configs[14] = {
1994 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1995 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001996 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001997 0x40c003fc, 0x40000100
1998};
1999
Tobin Davis93ed1502006-09-01 21:03:12 +02002000static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002001 [STAC_D965_REF] = ref927x_pin_configs,
2002 [STAC_D965_3ST] = d965_3st_pin_configs,
2003 [STAC_D965_5ST] = d965_5st_pin_configs,
2004 [STAC_DELL_3ST] = dell_3st_pin_configs,
2005 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002006};
2007
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002008static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002009 [STAC_D965_REF] = "ref",
2010 [STAC_D965_3ST] = "3stack",
2011 [STAC_D965_5ST] = "5stack",
2012 [STAC_DELL_3ST] = "dell-3stack",
2013 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002014};
2015
2016static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2017 /* SigmaTel reference board */
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2019 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002020 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002023 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002040 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002042 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002045 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002054 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002064 {} /* terminator */
2065};
2066
Matt Porterf3302a592006-07-31 12:49:34 +02002067static unsigned int ref9205_pin_configs[12] = {
2068 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002069 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002070 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a592006-07-31 12:49:34 +02002071};
2072
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002073/*
2074 STAC 9205 pin configs for
2075 102801F1
2076 102801F2
2077 102801FC
2078 102801FD
2079 10280204
2080 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002081 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002082*/
2083static unsigned int dell_9205_m42_pin_configs[12] = {
2084 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2085 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2086 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2087};
2088
2089/*
2090 STAC 9205 pin configs for
2091 102801F9
2092 102801FA
2093 102801FE
2094 102801FF (Dell Precision M4300)
2095 10280206
2096 10280200
2097 10280201
2098*/
2099static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002100 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2101 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2102 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2103};
2104
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002105static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002106 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2107 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2108 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2109};
2110
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002111static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002112 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002113 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2114 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2115 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a592006-07-31 12:49:34 +02002116};
2117
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002118static const char *stac9205_models[STAC_9205_MODELS] = {
2119 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002120 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002121 [STAC_9205_DELL_M43] = "dell-m43",
2122 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002123};
2124
2125static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2126 /* SigmaTel reference board */
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2128 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002129 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2130 "unknown Dell", STAC_9205_DELL_M42),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2132 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002134 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2136 "Dell Precision", STAC_9205_DELL_M43),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2138 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2140 "unknown Dell", STAC_9205_DELL_M42),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2142 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2144 "Dell Precision", STAC_9205_DELL_M43),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002146 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2148 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2150 "Dell Precision", STAC_9205_DELL_M43),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2152 "Dell Precision", STAC_9205_DELL_M43),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2154 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2156 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2158 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a592006-07-31 12:49:34 +02002159 {} /* terminator */
2160};
2161
Richard Fish11b44bb2006-08-23 18:31:34 +02002162static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2163{
2164 int i;
2165 struct sigmatel_spec *spec = codec->spec;
2166
2167 if (! spec->bios_pin_configs) {
2168 spec->bios_pin_configs = kcalloc(spec->num_pins,
2169 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2170 if (! spec->bios_pin_configs)
2171 return -ENOMEM;
2172 }
2173
2174 for (i = 0; i < spec->num_pins; i++) {
2175 hda_nid_t nid = spec->pin_nids[i];
2176 unsigned int pin_cfg;
2177
2178 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2179 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2180 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2181 nid, pin_cfg);
2182 spec->bios_pin_configs[i] = pin_cfg;
2183 }
2184
2185 return 0;
2186}
2187
Matthew Ranostay87d48362007-07-17 11:52:24 +02002188static void stac92xx_set_config_reg(struct hda_codec *codec,
2189 hda_nid_t pin_nid, unsigned int pin_config)
2190{
2191 int i;
2192 snd_hda_codec_write(codec, pin_nid, 0,
2193 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2194 pin_config & 0x000000ff);
2195 snd_hda_codec_write(codec, pin_nid, 0,
2196 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2197 (pin_config & 0x0000ff00) >> 8);
2198 snd_hda_codec_write(codec, pin_nid, 0,
2199 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2200 (pin_config & 0x00ff0000) >> 16);
2201 snd_hda_codec_write(codec, pin_nid, 0,
2202 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2203 pin_config >> 24);
2204 i = snd_hda_codec_read(codec, pin_nid, 0,
2205 AC_VERB_GET_CONFIG_DEFAULT,
2206 0x00);
2207 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2208 pin_nid, i);
2209}
2210
Matt2f2f4252005-04-13 14:45:30 +02002211static void stac92xx_set_config_regs(struct hda_codec *codec)
2212{
2213 int i;
2214 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002215
Matthew Ranostay87d48362007-07-17 11:52:24 +02002216 if (!spec->pin_configs)
2217 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002218
Matthew Ranostay87d48362007-07-17 11:52:24 +02002219 for (i = 0; i < spec->num_pins; i++)
2220 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2221 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002222}
Matt2f2f4252005-04-13 14:45:30 +02002223
Matt2f2f4252005-04-13 14:45:30 +02002224/*
2225 * Analog playback callbacks
2226 */
2227static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2228 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002229 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002230{
2231 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002232 if (spec->stream_delay)
2233 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002234 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2235 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002236}
2237
2238static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2239 struct hda_codec *codec,
2240 unsigned int stream_tag,
2241 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002242 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002243{
2244 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002245 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002246}
2247
2248static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2249 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-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;
2253 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2254}
2255
2256/*
Mattdabbed62005-06-14 10:19:34 +02002257 * Digital playback callbacks
2258 */
2259static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002261 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002262{
2263 struct sigmatel_spec *spec = codec->spec;
2264 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2265}
2266
2267static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2268 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002269 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002270{
2271 struct sigmatel_spec *spec = codec->spec;
2272 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2273}
2274
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002275static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2276 struct hda_codec *codec,
2277 unsigned int stream_tag,
2278 unsigned int format,
2279 struct snd_pcm_substream *substream)
2280{
2281 struct sigmatel_spec *spec = codec->spec;
2282 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2283 stream_tag, format, substream);
2284}
2285
Mattdabbed62005-06-14 10:19:34 +02002286
2287/*
Matt2f2f4252005-04-13 14:45:30 +02002288 * Analog capture callbacks
2289 */
2290static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2291 struct hda_codec *codec,
2292 unsigned int stream_tag,
2293 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002294 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002295{
2296 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002297 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002298
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002299 if (spec->powerdown_adcs) {
2300 msleep(40);
2301 snd_hda_codec_write_cache(codec, nid, 0,
2302 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2303 }
2304 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002305 return 0;
2306}
2307
2308static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2309 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002310 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002311{
2312 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002313 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002314
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002315 snd_hda_codec_cleanup_stream(codec, nid);
2316 if (spec->powerdown_adcs)
2317 snd_hda_codec_write_cache(codec, nid, 0,
2318 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002319 return 0;
2320}
2321
Mattdabbed62005-06-14 10:19:34 +02002322static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2323 .substreams = 1,
2324 .channels_min = 2,
2325 .channels_max = 2,
2326 /* NID is set in stac92xx_build_pcms */
2327 .ops = {
2328 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002329 .close = stac92xx_dig_playback_pcm_close,
2330 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002331 },
2332};
2333
2334static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2335 .substreams = 1,
2336 .channels_min = 2,
2337 .channels_max = 2,
2338 /* NID is set in stac92xx_build_pcms */
2339};
2340
Matt2f2f4252005-04-13 14:45:30 +02002341static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2342 .substreams = 1,
2343 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002344 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002345 .nid = 0x02, /* NID to query formats and rates */
2346 .ops = {
2347 .open = stac92xx_playback_pcm_open,
2348 .prepare = stac92xx_playback_pcm_prepare,
2349 .cleanup = stac92xx_playback_pcm_cleanup
2350 },
2351};
2352
Matt Porter3cc08dc2006-01-23 15:27:49 +01002353static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2354 .substreams = 1,
2355 .channels_min = 2,
2356 .channels_max = 2,
2357 .nid = 0x06, /* NID to query formats and rates */
2358 .ops = {
2359 .open = stac92xx_playback_pcm_open,
2360 .prepare = stac92xx_playback_pcm_prepare,
2361 .cleanup = stac92xx_playback_pcm_cleanup
2362 },
2363};
2364
Matt2f2f4252005-04-13 14:45:30 +02002365static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002366 .channels_min = 2,
2367 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002368 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002369 .ops = {
2370 .prepare = stac92xx_capture_pcm_prepare,
2371 .cleanup = stac92xx_capture_pcm_cleanup
2372 },
2373};
2374
2375static int stac92xx_build_pcms(struct hda_codec *codec)
2376{
2377 struct sigmatel_spec *spec = codec->spec;
2378 struct hda_pcm *info = spec->pcm_rec;
2379
2380 codec->num_pcms = 1;
2381 codec->pcm_info = info;
2382
Mattc7d4b2f2005-06-27 14:59:41 +02002383 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002384 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002385 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002386 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002387 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002388
2389 if (spec->alt_switch) {
2390 codec->num_pcms++;
2391 info++;
2392 info->name = "STAC92xx Analog Alt";
2393 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2394 }
Matt2f2f4252005-04-13 14:45:30 +02002395
Mattdabbed62005-06-14 10:19:34 +02002396 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2397 codec->num_pcms++;
2398 info++;
2399 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002400 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002401 if (spec->multiout.dig_out_nid) {
2402 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2403 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2404 }
2405 if (spec->dig_in_nid) {
2406 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2407 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2408 }
2409 }
2410
Matt2f2f4252005-04-13 14:45:30 +02002411 return 0;
2412}
2413
Takashi Iwaic960a032006-03-23 17:06:28 +01002414static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2415{
2416 unsigned int pincap = snd_hda_param_read(codec, nid,
2417 AC_PAR_PIN_CAP);
2418 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2419 if (pincap & AC_PINCAP_VREF_100)
2420 return AC_PINCTL_VREF_100;
2421 if (pincap & AC_PINCAP_VREF_80)
2422 return AC_PINCTL_VREF_80;
2423 if (pincap & AC_PINCAP_VREF_50)
2424 return AC_PINCTL_VREF_50;
2425 if (pincap & AC_PINCAP_VREF_GRD)
2426 return AC_PINCTL_VREF_GRD;
2427 return 0;
2428}
2429
Matt Porter403d1942005-11-29 15:00:51 +01002430static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2431
2432{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002433 snd_hda_codec_write_cache(codec, nid, 0,
2434 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002435}
2436
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002437#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2438
2439static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2440 struct snd_ctl_elem_value *ucontrol)
2441{
2442 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2443 struct sigmatel_spec *spec = codec->spec;
2444
2445 ucontrol->value.integer.value[0] = spec->hp_switch;
2446 return 0;
2447}
2448
2449static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2450 struct snd_ctl_elem_value *ucontrol)
2451{
2452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2453 struct sigmatel_spec *spec = codec->spec;
2454
2455 spec->hp_switch = ucontrol->value.integer.value[0];
2456
2457 /* check to be sure that the ports are upto date with
2458 * switch changes
2459 */
2460 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2461
2462 return 1;
2463}
2464
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002465#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002466
2467static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2468{
2469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2470 struct sigmatel_spec *spec = codec->spec;
2471 int io_idx = kcontrol-> private_value & 0xff;
2472
2473 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2474 return 0;
2475}
2476
2477static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2478{
2479 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2480 struct sigmatel_spec *spec = codec->spec;
2481 hda_nid_t nid = kcontrol->private_value >> 8;
2482 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002483 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002484
2485 spec->io_switch[io_idx] = val;
2486
2487 if (val)
2488 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002489 else {
2490 unsigned int pinctl = AC_PINCTL_IN_EN;
2491 if (io_idx) /* set VREF for mic */
2492 pinctl |= stac92xx_get_vref(codec, nid);
2493 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2494 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002495
2496 /* check the auto-mute again: we need to mute/unmute the speaker
2497 * appropriately according to the pin direction
2498 */
2499 if (spec->hp_detect)
2500 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2501
Matt Porter403d1942005-11-29 15:00:51 +01002502 return 1;
2503}
2504
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002505#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2506
2507static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2508 struct snd_ctl_elem_value *ucontrol)
2509{
2510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2511 struct sigmatel_spec *spec = codec->spec;
2512
2513 ucontrol->value.integer.value[0] = spec->clfe_swap;
2514 return 0;
2515}
2516
2517static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2518 struct snd_ctl_elem_value *ucontrol)
2519{
2520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2521 struct sigmatel_spec *spec = codec->spec;
2522 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002523 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002524
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002525 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002526 return 0;
2527
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002528 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002529
2530 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2531 spec->clfe_swap ? 0x4 : 0x0);
2532
2533 return 1;
2534}
2535
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002536#define STAC_CODEC_HP_SWITCH(xname) \
2537 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2538 .name = xname, \
2539 .index = 0, \
2540 .info = stac92xx_hp_switch_info, \
2541 .get = stac92xx_hp_switch_get, \
2542 .put = stac92xx_hp_switch_put, \
2543 }
2544
Matt Porter403d1942005-11-29 15:00:51 +01002545#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2546 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2547 .name = xname, \
2548 .index = 0, \
2549 .info = stac92xx_io_switch_info, \
2550 .get = stac92xx_io_switch_get, \
2551 .put = stac92xx_io_switch_put, \
2552 .private_value = xpval, \
2553 }
2554
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002555#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2556 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2557 .name = xname, \
2558 .index = 0, \
2559 .info = stac92xx_clfe_switch_info, \
2560 .get = stac92xx_clfe_switch_get, \
2561 .put = stac92xx_clfe_switch_put, \
2562 .private_value = xpval, \
2563 }
Matt Porter403d1942005-11-29 15:00:51 +01002564
Mattc7d4b2f2005-06-27 14:59:41 +02002565enum {
2566 STAC_CTL_WIDGET_VOL,
2567 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002568 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002569 STAC_CTL_WIDGET_AMP_MUX,
2570 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002571 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002572 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002573 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002574};
2575
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002576static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002577 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2578 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002579 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002580 STAC_AMP_MUX,
2581 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002582 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002583 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002584 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002585};
2586
2587/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002588static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2589 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002590{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002591 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002592
2593 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2594 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2595
2596 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2597 if (! knew)
2598 return -ENOMEM;
2599 if (spec->kctl_alloc) {
2600 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2601 kfree(spec->kctl_alloc);
2602 }
2603 spec->kctl_alloc = knew;
2604 spec->num_kctl_alloc = num;
2605 }
2606
2607 knew = &spec->kctl_alloc[spec->num_kctl_used];
2608 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002609 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002610 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002611 if (! knew->name)
2612 return -ENOMEM;
2613 knew->private_value = val;
2614 spec->num_kctl_used++;
2615 return 0;
2616}
2617
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002618
2619/* add dynamic controls */
2620static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2621 const char *name, unsigned long val)
2622{
2623 return stac92xx_add_control_idx(spec, type, 0, name, val);
2624}
2625
Matt Porter403d1942005-11-29 15:00:51 +01002626/* flag inputs as additional dynamic lineouts */
2627static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2628{
2629 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002630 unsigned int wcaps, wtype;
2631 int i, num_dacs = 0;
2632
2633 /* use the wcaps cache to count all DACs available for line-outs */
2634 for (i = 0; i < codec->num_nodes; i++) {
2635 wcaps = codec->wcaps[i];
2636 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002637
Steve Longerbeam7b043892007-05-03 20:50:03 +02002638 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2639 num_dacs++;
2640 }
Matt Porter403d1942005-11-29 15:00:51 +01002641
Steve Longerbeam7b043892007-05-03 20:50:03 +02002642 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2643
Matt Porter403d1942005-11-29 15:00:51 +01002644 switch (cfg->line_outs) {
2645 case 3:
2646 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002647 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002648 cfg->line_out_pins[cfg->line_outs] =
2649 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002650 spec->line_switch = 1;
2651 cfg->line_outs++;
2652 }
2653 break;
2654 case 2:
2655 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002656 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002657 cfg->line_out_pins[cfg->line_outs] =
2658 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002659 spec->line_switch = 1;
2660 cfg->line_outs++;
2661 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002662 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002663 cfg->line_out_pins[cfg->line_outs] =
2664 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002665 spec->mic_switch = 1;
2666 cfg->line_outs++;
2667 }
2668 break;
2669 case 1:
2670 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002671 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002672 cfg->line_out_pins[cfg->line_outs] =
2673 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002674 spec->line_switch = 1;
2675 cfg->line_outs++;
2676 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002677 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002678 cfg->line_out_pins[cfg->line_outs] =
2679 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002680 spec->mic_switch = 1;
2681 cfg->line_outs++;
2682 }
2683 break;
2684 }
2685
2686 return 0;
2687}
2688
Steve Longerbeam7b043892007-05-03 20:50:03 +02002689
2690static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2691{
2692 int i;
2693
2694 for (i = 0; i < spec->multiout.num_dacs; i++) {
2695 if (spec->multiout.dac_nids[i] == nid)
2696 return 1;
2697 }
2698
2699 return 0;
2700}
2701
Matt Porter3cc08dc2006-01-23 15:27:49 +01002702/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002703 * Fill in the dac_nids table from the parsed pin configuration
2704 * This function only works when every pin in line_out_pins[]
2705 * contains atleast one DAC in its connection list. Some 92xx
2706 * codecs are not connected directly to a DAC, such as the 9200
2707 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002708 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002709static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002710 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002711{
2712 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002713 int i, j, conn_len = 0;
2714 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2715 unsigned int wcaps, wtype;
2716
Mattc7d4b2f2005-06-27 14:59:41 +02002717 for (i = 0; i < cfg->line_outs; i++) {
2718 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002719 conn_len = snd_hda_get_connections(codec, nid, conn,
2720 HDA_MAX_CONNECTIONS);
2721 for (j = 0; j < conn_len; j++) {
2722 wcaps = snd_hda_param_read(codec, conn[j],
2723 AC_PAR_AUDIO_WIDGET_CAP);
2724 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002725 if (wtype != AC_WID_AUD_OUT ||
2726 (wcaps & AC_WCAP_DIGITAL))
2727 continue;
2728 /* conn[j] is a DAC routed to this line-out */
2729 if (!is_in_dac_nids(spec, conn[j]))
2730 break;
2731 }
2732
2733 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002734 if (spec->multiout.num_dacs > 0) {
2735 /* we have already working output pins,
2736 * so let's drop the broken ones again
2737 */
2738 cfg->line_outs = spec->multiout.num_dacs;
2739 break;
2740 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002741 /* error out, no available DAC found */
2742 snd_printk(KERN_ERR
2743 "%s: No available DAC for pin 0x%x\n",
2744 __func__, nid);
2745 return -ENODEV;
2746 }
2747
2748 spec->multiout.dac_nids[i] = conn[j];
2749 spec->multiout.num_dacs++;
2750 if (conn_len > 1) {
2751 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002752 snd_hda_codec_write_cache(codec, nid, 0,
2753 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002754
2755 }
Mattc7d4b2f2005-06-27 14:59:41 +02002756 }
2757
Steve Longerbeam7b043892007-05-03 20:50:03 +02002758 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2759 spec->multiout.num_dacs,
2760 spec->multiout.dac_nids[0],
2761 spec->multiout.dac_nids[1],
2762 spec->multiout.dac_nids[2],
2763 spec->multiout.dac_nids[3],
2764 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002765 return 0;
2766}
2767
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002768/* create volume control/switch for the given prefx type */
2769static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2770{
2771 char name[32];
2772 int err;
2773
2774 sprintf(name, "%s Playback Volume", pfx);
2775 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2776 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2777 if (err < 0)
2778 return err;
2779 sprintf(name, "%s Playback Switch", pfx);
2780 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2781 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2782 if (err < 0)
2783 return err;
2784 return 0;
2785}
2786
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002787static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2788{
2789 if (!spec->multiout.hp_nid)
2790 spec->multiout.hp_nid = nid;
2791 else if (spec->multiout.num_dacs > 4) {
2792 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2793 return 1;
2794 } else {
2795 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2796 spec->multiout.num_dacs++;
2797 }
2798 return 0;
2799}
2800
2801static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2802{
2803 if (is_in_dac_nids(spec, nid))
2804 return 1;
2805 if (spec->multiout.hp_nid == nid)
2806 return 1;
2807 return 0;
2808}
2809
Mattc7d4b2f2005-06-27 14:59:41 +02002810/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002811static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002812 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002813{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002814 static const char *chname[4] = {
2815 "Front", "Surround", NULL /*CLFE*/, "Side"
2816 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002817 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002818 int i, err;
2819
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002820 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002821 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002822
2823
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002824 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002825 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002826 continue;
2827
2828 nid = spec->multiout.dac_nids[i];
2829
2830 if (i == 2) {
2831 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002832 err = create_controls(spec, "Center", nid, 1);
2833 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002834 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002835 err = create_controls(spec, "LFE", nid, 2);
2836 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002837 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002838
2839 wid_caps = get_wcaps(codec, nid);
2840
2841 if (wid_caps & AC_WCAP_LR_SWAP) {
2842 err = stac92xx_add_control(spec,
2843 STAC_CTL_WIDGET_CLFE_SWITCH,
2844 "Swap Center/LFE Playback Switch", nid);
2845
2846 if (err < 0)
2847 return err;
2848 }
2849
Mattc7d4b2f2005-06-27 14:59:41 +02002850 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002851 err = create_controls(spec, chname[i], nid, 3);
2852 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002853 return err;
2854 }
2855 }
2856
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002857 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2858 cfg->hp_outs && !spec->multiout.hp_nid)
2859 spec->multiout.hp_nid = nid;
2860
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002861 if (cfg->hp_outs > 1) {
2862 err = stac92xx_add_control(spec,
2863 STAC_CTL_WIDGET_HP_SWITCH,
2864 "Headphone as Line Out Switch", 0);
2865 if (err < 0)
2866 return err;
2867 }
2868
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002869 if (spec->line_switch) {
2870 nid = cfg->input_pins[AUTO_PIN_LINE];
2871 pincap = snd_hda_param_read(codec, nid,
2872 AC_PAR_PIN_CAP);
2873 if (pincap & AC_PINCAP_OUT) {
2874 err = stac92xx_add_control(spec,
2875 STAC_CTL_WIDGET_IO_SWITCH,
2876 "Line In as Output Switch", nid << 8);
2877 if (err < 0)
2878 return err;
2879 }
2880 }
Matt Porter403d1942005-11-29 15:00:51 +01002881
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002882 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002883 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002884 unsigned int mic_pin = AUTO_PIN_MIC;
2885again:
2886 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002887 def_conf = snd_hda_codec_read(codec, nid, 0,
2888 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002889 /* some laptops have an internal analog microphone
2890 * which can't be used as a output */
2891 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2892 pincap = snd_hda_param_read(codec, nid,
2893 AC_PAR_PIN_CAP);
2894 if (pincap & AC_PINCAP_OUT) {
2895 err = stac92xx_add_control(spec,
2896 STAC_CTL_WIDGET_IO_SWITCH,
2897 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002898 nid = snd_hda_codec_read(codec, nid, 0,
2899 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2900 if (!check_in_dac_nids(spec, nid))
2901 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002902 if (err < 0)
2903 return err;
2904 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002905 } else if (mic_pin == AUTO_PIN_MIC) {
2906 mic_pin = AUTO_PIN_FRONT_MIC;
2907 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002908 }
2909 }
Matt Porter403d1942005-11-29 15:00:51 +01002910
Mattc7d4b2f2005-06-27 14:59:41 +02002911 return 0;
2912}
2913
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002914/* add playback controls for Speaker and HP outputs */
2915static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2916 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002917{
2918 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002919 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002920 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002921
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002922 old_num_dacs = spec->multiout.num_dacs;
2923 for (i = 0; i < cfg->hp_outs; i++) {
2924 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2925 if (wid_caps & AC_WCAP_UNSOL_CAP)
2926 spec->hp_detect = 1;
2927 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2928 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2929 if (check_in_dac_nids(spec, nid))
2930 nid = 0;
2931 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002932 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002933 add_spec_dacs(spec, nid);
2934 }
2935 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002936 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002937 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2938 if (check_in_dac_nids(spec, nid))
2939 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002940 if (! nid)
2941 continue;
2942 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002943 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002944 for (i = 0; i < cfg->line_outs; i++) {
2945 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2946 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2947 if (check_in_dac_nids(spec, nid))
2948 nid = 0;
2949 if (! nid)
2950 continue;
2951 add_spec_dacs(spec, nid);
2952 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002953 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2954 static const char *pfxs[] = {
2955 "Speaker", "External Speaker", "Speaker2",
2956 };
2957 err = create_controls(spec, pfxs[i - old_num_dacs],
2958 spec->multiout.dac_nids[i], 3);
2959 if (err < 0)
2960 return err;
2961 }
2962 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002963 err = create_controls(spec, "Headphone",
2964 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002965 if (err < 0)
2966 return err;
2967 }
Mattc7d4b2f2005-06-27 14:59:41 +02002968
2969 return 0;
2970}
2971
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002972/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002973static const char *stac92xx_mono_labels[4] = {
2974 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002975};
2976
2977/* create mono mux for mono out on capable codecs */
2978static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2979{
2980 struct sigmatel_spec *spec = codec->spec;
2981 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2982 int i, num_cons;
2983 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2984
2985 num_cons = snd_hda_get_connections(codec,
2986 spec->mono_nid,
2987 con_lst,
2988 HDA_MAX_NUM_INPUTS);
2989 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2990 return -EINVAL;
2991
2992 for (i = 0; i < num_cons; i++) {
2993 mono_mux->items[mono_mux->num_items].label =
2994 stac92xx_mono_labels[i];
2995 mono_mux->items[mono_mux->num_items].index = i;
2996 mono_mux->num_items++;
2997 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002998
2999 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3000 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003001}
3002
Matthew Ranostay89385032008-09-11 09:49:39 -04003003/* labels for amp mux outputs */
3004static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003005 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003006};
3007
3008/* create amp out controls mux on capable codecs */
3009static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3010{
3011 struct sigmatel_spec *spec = codec->spec;
3012 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3013 int i, err;
3014
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003015 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003016 amp_mux->items[amp_mux->num_items].label =
3017 stac92xx_amp_labels[i];
3018 amp_mux->items[amp_mux->num_items].index = i;
3019 amp_mux->num_items++;
3020 }
3021
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003022 if (spec->num_amps > 1) {
3023 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3024 "Amp Selector Capture Switch", 0);
3025 if (err < 0)
3026 return err;
3027 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003028 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3029 "Amp Capture Volume",
3030 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3031}
3032
3033
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003034/* create PC beep volume controls */
3035static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3036 hda_nid_t nid)
3037{
3038 struct sigmatel_spec *spec = codec->spec;
3039 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3040 int err;
3041
3042 /* check for mute support for the the amp */
3043 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3044 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3045 "PC Beep Playback Switch",
3046 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3047 if (err < 0)
3048 return err;
3049 }
3050
3051 /* check to see if there is volume support for the amp */
3052 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3053 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3054 "PC Beep Playback Volume",
3055 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3056 if (err < 0)
3057 return err;
3058 }
3059 return 0;
3060}
3061
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003062static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3063{
3064 struct sigmatel_spec *spec = codec->spec;
3065 int wcaps, nid, i, err = 0;
3066
3067 for (i = 0; i < spec->num_muxes; i++) {
3068 nid = spec->mux_nids[i];
3069 wcaps = get_wcaps(codec, nid);
3070
3071 if (wcaps & AC_WCAP_OUT_AMP) {
3072 err = stac92xx_add_control_idx(spec,
3073 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3074 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3075 if (err < 0)
3076 return err;
3077 }
3078 }
3079 return 0;
3080};
3081
Matthew Ranostayd9737752008-09-07 12:03:41 +02003082static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003083 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003084};
3085
3086static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3087{
3088 struct sigmatel_spec *spec = codec->spec;
3089 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003090 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003091 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003092 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003093
3094 num_cons = snd_hda_get_connections(codec,
3095 spec->smux_nids[0],
3096 con_lst,
3097 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003098 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003099 return -EINVAL;
3100
Matthew Ranostay65973632008-09-16 10:39:37 -04003101 if (!labels)
3102 labels = stac92xx_spdif_labels;
3103
Matthew Ranostayd9737752008-09-07 12:03:41 +02003104 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003105 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003106 spdif_mux->items[spdif_mux->num_items].index = i;
3107 spdif_mux->num_items++;
3108 }
3109
3110 return 0;
3111}
3112
Matt Porter8b657272006-10-26 17:12:59 +02003113/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003114static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003115 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3116 "Digital Mic 3", "Digital Mic 4"
3117};
3118
3119/* create playback/capture controls for input pins on dmic capable codecs */
3120static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3121 const struct auto_pin_cfg *cfg)
3122{
3123 struct sigmatel_spec *spec = codec->spec;
3124 struct hda_input_mux *dimux = &spec->private_dimux;
3125 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003126 int err, i, j;
3127 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003128
3129 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3130 dimux->items[dimux->num_items].index = 0;
3131 dimux->num_items++;
3132
3133 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003134 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003135 int index;
3136 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003137 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003138 unsigned int def_conf;
3139
3140 def_conf = snd_hda_codec_read(codec,
3141 spec->dmic_nids[i],
3142 0,
3143 AC_VERB_GET_CONFIG_DEFAULT,
3144 0);
3145 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3146 continue;
3147
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003148 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003149 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003150 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003151 con_lst,
3152 HDA_MAX_NUM_INPUTS);
3153 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003154 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003155 index = j;
3156 goto found;
3157 }
3158 continue;
3159found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003160 wcaps = get_wcaps(codec, nid) &
3161 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003162
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003163 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003164 sprintf(name, "%s Capture Volume",
3165 stac92xx_dmic_labels[dimux->num_items]);
3166
3167 err = stac92xx_add_control(spec,
3168 STAC_CTL_WIDGET_VOL,
3169 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003170 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3171 (wcaps & AC_WCAP_OUT_AMP) ?
3172 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003173 if (err < 0)
3174 return err;
3175 }
3176
Matt Porter8b657272006-10-26 17:12:59 +02003177 dimux->items[dimux->num_items].label =
3178 stac92xx_dmic_labels[dimux->num_items];
3179 dimux->items[dimux->num_items].index = index;
3180 dimux->num_items++;
3181 }
3182
3183 return 0;
3184}
3185
Mattc7d4b2f2005-06-27 14:59:41 +02003186/* create playback/capture controls for input pins */
3187static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3188{
3189 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003190 struct hda_input_mux *imux = &spec->private_imux;
3191 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3192 int i, j, k;
3193
3194 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003195 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003196
Takashi Iwai314634b2006-09-21 11:56:18 +02003197 if (!cfg->input_pins[i])
3198 continue;
3199 index = -1;
3200 for (j = 0; j < spec->num_muxes; j++) {
3201 int num_cons;
3202 num_cons = snd_hda_get_connections(codec,
3203 spec->mux_nids[j],
3204 con_lst,
3205 HDA_MAX_NUM_INPUTS);
3206 for (k = 0; k < num_cons; k++)
3207 if (con_lst[k] == cfg->input_pins[i]) {
3208 index = k;
3209 goto found;
3210 }
Mattc7d4b2f2005-06-27 14:59:41 +02003211 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003212 continue;
3213 found:
3214 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3215 imux->items[imux->num_items].index = index;
3216 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003217 }
3218
Steve Longerbeam7b043892007-05-03 20:50:03 +02003219 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003220 /*
3221 * Set the current input for the muxes.
3222 * The STAC9221 has two input muxes with identical source
3223 * NID lists. Hopefully this won't get confused.
3224 */
3225 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003226 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3227 AC_VERB_SET_CONNECT_SEL,
3228 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003229 }
3230 }
3231
Mattc7d4b2f2005-06-27 14:59:41 +02003232 return 0;
3233}
3234
Mattc7d4b2f2005-06-27 14:59:41 +02003235static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3236{
3237 struct sigmatel_spec *spec = codec->spec;
3238 int i;
3239
3240 for (i = 0; i < spec->autocfg.line_outs; i++) {
3241 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3242 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3243 }
3244}
3245
3246static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3247{
3248 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003249 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003250
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003251 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3252 hda_nid_t pin;
3253 pin = spec->autocfg.hp_pins[i];
3254 if (pin) /* connect to front */
3255 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3256 }
3257 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3258 hda_nid_t pin;
3259 pin = spec->autocfg.speaker_pins[i];
3260 if (pin) /* connect to front */
3261 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3262 }
Mattc7d4b2f2005-06-27 14:59:41 +02003263}
3264
Matt Porter3cc08dc2006-01-23 15:27:49 +01003265static 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 +02003266{
3267 struct sigmatel_spec *spec = codec->spec;
3268 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003269 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003270
Matt Porter8b657272006-10-26 17:12:59 +02003271 if ((err = snd_hda_parse_pin_def_config(codec,
3272 &spec->autocfg,
3273 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003274 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003275 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003276 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003277
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003278 /* If we have no real line-out pin and multiple hp-outs, HPs should
3279 * be set up as multi-channel outputs.
3280 */
3281 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3282 spec->autocfg.hp_outs > 1) {
3283 /* Copy hp_outs to line_outs, backup line_outs in
3284 * speaker_outs so that the following routines can handle
3285 * HP pins as primary outputs.
3286 */
3287 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3288 sizeof(spec->autocfg.line_out_pins));
3289 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3290 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3291 sizeof(spec->autocfg.hp_pins));
3292 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3293 hp_speaker_swap = 1;
3294 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003295 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003296 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3297 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003298 u32 caps = query_amp_caps(codec,
3299 spec->autocfg.mono_out_pin, dir);
3300 hda_nid_t conn_list[1];
3301
3302 /* get the mixer node and then the mono mux if it exists */
3303 if (snd_hda_get_connections(codec,
3304 spec->autocfg.mono_out_pin, conn_list, 1) &&
3305 snd_hda_get_connections(codec, conn_list[0],
3306 conn_list, 1)) {
3307
3308 int wcaps = get_wcaps(codec, conn_list[0]);
3309 int wid_type = (wcaps & AC_WCAP_TYPE)
3310 >> AC_WCAP_TYPE_SHIFT;
3311 /* LR swap check, some stac925x have a mux that
3312 * changes the DACs output path instead of the
3313 * mono-mux path.
3314 */
3315 if (wid_type == AC_WID_AUD_SEL &&
3316 !(wcaps & AC_WCAP_LR_SWAP))
3317 spec->mono_nid = conn_list[0];
3318 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003319 if (dir) {
3320 hda_nid_t nid = spec->autocfg.mono_out_pin;
3321
3322 /* most mono outs have a least a mute/unmute switch */
3323 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3324 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3325 "Mono Playback Switch",
3326 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003327 if (err < 0)
3328 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003329 /* check for volume support for the amp */
3330 if ((caps & AC_AMPCAP_NUM_STEPS)
3331 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3332 err = stac92xx_add_control(spec,
3333 STAC_CTL_WIDGET_VOL,
3334 "Mono Playback Volume",
3335 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3336 if (err < 0)
3337 return err;
3338 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003339 }
3340
3341 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3342 AC_PINCTL_OUT_EN);
3343 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003344
Matt Porter403d1942005-11-29 15:00:51 +01003345 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3346 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003347 if (spec->multiout.num_dacs == 0)
3348 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3349 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003350
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003351 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3352
3353 if (err < 0)
3354 return err;
3355
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003356 /* setup analog beep controls */
3357 if (spec->anabeep_nid > 0) {
3358 err = stac92xx_auto_create_beep_ctls(codec,
3359 spec->anabeep_nid);
3360 if (err < 0)
3361 return err;
3362 }
3363
3364 /* setup digital beep controls and input device */
3365#ifdef CONFIG_SND_HDA_INPUT_BEEP
3366 if (spec->digbeep_nid > 0) {
3367 hda_nid_t nid = spec->digbeep_nid;
3368
3369 err = stac92xx_auto_create_beep_ctls(codec, nid);
3370 if (err < 0)
3371 return err;
3372 err = snd_hda_attach_beep_device(codec, nid);
3373 if (err < 0)
3374 return err;
3375 }
3376#endif
3377
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003378 if (hp_speaker_swap == 1) {
3379 /* Restore the hp_outs and line_outs */
3380 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3381 sizeof(spec->autocfg.line_out_pins));
3382 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3383 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3384 sizeof(spec->autocfg.speaker_pins));
3385 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3386 memset(spec->autocfg.speaker_pins, 0,
3387 sizeof(spec->autocfg.speaker_pins));
3388 spec->autocfg.speaker_outs = 0;
3389 }
3390
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003391 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3392
3393 if (err < 0)
3394 return err;
3395
3396 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3397
3398 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003399 return err;
3400
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003401 if (spec->mono_nid > 0) {
3402 err = stac92xx_auto_create_mono_output_ctls(codec);
3403 if (err < 0)
3404 return err;
3405 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003406 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003407 err = stac92xx_auto_create_amp_output_ctls(codec);
3408 if (err < 0)
3409 return err;
3410 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003411 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003412 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3413 &spec->autocfg)) < 0)
3414 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003415 if (spec->num_muxes > 0) {
3416 err = stac92xx_auto_create_mux_input_ctls(codec);
3417 if (err < 0)
3418 return err;
3419 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003420 if (spec->num_smuxes > 0) {
3421 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3422 if (err < 0)
3423 return err;
3424 }
Matt Porter8b657272006-10-26 17:12:59 +02003425
Mattc7d4b2f2005-06-27 14:59:41 +02003426 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003427 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003428 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003429
Takashi Iwai82bc9552006-03-21 11:24:42 +01003430 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003431 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003432 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003433 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003434
3435 if (spec->kctl_alloc)
3436 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3437
3438 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003439 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003440 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003441 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003442 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003443 return 1;
3444}
3445
Takashi Iwai82bc9552006-03-21 11:24:42 +01003446/* add playback controls for HP output */
3447static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3448 struct auto_pin_cfg *cfg)
3449{
3450 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003451 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003452 unsigned int wid_caps;
3453
3454 if (! pin)
3455 return 0;
3456
3457 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003458 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003459 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003460
3461 return 0;
3462}
3463
Richard Fish160ea0d2006-09-06 13:58:25 +02003464/* add playback controls for LFE output */
3465static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3466 struct auto_pin_cfg *cfg)
3467{
3468 struct sigmatel_spec *spec = codec->spec;
3469 int err;
3470 hda_nid_t lfe_pin = 0x0;
3471 int i;
3472
3473 /*
3474 * search speaker outs and line outs for a mono speaker pin
3475 * with an amp. If one is found, add LFE controls
3476 * for it.
3477 */
3478 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3479 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003480 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003481 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3482 if (wcaps == AC_WCAP_OUT_AMP)
3483 /* found a mono speaker with an amp, must be lfe */
3484 lfe_pin = pin;
3485 }
3486
3487 /* if speaker_outs is 0, then speakers may be in line_outs */
3488 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3489 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3490 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003491 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003492 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003493 AC_VERB_GET_CONFIG_DEFAULT,
3494 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003495 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003496 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003497 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3498 if (wcaps == AC_WCAP_OUT_AMP)
3499 /* found a mono speaker with an amp,
3500 must be lfe */
3501 lfe_pin = pin;
3502 }
3503 }
3504 }
3505
3506 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003507 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003508 if (err < 0)
3509 return err;
3510 }
3511
3512 return 0;
3513}
3514
Mattc7d4b2f2005-06-27 14:59:41 +02003515static int stac9200_parse_auto_config(struct hda_codec *codec)
3516{
3517 struct sigmatel_spec *spec = codec->spec;
3518 int err;
3519
Kailang Yangdf694da2005-12-05 19:42:22 +01003520 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003521 return err;
3522
3523 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3524 return err;
3525
Takashi Iwai82bc9552006-03-21 11:24:42 +01003526 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3527 return err;
3528
Richard Fish160ea0d2006-09-06 13:58:25 +02003529 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3530 return err;
3531
Takashi Iwai82bc9552006-03-21 11:24:42 +01003532 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003533 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003534 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003535 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003536
3537 if (spec->kctl_alloc)
3538 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3539
3540 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003541 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003542
3543 return 1;
3544}
3545
Sam Revitch62fe78e2006-05-10 15:09:17 +02003546/*
3547 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3548 * funky external mute control using GPIO pins.
3549 */
3550
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003551static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003552 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003553{
3554 unsigned int gpiostate, gpiomask, gpiodir;
3555
3556 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3557 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003558 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003559
3560 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3561 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003562 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003563
3564 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3565 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003566 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003567
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003568 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003569 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3570
3571 snd_hda_codec_write(codec, codec->afg, 0,
3572 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003573 snd_hda_codec_read(codec, codec->afg, 0,
3574 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003575
3576 msleep(1);
3577
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003578 snd_hda_codec_read(codec, codec->afg, 0,
3579 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003580}
3581
Takashi Iwai314634b2006-09-21 11:56:18 +02003582static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3583 unsigned int event)
3584{
3585 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003586 snd_hda_codec_write_cache(codec, nid, 0,
3587 AC_VERB_SET_UNSOLICITED_ENABLE,
3588 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003589}
3590
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003591static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3592{
3593 int i;
3594 for (i = 0; i < cfg->hp_outs; i++)
3595 if (cfg->hp_pins[i] == nid)
3596 return 1; /* nid is a HP-Out */
3597
3598 return 0; /* nid is not a HP-Out */
3599};
3600
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003601static void stac92xx_power_down(struct hda_codec *codec)
3602{
3603 struct sigmatel_spec *spec = codec->spec;
3604
3605 /* power down inactive DACs */
3606 hda_nid_t *dac;
3607 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003608 if (!is_in_dac_nids(spec, *dac) &&
3609 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003610 snd_hda_codec_write_cache(codec, *dac, 0,
3611 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3612}
3613
Mattc7d4b2f2005-06-27 14:59:41 +02003614static int stac92xx_init(struct hda_codec *codec)
3615{
3616 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003617 struct auto_pin_cfg *cfg = &spec->autocfg;
3618 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003619
Mattc7d4b2f2005-06-27 14:59:41 +02003620 snd_hda_sequence_write(codec, spec->init);
3621
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003622 /* power down adcs initially */
3623 if (spec->powerdown_adcs)
3624 for (i = 0; i < spec->num_adcs; i++)
3625 snd_hda_codec_write_cache(codec,
3626 spec->adc_nids[i], 0,
3627 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003628 /* set up pins */
3629 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003630 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003631 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003632 enable_pin_detect(codec, cfg->hp_pins[i],
3633 STAC_HP_EVENT);
Takashi Iwai0a07aca2007-03-13 10:40:23 +01003634 /* force to enable the first line-out; the others are set up
3635 * in unsol_event
3636 */
3637 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3638 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003639 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003640 /* fake event to set up pins */
3641 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3642 } else {
3643 stac92xx_auto_init_multi_out(codec);
3644 stac92xx_auto_init_hp_out(codec);
3645 }
3646 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003647 hda_nid_t nid = cfg->input_pins[i];
3648 if (nid) {
Matthew Ranostayb9aea712008-10-09 08:37:28 -04003649 unsigned int pinctl = snd_hda_codec_read(codec, nid,
3650 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3651 /* if PINCTL already set then skip */
3652 if (pinctl & AC_PINCAP_IN)
3653 continue;
3654 pinctl = AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003655 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3656 pinctl |= stac92xx_get_vref(codec, nid);
3657 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3658 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003659 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003660 for (i = 0; i < spec->num_dmics; i++)
3661 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3662 AC_PINCTL_IN_EN);
3663 for (i = 0; i < spec->num_pwrs; i++) {
3664 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3665 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3666 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3667 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003668 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3669 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003670 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003671 /* outputs are only ports capable of power management
3672 * any attempts on powering down a input port cause the
3673 * referenced VREF to act quirky.
3674 */
3675 if (pinctl & AC_PINCTL_IN_EN)
3676 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003677 /* skip any ports that don't have jacks since presence
3678 * detection is useless */
3679 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003680 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003681 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3682 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3683 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003684 if (spec->dac_list)
3685 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003686 if (cfg->dig_out_pin)
3687 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3688 AC_PINCTL_OUT_EN);
3689 if (cfg->dig_in_pin)
3690 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3691 AC_PINCTL_IN_EN);
3692
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003693 stac_gpio_set(codec, spec->gpio_mask,
3694 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003695
Mattc7d4b2f2005-06-27 14:59:41 +02003696 return 0;
3697}
3698
Matt2f2f4252005-04-13 14:45:30 +02003699static void stac92xx_free(struct hda_codec *codec)
3700{
Mattc7d4b2f2005-06-27 14:59:41 +02003701 struct sigmatel_spec *spec = codec->spec;
3702 int i;
3703
3704 if (! spec)
3705 return;
3706
3707 if (spec->kctl_alloc) {
3708 for (i = 0; i < spec->num_kctl_used; i++)
3709 kfree(spec->kctl_alloc[i].name);
3710 kfree(spec->kctl_alloc);
3711 }
3712
Richard Fish11b44bb2006-08-23 18:31:34 +02003713 if (spec->bios_pin_configs)
3714 kfree(spec->bios_pin_configs);
3715
Mattc7d4b2f2005-06-27 14:59:41 +02003716 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003717 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003718}
3719
Matt4e550962005-07-04 17:51:39 +02003720static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3721 unsigned int flag)
3722{
3723 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3724 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003725
Takashi Iwaif9acba42007-05-29 18:01:06 +02003726 if (pin_ctl & AC_PINCTL_IN_EN) {
3727 /*
3728 * we need to check the current set-up direction of
3729 * shared input pins since they can be switched via
3730 * "xxx as Output" mixer switch
3731 */
3732 struct sigmatel_spec *spec = codec->spec;
3733 struct auto_pin_cfg *cfg = &spec->autocfg;
3734 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3735 spec->line_switch) ||
3736 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3737 spec->mic_switch))
3738 return;
3739 }
3740
Steve Longerbeam7b043892007-05-03 20:50:03 +02003741 /* if setting pin direction bits, clear the current
3742 direction bits first */
3743 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3744 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3745
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003746 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003747 AC_VERB_SET_PIN_WIDGET_CONTROL,
3748 pin_ctl | flag);
3749}
3750
3751static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3752 unsigned int flag)
3753{
3754 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3755 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003756 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003757 AC_VERB_SET_PIN_WIDGET_CONTROL,
3758 pin_ctl & ~flag);
3759}
3760
Jiang Zhe40c1d302007-11-12 13:05:16 +01003761static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003762{
3763 if (!nid)
3764 return 0;
3765 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003766 & (1 << 31)) {
3767 unsigned int pinctl;
3768 pinctl = snd_hda_codec_read(codec, nid, 0,
3769 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3770 if (pinctl & AC_PINCTL_IN_EN)
3771 return 0; /* mic- or line-input */
3772 else
3773 return 1; /* HP-output */
3774 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003775 return 0;
3776}
3777
3778static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003779{
3780 struct sigmatel_spec *spec = codec->spec;
3781 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003782 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003783 int i, presence;
3784
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003785 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003786 if (spec->gpio_mute)
3787 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3788 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3789
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003790 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003791 if (presence)
3792 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003793 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3794 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003795 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003796 }
Matt4e550962005-07-04 17:51:39 +02003797
3798 if (presence) {
3799 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003800 if (spec->hp_switch)
3801 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003802 for (i = 0; i < cfg->line_outs; i++)
3803 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3804 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003805 for (i = 0; i < cfg->speaker_outs; i++)
3806 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3807 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003808 if (spec->eapd_mask)
3809 stac_gpio_set(codec, spec->gpio_mask,
3810 spec->gpio_dir, spec->gpio_data &
3811 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003812 } else {
3813 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003814 if (spec->hp_switch)
3815 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003816 for (i = 0; i < cfg->line_outs; i++)
3817 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3818 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003819 for (i = 0; i < cfg->speaker_outs; i++)
3820 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3821 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003822 if (spec->eapd_mask)
3823 stac_gpio_set(codec, spec->gpio_mask,
3824 spec->gpio_dir, spec->gpio_data |
3825 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003826 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003827 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3828 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003829}
3830
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003831static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3832{
3833 struct sigmatel_spec *spec = codec->spec;
3834 hda_nid_t nid = spec->pwr_nids[idx];
3835 int presence, val;
3836 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3837 & 0x000000ff;
3838 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003839
3840 /* several codecs have two power down bits */
3841 if (spec->pwr_mapping)
3842 idx = spec->pwr_mapping[idx];
3843 else
3844 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003845
3846 if (presence)
3847 val &= ~idx;
3848 else
3849 val |= idx;
3850
3851 /* power down unused output ports */
3852 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3853};
3854
Takashi Iwai314634b2006-09-21 11:56:18 +02003855static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3856{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003857 struct sigmatel_spec *spec = codec->spec;
3858 int idx = res >> 26 & 0x0f;
3859
Matthew Ranostay72474be2008-10-09 09:32:17 -04003860 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003861 case STAC_HP_EVENT:
3862 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003863 /* fallthru */
3864 case STAC_PWR_EVENT:
3865 if (spec->num_pwrs > 0)
3866 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04003867 break;
3868 case STAC_VREF_EVENT: {
3869 int data = snd_hda_codec_read(codec, codec->afg, 0,
3870 AC_VERB_GET_GPIO_DATA, 0);
3871 /* toggle VREF state based on GPIOx status */
3872 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
3873 !!(data & (1 << idx)));
3874 break;
3875 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003876 }
3877}
3878
Takashi Iwaicb53c622007-08-10 17:21:45 +02003879#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003880static int stac92xx_resume(struct hda_codec *codec)
3881{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003882 struct sigmatel_spec *spec = codec->spec;
3883
Richard Fish11b44bb2006-08-23 18:31:34 +02003884 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003885 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003886 stac_gpio_set(codec, spec->gpio_mask,
3887 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003888 snd_hda_codec_resume_amp(codec);
3889 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003890 /* power down inactive DACs */
3891 if (spec->dac_list)
3892 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003893 /* invoke unsolicited event to reset the HP state */
3894 if (spec->hp_detect)
3895 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003896 return 0;
3897}
3898#endif
3899
Matt2f2f4252005-04-13 14:45:30 +02003900static struct hda_codec_ops stac92xx_patch_ops = {
3901 .build_controls = stac92xx_build_controls,
3902 .build_pcms = stac92xx_build_pcms,
3903 .init = stac92xx_init,
3904 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003905 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003906#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003907 .resume = stac92xx_resume,
3908#endif
Matt2f2f4252005-04-13 14:45:30 +02003909};
3910
3911static int patch_stac9200(struct hda_codec *codec)
3912{
3913 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003914 int err;
Matt2f2f4252005-04-13 14:45:30 +02003915
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003916 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003917 if (spec == NULL)
3918 return -ENOMEM;
3919
3920 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003921 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003922 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003923 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3924 stac9200_models,
3925 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003926 if (spec->board_config < 0) {
3927 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3928 err = stac92xx_save_bios_config_regs(codec);
3929 if (err < 0) {
3930 stac92xx_free(codec);
3931 return err;
3932 }
3933 spec->pin_configs = spec->bios_pin_configs;
3934 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003935 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3936 stac92xx_set_config_regs(codec);
3937 }
Matt2f2f4252005-04-13 14:45:30 +02003938
3939 spec->multiout.max_channels = 2;
3940 spec->multiout.num_dacs = 1;
3941 spec->multiout.dac_nids = stac9200_dac_nids;
3942 spec->adc_nids = stac9200_adc_nids;
3943 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003944 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003945 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003946 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003947 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003948
Tobin Davisbf277782008-02-03 20:31:47 +01003949 if (spec->board_config == STAC_9200_GATEWAY ||
3950 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003951 spec->init = stac9200_eapd_init;
3952 else
3953 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003954 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003955
Takashi Iwai117f2572008-03-18 09:53:23 +01003956 if (spec->board_config == STAC_9200_PANASONIC) {
3957 spec->gpio_mask = spec->gpio_dir = 0x09;
3958 spec->gpio_data = 0x00;
3959 }
3960
Mattc7d4b2f2005-06-27 14:59:41 +02003961 err = stac9200_parse_auto_config(codec);
3962 if (err < 0) {
3963 stac92xx_free(codec);
3964 return err;
3965 }
Matt2f2f4252005-04-13 14:45:30 +02003966
3967 codec->patch_ops = stac92xx_patch_ops;
3968
3969 return 0;
3970}
3971
Tobin Davis8e21c342007-01-08 11:04:17 +01003972static int patch_stac925x(struct hda_codec *codec)
3973{
3974 struct sigmatel_spec *spec;
3975 int err;
3976
3977 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3978 if (spec == NULL)
3979 return -ENOMEM;
3980
3981 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003982 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003983 spec->pin_nids = stac925x_pin_nids;
3984 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3985 stac925x_models,
3986 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003987 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003988 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003989 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3990 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003991 err = stac92xx_save_bios_config_regs(codec);
3992 if (err < 0) {
3993 stac92xx_free(codec);
3994 return err;
3995 }
3996 spec->pin_configs = spec->bios_pin_configs;
3997 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3998 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3999 stac92xx_set_config_regs(codec);
4000 }
4001
4002 spec->multiout.max_channels = 2;
4003 spec->multiout.num_dacs = 1;
4004 spec->multiout.dac_nids = stac925x_dac_nids;
4005 spec->adc_nids = stac925x_adc_nids;
4006 spec->mux_nids = stac925x_mux_nids;
4007 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004008 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004009 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004010 switch (codec->vendor_id) {
4011 case 0x83847632: /* STAC9202 */
4012 case 0x83847633: /* STAC9202D */
4013 case 0x83847636: /* STAC9251 */
4014 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004015 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004016 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004017 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4018 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004019 break;
4020 default:
4021 spec->num_dmics = 0;
4022 break;
4023 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004024
4025 spec->init = stac925x_core_init;
4026 spec->mixer = stac925x_mixer;
4027
4028 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004029 if (!err) {
4030 if (spec->board_config < 0) {
4031 printk(KERN_WARNING "hda_codec: No auto-config is "
4032 "available, default to model=ref\n");
4033 spec->board_config = STAC_925x_REF;
4034 goto again;
4035 }
4036 err = -EINVAL;
4037 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004038 if (err < 0) {
4039 stac92xx_free(codec);
4040 return err;
4041 }
4042
4043 codec->patch_ops = stac92xx_patch_ops;
4044
4045 return 0;
4046}
4047
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004048static struct hda_input_mux stac92hd73xx_dmux = {
4049 .num_items = 4,
4050 .items = {
4051 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004052 { "Digital Mic 1", 0x09 },
4053 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004054 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004055 }
4056};
4057
4058static int patch_stac92hd73xx(struct hda_codec *codec)
4059{
4060 struct sigmatel_spec *spec;
4061 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4062 int err = 0;
4063
4064 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4065 if (spec == NULL)
4066 return -ENOMEM;
4067
4068 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004069 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004070 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4071 spec->pin_nids = stac92hd73xx_pin_nids;
4072 spec->board_config = snd_hda_check_board_config(codec,
4073 STAC_92HD73XX_MODELS,
4074 stac92hd73xx_models,
4075 stac92hd73xx_cfg_tbl);
4076again:
4077 if (spec->board_config < 0) {
4078 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4079 " STAC92HD73XX, using BIOS defaults\n");
4080 err = stac92xx_save_bios_config_regs(codec);
4081 if (err < 0) {
4082 stac92xx_free(codec);
4083 return err;
4084 }
4085 spec->pin_configs = spec->bios_pin_configs;
4086 } else {
4087 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4088 stac92xx_set_config_regs(codec);
4089 }
4090
4091 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4092 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4093
4094 if (spec->multiout.num_dacs < 0) {
4095 printk(KERN_WARNING "hda_codec: Could not determine "
4096 "number of channels defaulting to DAC count\n");
4097 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4098 }
4099
4100 switch (spec->multiout.num_dacs) {
4101 case 0x3: /* 6 Channel */
4102 spec->mixer = stac92hd73xx_6ch_mixer;
4103 spec->init = stac92hd73xx_6ch_core_init;
4104 break;
4105 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004106 spec->mixer = stac92hd73xx_8ch_mixer;
4107 spec->init = stac92hd73xx_8ch_core_init;
4108 break;
4109 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004110 spec->mixer = stac92hd73xx_10ch_mixer;
4111 spec->init = stac92hd73xx_10ch_core_init;
4112 };
4113
4114 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4115 spec->aloopback_mask = 0x01;
4116 spec->aloopback_shift = 8;
4117
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004118 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004119 spec->mux_nids = stac92hd73xx_mux_nids;
4120 spec->adc_nids = stac92hd73xx_adc_nids;
4121 spec->dmic_nids = stac92hd73xx_dmic_nids;
4122 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004123 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004124 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004125 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004126
4127 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4128 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai16970552007-12-18 18:05:52 +01004129 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004130 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4131 sizeof(stac92hd73xx_dmux));
4132
Matthew Ranostaya7662642008-02-21 07:51:14 +01004133 switch (spec->board_config) {
4134 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004135 spec->init = dell_eq_core_init;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004136 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004137 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4138 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4139 spec->num_amps = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004140 switch (codec->subsystem_id) {
4141 case 0x1028025e: /* Analog Mics */
4142 case 0x1028025f:
4143 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4144 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004145 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004146 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004147 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004148 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004149 spec->init = dell_m6_core_init;
4150 /* fall-through */
4151 case 0x10280254:
4152 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004153 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4154 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004155 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004156 break;
4157 case 0x10280256: /* Both */
4158 case 0x10280057:
4159 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4160 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4161 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004162 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004163 break;
4164 }
4165 break;
4166 default:
4167 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004168 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004169 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004170 if (spec->board_config > STAC_92HD73XX_REF) {
4171 /* GPIO0 High = Enable EAPD */
4172 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4173 spec->gpio_data = 0x01;
4174 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004175 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004176
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004177 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4178 spec->pwr_nids = stac92hd73xx_pwr_nids;
4179
Matthew Ranostayd9737752008-09-07 12:03:41 +02004180 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004181
4182 if (!err) {
4183 if (spec->board_config < 0) {
4184 printk(KERN_WARNING "hda_codec: No auto-config is "
4185 "available, default to model=ref\n");
4186 spec->board_config = STAC_92HD73XX_REF;
4187 goto again;
4188 }
4189 err = -EINVAL;
4190 }
4191
4192 if (err < 0) {
4193 stac92xx_free(codec);
4194 return err;
4195 }
4196
4197 codec->patch_ops = stac92xx_patch_ops;
4198
4199 return 0;
4200}
4201
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004202static struct hda_input_mux stac92hd83xxx_dmux = {
4203 .num_items = 3,
4204 .items = {
4205 { "Analog Inputs", 0x03 },
4206 { "Digital Mic 1", 0x04 },
4207 { "Digital Mic 2", 0x05 },
4208 }
4209};
4210
4211static int patch_stac92hd83xxx(struct hda_codec *codec)
4212{
4213 struct sigmatel_spec *spec;
4214 int err;
4215
4216 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4217 if (spec == NULL)
4218 return -ENOMEM;
4219
4220 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004221 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004222 spec->mono_nid = 0x19;
4223 spec->digbeep_nid = 0x21;
4224 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4225 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4226 spec->adc_nids = stac92hd83xxx_adc_nids;
4227 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4228 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4229 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4230 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4231
4232 spec->init = stac92hd83xxx_core_init;
4233 switch (codec->vendor_id) {
4234 case 0x111d7605:
4235 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4236 break;
4237 default:
4238 spec->num_pwrs--;
4239 spec->init++; /* switch to config #2 */
4240 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4241 }
4242
4243 spec->mixer = stac92hd83xxx_mixer;
4244 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4245 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4246 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4247 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4248 spec->dinput_mux = &stac92hd83xxx_dmux;
4249 spec->pin_nids = stac92hd83xxx_pin_nids;
4250 spec->board_config = snd_hda_check_board_config(codec,
4251 STAC_92HD83XXX_MODELS,
4252 stac92hd83xxx_models,
4253 stac92hd83xxx_cfg_tbl);
4254again:
4255 if (spec->board_config < 0) {
4256 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4257 " STAC92HD83XXX, using BIOS defaults\n");
4258 err = stac92xx_save_bios_config_regs(codec);
4259 if (err < 0) {
4260 stac92xx_free(codec);
4261 return err;
4262 }
4263 spec->pin_configs = spec->bios_pin_configs;
4264 } else {
4265 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4266 stac92xx_set_config_regs(codec);
4267 }
4268
4269 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4270 if (!err) {
4271 if (spec->board_config < 0) {
4272 printk(KERN_WARNING "hda_codec: No auto-config is "
4273 "available, default to model=ref\n");
4274 spec->board_config = STAC_92HD83XXX_REF;
4275 goto again;
4276 }
4277 err = -EINVAL;
4278 }
4279
4280 if (err < 0) {
4281 stac92xx_free(codec);
4282 return err;
4283 }
4284
4285 codec->patch_ops = stac92xx_patch_ops;
4286
4287 return 0;
4288}
4289
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004290#ifdef SND_HDA_NEEDS_RESUME
4291static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4292{
4293 struct sigmatel_spec *spec = codec->spec;
4294 int i;
4295 snd_hda_codec_write_cache(codec, codec->afg, 0,
4296 AC_VERB_SET_POWER_STATE, pwr);
4297
4298 msleep(1);
4299 for (i = 0; i < spec->num_adcs; i++) {
4300 snd_hda_codec_write_cache(codec,
4301 spec->adc_nids[i], 0,
4302 AC_VERB_SET_POWER_STATE, pwr);
4303 }
4304};
4305
4306static int stac92hd71xx_resume(struct hda_codec *codec)
4307{
4308 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4309 return stac92xx_resume(codec);
4310}
4311
4312static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4313{
4314 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4315 return 0;
4316};
4317
4318#endif
4319
4320static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4321 .build_controls = stac92xx_build_controls,
4322 .build_pcms = stac92xx_build_pcms,
4323 .init = stac92xx_init,
4324 .free = stac92xx_free,
4325 .unsol_event = stac92xx_unsol_event,
4326#ifdef SND_HDA_NEEDS_RESUME
4327 .resume = stac92hd71xx_resume,
4328 .suspend = stac92hd71xx_suspend,
4329#endif
4330};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004331
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004332static struct hda_input_mux stac92hd71bxx_dmux = {
4333 .num_items = 4,
4334 .items = {
4335 { "Analog Inputs", 0x00 },
4336 { "Mixer", 0x01 },
4337 { "Digital Mic 1", 0x02 },
4338 { "Digital Mic 2", 0x03 },
4339 }
4340};
4341
Matthew Ranostaye035b842007-11-06 11:53:55 +01004342static int patch_stac92hd71bxx(struct hda_codec *codec)
4343{
4344 struct sigmatel_spec *spec;
4345 int err = 0;
4346
4347 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4348 if (spec == NULL)
4349 return -ENOMEM;
4350
4351 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004352 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004353 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004354 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004355 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004356 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4357 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004358 spec->board_config = snd_hda_check_board_config(codec,
4359 STAC_92HD71BXX_MODELS,
4360 stac92hd71bxx_models,
4361 stac92hd71bxx_cfg_tbl);
4362again:
4363 if (spec->board_config < 0) {
4364 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4365 " STAC92HD71BXX, using BIOS defaults\n");
4366 err = stac92xx_save_bios_config_regs(codec);
4367 if (err < 0) {
4368 stac92xx_free(codec);
4369 return err;
4370 }
4371 spec->pin_configs = spec->bios_pin_configs;
4372 } else {
4373 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4374 stac92xx_set_config_regs(codec);
4375 }
4376
Matthew Ranostay541eee82007-12-14 12:08:04 +01004377 switch (codec->vendor_id) {
4378 case 0x111d76b6: /* 4 Port without Analog Mixer */
4379 case 0x111d76b7:
4380 case 0x111d76b4: /* 6 Port without Analog Mixer */
4381 case 0x111d76b5:
4382 spec->mixer = stac92hd71bxx_mixer;
4383 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004384 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004385 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004386 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay72474be2008-10-09 09:32:17 -04004387 switch (codec->subsystem_id) {
4388 case 0x103c361a:
4389 /* Enable VREF power saving on GPIO1 detect */
4390 snd_hda_codec_write(codec, codec->afg, 0,
4391 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4392 snd_hda_codec_write_cache(codec, codec->afg, 0,
4393 AC_VERB_SET_UNSOLICITED_ENABLE,
4394 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4395 spec->gpio_mask |= 0x02;
4396 break;
4397 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004398 if ((codec->revision_id & 0xf) == 0 ||
4399 (codec->revision_id & 0xf) == 1) {
4400#ifdef SND_HDA_NEEDS_RESUME
4401 codec->patch_ops = stac92hd71bxx_patch_ops;
4402#endif
4403 spec->stream_delay = 40; /* 40 milliseconds */
4404 }
4405
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004406 /* no output amps */
4407 spec->num_pwrs = 0;
4408 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004409 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004410
4411 /* disable VSW */
4412 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4413 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4414 break;
4415 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004416 if ((codec->revision_id & 0xf) == 1) {
4417#ifdef SND_HDA_NEEDS_RESUME
4418 codec->patch_ops = stac92hd71bxx_patch_ops;
4419#endif
4420 spec->stream_delay = 40; /* 40 milliseconds */
4421 }
4422
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004423 /* no output amps */
4424 spec->num_pwrs = 0;
4425 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004426 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004427 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004428 spec->mixer = stac92hd71bxx_analog_mixer;
4429 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004430 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004431 }
4432
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004433 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004434 spec->aloopback_shift = 0;
4435
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004436 if (spec->board_config > STAC_92HD71BXX_REF) {
4437 /* GPIO0 = EAPD */
4438 spec->gpio_mask = 0x01;
4439 spec->gpio_dir = 0x01;
4440 spec->gpio_data = 0x01;
4441 }
Matthew Ranostaye035b842007-11-06 11:53:55 +01004442
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004443 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004444 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004445 spec->mux_nids = stac92hd71bxx_mux_nids;
4446 spec->adc_nids = stac92hd71bxx_adc_nids;
4447 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004448 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004449 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004450 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004451
4452 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4453 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004454
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004455 switch (spec->board_config) {
4456 case STAC_HP_M4:
4457 spec->num_dmics = 0;
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004458 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004459 spec->num_dmuxes = 0;
4460
4461 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004462 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4463 stac92xx_auto_set_pinctl(codec, 0x0e,
4464 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004465 break;
4466 default:
4467 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4468 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4469 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4470 };
4471
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004472 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004473 spec->multiout.hp_nid = 0x11;
4474 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004475 if (spec->dinput_mux)
4476 spec->private_dimux.num_items +=
4477 spec->num_dmics -
4478 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004479
4480 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4481 if (!err) {
4482 if (spec->board_config < 0) {
4483 printk(KERN_WARNING "hda_codec: No auto-config is "
4484 "available, default to model=ref\n");
4485 spec->board_config = STAC_92HD71BXX_REF;
4486 goto again;
4487 }
4488 err = -EINVAL;
4489 }
4490
4491 if (err < 0) {
4492 stac92xx_free(codec);
4493 return err;
4494 }
4495
Matthew Ranostaye035b842007-11-06 11:53:55 +01004496 return 0;
4497};
4498
Matt2f2f4252005-04-13 14:45:30 +02004499static int patch_stac922x(struct hda_codec *codec)
4500{
4501 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004502 int err;
Matt2f2f4252005-04-13 14:45:30 +02004503
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004504 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004505 if (spec == NULL)
4506 return -ENOMEM;
4507
4508 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004509 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004510 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004511 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4512 stac922x_models,
4513 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004514 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004515 spec->gpio_mask = spec->gpio_dir = 0x03;
4516 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004517 /* Intel Macs have all same PCI SSID, so we need to check
4518 * codec SSID to distinguish the exact models
4519 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004520 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004521 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004522
4523 case 0x106b0800:
4524 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004525 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004526 case 0x106b0600:
4527 case 0x106b0700:
4528 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004529 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004530 case 0x106b0e00:
4531 case 0x106b0f00:
4532 case 0x106b1600:
4533 case 0x106b1700:
4534 case 0x106b0200:
4535 case 0x106b1e00:
4536 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004537 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004538 case 0x106b1a00:
4539 case 0x00000100:
4540 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004541 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004542 case 0x106b0a00:
4543 case 0x106b2200:
4544 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004545 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004546 default:
4547 spec->board_config = STAC_INTEL_MAC_V3;
4548 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004549 }
4550 }
4551
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004552 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004553 if (spec->board_config < 0) {
4554 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4555 "using BIOS defaults\n");
4556 err = stac92xx_save_bios_config_regs(codec);
4557 if (err < 0) {
4558 stac92xx_free(codec);
4559 return err;
4560 }
4561 spec->pin_configs = spec->bios_pin_configs;
4562 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004563 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4564 stac92xx_set_config_regs(codec);
4565 }
Matt2f2f4252005-04-13 14:45:30 +02004566
Matt2f2f4252005-04-13 14:45:30 +02004567 spec->adc_nids = stac922x_adc_nids;
4568 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004569 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004570 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004571 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004572 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004573
4574 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004575 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004576
4577 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004578
Matt Porter3cc08dc2006-01-23 15:27:49 +01004579 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004580 if (!err) {
4581 if (spec->board_config < 0) {
4582 printk(KERN_WARNING "hda_codec: No auto-config is "
4583 "available, default to model=ref\n");
4584 spec->board_config = STAC_D945_REF;
4585 goto again;
4586 }
4587 err = -EINVAL;
4588 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004589 if (err < 0) {
4590 stac92xx_free(codec);
4591 return err;
4592 }
4593
4594 codec->patch_ops = stac92xx_patch_ops;
4595
Takashi Iwai807a46362007-05-29 19:01:37 +02004596 /* Fix Mux capture level; max to 2 */
4597 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4598 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4599 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4600 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4601 (0 << AC_AMPCAP_MUTE_SHIFT));
4602
Matt Porter3cc08dc2006-01-23 15:27:49 +01004603 return 0;
4604}
4605
4606static int patch_stac927x(struct hda_codec *codec)
4607{
4608 struct sigmatel_spec *spec;
4609 int err;
4610
4611 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4612 if (spec == NULL)
4613 return -ENOMEM;
4614
4615 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004616 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004617 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004618 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4619 stac927x_models,
4620 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004621 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004622 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4623 if (spec->board_config < 0)
4624 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4625 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004626 err = stac92xx_save_bios_config_regs(codec);
4627 if (err < 0) {
4628 stac92xx_free(codec);
4629 return err;
4630 }
4631 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004632 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004633 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4634 stac92xx_set_config_regs(codec);
4635 }
4636
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004637 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004638 spec->adc_nids = stac927x_adc_nids;
4639 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4640 spec->mux_nids = stac927x_mux_nids;
4641 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004642 spec->smux_nids = stac927x_smux_nids;
4643 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004644 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004645 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004646 spec->multiout.dac_nids = spec->dac_nids;
4647
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004648 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004649 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004650 case STAC_D965_5ST:
4651 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004652 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004653 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004654 spec->num_dmics = 0;
4655
Tobin Davis93ed1502006-09-01 21:03:12 +02004656 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004657 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004658 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004659 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004660 switch (codec->subsystem_id) {
4661 case 0x10280209:
4662 case 0x1028022e:
4663 /* correct the device field to SPDIF out */
4664 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4665 break;
4666 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004667 /* configure the analog microphone on some laptops */
4668 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004669 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004670 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004671 /* correct the front input jack as a mic */
4672 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4673 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004674 case STAC_DELL_3ST:
4675 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004676 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004677 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004678 spec->dmic_nids = stac927x_dmic_nids;
4679 spec->num_dmics = STAC927X_NUM_DMICS;
4680
Tobin Davis93ed1502006-09-01 21:03:12 +02004681 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004682 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004683 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004684 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004685 break;
4686 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004687 if (spec->board_config > STAC_D965_REF) {
4688 /* GPIO0 High = Enable EAPD */
4689 spec->eapd_mask = spec->gpio_mask = 0x01;
4690 spec->gpio_dir = spec->gpio_data = 0x01;
4691 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004692 spec->num_dmics = 0;
4693
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004694 spec->init = stac927x_core_init;
4695 spec->mixer = stac927x_mixer;
4696 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004697
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004698 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004699 spec->aloopback_mask = 0x40;
4700 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004701
Matt Porter3cc08dc2006-01-23 15:27:49 +01004702 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004703 if (!err) {
4704 if (spec->board_config < 0) {
4705 printk(KERN_WARNING "hda_codec: No auto-config is "
4706 "available, default to model=ref\n");
4707 spec->board_config = STAC_D965_REF;
4708 goto again;
4709 }
4710 err = -EINVAL;
4711 }
Mattc7d4b2f2005-06-27 14:59:41 +02004712 if (err < 0) {
4713 stac92xx_free(codec);
4714 return err;
4715 }
Matt2f2f4252005-04-13 14:45:30 +02004716
4717 codec->patch_ops = stac92xx_patch_ops;
4718
Takashi Iwai52987652008-01-16 16:09:47 +01004719 /*
4720 * !!FIXME!!
4721 * The STAC927x seem to require fairly long delays for certain
4722 * command sequences. With too short delays (even if the answer
4723 * is set to RIRB properly), it results in the silence output
4724 * on some hardwares like Dell.
4725 *
4726 * The below flag enables the longer delay (see get_response
4727 * in hda_intel.c).
4728 */
4729 codec->bus->needs_damn_long_delay = 1;
4730
Matt2f2f4252005-04-13 14:45:30 +02004731 return 0;
4732}
4733
Matt Porterf3302a592006-07-31 12:49:34 +02004734static int patch_stac9205(struct hda_codec *codec)
4735{
4736 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004737 int err;
Matt Porterf3302a592006-07-31 12:49:34 +02004738
4739 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4740 if (spec == NULL)
4741 return -ENOMEM;
4742
4743 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004744 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004745 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004746 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4747 stac9205_models,
4748 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004749 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004750 if (spec->board_config < 0) {
4751 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4752 err = stac92xx_save_bios_config_regs(codec);
4753 if (err < 0) {
4754 stac92xx_free(codec);
4755 return err;
4756 }
4757 spec->pin_configs = spec->bios_pin_configs;
4758 } else {
Matt Porterf3302a592006-07-31 12:49:34 +02004759 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4760 stac92xx_set_config_regs(codec);
4761 }
4762
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004763 spec->digbeep_nid = 0x23;
Matt Porterf3302a592006-07-31 12:49:34 +02004764 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004765 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a592006-07-31 12:49:34 +02004766 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004767 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004768 spec->smux_nids = stac9205_smux_nids;
4769 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004770 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004771 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004772 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004773 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004774 spec->num_pwrs = 0;
Matt Porterf3302a592006-07-31 12:49:34 +02004775
4776 spec->init = stac9205_core_init;
4777 spec->mixer = stac9205_mixer;
4778
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004779 spec->aloopback_mask = 0x40;
4780 spec->aloopback_shift = 0;
Matt Porterf3302a592006-07-31 12:49:34 +02004781 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004782
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004783 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004784 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004785 /* Enable SPDIF in/out */
4786 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4787 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004788
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004789 /* Enable unsol response for GPIO4/Dock HP connection */
4790 snd_hda_codec_write(codec, codec->afg, 0,
4791 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4792 snd_hda_codec_write_cache(codec, codec->afg, 0,
4793 AC_VERB_SET_UNSOLICITED_ENABLE,
4794 (AC_USRSP_EN | STAC_HP_EVENT));
4795
4796 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004797 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004798 spec->gpio_mask = 0x1b;
4799 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004800 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004801 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004802 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004803 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004804 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004805 case STAC_9205_REF:
4806 /* SPDIF-In enabled */
4807 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004808 default:
4809 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004810 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004811 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004812 break;
4813 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004814
Matt Porterf3302a592006-07-31 12:49:34 +02004815 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004816 if (!err) {
4817 if (spec->board_config < 0) {
4818 printk(KERN_WARNING "hda_codec: No auto-config is "
4819 "available, default to model=ref\n");
4820 spec->board_config = STAC_9205_REF;
4821 goto again;
4822 }
4823 err = -EINVAL;
4824 }
Matt Porterf3302a592006-07-31 12:49:34 +02004825 if (err < 0) {
4826 stac92xx_free(codec);
4827 return err;
4828 }
4829
4830 codec->patch_ops = stac92xx_patch_ops;
4831
4832 return 0;
4833}
4834
Matt2f2f4252005-04-13 14:45:30 +02004835/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004836 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004837 */
4838
Guillaume Munch99ccc562006-08-16 19:35:12 +02004839/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004840static hda_nid_t vaio_dacs[] = { 0x2 };
4841#define VAIO_HP_DAC 0x5
4842static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4843static hda_nid_t vaio_mux_nids[] = { 0x15 };
4844
4845static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004846 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004847 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004848 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004849 { "Mic Jack", 0x1 },
4850 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004851 { "PCM", 0x3 },
4852 }
4853};
4854
4855static struct hda_verb vaio_init[] = {
4856 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004857 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004858 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4859 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4860 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004862 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004863 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4864 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4865 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4868 {}
4869};
4870
Guillaume Munch6d859062006-08-22 17:15:47 +02004871static struct hda_verb vaio_ar_init[] = {
4872 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4873 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4874 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4875 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4876/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004878 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004879 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4880 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4881/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4885 {}
4886};
4887
Takashi Iwaidb064e52006-03-16 16:04:58 +01004888/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004889static struct hda_bind_ctls vaio_bind_master_vol = {
4890 .ops = &snd_hda_bind_vol,
4891 .values = {
4892 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4893 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4894 0
4895 },
4896};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004897
4898/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004899static struct hda_bind_ctls vaio_bind_master_sw = {
4900 .ops = &snd_hda_bind_sw,
4901 .values = {
4902 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4903 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4904 0,
4905 },
4906};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004907
4908static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004909 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4910 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004911 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4912 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4913 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4914 {
4915 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4916 .name = "Capture Source",
4917 .count = 1,
4918 .info = stac92xx_mux_enum_info,
4919 .get = stac92xx_mux_enum_get,
4920 .put = stac92xx_mux_enum_put,
4921 },
4922 {}
4923};
4924
Guillaume Munch6d859062006-08-22 17:15:47 +02004925static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004926 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4927 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004928 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4929 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4930 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4931 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4932 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4933 {
4934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4935 .name = "Capture Source",
4936 .count = 1,
4937 .info = stac92xx_mux_enum_info,
4938 .get = stac92xx_mux_enum_get,
4939 .put = stac92xx_mux_enum_put,
4940 },
4941 {}
4942};
4943
4944static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004945 .build_controls = stac92xx_build_controls,
4946 .build_pcms = stac92xx_build_pcms,
4947 .init = stac92xx_init,
4948 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004949#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004950 .resume = stac92xx_resume,
4951#endif
4952};
4953
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004954static int stac9872_vaio_init(struct hda_codec *codec)
4955{
4956 int err;
4957
4958 err = stac92xx_init(codec);
4959 if (err < 0)
4960 return err;
4961 if (codec->patch_ops.unsol_event)
4962 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4963 return 0;
4964}
4965
4966static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4967{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004968 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004969 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4970 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4971 } else {
4972 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4973 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4974 }
4975}
4976
4977static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4978{
4979 switch (res >> 26) {
4980 case STAC_HP_EVENT:
4981 stac9872_vaio_hp_detect(codec, res);
4982 break;
4983 }
4984}
4985
4986static struct hda_codec_ops stac9872_vaio_patch_ops = {
4987 .build_controls = stac92xx_build_controls,
4988 .build_pcms = stac92xx_build_pcms,
4989 .init = stac9872_vaio_init,
4990 .free = stac92xx_free,
4991 .unsol_event = stac9872_vaio_unsol_event,
4992#ifdef CONFIG_PM
4993 .resume = stac92xx_resume,
4994#endif
4995};
4996
Guillaume Munch6d859062006-08-22 17:15:47 +02004997enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4998 CXD9872RD_VAIO,
4999 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5000 STAC9872AK_VAIO,
5001 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5002 STAC9872K_VAIO,
5003 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005004 CXD9872AKD_VAIO,
5005 STAC_9872_MODELS,
5006};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005007
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005008static const char *stac9872_models[STAC_9872_MODELS] = {
5009 [CXD9872RD_VAIO] = "vaio",
5010 [CXD9872AKD_VAIO] = "vaio-ar",
5011};
5012
5013static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5014 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5015 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5016 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005017 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005018 {}
5019};
5020
Guillaume Munch6d859062006-08-22 17:15:47 +02005021static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005022{
5023 struct sigmatel_spec *spec;
5024 int board_config;
5025
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005026 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5027 stac9872_models,
5028 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005029 if (board_config < 0)
5030 /* unknown config, let generic-parser do its job... */
5031 return snd_hda_parse_generic_codec(codec);
5032
5033 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5034 if (spec == NULL)
5035 return -ENOMEM;
5036
5037 codec->spec = spec;
5038 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005039 case CXD9872RD_VAIO:
5040 case STAC9872AK_VAIO:
5041 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005042 spec->mixer = vaio_mixer;
5043 spec->init = vaio_init;
5044 spec->multiout.max_channels = 2;
5045 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5046 spec->multiout.dac_nids = vaio_dacs;
5047 spec->multiout.hp_nid = VAIO_HP_DAC;
5048 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5049 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005050 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005051 spec->input_mux = &vaio_mux;
5052 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005053 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005054 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005055
5056 case CXD9872AKD_VAIO:
5057 spec->mixer = vaio_ar_mixer;
5058 spec->init = vaio_ar_init;
5059 spec->multiout.max_channels = 2;
5060 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5061 spec->multiout.dac_nids = vaio_dacs;
5062 spec->multiout.hp_nid = VAIO_HP_DAC;
5063 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005064 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005065 spec->adc_nids = vaio_adcs;
5066 spec->input_mux = &vaio_mux;
5067 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005068 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005069 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005070 }
5071
Takashi Iwaidb064e52006-03-16 16:04:58 +01005072 return 0;
5073}
5074
5075
5076/*
Matt2f2f4252005-04-13 14:45:30 +02005077 * patch entries
5078 */
5079struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5080 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5081 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5082 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5083 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5084 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5085 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5086 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005087 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5088 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5089 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5090 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5091 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5092 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005093 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5094 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5095 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5096 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5097 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5098 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5099 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5100 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5101 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5102 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005103 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5104 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5105 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5106 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5107 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5108 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005109 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5110 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005111 /* The following does not take into account .id=0x83847661 when subsys =
5112 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5113 * currently not fully supported.
5114 */
5115 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5116 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5117 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a592006-07-31 12:49:34 +02005118 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5119 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5120 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5121 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5122 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5123 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5124 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5125 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005126 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005127 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5128 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005129 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005130 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5131 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005132 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005133 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5134 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5135 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5136 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5137 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5138 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5139 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5140 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005141 {} /* terminator */
5142};