blob: ec88ba8814822ebd4825d75125260cd6bb2082e3 [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>
Matthew Ranostay45a6ac12008-10-15 14:45:38 -040033#include <sound/jack.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010036#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020037#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020038
Matt4e550962005-07-04 17:51:39 +020039#define NUM_CONTROL_ALLOC 32
Matthew Ranostaya64135a2008-01-10 16:55:06 +010040#define STAC_PWR_EVENT 0x20
41#define STAC_HP_EVENT 0x30
Matthew Ranostay72474be2008-10-09 09:32:17 -040042#define STAC_VREF_EVENT 0x40
Matt4e550962005-07-04 17:51:39 +020043
Takashi Iwaif5fcc132006-11-24 17:07:44 +010044enum {
45 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010046 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020047 STAC_9200_DELL_D21,
48 STAC_9200_DELL_D22,
49 STAC_9200_DELL_D23,
50 STAC_9200_DELL_M21,
51 STAC_9200_DELL_M22,
52 STAC_9200_DELL_M23,
53 STAC_9200_DELL_M24,
54 STAC_9200_DELL_M25,
55 STAC_9200_DELL_M26,
56 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020057 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010058 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010059 STAC_9200_MODELS
60};
61
62enum {
63 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020064 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020065 STAC_9205_DELL_M43,
66 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010067 STAC_9205_MODELS
68};
69
70enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010071 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010072 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010073 STAC_92HD73XX_MODELS
74};
75
76enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020077 STAC_92HD83XXX_REF,
78 STAC_92HD83XXX_MODELS
79};
80
81enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010082 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010083 STAC_DELL_M4_1,
84 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040085 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010086 STAC_92HD71BXX_MODELS
87};
88
89enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010090 STAC_925x_REF,
91 STAC_M2_2,
92 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020093 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010094 STAC_925x_MODELS
95};
96
97enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010098 STAC_D945_REF,
99 STAC_D945GTP3,
100 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200101 STAC_INTEL_MAC_V1,
102 STAC_INTEL_MAC_V2,
103 STAC_INTEL_MAC_V3,
104 STAC_INTEL_MAC_V4,
105 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800106 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
107 * is given, one of the above models will be
108 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200109 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100110 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100111 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100112 STAC_MACBOOK_PRO_V1,
113 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200114 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200115 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300116 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200117 STAC_922X_DELL_D81,
118 STAC_922X_DELL_D82,
119 STAC_922X_DELL_M81,
120 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100121 STAC_922X_MODELS
122};
123
124enum {
125 STAC_D965_REF,
126 STAC_D965_3ST,
127 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200128 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100129 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100130 STAC_927X_MODELS
131};
Matt Porter403d1942005-11-29 15:00:51 +0100132
Matt2f2f4252005-04-13 14:45:30 +0200133struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100134 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200135 unsigned int num_mixers;
136
Matt Porter403d1942005-11-29 15:00:51 +0100137 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200138 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100139 unsigned int line_switch: 1;
140 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100141 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100142 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400143 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200144
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100145 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200146 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100147 unsigned int gpio_mask;
148 unsigned int gpio_dir;
149 unsigned int gpio_data;
150 unsigned int gpio_mute;
151
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200152 /* stream */
153 unsigned int stream_delay;
154
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100155 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100156 unsigned char aloopback_mask;
157 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200158
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100159 /* power management */
160 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200161 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100162 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100163 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100164
Matt2f2f4252005-04-13 14:45:30 +0200165 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100166 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400167 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100168 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200169 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100170 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200171
172 /* capture */
173 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200174 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200175 hda_nid_t *mux_nids;
176 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200177 hda_nid_t *dmic_nids;
178 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100179 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100180 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200181 hda_nid_t *smux_nids;
182 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400183 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200184
Mattdabbed62005-06-14 10:19:34 +0200185 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100186 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200187 hda_nid_t anabeep_nid;
188 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200189
Matt2f2f4252005-04-13 14:45:30 +0200190 /* pin widgets */
191 hda_nid_t *pin_nids;
192 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200193 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200194 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200195
196 /* codec specific stuff */
197 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100198 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200199
200 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200201 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100202 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200203 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100204 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200205 struct hda_input_mux *sinput_mux;
206 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400207 unsigned int cur_amux;
208 hda_nid_t *amp_nids;
209 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200210 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200211
Matt Porter403d1942005-11-29 15:00:51 +0100212 /* i/o switches */
213 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200214 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200215 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200216 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200217
Mattc7d4b2f2005-06-27 14:59:41 +0200218 struct hda_pcm pcm_rec[2]; /* PCM information */
219
Matthew Ranostay45a6ac12008-10-15 14:45:38 -0400220 /* jack detection */
221 struct snd_jack *jack;
222
Mattc7d4b2f2005-06-27 14:59:41 +0200223 /* dynamic controls and input_mux */
224 struct auto_pin_cfg autocfg;
225 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100226 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200227 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200228 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200229 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400230 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100231 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200232};
233
234static hda_nid_t stac9200_adc_nids[1] = {
235 0x03,
236};
237
238static hda_nid_t stac9200_mux_nids[1] = {
239 0x0c,
240};
241
242static hda_nid_t stac9200_dac_nids[1] = {
243 0x02,
244};
245
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100246static hda_nid_t stac92hd73xx_pwr_nids[8] = {
247 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
248 0x0f, 0x10, 0x11
249};
250
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400251static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
252 0x26, 0,
253};
254
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100255static hda_nid_t stac92hd73xx_adc_nids[2] = {
256 0x1a, 0x1b
257};
258
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400259#define DELL_M6_AMP 2
260static hda_nid_t stac92hd73xx_amp_nids[3] = {
261 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400262};
263
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100264#define STAC92HD73XX_NUM_DMICS 2
265static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
266 0x13, 0x14, 0
267};
268
269#define STAC92HD73_DAC_COUNT 5
270static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
271 0x15, 0x16, 0x17, 0x18, 0x19,
272};
273
274static hda_nid_t stac92hd73xx_mux_nids[4] = {
275 0x28, 0x29, 0x2a, 0x2b,
276};
277
278static hda_nid_t stac92hd73xx_dmux_nids[2] = {
279 0x20, 0x21,
280};
281
Matthew Ranostayd9737752008-09-07 12:03:41 +0200282static hda_nid_t stac92hd73xx_smux_nids[2] = {
283 0x22, 0x23,
284};
285
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200286#define STAC92HD83XXX_NUM_DMICS 2
287static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
288 0x11, 0x12, 0
289};
290
291#define STAC92HD81_DAC_COUNT 2
292#define STAC92HD83_DAC_COUNT 3
293static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
294 0x13, 0x14, 0x22,
295};
296
297static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
298 0x17, 0x18,
299};
300
301static hda_nid_t stac92hd83xxx_adc_nids[2] = {
302 0x15, 0x16,
303};
304
305static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
306 0xa, 0xb, 0xd, 0xe,
307};
308
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400309static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
310 0x1e, 0,
311};
312
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200313static unsigned int stac92hd83xxx_pwr_mapping[4] = {
314 0x03, 0x0c, 0x10, 0x40,
315};
316
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100317static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
318 0x0a, 0x0d, 0x0f
319};
320
Matthew Ranostaye035b842007-11-06 11:53:55 +0100321static hda_nid_t stac92hd71bxx_adc_nids[2] = {
322 0x12, 0x13,
323};
324
325static hda_nid_t stac92hd71bxx_mux_nids[2] = {
326 0x1a, 0x1b
327};
328
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400329static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
330 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100331};
332
Matthew Ranostayd9737752008-09-07 12:03:41 +0200333static hda_nid_t stac92hd71bxx_smux_nids[2] = {
334 0x24, 0x25,
335};
336
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100337static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100338 0x10, /*0x11, */
339};
340
341#define STAC92HD71BXX_NUM_DMICS 2
342static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
343 0x18, 0x19, 0
344};
345
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400346static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
347 0x22, 0
348};
349
Tobin Davis8e21c342007-01-08 11:04:17 +0100350static hda_nid_t stac925x_adc_nids[1] = {
351 0x03,
352};
353
354static hda_nid_t stac925x_mux_nids[1] = {
355 0x0f,
356};
357
358static hda_nid_t stac925x_dac_nids[1] = {
359 0x02,
360};
361
Takashi Iwaif6e98522007-10-16 14:27:04 +0200362#define STAC925X_NUM_DMICS 1
363static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
364 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200365};
366
Takashi Iwai1697055e2007-12-18 18:05:52 +0100367static hda_nid_t stac925x_dmux_nids[1] = {
368 0x14,
369};
370
Matt2f2f4252005-04-13 14:45:30 +0200371static hda_nid_t stac922x_adc_nids[2] = {
372 0x06, 0x07,
373};
374
375static hda_nid_t stac922x_mux_nids[2] = {
376 0x12, 0x13,
377};
378
Matt Porter3cc08dc2006-01-23 15:27:49 +0100379static hda_nid_t stac927x_adc_nids[3] = {
380 0x07, 0x08, 0x09
381};
382
383static hda_nid_t stac927x_mux_nids[3] = {
384 0x15, 0x16, 0x17
385};
386
Matthew Ranostayd9737752008-09-07 12:03:41 +0200387static hda_nid_t stac927x_smux_nids[1] = {
388 0x21,
389};
390
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100391static hda_nid_t stac927x_dac_nids[6] = {
392 0x02, 0x03, 0x04, 0x05, 0x06, 0
393};
394
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100395static hda_nid_t stac927x_dmux_nids[1] = {
396 0x1b,
397};
398
Matthew Ranostay7f168592007-10-18 17:38:17 +0200399#define STAC927X_NUM_DMICS 2
400static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
401 0x13, 0x14, 0
402};
403
Matthew Ranostay65973632008-09-16 10:39:37 -0400404static const char *stac927x_spdif_labels[5] = {
405 "Digital Playback", "ADAT", "Analog Mux 1",
406 "Analog Mux 2", "Analog Mux 3"
407};
408
Matt Porterf3302a52006-07-31 12:49:34 +0200409static hda_nid_t stac9205_adc_nids[2] = {
410 0x12, 0x13
411};
412
413static hda_nid_t stac9205_mux_nids[2] = {
414 0x19, 0x1a
415};
416
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100417static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100418 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100419};
420
Matthew Ranostayd9737752008-09-07 12:03:41 +0200421static hda_nid_t stac9205_smux_nids[1] = {
422 0x21,
423};
424
Takashi Iwaif6e98522007-10-16 14:27:04 +0200425#define STAC9205_NUM_DMICS 2
426static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
427 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200428};
429
Mattc7d4b2f2005-06-27 14:59:41 +0200430static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200431 0x08, 0x09, 0x0d, 0x0e,
432 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200433};
434
Tobin Davis8e21c342007-01-08 11:04:17 +0100435static hda_nid_t stac925x_pin_nids[8] = {
436 0x07, 0x08, 0x0a, 0x0b,
437 0x0c, 0x0d, 0x10, 0x11,
438};
439
Matt2f2f4252005-04-13 14:45:30 +0200440static hda_nid_t stac922x_pin_nids[10] = {
441 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
442 0x0f, 0x10, 0x11, 0x15, 0x1b,
443};
444
Matthew Ranostaya7662642008-02-21 07:51:14 +0100445static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100446 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
447 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200448 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100449};
450
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200451static hda_nid_t stac92hd83xxx_pin_nids[14] = {
452 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
453 0x0f, 0x10, 0x11, 0x12, 0x13,
454 0x1d, 0x1e, 0x1f, 0x20
455};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400456static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100457 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
458 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400459 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100460};
461
Matt Porter3cc08dc2006-01-23 15:27:49 +0100462static hda_nid_t stac927x_pin_nids[14] = {
463 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
464 0x0f, 0x10, 0x11, 0x12, 0x13,
465 0x14, 0x21, 0x22, 0x23,
466};
467
Matt Porterf3302a52006-07-31 12:49:34 +0200468static hda_nid_t stac9205_pin_nids[12] = {
469 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
470 0x0f, 0x14, 0x16, 0x17, 0x18,
471 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200472};
473
Matthew Ranostay89385032008-09-11 09:49:39 -0400474#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
475
476static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
477 struct snd_ctl_elem_value *ucontrol)
478{
479 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
480 struct sigmatel_spec *spec = codec->spec;
481 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
482
483 kcontrol->private_value ^= get_amp_nid(kcontrol);
484 kcontrol->private_value |= nid;
485
486 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
487}
488
489static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
490 struct snd_ctl_elem_value *ucontrol)
491{
492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
493 struct sigmatel_spec *spec = codec->spec;
494 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
495
496 kcontrol->private_value ^= get_amp_nid(kcontrol);
497 kcontrol->private_value |= nid;
498
499 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
500}
501
Matt Porter8b657272006-10-26 17:12:59 +0200502static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
503 struct snd_ctl_elem_info *uinfo)
504{
505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
506 struct sigmatel_spec *spec = codec->spec;
507 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
508}
509
510static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
511 struct snd_ctl_elem_value *ucontrol)
512{
513 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
514 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100515 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200516
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100517 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200518 return 0;
519}
520
521static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
522 struct snd_ctl_elem_value *ucontrol)
523{
524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
525 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100526 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200527
528 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100529 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200530}
531
Matthew Ranostayd9737752008-09-07 12:03:41 +0200532static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_info *uinfo)
534{
535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
536 struct sigmatel_spec *spec = codec->spec;
537 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
538}
539
540static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
541 struct snd_ctl_elem_value *ucontrol)
542{
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 struct sigmatel_spec *spec = codec->spec;
545 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
546
547 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
548 return 0;
549}
550
551static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_value *ucontrol)
553{
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400556 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200557 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400558 int err, val;
559 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200560
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400561 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200562 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400563 if (err < 0)
564 return err;
565
566 if (spec->spdif_mute) {
567 if (smux_idx == 0)
568 nid = spec->multiout.dig_out_nid;
569 else
570 nid = codec->slave_dig_outs[smux_idx - 1];
571 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
572 val = AMP_OUT_MUTE;
573 if (smux_idx == 0)
574 nid = spec->multiout.dig_out_nid;
575 else
576 nid = codec->slave_dig_outs[smux_idx - 1];
577 /* un/mute SPDIF out */
578 snd_hda_codec_write_cache(codec, nid, 0,
579 AC_VERB_SET_AMP_GAIN_MUTE, val);
580 }
581 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200582}
583
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100584static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200585{
586 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
587 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200588 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200589}
590
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100591static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200592{
593 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
594 struct sigmatel_spec *spec = codec->spec;
595 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
596
597 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
598 return 0;
599}
600
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100601static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200602{
603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
604 struct sigmatel_spec *spec = codec->spec;
605 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
606
Mattc7d4b2f2005-06-27 14:59:41 +0200607 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200608 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
609}
610
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100611static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_info *uinfo)
613{
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 struct sigmatel_spec *spec = codec->spec;
616 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
617}
618
619static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
620 struct snd_ctl_elem_value *ucontrol)
621{
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 struct sigmatel_spec *spec = codec->spec;
624
625 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
626 return 0;
627}
628
629static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
630 struct snd_ctl_elem_value *ucontrol)
631{
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct sigmatel_spec *spec = codec->spec;
634
635 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
636 spec->mono_nid, &spec->cur_mmux);
637}
638
Matthew Ranostay89385032008-09-11 09:49:39 -0400639static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_info *uinfo)
641{
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 struct sigmatel_spec *spec = codec->spec;
644 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
645}
646
647static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
648 struct snd_ctl_elem_value *ucontrol)
649{
650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
651 struct sigmatel_spec *spec = codec->spec;
652
653 ucontrol->value.enumerated.item[0] = spec->cur_amux;
654 return 0;
655}
656
657static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
658 struct snd_ctl_elem_value *ucontrol)
659{
660 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
661 struct sigmatel_spec *spec = codec->spec;
662 struct snd_kcontrol *ctl =
663 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
664 if (!ctl)
665 return -EINVAL;
666
667 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
668 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
669
670 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
671 0, &spec->cur_amux);
672}
673
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200674#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
675
676static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
677 struct snd_ctl_elem_value *ucontrol)
678{
679 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100680 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200681 struct sigmatel_spec *spec = codec->spec;
682
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100683 ucontrol->value.integer.value[0] = !!(spec->aloopback &
684 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200685 return 0;
686}
687
688static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
689 struct snd_ctl_elem_value *ucontrol)
690{
691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
692 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100693 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200694 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100695 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200696
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100697 idx_val = spec->aloopback_mask << idx;
698 if (ucontrol->value.integer.value[0])
699 val = spec->aloopback | idx_val;
700 else
701 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100702 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200703 return 0;
704
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100705 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200706
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100707 /* Only return the bits defined by the shift value of the
708 * first two bytes of the mask
709 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200710 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100711 kcontrol->private_value & 0xFFFF, 0x0);
712 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200713
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100714 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200715 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100716 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200717 } else {
718 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100719 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200720 }
721
722 snd_hda_codec_write_cache(codec, codec->afg, 0,
723 kcontrol->private_value >> 16, dac_mode);
724
725 return 1;
726}
727
Mattc7d4b2f2005-06-27 14:59:41 +0200728static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200729 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200730 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200731 {}
732};
733
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200734static struct hda_verb stac9200_eapd_init[] = {
735 /* set dac0mux for dac converter */
736 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
737 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
738 {}
739};
740
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100741static struct hda_verb stac92hd73xx_6ch_core_init[] = {
742 /* set master volume and direct control */
743 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
744 /* setup audio connections */
745 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
746 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
747 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
748 /* setup adcs to point to mixer */
749 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
750 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100751 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
752 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
753 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
754 /* setup import muxs */
755 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
756 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
757 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
758 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
759 {}
760};
761
Matthew Ranostayd654a662008-03-14 08:46:51 +0100762static struct hda_verb dell_eq_core_init[] = {
763 /* set master volume to max value without distortion
764 * and direct control */
765 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
766 /* setup audio connections */
767 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400768 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
769 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100770 /* setup adcs to point to mixer */
771 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
772 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
773 /* setup import muxs */
774 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
775 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
776 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
777 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
778 {}
779};
780
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100781static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200782 /* set master volume to max value without distortion
783 * and direct control */
784 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100785 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100786 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
787 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100788 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
789 /* setup adcs to point to mixer */
790 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
792 /* setup import muxs */
793 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
794 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
796 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
797 {}
798};
799
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100800static struct hda_verb stac92hd73xx_8ch_core_init[] = {
801 /* set master volume and direct control */
802 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
803 /* setup audio connections */
804 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
805 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
807 /* connect hp ports to dac3 */
808 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
809 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
810 /* setup adcs to point to mixer */
811 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
812 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100813 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
814 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
815 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
816 /* setup import muxs */
817 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
818 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
819 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
820 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
821 {}
822};
823
824static struct hda_verb stac92hd73xx_10ch_core_init[] = {
825 /* set master volume and direct control */
826 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
827 /* setup audio connections */
828 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
829 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
830 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
831 /* dac3 is connected to import3 mux */
832 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
833 /* connect hp ports to dac4 */
834 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
835 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
836 /* setup adcs to point to mixer */
837 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
838 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100839 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
841 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
842 /* setup import muxs */
843 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
845 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
846 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
847 {}
848};
849
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200850static struct hda_verb stac92hd83xxx_core_init[] = {
851 /* start of config #1 */
852 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
853
854 /* start of config #2 */
855 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
856 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
857 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
858
859 /* power state controls amps */
860 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
861};
862
Matthew Ranostaye035b842007-11-06 11:53:55 +0100863static struct hda_verb stac92hd71bxx_core_init[] = {
864 /* set master volume and direct control */
865 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
866 /* connect headphone jack to dac1 */
867 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100868 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
869 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
871 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100872};
873
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400874#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100875static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200876 /* start of config #1 */
877
878 /* connect port 0f to audio mixer */
879 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200880 /* unmute right and left channels for node 0x0f */
881 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
882 /* start of config #2 */
883
Matthew Ranostay541eee82007-12-14 12:08:04 +0100884 /* set master volume and direct control */
885 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
886 /* connect headphone jack to dac1 */
887 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200888 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100889 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
890 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100891 {}
892};
893
Tobin Davis8e21c342007-01-08 11:04:17 +0100894static struct hda_verb stac925x_core_init[] = {
895 /* set dac0mux for dac converter */
896 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
897 {}
898};
899
Mattc7d4b2f2005-06-27 14:59:41 +0200900static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200901 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200902 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200903 {}
904};
905
Tobin Davis93ed1502006-09-01 21:03:12 +0200906static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200907 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200908 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200909 /* unmute node 0x1b */
910 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
911 /* select node 0x03 as DAC */
912 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
913 {}
914};
915
Matt Porter3cc08dc2006-01-23 15:27:49 +0100916static struct hda_verb stac927x_core_init[] = {
917 /* set master volume and direct control */
918 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200919 /* enable analog pc beep path */
920 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100921 {}
922};
923
Matt Porterf3302a52006-07-31 12:49:34 +0200924static struct hda_verb stac9205_core_init[] = {
925 /* set master volume and direct control */
926 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200927 /* enable analog pc beep path */
928 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200929 {}
930};
931
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100932#define STAC_MONO_MUX \
933 { \
934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
935 .name = "Mono Mux", \
936 .count = 1, \
937 .info = stac92xx_mono_mux_enum_info, \
938 .get = stac92xx_mono_mux_enum_get, \
939 .put = stac92xx_mono_mux_enum_put, \
940 }
941
Matthew Ranostay89385032008-09-11 09:49:39 -0400942#define STAC_AMP_MUX \
943 { \
944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
945 .name = "Amp Selector Capture Switch", \
946 .count = 1, \
947 .info = stac92xx_amp_mux_enum_info, \
948 .get = stac92xx_amp_mux_enum_get, \
949 .put = stac92xx_amp_mux_enum_put, \
950 }
951
952#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
953 { \
954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
955 .name = xname, \
956 .index = 0, \
957 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
958 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
960 .info = stac92xx_amp_volume_info, \
961 .get = stac92xx_amp_volume_get, \
962 .put = stac92xx_amp_volume_put, \
963 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
964 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
965 }
966
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200967#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200968 { \
969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
970 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200971 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200972 .info = stac92xx_mux_enum_info, \
973 .get = stac92xx_mux_enum_get, \
974 .put = stac92xx_mux_enum_put, \
975 }
976
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100977#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200978 { \
979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
980 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100981 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200982 .info = stac92xx_aloopback_info, \
983 .get = stac92xx_aloopback_get, \
984 .put = stac92xx_aloopback_put, \
985 .private_value = verb_read | (verb_write << 16), \
986 }
987
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100988static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200989 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
990 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200991 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200992 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200994 { } /* end */
995};
996
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400997#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100998static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400999 /* start of config #1 */
1000 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1001 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1002
1003 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1004 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1005
1006 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1007 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1008
1009 /* start of config #2 */
1010 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1011 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1012
1013 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1014 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1015
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001016 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1017
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001018 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1019 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020
1021 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001024 { } /* end */
1025};
1026
1027static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1029
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001030 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032
1033 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035
1036 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1037 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1038
1039 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1040 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1041
1042 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1043 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1044
1045 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1046 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1047
1048 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1049 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1050 { } /* end */
1051};
1052
1053static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001054 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1055
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001056 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058
1059 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061
1062 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1063 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1064
1065 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1066 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1067
1068 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1069 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1070
1071 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1072 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1073
1074 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1075 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1076 { } /* end */
1077};
1078
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001079
1080static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086
1087 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1088 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1089
1090 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1091 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1092
1093 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1094 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1095
1096 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1097 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1098
1099 /*
1100 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1101 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1102 */
1103 { } /* end */
1104};
1105
Matthew Ranostay541eee82007-12-14 12:08:04 +01001106static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001107 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001108 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001109
Matthew Ranostay9b359472007-11-07 13:03:12 +01001110 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001112
1113 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001115 /* analog pc-beep replaced with digital beep support */
1116 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001117 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1118 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001119 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001120
Matthew Ranostay687cb982008-10-11 13:52:43 -04001121 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1122 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001123
Matthew Ranostay687cb982008-10-11 13:52:43 -04001124 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1125 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001126
1127 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1128 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1129
1130 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1131 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001132 { } /* end */
1133};
1134
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001136 STAC_INPUT_SOURCE(2),
1137 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1138
Matthew Ranostay541eee82007-12-14 12:08:04 +01001139 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001141
1142 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001144 { } /* end */
1145};
1146
Tobin Davis8e21c342007-01-08 11:04:17 +01001147static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001148 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001149 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001150 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001151 { } /* end */
1152};
1153
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001154static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001155 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001156 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001157
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001160
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001163 { } /* end */
1164};
1165
1166/* This needs to be generated dynamically based on sequence */
1167static struct snd_kcontrol_new stac922x_mixer[] = {
1168 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001169 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001171
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001174 { } /* end */
1175};
1176
1177
1178static struct snd_kcontrol_new stac927x_mixer[] = {
1179 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001180 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001181
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001184
1185 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001187
1188 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1189 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001190 { } /* end */
1191};
1192
Takashi Iwai1697055e2007-12-18 18:05:52 +01001193static struct snd_kcontrol_new stac_dmux_mixer = {
1194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1195 .name = "Digital Input Source",
1196 /* count set later */
1197 .info = stac92xx_dmux_enum_info,
1198 .get = stac92xx_dmux_enum_get,
1199 .put = stac92xx_dmux_enum_put,
1200};
1201
Matthew Ranostayd9737752008-09-07 12:03:41 +02001202static struct snd_kcontrol_new stac_smux_mixer = {
1203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001204 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001205 /* count set later */
1206 .info = stac92xx_smux_enum_info,
1207 .get = stac92xx_smux_enum_get,
1208 .put = stac92xx_smux_enum_put,
1209};
1210
Takashi Iwai2134ea42008-01-10 16:53:55 +01001211static const char *slave_vols[] = {
1212 "Front Playback Volume",
1213 "Surround Playback Volume",
1214 "Center Playback Volume",
1215 "LFE Playback Volume",
1216 "Side Playback Volume",
1217 "Headphone Playback Volume",
1218 "Headphone Playback Volume",
1219 "Speaker Playback Volume",
1220 "External Speaker Playback Volume",
1221 "Speaker2 Playback Volume",
1222 NULL
1223};
1224
1225static const char *slave_sws[] = {
1226 "Front Playback Switch",
1227 "Surround Playback Switch",
1228 "Center Playback Switch",
1229 "LFE Playback Switch",
1230 "Side Playback Switch",
1231 "Headphone Playback Switch",
1232 "Headphone Playback Switch",
1233 "Speaker Playback Switch",
1234 "External Speaker Playback Switch",
1235 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001236 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001237 NULL
1238};
1239
Matt2f2f4252005-04-13 14:45:30 +02001240static int stac92xx_build_controls(struct hda_codec *codec)
1241{
1242 struct sigmatel_spec *spec = codec->spec;
1243 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001244 int i;
Matt2f2f4252005-04-13 14:45:30 +02001245
1246 err = snd_hda_add_new_ctls(codec, spec->mixer);
1247 if (err < 0)
1248 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001249
1250 for (i = 0; i < spec->num_mixers; i++) {
1251 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1252 if (err < 0)
1253 return err;
1254 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001255 if (spec->num_dmuxes > 0) {
1256 stac_dmux_mixer.count = spec->num_dmuxes;
1257 err = snd_ctl_add(codec->bus->card,
1258 snd_ctl_new1(&stac_dmux_mixer, codec));
1259 if (err < 0)
1260 return err;
1261 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001262 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001263 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1264 struct hda_input_mux *smux = &spec->private_smux;
1265 /* check for mute support on SPDIF out */
1266 if (wcaps & AC_WCAP_OUT_AMP) {
1267 smux->items[smux->num_items].label = "Off";
1268 smux->items[smux->num_items].index = 0;
1269 smux->num_items++;
1270 spec->spdif_mute = 1;
1271 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001272 stac_smux_mixer.count = spec->num_smuxes;
1273 err = snd_ctl_add(codec->bus->card,
1274 snd_ctl_new1(&stac_smux_mixer, codec));
1275 if (err < 0)
1276 return err;
1277 }
Mattc7d4b2f2005-06-27 14:59:41 +02001278
Mattdabbed62005-06-14 10:19:34 +02001279 if (spec->multiout.dig_out_nid) {
1280 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1281 if (err < 0)
1282 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001283 err = snd_hda_create_spdif_share_sw(codec,
1284 &spec->multiout);
1285 if (err < 0)
1286 return err;
1287 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001288 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04001289 if (spec->dig_in_nid && (!spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001290 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1291 if (err < 0)
1292 return err;
1293 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001294
1295 /* if we have no master control, let's create it */
1296 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001297 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001298 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001299 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001300 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001301 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001302 if (err < 0)
1303 return err;
1304 }
1305 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1306 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1307 NULL, slave_sws);
1308 if (err < 0)
1309 return err;
1310 }
1311
Mattdabbed62005-06-14 10:19:34 +02001312 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001313}
1314
Matt Porter403d1942005-11-29 15:00:51 +01001315static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001316 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001317 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1318};
1319
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001320/*
1321 STAC 9200 pin configs for
1322 102801A8
1323 102801DE
1324 102801E8
1325*/
1326static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001327 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1328 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001329};
1330
1331/*
1332 STAC 9200 pin configs for
1333 102801C0
1334 102801C1
1335*/
1336static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001337 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1338 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001339};
1340
1341/*
1342 STAC 9200 pin configs for
1343 102801C4 (Dell Dimension E310)
1344 102801C5
1345 102801C7
1346 102801D9
1347 102801DA
1348 102801E3
1349*/
1350static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001351 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1352 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001353};
1354
1355
1356/*
1357 STAC 9200-32 pin configs for
1358 102801B5 (Dell Inspiron 630m)
1359 102801D8 (Dell Inspiron 640m)
1360*/
1361static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001362 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1363 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001364};
1365
1366/*
1367 STAC 9200-32 pin configs for
1368 102801C2 (Dell Latitude D620)
1369 102801C8
1370 102801CC (Dell Latitude D820)
1371 102801D4
1372 102801D6
1373*/
1374static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001375 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1376 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001377};
1378
1379/*
1380 STAC 9200-32 pin configs for
1381 102801CE (Dell XPS M1710)
1382 102801CF (Dell Precision M90)
1383*/
1384static unsigned int dell9200_m23_pin_configs[8] = {
1385 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1386 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1387};
1388
1389/*
1390 STAC 9200-32 pin configs for
1391 102801C9
1392 102801CA
1393 102801CB (Dell Latitude 120L)
1394 102801D3
1395*/
1396static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001397 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1398 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001399};
1400
1401/*
1402 STAC 9200-32 pin configs for
1403 102801BD (Dell Inspiron E1505n)
1404 102801EE
1405 102801EF
1406*/
1407static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001408 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1409 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001410};
1411
1412/*
1413 STAC 9200-32 pin configs for
1414 102801F5 (Dell Inspiron 1501)
1415 102801F6
1416*/
1417static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001418 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1419 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001420};
1421
1422/*
1423 STAC 9200-32
1424 102801CD (Dell Inspiron E1705/9400)
1425*/
1426static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001427 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1428 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001429};
1430
Tobin Davisbf277782008-02-03 20:31:47 +01001431static unsigned int oqo9200_pin_configs[8] = {
1432 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1433 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1434};
1435
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001436
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001437static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1438 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001439 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001440 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1441 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1442 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1443 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1444 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1445 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1446 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1447 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1448 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1449 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001450 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001451};
1452
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001453static const char *stac9200_models[STAC_9200_MODELS] = {
1454 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001455 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001456 [STAC_9200_DELL_D21] = "dell-d21",
1457 [STAC_9200_DELL_D22] = "dell-d22",
1458 [STAC_9200_DELL_D23] = "dell-d23",
1459 [STAC_9200_DELL_M21] = "dell-m21",
1460 [STAC_9200_DELL_M22] = "dell-m22",
1461 [STAC_9200_DELL_M23] = "dell-m23",
1462 [STAC_9200_DELL_M24] = "dell-m24",
1463 [STAC_9200_DELL_M25] = "dell-m25",
1464 [STAC_9200_DELL_M26] = "dell-m26",
1465 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001466 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001467 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001468};
1469
1470static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1471 /* SigmaTel reference board */
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1473 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001474 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1476 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001478 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1480 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1482 "unknown Dell", STAC_9200_DELL_D22),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1484 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001486 "Dell Latitude D620", STAC_9200_DELL_M22),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1488 "unknown Dell", STAC_9200_DELL_D23),
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1490 "unknown Dell", STAC_9200_DELL_D23),
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1492 "unknown Dell", STAC_9200_DELL_M22),
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1494 "unknown Dell", STAC_9200_DELL_M24),
1495 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1496 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001497 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001498 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001499 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001500 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001501 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001502 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001503 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001504 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001506 "Dell Precision M90", STAC_9200_DELL_M23),
1507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1508 "unknown Dell", STAC_9200_DELL_M22),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1510 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001512 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001514 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1516 "unknown Dell", STAC_9200_DELL_D23),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1518 "unknown Dell", STAC_9200_DELL_D23),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1520 "unknown Dell", STAC_9200_DELL_D21),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1522 "unknown Dell", STAC_9200_DELL_D23),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1524 "unknown Dell", STAC_9200_DELL_D21),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1526 "unknown Dell", STAC_9200_DELL_M25),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1528 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001530 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1532 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001533 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001534 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001535 /* Gateway machines needs EAPD to be set on resume */
1536 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1537 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1538 STAC_9200_GATEWAY),
1539 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1540 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001541 /* OQO Mobile */
1542 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001543 {} /* terminator */
1544};
1545
Tobin Davis8e21c342007-01-08 11:04:17 +01001546static unsigned int ref925x_pin_configs[8] = {
1547 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001548 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001549};
1550
1551static unsigned int stac925x_MA6_pin_configs[8] = {
1552 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1553 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1554};
1555
Tobin Davis2c11f952007-05-17 09:36:34 +02001556static unsigned int stac925x_PA6_pin_configs[8] = {
1557 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1558 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1559};
1560
Tobin Davis8e21c342007-01-08 11:04:17 +01001561static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001562 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1563 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001564};
1565
1566static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1567 [STAC_REF] = ref925x_pin_configs,
1568 [STAC_M2_2] = stac925xM2_2_pin_configs,
1569 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001570 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001571};
1572
1573static const char *stac925x_models[STAC_925x_MODELS] = {
1574 [STAC_REF] = "ref",
1575 [STAC_M2_2] = "m2-2",
1576 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001577 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001578};
1579
1580static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1581 /* SigmaTel reference board */
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001583 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001584 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1585 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1586 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001587 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001588 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1589 {} /* terminator */
1590};
1591
Matthew Ranostaya7662642008-02-21 07:51:14 +01001592static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001593 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1594 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1595 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001596 0x01452050,
1597};
1598
1599static unsigned int dell_m6_pin_configs[13] = {
1600 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001601 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001602 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1603 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001604};
1605
1606static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001607 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1608 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001609};
1610
1611static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1612 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001613 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001614};
1615
1616static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1617 /* SigmaTel reference board */
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001619 "DFI LanParty", STAC_92HD73XX_REF),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1621 "unknown Dell", STAC_DELL_M6),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1623 "unknown Dell", STAC_DELL_M6),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1625 "unknown Dell", STAC_DELL_M6),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1627 "unknown Dell", STAC_DELL_M6),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1629 "unknown Dell", STAC_DELL_M6),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1631 "unknown Dell", STAC_DELL_M6),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1633 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001634 {} /* terminator */
1635};
1636
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001637static unsigned int ref92hd83xxx_pin_configs[14] = {
1638 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1639 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1640 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1641 0x01451160, 0x98560170,
1642};
1643
1644static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1645 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1646};
1647
1648static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1649 [STAC_92HD83XXX_REF] = "ref",
1650};
1651
1652static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1653 /* SigmaTel reference board */
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1655 "DFI LanParty", STAC_92HD71BXX_REF),
1656};
1657
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001658static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001659 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001660 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001661 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001662};
1663
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001664static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001665 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001666 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001667 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001668};
1669
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001670static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001671 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1672 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001673 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001674};
1675
Matthew Ranostaye035b842007-11-06 11:53:55 +01001676static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1677 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001678 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1679 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001680 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001681};
1682
1683static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1684 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001685 [STAC_DELL_M4_1] = "dell-m4-1",
1686 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001687 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001688};
1689
1690static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1691 /* SigmaTel reference board */
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1693 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1695 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001696 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1697 "unknown Dell", STAC_DELL_M4_1),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1699 "unknown Dell", STAC_DELL_M4_1),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1701 "unknown Dell", STAC_DELL_M4_1),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1703 "unknown Dell", STAC_DELL_M4_1),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1705 "unknown Dell", STAC_DELL_M4_1),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1707 "unknown Dell", STAC_DELL_M4_1),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1709 "unknown Dell", STAC_DELL_M4_1),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1711 "unknown Dell", STAC_DELL_M4_2),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1713 "unknown Dell", STAC_DELL_M4_2),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1715 "unknown Dell", STAC_DELL_M4_2),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1717 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001718 {} /* terminator */
1719};
1720
Matt Porter403d1942005-11-29 15:00:51 +01001721static unsigned int ref922x_pin_configs[10] = {
1722 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1723 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001724 0x40000100, 0x40000100,
1725};
1726
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001727/*
1728 STAC 922X pin configs for
1729 102801A7
1730 102801AB
1731 102801A9
1732 102801D1
1733 102801D2
1734*/
1735static unsigned int dell_922x_d81_pin_configs[10] = {
1736 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1737 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1738 0x01813122, 0x400001f2,
1739};
1740
1741/*
1742 STAC 922X pin configs for
1743 102801AC
1744 102801D0
1745*/
1746static unsigned int dell_922x_d82_pin_configs[10] = {
1747 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1748 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1749 0x01813122, 0x400001f1,
1750};
1751
1752/*
1753 STAC 922X pin configs for
1754 102801BF
1755*/
1756static unsigned int dell_922x_m81_pin_configs[10] = {
1757 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1758 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1759 0x40C003f1, 0x405003f0,
1760};
1761
1762/*
1763 STAC 9221 A1 pin configs for
1764 102801D7 (Dell XPS M1210)
1765*/
1766static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001767 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1768 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001769 0x508003f3, 0x405003f4,
1770};
1771
Matt Porter403d1942005-11-29 15:00:51 +01001772static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001773 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001774 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1775 0x02a19120, 0x40000100,
1776};
1777
1778static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001779 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1780 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001781 0x02a19320, 0x40000100,
1782};
1783
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001784static unsigned int intel_mac_v1_pin_configs[10] = {
1785 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1786 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001787 0x400000fc, 0x400000fb,
1788};
1789
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001790static unsigned int intel_mac_v2_pin_configs[10] = {
1791 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1792 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001793 0x400000fc, 0x400000fb,
1794};
1795
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001796static unsigned int intel_mac_v3_pin_configs[10] = {
1797 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1798 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1799 0x400000fc, 0x400000fb,
1800};
1801
1802static unsigned int intel_mac_v4_pin_configs[10] = {
1803 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1804 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1805 0x400000fc, 0x400000fb,
1806};
1807
1808static unsigned int intel_mac_v5_pin_configs[10] = {
1809 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1810 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1811 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001812};
1813
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001814static unsigned int ecs202_pin_configs[10] = {
1815 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1816 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1817 0x9037012e, 0x40e000f2,
1818};
Takashi Iwai76c08822007-06-19 12:17:42 +02001819
Takashi Iwai19039bd2006-06-28 15:52:16 +02001820static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001821 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001822 [STAC_D945GTP3] = d945gtp3_pin_configs,
1823 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001824 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1825 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1826 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1827 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1828 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001829 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001830 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001831 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1832 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1833 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1834 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1835 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1836 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001837 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001838 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1839 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1840 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1841 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001842};
1843
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001844static const char *stac922x_models[STAC_922X_MODELS] = {
1845 [STAC_D945_REF] = "ref",
1846 [STAC_D945GTP5] = "5stack",
1847 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001848 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1849 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1850 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1851 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1852 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001853 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001854 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001855 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001856 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001857 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1858 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001859 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001860 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001861 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001862 [STAC_922X_DELL_D81] = "dell-d81",
1863 [STAC_922X_DELL_D82] = "dell-d82",
1864 [STAC_922X_DELL_M81] = "dell-m81",
1865 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001866};
1867
1868static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1869 /* SigmaTel reference board */
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1871 "DFI LanParty", STAC_D945_REF),
1872 /* Intel 945G based systems */
1873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1874 "Intel D945G", STAC_D945GTP3),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1876 "Intel D945G", STAC_D945GTP3),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1878 "Intel D945G", STAC_D945GTP3),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1880 "Intel D945G", STAC_D945GTP3),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1882 "Intel D945G", STAC_D945GTP3),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1884 "Intel D945G", STAC_D945GTP3),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1886 "Intel D945G", STAC_D945GTP3),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1888 "Intel D945G", STAC_D945GTP3),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1890 "Intel D945G", STAC_D945GTP3),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1892 "Intel D945G", STAC_D945GTP3),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1894 "Intel D945G", STAC_D945GTP3),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1896 "Intel D945G", STAC_D945GTP3),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1898 "Intel D945G", STAC_D945GTP3),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1900 "Intel D945G", STAC_D945GTP3),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1902 "Intel D945G", STAC_D945GTP3),
1903 /* Intel D945G 5-stack systems */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1905 "Intel D945G", STAC_D945GTP5),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1907 "Intel D945G", STAC_D945GTP5),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1909 "Intel D945G", STAC_D945GTP5),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1911 "Intel D945G", STAC_D945GTP5),
1912 /* Intel 945P based systems */
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1914 "Intel D945P", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1916 "Intel D945P", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1918 "Intel D945P", STAC_D945GTP3),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1920 "Intel D945P", STAC_D945GTP3),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1922 "Intel D945P", STAC_D945GTP3),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1924 "Intel D945P", STAC_D945GTP5),
1925 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001926 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001927 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001928 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001929 /* Dell systems */
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1931 "unknown Dell", STAC_922X_DELL_D81),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1933 "unknown Dell", STAC_922X_DELL_D81),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1935 "unknown Dell", STAC_922X_DELL_D81),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1937 "unknown Dell", STAC_922X_DELL_D82),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1939 "unknown Dell", STAC_922X_DELL_M81),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1941 "unknown Dell", STAC_922X_DELL_D82),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1943 "unknown Dell", STAC_922X_DELL_D81),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1945 "unknown Dell", STAC_922X_DELL_D81),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1947 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001948 /* ECS/PC Chips boards */
1949 SND_PCI_QUIRK(0x1019, 0x2144,
1950 "ECS/PC chips", STAC_ECS_202),
1951 SND_PCI_QUIRK(0x1019, 0x2608,
1952 "ECS/PC chips", STAC_ECS_202),
1953 SND_PCI_QUIRK(0x1019, 0x2633,
1954 "ECS/PC chips P17G/1333", STAC_ECS_202),
1955 SND_PCI_QUIRK(0x1019, 0x2811,
1956 "ECS/PC chips", STAC_ECS_202),
1957 SND_PCI_QUIRK(0x1019, 0x2812,
1958 "ECS/PC chips", STAC_ECS_202),
1959 SND_PCI_QUIRK(0x1019, 0x2813,
1960 "ECS/PC chips", STAC_ECS_202),
1961 SND_PCI_QUIRK(0x1019, 0x2814,
1962 "ECS/PC chips", STAC_ECS_202),
1963 SND_PCI_QUIRK(0x1019, 0x2815,
1964 "ECS/PC chips", STAC_ECS_202),
1965 SND_PCI_QUIRK(0x1019, 0x2816,
1966 "ECS/PC chips", STAC_ECS_202),
1967 SND_PCI_QUIRK(0x1019, 0x2817,
1968 "ECS/PC chips", STAC_ECS_202),
1969 SND_PCI_QUIRK(0x1019, 0x2818,
1970 "ECS/PC chips", STAC_ECS_202),
1971 SND_PCI_QUIRK(0x1019, 0x2819,
1972 "ECS/PC chips", STAC_ECS_202),
1973 SND_PCI_QUIRK(0x1019, 0x2820,
1974 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001975 {} /* terminator */
1976};
1977
Matt Porter3cc08dc2006-01-23 15:27:49 +01001978static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001979 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1980 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1981 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1982 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001983};
1984
Tobin Davis93ed1502006-09-01 21:03:12 +02001985static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001986 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1987 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1988 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1989 0x40000100, 0x40000100
1990};
1991
Tobin Davis93ed1502006-09-01 21:03:12 +02001992static unsigned int d965_5st_pin_configs[14] = {
1993 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1994 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1995 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1996 0x40000100, 0x40000100
1997};
1998
Tobin Davis4ff076e2007-08-07 11:48:12 +02001999static unsigned int dell_3st_pin_configs[14] = {
2000 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2001 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002002 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002003 0x40c003fc, 0x40000100
2004};
2005
Tobin Davis93ed1502006-09-01 21:03:12 +02002006static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002007 [STAC_D965_REF] = ref927x_pin_configs,
2008 [STAC_D965_3ST] = d965_3st_pin_configs,
2009 [STAC_D965_5ST] = d965_5st_pin_configs,
2010 [STAC_DELL_3ST] = dell_3st_pin_configs,
2011 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002012};
2013
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002014static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002015 [STAC_D965_REF] = "ref",
2016 [STAC_D965_3ST] = "3stack",
2017 [STAC_D965_5ST] = "5stack",
2018 [STAC_DELL_3ST] = "dell-3stack",
2019 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002020};
2021
2022static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2023 /* SigmaTel reference board */
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2025 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002026 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002029 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002046 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002051 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002055 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002056 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002060 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002070 {} /* terminator */
2071};
2072
Matt Porterf3302a52006-07-31 12:49:34 +02002073static unsigned int ref9205_pin_configs[12] = {
2074 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002075 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002076 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002077};
2078
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002079/*
2080 STAC 9205 pin configs for
2081 102801F1
2082 102801F2
2083 102801FC
2084 102801FD
2085 10280204
2086 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002087 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002088*/
2089static unsigned int dell_9205_m42_pin_configs[12] = {
2090 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2091 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2092 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2093};
2094
2095/*
2096 STAC 9205 pin configs for
2097 102801F9
2098 102801FA
2099 102801FE
2100 102801FF (Dell Precision M4300)
2101 10280206
2102 10280200
2103 10280201
2104*/
2105static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002106 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2107 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2108 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2109};
2110
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002111static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002112 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2113 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2114 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2115};
2116
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002117static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002118 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002119 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2120 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2121 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002122};
2123
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002124static const char *stac9205_models[STAC_9205_MODELS] = {
2125 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002126 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002127 [STAC_9205_DELL_M43] = "dell-m43",
2128 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002129};
2130
2131static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2132 /* SigmaTel reference board */
2133 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2134 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2136 "unknown Dell", STAC_9205_DELL_M42),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2138 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002140 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2142 "Dell Precision", STAC_9205_DELL_M43),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2144 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2146 "unknown Dell", STAC_9205_DELL_M42),
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2148 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2150 "Dell Precision", STAC_9205_DELL_M43),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002152 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2154 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2156 "Dell Precision", STAC_9205_DELL_M43),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2158 "Dell Precision", STAC_9205_DELL_M43),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2160 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2162 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2164 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002165 {} /* terminator */
2166};
2167
Richard Fish11b44bb2006-08-23 18:31:34 +02002168static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2169{
2170 int i;
2171 struct sigmatel_spec *spec = codec->spec;
2172
2173 if (! spec->bios_pin_configs) {
2174 spec->bios_pin_configs = kcalloc(spec->num_pins,
2175 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2176 if (! spec->bios_pin_configs)
2177 return -ENOMEM;
2178 }
2179
2180 for (i = 0; i < spec->num_pins; i++) {
2181 hda_nid_t nid = spec->pin_nids[i];
2182 unsigned int pin_cfg;
2183
2184 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2185 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2186 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2187 nid, pin_cfg);
2188 spec->bios_pin_configs[i] = pin_cfg;
2189 }
2190
2191 return 0;
2192}
2193
Matthew Ranostay87d48362007-07-17 11:52:24 +02002194static void stac92xx_set_config_reg(struct hda_codec *codec,
2195 hda_nid_t pin_nid, unsigned int pin_config)
2196{
2197 int i;
2198 snd_hda_codec_write(codec, pin_nid, 0,
2199 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2200 pin_config & 0x000000ff);
2201 snd_hda_codec_write(codec, pin_nid, 0,
2202 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2203 (pin_config & 0x0000ff00) >> 8);
2204 snd_hda_codec_write(codec, pin_nid, 0,
2205 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2206 (pin_config & 0x00ff0000) >> 16);
2207 snd_hda_codec_write(codec, pin_nid, 0,
2208 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2209 pin_config >> 24);
2210 i = snd_hda_codec_read(codec, pin_nid, 0,
2211 AC_VERB_GET_CONFIG_DEFAULT,
2212 0x00);
2213 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2214 pin_nid, i);
2215}
2216
Matt2f2f4252005-04-13 14:45:30 +02002217static void stac92xx_set_config_regs(struct hda_codec *codec)
2218{
2219 int i;
2220 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002221
Matthew Ranostay87d48362007-07-17 11:52:24 +02002222 if (!spec->pin_configs)
2223 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002224
Matthew Ranostay87d48362007-07-17 11:52:24 +02002225 for (i = 0; i < spec->num_pins; i++)
2226 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2227 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002228}
Matt2f2f4252005-04-13 14:45:30 +02002229
Matt2f2f4252005-04-13 14:45:30 +02002230/*
2231 * Analog playback callbacks
2232 */
2233static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2234 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002235 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002236{
2237 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002238 if (spec->stream_delay)
2239 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002240 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2241 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002242}
2243
2244static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2245 struct hda_codec *codec,
2246 unsigned int stream_tag,
2247 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002248 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002249{
2250 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002251 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002252}
2253
2254static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2255 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002256 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002257{
2258 struct sigmatel_spec *spec = codec->spec;
2259 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2260}
2261
2262/*
Mattdabbed62005-06-14 10:19:34 +02002263 * Digital playback callbacks
2264 */
2265static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2266 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002267 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002268{
2269 struct sigmatel_spec *spec = codec->spec;
2270 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2271}
2272
2273static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2274 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002275 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002276{
2277 struct sigmatel_spec *spec = codec->spec;
2278 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2279}
2280
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002281static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2282 struct hda_codec *codec,
2283 unsigned int stream_tag,
2284 unsigned int format,
2285 struct snd_pcm_substream *substream)
2286{
2287 struct sigmatel_spec *spec = codec->spec;
2288 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2289 stream_tag, format, substream);
2290}
2291
Mattdabbed62005-06-14 10:19:34 +02002292
2293/*
Matt2f2f4252005-04-13 14:45:30 +02002294 * Analog capture callbacks
2295 */
2296static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2297 struct hda_codec *codec,
2298 unsigned int stream_tag,
2299 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002300 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002301{
2302 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002303 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002304
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002305 if (spec->powerdown_adcs) {
2306 msleep(40);
2307 snd_hda_codec_write_cache(codec, nid, 0,
2308 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2309 }
2310 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002311 return 0;
2312}
2313
2314static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2315 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002316 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002317{
2318 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002319 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002320
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002321 snd_hda_codec_cleanup_stream(codec, nid);
2322 if (spec->powerdown_adcs)
2323 snd_hda_codec_write_cache(codec, nid, 0,
2324 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002325 return 0;
2326}
2327
Mattdabbed62005-06-14 10:19:34 +02002328static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2329 .substreams = 1,
2330 .channels_min = 2,
2331 .channels_max = 2,
2332 /* NID is set in stac92xx_build_pcms */
2333 .ops = {
2334 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002335 .close = stac92xx_dig_playback_pcm_close,
2336 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002337 },
2338};
2339
2340static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2341 .substreams = 1,
2342 .channels_min = 2,
2343 .channels_max = 2,
2344 /* NID is set in stac92xx_build_pcms */
2345};
2346
Matt2f2f4252005-04-13 14:45:30 +02002347static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2348 .substreams = 1,
2349 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002350 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002351 .nid = 0x02, /* NID to query formats and rates */
2352 .ops = {
2353 .open = stac92xx_playback_pcm_open,
2354 .prepare = stac92xx_playback_pcm_prepare,
2355 .cleanup = stac92xx_playback_pcm_cleanup
2356 },
2357};
2358
Matt Porter3cc08dc2006-01-23 15:27:49 +01002359static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2360 .substreams = 1,
2361 .channels_min = 2,
2362 .channels_max = 2,
2363 .nid = 0x06, /* NID to query formats and rates */
2364 .ops = {
2365 .open = stac92xx_playback_pcm_open,
2366 .prepare = stac92xx_playback_pcm_prepare,
2367 .cleanup = stac92xx_playback_pcm_cleanup
2368 },
2369};
2370
Matt2f2f4252005-04-13 14:45:30 +02002371static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002372 .channels_min = 2,
2373 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002374 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002375 .ops = {
2376 .prepare = stac92xx_capture_pcm_prepare,
2377 .cleanup = stac92xx_capture_pcm_cleanup
2378 },
2379};
2380
2381static int stac92xx_build_pcms(struct hda_codec *codec)
2382{
2383 struct sigmatel_spec *spec = codec->spec;
2384 struct hda_pcm *info = spec->pcm_rec;
2385
2386 codec->num_pcms = 1;
2387 codec->pcm_info = info;
2388
Mattc7d4b2f2005-06-27 14:59:41 +02002389 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002390 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002391 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002392 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002393 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002394
2395 if (spec->alt_switch) {
2396 codec->num_pcms++;
2397 info++;
2398 info->name = "STAC92xx Analog Alt";
2399 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2400 }
Matt2f2f4252005-04-13 14:45:30 +02002401
Mattdabbed62005-06-14 10:19:34 +02002402 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2403 codec->num_pcms++;
2404 info++;
2405 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002406 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002407 if (spec->multiout.dig_out_nid) {
2408 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2409 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2410 }
2411 if (spec->dig_in_nid) {
2412 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2413 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2414 }
2415 }
2416
Matt2f2f4252005-04-13 14:45:30 +02002417 return 0;
2418}
2419
Takashi Iwaic960a032006-03-23 17:06:28 +01002420static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2421{
2422 unsigned int pincap = snd_hda_param_read(codec, nid,
2423 AC_PAR_PIN_CAP);
2424 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2425 if (pincap & AC_PINCAP_VREF_100)
2426 return AC_PINCTL_VREF_100;
2427 if (pincap & AC_PINCAP_VREF_80)
2428 return AC_PINCTL_VREF_80;
2429 if (pincap & AC_PINCAP_VREF_50)
2430 return AC_PINCTL_VREF_50;
2431 if (pincap & AC_PINCAP_VREF_GRD)
2432 return AC_PINCTL_VREF_GRD;
2433 return 0;
2434}
2435
Matt Porter403d1942005-11-29 15:00:51 +01002436static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2437
2438{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002439 snd_hda_codec_write_cache(codec, nid, 0,
2440 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002441}
2442
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002443#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2444
2445static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2446 struct snd_ctl_elem_value *ucontrol)
2447{
2448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2449 struct sigmatel_spec *spec = codec->spec;
2450
2451 ucontrol->value.integer.value[0] = spec->hp_switch;
2452 return 0;
2453}
2454
2455static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2456 struct snd_ctl_elem_value *ucontrol)
2457{
2458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2459 struct sigmatel_spec *spec = codec->spec;
2460
2461 spec->hp_switch = ucontrol->value.integer.value[0];
2462
2463 /* check to be sure that the ports are upto date with
2464 * switch changes
2465 */
2466 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2467
2468 return 1;
2469}
2470
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002471#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002472
2473static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2474{
2475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2476 struct sigmatel_spec *spec = codec->spec;
2477 int io_idx = kcontrol-> private_value & 0xff;
2478
2479 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2480 return 0;
2481}
2482
2483static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2484{
2485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2486 struct sigmatel_spec *spec = codec->spec;
2487 hda_nid_t nid = kcontrol->private_value >> 8;
2488 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002489 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002490
2491 spec->io_switch[io_idx] = val;
2492
2493 if (val)
2494 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002495 else {
2496 unsigned int pinctl = AC_PINCTL_IN_EN;
2497 if (io_idx) /* set VREF for mic */
2498 pinctl |= stac92xx_get_vref(codec, nid);
2499 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2500 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002501
2502 /* check the auto-mute again: we need to mute/unmute the speaker
2503 * appropriately according to the pin direction
2504 */
2505 if (spec->hp_detect)
2506 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2507
Matt Porter403d1942005-11-29 15:00:51 +01002508 return 1;
2509}
2510
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002511#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2512
2513static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2514 struct snd_ctl_elem_value *ucontrol)
2515{
2516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2517 struct sigmatel_spec *spec = codec->spec;
2518
2519 ucontrol->value.integer.value[0] = spec->clfe_swap;
2520 return 0;
2521}
2522
2523static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2524 struct snd_ctl_elem_value *ucontrol)
2525{
2526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2527 struct sigmatel_spec *spec = codec->spec;
2528 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002529 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002530
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002531 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002532 return 0;
2533
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002534 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002535
2536 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2537 spec->clfe_swap ? 0x4 : 0x0);
2538
2539 return 1;
2540}
2541
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002542#define STAC_CODEC_HP_SWITCH(xname) \
2543 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2544 .name = xname, \
2545 .index = 0, \
2546 .info = stac92xx_hp_switch_info, \
2547 .get = stac92xx_hp_switch_get, \
2548 .put = stac92xx_hp_switch_put, \
2549 }
2550
Matt Porter403d1942005-11-29 15:00:51 +01002551#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2552 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2553 .name = xname, \
2554 .index = 0, \
2555 .info = stac92xx_io_switch_info, \
2556 .get = stac92xx_io_switch_get, \
2557 .put = stac92xx_io_switch_put, \
2558 .private_value = xpval, \
2559 }
2560
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002561#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2562 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2563 .name = xname, \
2564 .index = 0, \
2565 .info = stac92xx_clfe_switch_info, \
2566 .get = stac92xx_clfe_switch_get, \
2567 .put = stac92xx_clfe_switch_put, \
2568 .private_value = xpval, \
2569 }
Matt Porter403d1942005-11-29 15:00:51 +01002570
Mattc7d4b2f2005-06-27 14:59:41 +02002571enum {
2572 STAC_CTL_WIDGET_VOL,
2573 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002574 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002575 STAC_CTL_WIDGET_AMP_MUX,
2576 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002577 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002578 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002579 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002580};
2581
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002582static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002583 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2584 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002585 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002586 STAC_AMP_MUX,
2587 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002588 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002589 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002590 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002591};
2592
2593/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002594static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2595 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002596{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002597 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002598
2599 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2600 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2601
2602 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2603 if (! knew)
2604 return -ENOMEM;
2605 if (spec->kctl_alloc) {
2606 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2607 kfree(spec->kctl_alloc);
2608 }
2609 spec->kctl_alloc = knew;
2610 spec->num_kctl_alloc = num;
2611 }
2612
2613 knew = &spec->kctl_alloc[spec->num_kctl_used];
2614 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002615 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002616 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002617 if (! knew->name)
2618 return -ENOMEM;
2619 knew->private_value = val;
2620 spec->num_kctl_used++;
2621 return 0;
2622}
2623
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002624
2625/* add dynamic controls */
2626static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2627 const char *name, unsigned long val)
2628{
2629 return stac92xx_add_control_idx(spec, type, 0, name, val);
2630}
2631
Matt Porter403d1942005-11-29 15:00:51 +01002632/* flag inputs as additional dynamic lineouts */
2633static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2634{
2635 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002636 unsigned int wcaps, wtype;
2637 int i, num_dacs = 0;
2638
2639 /* use the wcaps cache to count all DACs available for line-outs */
2640 for (i = 0; i < codec->num_nodes; i++) {
2641 wcaps = codec->wcaps[i];
2642 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002643
Steve Longerbeam7b043892007-05-03 20:50:03 +02002644 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2645 num_dacs++;
2646 }
Matt Porter403d1942005-11-29 15:00:51 +01002647
Steve Longerbeam7b043892007-05-03 20:50:03 +02002648 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2649
Matt Porter403d1942005-11-29 15:00:51 +01002650 switch (cfg->line_outs) {
2651 case 3:
2652 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002653 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002654 cfg->line_out_pins[cfg->line_outs] =
2655 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002656 spec->line_switch = 1;
2657 cfg->line_outs++;
2658 }
2659 break;
2660 case 2:
2661 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002662 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002663 cfg->line_out_pins[cfg->line_outs] =
2664 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002665 spec->line_switch = 1;
2666 cfg->line_outs++;
2667 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002668 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002669 cfg->line_out_pins[cfg->line_outs] =
2670 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002671 spec->mic_switch = 1;
2672 cfg->line_outs++;
2673 }
2674 break;
2675 case 1:
2676 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002677 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002678 cfg->line_out_pins[cfg->line_outs] =
2679 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002680 spec->line_switch = 1;
2681 cfg->line_outs++;
2682 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002683 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002684 cfg->line_out_pins[cfg->line_outs] =
2685 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002686 spec->mic_switch = 1;
2687 cfg->line_outs++;
2688 }
2689 break;
2690 }
2691
2692 return 0;
2693}
2694
Steve Longerbeam7b043892007-05-03 20:50:03 +02002695
2696static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2697{
2698 int i;
2699
2700 for (i = 0; i < spec->multiout.num_dacs; i++) {
2701 if (spec->multiout.dac_nids[i] == nid)
2702 return 1;
2703 }
2704
2705 return 0;
2706}
2707
Matt Porter3cc08dc2006-01-23 15:27:49 +01002708/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002709 * Fill in the dac_nids table from the parsed pin configuration
2710 * This function only works when every pin in line_out_pins[]
2711 * contains atleast one DAC in its connection list. Some 92xx
2712 * codecs are not connected directly to a DAC, such as the 9200
2713 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002714 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002715static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002716 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002717{
2718 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002719 int i, j, conn_len = 0;
2720 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2721 unsigned int wcaps, wtype;
2722
Mattc7d4b2f2005-06-27 14:59:41 +02002723 for (i = 0; i < cfg->line_outs; i++) {
2724 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002725 conn_len = snd_hda_get_connections(codec, nid, conn,
2726 HDA_MAX_CONNECTIONS);
2727 for (j = 0; j < conn_len; j++) {
2728 wcaps = snd_hda_param_read(codec, conn[j],
2729 AC_PAR_AUDIO_WIDGET_CAP);
2730 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002731 if (wtype != AC_WID_AUD_OUT ||
2732 (wcaps & AC_WCAP_DIGITAL))
2733 continue;
2734 /* conn[j] is a DAC routed to this line-out */
2735 if (!is_in_dac_nids(spec, conn[j]))
2736 break;
2737 }
2738
2739 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002740 if (spec->multiout.num_dacs > 0) {
2741 /* we have already working output pins,
2742 * so let's drop the broken ones again
2743 */
2744 cfg->line_outs = spec->multiout.num_dacs;
2745 break;
2746 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002747 /* error out, no available DAC found */
2748 snd_printk(KERN_ERR
2749 "%s: No available DAC for pin 0x%x\n",
2750 __func__, nid);
2751 return -ENODEV;
2752 }
2753
2754 spec->multiout.dac_nids[i] = conn[j];
2755 spec->multiout.num_dacs++;
2756 if (conn_len > 1) {
2757 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002758 snd_hda_codec_write_cache(codec, nid, 0,
2759 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002760
2761 }
Mattc7d4b2f2005-06-27 14:59:41 +02002762 }
2763
Steve Longerbeam7b043892007-05-03 20:50:03 +02002764 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2765 spec->multiout.num_dacs,
2766 spec->multiout.dac_nids[0],
2767 spec->multiout.dac_nids[1],
2768 spec->multiout.dac_nids[2],
2769 spec->multiout.dac_nids[3],
2770 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002771 return 0;
2772}
2773
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002774/* create volume control/switch for the given prefx type */
2775static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2776{
2777 char name[32];
2778 int err;
2779
2780 sprintf(name, "%s Playback Volume", pfx);
2781 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2782 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2783 if (err < 0)
2784 return err;
2785 sprintf(name, "%s Playback Switch", pfx);
2786 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2787 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2788 if (err < 0)
2789 return err;
2790 return 0;
2791}
2792
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002793static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2794{
2795 if (!spec->multiout.hp_nid)
2796 spec->multiout.hp_nid = nid;
2797 else if (spec->multiout.num_dacs > 4) {
2798 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2799 return 1;
2800 } else {
2801 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2802 spec->multiout.num_dacs++;
2803 }
2804 return 0;
2805}
2806
2807static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2808{
2809 if (is_in_dac_nids(spec, nid))
2810 return 1;
2811 if (spec->multiout.hp_nid == nid)
2812 return 1;
2813 return 0;
2814}
2815
Mattc7d4b2f2005-06-27 14:59:41 +02002816/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002817static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002818 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002819{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002820 static const char *chname[4] = {
2821 "Front", "Surround", NULL /*CLFE*/, "Side"
2822 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002823 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002824 int i, err;
2825
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002826 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002827 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002828
2829
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002830 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002831 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002832 continue;
2833
2834 nid = spec->multiout.dac_nids[i];
2835
2836 if (i == 2) {
2837 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002838 err = create_controls(spec, "Center", nid, 1);
2839 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002840 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002841 err = create_controls(spec, "LFE", nid, 2);
2842 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002843 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002844
2845 wid_caps = get_wcaps(codec, nid);
2846
2847 if (wid_caps & AC_WCAP_LR_SWAP) {
2848 err = stac92xx_add_control(spec,
2849 STAC_CTL_WIDGET_CLFE_SWITCH,
2850 "Swap Center/LFE Playback Switch", nid);
2851
2852 if (err < 0)
2853 return err;
2854 }
2855
Mattc7d4b2f2005-06-27 14:59:41 +02002856 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002857 err = create_controls(spec, chname[i], nid, 3);
2858 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002859 return err;
2860 }
2861 }
2862
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002863 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2864 cfg->hp_outs && !spec->multiout.hp_nid)
2865 spec->multiout.hp_nid = nid;
2866
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002867 if (cfg->hp_outs > 1) {
2868 err = stac92xx_add_control(spec,
2869 STAC_CTL_WIDGET_HP_SWITCH,
2870 "Headphone as Line Out Switch", 0);
2871 if (err < 0)
2872 return err;
2873 }
2874
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002875 if (spec->line_switch) {
2876 nid = cfg->input_pins[AUTO_PIN_LINE];
2877 pincap = snd_hda_param_read(codec, nid,
2878 AC_PAR_PIN_CAP);
2879 if (pincap & AC_PINCAP_OUT) {
2880 err = stac92xx_add_control(spec,
2881 STAC_CTL_WIDGET_IO_SWITCH,
2882 "Line In as Output Switch", nid << 8);
2883 if (err < 0)
2884 return err;
2885 }
2886 }
Matt Porter403d1942005-11-29 15:00:51 +01002887
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002888 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002889 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002890 unsigned int mic_pin = AUTO_PIN_MIC;
2891again:
2892 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002893 def_conf = snd_hda_codec_read(codec, nid, 0,
2894 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002895 /* some laptops have an internal analog microphone
2896 * which can't be used as a output */
2897 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2898 pincap = snd_hda_param_read(codec, nid,
2899 AC_PAR_PIN_CAP);
2900 if (pincap & AC_PINCAP_OUT) {
2901 err = stac92xx_add_control(spec,
2902 STAC_CTL_WIDGET_IO_SWITCH,
2903 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002904 nid = snd_hda_codec_read(codec, nid, 0,
2905 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2906 if (!check_in_dac_nids(spec, nid))
2907 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002908 if (err < 0)
2909 return err;
2910 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002911 } else if (mic_pin == AUTO_PIN_MIC) {
2912 mic_pin = AUTO_PIN_FRONT_MIC;
2913 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002914 }
2915 }
Matt Porter403d1942005-11-29 15:00:51 +01002916
Mattc7d4b2f2005-06-27 14:59:41 +02002917 return 0;
2918}
2919
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002920/* add playback controls for Speaker and HP outputs */
2921static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2922 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002923{
2924 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002925 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002926 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002927
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002928 old_num_dacs = spec->multiout.num_dacs;
2929 for (i = 0; i < cfg->hp_outs; i++) {
2930 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2931 if (wid_caps & AC_WCAP_UNSOL_CAP)
2932 spec->hp_detect = 1;
2933 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2934 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2935 if (check_in_dac_nids(spec, nid))
2936 nid = 0;
2937 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002938 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002939 add_spec_dacs(spec, nid);
2940 }
2941 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002942 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002943 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2944 if (check_in_dac_nids(spec, nid))
2945 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002946 if (! nid)
2947 continue;
2948 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002949 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002950 for (i = 0; i < cfg->line_outs; i++) {
2951 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2952 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2953 if (check_in_dac_nids(spec, nid))
2954 nid = 0;
2955 if (! nid)
2956 continue;
2957 add_spec_dacs(spec, nid);
2958 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002959 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2960 static const char *pfxs[] = {
2961 "Speaker", "External Speaker", "Speaker2",
2962 };
2963 err = create_controls(spec, pfxs[i - old_num_dacs],
2964 spec->multiout.dac_nids[i], 3);
2965 if (err < 0)
2966 return err;
2967 }
2968 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002969 err = create_controls(spec, "Headphone",
2970 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002971 if (err < 0)
2972 return err;
2973 }
Mattc7d4b2f2005-06-27 14:59:41 +02002974
2975 return 0;
2976}
2977
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002978/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002979static const char *stac92xx_mono_labels[4] = {
2980 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002981};
2982
2983/* create mono mux for mono out on capable codecs */
2984static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2985{
2986 struct sigmatel_spec *spec = codec->spec;
2987 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2988 int i, num_cons;
2989 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2990
2991 num_cons = snd_hda_get_connections(codec,
2992 spec->mono_nid,
2993 con_lst,
2994 HDA_MAX_NUM_INPUTS);
2995 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2996 return -EINVAL;
2997
2998 for (i = 0; i < num_cons; i++) {
2999 mono_mux->items[mono_mux->num_items].label =
3000 stac92xx_mono_labels[i];
3001 mono_mux->items[mono_mux->num_items].index = i;
3002 mono_mux->num_items++;
3003 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003004
3005 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3006 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003007}
3008
Matthew Ranostay89385032008-09-11 09:49:39 -04003009/* labels for amp mux outputs */
3010static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003011 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003012};
3013
3014/* create amp out controls mux on capable codecs */
3015static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3016{
3017 struct sigmatel_spec *spec = codec->spec;
3018 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3019 int i, err;
3020
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003021 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003022 amp_mux->items[amp_mux->num_items].label =
3023 stac92xx_amp_labels[i];
3024 amp_mux->items[amp_mux->num_items].index = i;
3025 amp_mux->num_items++;
3026 }
3027
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003028 if (spec->num_amps > 1) {
3029 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3030 "Amp Selector Capture Switch", 0);
3031 if (err < 0)
3032 return err;
3033 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003034 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3035 "Amp Capture Volume",
3036 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3037}
3038
3039
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003040/* create PC beep volume controls */
3041static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3042 hda_nid_t nid)
3043{
3044 struct sigmatel_spec *spec = codec->spec;
3045 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3046 int err;
3047
3048 /* check for mute support for the the amp */
3049 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3050 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3051 "PC Beep Playback Switch",
3052 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3053 if (err < 0)
3054 return err;
3055 }
3056
3057 /* check to see if there is volume support for the amp */
3058 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3059 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3060 "PC Beep Playback Volume",
3061 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3062 if (err < 0)
3063 return err;
3064 }
3065 return 0;
3066}
3067
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003068static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3069{
3070 struct sigmatel_spec *spec = codec->spec;
3071 int wcaps, nid, i, err = 0;
3072
3073 for (i = 0; i < spec->num_muxes; i++) {
3074 nid = spec->mux_nids[i];
3075 wcaps = get_wcaps(codec, nid);
3076
3077 if (wcaps & AC_WCAP_OUT_AMP) {
3078 err = stac92xx_add_control_idx(spec,
3079 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3080 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3081 if (err < 0)
3082 return err;
3083 }
3084 }
3085 return 0;
3086};
3087
Matthew Ranostayd9737752008-09-07 12:03:41 +02003088static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003089 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003090};
3091
3092static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3093{
3094 struct sigmatel_spec *spec = codec->spec;
3095 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003096 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003097 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003098 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003099
3100 num_cons = snd_hda_get_connections(codec,
3101 spec->smux_nids[0],
3102 con_lst,
3103 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003104 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003105 return -EINVAL;
3106
Matthew Ranostay65973632008-09-16 10:39:37 -04003107 if (!labels)
3108 labels = stac92xx_spdif_labels;
3109
Matthew Ranostayd9737752008-09-07 12:03:41 +02003110 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003111 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003112 spdif_mux->items[spdif_mux->num_items].index = i;
3113 spdif_mux->num_items++;
3114 }
3115
3116 return 0;
3117}
3118
Matt Porter8b657272006-10-26 17:12:59 +02003119/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003120static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003121 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3122 "Digital Mic 3", "Digital Mic 4"
3123};
3124
3125/* create playback/capture controls for input pins on dmic capable codecs */
3126static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3127 const struct auto_pin_cfg *cfg)
3128{
3129 struct sigmatel_spec *spec = codec->spec;
3130 struct hda_input_mux *dimux = &spec->private_dimux;
3131 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003132 int err, i, j;
3133 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003134
3135 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3136 dimux->items[dimux->num_items].index = 0;
3137 dimux->num_items++;
3138
3139 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003140 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003141 int index;
3142 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003143 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003144 unsigned int def_conf;
3145
3146 def_conf = snd_hda_codec_read(codec,
3147 spec->dmic_nids[i],
3148 0,
3149 AC_VERB_GET_CONFIG_DEFAULT,
3150 0);
3151 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3152 continue;
3153
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003154 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003155 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003156 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003157 con_lst,
3158 HDA_MAX_NUM_INPUTS);
3159 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003160 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003161 index = j;
3162 goto found;
3163 }
3164 continue;
3165found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003166 wcaps = get_wcaps(codec, nid) &
3167 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003168
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003169 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003170 sprintf(name, "%s Capture Volume",
3171 stac92xx_dmic_labels[dimux->num_items]);
3172
3173 err = stac92xx_add_control(spec,
3174 STAC_CTL_WIDGET_VOL,
3175 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003176 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3177 (wcaps & AC_WCAP_OUT_AMP) ?
3178 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003179 if (err < 0)
3180 return err;
3181 }
3182
Matt Porter8b657272006-10-26 17:12:59 +02003183 dimux->items[dimux->num_items].label =
3184 stac92xx_dmic_labels[dimux->num_items];
3185 dimux->items[dimux->num_items].index = index;
3186 dimux->num_items++;
3187 }
3188
3189 return 0;
3190}
3191
Mattc7d4b2f2005-06-27 14:59:41 +02003192/* create playback/capture controls for input pins */
3193static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3194{
3195 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003196 struct hda_input_mux *imux = &spec->private_imux;
3197 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3198 int i, j, k;
3199
3200 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003201 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003202
Takashi Iwai314634b2006-09-21 11:56:18 +02003203 if (!cfg->input_pins[i])
3204 continue;
3205 index = -1;
3206 for (j = 0; j < spec->num_muxes; j++) {
3207 int num_cons;
3208 num_cons = snd_hda_get_connections(codec,
3209 spec->mux_nids[j],
3210 con_lst,
3211 HDA_MAX_NUM_INPUTS);
3212 for (k = 0; k < num_cons; k++)
3213 if (con_lst[k] == cfg->input_pins[i]) {
3214 index = k;
3215 goto found;
3216 }
Mattc7d4b2f2005-06-27 14:59:41 +02003217 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003218 continue;
3219 found:
3220 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3221 imux->items[imux->num_items].index = index;
3222 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003223 }
3224
Steve Longerbeam7b043892007-05-03 20:50:03 +02003225 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003226 /*
3227 * Set the current input for the muxes.
3228 * The STAC9221 has two input muxes with identical source
3229 * NID lists. Hopefully this won't get confused.
3230 */
3231 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003232 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3233 AC_VERB_SET_CONNECT_SEL,
3234 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003235 }
3236 }
3237
Mattc7d4b2f2005-06-27 14:59:41 +02003238 return 0;
3239}
3240
Mattc7d4b2f2005-06-27 14:59:41 +02003241static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3242{
3243 struct sigmatel_spec *spec = codec->spec;
3244 int i;
3245
3246 for (i = 0; i < spec->autocfg.line_outs; i++) {
3247 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3248 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3249 }
3250}
3251
3252static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3253{
3254 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003255 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003256
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003257 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3258 hda_nid_t pin;
3259 pin = spec->autocfg.hp_pins[i];
3260 if (pin) /* connect to front */
3261 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3262 }
3263 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3264 hda_nid_t pin;
3265 pin = spec->autocfg.speaker_pins[i];
3266 if (pin) /* connect to front */
3267 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3268 }
Mattc7d4b2f2005-06-27 14:59:41 +02003269}
3270
Matt Porter3cc08dc2006-01-23 15:27:49 +01003271static 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 +02003272{
3273 struct sigmatel_spec *spec = codec->spec;
3274 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003275 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003276
Matt Porter8b657272006-10-26 17:12:59 +02003277 if ((err = snd_hda_parse_pin_def_config(codec,
3278 &spec->autocfg,
3279 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003280 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003281 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003282 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003283
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003284 /* If we have no real line-out pin and multiple hp-outs, HPs should
3285 * be set up as multi-channel outputs.
3286 */
3287 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3288 spec->autocfg.hp_outs > 1) {
3289 /* Copy hp_outs to line_outs, backup line_outs in
3290 * speaker_outs so that the following routines can handle
3291 * HP pins as primary outputs.
3292 */
3293 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3294 sizeof(spec->autocfg.line_out_pins));
3295 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3296 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3297 sizeof(spec->autocfg.hp_pins));
3298 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3299 hp_speaker_swap = 1;
3300 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003301 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003302 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3303 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003304 u32 caps = query_amp_caps(codec,
3305 spec->autocfg.mono_out_pin, dir);
3306 hda_nid_t conn_list[1];
3307
3308 /* get the mixer node and then the mono mux if it exists */
3309 if (snd_hda_get_connections(codec,
3310 spec->autocfg.mono_out_pin, conn_list, 1) &&
3311 snd_hda_get_connections(codec, conn_list[0],
3312 conn_list, 1)) {
3313
3314 int wcaps = get_wcaps(codec, conn_list[0]);
3315 int wid_type = (wcaps & AC_WCAP_TYPE)
3316 >> AC_WCAP_TYPE_SHIFT;
3317 /* LR swap check, some stac925x have a mux that
3318 * changes the DACs output path instead of the
3319 * mono-mux path.
3320 */
3321 if (wid_type == AC_WID_AUD_SEL &&
3322 !(wcaps & AC_WCAP_LR_SWAP))
3323 spec->mono_nid = conn_list[0];
3324 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003325 if (dir) {
3326 hda_nid_t nid = spec->autocfg.mono_out_pin;
3327
3328 /* most mono outs have a least a mute/unmute switch */
3329 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3330 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3331 "Mono Playback Switch",
3332 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003333 if (err < 0)
3334 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003335 /* check for volume support for the amp */
3336 if ((caps & AC_AMPCAP_NUM_STEPS)
3337 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3338 err = stac92xx_add_control(spec,
3339 STAC_CTL_WIDGET_VOL,
3340 "Mono Playback Volume",
3341 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3342 if (err < 0)
3343 return err;
3344 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003345 }
3346
3347 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3348 AC_PINCTL_OUT_EN);
3349 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003350
Matt Porter403d1942005-11-29 15:00:51 +01003351 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3352 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003353 if (spec->multiout.num_dacs == 0)
3354 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3355 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003356
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003357 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3358
3359 if (err < 0)
3360 return err;
3361
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003362 /* setup analog beep controls */
3363 if (spec->anabeep_nid > 0) {
3364 err = stac92xx_auto_create_beep_ctls(codec,
3365 spec->anabeep_nid);
3366 if (err < 0)
3367 return err;
3368 }
3369
3370 /* setup digital beep controls and input device */
3371#ifdef CONFIG_SND_HDA_INPUT_BEEP
3372 if (spec->digbeep_nid > 0) {
3373 hda_nid_t nid = spec->digbeep_nid;
3374
3375 err = stac92xx_auto_create_beep_ctls(codec, nid);
3376 if (err < 0)
3377 return err;
3378 err = snd_hda_attach_beep_device(codec, nid);
3379 if (err < 0)
3380 return err;
3381 }
3382#endif
3383
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003384 if (hp_speaker_swap == 1) {
3385 /* Restore the hp_outs and line_outs */
3386 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3387 sizeof(spec->autocfg.line_out_pins));
3388 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3389 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3390 sizeof(spec->autocfg.speaker_pins));
3391 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3392 memset(spec->autocfg.speaker_pins, 0,
3393 sizeof(spec->autocfg.speaker_pins));
3394 spec->autocfg.speaker_outs = 0;
3395 }
3396
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003397 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3398
3399 if (err < 0)
3400 return err;
3401
3402 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3403
3404 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003405 return err;
3406
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003407 if (spec->mono_nid > 0) {
3408 err = stac92xx_auto_create_mono_output_ctls(codec);
3409 if (err < 0)
3410 return err;
3411 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003412 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003413 err = stac92xx_auto_create_amp_output_ctls(codec);
3414 if (err < 0)
3415 return err;
3416 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003417 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003418 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3419 &spec->autocfg)) < 0)
3420 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003421 if (spec->num_muxes > 0) {
3422 err = stac92xx_auto_create_mux_input_ctls(codec);
3423 if (err < 0)
3424 return err;
3425 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003426 if (spec->num_smuxes > 0) {
3427 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3428 if (err < 0)
3429 return err;
3430 }
Matt Porter8b657272006-10-26 17:12:59 +02003431
Mattc7d4b2f2005-06-27 14:59:41 +02003432 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003433 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003434 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003435
Takashi Iwai82bc9552006-03-21 11:24:42 +01003436 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003437 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003438 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003439 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003440
3441 if (spec->kctl_alloc)
3442 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3443
3444 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003445 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003446 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003447 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003448 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003449 return 1;
3450}
3451
Takashi Iwai82bc9552006-03-21 11:24:42 +01003452/* add playback controls for HP output */
3453static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3454 struct auto_pin_cfg *cfg)
3455{
3456 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003457 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003458 unsigned int wid_caps;
3459
3460 if (! pin)
3461 return 0;
3462
3463 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003464 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003465 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003466
3467 return 0;
3468}
3469
Richard Fish160ea0d2006-09-06 13:58:25 +02003470/* add playback controls for LFE output */
3471static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3472 struct auto_pin_cfg *cfg)
3473{
3474 struct sigmatel_spec *spec = codec->spec;
3475 int err;
3476 hda_nid_t lfe_pin = 0x0;
3477 int i;
3478
3479 /*
3480 * search speaker outs and line outs for a mono speaker pin
3481 * with an amp. If one is found, add LFE controls
3482 * for it.
3483 */
3484 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3485 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003486 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003487 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3488 if (wcaps == AC_WCAP_OUT_AMP)
3489 /* found a mono speaker with an amp, must be lfe */
3490 lfe_pin = pin;
3491 }
3492
3493 /* if speaker_outs is 0, then speakers may be in line_outs */
3494 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3495 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3496 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003497 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003498 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003499 AC_VERB_GET_CONFIG_DEFAULT,
3500 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003501 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003502 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003503 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3504 if (wcaps == AC_WCAP_OUT_AMP)
3505 /* found a mono speaker with an amp,
3506 must be lfe */
3507 lfe_pin = pin;
3508 }
3509 }
3510 }
3511
3512 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003513 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003514 if (err < 0)
3515 return err;
3516 }
3517
3518 return 0;
3519}
3520
Mattc7d4b2f2005-06-27 14:59:41 +02003521static int stac9200_parse_auto_config(struct hda_codec *codec)
3522{
3523 struct sigmatel_spec *spec = codec->spec;
3524 int err;
3525
Kailang Yangdf694da2005-12-05 19:42:22 +01003526 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003527 return err;
3528
3529 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3530 return err;
3531
Takashi Iwai82bc9552006-03-21 11:24:42 +01003532 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3533 return err;
3534
Richard Fish160ea0d2006-09-06 13:58:25 +02003535 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3536 return err;
3537
Takashi Iwai82bc9552006-03-21 11:24:42 +01003538 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003539 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003540 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003541 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003542
3543 if (spec->kctl_alloc)
3544 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3545
3546 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003547 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003548
3549 return 1;
3550}
3551
Sam Revitch62fe78e2006-05-10 15:09:17 +02003552/*
3553 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3554 * funky external mute control using GPIO pins.
3555 */
3556
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003557static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003558 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003559{
3560 unsigned int gpiostate, gpiomask, gpiodir;
3561
3562 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3563 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003564 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003565
3566 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3567 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003568 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003569
3570 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3571 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003572 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003573
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003574 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003575 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3576
3577 snd_hda_codec_write(codec, codec->afg, 0,
3578 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003579 snd_hda_codec_read(codec, codec->afg, 0,
3580 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003581
3582 msleep(1);
3583
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003584 snd_hda_codec_read(codec, codec->afg, 0,
3585 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003586}
3587
Takashi Iwai314634b2006-09-21 11:56:18 +02003588static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3589 unsigned int event)
3590{
3591 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003592 snd_hda_codec_write_cache(codec, nid, 0,
3593 AC_VERB_SET_UNSOLICITED_ENABLE,
3594 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003595}
3596
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003597static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3598{
3599 int i;
3600 for (i = 0; i < cfg->hp_outs; i++)
3601 if (cfg->hp_pins[i] == nid)
3602 return 1; /* nid is a HP-Out */
3603
3604 return 0; /* nid is not a HP-Out */
3605};
3606
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003607static void stac92xx_power_down(struct hda_codec *codec)
3608{
3609 struct sigmatel_spec *spec = codec->spec;
3610
3611 /* power down inactive DACs */
3612 hda_nid_t *dac;
3613 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003614 if (!is_in_dac_nids(spec, *dac) &&
3615 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003616 snd_hda_codec_write_cache(codec, *dac, 0,
3617 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3618}
3619
Mattc7d4b2f2005-06-27 14:59:41 +02003620static int stac92xx_init(struct hda_codec *codec)
3621{
3622 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003623 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay45a6ac12008-10-15 14:45:38 -04003624 int i, err;
Mattc7d4b2f2005-06-27 14:59:41 +02003625
Mattc7d4b2f2005-06-27 14:59:41 +02003626 snd_hda_sequence_write(codec, spec->init);
3627
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003628 /* power down adcs initially */
3629 if (spec->powerdown_adcs)
3630 for (i = 0; i < spec->num_adcs; i++)
3631 snd_hda_codec_write_cache(codec,
3632 spec->adc_nids[i], 0,
3633 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003634 /* set up pins */
3635 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003636 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003637 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003638 enable_pin_detect(codec, cfg->hp_pins[i],
3639 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003640 /* force to enable the first line-out; the others are set up
3641 * in unsol_event
3642 */
3643 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3644 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003645 stac92xx_auto_init_hp_out(codec);
Matthew Ranostay45a6ac12008-10-15 14:45:38 -04003646 /* jack detection */
3647 err = snd_jack_new(codec->bus->card,
3648 "Headphone Jack",
3649 SND_JACK_HEADPHONE, &spec->jack);
3650 if (err < 0)
3651 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003652 /* fake event to set up pins */
3653 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3654 } else {
3655 stac92xx_auto_init_multi_out(codec);
3656 stac92xx_auto_init_hp_out(codec);
3657 }
3658 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003659 hda_nid_t nid = cfg->input_pins[i];
3660 if (nid) {
Matthew Ranostayb9aea712008-10-09 08:37:28 -04003661 unsigned int pinctl = snd_hda_codec_read(codec, nid,
3662 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3663 /* if PINCTL already set then skip */
3664 if (pinctl & AC_PINCAP_IN)
3665 continue;
3666 pinctl = AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003667 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3668 pinctl |= stac92xx_get_vref(codec, nid);
3669 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3670 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003671 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003672 for (i = 0; i < spec->num_dmics; i++)
3673 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3674 AC_PINCTL_IN_EN);
3675 for (i = 0; i < spec->num_pwrs; i++) {
3676 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3677 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3678 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3679 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003680 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3681 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003682 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003683 /* outputs are only ports capable of power management
3684 * any attempts on powering down a input port cause the
3685 * referenced VREF to act quirky.
3686 */
3687 if (pinctl & AC_PINCTL_IN_EN)
3688 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003689 /* skip any ports that don't have jacks since presence
3690 * detection is useless */
3691 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003692 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003693 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3694 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3695 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003696 if (spec->dac_list)
3697 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003698 if (cfg->dig_out_pin)
3699 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3700 AC_PINCTL_OUT_EN);
3701 if (cfg->dig_in_pin)
3702 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3703 AC_PINCTL_IN_EN);
3704
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003705 stac_gpio_set(codec, spec->gpio_mask,
3706 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003707
Mattc7d4b2f2005-06-27 14:59:41 +02003708 return 0;
3709}
3710
Matt2f2f4252005-04-13 14:45:30 +02003711static void stac92xx_free(struct hda_codec *codec)
3712{
Mattc7d4b2f2005-06-27 14:59:41 +02003713 struct sigmatel_spec *spec = codec->spec;
3714 int i;
3715
3716 if (! spec)
3717 return;
3718
3719 if (spec->kctl_alloc) {
3720 for (i = 0; i < spec->num_kctl_used; i++)
3721 kfree(spec->kctl_alloc[i].name);
3722 kfree(spec->kctl_alloc);
3723 }
3724
Richard Fish11b44bb2006-08-23 18:31:34 +02003725 if (spec->bios_pin_configs)
3726 kfree(spec->bios_pin_configs);
3727
Mattc7d4b2f2005-06-27 14:59:41 +02003728 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003729 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003730}
3731
Matt4e550962005-07-04 17:51:39 +02003732static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3733 unsigned int flag)
3734{
3735 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3736 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003737
Takashi Iwaif9acba42007-05-29 18:01:06 +02003738 if (pin_ctl & AC_PINCTL_IN_EN) {
3739 /*
3740 * we need to check the current set-up direction of
3741 * shared input pins since they can be switched via
3742 * "xxx as Output" mixer switch
3743 */
3744 struct sigmatel_spec *spec = codec->spec;
3745 struct auto_pin_cfg *cfg = &spec->autocfg;
3746 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3747 spec->line_switch) ||
3748 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3749 spec->mic_switch))
3750 return;
3751 }
3752
Steve Longerbeam7b043892007-05-03 20:50:03 +02003753 /* if setting pin direction bits, clear the current
3754 direction bits first */
3755 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3756 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3757
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003758 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003759 AC_VERB_SET_PIN_WIDGET_CONTROL,
3760 pin_ctl | flag);
3761}
3762
3763static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3764 unsigned int flag)
3765{
3766 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3767 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003768 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003769 AC_VERB_SET_PIN_WIDGET_CONTROL,
3770 pin_ctl & ~flag);
3771}
3772
Jiang Zhe40c1d302007-11-12 13:05:16 +01003773static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003774{
3775 if (!nid)
3776 return 0;
3777 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003778 & (1 << 31)) {
3779 unsigned int pinctl;
3780 pinctl = snd_hda_codec_read(codec, nid, 0,
3781 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3782 if (pinctl & AC_PINCTL_IN_EN)
3783 return 0; /* mic- or line-input */
3784 else
3785 return 1; /* HP-output */
3786 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003787 return 0;
3788}
3789
3790static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003791{
3792 struct sigmatel_spec *spec = codec->spec;
3793 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003794 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003795 int i, presence;
3796
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003797 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003798 if (spec->gpio_mute)
3799 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3800 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3801
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003802 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003803 if (presence)
3804 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003805 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3806 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003807 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003808 }
Matthew Ranostay45a6ac12008-10-15 14:45:38 -04003809 snd_jack_report(spec->jack,
3810 presence ? SND_JACK_HEADPHONE : 0);
Matt4e550962005-07-04 17:51:39 +02003811
3812 if (presence) {
3813 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003814 if (spec->hp_switch)
3815 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003816 for (i = 0; i < cfg->line_outs; i++)
3817 stac92xx_reset_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_reset_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 } else {
3827 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003828 if (spec->hp_switch)
3829 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003830 for (i = 0; i < cfg->line_outs; i++)
3831 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3832 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003833 for (i = 0; i < cfg->speaker_outs; i++)
3834 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3835 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003836 if (spec->eapd_mask)
3837 stac_gpio_set(codec, spec->gpio_mask,
3838 spec->gpio_dir, spec->gpio_data |
3839 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003840 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003841 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3842 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003843}
3844
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003845static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3846{
3847 struct sigmatel_spec *spec = codec->spec;
3848 hda_nid_t nid = spec->pwr_nids[idx];
3849 int presence, val;
3850 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3851 & 0x000000ff;
3852 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003853
3854 /* several codecs have two power down bits */
3855 if (spec->pwr_mapping)
3856 idx = spec->pwr_mapping[idx];
3857 else
3858 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003859
3860 if (presence)
3861 val &= ~idx;
3862 else
3863 val |= idx;
3864
3865 /* power down unused output ports */
3866 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3867};
3868
Takashi Iwai314634b2006-09-21 11:56:18 +02003869static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3870{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003871 struct sigmatel_spec *spec = codec->spec;
3872 int idx = res >> 26 & 0x0f;
3873
Matthew Ranostay72474be2008-10-09 09:32:17 -04003874 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003875 case STAC_HP_EVENT:
3876 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003877 /* fallthru */
3878 case STAC_PWR_EVENT:
3879 if (spec->num_pwrs > 0)
3880 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04003881 break;
3882 case STAC_VREF_EVENT: {
3883 int data = snd_hda_codec_read(codec, codec->afg, 0,
3884 AC_VERB_GET_GPIO_DATA, 0);
3885 /* toggle VREF state based on GPIOx status */
3886 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
3887 !!(data & (1 << idx)));
3888 break;
3889 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003890 }
3891}
3892
Takashi Iwaicb53c622007-08-10 17:21:45 +02003893#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003894static int stac92xx_resume(struct hda_codec *codec)
3895{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003896 struct sigmatel_spec *spec = codec->spec;
3897
Richard Fish11b44bb2006-08-23 18:31:34 +02003898 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003899 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003900 stac_gpio_set(codec, spec->gpio_mask,
3901 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003902 snd_hda_codec_resume_amp(codec);
3903 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003904 /* power down inactive DACs */
3905 if (spec->dac_list)
3906 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003907 /* invoke unsolicited event to reset the HP state */
3908 if (spec->hp_detect)
3909 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003910 return 0;
3911}
3912#endif
3913
Matt2f2f4252005-04-13 14:45:30 +02003914static struct hda_codec_ops stac92xx_patch_ops = {
3915 .build_controls = stac92xx_build_controls,
3916 .build_pcms = stac92xx_build_pcms,
3917 .init = stac92xx_init,
3918 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003919 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003920#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003921 .resume = stac92xx_resume,
3922#endif
Matt2f2f4252005-04-13 14:45:30 +02003923};
3924
3925static int patch_stac9200(struct hda_codec *codec)
3926{
3927 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003928 int err;
Matt2f2f4252005-04-13 14:45:30 +02003929
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003930 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003931 if (spec == NULL)
3932 return -ENOMEM;
3933
3934 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003935 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003936 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003937 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3938 stac9200_models,
3939 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003940 if (spec->board_config < 0) {
3941 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3942 err = stac92xx_save_bios_config_regs(codec);
3943 if (err < 0) {
3944 stac92xx_free(codec);
3945 return err;
3946 }
3947 spec->pin_configs = spec->bios_pin_configs;
3948 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003949 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3950 stac92xx_set_config_regs(codec);
3951 }
Matt2f2f4252005-04-13 14:45:30 +02003952
3953 spec->multiout.max_channels = 2;
3954 spec->multiout.num_dacs = 1;
3955 spec->multiout.dac_nids = stac9200_dac_nids;
3956 spec->adc_nids = stac9200_adc_nids;
3957 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003958 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003959 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003960 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003961 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003962
Tobin Davisbf277782008-02-03 20:31:47 +01003963 if (spec->board_config == STAC_9200_GATEWAY ||
3964 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003965 spec->init = stac9200_eapd_init;
3966 else
3967 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003968 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003969
Takashi Iwai117f2572008-03-18 09:53:23 +01003970 if (spec->board_config == STAC_9200_PANASONIC) {
3971 spec->gpio_mask = spec->gpio_dir = 0x09;
3972 spec->gpio_data = 0x00;
3973 }
3974
Mattc7d4b2f2005-06-27 14:59:41 +02003975 err = stac9200_parse_auto_config(codec);
3976 if (err < 0) {
3977 stac92xx_free(codec);
3978 return err;
3979 }
Matt2f2f4252005-04-13 14:45:30 +02003980
3981 codec->patch_ops = stac92xx_patch_ops;
3982
3983 return 0;
3984}
3985
Tobin Davis8e21c342007-01-08 11:04:17 +01003986static int patch_stac925x(struct hda_codec *codec)
3987{
3988 struct sigmatel_spec *spec;
3989 int err;
3990
3991 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3992 if (spec == NULL)
3993 return -ENOMEM;
3994
3995 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003996 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003997 spec->pin_nids = stac925x_pin_nids;
3998 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3999 stac925x_models,
4000 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004001 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004002 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004003 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4004 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004005 err = stac92xx_save_bios_config_regs(codec);
4006 if (err < 0) {
4007 stac92xx_free(codec);
4008 return err;
4009 }
4010 spec->pin_configs = spec->bios_pin_configs;
4011 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4012 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4013 stac92xx_set_config_regs(codec);
4014 }
4015
4016 spec->multiout.max_channels = 2;
4017 spec->multiout.num_dacs = 1;
4018 spec->multiout.dac_nids = stac925x_dac_nids;
4019 spec->adc_nids = stac925x_adc_nids;
4020 spec->mux_nids = stac925x_mux_nids;
4021 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004022 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004023 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004024 switch (codec->vendor_id) {
4025 case 0x83847632: /* STAC9202 */
4026 case 0x83847633: /* STAC9202D */
4027 case 0x83847636: /* STAC9251 */
4028 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004029 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004030 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004031 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4032 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004033 break;
4034 default:
4035 spec->num_dmics = 0;
4036 break;
4037 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004038
4039 spec->init = stac925x_core_init;
4040 spec->mixer = stac925x_mixer;
4041
4042 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004043 if (!err) {
4044 if (spec->board_config < 0) {
4045 printk(KERN_WARNING "hda_codec: No auto-config is "
4046 "available, default to model=ref\n");
4047 spec->board_config = STAC_925x_REF;
4048 goto again;
4049 }
4050 err = -EINVAL;
4051 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004052 if (err < 0) {
4053 stac92xx_free(codec);
4054 return err;
4055 }
4056
4057 codec->patch_ops = stac92xx_patch_ops;
4058
4059 return 0;
4060}
4061
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004062static struct hda_input_mux stac92hd73xx_dmux = {
4063 .num_items = 4,
4064 .items = {
4065 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004066 { "Digital Mic 1", 0x09 },
4067 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004068 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004069 }
4070};
4071
4072static int patch_stac92hd73xx(struct hda_codec *codec)
4073{
4074 struct sigmatel_spec *spec;
4075 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4076 int err = 0;
4077
4078 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4079 if (spec == NULL)
4080 return -ENOMEM;
4081
4082 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004083 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004084 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4085 spec->pin_nids = stac92hd73xx_pin_nids;
4086 spec->board_config = snd_hda_check_board_config(codec,
4087 STAC_92HD73XX_MODELS,
4088 stac92hd73xx_models,
4089 stac92hd73xx_cfg_tbl);
4090again:
4091 if (spec->board_config < 0) {
4092 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4093 " STAC92HD73XX, using BIOS defaults\n");
4094 err = stac92xx_save_bios_config_regs(codec);
4095 if (err < 0) {
4096 stac92xx_free(codec);
4097 return err;
4098 }
4099 spec->pin_configs = spec->bios_pin_configs;
4100 } else {
4101 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4102 stac92xx_set_config_regs(codec);
4103 }
4104
4105 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4106 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4107
4108 if (spec->multiout.num_dacs < 0) {
4109 printk(KERN_WARNING "hda_codec: Could not determine "
4110 "number of channels defaulting to DAC count\n");
4111 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4112 }
4113
4114 switch (spec->multiout.num_dacs) {
4115 case 0x3: /* 6 Channel */
4116 spec->mixer = stac92hd73xx_6ch_mixer;
4117 spec->init = stac92hd73xx_6ch_core_init;
4118 break;
4119 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004120 spec->mixer = stac92hd73xx_8ch_mixer;
4121 spec->init = stac92hd73xx_8ch_core_init;
4122 break;
4123 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004124 spec->mixer = stac92hd73xx_10ch_mixer;
4125 spec->init = stac92hd73xx_10ch_core_init;
4126 };
4127
4128 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4129 spec->aloopback_mask = 0x01;
4130 spec->aloopback_shift = 8;
4131
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004132 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004133 spec->mux_nids = stac92hd73xx_mux_nids;
4134 spec->adc_nids = stac92hd73xx_adc_nids;
4135 spec->dmic_nids = stac92hd73xx_dmic_nids;
4136 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004137 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004138 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004139 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004140
4141 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4142 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004143 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004144 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4145 sizeof(stac92hd73xx_dmux));
4146
Matthew Ranostaya7662642008-02-21 07:51:14 +01004147 switch (spec->board_config) {
4148 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004149 spec->init = dell_eq_core_init;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004150 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004151 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4152 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4153 spec->num_amps = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004154 switch (codec->subsystem_id) {
4155 case 0x1028025e: /* Analog Mics */
4156 case 0x1028025f:
4157 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4158 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004159 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004160 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004161 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004162 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004163 spec->init = dell_m6_core_init;
4164 /* fall-through */
4165 case 0x10280254:
4166 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004167 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4168 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004169 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004170 break;
4171 case 0x10280256: /* Both */
4172 case 0x10280057:
4173 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4174 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4175 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004176 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004177 break;
4178 }
4179 break;
4180 default:
4181 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004182 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaya7662642008-02-21 07:51:14 +01004183 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004184 if (spec->board_config > STAC_92HD73XX_REF) {
4185 /* GPIO0 High = Enable EAPD */
4186 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4187 spec->gpio_data = 0x01;
4188 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004189 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004190
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004191 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4192 spec->pwr_nids = stac92hd73xx_pwr_nids;
4193
Matthew Ranostayd9737752008-09-07 12:03:41 +02004194 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004195
4196 if (!err) {
4197 if (spec->board_config < 0) {
4198 printk(KERN_WARNING "hda_codec: No auto-config is "
4199 "available, default to model=ref\n");
4200 spec->board_config = STAC_92HD73XX_REF;
4201 goto again;
4202 }
4203 err = -EINVAL;
4204 }
4205
4206 if (err < 0) {
4207 stac92xx_free(codec);
4208 return err;
4209 }
4210
4211 codec->patch_ops = stac92xx_patch_ops;
4212
4213 return 0;
4214}
4215
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004216static struct hda_input_mux stac92hd83xxx_dmux = {
4217 .num_items = 3,
4218 .items = {
4219 { "Analog Inputs", 0x03 },
4220 { "Digital Mic 1", 0x04 },
4221 { "Digital Mic 2", 0x05 },
4222 }
4223};
4224
4225static int patch_stac92hd83xxx(struct hda_codec *codec)
4226{
4227 struct sigmatel_spec *spec;
4228 int err;
4229
4230 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4231 if (spec == NULL)
4232 return -ENOMEM;
4233
4234 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004235 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004236 spec->mono_nid = 0x19;
4237 spec->digbeep_nid = 0x21;
4238 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4239 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4240 spec->adc_nids = stac92hd83xxx_adc_nids;
4241 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4242 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4243 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4244 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4245
4246 spec->init = stac92hd83xxx_core_init;
4247 switch (codec->vendor_id) {
4248 case 0x111d7605:
4249 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4250 break;
4251 default:
4252 spec->num_pwrs--;
4253 spec->init++; /* switch to config #2 */
4254 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4255 }
4256
4257 spec->mixer = stac92hd83xxx_mixer;
4258 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4259 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4260 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4261 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4262 spec->dinput_mux = &stac92hd83xxx_dmux;
4263 spec->pin_nids = stac92hd83xxx_pin_nids;
4264 spec->board_config = snd_hda_check_board_config(codec,
4265 STAC_92HD83XXX_MODELS,
4266 stac92hd83xxx_models,
4267 stac92hd83xxx_cfg_tbl);
4268again:
4269 if (spec->board_config < 0) {
4270 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4271 " STAC92HD83XXX, using BIOS defaults\n");
4272 err = stac92xx_save_bios_config_regs(codec);
4273 if (err < 0) {
4274 stac92xx_free(codec);
4275 return err;
4276 }
4277 spec->pin_configs = spec->bios_pin_configs;
4278 } else {
4279 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4280 stac92xx_set_config_regs(codec);
4281 }
4282
4283 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4284 if (!err) {
4285 if (spec->board_config < 0) {
4286 printk(KERN_WARNING "hda_codec: No auto-config is "
4287 "available, default to model=ref\n");
4288 spec->board_config = STAC_92HD83XXX_REF;
4289 goto again;
4290 }
4291 err = -EINVAL;
4292 }
4293
4294 if (err < 0) {
4295 stac92xx_free(codec);
4296 return err;
4297 }
4298
4299 codec->patch_ops = stac92xx_patch_ops;
4300
4301 return 0;
4302}
4303
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004304#ifdef SND_HDA_NEEDS_RESUME
4305static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4306{
4307 struct sigmatel_spec *spec = codec->spec;
4308 int i;
4309 snd_hda_codec_write_cache(codec, codec->afg, 0,
4310 AC_VERB_SET_POWER_STATE, pwr);
4311
4312 msleep(1);
4313 for (i = 0; i < spec->num_adcs; i++) {
4314 snd_hda_codec_write_cache(codec,
4315 spec->adc_nids[i], 0,
4316 AC_VERB_SET_POWER_STATE, pwr);
4317 }
4318};
4319
4320static int stac92hd71xx_resume(struct hda_codec *codec)
4321{
4322 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4323 return stac92xx_resume(codec);
4324}
4325
4326static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4327{
4328 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4329 return 0;
4330};
4331
4332#endif
4333
4334static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4335 .build_controls = stac92xx_build_controls,
4336 .build_pcms = stac92xx_build_pcms,
4337 .init = stac92xx_init,
4338 .free = stac92xx_free,
4339 .unsol_event = stac92xx_unsol_event,
4340#ifdef SND_HDA_NEEDS_RESUME
4341 .resume = stac92hd71xx_resume,
4342 .suspend = stac92hd71xx_suspend,
4343#endif
4344};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004345
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004346static struct hda_input_mux stac92hd71bxx_dmux = {
4347 .num_items = 4,
4348 .items = {
4349 { "Analog Inputs", 0x00 },
4350 { "Mixer", 0x01 },
4351 { "Digital Mic 1", 0x02 },
4352 { "Digital Mic 2", 0x03 },
4353 }
4354};
4355
Matthew Ranostaye035b842007-11-06 11:53:55 +01004356static int patch_stac92hd71bxx(struct hda_codec *codec)
4357{
4358 struct sigmatel_spec *spec;
4359 int err = 0;
4360
4361 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4362 if (spec == NULL)
4363 return -ENOMEM;
4364
4365 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004366 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004367 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004368 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004369 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004370 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4371 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004372 spec->board_config = snd_hda_check_board_config(codec,
4373 STAC_92HD71BXX_MODELS,
4374 stac92hd71bxx_models,
4375 stac92hd71bxx_cfg_tbl);
4376again:
4377 if (spec->board_config < 0) {
4378 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4379 " STAC92HD71BXX, using BIOS defaults\n");
4380 err = stac92xx_save_bios_config_regs(codec);
4381 if (err < 0) {
4382 stac92xx_free(codec);
4383 return err;
4384 }
4385 spec->pin_configs = spec->bios_pin_configs;
4386 } else {
4387 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4388 stac92xx_set_config_regs(codec);
4389 }
4390
Matthew Ranostay541eee82007-12-14 12:08:04 +01004391 switch (codec->vendor_id) {
4392 case 0x111d76b6: /* 4 Port without Analog Mixer */
4393 case 0x111d76b7:
4394 case 0x111d76b4: /* 6 Port without Analog Mixer */
4395 case 0x111d76b5:
4396 spec->mixer = stac92hd71bxx_mixer;
4397 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004398 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004399 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004400 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay72474be2008-10-09 09:32:17 -04004401 switch (codec->subsystem_id) {
4402 case 0x103c361a:
4403 /* Enable VREF power saving on GPIO1 detect */
4404 snd_hda_codec_write(codec, codec->afg, 0,
4405 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4406 snd_hda_codec_write_cache(codec, codec->afg, 0,
4407 AC_VERB_SET_UNSOLICITED_ENABLE,
4408 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4409 spec->gpio_mask |= 0x02;
4410 break;
4411 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004412 if ((codec->revision_id & 0xf) == 0 ||
4413 (codec->revision_id & 0xf) == 1) {
4414#ifdef SND_HDA_NEEDS_RESUME
4415 codec->patch_ops = stac92hd71bxx_patch_ops;
4416#endif
4417 spec->stream_delay = 40; /* 40 milliseconds */
4418 }
4419
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004420 /* no output amps */
4421 spec->num_pwrs = 0;
4422 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004423 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004424
4425 /* disable VSW */
4426 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4427 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4428 break;
4429 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004430 if ((codec->revision_id & 0xf) == 1) {
4431#ifdef SND_HDA_NEEDS_RESUME
4432 codec->patch_ops = stac92hd71bxx_patch_ops;
4433#endif
4434 spec->stream_delay = 40; /* 40 milliseconds */
4435 }
4436
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004437 /* no output amps */
4438 spec->num_pwrs = 0;
4439 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004440 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004441 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004442 spec->mixer = stac92hd71bxx_analog_mixer;
4443 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004444 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004445 }
4446
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004447 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004448 spec->aloopback_shift = 0;
4449
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004450 if (spec->board_config > STAC_92HD71BXX_REF) {
4451 /* GPIO0 = EAPD */
4452 spec->gpio_mask = 0x01;
4453 spec->gpio_dir = 0x01;
4454 spec->gpio_data = 0x01;
4455 }
Matthew Ranostaye035b842007-11-06 11:53:55 +01004456
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004457 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004458 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004459 spec->mux_nids = stac92hd71bxx_mux_nids;
4460 spec->adc_nids = stac92hd71bxx_adc_nids;
4461 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004462 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004463 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004464 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004465
4466 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4467 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004468
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004469 switch (spec->board_config) {
4470 case STAC_HP_M4:
4471 spec->num_dmics = 0;
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004472 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004473 spec->num_dmuxes = 0;
4474
4475 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004476 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4477 stac92xx_auto_set_pinctl(codec, 0x0e,
4478 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004479 break;
4480 default:
4481 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4482 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4483 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4484 };
4485
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004486 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004487 spec->multiout.hp_nid = 0x11;
4488 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004489 if (spec->dinput_mux)
4490 spec->private_dimux.num_items +=
4491 spec->num_dmics -
4492 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004493
4494 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4495 if (!err) {
4496 if (spec->board_config < 0) {
4497 printk(KERN_WARNING "hda_codec: No auto-config is "
4498 "available, default to model=ref\n");
4499 spec->board_config = STAC_92HD71BXX_REF;
4500 goto again;
4501 }
4502 err = -EINVAL;
4503 }
4504
4505 if (err < 0) {
4506 stac92xx_free(codec);
4507 return err;
4508 }
4509
Matthew Ranostaye035b842007-11-06 11:53:55 +01004510 return 0;
4511};
4512
Matt2f2f4252005-04-13 14:45:30 +02004513static int patch_stac922x(struct hda_codec *codec)
4514{
4515 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004516 int err;
Matt2f2f4252005-04-13 14:45:30 +02004517
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004518 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004519 if (spec == NULL)
4520 return -ENOMEM;
4521
4522 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004523 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004524 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004525 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4526 stac922x_models,
4527 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004528 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004529 spec->gpio_mask = spec->gpio_dir = 0x03;
4530 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004531 /* Intel Macs have all same PCI SSID, so we need to check
4532 * codec SSID to distinguish the exact models
4533 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004534 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004535 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004536
4537 case 0x106b0800:
4538 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004539 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004540 case 0x106b0600:
4541 case 0x106b0700:
4542 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004543 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004544 case 0x106b0e00:
4545 case 0x106b0f00:
4546 case 0x106b1600:
4547 case 0x106b1700:
4548 case 0x106b0200:
4549 case 0x106b1e00:
4550 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004551 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004552 case 0x106b1a00:
4553 case 0x00000100:
4554 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004555 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004556 case 0x106b0a00:
4557 case 0x106b2200:
4558 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004559 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004560 default:
4561 spec->board_config = STAC_INTEL_MAC_V3;
4562 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004563 }
4564 }
4565
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004566 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004567 if (spec->board_config < 0) {
4568 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4569 "using BIOS defaults\n");
4570 err = stac92xx_save_bios_config_regs(codec);
4571 if (err < 0) {
4572 stac92xx_free(codec);
4573 return err;
4574 }
4575 spec->pin_configs = spec->bios_pin_configs;
4576 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004577 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4578 stac92xx_set_config_regs(codec);
4579 }
Matt2f2f4252005-04-13 14:45:30 +02004580
Matt2f2f4252005-04-13 14:45:30 +02004581 spec->adc_nids = stac922x_adc_nids;
4582 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004583 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004584 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004585 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004586 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004587
4588 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004589 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004590
4591 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004592
Matt Porter3cc08dc2006-01-23 15:27:49 +01004593 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004594 if (!err) {
4595 if (spec->board_config < 0) {
4596 printk(KERN_WARNING "hda_codec: No auto-config is "
4597 "available, default to model=ref\n");
4598 spec->board_config = STAC_D945_REF;
4599 goto again;
4600 }
4601 err = -EINVAL;
4602 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004603 if (err < 0) {
4604 stac92xx_free(codec);
4605 return err;
4606 }
4607
4608 codec->patch_ops = stac92xx_patch_ops;
4609
Takashi Iwai807a46362007-05-29 19:01:37 +02004610 /* Fix Mux capture level; max to 2 */
4611 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4612 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4613 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4614 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4615 (0 << AC_AMPCAP_MUTE_SHIFT));
4616
Matt Porter3cc08dc2006-01-23 15:27:49 +01004617 return 0;
4618}
4619
4620static int patch_stac927x(struct hda_codec *codec)
4621{
4622 struct sigmatel_spec *spec;
4623 int err;
4624
4625 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4626 if (spec == NULL)
4627 return -ENOMEM;
4628
4629 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004630 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004631 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004632 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4633 stac927x_models,
4634 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004635 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004636 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4637 if (spec->board_config < 0)
4638 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4639 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004640 err = stac92xx_save_bios_config_regs(codec);
4641 if (err < 0) {
4642 stac92xx_free(codec);
4643 return err;
4644 }
4645 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004646 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004647 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4648 stac92xx_set_config_regs(codec);
4649 }
4650
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004651 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004652 spec->adc_nids = stac927x_adc_nids;
4653 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4654 spec->mux_nids = stac927x_mux_nids;
4655 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004656 spec->smux_nids = stac927x_smux_nids;
4657 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004658 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004659 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004660 spec->multiout.dac_nids = spec->dac_nids;
4661
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004662 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004663 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004664 case STAC_D965_5ST:
4665 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004666 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004667 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004668 spec->num_dmics = 0;
4669
Tobin Davis93ed1502006-09-01 21:03:12 +02004670 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004671 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004672 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004673 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004674 switch (codec->subsystem_id) {
4675 case 0x10280209:
4676 case 0x1028022e:
4677 /* correct the device field to SPDIF out */
4678 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4679 break;
4680 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004681 /* configure the analog microphone on some laptops */
4682 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004683 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004684 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004685 /* correct the front input jack as a mic */
4686 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4687 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004688 case STAC_DELL_3ST:
4689 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004690 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004691 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004692 spec->dmic_nids = stac927x_dmic_nids;
4693 spec->num_dmics = STAC927X_NUM_DMICS;
4694
Tobin Davis93ed1502006-09-01 21:03:12 +02004695 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004696 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004697 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004698 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004699 break;
4700 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004701 if (spec->board_config > STAC_D965_REF) {
4702 /* GPIO0 High = Enable EAPD */
4703 spec->eapd_mask = spec->gpio_mask = 0x01;
4704 spec->gpio_dir = spec->gpio_data = 0x01;
4705 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004706 spec->num_dmics = 0;
4707
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004708 spec->init = stac927x_core_init;
4709 spec->mixer = stac927x_mixer;
4710 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004711
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004712 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004713 spec->aloopback_mask = 0x40;
4714 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004715
Matt Porter3cc08dc2006-01-23 15:27:49 +01004716 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004717 if (!err) {
4718 if (spec->board_config < 0) {
4719 printk(KERN_WARNING "hda_codec: No auto-config is "
4720 "available, default to model=ref\n");
4721 spec->board_config = STAC_D965_REF;
4722 goto again;
4723 }
4724 err = -EINVAL;
4725 }
Mattc7d4b2f2005-06-27 14:59:41 +02004726 if (err < 0) {
4727 stac92xx_free(codec);
4728 return err;
4729 }
Matt2f2f4252005-04-13 14:45:30 +02004730
4731 codec->patch_ops = stac92xx_patch_ops;
4732
Takashi Iwai52987652008-01-16 16:09:47 +01004733 /*
4734 * !!FIXME!!
4735 * The STAC927x seem to require fairly long delays for certain
4736 * command sequences. With too short delays (even if the answer
4737 * is set to RIRB properly), it results in the silence output
4738 * on some hardwares like Dell.
4739 *
4740 * The below flag enables the longer delay (see get_response
4741 * in hda_intel.c).
4742 */
4743 codec->bus->needs_damn_long_delay = 1;
4744
Matt2f2f4252005-04-13 14:45:30 +02004745 return 0;
4746}
4747
Matt Porterf3302a52006-07-31 12:49:34 +02004748static int patch_stac9205(struct hda_codec *codec)
4749{
4750 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004751 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004752
4753 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4754 if (spec == NULL)
4755 return -ENOMEM;
4756
4757 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004758 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004759 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004760 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4761 stac9205_models,
4762 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004763 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004764 if (spec->board_config < 0) {
4765 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4766 err = stac92xx_save_bios_config_regs(codec);
4767 if (err < 0) {
4768 stac92xx_free(codec);
4769 return err;
4770 }
4771 spec->pin_configs = spec->bios_pin_configs;
4772 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004773 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4774 stac92xx_set_config_regs(codec);
4775 }
4776
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004777 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004778 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004779 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004780 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004781 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004782 spec->smux_nids = stac9205_smux_nids;
4783 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004784 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004785 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004786 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004787 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004788 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004789
4790 spec->init = stac9205_core_init;
4791 spec->mixer = stac9205_mixer;
4792
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004793 spec->aloopback_mask = 0x40;
4794 spec->aloopback_shift = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004795 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004796
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004797 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004798 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004799 /* Enable SPDIF in/out */
4800 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4801 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004802
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004803 /* Enable unsol response for GPIO4/Dock HP connection */
4804 snd_hda_codec_write(codec, codec->afg, 0,
4805 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4806 snd_hda_codec_write_cache(codec, codec->afg, 0,
4807 AC_VERB_SET_UNSOLICITED_ENABLE,
4808 (AC_USRSP_EN | STAC_HP_EVENT));
4809
4810 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004811 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004812 spec->gpio_mask = 0x1b;
4813 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004814 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004815 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004816 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004817 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004818 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004819 case STAC_9205_REF:
4820 /* SPDIF-In enabled */
4821 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004822 default:
4823 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004824 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004825 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004826 break;
4827 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004828
Matt Porterf3302a52006-07-31 12:49:34 +02004829 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004830 if (!err) {
4831 if (spec->board_config < 0) {
4832 printk(KERN_WARNING "hda_codec: No auto-config is "
4833 "available, default to model=ref\n");
4834 spec->board_config = STAC_9205_REF;
4835 goto again;
4836 }
4837 err = -EINVAL;
4838 }
Matt Porterf3302a52006-07-31 12:49:34 +02004839 if (err < 0) {
4840 stac92xx_free(codec);
4841 return err;
4842 }
4843
4844 codec->patch_ops = stac92xx_patch_ops;
4845
4846 return 0;
4847}
4848
Matt2f2f4252005-04-13 14:45:30 +02004849/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004850 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004851 */
4852
Guillaume Munch99ccc562006-08-16 19:35:12 +02004853/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004854static hda_nid_t vaio_dacs[] = { 0x2 };
4855#define VAIO_HP_DAC 0x5
4856static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4857static hda_nid_t vaio_mux_nids[] = { 0x15 };
4858
4859static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004860 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004861 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004862 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004863 { "Mic Jack", 0x1 },
4864 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004865 { "PCM", 0x3 },
4866 }
4867};
4868
4869static struct hda_verb vaio_init[] = {
4870 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004871 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004872 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4873 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4874 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004876 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004877 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4878 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4880 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4882 {}
4883};
4884
Guillaume Munch6d859062006-08-22 17:15:47 +02004885static struct hda_verb vaio_ar_init[] = {
4886 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4887 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4888 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4889 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4890/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004892 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004893 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4894 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4895/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4899 {}
4900};
4901
Takashi Iwaidb064e52006-03-16 16:04:58 +01004902/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004903static struct hda_bind_ctls vaio_bind_master_vol = {
4904 .ops = &snd_hda_bind_vol,
4905 .values = {
4906 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4907 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4908 0
4909 },
4910};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004911
4912/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004913static struct hda_bind_ctls vaio_bind_master_sw = {
4914 .ops = &snd_hda_bind_sw,
4915 .values = {
4916 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4917 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4918 0,
4919 },
4920};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004921
4922static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004923 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4924 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004925 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4926 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4927 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4928 {
4929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4930 .name = "Capture Source",
4931 .count = 1,
4932 .info = stac92xx_mux_enum_info,
4933 .get = stac92xx_mux_enum_get,
4934 .put = stac92xx_mux_enum_put,
4935 },
4936 {}
4937};
4938
Guillaume Munch6d859062006-08-22 17:15:47 +02004939static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004940 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4941 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004942 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4943 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4944 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4945 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4946 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4947 {
4948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4949 .name = "Capture Source",
4950 .count = 1,
4951 .info = stac92xx_mux_enum_info,
4952 .get = stac92xx_mux_enum_get,
4953 .put = stac92xx_mux_enum_put,
4954 },
4955 {}
4956};
4957
4958static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004959 .build_controls = stac92xx_build_controls,
4960 .build_pcms = stac92xx_build_pcms,
4961 .init = stac92xx_init,
4962 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004963#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004964 .resume = stac92xx_resume,
4965#endif
4966};
4967
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004968static int stac9872_vaio_init(struct hda_codec *codec)
4969{
4970 int err;
4971
4972 err = stac92xx_init(codec);
4973 if (err < 0)
4974 return err;
4975 if (codec->patch_ops.unsol_event)
4976 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4977 return 0;
4978}
4979
4980static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4981{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004982 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004983 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4984 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4985 } else {
4986 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4987 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4988 }
4989}
4990
4991static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4992{
4993 switch (res >> 26) {
4994 case STAC_HP_EVENT:
4995 stac9872_vaio_hp_detect(codec, res);
4996 break;
4997 }
4998}
4999
5000static struct hda_codec_ops stac9872_vaio_patch_ops = {
5001 .build_controls = stac92xx_build_controls,
5002 .build_pcms = stac92xx_build_pcms,
5003 .init = stac9872_vaio_init,
5004 .free = stac92xx_free,
5005 .unsol_event = stac9872_vaio_unsol_event,
5006#ifdef CONFIG_PM
5007 .resume = stac92xx_resume,
5008#endif
5009};
5010
Guillaume Munch6d859062006-08-22 17:15:47 +02005011enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5012 CXD9872RD_VAIO,
5013 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5014 STAC9872AK_VAIO,
5015 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5016 STAC9872K_VAIO,
5017 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005018 CXD9872AKD_VAIO,
5019 STAC_9872_MODELS,
5020};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005021
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005022static const char *stac9872_models[STAC_9872_MODELS] = {
5023 [CXD9872RD_VAIO] = "vaio",
5024 [CXD9872AKD_VAIO] = "vaio-ar",
5025};
5026
5027static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5028 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5029 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5030 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005031 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005032 {}
5033};
5034
Guillaume Munch6d859062006-08-22 17:15:47 +02005035static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005036{
5037 struct sigmatel_spec *spec;
5038 int board_config;
5039
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005040 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5041 stac9872_models,
5042 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005043 if (board_config < 0)
5044 /* unknown config, let generic-parser do its job... */
5045 return snd_hda_parse_generic_codec(codec);
5046
5047 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5048 if (spec == NULL)
5049 return -ENOMEM;
5050
5051 codec->spec = spec;
5052 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005053 case CXD9872RD_VAIO:
5054 case STAC9872AK_VAIO:
5055 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005056 spec->mixer = vaio_mixer;
5057 spec->init = vaio_init;
5058 spec->multiout.max_channels = 2;
5059 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5060 spec->multiout.dac_nids = vaio_dacs;
5061 spec->multiout.hp_nid = VAIO_HP_DAC;
5062 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5063 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005064 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005065 spec->input_mux = &vaio_mux;
5066 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005067 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005068 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005069
5070 case CXD9872AKD_VAIO:
5071 spec->mixer = vaio_ar_mixer;
5072 spec->init = vaio_ar_init;
5073 spec->multiout.max_channels = 2;
5074 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5075 spec->multiout.dac_nids = vaio_dacs;
5076 spec->multiout.hp_nid = VAIO_HP_DAC;
5077 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005078 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005079 spec->adc_nids = vaio_adcs;
5080 spec->input_mux = &vaio_mux;
5081 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005082 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005083 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005084 }
5085
Takashi Iwaidb064e52006-03-16 16:04:58 +01005086 return 0;
5087}
5088
5089
5090/*
Matt2f2f4252005-04-13 14:45:30 +02005091 * patch entries
5092 */
5093struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5094 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5095 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5096 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5097 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5098 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5099 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5100 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005101 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5102 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5103 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5104 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5105 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5106 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005107 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5108 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5109 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5110 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5111 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5112 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5113 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5114 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5115 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5116 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005117 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5118 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5119 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5120 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5121 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5122 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005123 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5124 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005125 /* The following does not take into account .id=0x83847661 when subsys =
5126 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5127 * currently not fully supported.
5128 */
5129 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5130 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5131 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005132 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5133 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5134 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5135 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5136 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5137 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5138 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5139 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005140 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005141 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5142 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005143 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005144 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5145 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005146 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005147 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5148 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5149 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5150 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5151 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5152 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5153 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5154 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005155 {} /* terminator */
5156};