blob: 31a234afe1aff77adbfa20fce3018190a60fb011 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include "hda_codec.h"
34#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010035#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Matt4e550962005-07-04 17:51:39 +020038#define NUM_CONTROL_ALLOC 32
Matthew Ranostayc39555d2008-11-14 17:46:22 -050039
40#define STAC_VREF_EVENT 0x00
41#define STAC_INSERT_EVENT 0x10
Matthew Ranostaya64135a2008-01-10 16:55:06 +010042#define STAC_PWR_EVENT 0x20
43#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020044
Takashi Iwaif5fcc132006-11-24 17:07:44 +010045enum {
46 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010047 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020048 STAC_9200_DELL_D21,
49 STAC_9200_DELL_D22,
50 STAC_9200_DELL_D23,
51 STAC_9200_DELL_M21,
52 STAC_9200_DELL_M22,
53 STAC_9200_DELL_M23,
54 STAC_9200_DELL_M24,
55 STAC_9200_DELL_M25,
56 STAC_9200_DELL_M26,
57 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020058 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010059 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010060 STAC_9200_MODELS
61};
62
63enum {
64 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020065 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020066 STAC_9205_DELL_M43,
67 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_9205_MODELS
69};
70
71enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010072 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010073 STAC_DELL_M6,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050074 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010075 STAC_92HD73XX_MODELS
76};
77
78enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020079 STAC_92HD83XXX_REF,
80 STAC_92HD83XXX_MODELS
81};
82
83enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010084 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010085 STAC_DELL_M4_1,
86 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040087 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010088 STAC_92HD71BXX_MODELS
89};
90
91enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010092 STAC_925x_REF,
93 STAC_M2_2,
94 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020095 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010096 STAC_925x_MODELS
97};
98
99enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100100 STAC_D945_REF,
101 STAC_D945GTP3,
102 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200103 STAC_INTEL_MAC_V1,
104 STAC_INTEL_MAC_V2,
105 STAC_INTEL_MAC_V3,
106 STAC_INTEL_MAC_V4,
107 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800108 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
109 * is given, one of the above models will be
110 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200111 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100112 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100113 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100114 STAC_MACBOOK_PRO_V1,
115 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200116 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200117 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300118 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200119 STAC_922X_DELL_D81,
120 STAC_922X_DELL_D82,
121 STAC_922X_DELL_M81,
122 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100123 STAC_922X_MODELS
124};
125
126enum {
127 STAC_D965_REF,
128 STAC_D965_3ST,
129 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200130 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100131 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100132 STAC_927X_MODELS
133};
Matt Porter403d1942005-11-29 15:00:51 +0100134
Matt2f2f4252005-04-13 14:45:30 +0200135struct sigmatel_spec {
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100136 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200137 unsigned int num_mixers;
138
Matt Porter403d1942005-11-29 15:00:51 +0100139 int board_config;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -0500140 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200141 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100142 unsigned int line_switch: 1;
143 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100144 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100145 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400146 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200147
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100148 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200149 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100150 unsigned int gpio_mask;
151 unsigned int gpio_dir;
152 unsigned int gpio_data;
153 unsigned int gpio_mute;
154
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200155 /* stream */
156 unsigned int stream_delay;
157
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100158 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100159 unsigned char aloopback_mask;
160 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200161
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100162 /* power management */
163 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200164 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100165 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100166 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100167
Matt2f2f4252005-04-13 14:45:30 +0200168 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100169 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400170 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100171 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200172 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100173 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200174
175 /* capture */
176 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200177 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200178 hda_nid_t *mux_nids;
179 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200180 hda_nid_t *dmic_nids;
181 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100182 hda_nid_t *dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +0100183 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200184 hda_nid_t *smux_nids;
185 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400186 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200187
Mattdabbed62005-06-14 10:19:34 +0200188 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100189 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200190 hda_nid_t anabeep_nid;
191 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200192
Matt2f2f4252005-04-13 14:45:30 +0200193 /* pin widgets */
194 hda_nid_t *pin_nids;
195 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200196 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200197 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200198
199 /* codec specific stuff */
200 struct hda_verb *init;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100201 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200202
203 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200204 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100205 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200206 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100207 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200208 struct hda_input_mux *sinput_mux;
209 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400210 unsigned int cur_amux;
211 hda_nid_t *amp_nids;
212 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200213 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200214
Matt Porter403d1942005-11-29 15:00:51 +0100215 /* i/o switches */
216 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200217 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100218 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200219 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200220
Mattc7d4b2f2005-06-27 14:59:41 +0200221 struct hda_pcm pcm_rec[2]; /* PCM information */
222
223 /* dynamic controls and input_mux */
224 struct auto_pin_cfg autocfg;
225 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-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 Iwai16970552007-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 Porterf3302a592006-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 Iwai16970552007-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 Porterf3302a592006-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 Porterf3302a592006-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;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400573 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100574 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400575 /* un/mute SPDIF out */
576 snd_hda_codec_write_cache(codec, nid, 0,
577 AC_VERB_SET_AMP_GAIN_MUTE, val);
578 }
579 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200580}
581
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100582static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200583{
584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
585 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200586 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200587}
588
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100589static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200590{
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct sigmatel_spec *spec = codec->spec;
593 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
594
595 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
596 return 0;
597}
598
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100599static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200600{
601 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
602 struct sigmatel_spec *spec = codec->spec;
603 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
604
Mattc7d4b2f2005-06-27 14:59:41 +0200605 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200606 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
607}
608
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100609static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
610 struct snd_ctl_elem_info *uinfo)
611{
612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
613 struct sigmatel_spec *spec = codec->spec;
614 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
615}
616
617static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
618 struct snd_ctl_elem_value *ucontrol)
619{
620 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
621 struct sigmatel_spec *spec = codec->spec;
622
623 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
624 return 0;
625}
626
627static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_value *ucontrol)
629{
630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
631 struct sigmatel_spec *spec = codec->spec;
632
633 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
634 spec->mono_nid, &spec->cur_mmux);
635}
636
Matthew Ranostay89385032008-09-11 09:49:39 -0400637static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_info *uinfo)
639{
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 struct sigmatel_spec *spec = codec->spec;
642 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
643}
644
645static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
647{
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 struct sigmatel_spec *spec = codec->spec;
650
651 ucontrol->value.enumerated.item[0] = spec->cur_amux;
652 return 0;
653}
654
655static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
657{
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
660 struct snd_kcontrol *ctl =
661 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
662 if (!ctl)
663 return -EINVAL;
664
665 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
666 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
667
668 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
669 0, &spec->cur_amux);
670}
671
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200672#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
673
674static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
675 struct snd_ctl_elem_value *ucontrol)
676{
677 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100678 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200679 struct sigmatel_spec *spec = codec->spec;
680
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100681 ucontrol->value.integer.value[0] = !!(spec->aloopback &
682 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200683 return 0;
684}
685
686static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
687 struct snd_ctl_elem_value *ucontrol)
688{
689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
690 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100691 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200692 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100693 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200694
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100695 idx_val = spec->aloopback_mask << idx;
696 if (ucontrol->value.integer.value[0])
697 val = spec->aloopback | idx_val;
698 else
699 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100700 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200701 return 0;
702
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100703 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200704
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100705 /* Only return the bits defined by the shift value of the
706 * first two bytes of the mask
707 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200708 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100709 kcontrol->private_value & 0xFFFF, 0x0);
710 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200711
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100712 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200713 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100714 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200715 } else {
716 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100717 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200718 }
719
720 snd_hda_codec_write_cache(codec, codec->afg, 0,
721 kcontrol->private_value >> 16, dac_mode);
722
723 return 1;
724}
725
Mattc7d4b2f2005-06-27 14:59:41 +0200726static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200727 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200728 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200729 {}
730};
731
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200732static struct hda_verb stac9200_eapd_init[] = {
733 /* set dac0mux for dac converter */
734 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
735 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
736 {}
737};
738
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100739static struct hda_verb stac92hd73xx_6ch_core_init[] = {
740 /* set master volume and direct control */
741 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
742 /* setup audio connections */
743 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
744 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
745 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
746 /* setup adcs to point to mixer */
747 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
748 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100749 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
750 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
751 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
752 /* setup import muxs */
753 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
754 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
755 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
756 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
757 {}
758};
759
Matthew Ranostayd654a662008-03-14 08:46:51 +0100760static struct hda_verb dell_eq_core_init[] = {
761 /* set master volume to max value without distortion
762 * and direct control */
763 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
764 /* setup audio connections */
765 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400766 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
767 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100768 /* setup adcs to point to mixer */
769 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
770 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
771 /* setup import muxs */
772 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
773 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
774 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
775 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
776 {}
777};
778
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100779static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500780 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100781 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100782 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
783 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100784 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
785 /* setup adcs to point to mixer */
786 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
787 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
788 /* setup import muxs */
789 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
791 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
792 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
793 {}
794};
795
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100796static struct hda_verb stac92hd73xx_8ch_core_init[] = {
797 /* set master volume and direct control */
798 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
799 /* setup audio connections */
800 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
801 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
802 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
803 /* connect hp ports to dac3 */
804 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
805 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
806 /* setup adcs to point to mixer */
807 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
808 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100809 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
810 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
811 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
812 /* setup import muxs */
813 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
817 {}
818};
819
820static struct hda_verb stac92hd73xx_10ch_core_init[] = {
821 /* set master volume and direct control */
822 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
823 /* setup audio connections */
824 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
825 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
826 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
827 /* dac3 is connected to import3 mux */
828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
829 /* connect hp ports to dac4 */
830 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
831 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
832 /* setup adcs to point to mixer */
833 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
834 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100835 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 /* setup import muxs */
839 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
840 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
843 {}
844};
845
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200846static struct hda_verb stac92hd83xxx_core_init[] = {
847 /* start of config #1 */
848 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
849
850 /* start of config #2 */
851 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
852 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
853 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
854
855 /* power state controls amps */
856 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
857};
858
Matthew Ranostaye035b842007-11-06 11:53:55 +0100859static struct hda_verb stac92hd71bxx_core_init[] = {
860 /* set master volume and direct control */
861 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
862 /* connect headphone jack to dac1 */
863 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100864 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
865 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
866 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
867 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100868};
869
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400870#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100871static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200872 /* start of config #1 */
873
874 /* connect port 0f to audio mixer */
875 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200876 /* unmute right and left channels for node 0x0f */
877 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
878 /* start of config #2 */
879
Matthew Ranostay541eee82007-12-14 12:08:04 +0100880 /* set master volume and direct control */
881 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
882 /* connect headphone jack to dac1 */
883 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200884 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100885 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
886 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100887 {}
888};
889
Tobin Davis8e21c342007-01-08 11:04:17 +0100890static struct hda_verb stac925x_core_init[] = {
891 /* set dac0mux for dac converter */
892 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
893 {}
894};
895
Mattc7d4b2f2005-06-27 14:59:41 +0200896static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200897 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200898 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200899 {}
900};
901
Tobin Davis93ed1502006-09-01 21:03:12 +0200902static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200903 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200904 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200905 /* unmute node 0x1b */
906 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
907 /* select node 0x03 as DAC */
908 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
909 {}
910};
911
Matt Porter3cc08dc2006-01-23 15:27:49 +0100912static struct hda_verb stac927x_core_init[] = {
913 /* set master volume and direct control */
914 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200915 /* enable analog pc beep path */
916 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100917 {}
918};
919
Matt Porterf3302a592006-07-31 12:49:34 +0200920static struct hda_verb stac9205_core_init[] = {
921 /* set master volume and direct control */
922 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200923 /* enable analog pc beep path */
924 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a592006-07-31 12:49:34 +0200925 {}
926};
927
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100928#define STAC_MONO_MUX \
929 { \
930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
931 .name = "Mono Mux", \
932 .count = 1, \
933 .info = stac92xx_mono_mux_enum_info, \
934 .get = stac92xx_mono_mux_enum_get, \
935 .put = stac92xx_mono_mux_enum_put, \
936 }
937
Matthew Ranostay89385032008-09-11 09:49:39 -0400938#define STAC_AMP_MUX \
939 { \
940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
941 .name = "Amp Selector Capture Switch", \
942 .count = 1, \
943 .info = stac92xx_amp_mux_enum_info, \
944 .get = stac92xx_amp_mux_enum_get, \
945 .put = stac92xx_amp_mux_enum_put, \
946 }
947
948#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
949 { \
950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
951 .name = xname, \
952 .index = 0, \
953 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
954 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
955 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
956 .info = stac92xx_amp_volume_info, \
957 .get = stac92xx_amp_volume_get, \
958 .put = stac92xx_amp_volume_put, \
959 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
960 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
961 }
962
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200963#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200964 { \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200967 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200968 .info = stac92xx_mux_enum_info, \
969 .get = stac92xx_mux_enum_get, \
970 .put = stac92xx_mux_enum_put, \
971 }
972
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100973#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200974 { \
975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
976 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100977 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200978 .info = stac92xx_aloopback_info, \
979 .get = stac92xx_aloopback_get, \
980 .put = stac92xx_aloopback_put, \
981 .private_value = verb_read | (verb_write << 16), \
982 }
983
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100984static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200985 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
986 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200987 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200988 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200990 { } /* end */
991};
992
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400993#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100994static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400995 /* start of config #1 */
996 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
997 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
998
999 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1000 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1001
1002 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1003 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1004
1005 /* start of config #2 */
1006 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1007 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1008
1009 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1010 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1011
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001012 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1013
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001014 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1015 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1016
1017 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1018 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1019
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001020 { } /* end */
1021};
1022
1023static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001024 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1025
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001026 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1027 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1028
1029 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1031
1032 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1033 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1034
1035 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1036 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1037
1038 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1039 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1040
1041 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1042 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1043
1044 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1045 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1046 { } /* end */
1047};
1048
1049static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001050 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1051
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001052 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1054
1055 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1057
1058 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1059 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1060
1061 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1062 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1063
1064 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1065 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1066
1067 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1068 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1069
1070 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1071 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1072 { } /* end */
1073};
1074
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001075
1076static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1077 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1078 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1079
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1082
1083 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1084 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1085
1086 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1087 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1088
1089 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1090 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1091
1092 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1093 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1094
1095 /*
1096 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1097 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1098 */
1099 { } /* end */
1100};
1101
Matthew Ranostay541eee82007-12-14 12:08:04 +01001102static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001103 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001104 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001105
Matthew Ranostay9b359472007-11-07 13:03:12 +01001106 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1107 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001108
1109 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1110 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001111 /* analog pc-beep replaced with digital beep support */
1112 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001113 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1114 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001115 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001116
Matthew Ranostay687cb982008-10-11 13:52:43 -04001117 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1118 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001119
Matthew Ranostay687cb982008-10-11 13:52:43 -04001120 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001122
1123 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1124 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1125
1126 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1127 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001128 { } /* end */
1129};
1130
Matthew Ranostay541eee82007-12-14 12:08:04 +01001131static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001132 STAC_INPUT_SOURCE(2),
1133 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1134
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001137
1138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001140 { } /* end */
1141};
1142
Tobin Davis8e21c342007-01-08 11:04:17 +01001143static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001144 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001145 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001146 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001147 { } /* end */
1148};
1149
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001150static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001151 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001152 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001153
1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001156
1157 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1158 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001159 { } /* end */
1160};
1161
1162/* This needs to be generated dynamically based on sequence */
1163static struct snd_kcontrol_new stac922x_mixer[] = {
1164 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001165 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1166 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001167
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001170 { } /* end */
1171};
1172
1173
1174static struct snd_kcontrol_new stac927x_mixer[] = {
1175 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001176 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001177
1178 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001180
1181 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001183
1184 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a592006-07-31 12:49:34 +02001186 { } /* end */
1187};
1188
Takashi Iwai16970552007-12-18 18:05:52 +01001189static struct snd_kcontrol_new stac_dmux_mixer = {
1190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1191 .name = "Digital Input Source",
1192 /* count set later */
1193 .info = stac92xx_dmux_enum_info,
1194 .get = stac92xx_dmux_enum_get,
1195 .put = stac92xx_dmux_enum_put,
1196};
1197
Matthew Ranostayd9737752008-09-07 12:03:41 +02001198static struct snd_kcontrol_new stac_smux_mixer = {
1199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001200 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001201 /* count set later */
1202 .info = stac92xx_smux_enum_info,
1203 .get = stac92xx_smux_enum_get,
1204 .put = stac92xx_smux_enum_put,
1205};
1206
Takashi Iwai2134ea42008-01-10 16:53:55 +01001207static const char *slave_vols[] = {
1208 "Front Playback Volume",
1209 "Surround Playback Volume",
1210 "Center Playback Volume",
1211 "LFE Playback Volume",
1212 "Side Playback Volume",
1213 "Headphone Playback Volume",
1214 "Headphone Playback Volume",
1215 "Speaker Playback Volume",
1216 "External Speaker Playback Volume",
1217 "Speaker2 Playback Volume",
1218 NULL
1219};
1220
1221static const char *slave_sws[] = {
1222 "Front Playback Switch",
1223 "Surround Playback Switch",
1224 "Center Playback Switch",
1225 "LFE Playback Switch",
1226 "Side Playback Switch",
1227 "Headphone Playback Switch",
1228 "Headphone Playback Switch",
1229 "Speaker Playback Switch",
1230 "External Speaker Playback Switch",
1231 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001232 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001233 NULL
1234};
1235
Matt2f2f4252005-04-13 14:45:30 +02001236static int stac92xx_build_controls(struct hda_codec *codec)
1237{
1238 struct sigmatel_spec *spec = codec->spec;
1239 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001240 int i;
Matt2f2f4252005-04-13 14:45:30 +02001241
1242 err = snd_hda_add_new_ctls(codec, spec->mixer);
1243 if (err < 0)
1244 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001245
1246 for (i = 0; i < spec->num_mixers; i++) {
1247 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1248 if (err < 0)
1249 return err;
1250 }
Takashi Iwai16970552007-12-18 18:05:52 +01001251 if (spec->num_dmuxes > 0) {
1252 stac_dmux_mixer.count = spec->num_dmuxes;
1253 err = snd_ctl_add(codec->bus->card,
1254 snd_ctl_new1(&stac_dmux_mixer, codec));
1255 if (err < 0)
1256 return err;
1257 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001258 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001259 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1260 struct hda_input_mux *smux = &spec->private_smux;
1261 /* check for mute support on SPDIF out */
1262 if (wcaps & AC_WCAP_OUT_AMP) {
1263 smux->items[smux->num_items].label = "Off";
1264 smux->items[smux->num_items].index = 0;
1265 smux->num_items++;
1266 spec->spdif_mute = 1;
1267 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001268 stac_smux_mixer.count = spec->num_smuxes;
1269 err = snd_ctl_add(codec->bus->card,
1270 snd_ctl_new1(&stac_smux_mixer, codec));
1271 if (err < 0)
1272 return err;
1273 }
Mattc7d4b2f2005-06-27 14:59:41 +02001274
Mattdabbed62005-06-14 10:19:34 +02001275 if (spec->multiout.dig_out_nid) {
1276 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1277 if (err < 0)
1278 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001279 err = snd_hda_create_spdif_share_sw(codec,
1280 &spec->multiout);
1281 if (err < 0)
1282 return err;
1283 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001284 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001285 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001286 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1287 if (err < 0)
1288 return err;
1289 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001290
1291 /* if we have no master control, let's create it */
1292 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001293 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001294 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001295 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001296 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001297 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001298 if (err < 0)
1299 return err;
1300 }
1301 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1302 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1303 NULL, slave_sws);
1304 if (err < 0)
1305 return err;
1306 }
1307
Mattdabbed62005-06-14 10:19:34 +02001308 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001309}
1310
Matt Porter403d1942005-11-29 15:00:51 +01001311static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001312 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001313 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1314};
1315
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001316/*
1317 STAC 9200 pin configs for
1318 102801A8
1319 102801DE
1320 102801E8
1321*/
1322static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001323 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1324 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001325};
1326
1327/*
1328 STAC 9200 pin configs for
1329 102801C0
1330 102801C1
1331*/
1332static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001333 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1334 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001335};
1336
1337/*
1338 STAC 9200 pin configs for
1339 102801C4 (Dell Dimension E310)
1340 102801C5
1341 102801C7
1342 102801D9
1343 102801DA
1344 102801E3
1345*/
1346static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001347 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1348 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001349};
1350
1351
1352/*
1353 STAC 9200-32 pin configs for
1354 102801B5 (Dell Inspiron 630m)
1355 102801D8 (Dell Inspiron 640m)
1356*/
1357static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001358 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1359 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001360};
1361
1362/*
1363 STAC 9200-32 pin configs for
1364 102801C2 (Dell Latitude D620)
1365 102801C8
1366 102801CC (Dell Latitude D820)
1367 102801D4
1368 102801D6
1369*/
1370static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001371 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1372 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001373};
1374
1375/*
1376 STAC 9200-32 pin configs for
1377 102801CE (Dell XPS M1710)
1378 102801CF (Dell Precision M90)
1379*/
1380static unsigned int dell9200_m23_pin_configs[8] = {
1381 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1382 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1383};
1384
1385/*
1386 STAC 9200-32 pin configs for
1387 102801C9
1388 102801CA
1389 102801CB (Dell Latitude 120L)
1390 102801D3
1391*/
1392static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001393 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1394 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001395};
1396
1397/*
1398 STAC 9200-32 pin configs for
1399 102801BD (Dell Inspiron E1505n)
1400 102801EE
1401 102801EF
1402*/
1403static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001404 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1405 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001406};
1407
1408/*
1409 STAC 9200-32 pin configs for
1410 102801F5 (Dell Inspiron 1501)
1411 102801F6
1412*/
1413static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001414 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1415 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001416};
1417
1418/*
1419 STAC 9200-32
1420 102801CD (Dell Inspiron E1705/9400)
1421*/
1422static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001423 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1424 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001425};
1426
Tobin Davisbf277782008-02-03 20:31:47 +01001427static unsigned int oqo9200_pin_configs[8] = {
1428 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1429 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1430};
1431
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001432
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001433static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1434 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001435 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001436 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1437 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1438 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1439 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1440 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1441 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1442 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1443 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1444 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1445 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001446 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001447};
1448
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001449static const char *stac9200_models[STAC_9200_MODELS] = {
1450 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001451 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001452 [STAC_9200_DELL_D21] = "dell-d21",
1453 [STAC_9200_DELL_D22] = "dell-d22",
1454 [STAC_9200_DELL_D23] = "dell-d23",
1455 [STAC_9200_DELL_M21] = "dell-m21",
1456 [STAC_9200_DELL_M22] = "dell-m22",
1457 [STAC_9200_DELL_M23] = "dell-m23",
1458 [STAC_9200_DELL_M24] = "dell-m24",
1459 [STAC_9200_DELL_M25] = "dell-m25",
1460 [STAC_9200_DELL_M26] = "dell-m26",
1461 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001462 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001463 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001464};
1465
1466static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1467 /* SigmaTel reference board */
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1469 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001470 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1472 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001474 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1476 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1478 "unknown Dell", STAC_9200_DELL_D22),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1480 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001482 "Dell Latitude D620", STAC_9200_DELL_M22),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1484 "unknown Dell", STAC_9200_DELL_D23),
1485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1486 "unknown Dell", STAC_9200_DELL_D23),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1488 "unknown Dell", STAC_9200_DELL_M22),
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1490 "unknown Dell", STAC_9200_DELL_M24),
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1492 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001493 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001494 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001495 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001496 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001497 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001498 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001499 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001500 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001501 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001502 "Dell Precision M90", STAC_9200_DELL_M23),
1503 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1504 "unknown Dell", STAC_9200_DELL_M22),
1505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1506 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001508 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001510 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1512 "unknown Dell", STAC_9200_DELL_D23),
1513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1514 "unknown Dell", STAC_9200_DELL_D23),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1516 "unknown Dell", STAC_9200_DELL_D21),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1518 "unknown Dell", STAC_9200_DELL_D23),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1520 "unknown Dell", STAC_9200_DELL_D21),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1522 "unknown Dell", STAC_9200_DELL_M25),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1524 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001526 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1528 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001529 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001530 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001531 /* Gateway machines needs EAPD to be set on resume */
1532 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1533 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1534 STAC_9200_GATEWAY),
1535 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1536 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001537 /* OQO Mobile */
1538 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001539 {} /* terminator */
1540};
1541
Tobin Davis8e21c342007-01-08 11:04:17 +01001542static unsigned int ref925x_pin_configs[8] = {
1543 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001544 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001545};
1546
1547static unsigned int stac925x_MA6_pin_configs[8] = {
1548 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1549 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1550};
1551
Tobin Davis2c11f952007-05-17 09:36:34 +02001552static unsigned int stac925x_PA6_pin_configs[8] = {
1553 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1554 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1555};
1556
Tobin Davis8e21c342007-01-08 11:04:17 +01001557static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001558 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1559 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001560};
1561
1562static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1563 [STAC_REF] = ref925x_pin_configs,
1564 [STAC_M2_2] = stac925xM2_2_pin_configs,
1565 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001566 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001567};
1568
1569static const char *stac925x_models[STAC_925x_MODELS] = {
1570 [STAC_REF] = "ref",
1571 [STAC_M2_2] = "m2-2",
1572 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001573 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001574};
1575
1576static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1577 /* SigmaTel reference board */
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001579 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001580 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1581 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1582 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001583 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001584 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1585 {} /* terminator */
1586};
1587
Matthew Ranostaya7662642008-02-21 07:51:14 +01001588static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001589 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1590 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1591 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001592 0x01452050,
1593};
1594
1595static unsigned int dell_m6_pin_configs[13] = {
1596 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001597 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001598 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1599 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001600};
1601
1602static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001603 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1604 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001605 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001606};
1607
1608static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1609 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001610 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001611 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001612};
1613
1614static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1615 /* SigmaTel reference board */
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001617 "DFI LanParty", STAC_92HD73XX_REF),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1619 "unknown Dell", STAC_DELL_M6),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1621 "unknown Dell", STAC_DELL_M6),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1623 "unknown Dell", STAC_DELL_M6),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1625 "unknown Dell", STAC_DELL_M6),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1627 "unknown Dell", STAC_DELL_M6),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1629 "unknown Dell", STAC_DELL_M6),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1631 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001632 {} /* terminator */
1633};
1634
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001635static unsigned int ref92hd83xxx_pin_configs[14] = {
1636 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1637 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1638 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1639 0x01451160, 0x98560170,
1640};
1641
1642static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1643 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1644};
1645
1646static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1647 [STAC_92HD83XXX_REF] = "ref",
1648};
1649
1650static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1651 /* SigmaTel reference board */
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1653 "DFI LanParty", STAC_92HD71BXX_REF),
1654};
1655
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001656static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001657 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001658 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001659 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001660};
1661
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001662static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001663 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001664 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001665 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001666};
1667
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001668static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001669 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1670 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001671 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001672};
1673
Matthew Ranostaye035b842007-11-06 11:53:55 +01001674static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1675 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001676 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1677 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001678 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001679};
1680
1681static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1682 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001683 [STAC_DELL_M4_1] = "dell-m4-1",
1684 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001685 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001686};
1687
1688static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1689 /* SigmaTel reference board */
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1691 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001692 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1693 "HP dv5", STAC_HP_M4),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1695 "HP dv7", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001696 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1697 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1699 "unknown Dell", STAC_DELL_M4_1),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1701 "unknown Dell", STAC_DELL_M4_1),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1703 "unknown Dell", STAC_DELL_M4_1),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1705 "unknown Dell", STAC_DELL_M4_1),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1707 "unknown Dell", STAC_DELL_M4_1),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1709 "unknown Dell", STAC_DELL_M4_1),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1711 "unknown Dell", STAC_DELL_M4_1),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1713 "unknown Dell", STAC_DELL_M4_2),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1715 "unknown Dell", STAC_DELL_M4_2),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1717 "unknown Dell", STAC_DELL_M4_2),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1719 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001720 {} /* terminator */
1721};
1722
Matt Porter403d1942005-11-29 15:00:51 +01001723static unsigned int ref922x_pin_configs[10] = {
1724 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1725 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001726 0x40000100, 0x40000100,
1727};
1728
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001729/*
1730 STAC 922X pin configs for
1731 102801A7
1732 102801AB
1733 102801A9
1734 102801D1
1735 102801D2
1736*/
1737static unsigned int dell_922x_d81_pin_configs[10] = {
1738 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1739 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1740 0x01813122, 0x400001f2,
1741};
1742
1743/*
1744 STAC 922X pin configs for
1745 102801AC
1746 102801D0
1747*/
1748static unsigned int dell_922x_d82_pin_configs[10] = {
1749 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1750 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1751 0x01813122, 0x400001f1,
1752};
1753
1754/*
1755 STAC 922X pin configs for
1756 102801BF
1757*/
1758static unsigned int dell_922x_m81_pin_configs[10] = {
1759 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1760 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1761 0x40C003f1, 0x405003f0,
1762};
1763
1764/*
1765 STAC 9221 A1 pin configs for
1766 102801D7 (Dell XPS M1210)
1767*/
1768static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001769 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1770 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001771 0x508003f3, 0x405003f4,
1772};
1773
Matt Porter403d1942005-11-29 15:00:51 +01001774static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001775 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001776 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1777 0x02a19120, 0x40000100,
1778};
1779
1780static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001781 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1782 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001783 0x02a19320, 0x40000100,
1784};
1785
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001786static unsigned int intel_mac_v1_pin_configs[10] = {
1787 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1788 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001789 0x400000fc, 0x400000fb,
1790};
1791
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001792static unsigned int intel_mac_v2_pin_configs[10] = {
1793 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1794 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001795 0x400000fc, 0x400000fb,
1796};
1797
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001798static unsigned int intel_mac_v3_pin_configs[10] = {
1799 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1800 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1801 0x400000fc, 0x400000fb,
1802};
1803
1804static unsigned int intel_mac_v4_pin_configs[10] = {
1805 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1806 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1807 0x400000fc, 0x400000fb,
1808};
1809
1810static unsigned int intel_mac_v5_pin_configs[10] = {
1811 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1812 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1813 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001814};
1815
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001816static unsigned int ecs202_pin_configs[10] = {
1817 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1818 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1819 0x9037012e, 0x40e000f2,
1820};
Takashi Iwai76c08822007-06-19 12:17:42 +02001821
Takashi Iwai19039bd2006-06-28 15:52:16 +02001822static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001823 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001824 [STAC_D945GTP3] = d945gtp3_pin_configs,
1825 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001826 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1827 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1828 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1829 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1830 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001831 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001832 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001833 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1834 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1835 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1836 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1837 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1838 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001839 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001840 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1841 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1842 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1843 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001844};
1845
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001846static const char *stac922x_models[STAC_922X_MODELS] = {
1847 [STAC_D945_REF] = "ref",
1848 [STAC_D945GTP5] = "5stack",
1849 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001850 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1851 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1852 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1853 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1854 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001855 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001856 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001857 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001858 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001859 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1860 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001861 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001862 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001863 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001864 [STAC_922X_DELL_D81] = "dell-d81",
1865 [STAC_922X_DELL_D82] = "dell-d82",
1866 [STAC_922X_DELL_M81] = "dell-m81",
1867 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001868};
1869
1870static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1871 /* SigmaTel reference board */
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1873 "DFI LanParty", STAC_D945_REF),
1874 /* Intel 945G based systems */
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1876 "Intel D945G", STAC_D945GTP3),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1878 "Intel D945G", STAC_D945GTP3),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1880 "Intel D945G", STAC_D945GTP3),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1882 "Intel D945G", STAC_D945GTP3),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1884 "Intel D945G", STAC_D945GTP3),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1886 "Intel D945G", STAC_D945GTP3),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1888 "Intel D945G", STAC_D945GTP3),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1890 "Intel D945G", STAC_D945GTP3),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1892 "Intel D945G", STAC_D945GTP3),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1894 "Intel D945G", STAC_D945GTP3),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1896 "Intel D945G", STAC_D945GTP3),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1898 "Intel D945G", STAC_D945GTP3),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1900 "Intel D945G", STAC_D945GTP3),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1902 "Intel D945G", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1904 "Intel D945G", STAC_D945GTP3),
1905 /* Intel D945G 5-stack systems */
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1907 "Intel D945G", STAC_D945GTP5),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1909 "Intel D945G", STAC_D945GTP5),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1911 "Intel D945G", STAC_D945GTP5),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1913 "Intel D945G", STAC_D945GTP5),
1914 /* Intel 945P based systems */
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1916 "Intel D945P", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1918 "Intel D945P", STAC_D945GTP3),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1920 "Intel D945P", STAC_D945GTP3),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1922 "Intel D945P", STAC_D945GTP3),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1924 "Intel D945P", STAC_D945GTP3),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1926 "Intel D945P", STAC_D945GTP5),
1927 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001928 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001929 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001930 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001931 /* Dell systems */
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1933 "unknown Dell", STAC_922X_DELL_D81),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1935 "unknown Dell", STAC_922X_DELL_D81),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1937 "unknown Dell", STAC_922X_DELL_D81),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1939 "unknown Dell", STAC_922X_DELL_D82),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1941 "unknown Dell", STAC_922X_DELL_M81),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1943 "unknown Dell", STAC_922X_DELL_D82),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1945 "unknown Dell", STAC_922X_DELL_D81),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1947 "unknown Dell", STAC_922X_DELL_D81),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1949 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001950 /* ECS/PC Chips boards */
1951 SND_PCI_QUIRK(0x1019, 0x2144,
1952 "ECS/PC chips", STAC_ECS_202),
1953 SND_PCI_QUIRK(0x1019, 0x2608,
1954 "ECS/PC chips", STAC_ECS_202),
1955 SND_PCI_QUIRK(0x1019, 0x2633,
1956 "ECS/PC chips P17G/1333", STAC_ECS_202),
1957 SND_PCI_QUIRK(0x1019, 0x2811,
1958 "ECS/PC chips", STAC_ECS_202),
1959 SND_PCI_QUIRK(0x1019, 0x2812,
1960 "ECS/PC chips", STAC_ECS_202),
1961 SND_PCI_QUIRK(0x1019, 0x2813,
1962 "ECS/PC chips", STAC_ECS_202),
1963 SND_PCI_QUIRK(0x1019, 0x2814,
1964 "ECS/PC chips", STAC_ECS_202),
1965 SND_PCI_QUIRK(0x1019, 0x2815,
1966 "ECS/PC chips", STAC_ECS_202),
1967 SND_PCI_QUIRK(0x1019, 0x2816,
1968 "ECS/PC chips", STAC_ECS_202),
1969 SND_PCI_QUIRK(0x1019, 0x2817,
1970 "ECS/PC chips", STAC_ECS_202),
1971 SND_PCI_QUIRK(0x1019, 0x2818,
1972 "ECS/PC chips", STAC_ECS_202),
1973 SND_PCI_QUIRK(0x1019, 0x2819,
1974 "ECS/PC chips", STAC_ECS_202),
1975 SND_PCI_QUIRK(0x1019, 0x2820,
1976 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001977 {} /* terminator */
1978};
1979
Matt Porter3cc08dc2006-01-23 15:27:49 +01001980static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001981 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1982 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1983 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1984 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001985};
1986
Tobin Davis93ed1502006-09-01 21:03:12 +02001987static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001988 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1989 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1990 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1991 0x40000100, 0x40000100
1992};
1993
Tobin Davis93ed1502006-09-01 21:03:12 +02001994static unsigned int d965_5st_pin_configs[14] = {
1995 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1996 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1997 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1998 0x40000100, 0x40000100
1999};
2000
Tobin Davis4ff076e2007-08-07 11:48:12 +02002001static unsigned int dell_3st_pin_configs[14] = {
2002 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2003 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002004 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002005 0x40c003fc, 0x40000100
2006};
2007
Tobin Davis93ed1502006-09-01 21:03:12 +02002008static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002009 [STAC_D965_REF] = ref927x_pin_configs,
2010 [STAC_D965_3ST] = d965_3st_pin_configs,
2011 [STAC_D965_5ST] = d965_5st_pin_configs,
2012 [STAC_DELL_3ST] = dell_3st_pin_configs,
2013 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002014};
2015
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002016static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002017 [STAC_D965_REF] = "ref",
2018 [STAC_D965_3ST] = "3stack",
2019 [STAC_D965_5ST] = "5stack",
2020 [STAC_DELL_3ST] = "dell-3stack",
2021 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002022};
2023
2024static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2025 /* SigmaTel reference board */
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2027 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002028 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002031 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002048 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002053 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002056 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002057 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002058 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002062 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002072 {} /* terminator */
2073};
2074
Matt Porterf3302a592006-07-31 12:49:34 +02002075static unsigned int ref9205_pin_configs[12] = {
2076 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002077 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002078 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a592006-07-31 12:49:34 +02002079};
2080
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002081/*
2082 STAC 9205 pin configs for
2083 102801F1
2084 102801F2
2085 102801FC
2086 102801FD
2087 10280204
2088 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002089 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002090*/
2091static unsigned int dell_9205_m42_pin_configs[12] = {
2092 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2093 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2094 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2095};
2096
2097/*
2098 STAC 9205 pin configs for
2099 102801F9
2100 102801FA
2101 102801FE
2102 102801FF (Dell Precision M4300)
2103 10280206
2104 10280200
2105 10280201
2106*/
2107static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002108 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2109 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2110 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2111};
2112
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002113static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002114 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2115 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2116 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2117};
2118
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002119static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002120 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002121 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2122 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2123 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a592006-07-31 12:49:34 +02002124};
2125
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002126static const char *stac9205_models[STAC_9205_MODELS] = {
2127 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002128 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002129 [STAC_9205_DELL_M43] = "dell-m43",
2130 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002131};
2132
2133static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2134 /* SigmaTel reference board */
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2136 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2138 "unknown Dell", STAC_9205_DELL_M42),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2140 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002142 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2144 "Dell Precision", STAC_9205_DELL_M43),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2146 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2148 "unknown Dell", STAC_9205_DELL_M42),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2150 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2152 "Dell Precision", STAC_9205_DELL_M43),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002154 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2156 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2158 "Dell Precision", STAC_9205_DELL_M43),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2160 "Dell Precision", STAC_9205_DELL_M43),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2162 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2164 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2166 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a592006-07-31 12:49:34 +02002167 {} /* terminator */
2168};
2169
Richard Fish11b44bb2006-08-23 18:31:34 +02002170static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2171{
2172 int i;
2173 struct sigmatel_spec *spec = codec->spec;
2174
2175 if (! spec->bios_pin_configs) {
2176 spec->bios_pin_configs = kcalloc(spec->num_pins,
2177 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2178 if (! spec->bios_pin_configs)
2179 return -ENOMEM;
2180 }
2181
2182 for (i = 0; i < spec->num_pins; i++) {
2183 hda_nid_t nid = spec->pin_nids[i];
2184 unsigned int pin_cfg;
2185
2186 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2187 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2188 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2189 nid, pin_cfg);
2190 spec->bios_pin_configs[i] = pin_cfg;
2191 }
2192
2193 return 0;
2194}
2195
Matthew Ranostay87d48362007-07-17 11:52:24 +02002196static void stac92xx_set_config_reg(struct hda_codec *codec,
2197 hda_nid_t pin_nid, unsigned int pin_config)
2198{
2199 int i;
2200 snd_hda_codec_write(codec, pin_nid, 0,
2201 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2202 pin_config & 0x000000ff);
2203 snd_hda_codec_write(codec, pin_nid, 0,
2204 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2205 (pin_config & 0x0000ff00) >> 8);
2206 snd_hda_codec_write(codec, pin_nid, 0,
2207 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2208 (pin_config & 0x00ff0000) >> 16);
2209 snd_hda_codec_write(codec, pin_nid, 0,
2210 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2211 pin_config >> 24);
2212 i = snd_hda_codec_read(codec, pin_nid, 0,
2213 AC_VERB_GET_CONFIG_DEFAULT,
2214 0x00);
2215 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2216 pin_nid, i);
2217}
2218
Matt2f2f4252005-04-13 14:45:30 +02002219static void stac92xx_set_config_regs(struct hda_codec *codec)
2220{
2221 int i;
2222 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002223
Matthew Ranostay87d48362007-07-17 11:52:24 +02002224 if (!spec->pin_configs)
2225 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002226
Matthew Ranostay87d48362007-07-17 11:52:24 +02002227 for (i = 0; i < spec->num_pins; i++)
2228 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2229 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002230}
Matt2f2f4252005-04-13 14:45:30 +02002231
Matt2f2f4252005-04-13 14:45:30 +02002232/*
2233 * Analog playback callbacks
2234 */
2235static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2236 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002237 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002238{
2239 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002240 if (spec->stream_delay)
2241 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002242 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2243 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002244}
2245
2246static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2247 struct hda_codec *codec,
2248 unsigned int stream_tag,
2249 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002250 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002251{
2252 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002253 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002254}
2255
2256static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2257 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002258 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002259{
2260 struct sigmatel_spec *spec = codec->spec;
2261 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2262}
2263
2264/*
Mattdabbed62005-06-14 10:19:34 +02002265 * Digital playback callbacks
2266 */
2267static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2268 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002269 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002270{
2271 struct sigmatel_spec *spec = codec->spec;
2272 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2273}
2274
2275static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2276 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002277 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002278{
2279 struct sigmatel_spec *spec = codec->spec;
2280 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2281}
2282
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002283static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2284 struct hda_codec *codec,
2285 unsigned int stream_tag,
2286 unsigned int format,
2287 struct snd_pcm_substream *substream)
2288{
2289 struct sigmatel_spec *spec = codec->spec;
2290 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2291 stream_tag, format, substream);
2292}
2293
Mattdabbed62005-06-14 10:19:34 +02002294
2295/*
Matt2f2f4252005-04-13 14:45:30 +02002296 * Analog capture callbacks
2297 */
2298static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2299 struct hda_codec *codec,
2300 unsigned int stream_tag,
2301 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002302 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002303{
2304 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002305 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002306
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002307 if (spec->powerdown_adcs) {
2308 msleep(40);
2309 snd_hda_codec_write_cache(codec, nid, 0,
2310 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2311 }
2312 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002313 return 0;
2314}
2315
2316static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2317 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002318 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002319{
2320 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002321 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002322
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002323 snd_hda_codec_cleanup_stream(codec, nid);
2324 if (spec->powerdown_adcs)
2325 snd_hda_codec_write_cache(codec, nid, 0,
2326 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002327 return 0;
2328}
2329
Mattdabbed62005-06-14 10:19:34 +02002330static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2331 .substreams = 1,
2332 .channels_min = 2,
2333 .channels_max = 2,
2334 /* NID is set in stac92xx_build_pcms */
2335 .ops = {
2336 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002337 .close = stac92xx_dig_playback_pcm_close,
2338 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002339 },
2340};
2341
2342static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2343 .substreams = 1,
2344 .channels_min = 2,
2345 .channels_max = 2,
2346 /* NID is set in stac92xx_build_pcms */
2347};
2348
Matt2f2f4252005-04-13 14:45:30 +02002349static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2350 .substreams = 1,
2351 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002352 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002353 .nid = 0x02, /* NID to query formats and rates */
2354 .ops = {
2355 .open = stac92xx_playback_pcm_open,
2356 .prepare = stac92xx_playback_pcm_prepare,
2357 .cleanup = stac92xx_playback_pcm_cleanup
2358 },
2359};
2360
Matt Porter3cc08dc2006-01-23 15:27:49 +01002361static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2362 .substreams = 1,
2363 .channels_min = 2,
2364 .channels_max = 2,
2365 .nid = 0x06, /* NID to query formats and rates */
2366 .ops = {
2367 .open = stac92xx_playback_pcm_open,
2368 .prepare = stac92xx_playback_pcm_prepare,
2369 .cleanup = stac92xx_playback_pcm_cleanup
2370 },
2371};
2372
Matt2f2f4252005-04-13 14:45:30 +02002373static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002374 .channels_min = 2,
2375 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002376 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002377 .ops = {
2378 .prepare = stac92xx_capture_pcm_prepare,
2379 .cleanup = stac92xx_capture_pcm_cleanup
2380 },
2381};
2382
2383static int stac92xx_build_pcms(struct hda_codec *codec)
2384{
2385 struct sigmatel_spec *spec = codec->spec;
2386 struct hda_pcm *info = spec->pcm_rec;
2387
2388 codec->num_pcms = 1;
2389 codec->pcm_info = info;
2390
Mattc7d4b2f2005-06-27 14:59:41 +02002391 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002392 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002393 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002394 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002395 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002396
2397 if (spec->alt_switch) {
2398 codec->num_pcms++;
2399 info++;
2400 info->name = "STAC92xx Analog Alt";
2401 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2402 }
Matt2f2f4252005-04-13 14:45:30 +02002403
Mattdabbed62005-06-14 10:19:34 +02002404 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2405 codec->num_pcms++;
2406 info++;
2407 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002408 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002409 if (spec->multiout.dig_out_nid) {
2410 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2411 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2412 }
2413 if (spec->dig_in_nid) {
2414 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2415 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2416 }
2417 }
2418
Matt2f2f4252005-04-13 14:45:30 +02002419 return 0;
2420}
2421
Takashi Iwaic960a032006-03-23 17:06:28 +01002422static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2423{
2424 unsigned int pincap = snd_hda_param_read(codec, nid,
2425 AC_PAR_PIN_CAP);
2426 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2427 if (pincap & AC_PINCAP_VREF_100)
2428 return AC_PINCTL_VREF_100;
2429 if (pincap & AC_PINCAP_VREF_80)
2430 return AC_PINCTL_VREF_80;
2431 if (pincap & AC_PINCAP_VREF_50)
2432 return AC_PINCTL_VREF_50;
2433 if (pincap & AC_PINCAP_VREF_GRD)
2434 return AC_PINCTL_VREF_GRD;
2435 return 0;
2436}
2437
Matt Porter403d1942005-11-29 15:00:51 +01002438static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2439
2440{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002441 snd_hda_codec_write_cache(codec, nid, 0,
2442 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002443}
2444
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002445#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2446
2447static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_value *ucontrol)
2449{
2450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2451 struct sigmatel_spec *spec = codec->spec;
2452
Takashi Iwaid7a89432008-11-12 09:48:04 +01002453 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002454 return 0;
2455}
2456
2457static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2458 struct snd_ctl_elem_value *ucontrol)
2459{
2460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2461 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002462 int nid = kcontrol->private_value;
2463
2464 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002465
2466 /* check to be sure that the ports are upto date with
2467 * switch changes
2468 */
2469 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2470
2471 return 1;
2472}
2473
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002474#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002475
2476static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2477{
2478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2479 struct sigmatel_spec *spec = codec->spec;
2480 int io_idx = kcontrol-> private_value & 0xff;
2481
2482 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2483 return 0;
2484}
2485
2486static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2487{
2488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2489 struct sigmatel_spec *spec = codec->spec;
2490 hda_nid_t nid = kcontrol->private_value >> 8;
2491 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002492 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002493
2494 spec->io_switch[io_idx] = val;
2495
2496 if (val)
2497 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002498 else {
2499 unsigned int pinctl = AC_PINCTL_IN_EN;
2500 if (io_idx) /* set VREF for mic */
2501 pinctl |= stac92xx_get_vref(codec, nid);
2502 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2503 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002504
2505 /* check the auto-mute again: we need to mute/unmute the speaker
2506 * appropriately according to the pin direction
2507 */
2508 if (spec->hp_detect)
2509 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2510
Matt Porter403d1942005-11-29 15:00:51 +01002511 return 1;
2512}
2513
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002514#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2515
2516static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2517 struct snd_ctl_elem_value *ucontrol)
2518{
2519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2520 struct sigmatel_spec *spec = codec->spec;
2521
2522 ucontrol->value.integer.value[0] = spec->clfe_swap;
2523 return 0;
2524}
2525
2526static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2527 struct snd_ctl_elem_value *ucontrol)
2528{
2529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2530 struct sigmatel_spec *spec = codec->spec;
2531 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002532 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002533
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002534 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002535 return 0;
2536
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002537 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002538
2539 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2540 spec->clfe_swap ? 0x4 : 0x0);
2541
2542 return 1;
2543}
2544
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002545#define STAC_CODEC_HP_SWITCH(xname) \
2546 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2547 .name = xname, \
2548 .index = 0, \
2549 .info = stac92xx_hp_switch_info, \
2550 .get = stac92xx_hp_switch_get, \
2551 .put = stac92xx_hp_switch_put, \
2552 }
2553
Matt Porter403d1942005-11-29 15:00:51 +01002554#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2555 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2556 .name = xname, \
2557 .index = 0, \
2558 .info = stac92xx_io_switch_info, \
2559 .get = stac92xx_io_switch_get, \
2560 .put = stac92xx_io_switch_put, \
2561 .private_value = xpval, \
2562 }
2563
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002564#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2565 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2566 .name = xname, \
2567 .index = 0, \
2568 .info = stac92xx_clfe_switch_info, \
2569 .get = stac92xx_clfe_switch_get, \
2570 .put = stac92xx_clfe_switch_put, \
2571 .private_value = xpval, \
2572 }
Matt Porter403d1942005-11-29 15:00:51 +01002573
Mattc7d4b2f2005-06-27 14:59:41 +02002574enum {
2575 STAC_CTL_WIDGET_VOL,
2576 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002577 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002578 STAC_CTL_WIDGET_AMP_MUX,
2579 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002580 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002581 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002582 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002583};
2584
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002585static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002586 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2587 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002588 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002589 STAC_AMP_MUX,
2590 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002591 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002592 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002593 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002594};
2595
2596/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002597static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2598 struct snd_kcontrol_new *ktemp,
2599 int idx, const char *name,
2600 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002601{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002602 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002603
2604 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2605 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2606
2607 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2608 if (! knew)
2609 return -ENOMEM;
2610 if (spec->kctl_alloc) {
2611 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2612 kfree(spec->kctl_alloc);
2613 }
2614 spec->kctl_alloc = knew;
2615 spec->num_kctl_alloc = num;
2616 }
2617
2618 knew = &spec->kctl_alloc[spec->num_kctl_used];
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002619 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002620 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002621 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002622 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002623 return -ENOMEM;
2624 knew->private_value = val;
2625 spec->num_kctl_used++;
2626 return 0;
2627}
2628
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002629static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2630 int type, int idx, const char *name,
2631 unsigned long val)
2632{
2633 return stac92xx_add_control_temp(spec,
2634 &stac92xx_control_templates[type],
2635 idx, name, val);
2636}
2637
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002638
2639/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002640static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2641 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002642{
2643 return stac92xx_add_control_idx(spec, type, 0, name, val);
2644}
2645
Matt Porter403d1942005-11-29 15:00:51 +01002646/* flag inputs as additional dynamic lineouts */
2647static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2648{
2649 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002650 unsigned int wcaps, wtype;
2651 int i, num_dacs = 0;
2652
2653 /* use the wcaps cache to count all DACs available for line-outs */
2654 for (i = 0; i < codec->num_nodes; i++) {
2655 wcaps = codec->wcaps[i];
2656 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002657
Steve Longerbeam7b043892007-05-03 20:50:03 +02002658 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2659 num_dacs++;
2660 }
Matt Porter403d1942005-11-29 15:00:51 +01002661
Steve Longerbeam7b043892007-05-03 20:50:03 +02002662 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2663
Matt Porter403d1942005-11-29 15:00:51 +01002664 switch (cfg->line_outs) {
2665 case 3:
2666 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002667 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002668 cfg->line_out_pins[cfg->line_outs] =
2669 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002670 spec->line_switch = 1;
2671 cfg->line_outs++;
2672 }
2673 break;
2674 case 2:
2675 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002676 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002677 cfg->line_out_pins[cfg->line_outs] =
2678 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002679 spec->line_switch = 1;
2680 cfg->line_outs++;
2681 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002682 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002683 cfg->line_out_pins[cfg->line_outs] =
2684 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002685 spec->mic_switch = 1;
2686 cfg->line_outs++;
2687 }
2688 break;
2689 case 1:
2690 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002691 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002692 cfg->line_out_pins[cfg->line_outs] =
2693 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002694 spec->line_switch = 1;
2695 cfg->line_outs++;
2696 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002697 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002698 cfg->line_out_pins[cfg->line_outs] =
2699 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002700 spec->mic_switch = 1;
2701 cfg->line_outs++;
2702 }
2703 break;
2704 }
2705
2706 return 0;
2707}
2708
Steve Longerbeam7b043892007-05-03 20:50:03 +02002709
2710static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2711{
2712 int i;
2713
2714 for (i = 0; i < spec->multiout.num_dacs; i++) {
2715 if (spec->multiout.dac_nids[i] == nid)
2716 return 1;
2717 }
2718
2719 return 0;
2720}
2721
Matt Porter3cc08dc2006-01-23 15:27:49 +01002722/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002723 * Fill in the dac_nids table from the parsed pin configuration
2724 * This function only works when every pin in line_out_pins[]
2725 * contains atleast one DAC in its connection list. Some 92xx
2726 * codecs are not connected directly to a DAC, such as the 9200
2727 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002728 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002729static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002730 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002731{
2732 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002733 int i, j, conn_len = 0;
2734 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2735 unsigned int wcaps, wtype;
2736
Mattc7d4b2f2005-06-27 14:59:41 +02002737 for (i = 0; i < cfg->line_outs; i++) {
2738 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002739 conn_len = snd_hda_get_connections(codec, nid, conn,
2740 HDA_MAX_CONNECTIONS);
2741 for (j = 0; j < conn_len; j++) {
2742 wcaps = snd_hda_param_read(codec, conn[j],
2743 AC_PAR_AUDIO_WIDGET_CAP);
2744 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002745 if (wtype != AC_WID_AUD_OUT ||
2746 (wcaps & AC_WCAP_DIGITAL))
2747 continue;
2748 /* conn[j] is a DAC routed to this line-out */
2749 if (!is_in_dac_nids(spec, conn[j]))
2750 break;
2751 }
2752
2753 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002754 if (spec->multiout.num_dacs > 0) {
2755 /* we have already working output pins,
2756 * so let's drop the broken ones again
2757 */
2758 cfg->line_outs = spec->multiout.num_dacs;
2759 break;
2760 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002761 /* error out, no available DAC found */
2762 snd_printk(KERN_ERR
2763 "%s: No available DAC for pin 0x%x\n",
2764 __func__, nid);
2765 return -ENODEV;
2766 }
2767
2768 spec->multiout.dac_nids[i] = conn[j];
2769 spec->multiout.num_dacs++;
2770 if (conn_len > 1) {
2771 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002772 snd_hda_codec_write_cache(codec, nid, 0,
2773 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002774
2775 }
Mattc7d4b2f2005-06-27 14:59:41 +02002776 }
2777
Steve Longerbeam7b043892007-05-03 20:50:03 +02002778 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2779 spec->multiout.num_dacs,
2780 spec->multiout.dac_nids[0],
2781 spec->multiout.dac_nids[1],
2782 spec->multiout.dac_nids[2],
2783 spec->multiout.dac_nids[3],
2784 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002785 return 0;
2786}
2787
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002788/* create volume control/switch for the given prefx type */
2789static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2790{
2791 char name[32];
2792 int err;
2793
2794 sprintf(name, "%s Playback Volume", pfx);
2795 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2796 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2797 if (err < 0)
2798 return err;
2799 sprintf(name, "%s Playback Switch", pfx);
2800 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2801 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2802 if (err < 0)
2803 return err;
2804 return 0;
2805}
2806
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002807static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2808{
2809 if (!spec->multiout.hp_nid)
2810 spec->multiout.hp_nid = nid;
2811 else if (spec->multiout.num_dacs > 4) {
2812 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2813 return 1;
2814 } else {
2815 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2816 spec->multiout.num_dacs++;
2817 }
2818 return 0;
2819}
2820
2821static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2822{
2823 if (is_in_dac_nids(spec, nid))
2824 return 1;
2825 if (spec->multiout.hp_nid == nid)
2826 return 1;
2827 return 0;
2828}
2829
Mattc7d4b2f2005-06-27 14:59:41 +02002830/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002831static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002832 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002833{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002834 static const char *chname[4] = {
2835 "Front", "Surround", NULL /*CLFE*/, "Side"
2836 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002837 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002838 int i, err;
2839
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002840 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002841 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002842
2843
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002844 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002845 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002846 continue;
2847
2848 nid = spec->multiout.dac_nids[i];
2849
2850 if (i == 2) {
2851 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002852 err = create_controls(spec, "Center", nid, 1);
2853 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002854 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002855 err = create_controls(spec, "LFE", nid, 2);
2856 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002857 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002858
2859 wid_caps = get_wcaps(codec, nid);
2860
2861 if (wid_caps & AC_WCAP_LR_SWAP) {
2862 err = stac92xx_add_control(spec,
2863 STAC_CTL_WIDGET_CLFE_SWITCH,
2864 "Swap Center/LFE Playback Switch", nid);
2865
2866 if (err < 0)
2867 return err;
2868 }
2869
Mattc7d4b2f2005-06-27 14:59:41 +02002870 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002871 err = create_controls(spec, chname[i], nid, 3);
2872 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002873 return err;
2874 }
2875 }
2876
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002877 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2878 cfg->hp_outs && !spec->multiout.hp_nid)
2879 spec->multiout.hp_nid = nid;
2880
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002881 if (cfg->hp_outs > 1) {
2882 err = stac92xx_add_control(spec,
2883 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002884 "Headphone as Line Out Switch",
2885 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002886 if (err < 0)
2887 return err;
2888 }
2889
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002890 if (spec->line_switch) {
2891 nid = cfg->input_pins[AUTO_PIN_LINE];
2892 pincap = snd_hda_param_read(codec, nid,
2893 AC_PAR_PIN_CAP);
2894 if (pincap & AC_PINCAP_OUT) {
2895 err = stac92xx_add_control(spec,
2896 STAC_CTL_WIDGET_IO_SWITCH,
2897 "Line In as Output Switch", nid << 8);
2898 if (err < 0)
2899 return err;
2900 }
2901 }
Matt Porter403d1942005-11-29 15:00:51 +01002902
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002903 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002904 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002905 unsigned int mic_pin = AUTO_PIN_MIC;
2906again:
2907 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002908 def_conf = snd_hda_codec_read(codec, nid, 0,
2909 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002910 /* some laptops have an internal analog microphone
2911 * which can't be used as a output */
2912 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2913 pincap = snd_hda_param_read(codec, nid,
2914 AC_PAR_PIN_CAP);
2915 if (pincap & AC_PINCAP_OUT) {
2916 err = stac92xx_add_control(spec,
2917 STAC_CTL_WIDGET_IO_SWITCH,
2918 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002919 nid = snd_hda_codec_read(codec, nid, 0,
2920 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2921 if (!check_in_dac_nids(spec, nid))
2922 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002923 if (err < 0)
2924 return err;
2925 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002926 } else if (mic_pin == AUTO_PIN_MIC) {
2927 mic_pin = AUTO_PIN_FRONT_MIC;
2928 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002929 }
2930 }
Matt Porter403d1942005-11-29 15:00:51 +01002931
Mattc7d4b2f2005-06-27 14:59:41 +02002932 return 0;
2933}
2934
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002935/* add playback controls for Speaker and HP outputs */
2936static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2937 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002938{
2939 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002940 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002941 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002942
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002943 old_num_dacs = spec->multiout.num_dacs;
2944 for (i = 0; i < cfg->hp_outs; i++) {
2945 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2946 if (wid_caps & AC_WCAP_UNSOL_CAP)
2947 spec->hp_detect = 1;
2948 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2949 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2950 if (check_in_dac_nids(spec, nid))
2951 nid = 0;
2952 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002953 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002954 add_spec_dacs(spec, nid);
2955 }
2956 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002957 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002958 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2959 if (check_in_dac_nids(spec, nid))
2960 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002961 if (! nid)
2962 continue;
2963 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002964 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002965 for (i = 0; i < cfg->line_outs; i++) {
2966 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2967 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2968 if (check_in_dac_nids(spec, nid))
2969 nid = 0;
2970 if (! nid)
2971 continue;
2972 add_spec_dacs(spec, nid);
2973 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002974 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2975 static const char *pfxs[] = {
2976 "Speaker", "External Speaker", "Speaker2",
2977 };
2978 err = create_controls(spec, pfxs[i - old_num_dacs],
2979 spec->multiout.dac_nids[i], 3);
2980 if (err < 0)
2981 return err;
2982 }
2983 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002984 err = create_controls(spec, "Headphone",
2985 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002986 if (err < 0)
2987 return err;
2988 }
Mattc7d4b2f2005-06-27 14:59:41 +02002989
2990 return 0;
2991}
2992
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002993/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002994static const char *stac92xx_mono_labels[4] = {
2995 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002996};
2997
2998/* create mono mux for mono out on capable codecs */
2999static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3000{
3001 struct sigmatel_spec *spec = codec->spec;
3002 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3003 int i, num_cons;
3004 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3005
3006 num_cons = snd_hda_get_connections(codec,
3007 spec->mono_nid,
3008 con_lst,
3009 HDA_MAX_NUM_INPUTS);
3010 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3011 return -EINVAL;
3012
3013 for (i = 0; i < num_cons; i++) {
3014 mono_mux->items[mono_mux->num_items].label =
3015 stac92xx_mono_labels[i];
3016 mono_mux->items[mono_mux->num_items].index = i;
3017 mono_mux->num_items++;
3018 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003019
3020 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3021 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003022}
3023
Matthew Ranostay89385032008-09-11 09:49:39 -04003024/* labels for amp mux outputs */
3025static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003026 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003027};
3028
3029/* create amp out controls mux on capable codecs */
3030static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3031{
3032 struct sigmatel_spec *spec = codec->spec;
3033 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3034 int i, err;
3035
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003036 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003037 amp_mux->items[amp_mux->num_items].label =
3038 stac92xx_amp_labels[i];
3039 amp_mux->items[amp_mux->num_items].index = i;
3040 amp_mux->num_items++;
3041 }
3042
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003043 if (spec->num_amps > 1) {
3044 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3045 "Amp Selector Capture Switch", 0);
3046 if (err < 0)
3047 return err;
3048 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003049 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3050 "Amp Capture Volume",
3051 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3052}
3053
3054
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003055/* create PC beep volume controls */
3056static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3057 hda_nid_t nid)
3058{
3059 struct sigmatel_spec *spec = codec->spec;
3060 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3061 int err;
3062
3063 /* check for mute support for the the amp */
3064 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3065 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3066 "PC Beep Playback Switch",
3067 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3068 if (err < 0)
3069 return err;
3070 }
3071
3072 /* check to see if there is volume support for the amp */
3073 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3074 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3075 "PC Beep Playback Volume",
3076 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3077 if (err < 0)
3078 return err;
3079 }
3080 return 0;
3081}
3082
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003083#ifdef CONFIG_SND_HDA_INPUT_BEEP
3084#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3085
3086static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3087 struct snd_ctl_elem_value *ucontrol)
3088{
3089 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3090 ucontrol->value.integer.value[0] = codec->beep->enabled;
3091 return 0;
3092}
3093
3094static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3095 struct snd_ctl_elem_value *ucontrol)
3096{
3097 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3098 int enabled = !!ucontrol->value.integer.value[0];
3099 if (codec->beep->enabled != enabled) {
3100 codec->beep->enabled = enabled;
3101 return 1;
3102 }
3103 return 0;
3104}
3105
3106static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3108 .info = stac92xx_dig_beep_switch_info,
3109 .get = stac92xx_dig_beep_switch_get,
3110 .put = stac92xx_dig_beep_switch_put,
3111};
3112
3113static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3114{
3115 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3116 0, "PC Beep Playback Switch", 0);
3117}
3118#endif
3119
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003120static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3121{
3122 struct sigmatel_spec *spec = codec->spec;
3123 int wcaps, nid, i, err = 0;
3124
3125 for (i = 0; i < spec->num_muxes; i++) {
3126 nid = spec->mux_nids[i];
3127 wcaps = get_wcaps(codec, nid);
3128
3129 if (wcaps & AC_WCAP_OUT_AMP) {
3130 err = stac92xx_add_control_idx(spec,
3131 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3132 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3133 if (err < 0)
3134 return err;
3135 }
3136 }
3137 return 0;
3138};
3139
Matthew Ranostayd9737752008-09-07 12:03:41 +02003140static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003141 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003142};
3143
3144static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3145{
3146 struct sigmatel_spec *spec = codec->spec;
3147 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003148 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003149 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003150 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003151
3152 num_cons = snd_hda_get_connections(codec,
3153 spec->smux_nids[0],
3154 con_lst,
3155 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003156 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003157 return -EINVAL;
3158
Matthew Ranostay65973632008-09-16 10:39:37 -04003159 if (!labels)
3160 labels = stac92xx_spdif_labels;
3161
Matthew Ranostayd9737752008-09-07 12:03:41 +02003162 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003163 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003164 spdif_mux->items[spdif_mux->num_items].index = i;
3165 spdif_mux->num_items++;
3166 }
3167
3168 return 0;
3169}
3170
Matt Porter8b657272006-10-26 17:12:59 +02003171/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003172static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003173 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3174 "Digital Mic 3", "Digital Mic 4"
3175};
3176
3177/* create playback/capture controls for input pins on dmic capable codecs */
3178static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3179 const struct auto_pin_cfg *cfg)
3180{
3181 struct sigmatel_spec *spec = codec->spec;
3182 struct hda_input_mux *dimux = &spec->private_dimux;
3183 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003184 int err, i, j;
3185 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003186
3187 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3188 dimux->items[dimux->num_items].index = 0;
3189 dimux->num_items++;
3190
3191 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003192 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003193 int index;
3194 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003195 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003196 unsigned int def_conf;
3197
3198 def_conf = snd_hda_codec_read(codec,
3199 spec->dmic_nids[i],
3200 0,
3201 AC_VERB_GET_CONFIG_DEFAULT,
3202 0);
3203 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3204 continue;
3205
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003206 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003207 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003208 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003209 con_lst,
3210 HDA_MAX_NUM_INPUTS);
3211 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003212 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003213 index = j;
3214 goto found;
3215 }
3216 continue;
3217found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003218 wcaps = get_wcaps(codec, nid) &
3219 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003220
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003221 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003222 sprintf(name, "%s Capture Volume",
3223 stac92xx_dmic_labels[dimux->num_items]);
3224
3225 err = stac92xx_add_control(spec,
3226 STAC_CTL_WIDGET_VOL,
3227 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003228 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3229 (wcaps & AC_WCAP_OUT_AMP) ?
3230 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003231 if (err < 0)
3232 return err;
3233 }
3234
Matt Porter8b657272006-10-26 17:12:59 +02003235 dimux->items[dimux->num_items].label =
3236 stac92xx_dmic_labels[dimux->num_items];
3237 dimux->items[dimux->num_items].index = index;
3238 dimux->num_items++;
3239 }
3240
3241 return 0;
3242}
3243
Mattc7d4b2f2005-06-27 14:59:41 +02003244/* create playback/capture controls for input pins */
3245static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3246{
3247 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003248 struct hda_input_mux *imux = &spec->private_imux;
3249 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3250 int i, j, k;
3251
3252 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003253 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003254
Takashi Iwai314634b2006-09-21 11:56:18 +02003255 if (!cfg->input_pins[i])
3256 continue;
3257 index = -1;
3258 for (j = 0; j < spec->num_muxes; j++) {
3259 int num_cons;
3260 num_cons = snd_hda_get_connections(codec,
3261 spec->mux_nids[j],
3262 con_lst,
3263 HDA_MAX_NUM_INPUTS);
3264 for (k = 0; k < num_cons; k++)
3265 if (con_lst[k] == cfg->input_pins[i]) {
3266 index = k;
3267 goto found;
3268 }
Mattc7d4b2f2005-06-27 14:59:41 +02003269 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003270 continue;
3271 found:
3272 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3273 imux->items[imux->num_items].index = index;
3274 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003275 }
3276
Steve Longerbeam7b043892007-05-03 20:50:03 +02003277 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003278 /*
3279 * Set the current input for the muxes.
3280 * The STAC9221 has two input muxes with identical source
3281 * NID lists. Hopefully this won't get confused.
3282 */
3283 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003284 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3285 AC_VERB_SET_CONNECT_SEL,
3286 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003287 }
3288 }
3289
Mattc7d4b2f2005-06-27 14:59:41 +02003290 return 0;
3291}
3292
Mattc7d4b2f2005-06-27 14:59:41 +02003293static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3294{
3295 struct sigmatel_spec *spec = codec->spec;
3296 int i;
3297
3298 for (i = 0; i < spec->autocfg.line_outs; i++) {
3299 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3300 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3301 }
3302}
3303
3304static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3305{
3306 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003307 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003308
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003309 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3310 hda_nid_t pin;
3311 pin = spec->autocfg.hp_pins[i];
3312 if (pin) /* connect to front */
3313 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3314 }
3315 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3316 hda_nid_t pin;
3317 pin = spec->autocfg.speaker_pins[i];
3318 if (pin) /* connect to front */
3319 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3320 }
Mattc7d4b2f2005-06-27 14:59:41 +02003321}
3322
Matt Porter3cc08dc2006-01-23 15:27:49 +01003323static 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 +02003324{
3325 struct sigmatel_spec *spec = codec->spec;
3326 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003327 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003328
Matt Porter8b657272006-10-26 17:12:59 +02003329 if ((err = snd_hda_parse_pin_def_config(codec,
3330 &spec->autocfg,
3331 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003332 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003333 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003334 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003335
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003336 /* If we have no real line-out pin and multiple hp-outs, HPs should
3337 * be set up as multi-channel outputs.
3338 */
3339 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3340 spec->autocfg.hp_outs > 1) {
3341 /* Copy hp_outs to line_outs, backup line_outs in
3342 * speaker_outs so that the following routines can handle
3343 * HP pins as primary outputs.
3344 */
3345 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3346 sizeof(spec->autocfg.line_out_pins));
3347 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3348 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3349 sizeof(spec->autocfg.hp_pins));
3350 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3351 hp_speaker_swap = 1;
3352 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003353 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003354 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3355 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003356 u32 caps = query_amp_caps(codec,
3357 spec->autocfg.mono_out_pin, dir);
3358 hda_nid_t conn_list[1];
3359
3360 /* get the mixer node and then the mono mux if it exists */
3361 if (snd_hda_get_connections(codec,
3362 spec->autocfg.mono_out_pin, conn_list, 1) &&
3363 snd_hda_get_connections(codec, conn_list[0],
3364 conn_list, 1)) {
3365
3366 int wcaps = get_wcaps(codec, conn_list[0]);
3367 int wid_type = (wcaps & AC_WCAP_TYPE)
3368 >> AC_WCAP_TYPE_SHIFT;
3369 /* LR swap check, some stac925x have a mux that
3370 * changes the DACs output path instead of the
3371 * mono-mux path.
3372 */
3373 if (wid_type == AC_WID_AUD_SEL &&
3374 !(wcaps & AC_WCAP_LR_SWAP))
3375 spec->mono_nid = conn_list[0];
3376 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003377 if (dir) {
3378 hda_nid_t nid = spec->autocfg.mono_out_pin;
3379
3380 /* most mono outs have a least a mute/unmute switch */
3381 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3382 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3383 "Mono Playback Switch",
3384 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003385 if (err < 0)
3386 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003387 /* check for volume support for the amp */
3388 if ((caps & AC_AMPCAP_NUM_STEPS)
3389 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3390 err = stac92xx_add_control(spec,
3391 STAC_CTL_WIDGET_VOL,
3392 "Mono Playback Volume",
3393 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3394 if (err < 0)
3395 return err;
3396 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003397 }
3398
3399 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3400 AC_PINCTL_OUT_EN);
3401 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003402
Matt Porter403d1942005-11-29 15:00:51 +01003403 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3404 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003405 if (spec->multiout.num_dacs == 0)
3406 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3407 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003408
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003409 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3410
3411 if (err < 0)
3412 return err;
3413
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003414 /* setup analog beep controls */
3415 if (spec->anabeep_nid > 0) {
3416 err = stac92xx_auto_create_beep_ctls(codec,
3417 spec->anabeep_nid);
3418 if (err < 0)
3419 return err;
3420 }
3421
3422 /* setup digital beep controls and input device */
3423#ifdef CONFIG_SND_HDA_INPUT_BEEP
3424 if (spec->digbeep_nid > 0) {
3425 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003426 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003427
3428 err = stac92xx_auto_create_beep_ctls(codec, nid);
3429 if (err < 0)
3430 return err;
3431 err = snd_hda_attach_beep_device(codec, nid);
3432 if (err < 0)
3433 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003434 /* if no beep switch is available, make its own one */
3435 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3436 if (codec->beep &&
3437 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3438 err = stac92xx_beep_switch_ctl(codec);
3439 if (err < 0)
3440 return err;
3441 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003442 }
3443#endif
3444
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003445 if (hp_speaker_swap == 1) {
3446 /* Restore the hp_outs and line_outs */
3447 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3448 sizeof(spec->autocfg.line_out_pins));
3449 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3450 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3451 sizeof(spec->autocfg.speaker_pins));
3452 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3453 memset(spec->autocfg.speaker_pins, 0,
3454 sizeof(spec->autocfg.speaker_pins));
3455 spec->autocfg.speaker_outs = 0;
3456 }
3457
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003458 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3459
3460 if (err < 0)
3461 return err;
3462
3463 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3464
3465 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003466 return err;
3467
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003468 if (spec->mono_nid > 0) {
3469 err = stac92xx_auto_create_mono_output_ctls(codec);
3470 if (err < 0)
3471 return err;
3472 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003473 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003474 err = stac92xx_auto_create_amp_output_ctls(codec);
3475 if (err < 0)
3476 return err;
3477 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003478 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003479 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3480 &spec->autocfg)) < 0)
3481 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003482 if (spec->num_muxes > 0) {
3483 err = stac92xx_auto_create_mux_input_ctls(codec);
3484 if (err < 0)
3485 return err;
3486 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003487 if (spec->num_smuxes > 0) {
3488 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3489 if (err < 0)
3490 return err;
3491 }
Matt Porter8b657272006-10-26 17:12:59 +02003492
Mattc7d4b2f2005-06-27 14:59:41 +02003493 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003494 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003495 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003496
Takashi Iwai82bc9552006-03-21 11:24:42 +01003497 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003498 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003499 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003500 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003501
3502 if (spec->kctl_alloc)
3503 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3504
3505 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003506 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003507 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003508 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003509 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003510 return 1;
3511}
3512
Takashi Iwai82bc9552006-03-21 11:24:42 +01003513/* add playback controls for HP output */
3514static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3515 struct auto_pin_cfg *cfg)
3516{
3517 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003518 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003519 unsigned int wid_caps;
3520
3521 if (! pin)
3522 return 0;
3523
3524 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003525 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003526 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003527
3528 return 0;
3529}
3530
Richard Fish160ea0d2006-09-06 13:58:25 +02003531/* add playback controls for LFE output */
3532static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3533 struct auto_pin_cfg *cfg)
3534{
3535 struct sigmatel_spec *spec = codec->spec;
3536 int err;
3537 hda_nid_t lfe_pin = 0x0;
3538 int i;
3539
3540 /*
3541 * search speaker outs and line outs for a mono speaker pin
3542 * with an amp. If one is found, add LFE controls
3543 * for it.
3544 */
3545 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3546 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003547 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003548 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3549 if (wcaps == AC_WCAP_OUT_AMP)
3550 /* found a mono speaker with an amp, must be lfe */
3551 lfe_pin = pin;
3552 }
3553
3554 /* if speaker_outs is 0, then speakers may be in line_outs */
3555 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3556 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3557 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003558 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003559 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003560 AC_VERB_GET_CONFIG_DEFAULT,
3561 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003562 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003563 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003564 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3565 if (wcaps == AC_WCAP_OUT_AMP)
3566 /* found a mono speaker with an amp,
3567 must be lfe */
3568 lfe_pin = pin;
3569 }
3570 }
3571 }
3572
3573 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003574 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003575 if (err < 0)
3576 return err;
3577 }
3578
3579 return 0;
3580}
3581
Mattc7d4b2f2005-06-27 14:59:41 +02003582static int stac9200_parse_auto_config(struct hda_codec *codec)
3583{
3584 struct sigmatel_spec *spec = codec->spec;
3585 int err;
3586
Kailang Yangdf694da2005-12-05 19:42:22 +01003587 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003588 return err;
3589
3590 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3591 return err;
3592
Takashi Iwai82bc9552006-03-21 11:24:42 +01003593 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3594 return err;
3595
Richard Fish160ea0d2006-09-06 13:58:25 +02003596 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3597 return err;
3598
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003599 if (spec->num_muxes > 0) {
3600 err = stac92xx_auto_create_mux_input_ctls(codec);
3601 if (err < 0)
3602 return err;
3603 }
3604
Takashi Iwai82bc9552006-03-21 11:24:42 +01003605 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003606 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003607 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003608 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003609
3610 if (spec->kctl_alloc)
3611 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3612
3613 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003614 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003615
3616 return 1;
3617}
3618
Sam Revitch62fe78e2006-05-10 15:09:17 +02003619/*
3620 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3621 * funky external mute control using GPIO pins.
3622 */
3623
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003624static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003625 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003626{
3627 unsigned int gpiostate, gpiomask, gpiodir;
3628
3629 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3630 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003631 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003632
3633 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3634 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003635 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003636
3637 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3638 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003639 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003640
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003641 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003642 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3643
3644 snd_hda_codec_write(codec, codec->afg, 0,
3645 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003646 snd_hda_codec_read(codec, codec->afg, 0,
3647 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003648
3649 msleep(1);
3650
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003651 snd_hda_codec_read(codec, codec->afg, 0,
3652 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003653}
3654
Takashi Iwai314634b2006-09-21 11:56:18 +02003655static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3656 unsigned int event)
3657{
3658 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003659 snd_hda_codec_write_cache(codec, nid, 0,
3660 AC_VERB_SET_UNSOLICITED_ENABLE,
3661 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003662}
3663
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003664static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3665{
3666 int i;
3667 for (i = 0; i < cfg->hp_outs; i++)
3668 if (cfg->hp_pins[i] == nid)
3669 return 1; /* nid is a HP-Out */
3670
3671 return 0; /* nid is not a HP-Out */
3672};
3673
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003674static void stac92xx_power_down(struct hda_codec *codec)
3675{
3676 struct sigmatel_spec *spec = codec->spec;
3677
3678 /* power down inactive DACs */
3679 hda_nid_t *dac;
3680 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003681 if (!is_in_dac_nids(spec, *dac) &&
3682 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003683 snd_hda_codec_write_cache(codec, *dac, 0,
3684 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3685}
3686
Mattc7d4b2f2005-06-27 14:59:41 +02003687static int stac92xx_init(struct hda_codec *codec)
3688{
3689 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003690 struct auto_pin_cfg *cfg = &spec->autocfg;
3691 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003692
Mattc7d4b2f2005-06-27 14:59:41 +02003693 snd_hda_sequence_write(codec, spec->init);
3694
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003695 /* power down adcs initially */
3696 if (spec->powerdown_adcs)
3697 for (i = 0; i < spec->num_adcs; i++)
3698 snd_hda_codec_write_cache(codec,
3699 spec->adc_nids[i], 0,
3700 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003701 /* set up pins */
3702 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003703 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003704 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003705 enable_pin_detect(codec, cfg->hp_pins[i],
3706 STAC_HP_EVENT);
Takashi Iwai0a07aca2007-03-13 10:40:23 +01003707 /* force to enable the first line-out; the others are set up
3708 * in unsol_event
3709 */
3710 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3711 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003712 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003713 /* fake event to set up pins */
3714 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3715 } else {
3716 stac92xx_auto_init_multi_out(codec);
3717 stac92xx_auto_init_hp_out(codec);
3718 }
3719 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003720 hda_nid_t nid = cfg->input_pins[i];
3721 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003722 unsigned int pinctl;
3723 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3724 /* for mic pins, force to initialize */
3725 pinctl = stac92xx_get_vref(codec, nid);
3726 } else {
3727 pinctl = snd_hda_codec_read(codec, nid, 0,
3728 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3729 /* if PINCTL already set then skip */
3730 if (pinctl & AC_PINCTL_IN_EN)
3731 continue;
3732 }
3733 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003734 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3735 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003736 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003737 for (i = 0; i < spec->num_dmics; i++)
3738 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3739 AC_PINCTL_IN_EN);
3740 for (i = 0; i < spec->num_pwrs; i++) {
3741 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3742 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3743 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3744 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003745 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3746 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003747 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003748 /* outputs are only ports capable of power management
3749 * any attempts on powering down a input port cause the
3750 * referenced VREF to act quirky.
3751 */
3752 if (pinctl & AC_PINCTL_IN_EN)
3753 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003754 /* skip any ports that don't have jacks since presence
3755 * detection is useless */
3756 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003757 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003758 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3759 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3760 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003761 if (spec->dac_list)
3762 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003763 if (cfg->dig_out_pin)
3764 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3765 AC_PINCTL_OUT_EN);
3766 if (cfg->dig_in_pin)
3767 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3768 AC_PINCTL_IN_EN);
3769
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003770 stac_gpio_set(codec, spec->gpio_mask,
3771 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003772
Mattc7d4b2f2005-06-27 14:59:41 +02003773 return 0;
3774}
3775
Matt2f2f4252005-04-13 14:45:30 +02003776static void stac92xx_free(struct hda_codec *codec)
3777{
Mattc7d4b2f2005-06-27 14:59:41 +02003778 struct sigmatel_spec *spec = codec->spec;
3779 int i;
3780
3781 if (! spec)
3782 return;
3783
3784 if (spec->kctl_alloc) {
3785 for (i = 0; i < spec->num_kctl_used; i++)
3786 kfree(spec->kctl_alloc[i].name);
3787 kfree(spec->kctl_alloc);
3788 }
3789
Richard Fish11b44bb2006-08-23 18:31:34 +02003790 if (spec->bios_pin_configs)
3791 kfree(spec->bios_pin_configs);
3792
Mattc7d4b2f2005-06-27 14:59:41 +02003793 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003794 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003795}
3796
Matt4e550962005-07-04 17:51:39 +02003797static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3798 unsigned int flag)
3799{
3800 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3801 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003802
Takashi Iwaif9acba42007-05-29 18:01:06 +02003803 if (pin_ctl & AC_PINCTL_IN_EN) {
3804 /*
3805 * we need to check the current set-up direction of
3806 * shared input pins since they can be switched via
3807 * "xxx as Output" mixer switch
3808 */
3809 struct sigmatel_spec *spec = codec->spec;
3810 struct auto_pin_cfg *cfg = &spec->autocfg;
3811 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3812 spec->line_switch) ||
3813 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3814 spec->mic_switch))
3815 return;
3816 }
3817
Steve Longerbeam7b043892007-05-03 20:50:03 +02003818 /* if setting pin direction bits, clear the current
3819 direction bits first */
3820 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3821 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3822
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003823 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003824 AC_VERB_SET_PIN_WIDGET_CONTROL,
3825 pin_ctl | flag);
3826}
3827
3828static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3829 unsigned int flag)
3830{
3831 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3832 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003833 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003834 AC_VERB_SET_PIN_WIDGET_CONTROL,
3835 pin_ctl & ~flag);
3836}
3837
Jiang Zhe40c1d302007-11-12 13:05:16 +01003838static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003839{
3840 if (!nid)
3841 return 0;
3842 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003843 & (1 << 31)) {
3844 unsigned int pinctl;
3845 pinctl = snd_hda_codec_read(codec, nid, 0,
3846 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3847 if (pinctl & AC_PINCTL_IN_EN)
3848 return 0; /* mic- or line-input */
3849 else
3850 return 1; /* HP-output */
3851 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003852 return 0;
3853}
3854
Takashi Iwaid7a89432008-11-12 09:48:04 +01003855/* return non-zero if the hp-pin of the given array index isn't
3856 * a jack-detection target
3857 */
3858static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3859{
3860 struct auto_pin_cfg *cfg = &spec->autocfg;
3861
3862 /* ignore sensing of shared line and mic jacks */
3863 if (spec->line_switch &&
3864 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3865 return 1;
3866 if (spec->mic_switch &&
3867 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3868 return 1;
3869 /* ignore if the pin is set as line-out */
3870 if (cfg->hp_pins[i] == spec->hp_switch)
3871 return 1;
3872 return 0;
3873}
3874
Takashi Iwai314634b2006-09-21 11:56:18 +02003875static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003876{
3877 struct sigmatel_spec *spec = codec->spec;
3878 struct auto_pin_cfg *cfg = &spec->autocfg;
3879 int i, presence;
3880
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003881 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003882 if (spec->gpio_mute)
3883 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3884 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3885
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003886 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003887 if (presence)
3888 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003889 if (no_hp_sensing(spec, i))
3890 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003891 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003892 }
Matt4e550962005-07-04 17:51:39 +02003893
3894 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003895 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003896 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003897 stac92xx_reset_pinctl(codec, spec->hp_switch,
3898 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003899 for (i = 0; i < cfg->line_outs; i++)
3900 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3901 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003902 for (i = 0; i < cfg->speaker_outs; i++)
3903 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3904 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003905 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003906 stac_gpio_set(codec, spec->gpio_mask,
3907 spec->gpio_dir, spec->gpio_data &
3908 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003909 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003910 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003911 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003912 stac92xx_set_pinctl(codec, spec->hp_switch,
3913 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003914 for (i = 0; i < cfg->line_outs; i++)
3915 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3916 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003917 for (i = 0; i < cfg->speaker_outs; i++)
3918 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3919 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003920 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003921 stac_gpio_set(codec, spec->gpio_mask,
3922 spec->gpio_dir, spec->gpio_data |
3923 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003924 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01003925 /* toggle hp outs */
3926 for (i = 0; i < cfg->hp_outs; i++) {
3927 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3928 if (no_hp_sensing(spec, i))
3929 continue;
3930 if (presence)
3931 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3932 else
3933 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3934 }
Matt4e550962005-07-04 17:51:39 +02003935}
3936
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003937static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3938{
3939 struct sigmatel_spec *spec = codec->spec;
3940 hda_nid_t nid = spec->pwr_nids[idx];
3941 int presence, val;
3942 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3943 & 0x000000ff;
3944 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003945
3946 /* several codecs have two power down bits */
3947 if (spec->pwr_mapping)
3948 idx = spec->pwr_mapping[idx];
3949 else
3950 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003951
3952 if (presence)
3953 val &= ~idx;
3954 else
3955 val |= idx;
3956
3957 /* power down unused output ports */
3958 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3959};
3960
Takashi Iwai314634b2006-09-21 11:56:18 +02003961static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3962{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003963 struct sigmatel_spec *spec = codec->spec;
3964 int idx = res >> 26 & 0x0f;
3965
Matthew Ranostay72474be2008-10-09 09:32:17 -04003966 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003967 case STAC_HP_EVENT:
3968 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003969 /* fallthru */
3970 case STAC_PWR_EVENT:
3971 if (spec->num_pwrs > 0)
3972 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04003973 break;
3974 case STAC_VREF_EVENT: {
3975 int data = snd_hda_codec_read(codec, codec->afg, 0,
3976 AC_VERB_GET_GPIO_DATA, 0);
3977 /* toggle VREF state based on GPIOx status */
3978 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
3979 !!(data & (1 << idx)));
3980 break;
3981 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003982 }
3983}
3984
Takashi Iwaicb53c622007-08-10 17:21:45 +02003985#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003986static int stac92xx_resume(struct hda_codec *codec)
3987{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003988 struct sigmatel_spec *spec = codec->spec;
3989
Richard Fish11b44bb2006-08-23 18:31:34 +02003990 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003991 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003992 stac_gpio_set(codec, spec->gpio_mask,
3993 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003994 snd_hda_codec_resume_amp(codec);
3995 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003996 /* power down inactive DACs */
3997 if (spec->dac_list)
3998 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003999 /* invoke unsolicited event to reset the HP state */
4000 if (spec->hp_detect)
4001 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02004002 return 0;
4003}
4004#endif
4005
Matt2f2f4252005-04-13 14:45:30 +02004006static struct hda_codec_ops stac92xx_patch_ops = {
4007 .build_controls = stac92xx_build_controls,
4008 .build_pcms = stac92xx_build_pcms,
4009 .init = stac92xx_init,
4010 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004011 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004012#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004013 .resume = stac92xx_resume,
4014#endif
Matt2f2f4252005-04-13 14:45:30 +02004015};
4016
4017static int patch_stac9200(struct hda_codec *codec)
4018{
4019 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004020 int err;
Matt2f2f4252005-04-13 14:45:30 +02004021
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004022 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004023 if (spec == NULL)
4024 return -ENOMEM;
4025
4026 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004027 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004028 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004029 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4030 stac9200_models,
4031 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004032 if (spec->board_config < 0) {
4033 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4034 err = stac92xx_save_bios_config_regs(codec);
4035 if (err < 0) {
4036 stac92xx_free(codec);
4037 return err;
4038 }
4039 spec->pin_configs = spec->bios_pin_configs;
4040 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004041 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4042 stac92xx_set_config_regs(codec);
4043 }
Matt2f2f4252005-04-13 14:45:30 +02004044
4045 spec->multiout.max_channels = 2;
4046 spec->multiout.num_dacs = 1;
4047 spec->multiout.dac_nids = stac9200_dac_nids;
4048 spec->adc_nids = stac9200_adc_nids;
4049 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004050 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004051 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004052 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004053 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004054
Tobin Davisbf277782008-02-03 20:31:47 +01004055 if (spec->board_config == STAC_9200_GATEWAY ||
4056 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004057 spec->init = stac9200_eapd_init;
4058 else
4059 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004060 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004061
Takashi Iwai117f2572008-03-18 09:53:23 +01004062 if (spec->board_config == STAC_9200_PANASONIC) {
4063 spec->gpio_mask = spec->gpio_dir = 0x09;
4064 spec->gpio_data = 0x00;
4065 }
4066
Mattc7d4b2f2005-06-27 14:59:41 +02004067 err = stac9200_parse_auto_config(codec);
4068 if (err < 0) {
4069 stac92xx_free(codec);
4070 return err;
4071 }
Matt2f2f4252005-04-13 14:45:30 +02004072
4073 codec->patch_ops = stac92xx_patch_ops;
4074
4075 return 0;
4076}
4077
Tobin Davis8e21c342007-01-08 11:04:17 +01004078static int patch_stac925x(struct hda_codec *codec)
4079{
4080 struct sigmatel_spec *spec;
4081 int err;
4082
4083 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4084 if (spec == NULL)
4085 return -ENOMEM;
4086
4087 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004088 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004089 spec->pin_nids = stac925x_pin_nids;
4090 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4091 stac925x_models,
4092 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004093 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004094 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004095 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4096 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004097 err = stac92xx_save_bios_config_regs(codec);
4098 if (err < 0) {
4099 stac92xx_free(codec);
4100 return err;
4101 }
4102 spec->pin_configs = spec->bios_pin_configs;
4103 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4104 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4105 stac92xx_set_config_regs(codec);
4106 }
4107
4108 spec->multiout.max_channels = 2;
4109 spec->multiout.num_dacs = 1;
4110 spec->multiout.dac_nids = stac925x_dac_nids;
4111 spec->adc_nids = stac925x_adc_nids;
4112 spec->mux_nids = stac925x_mux_nids;
4113 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004114 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004115 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004116 switch (codec->vendor_id) {
4117 case 0x83847632: /* STAC9202 */
4118 case 0x83847633: /* STAC9202D */
4119 case 0x83847636: /* STAC9251 */
4120 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004121 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004122 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004123 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4124 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004125 break;
4126 default:
4127 spec->num_dmics = 0;
4128 break;
4129 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004130
4131 spec->init = stac925x_core_init;
4132 spec->mixer = stac925x_mixer;
4133
4134 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004135 if (!err) {
4136 if (spec->board_config < 0) {
4137 printk(KERN_WARNING "hda_codec: No auto-config is "
4138 "available, default to model=ref\n");
4139 spec->board_config = STAC_925x_REF;
4140 goto again;
4141 }
4142 err = -EINVAL;
4143 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004144 if (err < 0) {
4145 stac92xx_free(codec);
4146 return err;
4147 }
4148
4149 codec->patch_ops = stac92xx_patch_ops;
4150
4151 return 0;
4152}
4153
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004154static struct hda_input_mux stac92hd73xx_dmux = {
4155 .num_items = 4,
4156 .items = {
4157 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004158 { "Digital Mic 1", 0x09 },
4159 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004160 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004161 }
4162};
4163
4164static int patch_stac92hd73xx(struct hda_codec *codec)
4165{
4166 struct sigmatel_spec *spec;
4167 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4168 int err = 0;
4169
4170 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4171 if (spec == NULL)
4172 return -ENOMEM;
4173
4174 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004175 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004176 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4177 spec->pin_nids = stac92hd73xx_pin_nids;
4178 spec->board_config = snd_hda_check_board_config(codec,
4179 STAC_92HD73XX_MODELS,
4180 stac92hd73xx_models,
4181 stac92hd73xx_cfg_tbl);
4182again:
4183 if (spec->board_config < 0) {
4184 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4185 " STAC92HD73XX, using BIOS defaults\n");
4186 err = stac92xx_save_bios_config_regs(codec);
4187 if (err < 0) {
4188 stac92xx_free(codec);
4189 return err;
4190 }
4191 spec->pin_configs = spec->bios_pin_configs;
4192 } else {
4193 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4194 stac92xx_set_config_regs(codec);
4195 }
4196
4197 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4198 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4199
4200 if (spec->multiout.num_dacs < 0) {
4201 printk(KERN_WARNING "hda_codec: Could not determine "
4202 "number of channels defaulting to DAC count\n");
4203 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4204 }
4205
4206 switch (spec->multiout.num_dacs) {
4207 case 0x3: /* 6 Channel */
4208 spec->mixer = stac92hd73xx_6ch_mixer;
4209 spec->init = stac92hd73xx_6ch_core_init;
4210 break;
4211 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004212 spec->mixer = stac92hd73xx_8ch_mixer;
4213 spec->init = stac92hd73xx_8ch_core_init;
4214 break;
4215 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004216 spec->mixer = stac92hd73xx_10ch_mixer;
4217 spec->init = stac92hd73xx_10ch_core_init;
4218 };
4219
4220 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4221 spec->aloopback_mask = 0x01;
4222 spec->aloopback_shift = 8;
4223
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004224 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004225 spec->mux_nids = stac92hd73xx_mux_nids;
4226 spec->adc_nids = stac92hd73xx_adc_nids;
4227 spec->dmic_nids = stac92hd73xx_dmic_nids;
4228 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004229 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004230 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004231 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004232
4233 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4234 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai16970552007-12-18 18:05:52 +01004235 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004236 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4237 sizeof(stac92hd73xx_dmux));
4238
Matthew Ranostaya7662642008-02-21 07:51:14 +01004239 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004240 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004241 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004242 /* fallthru */
4243 case STAC_DELL_M6:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004244 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004245 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4246 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004247 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004248 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004249
4250 if (!spec->init)
4251 spec->init = dell_m6_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004252 switch (codec->subsystem_id) {
4253 case 0x1028025e: /* Analog Mics */
4254 case 0x1028025f:
4255 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4256 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004257 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004258 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004259 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004260 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004261 case 0x10280254:
4262 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004263 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4264 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004265 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004266 break;
4267 case 0x10280256: /* Both */
4268 case 0x10280057:
4269 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4270 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4271 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004272 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004273 break;
4274 }
4275 break;
4276 default:
4277 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004278 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004279 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004280 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004281 if (spec->board_config > STAC_92HD73XX_REF) {
4282 /* GPIO0 High = Enable EAPD */
4283 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4284 spec->gpio_data = 0x01;
4285 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004286 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004287
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004288 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4289 spec->pwr_nids = stac92hd73xx_pwr_nids;
4290
Matthew Ranostayd9737752008-09-07 12:03:41 +02004291 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004292
4293 if (!err) {
4294 if (spec->board_config < 0) {
4295 printk(KERN_WARNING "hda_codec: No auto-config is "
4296 "available, default to model=ref\n");
4297 spec->board_config = STAC_92HD73XX_REF;
4298 goto again;
4299 }
4300 err = -EINVAL;
4301 }
4302
4303 if (err < 0) {
4304 stac92xx_free(codec);
4305 return err;
4306 }
4307
4308 codec->patch_ops = stac92xx_patch_ops;
4309
4310 return 0;
4311}
4312
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004313static struct hda_input_mux stac92hd83xxx_dmux = {
4314 .num_items = 3,
4315 .items = {
4316 { "Analog Inputs", 0x03 },
4317 { "Digital Mic 1", 0x04 },
4318 { "Digital Mic 2", 0x05 },
4319 }
4320};
4321
4322static int patch_stac92hd83xxx(struct hda_codec *codec)
4323{
4324 struct sigmatel_spec *spec;
4325 int err;
4326
4327 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4328 if (spec == NULL)
4329 return -ENOMEM;
4330
4331 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004332 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004333 spec->mono_nid = 0x19;
4334 spec->digbeep_nid = 0x21;
4335 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4336 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4337 spec->adc_nids = stac92hd83xxx_adc_nids;
4338 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4339 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4340 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4341 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4342
4343 spec->init = stac92hd83xxx_core_init;
4344 switch (codec->vendor_id) {
4345 case 0x111d7605:
4346 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4347 break;
4348 default:
4349 spec->num_pwrs--;
4350 spec->init++; /* switch to config #2 */
4351 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4352 }
4353
4354 spec->mixer = stac92hd83xxx_mixer;
4355 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4356 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4357 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4358 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4359 spec->dinput_mux = &stac92hd83xxx_dmux;
4360 spec->pin_nids = stac92hd83xxx_pin_nids;
4361 spec->board_config = snd_hda_check_board_config(codec,
4362 STAC_92HD83XXX_MODELS,
4363 stac92hd83xxx_models,
4364 stac92hd83xxx_cfg_tbl);
4365again:
4366 if (spec->board_config < 0) {
4367 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4368 " STAC92HD83XXX, using BIOS defaults\n");
4369 err = stac92xx_save_bios_config_regs(codec);
4370 if (err < 0) {
4371 stac92xx_free(codec);
4372 return err;
4373 }
4374 spec->pin_configs = spec->bios_pin_configs;
4375 } else {
4376 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4377 stac92xx_set_config_regs(codec);
4378 }
4379
4380 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4381 if (!err) {
4382 if (spec->board_config < 0) {
4383 printk(KERN_WARNING "hda_codec: No auto-config is "
4384 "available, default to model=ref\n");
4385 spec->board_config = STAC_92HD83XXX_REF;
4386 goto again;
4387 }
4388 err = -EINVAL;
4389 }
4390
4391 if (err < 0) {
4392 stac92xx_free(codec);
4393 return err;
4394 }
4395
4396 codec->patch_ops = stac92xx_patch_ops;
4397
4398 return 0;
4399}
4400
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004401#ifdef SND_HDA_NEEDS_RESUME
4402static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4403{
4404 struct sigmatel_spec *spec = codec->spec;
4405 int i;
4406 snd_hda_codec_write_cache(codec, codec->afg, 0,
4407 AC_VERB_SET_POWER_STATE, pwr);
4408
4409 msleep(1);
4410 for (i = 0; i < spec->num_adcs; i++) {
4411 snd_hda_codec_write_cache(codec,
4412 spec->adc_nids[i], 0,
4413 AC_VERB_SET_POWER_STATE, pwr);
4414 }
4415};
4416
4417static int stac92hd71xx_resume(struct hda_codec *codec)
4418{
4419 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4420 return stac92xx_resume(codec);
4421}
4422
4423static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4424{
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004425 struct sigmatel_spec *spec = codec->spec;
4426
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004427 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004428 if (spec->eapd_mask)
4429 stac_gpio_set(codec, spec->gpio_mask,
4430 spec->gpio_dir, spec->gpio_data &
4431 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004432 return 0;
4433};
4434
4435#endif
4436
4437static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4438 .build_controls = stac92xx_build_controls,
4439 .build_pcms = stac92xx_build_pcms,
4440 .init = stac92xx_init,
4441 .free = stac92xx_free,
4442 .unsol_event = stac92xx_unsol_event,
4443#ifdef SND_HDA_NEEDS_RESUME
4444 .resume = stac92hd71xx_resume,
4445 .suspend = stac92hd71xx_suspend,
4446#endif
4447};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004448
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004449static struct hda_input_mux stac92hd71bxx_dmux = {
4450 .num_items = 4,
4451 .items = {
4452 { "Analog Inputs", 0x00 },
4453 { "Mixer", 0x01 },
4454 { "Digital Mic 1", 0x02 },
4455 { "Digital Mic 2", 0x03 },
4456 }
4457};
4458
Matthew Ranostaye035b842007-11-06 11:53:55 +01004459static int patch_stac92hd71bxx(struct hda_codec *codec)
4460{
4461 struct sigmatel_spec *spec;
4462 int err = 0;
4463
4464 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4465 if (spec == NULL)
4466 return -ENOMEM;
4467
4468 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004469 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004470 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004471 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004472 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004473 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4474 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004475 spec->board_config = snd_hda_check_board_config(codec,
4476 STAC_92HD71BXX_MODELS,
4477 stac92hd71bxx_models,
4478 stac92hd71bxx_cfg_tbl);
4479again:
4480 if (spec->board_config < 0) {
4481 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4482 " STAC92HD71BXX, using BIOS defaults\n");
4483 err = stac92xx_save_bios_config_regs(codec);
4484 if (err < 0) {
4485 stac92xx_free(codec);
4486 return err;
4487 }
4488 spec->pin_configs = spec->bios_pin_configs;
4489 } else {
4490 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4491 stac92xx_set_config_regs(codec);
4492 }
4493
Takashi Iwai41c3b642008-11-18 10:45:15 +01004494 if (spec->board_config > STAC_92HD71BXX_REF) {
4495 /* GPIO0 = EAPD */
4496 spec->gpio_mask = 0x01;
4497 spec->gpio_dir = 0x01;
4498 spec->gpio_data = 0x01;
4499 }
4500
Matthew Ranostay541eee82007-12-14 12:08:04 +01004501 switch (codec->vendor_id) {
4502 case 0x111d76b6: /* 4 Port without Analog Mixer */
4503 case 0x111d76b7:
4504 case 0x111d76b4: /* 6 Port without Analog Mixer */
4505 case 0x111d76b5:
4506 spec->mixer = stac92hd71bxx_mixer;
4507 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004508 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004509 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004510 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004511 switch (spec->board_config) {
4512 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004513 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004514 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004515 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4516 snd_hda_codec_write_cache(codec, codec->afg, 0,
4517 AC_VERB_SET_UNSOLICITED_ENABLE,
4518 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4519 spec->gpio_mask |= 0x02;
4520 break;
4521 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004522 if ((codec->revision_id & 0xf) == 0 ||
4523 (codec->revision_id & 0xf) == 1) {
4524#ifdef SND_HDA_NEEDS_RESUME
4525 codec->patch_ops = stac92hd71bxx_patch_ops;
4526#endif
4527 spec->stream_delay = 40; /* 40 milliseconds */
4528 }
4529
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004530 /* no output amps */
4531 spec->num_pwrs = 0;
4532 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004533 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004534
4535 /* disable VSW */
4536 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4537 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4538 break;
4539 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004540 if ((codec->revision_id & 0xf) == 1) {
4541#ifdef SND_HDA_NEEDS_RESUME
4542 codec->patch_ops = stac92hd71bxx_patch_ops;
4543#endif
4544 spec->stream_delay = 40; /* 40 milliseconds */
4545 }
4546
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004547 /* no output amps */
4548 spec->num_pwrs = 0;
4549 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004550 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004551 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004552 spec->mixer = stac92hd71bxx_analog_mixer;
4553 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004554 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004555 }
4556
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004557 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004558 spec->aloopback_shift = 0;
4559
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004560 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004561 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004562 spec->mux_nids = stac92hd71bxx_mux_nids;
4563 spec->adc_nids = stac92hd71bxx_adc_nids;
4564 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004565 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004566 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004567 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004568
4569 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4570 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004571
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004572 switch (spec->board_config) {
4573 case STAC_HP_M4:
4574 spec->num_dmics = 0;
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004575 spec->num_smuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004576 spec->num_dmuxes = 0;
4577
4578 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004579 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4580 stac92xx_auto_set_pinctl(codec, 0x0e,
4581 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004582 break;
4583 default:
4584 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4585 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4586 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4587 };
4588
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004589 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004590 spec->multiout.hp_nid = 0x11;
4591 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004592 if (spec->dinput_mux)
4593 spec->private_dimux.num_items +=
4594 spec->num_dmics -
4595 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004596
4597 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4598 if (!err) {
4599 if (spec->board_config < 0) {
4600 printk(KERN_WARNING "hda_codec: No auto-config is "
4601 "available, default to model=ref\n");
4602 spec->board_config = STAC_92HD71BXX_REF;
4603 goto again;
4604 }
4605 err = -EINVAL;
4606 }
4607
4608 if (err < 0) {
4609 stac92xx_free(codec);
4610 return err;
4611 }
4612
Matthew Ranostaye035b842007-11-06 11:53:55 +01004613 return 0;
4614};
4615
Matt2f2f4252005-04-13 14:45:30 +02004616static int patch_stac922x(struct hda_codec *codec)
4617{
4618 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004619 int err;
Matt2f2f4252005-04-13 14:45:30 +02004620
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004621 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004622 if (spec == NULL)
4623 return -ENOMEM;
4624
4625 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004626 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004627 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004628 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4629 stac922x_models,
4630 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004631 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004632 spec->gpio_mask = spec->gpio_dir = 0x03;
4633 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004634 /* Intel Macs have all same PCI SSID, so we need to check
4635 * codec SSID to distinguish the exact models
4636 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004637 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004638 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004639
4640 case 0x106b0800:
4641 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004642 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004643 case 0x106b0600:
4644 case 0x106b0700:
4645 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004646 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004647 case 0x106b0e00:
4648 case 0x106b0f00:
4649 case 0x106b1600:
4650 case 0x106b1700:
4651 case 0x106b0200:
4652 case 0x106b1e00:
4653 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004654 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004655 case 0x106b1a00:
4656 case 0x00000100:
4657 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004658 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004659 case 0x106b0a00:
4660 case 0x106b2200:
4661 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004662 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004663 default:
4664 spec->board_config = STAC_INTEL_MAC_V3;
4665 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004666 }
4667 }
4668
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004669 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004670 if (spec->board_config < 0) {
4671 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4672 "using BIOS defaults\n");
4673 err = stac92xx_save_bios_config_regs(codec);
4674 if (err < 0) {
4675 stac92xx_free(codec);
4676 return err;
4677 }
4678 spec->pin_configs = spec->bios_pin_configs;
4679 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004680 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4681 stac92xx_set_config_regs(codec);
4682 }
Matt2f2f4252005-04-13 14:45:30 +02004683
Matt2f2f4252005-04-13 14:45:30 +02004684 spec->adc_nids = stac922x_adc_nids;
4685 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004686 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004687 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004688 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004689 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004690
4691 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004692 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004693
4694 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004695
Matt Porter3cc08dc2006-01-23 15:27:49 +01004696 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004697 if (!err) {
4698 if (spec->board_config < 0) {
4699 printk(KERN_WARNING "hda_codec: No auto-config is "
4700 "available, default to model=ref\n");
4701 spec->board_config = STAC_D945_REF;
4702 goto again;
4703 }
4704 err = -EINVAL;
4705 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004706 if (err < 0) {
4707 stac92xx_free(codec);
4708 return err;
4709 }
4710
4711 codec->patch_ops = stac92xx_patch_ops;
4712
Takashi Iwai807a46362007-05-29 19:01:37 +02004713 /* Fix Mux capture level; max to 2 */
4714 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4715 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4716 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4717 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4718 (0 << AC_AMPCAP_MUTE_SHIFT));
4719
Matt Porter3cc08dc2006-01-23 15:27:49 +01004720 return 0;
4721}
4722
4723static int patch_stac927x(struct hda_codec *codec)
4724{
4725 struct sigmatel_spec *spec;
4726 int err;
4727
4728 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4729 if (spec == NULL)
4730 return -ENOMEM;
4731
4732 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004733 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004734 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004735 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4736 stac927x_models,
4737 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004738 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004739 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4740 if (spec->board_config < 0)
4741 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4742 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004743 err = stac92xx_save_bios_config_regs(codec);
4744 if (err < 0) {
4745 stac92xx_free(codec);
4746 return err;
4747 }
4748 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004749 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004750 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4751 stac92xx_set_config_regs(codec);
4752 }
4753
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004754 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004755 spec->adc_nids = stac927x_adc_nids;
4756 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4757 spec->mux_nids = stac927x_mux_nids;
4758 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004759 spec->smux_nids = stac927x_smux_nids;
4760 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004761 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004762 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004763 spec->multiout.dac_nids = spec->dac_nids;
4764
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004765 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004766 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004767 case STAC_D965_5ST:
4768 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004769 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004770 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004771 spec->num_dmics = 0;
4772
Tobin Davis93ed1502006-09-01 21:03:12 +02004773 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004774 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004775 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004776 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004777 switch (codec->subsystem_id) {
4778 case 0x10280209:
4779 case 0x1028022e:
4780 /* correct the device field to SPDIF out */
4781 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4782 break;
4783 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004784 /* configure the analog microphone on some laptops */
4785 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004786 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004787 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004788 /* correct the front input jack as a mic */
4789 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4790 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004791 case STAC_DELL_3ST:
4792 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004793 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004794 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004795 spec->dmic_nids = stac927x_dmic_nids;
4796 spec->num_dmics = STAC927X_NUM_DMICS;
4797
Tobin Davis93ed1502006-09-01 21:03:12 +02004798 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004799 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004800 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004801 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004802 break;
4803 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004804 if (spec->board_config > STAC_D965_REF) {
4805 /* GPIO0 High = Enable EAPD */
4806 spec->eapd_mask = spec->gpio_mask = 0x01;
4807 spec->gpio_dir = spec->gpio_data = 0x01;
4808 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004809 spec->num_dmics = 0;
4810
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004811 spec->init = stac927x_core_init;
4812 spec->mixer = stac927x_mixer;
4813 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004814
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004815 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004816 spec->aloopback_mask = 0x40;
4817 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004818 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004819
Matt Porter3cc08dc2006-01-23 15:27:49 +01004820 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004821 if (!err) {
4822 if (spec->board_config < 0) {
4823 printk(KERN_WARNING "hda_codec: No auto-config is "
4824 "available, default to model=ref\n");
4825 spec->board_config = STAC_D965_REF;
4826 goto again;
4827 }
4828 err = -EINVAL;
4829 }
Mattc7d4b2f2005-06-27 14:59:41 +02004830 if (err < 0) {
4831 stac92xx_free(codec);
4832 return err;
4833 }
Matt2f2f4252005-04-13 14:45:30 +02004834
4835 codec->patch_ops = stac92xx_patch_ops;
4836
Takashi Iwai52987652008-01-16 16:09:47 +01004837 /*
4838 * !!FIXME!!
4839 * The STAC927x seem to require fairly long delays for certain
4840 * command sequences. With too short delays (even if the answer
4841 * is set to RIRB properly), it results in the silence output
4842 * on some hardwares like Dell.
4843 *
4844 * The below flag enables the longer delay (see get_response
4845 * in hda_intel.c).
4846 */
4847 codec->bus->needs_damn_long_delay = 1;
4848
Matt2f2f4252005-04-13 14:45:30 +02004849 return 0;
4850}
4851
Matt Porterf3302a592006-07-31 12:49:34 +02004852static int patch_stac9205(struct hda_codec *codec)
4853{
4854 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004855 int err;
Matt Porterf3302a592006-07-31 12:49:34 +02004856
4857 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4858 if (spec == NULL)
4859 return -ENOMEM;
4860
4861 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004862 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004863 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004864 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4865 stac9205_models,
4866 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004867 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004868 if (spec->board_config < 0) {
4869 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4870 err = stac92xx_save_bios_config_regs(codec);
4871 if (err < 0) {
4872 stac92xx_free(codec);
4873 return err;
4874 }
4875 spec->pin_configs = spec->bios_pin_configs;
4876 } else {
Matt Porterf3302a592006-07-31 12:49:34 +02004877 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4878 stac92xx_set_config_regs(codec);
4879 }
4880
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004881 spec->digbeep_nid = 0x23;
Matt Porterf3302a592006-07-31 12:49:34 +02004882 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004883 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a592006-07-31 12:49:34 +02004884 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004885 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004886 spec->smux_nids = stac9205_smux_nids;
4887 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004888 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004889 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004890 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004891 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004892 spec->num_pwrs = 0;
Matt Porterf3302a592006-07-31 12:49:34 +02004893
4894 spec->init = stac9205_core_init;
4895 spec->mixer = stac9205_mixer;
4896
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004897 spec->aloopback_mask = 0x40;
4898 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004899 spec->eapd_switch = 1;
Matt Porterf3302a592006-07-31 12:49:34 +02004900 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004901
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004902 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004903 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004904 /* Enable SPDIF in/out */
4905 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4906 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004907
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004908 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004909 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004910 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4911 snd_hda_codec_write_cache(codec, codec->afg, 0,
4912 AC_VERB_SET_UNSOLICITED_ENABLE,
4913 (AC_USRSP_EN | STAC_HP_EVENT));
4914
4915 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004916 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004917 spec->gpio_mask = 0x1b;
4918 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004919 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004920 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004921 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004922 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004923 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004924 case STAC_9205_REF:
4925 /* SPDIF-In enabled */
4926 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004927 default:
4928 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004929 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004930 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004931 break;
4932 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004933
Matt Porterf3302a592006-07-31 12:49:34 +02004934 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004935 if (!err) {
4936 if (spec->board_config < 0) {
4937 printk(KERN_WARNING "hda_codec: No auto-config is "
4938 "available, default to model=ref\n");
4939 spec->board_config = STAC_9205_REF;
4940 goto again;
4941 }
4942 err = -EINVAL;
4943 }
Matt Porterf3302a592006-07-31 12:49:34 +02004944 if (err < 0) {
4945 stac92xx_free(codec);
4946 return err;
4947 }
4948
4949 codec->patch_ops = stac92xx_patch_ops;
4950
4951 return 0;
4952}
4953
Matt2f2f4252005-04-13 14:45:30 +02004954/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004955 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004956 */
4957
Guillaume Munch99ccc562006-08-16 19:35:12 +02004958/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004959static hda_nid_t vaio_dacs[] = { 0x2 };
4960#define VAIO_HP_DAC 0x5
4961static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4962static hda_nid_t vaio_mux_nids[] = { 0x15 };
4963
4964static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004965 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004966 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004967 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004968 { "Mic Jack", 0x1 },
4969 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004970 { "PCM", 0x3 },
4971 }
4972};
4973
4974static struct hda_verb vaio_init[] = {
4975 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004976 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004977 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4978 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4979 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004982 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4983 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4984 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4986 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4987 {}
4988};
4989
Guillaume Munch6d859062006-08-22 17:15:47 +02004990static struct hda_verb vaio_ar_init[] = {
4991 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4992 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4993 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4994 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4995/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4996 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004998 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4999 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5000/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5001 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5004 {}
5005};
5006
Takashi Iwaidb064e52006-03-16 16:04:58 +01005007/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005008static struct hda_bind_ctls vaio_bind_master_vol = {
5009 .ops = &snd_hda_bind_vol,
5010 .values = {
5011 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5012 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5013 0
5014 },
5015};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005016
5017/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005018static struct hda_bind_ctls vaio_bind_master_sw = {
5019 .ops = &snd_hda_bind_sw,
5020 .values = {
5021 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5022 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5023 0,
5024 },
5025};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005026
5027static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005028 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5029 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005030 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5031 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5032 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5033 {
5034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5035 .name = "Capture Source",
5036 .count = 1,
5037 .info = stac92xx_mux_enum_info,
5038 .get = stac92xx_mux_enum_get,
5039 .put = stac92xx_mux_enum_put,
5040 },
5041 {}
5042};
5043
Guillaume Munch6d859062006-08-22 17:15:47 +02005044static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005045 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5046 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02005047 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5048 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5049 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5050 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5051 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5052 {
5053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5054 .name = "Capture Source",
5055 .count = 1,
5056 .info = stac92xx_mux_enum_info,
5057 .get = stac92xx_mux_enum_get,
5058 .put = stac92xx_mux_enum_put,
5059 },
5060 {}
5061};
5062
5063static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005064 .build_controls = stac92xx_build_controls,
5065 .build_pcms = stac92xx_build_pcms,
5066 .init = stac92xx_init,
5067 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005068#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005069 .resume = stac92xx_resume,
5070#endif
5071};
5072
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005073static int stac9872_vaio_init(struct hda_codec *codec)
5074{
5075 int err;
5076
5077 err = stac92xx_init(codec);
5078 if (err < 0)
5079 return err;
5080 if (codec->patch_ops.unsol_event)
5081 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5082 return 0;
5083}
5084
5085static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5086{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005087 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005088 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5089 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5090 } else {
5091 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5092 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5093 }
5094}
5095
5096static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5097{
5098 switch (res >> 26) {
5099 case STAC_HP_EVENT:
5100 stac9872_vaio_hp_detect(codec, res);
5101 break;
5102 }
5103}
5104
5105static struct hda_codec_ops stac9872_vaio_patch_ops = {
5106 .build_controls = stac92xx_build_controls,
5107 .build_pcms = stac92xx_build_pcms,
5108 .init = stac9872_vaio_init,
5109 .free = stac92xx_free,
5110 .unsol_event = stac9872_vaio_unsol_event,
5111#ifdef CONFIG_PM
5112 .resume = stac92xx_resume,
5113#endif
5114};
5115
Guillaume Munch6d859062006-08-22 17:15:47 +02005116enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5117 CXD9872RD_VAIO,
5118 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5119 STAC9872AK_VAIO,
5120 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5121 STAC9872K_VAIO,
5122 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005123 CXD9872AKD_VAIO,
5124 STAC_9872_MODELS,
5125};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005126
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005127static const char *stac9872_models[STAC_9872_MODELS] = {
5128 [CXD9872RD_VAIO] = "vaio",
5129 [CXD9872AKD_VAIO] = "vaio-ar",
5130};
5131
5132static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5133 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5134 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5135 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005136 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005137 {}
5138};
5139
Guillaume Munch6d859062006-08-22 17:15:47 +02005140static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005141{
5142 struct sigmatel_spec *spec;
5143 int board_config;
5144
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005145 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5146 stac9872_models,
5147 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005148 if (board_config < 0)
5149 /* unknown config, let generic-parser do its job... */
5150 return snd_hda_parse_generic_codec(codec);
5151
5152 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5153 if (spec == NULL)
5154 return -ENOMEM;
5155
5156 codec->spec = spec;
5157 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005158 case CXD9872RD_VAIO:
5159 case STAC9872AK_VAIO:
5160 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005161 spec->mixer = vaio_mixer;
5162 spec->init = vaio_init;
5163 spec->multiout.max_channels = 2;
5164 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5165 spec->multiout.dac_nids = vaio_dacs;
5166 spec->multiout.hp_nid = VAIO_HP_DAC;
5167 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5168 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005169 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005170 spec->input_mux = &vaio_mux;
5171 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005172 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005173 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005174
5175 case CXD9872AKD_VAIO:
5176 spec->mixer = vaio_ar_mixer;
5177 spec->init = vaio_ar_init;
5178 spec->multiout.max_channels = 2;
5179 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5180 spec->multiout.dac_nids = vaio_dacs;
5181 spec->multiout.hp_nid = VAIO_HP_DAC;
5182 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005183 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005184 spec->adc_nids = vaio_adcs;
5185 spec->input_mux = &vaio_mux;
5186 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005187 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005188 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005189 }
5190
Takashi Iwaidb064e52006-03-16 16:04:58 +01005191 return 0;
5192}
5193
5194
5195/*
Matt2f2f4252005-04-13 14:45:30 +02005196 * patch entries
5197 */
5198struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5199 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5200 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5201 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5202 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5203 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5204 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5205 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005206 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5207 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5208 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5209 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5210 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5211 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005212 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5213 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5214 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5215 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5216 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5217 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5218 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5219 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5220 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5221 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005222 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5223 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5224 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5225 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5226 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5227 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005228 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5229 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005230 /* The following does not take into account .id=0x83847661 when subsys =
5231 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5232 * currently not fully supported.
5233 */
5234 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5235 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5236 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a592006-07-31 12:49:34 +02005237 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5238 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5239 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5240 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5241 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5242 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5243 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5244 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005245 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005246 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5247 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005248 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005249 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5250 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005251 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005252 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5253 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5254 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5255 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5256 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5257 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5258 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5259 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005260 {} /* terminator */
5261};