blob: 5dd3e89f620a2753511097d1fe86b4e6673afefa [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,
Takashi Iwai661cd8f2008-11-25 15:18:29 +010073 STAC_DELL_M6_AMIC,
74 STAC_DELL_M6_DMIC,
75 STAC_DELL_M6_BOTH,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -050076 STAC_DELL_EQ,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010077 STAC_92HD73XX_MODELS
78};
79
80enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020081 STAC_92HD83XXX_REF,
82 STAC_92HD83XXX_MODELS
83};
84
85enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010086 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010087 STAC_DELL_M4_1,
88 STAC_DELL_M4_2,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -050089 STAC_DELL_M4_3,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040090 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010091 STAC_92HD71BXX_MODELS
92};
93
94enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010095 STAC_925x_REF,
96 STAC_M2_2,
97 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020098 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010099 STAC_925x_MODELS
100};
101
102enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100103 STAC_D945_REF,
104 STAC_D945GTP3,
105 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200106 STAC_INTEL_MAC_V1,
107 STAC_INTEL_MAC_V2,
108 STAC_INTEL_MAC_V3,
109 STAC_INTEL_MAC_V4,
110 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800111 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
112 * is given, one of the above models will be
113 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200114 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100115 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100116 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100117 STAC_MACBOOK_PRO_V1,
118 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200119 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200120 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300121 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200122 STAC_922X_DELL_D81,
123 STAC_922X_DELL_D82,
124 STAC_922X_DELL_M81,
125 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100126 STAC_922X_MODELS
127};
128
129enum {
130 STAC_D965_REF,
131 STAC_D965_3ST,
132 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200133 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100134 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100135 STAC_927X_MODELS
136};
Matt Porter403d1942005-11-29 15:00:51 +0100137
Matt2f2f4252005-04-13 14:45:30 +0200138struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100139 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200140 unsigned int num_mixers;
141
Matt Porter403d1942005-11-29 15:00:51 +0100142 int board_config;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -0500143 unsigned int eapd_switch: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200144 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100145 unsigned int line_switch: 1;
146 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100147 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100148 unsigned int hp_detect: 1;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400149 unsigned int spdif_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200150
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100151 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200152 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100153 unsigned int gpio_mask;
154 unsigned int gpio_dir;
155 unsigned int gpio_data;
156 unsigned int gpio_mute;
157
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200158 /* stream */
159 unsigned int stream_delay;
160
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100161 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100162 unsigned char aloopback_mask;
163 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200164
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100165 /* power management */
166 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200167 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100168 hda_nid_t *pwr_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100169 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100170
Matt2f2f4252005-04-13 14:45:30 +0200171 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100172 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400173 struct hda_input_mux *amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100174 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200175 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100176 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200177
178 /* capture */
179 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200180 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200181 hda_nid_t *mux_nids;
182 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200183 hda_nid_t *dmic_nids;
184 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100185 hda_nid_t *dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +0100186 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200187 hda_nid_t *smux_nids;
188 unsigned int num_smuxes;
Matthew Ranostay65973632008-09-16 10:39:37 -0400189 const char **spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200190
Mattdabbed62005-06-14 10:19:34 +0200191 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100192 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200193 hda_nid_t anabeep_nid;
194 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200195
Matt2f2f4252005-04-13 14:45:30 +0200196 /* pin widgets */
197 hda_nid_t *pin_nids;
198 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200199 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200200 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200201
202 /* codec specific stuff */
203 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100204 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200205
206 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200207 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100208 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200209 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100210 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200211 struct hda_input_mux *sinput_mux;
212 unsigned int cur_smux[2];
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400213 unsigned int cur_amux;
214 hda_nid_t *amp_nids;
215 unsigned int num_amps;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200216 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200217
Matt Porter403d1942005-11-29 15:00:51 +0100218 /* i/o switches */
219 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200220 unsigned int clfe_swap;
Takashi Iwaid7a89432008-11-12 09:48:04 +0100221 unsigned int hp_switch; /* NID of HP as line-out */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200222 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200223
Mattc7d4b2f2005-06-27 14:59:41 +0200224 struct hda_pcm pcm_rec[2]; /* PCM information */
225
226 /* dynamic controls and input_mux */
227 struct auto_pin_cfg autocfg;
228 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100229 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200230 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200231 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200232 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400233 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100234 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200235};
236
237static hda_nid_t stac9200_adc_nids[1] = {
238 0x03,
239};
240
241static hda_nid_t stac9200_mux_nids[1] = {
242 0x0c,
243};
244
245static hda_nid_t stac9200_dac_nids[1] = {
246 0x02,
247};
248
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100249static hda_nid_t stac92hd73xx_pwr_nids[8] = {
250 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
251 0x0f, 0x10, 0x11
252};
253
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400254static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
255 0x26, 0,
256};
257
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100258static hda_nid_t stac92hd73xx_adc_nids[2] = {
259 0x1a, 0x1b
260};
261
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400262#define DELL_M6_AMP 2
263static hda_nid_t stac92hd73xx_amp_nids[3] = {
264 0x0b, 0x0c, 0x0e
Matthew Ranostay89385032008-09-11 09:49:39 -0400265};
266
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100267#define STAC92HD73XX_NUM_DMICS 2
268static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
269 0x13, 0x14, 0
270};
271
272#define STAC92HD73_DAC_COUNT 5
273static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
274 0x15, 0x16, 0x17, 0x18, 0x19,
275};
276
277static hda_nid_t stac92hd73xx_mux_nids[4] = {
278 0x28, 0x29, 0x2a, 0x2b,
279};
280
281static hda_nid_t stac92hd73xx_dmux_nids[2] = {
282 0x20, 0x21,
283};
284
Matthew Ranostayd9737752008-09-07 12:03:41 +0200285static hda_nid_t stac92hd73xx_smux_nids[2] = {
286 0x22, 0x23,
287};
288
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200289#define STAC92HD83XXX_NUM_DMICS 2
290static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
291 0x11, 0x12, 0
292};
293
294#define STAC92HD81_DAC_COUNT 2
295#define STAC92HD83_DAC_COUNT 3
296static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
297 0x13, 0x14, 0x22,
298};
299
300static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
301 0x17, 0x18,
302};
303
304static hda_nid_t stac92hd83xxx_adc_nids[2] = {
305 0x15, 0x16,
306};
307
308static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
309 0xa, 0xb, 0xd, 0xe,
310};
311
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400312static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
313 0x1e, 0,
314};
315
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200316static unsigned int stac92hd83xxx_pwr_mapping[4] = {
317 0x03, 0x0c, 0x10, 0x40,
318};
319
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100320static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
321 0x0a, 0x0d, 0x0f
322};
323
Matthew Ranostaye035b842007-11-06 11:53:55 +0100324static hda_nid_t stac92hd71bxx_adc_nids[2] = {
325 0x12, 0x13,
326};
327
328static hda_nid_t stac92hd71bxx_mux_nids[2] = {
329 0x1a, 0x1b
330};
331
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400332static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
333 0x1c, 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100334};
335
Matthew Ranostayd9737752008-09-07 12:03:41 +0200336static hda_nid_t stac92hd71bxx_smux_nids[2] = {
337 0x24, 0x25,
338};
339
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100340static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100341 0x10, /*0x11, */
342};
343
344#define STAC92HD71BXX_NUM_DMICS 2
345static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
346 0x18, 0x19, 0
347};
348
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400349static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
350 0x22, 0
351};
352
Tobin Davis8e21c342007-01-08 11:04:17 +0100353static hda_nid_t stac925x_adc_nids[1] = {
354 0x03,
355};
356
357static hda_nid_t stac925x_mux_nids[1] = {
358 0x0f,
359};
360
361static hda_nid_t stac925x_dac_nids[1] = {
362 0x02,
363};
364
Takashi Iwaif6e98522007-10-16 14:27:04 +0200365#define STAC925X_NUM_DMICS 1
366static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
367 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200368};
369
Takashi Iwai1697055e2007-12-18 18:05:52 +0100370static hda_nid_t stac925x_dmux_nids[1] = {
371 0x14,
372};
373
Matt2f2f4252005-04-13 14:45:30 +0200374static hda_nid_t stac922x_adc_nids[2] = {
375 0x06, 0x07,
376};
377
378static hda_nid_t stac922x_mux_nids[2] = {
379 0x12, 0x13,
380};
381
Matt Porter3cc08dc2006-01-23 15:27:49 +0100382static hda_nid_t stac927x_adc_nids[3] = {
383 0x07, 0x08, 0x09
384};
385
386static hda_nid_t stac927x_mux_nids[3] = {
387 0x15, 0x16, 0x17
388};
389
Matthew Ranostayd9737752008-09-07 12:03:41 +0200390static hda_nid_t stac927x_smux_nids[1] = {
391 0x21,
392};
393
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100394static hda_nid_t stac927x_dac_nids[6] = {
395 0x02, 0x03, 0x04, 0x05, 0x06, 0
396};
397
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100398static hda_nid_t stac927x_dmux_nids[1] = {
399 0x1b,
400};
401
Matthew Ranostay7f168592007-10-18 17:38:17 +0200402#define STAC927X_NUM_DMICS 2
403static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
404 0x13, 0x14, 0
405};
406
Matthew Ranostay65973632008-09-16 10:39:37 -0400407static const char *stac927x_spdif_labels[5] = {
408 "Digital Playback", "ADAT", "Analog Mux 1",
409 "Analog Mux 2", "Analog Mux 3"
410};
411
Matt Porterf3302a52006-07-31 12:49:34 +0200412static hda_nid_t stac9205_adc_nids[2] = {
413 0x12, 0x13
414};
415
416static hda_nid_t stac9205_mux_nids[2] = {
417 0x19, 0x1a
418};
419
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100420static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai1697055e2007-12-18 18:05:52 +0100421 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100422};
423
Matthew Ranostayd9737752008-09-07 12:03:41 +0200424static hda_nid_t stac9205_smux_nids[1] = {
425 0x21,
426};
427
Takashi Iwaif6e98522007-10-16 14:27:04 +0200428#define STAC9205_NUM_DMICS 2
429static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
430 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200431};
432
Mattc7d4b2f2005-06-27 14:59:41 +0200433static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200434 0x08, 0x09, 0x0d, 0x0e,
435 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200436};
437
Tobin Davis8e21c342007-01-08 11:04:17 +0100438static hda_nid_t stac925x_pin_nids[8] = {
439 0x07, 0x08, 0x0a, 0x0b,
440 0x0c, 0x0d, 0x10, 0x11,
441};
442
Matt2f2f4252005-04-13 14:45:30 +0200443static hda_nid_t stac922x_pin_nids[10] = {
444 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
445 0x0f, 0x10, 0x11, 0x15, 0x1b,
446};
447
Matthew Ranostaya7662642008-02-21 07:51:14 +0100448static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100449 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
450 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200451 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100452};
453
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200454static hda_nid_t stac92hd83xxx_pin_nids[14] = {
455 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
456 0x0f, 0x10, 0x11, 0x12, 0x13,
457 0x1d, 0x1e, 0x1f, 0x20
458};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400459static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100460 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
461 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400462 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100463};
464
Matt Porter3cc08dc2006-01-23 15:27:49 +0100465static hda_nid_t stac927x_pin_nids[14] = {
466 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
467 0x0f, 0x10, 0x11, 0x12, 0x13,
468 0x14, 0x21, 0x22, 0x23,
469};
470
Matt Porterf3302a52006-07-31 12:49:34 +0200471static hda_nid_t stac9205_pin_nids[12] = {
472 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
473 0x0f, 0x14, 0x16, 0x17, 0x18,
474 0x21, 0x22,
Matt Porterf3302a52006-07-31 12:49:34 +0200475};
476
Matthew Ranostay89385032008-09-11 09:49:39 -0400477#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
478
479static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
481{
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 struct sigmatel_spec *spec = codec->spec;
484 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
485
486 kcontrol->private_value ^= get_amp_nid(kcontrol);
487 kcontrol->private_value |= nid;
488
489 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
490}
491
492static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
493 struct snd_ctl_elem_value *ucontrol)
494{
495 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
496 struct sigmatel_spec *spec = codec->spec;
497 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
498
499 kcontrol->private_value ^= get_amp_nid(kcontrol);
500 kcontrol->private_value |= nid;
501
502 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
503}
504
Matt Porter8b657272006-10-26 17:12:59 +0200505static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_info *uinfo)
507{
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct sigmatel_spec *spec = codec->spec;
510 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
511}
512
513static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
514 struct snd_ctl_elem_value *ucontrol)
515{
516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
517 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100518 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200519
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100520 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200521 return 0;
522}
523
524static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100529 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200530
531 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100532 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200533}
534
Matthew Ranostayd9737752008-09-07 12:03:41 +0200535static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_info *uinfo)
537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
540 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
541}
542
543static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_value *ucontrol)
545{
546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
547 struct sigmatel_spec *spec = codec->spec;
548 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
549
550 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
551 return 0;
552}
553
554static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
555 struct snd_ctl_elem_value *ucontrol)
556{
557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
558 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400559 struct hda_input_mux *smux = &spec->private_smux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200560 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400561 int err, val;
562 hda_nid_t nid;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200563
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400564 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200565 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400566 if (err < 0)
567 return err;
568
569 if (spec->spdif_mute) {
570 if (smux_idx == 0)
571 nid = spec->multiout.dig_out_nid;
572 else
573 nid = codec->slave_dig_outs[smux_idx - 1];
574 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
575 val = AMP_OUT_MUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400576 else
Takashi Iwaic1e99bd2008-10-29 08:03:42 +0100577 val = AMP_OUT_UNMUTE;
Matthew Ranostay00ef50c2008-09-27 18:13:47 -0400578 /* un/mute SPDIF out */
579 snd_hda_codec_write_cache(codec, nid, 0,
580 AC_VERB_SET_AMP_GAIN_MUTE, val);
581 }
582 return 0;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200583}
584
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100585static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200586{
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200589 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200590}
591
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100592static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200593{
594 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
595 struct sigmatel_spec *spec = codec->spec;
596 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
597
598 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
599 return 0;
600}
601
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100602static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200603{
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 struct sigmatel_spec *spec = codec->spec;
606 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
607
Mattc7d4b2f2005-06-27 14:59:41 +0200608 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200609 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
610}
611
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100612static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_info *uinfo)
614{
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 struct sigmatel_spec *spec = codec->spec;
617 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
618}
619
620static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
621 struct snd_ctl_elem_value *ucontrol)
622{
623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
624 struct sigmatel_spec *spec = codec->spec;
625
626 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
627 return 0;
628}
629
630static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 struct sigmatel_spec *spec = codec->spec;
635
636 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
637 spec->mono_nid, &spec->cur_mmux);
638}
639
Matthew Ranostay89385032008-09-11 09:49:39 -0400640static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_info *uinfo)
642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
646}
647
648static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
649 struct snd_ctl_elem_value *ucontrol)
650{
651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
652 struct sigmatel_spec *spec = codec->spec;
653
654 ucontrol->value.enumerated.item[0] = spec->cur_amux;
655 return 0;
656}
657
658static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
660{
661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
662 struct sigmatel_spec *spec = codec->spec;
663 struct snd_kcontrol *ctl =
664 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
665 if (!ctl)
666 return -EINVAL;
667
668 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
669 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
670
671 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
672 0, &spec->cur_amux);
673}
674
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200675#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
676
677static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
678 struct snd_ctl_elem_value *ucontrol)
679{
680 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100681 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200682 struct sigmatel_spec *spec = codec->spec;
683
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100684 ucontrol->value.integer.value[0] = !!(spec->aloopback &
685 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200686 return 0;
687}
688
689static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
691{
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100694 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200695 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100696 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200697
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100698 idx_val = spec->aloopback_mask << idx;
699 if (ucontrol->value.integer.value[0])
700 val = spec->aloopback | idx_val;
701 else
702 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100703 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200704 return 0;
705
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100706 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200707
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100708 /* Only return the bits defined by the shift value of the
709 * first two bytes of the mask
710 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200711 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100712 kcontrol->private_value & 0xFFFF, 0x0);
713 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200714
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100715 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200716 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100717 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200718 } else {
719 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100720 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200721 }
722
723 snd_hda_codec_write_cache(codec, codec->afg, 0,
724 kcontrol->private_value >> 16, dac_mode);
725
726 return 1;
727}
728
Mattc7d4b2f2005-06-27 14:59:41 +0200729static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200730 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200731 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200732 {}
733};
734
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200735static struct hda_verb stac9200_eapd_init[] = {
736 /* set dac0mux for dac converter */
737 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
738 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
739 {}
740};
741
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100742static struct hda_verb stac92hd73xx_6ch_core_init[] = {
743 /* set master volume and direct control */
744 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
745 /* setup audio connections */
746 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
747 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
748 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
749 /* setup adcs to point to mixer */
750 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
751 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100752 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
753 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
754 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
755 /* setup import muxs */
756 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
757 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
758 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
760 {}
761};
762
Matthew Ranostayd654a662008-03-14 08:46:51 +0100763static struct hda_verb dell_eq_core_init[] = {
764 /* set master volume to max value without distortion
765 * and direct control */
766 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
767 /* setup audio connections */
768 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400769 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
770 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100771 /* setup adcs to point to mixer */
772 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
773 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
774 /* setup import muxs */
775 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
776 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
777 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
779 {}
780};
781
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100782static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -0500783 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100784 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100785 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
786 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100787 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
788 /* setup adcs to point to mixer */
789 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
790 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 /* setup import muxs */
792 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
793 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
794 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
796 {}
797};
798
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100799static struct hda_verb stac92hd73xx_8ch_core_init[] = {
800 /* set master volume and direct control */
801 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
802 /* setup audio connections */
803 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
804 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
806 /* connect hp ports to dac3 */
807 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
808 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
809 /* setup adcs to point to mixer */
810 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
811 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100812 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
813 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
814 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
815 /* setup import muxs */
816 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
818 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
819 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
820 {}
821};
822
823static struct hda_verb stac92hd73xx_10ch_core_init[] = {
824 /* set master volume and direct control */
825 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
826 /* setup audio connections */
827 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
828 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
829 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
830 /* dac3 is connected to import3 mux */
831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
832 /* connect hp ports to dac4 */
833 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
834 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
835 /* setup adcs to point to mixer */
836 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
837 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100838 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
841 /* setup import muxs */
842 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
845 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
846 {}
847};
848
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200849static struct hda_verb stac92hd83xxx_core_init[] = {
850 /* start of config #1 */
851 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
852
853 /* start of config #2 */
854 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
855 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
856 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
857
858 /* power state controls amps */
859 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
860};
861
Matthew Ranostaye035b842007-11-06 11:53:55 +0100862static struct hda_verb stac92hd71bxx_core_init[] = {
863 /* set master volume and direct control */
864 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
865 /* connect headphone jack to dac1 */
866 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100867 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
868 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
869 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100871};
872
Matthew Ranostay4b33c762008-10-10 09:07:23 -0400873#define HD_DISABLE_PORTF 2
Matthew Ranostay541eee82007-12-14 12:08:04 +0100874static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200875 /* start of config #1 */
876
877 /* connect port 0f to audio mixer */
878 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200879 /* unmute right and left channels for node 0x0f */
880 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
881 /* start of config #2 */
882
Matthew Ranostay541eee82007-12-14 12:08:04 +0100883 /* set master volume and direct control */
884 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
885 /* connect headphone jack to dac1 */
886 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200887 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100888 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
889 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100890 {}
891};
892
Tobin Davis8e21c342007-01-08 11:04:17 +0100893static struct hda_verb stac925x_core_init[] = {
894 /* set dac0mux for dac converter */
895 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
896 {}
897};
898
Mattc7d4b2f2005-06-27 14:59:41 +0200899static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200900 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200901 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200902 {}
903};
904
Tobin Davis93ed1502006-09-01 21:03:12 +0200905static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200906 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200907 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200908 /* unmute node 0x1b */
909 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
910 /* select node 0x03 as DAC */
911 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
912 {}
913};
914
Matt Porter3cc08dc2006-01-23 15:27:49 +0100915static struct hda_verb stac927x_core_init[] = {
916 /* set master volume and direct control */
917 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200918 /* enable analog pc beep path */
919 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100920 {}
921};
922
Matt Porterf3302a52006-07-31 12:49:34 +0200923static struct hda_verb stac9205_core_init[] = {
924 /* set master volume and direct control */
925 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200926 /* enable analog pc beep path */
927 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a52006-07-31 12:49:34 +0200928 {}
929};
930
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100931#define STAC_MONO_MUX \
932 { \
933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
934 .name = "Mono Mux", \
935 .count = 1, \
936 .info = stac92xx_mono_mux_enum_info, \
937 .get = stac92xx_mono_mux_enum_get, \
938 .put = stac92xx_mono_mux_enum_put, \
939 }
940
Matthew Ranostay89385032008-09-11 09:49:39 -0400941#define STAC_AMP_MUX \
942 { \
943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
944 .name = "Amp Selector Capture Switch", \
945 .count = 1, \
946 .info = stac92xx_amp_mux_enum_info, \
947 .get = stac92xx_amp_mux_enum_get, \
948 .put = stac92xx_amp_mux_enum_put, \
949 }
950
951#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
952 { \
953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
954 .name = xname, \
955 .index = 0, \
956 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
957 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
958 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
959 .info = stac92xx_amp_volume_info, \
960 .get = stac92xx_amp_volume_get, \
961 .put = stac92xx_amp_volume_put, \
962 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
963 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
964 }
965
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200966#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200967 { \
968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
969 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200970 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200971 .info = stac92xx_mux_enum_info, \
972 .get = stac92xx_mux_enum_get, \
973 .put = stac92xx_mux_enum_put, \
974 }
975
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100976#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200977 { \
978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
979 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100980 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200981 .info = stac92xx_aloopback_info, \
982 .get = stac92xx_aloopback_get, \
983 .put = stac92xx_aloopback_put, \
984 .private_value = verb_read | (verb_write << 16), \
985 }
986
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100987static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200988 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200990 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200991 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200993 { } /* end */
994};
995
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400996#define DELL_M6_MIXER 6
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100997static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostay2a9c7812008-09-13 16:45:39 -0400998 /* start of config #1 */
999 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1000 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1001
1002 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1003 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1004
1005 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1006 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1007
1008 /* start of config #2 */
1009 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1010 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1011
1012 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1013 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1014
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001015 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1016
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001017 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1018 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1019
1020 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1021 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1022
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001023 { } /* end */
1024};
1025
1026static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1028
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001029 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031
1032 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1033 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034
1035 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1036 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1037
1038 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1039 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1040
1041 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1042 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1043
1044 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1045 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1046
1047 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1048 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1049 { } /* end */
1050};
1051
1052static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001053 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1054
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001055 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1057
1058 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1059 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1060
1061 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1062 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1063
1064 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1065 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1066
1067 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1068 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1069
1070 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1071 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1072
1073 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1074 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1075 { } /* end */
1076};
1077
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001078
1079static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1082
1083 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1084 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1085
1086 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1087 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1088
1089 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1090 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1091
1092 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1093 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1094
1095 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1096 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1097
1098 /*
1099 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1100 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1101 */
1102 { } /* end */
1103};
1104
Matthew Ranostay541eee82007-12-14 12:08:04 +01001105static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001106 STAC_INPUT_SOURCE(2),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001107 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001108
Matthew Ranostay9b359472007-11-07 13:03:12 +01001109 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1110 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001111
1112 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1113 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001114 /* analog pc-beep replaced with digital beep support */
1115 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001116 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1117 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001118 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001119
Matthew Ranostay687cb982008-10-11 13:52:43 -04001120 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001122
Matthew Ranostay687cb982008-10-11 13:52:43 -04001123 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1124 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001125
1126 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1127 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1128
1129 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1130 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001131 { } /* end */
1132};
1133
Matthew Ranostay541eee82007-12-14 12:08:04 +01001134static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001135 STAC_INPUT_SOURCE(2),
1136 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1137
Matthew Ranostay541eee82007-12-14 12:08:04 +01001138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001140
1141 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1142 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001143 { } /* end */
1144};
1145
Tobin Davis8e21c342007-01-08 11:04:17 +01001146static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001147 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001148 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001149 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001150 { } /* end */
1151};
1152
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001153static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001154 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001155 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001156
1157 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1158 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001159
1160 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1161 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001162 { } /* end */
1163};
1164
1165/* This needs to be generated dynamically based on sequence */
1166static struct snd_kcontrol_new stac922x_mixer[] = {
1167 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001170
1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001173 { } /* end */
1174};
1175
1176
1177static struct snd_kcontrol_new stac927x_mixer[] = {
1178 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001179 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001180
1181 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001183
1184 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001186
1187 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1188 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a52006-07-31 12:49:34 +02001189 { } /* end */
1190};
1191
Takashi Iwai1697055e2007-12-18 18:05:52 +01001192static struct snd_kcontrol_new stac_dmux_mixer = {
1193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1194 .name = "Digital Input Source",
1195 /* count set later */
1196 .info = stac92xx_dmux_enum_info,
1197 .get = stac92xx_dmux_enum_get,
1198 .put = stac92xx_dmux_enum_put,
1199};
1200
Matthew Ranostayd9737752008-09-07 12:03:41 +02001201static struct snd_kcontrol_new stac_smux_mixer = {
1202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001203 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001204 /* count set later */
1205 .info = stac92xx_smux_enum_info,
1206 .get = stac92xx_smux_enum_get,
1207 .put = stac92xx_smux_enum_put,
1208};
1209
Takashi Iwai2134ea42008-01-10 16:53:55 +01001210static const char *slave_vols[] = {
1211 "Front Playback Volume",
1212 "Surround Playback Volume",
1213 "Center Playback Volume",
1214 "LFE Playback Volume",
1215 "Side Playback Volume",
1216 "Headphone Playback Volume",
1217 "Headphone Playback Volume",
1218 "Speaker Playback Volume",
1219 "External Speaker Playback Volume",
1220 "Speaker2 Playback Volume",
1221 NULL
1222};
1223
1224static const char *slave_sws[] = {
1225 "Front Playback Switch",
1226 "Surround Playback Switch",
1227 "Center Playback Switch",
1228 "LFE Playback Switch",
1229 "Side Playback Switch",
1230 "Headphone Playback Switch",
1231 "Headphone Playback Switch",
1232 "Speaker Playback Switch",
1233 "External Speaker Playback Switch",
1234 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001235 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001236 NULL
1237};
1238
Matt2f2f4252005-04-13 14:45:30 +02001239static int stac92xx_build_controls(struct hda_codec *codec)
1240{
1241 struct sigmatel_spec *spec = codec->spec;
1242 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001243 int i;
Matt2f2f4252005-04-13 14:45:30 +02001244
1245 err = snd_hda_add_new_ctls(codec, spec->mixer);
1246 if (err < 0)
1247 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001248
1249 for (i = 0; i < spec->num_mixers; i++) {
1250 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1251 if (err < 0)
1252 return err;
1253 }
Takashi Iwai1697055e2007-12-18 18:05:52 +01001254 if (spec->num_dmuxes > 0) {
1255 stac_dmux_mixer.count = spec->num_dmuxes;
1256 err = snd_ctl_add(codec->bus->card,
1257 snd_ctl_new1(&stac_dmux_mixer, codec));
1258 if (err < 0)
1259 return err;
1260 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001261 if (spec->num_smuxes > 0) {
Matthew Ranostay00ef50c2008-09-27 18:13:47 -04001262 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1263 struct hda_input_mux *smux = &spec->private_smux;
1264 /* check for mute support on SPDIF out */
1265 if (wcaps & AC_WCAP_OUT_AMP) {
1266 smux->items[smux->num_items].label = "Off";
1267 smux->items[smux->num_items].index = 0;
1268 smux->num_items++;
1269 spec->spdif_mute = 1;
1270 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001271 stac_smux_mixer.count = spec->num_smuxes;
1272 err = snd_ctl_add(codec->bus->card,
1273 snd_ctl_new1(&stac_smux_mixer, codec));
1274 if (err < 0)
1275 return err;
1276 }
Mattc7d4b2f2005-06-27 14:59:41 +02001277
Mattdabbed62005-06-14 10:19:34 +02001278 if (spec->multiout.dig_out_nid) {
1279 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1280 if (err < 0)
1281 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001282 err = snd_hda_create_spdif_share_sw(codec,
1283 &spec->multiout);
1284 if (err < 0)
1285 return err;
1286 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001287 }
Harvey Harrisonda74ae32008-10-21 20:28:04 -07001288 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
Mattdabbed62005-06-14 10:19:34 +02001289 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1290 if (err < 0)
1291 return err;
1292 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001293
1294 /* if we have no master control, let's create it */
1295 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001296 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001297 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001298 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001299 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001300 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001301 if (err < 0)
1302 return err;
1303 }
1304 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1305 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1306 NULL, slave_sws);
1307 if (err < 0)
1308 return err;
1309 }
1310
Mattdabbed62005-06-14 10:19:34 +02001311 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001312}
1313
Matt Porter403d1942005-11-29 15:00:51 +01001314static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001315 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001316 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1317};
1318
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001319/*
1320 STAC 9200 pin configs for
1321 102801A8
1322 102801DE
1323 102801E8
1324*/
1325static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001326 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1327 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001328};
1329
1330/*
1331 STAC 9200 pin configs for
1332 102801C0
1333 102801C1
1334*/
1335static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001336 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1337 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001338};
1339
1340/*
1341 STAC 9200 pin configs for
1342 102801C4 (Dell Dimension E310)
1343 102801C5
1344 102801C7
1345 102801D9
1346 102801DA
1347 102801E3
1348*/
1349static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001350 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1351 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001352};
1353
1354
1355/*
1356 STAC 9200-32 pin configs for
1357 102801B5 (Dell Inspiron 630m)
1358 102801D8 (Dell Inspiron 640m)
1359*/
1360static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001361 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1362 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001363};
1364
1365/*
1366 STAC 9200-32 pin configs for
1367 102801C2 (Dell Latitude D620)
1368 102801C8
1369 102801CC (Dell Latitude D820)
1370 102801D4
1371 102801D6
1372*/
1373static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001374 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1375 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001376};
1377
1378/*
1379 STAC 9200-32 pin configs for
1380 102801CE (Dell XPS M1710)
1381 102801CF (Dell Precision M90)
1382*/
1383static unsigned int dell9200_m23_pin_configs[8] = {
1384 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1385 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1386};
1387
1388/*
1389 STAC 9200-32 pin configs for
1390 102801C9
1391 102801CA
1392 102801CB (Dell Latitude 120L)
1393 102801D3
1394*/
1395static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001396 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1397 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001398};
1399
1400/*
1401 STAC 9200-32 pin configs for
1402 102801BD (Dell Inspiron E1505n)
1403 102801EE
1404 102801EF
1405*/
1406static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001407 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1408 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001409};
1410
1411/*
1412 STAC 9200-32 pin configs for
1413 102801F5 (Dell Inspiron 1501)
1414 102801F6
1415*/
1416static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001417 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1418 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001419};
1420
1421/*
1422 STAC 9200-32
1423 102801CD (Dell Inspiron E1705/9400)
1424*/
1425static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001426 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1427 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001428};
1429
Tobin Davisbf277782008-02-03 20:31:47 +01001430static unsigned int oqo9200_pin_configs[8] = {
1431 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1432 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1433};
1434
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001435
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001436static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1437 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001438 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001439 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1440 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1441 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1442 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1443 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1444 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1445 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1446 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1447 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1448 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001449 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001450};
1451
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001452static const char *stac9200_models[STAC_9200_MODELS] = {
1453 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001454 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001455 [STAC_9200_DELL_D21] = "dell-d21",
1456 [STAC_9200_DELL_D22] = "dell-d22",
1457 [STAC_9200_DELL_D23] = "dell-d23",
1458 [STAC_9200_DELL_M21] = "dell-m21",
1459 [STAC_9200_DELL_M22] = "dell-m22",
1460 [STAC_9200_DELL_M23] = "dell-m23",
1461 [STAC_9200_DELL_M24] = "dell-m24",
1462 [STAC_9200_DELL_M25] = "dell-m25",
1463 [STAC_9200_DELL_M26] = "dell-m26",
1464 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001465 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001466 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001467};
1468
1469static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1470 /* SigmaTel reference board */
1471 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1472 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001473 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1475 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001477 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1479 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1481 "unknown Dell", STAC_9200_DELL_D22),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1483 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001485 "Dell Latitude D620", STAC_9200_DELL_M22),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1487 "unknown Dell", STAC_9200_DELL_D23),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1489 "unknown Dell", STAC_9200_DELL_D23),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1491 "unknown Dell", STAC_9200_DELL_M22),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1493 "unknown Dell", STAC_9200_DELL_M24),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1495 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001497 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001499 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001501 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001503 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001505 "Dell Precision M90", STAC_9200_DELL_M23),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1507 "unknown Dell", STAC_9200_DELL_M22),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1509 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001511 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001513 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1515 "unknown Dell", STAC_9200_DELL_D23),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1517 "unknown Dell", STAC_9200_DELL_D23),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1519 "unknown Dell", STAC_9200_DELL_D21),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1521 "unknown Dell", STAC_9200_DELL_D23),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1523 "unknown Dell", STAC_9200_DELL_D21),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1525 "unknown Dell", STAC_9200_DELL_M25),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1527 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001529 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1531 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001532 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001533 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001534 /* Gateway machines needs EAPD to be set on resume */
1535 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1536 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1537 STAC_9200_GATEWAY),
1538 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1539 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001540 /* OQO Mobile */
1541 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001542 {} /* terminator */
1543};
1544
Tobin Davis8e21c342007-01-08 11:04:17 +01001545static unsigned int ref925x_pin_configs[8] = {
1546 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001547 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001548};
1549
1550static unsigned int stac925x_MA6_pin_configs[8] = {
1551 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1552 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1553};
1554
Tobin Davis2c11f952007-05-17 09:36:34 +02001555static unsigned int stac925x_PA6_pin_configs[8] = {
1556 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1557 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1558};
1559
Tobin Davis8e21c342007-01-08 11:04:17 +01001560static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001561 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1562 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001563};
1564
1565static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1566 [STAC_REF] = ref925x_pin_configs,
1567 [STAC_M2_2] = stac925xM2_2_pin_configs,
1568 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001569 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001570};
1571
1572static const char *stac925x_models[STAC_925x_MODELS] = {
1573 [STAC_REF] = "ref",
1574 [STAC_M2_2] = "m2-2",
1575 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001576 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001577};
1578
1579static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1580 /* SigmaTel reference board */
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001582 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001583 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1584 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1585 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001586 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001587 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1588 {} /* terminator */
1589};
1590
Matthew Ranostaya7662642008-02-21 07:51:14 +01001591static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001592 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1593 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1594 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001595 0x01452050,
1596};
1597
1598static unsigned int dell_m6_pin_configs[13] = {
1599 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001600 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001601 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1602 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001603};
1604
1605static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001606 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001607 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1608 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1609 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001610 [STAC_DELL_EQ] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001611};
1612
1613static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1614 [STAC_92HD73XX_REF] = "ref",
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001615 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1616 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1617 [STAC_DELL_M6_BOTH] = "dell-m6",
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05001618 [STAC_DELL_EQ] = "dell-eq",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001619};
1620
1621static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1622 /* SigmaTel reference board */
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001624 "DFI LanParty", STAC_92HD73XX_REF),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001626 "Dell Studio 1535", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001628 "unknown Dell", STAC_DELL_M6_DMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001630 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001631 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001632 "unknown Dell", STAC_DELL_M6_BOTH),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001633 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001634 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001635 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001636 "unknown Dell", STAC_DELL_M6_AMIC),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001637 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001638 "unknown Dell", STAC_DELL_M6_DMIC),
1639 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1640 "unknown Dell", STAC_DELL_M6_DMIC),
Takashi Iwaib0fc5e02008-11-21 08:37:03 +01001641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
Takashi Iwai661cd8f2008-11-25 15:18:29 +01001642 "Dell Studio 1537", STAC_DELL_M6_DMIC),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001643 {} /* terminator */
1644};
1645
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001646static unsigned int ref92hd83xxx_pin_configs[14] = {
1647 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1648 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1649 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1650 0x01451160, 0x98560170,
1651};
1652
1653static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1654 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1655};
1656
1657static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1658 [STAC_92HD83XXX_REF] = "ref",
1659};
1660
1661static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1662 /* SigmaTel reference board */
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1664 "DFI LanParty", STAC_92HD71BXX_REF),
1665};
1666
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001667static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001668 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostay4b33c762008-10-10 09:07:23 -04001669 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001670 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001671};
1672
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001673static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001674 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001675 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001676 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001677};
1678
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001679static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001680 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1681 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001682 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001683};
1684
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001685static unsigned int dell_m4_3_pin_configs[11] = {
1686 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1687 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1688 0x40f000f0, 0x044413b0, 0x044413b0,
1689};
1690
Matthew Ranostaye035b842007-11-06 11:53:55 +01001691static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1692 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001693 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1694 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001695 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001696 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001697};
1698
1699static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1700 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001701 [STAC_DELL_M4_1] = "dell-m4-1",
1702 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001703 [STAC_DELL_M4_3] = "dell-m4-3",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001704 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001705};
1706
1707static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1708 /* SigmaTel reference board */
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1710 "DFI LanParty", STAC_92HD71BXX_REF),
Takashi Iwai80bf2722008-11-18 10:48:41 +01001711 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1712 "HP dv5", STAC_HP_M4),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1714 "HP dv7", STAC_HP_M4),
Matthew Ranostay9a9e2352008-09-26 10:37:03 -04001715 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1716 "unknown HP", STAC_HP_M4),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1718 "unknown Dell", STAC_DELL_M4_1),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1720 "unknown Dell", STAC_DELL_M4_1),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1722 "unknown Dell", STAC_DELL_M4_1),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1724 "unknown Dell", STAC_DELL_M4_1),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1726 "unknown Dell", STAC_DELL_M4_1),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1728 "unknown Dell", STAC_DELL_M4_1),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1730 "unknown Dell", STAC_DELL_M4_1),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1732 "unknown Dell", STAC_DELL_M4_2),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1734 "unknown Dell", STAC_DELL_M4_2),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1736 "unknown Dell", STAC_DELL_M4_2),
1737 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1738 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05001739 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1740 "unknown Dell", STAC_DELL_M4_3),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001741 {} /* terminator */
1742};
1743
Matt Porter403d1942005-11-29 15:00:51 +01001744static unsigned int ref922x_pin_configs[10] = {
1745 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1746 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001747 0x40000100, 0x40000100,
1748};
1749
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001750/*
1751 STAC 922X pin configs for
1752 102801A7
1753 102801AB
1754 102801A9
1755 102801D1
1756 102801D2
1757*/
1758static unsigned int dell_922x_d81_pin_configs[10] = {
1759 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1760 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1761 0x01813122, 0x400001f2,
1762};
1763
1764/*
1765 STAC 922X pin configs for
1766 102801AC
1767 102801D0
1768*/
1769static unsigned int dell_922x_d82_pin_configs[10] = {
1770 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1771 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1772 0x01813122, 0x400001f1,
1773};
1774
1775/*
1776 STAC 922X pin configs for
1777 102801BF
1778*/
1779static unsigned int dell_922x_m81_pin_configs[10] = {
1780 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1781 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1782 0x40C003f1, 0x405003f0,
1783};
1784
1785/*
1786 STAC 9221 A1 pin configs for
1787 102801D7 (Dell XPS M1210)
1788*/
1789static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001790 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1791 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001792 0x508003f3, 0x405003f4,
1793};
1794
Matt Porter403d1942005-11-29 15:00:51 +01001795static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001796 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001797 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1798 0x02a19120, 0x40000100,
1799};
1800
1801static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001802 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1803 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001804 0x02a19320, 0x40000100,
1805};
1806
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001807static unsigned int intel_mac_v1_pin_configs[10] = {
1808 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1809 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001810 0x400000fc, 0x400000fb,
1811};
1812
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001813static unsigned int intel_mac_v2_pin_configs[10] = {
1814 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1815 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001816 0x400000fc, 0x400000fb,
1817};
1818
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001819static unsigned int intel_mac_v3_pin_configs[10] = {
1820 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1821 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1822 0x400000fc, 0x400000fb,
1823};
1824
1825static unsigned int intel_mac_v4_pin_configs[10] = {
1826 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1827 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1828 0x400000fc, 0x400000fb,
1829};
1830
1831static unsigned int intel_mac_v5_pin_configs[10] = {
1832 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1833 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1834 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001835};
1836
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001837static unsigned int ecs202_pin_configs[10] = {
1838 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1839 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1840 0x9037012e, 0x40e000f2,
1841};
Takashi Iwai76c08822007-06-19 12:17:42 +02001842
Takashi Iwai19039bd2006-06-28 15:52:16 +02001843static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001844 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001845 [STAC_D945GTP3] = d945gtp3_pin_configs,
1846 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001847 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1848 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1849 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1850 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1851 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001852 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001853 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001854 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1855 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1856 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1857 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1858 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1859 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001860 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001861 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1862 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1863 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1864 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001865};
1866
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001867static const char *stac922x_models[STAC_922X_MODELS] = {
1868 [STAC_D945_REF] = "ref",
1869 [STAC_D945GTP5] = "5stack",
1870 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001871 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1872 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1873 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1874 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1875 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001876 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001877 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001878 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001879 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001880 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1881 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001882 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001883 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001884 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001885 [STAC_922X_DELL_D81] = "dell-d81",
1886 [STAC_922X_DELL_D82] = "dell-d82",
1887 [STAC_922X_DELL_M81] = "dell-m81",
1888 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001889};
1890
1891static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1892 /* SigmaTel reference board */
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1894 "DFI LanParty", STAC_D945_REF),
1895 /* Intel 945G based systems */
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1899 "Intel D945G", STAC_D945GTP3),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1901 "Intel D945G", STAC_D945GTP3),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1903 "Intel D945G", STAC_D945GTP3),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1913 "Intel D945G", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1915 "Intel D945G", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1917 "Intel D945G", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1919 "Intel D945G", STAC_D945GTP3),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1921 "Intel D945G", STAC_D945GTP3),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1923 "Intel D945G", STAC_D945GTP3),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1925 "Intel D945G", STAC_D945GTP3),
1926 /* Intel D945G 5-stack systems */
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1928 "Intel D945G", STAC_D945GTP5),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1930 "Intel D945G", STAC_D945GTP5),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1932 "Intel D945G", STAC_D945GTP5),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1934 "Intel D945G", STAC_D945GTP5),
1935 /* Intel 945P based systems */
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1937 "Intel D945P", STAC_D945GTP3),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1939 "Intel D945P", STAC_D945GTP3),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1941 "Intel D945P", STAC_D945GTP3),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1943 "Intel D945P", STAC_D945GTP3),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1945 "Intel D945P", STAC_D945GTP3),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1947 "Intel D945P", STAC_D945GTP5),
1948 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001949 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001950 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001951 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001952 /* Dell systems */
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1954 "unknown Dell", STAC_922X_DELL_D81),
1955 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1956 "unknown Dell", STAC_922X_DELL_D81),
1957 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1958 "unknown Dell", STAC_922X_DELL_D81),
1959 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1960 "unknown Dell", STAC_922X_DELL_D82),
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1962 "unknown Dell", STAC_922X_DELL_M81),
1963 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1964 "unknown Dell", STAC_922X_DELL_D82),
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1966 "unknown Dell", STAC_922X_DELL_D81),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1968 "unknown Dell", STAC_922X_DELL_D81),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1970 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001971 /* ECS/PC Chips boards */
1972 SND_PCI_QUIRK(0x1019, 0x2144,
1973 "ECS/PC chips", STAC_ECS_202),
1974 SND_PCI_QUIRK(0x1019, 0x2608,
1975 "ECS/PC chips", STAC_ECS_202),
1976 SND_PCI_QUIRK(0x1019, 0x2633,
1977 "ECS/PC chips P17G/1333", STAC_ECS_202),
1978 SND_PCI_QUIRK(0x1019, 0x2811,
1979 "ECS/PC chips", STAC_ECS_202),
1980 SND_PCI_QUIRK(0x1019, 0x2812,
1981 "ECS/PC chips", STAC_ECS_202),
1982 SND_PCI_QUIRK(0x1019, 0x2813,
1983 "ECS/PC chips", STAC_ECS_202),
1984 SND_PCI_QUIRK(0x1019, 0x2814,
1985 "ECS/PC chips", STAC_ECS_202),
1986 SND_PCI_QUIRK(0x1019, 0x2815,
1987 "ECS/PC chips", STAC_ECS_202),
1988 SND_PCI_QUIRK(0x1019, 0x2816,
1989 "ECS/PC chips", STAC_ECS_202),
1990 SND_PCI_QUIRK(0x1019, 0x2817,
1991 "ECS/PC chips", STAC_ECS_202),
1992 SND_PCI_QUIRK(0x1019, 0x2818,
1993 "ECS/PC chips", STAC_ECS_202),
1994 SND_PCI_QUIRK(0x1019, 0x2819,
1995 "ECS/PC chips", STAC_ECS_202),
1996 SND_PCI_QUIRK(0x1019, 0x2820,
1997 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001998 {} /* terminator */
1999};
2000
Matt Porter3cc08dc2006-01-23 15:27:49 +01002001static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02002002 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2003 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2004 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2005 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002006};
2007
Tobin Davis93ed1502006-09-01 21:03:12 +02002008static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002009 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2010 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2011 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2012 0x40000100, 0x40000100
2013};
2014
Tobin Davis93ed1502006-09-01 21:03:12 +02002015static unsigned int d965_5st_pin_configs[14] = {
2016 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2017 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2018 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2019 0x40000100, 0x40000100
2020};
2021
Tobin Davis4ff076e2007-08-07 11:48:12 +02002022static unsigned int dell_3st_pin_configs[14] = {
2023 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2024 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002025 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02002026 0x40c003fc, 0x40000100
2027};
2028
Tobin Davis93ed1502006-09-01 21:03:12 +02002029static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002030 [STAC_D965_REF] = ref927x_pin_configs,
2031 [STAC_D965_3ST] = d965_3st_pin_configs,
2032 [STAC_D965_5ST] = d965_5st_pin_configs,
2033 [STAC_DELL_3ST] = dell_3st_pin_configs,
2034 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01002035};
2036
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002037static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002038 [STAC_D965_REF] = "ref",
2039 [STAC_D965_3ST] = "3stack",
2040 [STAC_D965_5ST] = "5stack",
2041 [STAC_DELL_3ST] = "dell-3stack",
2042 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002043};
2044
2045static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2046 /* SigmaTel reference board */
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2048 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002049 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02002052 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002069 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02002072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002074 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01002075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002083 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002093 {} /* terminator */
2094};
2095
Matt Porterf3302a52006-07-31 12:49:34 +02002096static unsigned int ref9205_pin_configs[12] = {
2097 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002098 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002099 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +02002100};
2101
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002102/*
2103 STAC 9205 pin configs for
2104 102801F1
2105 102801F2
2106 102801FC
2107 102801FD
2108 10280204
2109 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002110 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002111*/
2112static unsigned int dell_9205_m42_pin_configs[12] = {
2113 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2114 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2115 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2116};
2117
2118/*
2119 STAC 9205 pin configs for
2120 102801F9
2121 102801FA
2122 102801FE
2123 102801FF (Dell Precision M4300)
2124 10280206
2125 10280200
2126 10280201
2127*/
2128static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002129 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2130 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2131 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2132};
2133
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002134static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002135 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2136 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2137 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2138};
2139
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002140static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002141 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002142 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2143 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2144 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a52006-07-31 12:49:34 +02002145};
2146
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002147static const char *stac9205_models[STAC_9205_MODELS] = {
2148 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002149 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002150 [STAC_9205_DELL_M43] = "dell-m43",
2151 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002152};
2153
2154static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2155 /* SigmaTel reference board */
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2157 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2159 "unknown Dell", STAC_9205_DELL_M42),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2161 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002163 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2165 "Dell Precision", STAC_9205_DELL_M43),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2167 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2169 "unknown Dell", STAC_9205_DELL_M42),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2171 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2173 "Dell Precision", STAC_9205_DELL_M43),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002175 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2177 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2179 "Dell Precision", STAC_9205_DELL_M43),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2181 "Dell Precision", STAC_9205_DELL_M43),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2183 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2185 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2187 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a52006-07-31 12:49:34 +02002188 {} /* terminator */
2189};
2190
Richard Fish11b44bb2006-08-23 18:31:34 +02002191static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2192{
2193 int i;
2194 struct sigmatel_spec *spec = codec->spec;
2195
2196 if (! spec->bios_pin_configs) {
2197 spec->bios_pin_configs = kcalloc(spec->num_pins,
2198 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2199 if (! spec->bios_pin_configs)
2200 return -ENOMEM;
2201 }
2202
2203 for (i = 0; i < spec->num_pins; i++) {
2204 hda_nid_t nid = spec->pin_nids[i];
2205 unsigned int pin_cfg;
2206
2207 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2208 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2209 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2210 nid, pin_cfg);
2211 spec->bios_pin_configs[i] = pin_cfg;
2212 }
2213
2214 return 0;
2215}
2216
Matthew Ranostay87d48362007-07-17 11:52:24 +02002217static void stac92xx_set_config_reg(struct hda_codec *codec,
2218 hda_nid_t pin_nid, unsigned int pin_config)
2219{
2220 int i;
2221 snd_hda_codec_write(codec, pin_nid, 0,
2222 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2223 pin_config & 0x000000ff);
2224 snd_hda_codec_write(codec, pin_nid, 0,
2225 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2226 (pin_config & 0x0000ff00) >> 8);
2227 snd_hda_codec_write(codec, pin_nid, 0,
2228 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2229 (pin_config & 0x00ff0000) >> 16);
2230 snd_hda_codec_write(codec, pin_nid, 0,
2231 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2232 pin_config >> 24);
2233 i = snd_hda_codec_read(codec, pin_nid, 0,
2234 AC_VERB_GET_CONFIG_DEFAULT,
2235 0x00);
2236 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2237 pin_nid, i);
2238}
2239
Matt2f2f4252005-04-13 14:45:30 +02002240static void stac92xx_set_config_regs(struct hda_codec *codec)
2241{
2242 int i;
2243 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002244
Matthew Ranostay87d48362007-07-17 11:52:24 +02002245 if (!spec->pin_configs)
2246 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002247
Matthew Ranostay87d48362007-07-17 11:52:24 +02002248 for (i = 0; i < spec->num_pins; i++)
2249 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2250 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002251}
Matt2f2f4252005-04-13 14:45:30 +02002252
Matt2f2f4252005-04-13 14:45:30 +02002253/*
2254 * Analog playback callbacks
2255 */
2256static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2257 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-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;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002261 if (spec->stream_delay)
2262 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002263 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2264 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002265}
2266
2267static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2268 struct hda_codec *codec,
2269 unsigned int stream_tag,
2270 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002271 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002272{
2273 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002274 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002275}
2276
2277static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2278 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002279 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002280{
2281 struct sigmatel_spec *spec = codec->spec;
2282 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2283}
2284
2285/*
Mattdabbed62005-06-14 10:19:34 +02002286 * Digital playback callbacks
2287 */
2288static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2289 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002290 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002291{
2292 struct sigmatel_spec *spec = codec->spec;
2293 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2294}
2295
2296static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2297 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002298 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002299{
2300 struct sigmatel_spec *spec = codec->spec;
2301 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2302}
2303
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002304static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2305 struct hda_codec *codec,
2306 unsigned int stream_tag,
2307 unsigned int format,
2308 struct snd_pcm_substream *substream)
2309{
2310 struct sigmatel_spec *spec = codec->spec;
2311 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2312 stream_tag, format, substream);
2313}
2314
Mattdabbed62005-06-14 10:19:34 +02002315
2316/*
Matt2f2f4252005-04-13 14:45:30 +02002317 * Analog capture callbacks
2318 */
2319static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2320 struct hda_codec *codec,
2321 unsigned int stream_tag,
2322 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002323 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002324{
2325 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002326 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002327
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002328 if (spec->powerdown_adcs) {
2329 msleep(40);
2330 snd_hda_codec_write_cache(codec, nid, 0,
2331 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2332 }
2333 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002334 return 0;
2335}
2336
2337static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2338 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002339 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002340{
2341 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002342 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002343
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002344 snd_hda_codec_cleanup_stream(codec, nid);
2345 if (spec->powerdown_adcs)
2346 snd_hda_codec_write_cache(codec, nid, 0,
2347 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002348 return 0;
2349}
2350
Mattdabbed62005-06-14 10:19:34 +02002351static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2352 .substreams = 1,
2353 .channels_min = 2,
2354 .channels_max = 2,
2355 /* NID is set in stac92xx_build_pcms */
2356 .ops = {
2357 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002358 .close = stac92xx_dig_playback_pcm_close,
2359 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002360 },
2361};
2362
2363static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2364 .substreams = 1,
2365 .channels_min = 2,
2366 .channels_max = 2,
2367 /* NID is set in stac92xx_build_pcms */
2368};
2369
Matt2f2f4252005-04-13 14:45:30 +02002370static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2371 .substreams = 1,
2372 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002373 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002374 .nid = 0x02, /* NID to query formats and rates */
2375 .ops = {
2376 .open = stac92xx_playback_pcm_open,
2377 .prepare = stac92xx_playback_pcm_prepare,
2378 .cleanup = stac92xx_playback_pcm_cleanup
2379 },
2380};
2381
Matt Porter3cc08dc2006-01-23 15:27:49 +01002382static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2383 .substreams = 1,
2384 .channels_min = 2,
2385 .channels_max = 2,
2386 .nid = 0x06, /* NID to query formats and rates */
2387 .ops = {
2388 .open = stac92xx_playback_pcm_open,
2389 .prepare = stac92xx_playback_pcm_prepare,
2390 .cleanup = stac92xx_playback_pcm_cleanup
2391 },
2392};
2393
Matt2f2f4252005-04-13 14:45:30 +02002394static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002395 .channels_min = 2,
2396 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002397 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002398 .ops = {
2399 .prepare = stac92xx_capture_pcm_prepare,
2400 .cleanup = stac92xx_capture_pcm_cleanup
2401 },
2402};
2403
2404static int stac92xx_build_pcms(struct hda_codec *codec)
2405{
2406 struct sigmatel_spec *spec = codec->spec;
2407 struct hda_pcm *info = spec->pcm_rec;
2408
2409 codec->num_pcms = 1;
2410 codec->pcm_info = info;
2411
Mattc7d4b2f2005-06-27 14:59:41 +02002412 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002413 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002414 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002415 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002416 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002417
2418 if (spec->alt_switch) {
2419 codec->num_pcms++;
2420 info++;
2421 info->name = "STAC92xx Analog Alt";
2422 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2423 }
Matt2f2f4252005-04-13 14:45:30 +02002424
Mattdabbed62005-06-14 10:19:34 +02002425 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2426 codec->num_pcms++;
2427 info++;
2428 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002429 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002430 if (spec->multiout.dig_out_nid) {
2431 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2432 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2433 }
2434 if (spec->dig_in_nid) {
2435 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2436 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2437 }
2438 }
2439
Matt2f2f4252005-04-13 14:45:30 +02002440 return 0;
2441}
2442
Takashi Iwaic960a032006-03-23 17:06:28 +01002443static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2444{
2445 unsigned int pincap = snd_hda_param_read(codec, nid,
2446 AC_PAR_PIN_CAP);
2447 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2448 if (pincap & AC_PINCAP_VREF_100)
2449 return AC_PINCTL_VREF_100;
2450 if (pincap & AC_PINCAP_VREF_80)
2451 return AC_PINCTL_VREF_80;
2452 if (pincap & AC_PINCAP_VREF_50)
2453 return AC_PINCTL_VREF_50;
2454 if (pincap & AC_PINCAP_VREF_GRD)
2455 return AC_PINCTL_VREF_GRD;
2456 return 0;
2457}
2458
Matt Porter403d1942005-11-29 15:00:51 +01002459static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2460
2461{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002462 snd_hda_codec_write_cache(codec, nid, 0,
2463 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002464}
2465
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002466#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2467
2468static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2469 struct snd_ctl_elem_value *ucontrol)
2470{
2471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2472 struct sigmatel_spec *spec = codec->spec;
2473
Takashi Iwaid7a89432008-11-12 09:48:04 +01002474 ucontrol->value.integer.value[0] = !!spec->hp_switch;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002475 return 0;
2476}
2477
2478static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2479 struct snd_ctl_elem_value *ucontrol)
2480{
2481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2482 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaid7a89432008-11-12 09:48:04 +01002483 int nid = kcontrol->private_value;
2484
2485 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002486
2487 /* check to be sure that the ports are upto date with
2488 * switch changes
2489 */
2490 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2491
2492 return 1;
2493}
2494
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002495#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002496
2497static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2498{
2499 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2500 struct sigmatel_spec *spec = codec->spec;
2501 int io_idx = kcontrol-> private_value & 0xff;
2502
2503 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2504 return 0;
2505}
2506
2507static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2508{
2509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2510 struct sigmatel_spec *spec = codec->spec;
2511 hda_nid_t nid = kcontrol->private_value >> 8;
2512 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002513 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002514
2515 spec->io_switch[io_idx] = val;
2516
2517 if (val)
2518 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002519 else {
2520 unsigned int pinctl = AC_PINCTL_IN_EN;
2521 if (io_idx) /* set VREF for mic */
2522 pinctl |= stac92xx_get_vref(codec, nid);
2523 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2524 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002525
2526 /* check the auto-mute again: we need to mute/unmute the speaker
2527 * appropriately according to the pin direction
2528 */
2529 if (spec->hp_detect)
2530 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2531
Matt Porter403d1942005-11-29 15:00:51 +01002532 return 1;
2533}
2534
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002535#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2536
2537static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2538 struct snd_ctl_elem_value *ucontrol)
2539{
2540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2541 struct sigmatel_spec *spec = codec->spec;
2542
2543 ucontrol->value.integer.value[0] = spec->clfe_swap;
2544 return 0;
2545}
2546
2547static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2548 struct snd_ctl_elem_value *ucontrol)
2549{
2550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2551 struct sigmatel_spec *spec = codec->spec;
2552 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002553 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002554
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002555 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002556 return 0;
2557
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002558 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002559
2560 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2561 spec->clfe_swap ? 0x4 : 0x0);
2562
2563 return 1;
2564}
2565
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002566#define STAC_CODEC_HP_SWITCH(xname) \
2567 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2568 .name = xname, \
2569 .index = 0, \
2570 .info = stac92xx_hp_switch_info, \
2571 .get = stac92xx_hp_switch_get, \
2572 .put = stac92xx_hp_switch_put, \
2573 }
2574
Matt Porter403d1942005-11-29 15:00:51 +01002575#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2576 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2577 .name = xname, \
2578 .index = 0, \
2579 .info = stac92xx_io_switch_info, \
2580 .get = stac92xx_io_switch_get, \
2581 .put = stac92xx_io_switch_put, \
2582 .private_value = xpval, \
2583 }
2584
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002585#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2586 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2587 .name = xname, \
2588 .index = 0, \
2589 .info = stac92xx_clfe_switch_info, \
2590 .get = stac92xx_clfe_switch_get, \
2591 .put = stac92xx_clfe_switch_put, \
2592 .private_value = xpval, \
2593 }
Matt Porter403d1942005-11-29 15:00:51 +01002594
Mattc7d4b2f2005-06-27 14:59:41 +02002595enum {
2596 STAC_CTL_WIDGET_VOL,
2597 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002598 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002599 STAC_CTL_WIDGET_AMP_MUX,
2600 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002601 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002602 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002603 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002604};
2605
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002606static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002607 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2608 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002609 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002610 STAC_AMP_MUX,
2611 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002612 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002613 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002614 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002615};
2616
2617/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002618static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2619 struct snd_kcontrol_new *ktemp,
2620 int idx, const char *name,
2621 unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002622{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002623 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002624
2625 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2626 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2627
2628 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2629 if (! knew)
2630 return -ENOMEM;
2631 if (spec->kctl_alloc) {
2632 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2633 kfree(spec->kctl_alloc);
2634 }
2635 spec->kctl_alloc = knew;
2636 spec->num_kctl_alloc = num;
2637 }
2638
2639 knew = &spec->kctl_alloc[spec->num_kctl_used];
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002640 *knew = *ktemp;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002641 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002642 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002643 if (!knew->name)
Mattc7d4b2f2005-06-27 14:59:41 +02002644 return -ENOMEM;
2645 knew->private_value = val;
2646 spec->num_kctl_used++;
2647 return 0;
2648}
2649
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002650static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2651 int type, int idx, const char *name,
2652 unsigned long val)
2653{
2654 return stac92xx_add_control_temp(spec,
2655 &stac92xx_control_templates[type],
2656 idx, name, val);
2657}
2658
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002659
2660/* add dynamic controls */
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01002661static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2662 const char *name, unsigned long val)
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002663{
2664 return stac92xx_add_control_idx(spec, type, 0, name, val);
2665}
2666
Matt Porter403d1942005-11-29 15:00:51 +01002667/* flag inputs as additional dynamic lineouts */
2668static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2669{
2670 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002671 unsigned int wcaps, wtype;
2672 int i, num_dacs = 0;
2673
2674 /* use the wcaps cache to count all DACs available for line-outs */
2675 for (i = 0; i < codec->num_nodes; i++) {
2676 wcaps = codec->wcaps[i];
2677 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002678
Steve Longerbeam7b043892007-05-03 20:50:03 +02002679 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2680 num_dacs++;
2681 }
Matt Porter403d1942005-11-29 15:00:51 +01002682
Steve Longerbeam7b043892007-05-03 20:50:03 +02002683 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2684
Matt Porter403d1942005-11-29 15:00:51 +01002685 switch (cfg->line_outs) {
2686 case 3:
2687 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002688 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002689 cfg->line_out_pins[cfg->line_outs] =
2690 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002691 spec->line_switch = 1;
2692 cfg->line_outs++;
2693 }
2694 break;
2695 case 2:
2696 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002697 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002698 cfg->line_out_pins[cfg->line_outs] =
2699 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002700 spec->line_switch = 1;
2701 cfg->line_outs++;
2702 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002703 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002704 cfg->line_out_pins[cfg->line_outs] =
2705 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002706 spec->mic_switch = 1;
2707 cfg->line_outs++;
2708 }
2709 break;
2710 case 1:
2711 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002712 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002713 cfg->line_out_pins[cfg->line_outs] =
2714 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002715 spec->line_switch = 1;
2716 cfg->line_outs++;
2717 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002718 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002719 cfg->line_out_pins[cfg->line_outs] =
2720 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002721 spec->mic_switch = 1;
2722 cfg->line_outs++;
2723 }
2724 break;
2725 }
2726
2727 return 0;
2728}
2729
Steve Longerbeam7b043892007-05-03 20:50:03 +02002730
2731static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2732{
2733 int i;
2734
2735 for (i = 0; i < spec->multiout.num_dacs; i++) {
2736 if (spec->multiout.dac_nids[i] == nid)
2737 return 1;
2738 }
2739
2740 return 0;
2741}
2742
Matt Porter3cc08dc2006-01-23 15:27:49 +01002743/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002744 * Fill in the dac_nids table from the parsed pin configuration
2745 * This function only works when every pin in line_out_pins[]
2746 * contains atleast one DAC in its connection list. Some 92xx
2747 * codecs are not connected directly to a DAC, such as the 9200
2748 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002749 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002750static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002751 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002752{
2753 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002754 int i, j, conn_len = 0;
2755 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2756 unsigned int wcaps, wtype;
2757
Mattc7d4b2f2005-06-27 14:59:41 +02002758 for (i = 0; i < cfg->line_outs; i++) {
2759 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002760 conn_len = snd_hda_get_connections(codec, nid, conn,
2761 HDA_MAX_CONNECTIONS);
2762 for (j = 0; j < conn_len; j++) {
2763 wcaps = snd_hda_param_read(codec, conn[j],
2764 AC_PAR_AUDIO_WIDGET_CAP);
2765 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002766 if (wtype != AC_WID_AUD_OUT ||
2767 (wcaps & AC_WCAP_DIGITAL))
2768 continue;
2769 /* conn[j] is a DAC routed to this line-out */
2770 if (!is_in_dac_nids(spec, conn[j]))
2771 break;
2772 }
2773
2774 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002775 if (spec->multiout.num_dacs > 0) {
2776 /* we have already working output pins,
2777 * so let's drop the broken ones again
2778 */
2779 cfg->line_outs = spec->multiout.num_dacs;
2780 break;
2781 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002782 /* error out, no available DAC found */
2783 snd_printk(KERN_ERR
2784 "%s: No available DAC for pin 0x%x\n",
2785 __func__, nid);
2786 return -ENODEV;
2787 }
2788
2789 spec->multiout.dac_nids[i] = conn[j];
2790 spec->multiout.num_dacs++;
2791 if (conn_len > 1) {
2792 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002793 snd_hda_codec_write_cache(codec, nid, 0,
2794 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002795
2796 }
Mattc7d4b2f2005-06-27 14:59:41 +02002797 }
2798
Steve Longerbeam7b043892007-05-03 20:50:03 +02002799 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2800 spec->multiout.num_dacs,
2801 spec->multiout.dac_nids[0],
2802 spec->multiout.dac_nids[1],
2803 spec->multiout.dac_nids[2],
2804 spec->multiout.dac_nids[3],
2805 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002806 return 0;
2807}
2808
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002809/* create volume control/switch for the given prefx type */
2810static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2811{
2812 char name[32];
2813 int err;
2814
2815 sprintf(name, "%s Playback Volume", pfx);
2816 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2817 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2818 if (err < 0)
2819 return err;
2820 sprintf(name, "%s Playback Switch", pfx);
2821 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2822 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2823 if (err < 0)
2824 return err;
2825 return 0;
2826}
2827
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002828static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2829{
2830 if (!spec->multiout.hp_nid)
2831 spec->multiout.hp_nid = nid;
2832 else if (spec->multiout.num_dacs > 4) {
2833 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2834 return 1;
2835 } else {
2836 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2837 spec->multiout.num_dacs++;
2838 }
2839 return 0;
2840}
2841
2842static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2843{
2844 if (is_in_dac_nids(spec, nid))
2845 return 1;
2846 if (spec->multiout.hp_nid == nid)
2847 return 1;
2848 return 0;
2849}
2850
Mattc7d4b2f2005-06-27 14:59:41 +02002851/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002852static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002853 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002854{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002855 static const char *chname[4] = {
2856 "Front", "Surround", NULL /*CLFE*/, "Side"
2857 };
Matthew Ranostayd21995e2008-10-13 13:22:45 -04002858 hda_nid_t nid = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002859 int i, err;
2860
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002861 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002862 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002863
2864
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002865 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002866 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002867 continue;
2868
2869 nid = spec->multiout.dac_nids[i];
2870
2871 if (i == 2) {
2872 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002873 err = create_controls(spec, "Center", nid, 1);
2874 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002875 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002876 err = create_controls(spec, "LFE", nid, 2);
2877 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002878 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002879
2880 wid_caps = get_wcaps(codec, nid);
2881
2882 if (wid_caps & AC_WCAP_LR_SWAP) {
2883 err = stac92xx_add_control(spec,
2884 STAC_CTL_WIDGET_CLFE_SWITCH,
2885 "Swap Center/LFE Playback Switch", nid);
2886
2887 if (err < 0)
2888 return err;
2889 }
2890
Mattc7d4b2f2005-06-27 14:59:41 +02002891 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002892 err = create_controls(spec, chname[i], nid, 3);
2893 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002894 return err;
2895 }
2896 }
2897
Matthew Ranostayfedb7562008-09-23 21:46:30 -04002898 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2899 cfg->hp_outs && !spec->multiout.hp_nid)
2900 spec->multiout.hp_nid = nid;
2901
Takashi Iwai95026622008-11-24 07:51:11 +01002902 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002903 err = stac92xx_add_control(spec,
2904 STAC_CTL_WIDGET_HP_SWITCH,
Takashi Iwaid7a89432008-11-12 09:48:04 +01002905 "Headphone as Line Out Switch",
2906 cfg->hp_pins[cfg->hp_outs - 1]);
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002907 if (err < 0)
2908 return err;
2909 }
2910
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002911 if (spec->line_switch) {
2912 nid = cfg->input_pins[AUTO_PIN_LINE];
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 "Line In as Output Switch", nid << 8);
2919 if (err < 0)
2920 return err;
2921 }
2922 }
Matt Porter403d1942005-11-29 15:00:51 +01002923
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002924 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002925 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002926 unsigned int mic_pin = AUTO_PIN_MIC;
2927again:
2928 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002929 def_conf = snd_hda_codec_read(codec, nid, 0,
2930 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002931 /* some laptops have an internal analog microphone
2932 * which can't be used as a output */
2933 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2934 pincap = snd_hda_param_read(codec, nid,
2935 AC_PAR_PIN_CAP);
2936 if (pincap & AC_PINCAP_OUT) {
2937 err = stac92xx_add_control(spec,
2938 STAC_CTL_WIDGET_IO_SWITCH,
2939 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002940 nid = snd_hda_codec_read(codec, nid, 0,
2941 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2942 if (!check_in_dac_nids(spec, nid))
2943 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002944 if (err < 0)
2945 return err;
2946 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002947 } else if (mic_pin == AUTO_PIN_MIC) {
2948 mic_pin = AUTO_PIN_FRONT_MIC;
2949 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002950 }
2951 }
Matt Porter403d1942005-11-29 15:00:51 +01002952
Mattc7d4b2f2005-06-27 14:59:41 +02002953 return 0;
2954}
2955
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002956/* add playback controls for Speaker and HP outputs */
2957static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2958 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002959{
2960 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002961 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002962 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002963
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002964 old_num_dacs = spec->multiout.num_dacs;
2965 for (i = 0; i < cfg->hp_outs; i++) {
2966 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2967 if (wid_caps & AC_WCAP_UNSOL_CAP)
2968 spec->hp_detect = 1;
2969 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2970 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2971 if (check_in_dac_nids(spec, nid))
2972 nid = 0;
2973 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002974 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002975 add_spec_dacs(spec, nid);
2976 }
2977 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002978 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002979 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2980 if (check_in_dac_nids(spec, nid))
2981 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002982 if (! nid)
2983 continue;
2984 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002985 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002986 for (i = 0; i < cfg->line_outs; i++) {
2987 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2988 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2989 if (check_in_dac_nids(spec, nid))
2990 nid = 0;
2991 if (! nid)
2992 continue;
2993 add_spec_dacs(spec, nid);
2994 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002995 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2996 static const char *pfxs[] = {
2997 "Speaker", "External Speaker", "Speaker2",
2998 };
2999 err = create_controls(spec, pfxs[i - old_num_dacs],
3000 spec->multiout.dac_nids[i], 3);
3001 if (err < 0)
3002 return err;
3003 }
3004 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01003005 err = create_controls(spec, "Headphone",
3006 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003007 if (err < 0)
3008 return err;
3009 }
Mattc7d4b2f2005-06-27 14:59:41 +02003010
3011 return 0;
3012}
3013
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003014/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003015static const char *stac92xx_mono_labels[4] = {
3016 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003017};
3018
3019/* create mono mux for mono out on capable codecs */
3020static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3021{
3022 struct sigmatel_spec *spec = codec->spec;
3023 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3024 int i, num_cons;
3025 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3026
3027 num_cons = snd_hda_get_connections(codec,
3028 spec->mono_nid,
3029 con_lst,
3030 HDA_MAX_NUM_INPUTS);
3031 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3032 return -EINVAL;
3033
3034 for (i = 0; i < num_cons; i++) {
3035 mono_mux->items[mono_mux->num_items].label =
3036 stac92xx_mono_labels[i];
3037 mono_mux->items[mono_mux->num_items].index = i;
3038 mono_mux->num_items++;
3039 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003040
3041 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3042 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003043}
3044
Matthew Ranostay89385032008-09-11 09:49:39 -04003045/* labels for amp mux outputs */
3046static const char *stac92xx_amp_labels[3] = {
Matthew Ranostay4b33c762008-10-10 09:07:23 -04003047 "Front Microphone", "Microphone", "Line In",
Matthew Ranostay89385032008-09-11 09:49:39 -04003048};
3049
3050/* create amp out controls mux on capable codecs */
3051static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3052{
3053 struct sigmatel_spec *spec = codec->spec;
3054 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3055 int i, err;
3056
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003057 for (i = 0; i < spec->num_amps; i++) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003058 amp_mux->items[amp_mux->num_items].label =
3059 stac92xx_amp_labels[i];
3060 amp_mux->items[amp_mux->num_items].index = i;
3061 amp_mux->num_items++;
3062 }
3063
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003064 if (spec->num_amps > 1) {
3065 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3066 "Amp Selector Capture Switch", 0);
3067 if (err < 0)
3068 return err;
3069 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003070 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3071 "Amp Capture Volume",
3072 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3073}
3074
3075
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003076/* create PC beep volume controls */
3077static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3078 hda_nid_t nid)
3079{
3080 struct sigmatel_spec *spec = codec->spec;
3081 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3082 int err;
3083
3084 /* check for mute support for the the amp */
3085 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3086 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3087 "PC Beep Playback Switch",
3088 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3089 if (err < 0)
3090 return err;
3091 }
3092
3093 /* check to see if there is volume support for the amp */
3094 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3095 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3096 "PC Beep Playback Volume",
3097 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3098 if (err < 0)
3099 return err;
3100 }
3101 return 0;
3102}
3103
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003104#ifdef CONFIG_SND_HDA_INPUT_BEEP
3105#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3106
3107static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3108 struct snd_ctl_elem_value *ucontrol)
3109{
3110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3111 ucontrol->value.integer.value[0] = codec->beep->enabled;
3112 return 0;
3113}
3114
3115static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3116 struct snd_ctl_elem_value *ucontrol)
3117{
3118 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3119 int enabled = !!ucontrol->value.integer.value[0];
3120 if (codec->beep->enabled != enabled) {
3121 codec->beep->enabled = enabled;
3122 return 1;
3123 }
3124 return 0;
3125}
3126
3127static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3129 .info = stac92xx_dig_beep_switch_info,
3130 .get = stac92xx_dig_beep_switch_get,
3131 .put = stac92xx_dig_beep_switch_put,
3132};
3133
3134static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3135{
3136 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3137 0, "PC Beep Playback Switch", 0);
3138}
3139#endif
3140
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003141static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3142{
3143 struct sigmatel_spec *spec = codec->spec;
3144 int wcaps, nid, i, err = 0;
3145
3146 for (i = 0; i < spec->num_muxes; i++) {
3147 nid = spec->mux_nids[i];
3148 wcaps = get_wcaps(codec, nid);
3149
3150 if (wcaps & AC_WCAP_OUT_AMP) {
3151 err = stac92xx_add_control_idx(spec,
3152 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3153 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3154 if (err < 0)
3155 return err;
3156 }
3157 }
3158 return 0;
3159};
3160
Matthew Ranostayd9737752008-09-07 12:03:41 +02003161static const char *stac92xx_spdif_labels[3] = {
Matthew Ranostay65973632008-09-16 10:39:37 -04003162 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
Matthew Ranostayd9737752008-09-07 12:03:41 +02003163};
3164
3165static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3166{
3167 struct sigmatel_spec *spec = codec->spec;
3168 struct hda_input_mux *spdif_mux = &spec->private_smux;
Matthew Ranostay65973632008-09-16 10:39:37 -04003169 const char **labels = spec->spdif_labels;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003170 int i, num_cons;
Matthew Ranostay65973632008-09-16 10:39:37 -04003171 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003172
3173 num_cons = snd_hda_get_connections(codec,
3174 spec->smux_nids[0],
3175 con_lst,
3176 HDA_MAX_NUM_INPUTS);
Matthew Ranostay65973632008-09-16 10:39:37 -04003177 if (!num_cons)
Matthew Ranostayd9737752008-09-07 12:03:41 +02003178 return -EINVAL;
3179
Matthew Ranostay65973632008-09-16 10:39:37 -04003180 if (!labels)
3181 labels = stac92xx_spdif_labels;
3182
Matthew Ranostayd9737752008-09-07 12:03:41 +02003183 for (i = 0; i < num_cons; i++) {
Matthew Ranostay65973632008-09-16 10:39:37 -04003184 spdif_mux->items[spdif_mux->num_items].label = labels[i];
Matthew Ranostayd9737752008-09-07 12:03:41 +02003185 spdif_mux->items[spdif_mux->num_items].index = i;
3186 spdif_mux->num_items++;
3187 }
3188
3189 return 0;
3190}
3191
Matt Porter8b657272006-10-26 17:12:59 +02003192/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003193static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003194 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3195 "Digital Mic 3", "Digital Mic 4"
3196};
3197
3198/* create playback/capture controls for input pins on dmic capable codecs */
3199static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3200 const struct auto_pin_cfg *cfg)
3201{
3202 struct sigmatel_spec *spec = codec->spec;
3203 struct hda_input_mux *dimux = &spec->private_dimux;
3204 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003205 int err, i, j;
3206 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003207
3208 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3209 dimux->items[dimux->num_items].index = 0;
3210 dimux->num_items++;
3211
3212 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003213 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003214 int index;
3215 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003216 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003217 unsigned int def_conf;
3218
3219 def_conf = snd_hda_codec_read(codec,
3220 spec->dmic_nids[i],
3221 0,
3222 AC_VERB_GET_CONFIG_DEFAULT,
3223 0);
3224 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3225 continue;
3226
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003227 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003228 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003229 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003230 con_lst,
3231 HDA_MAX_NUM_INPUTS);
3232 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003233 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003234 index = j;
3235 goto found;
3236 }
3237 continue;
3238found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003239 wcaps = get_wcaps(codec, nid) &
3240 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003241
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003242 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003243 sprintf(name, "%s Capture Volume",
3244 stac92xx_dmic_labels[dimux->num_items]);
3245
3246 err = stac92xx_add_control(spec,
3247 STAC_CTL_WIDGET_VOL,
3248 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003249 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3250 (wcaps & AC_WCAP_OUT_AMP) ?
3251 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003252 if (err < 0)
3253 return err;
3254 }
3255
Matt Porter8b657272006-10-26 17:12:59 +02003256 dimux->items[dimux->num_items].label =
3257 stac92xx_dmic_labels[dimux->num_items];
3258 dimux->items[dimux->num_items].index = index;
3259 dimux->num_items++;
3260 }
3261
3262 return 0;
3263}
3264
Mattc7d4b2f2005-06-27 14:59:41 +02003265/* create playback/capture controls for input pins */
3266static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3267{
3268 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003269 struct hda_input_mux *imux = &spec->private_imux;
3270 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3271 int i, j, k;
3272
3273 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003274 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003275
Takashi Iwai314634b2006-09-21 11:56:18 +02003276 if (!cfg->input_pins[i])
3277 continue;
3278 index = -1;
3279 for (j = 0; j < spec->num_muxes; j++) {
3280 int num_cons;
3281 num_cons = snd_hda_get_connections(codec,
3282 spec->mux_nids[j],
3283 con_lst,
3284 HDA_MAX_NUM_INPUTS);
3285 for (k = 0; k < num_cons; k++)
3286 if (con_lst[k] == cfg->input_pins[i]) {
3287 index = k;
3288 goto found;
3289 }
Mattc7d4b2f2005-06-27 14:59:41 +02003290 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003291 continue;
3292 found:
3293 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3294 imux->items[imux->num_items].index = index;
3295 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003296 }
3297
Steve Longerbeam7b043892007-05-03 20:50:03 +02003298 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003299 /*
3300 * Set the current input for the muxes.
3301 * The STAC9221 has two input muxes with identical source
3302 * NID lists. Hopefully this won't get confused.
3303 */
3304 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003305 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3306 AC_VERB_SET_CONNECT_SEL,
3307 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003308 }
3309 }
3310
Mattc7d4b2f2005-06-27 14:59:41 +02003311 return 0;
3312}
3313
Mattc7d4b2f2005-06-27 14:59:41 +02003314static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3315{
3316 struct sigmatel_spec *spec = codec->spec;
3317 int i;
3318
3319 for (i = 0; i < spec->autocfg.line_outs; i++) {
3320 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3321 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3322 }
3323}
3324
3325static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3326{
3327 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003328 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003329
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003330 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3331 hda_nid_t pin;
3332 pin = spec->autocfg.hp_pins[i];
3333 if (pin) /* connect to front */
3334 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3335 }
3336 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3337 hda_nid_t pin;
3338 pin = spec->autocfg.speaker_pins[i];
3339 if (pin) /* connect to front */
3340 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3341 }
Mattc7d4b2f2005-06-27 14:59:41 +02003342}
3343
Matt Porter3cc08dc2006-01-23 15:27:49 +01003344static 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 +02003345{
3346 struct sigmatel_spec *spec = codec->spec;
3347 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003348 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003349
Matt Porter8b657272006-10-26 17:12:59 +02003350 if ((err = snd_hda_parse_pin_def_config(codec,
3351 &spec->autocfg,
3352 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003353 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003354 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003355 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003356
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003357 /* If we have no real line-out pin and multiple hp-outs, HPs should
3358 * be set up as multi-channel outputs.
3359 */
3360 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3361 spec->autocfg.hp_outs > 1) {
3362 /* Copy hp_outs to line_outs, backup line_outs in
3363 * speaker_outs so that the following routines can handle
3364 * HP pins as primary outputs.
3365 */
3366 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3367 sizeof(spec->autocfg.line_out_pins));
3368 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3369 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3370 sizeof(spec->autocfg.hp_pins));
3371 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3372 hp_speaker_swap = 1;
3373 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003374 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003375 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3376 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003377 u32 caps = query_amp_caps(codec,
3378 spec->autocfg.mono_out_pin, dir);
3379 hda_nid_t conn_list[1];
3380
3381 /* get the mixer node and then the mono mux if it exists */
3382 if (snd_hda_get_connections(codec,
3383 spec->autocfg.mono_out_pin, conn_list, 1) &&
3384 snd_hda_get_connections(codec, conn_list[0],
3385 conn_list, 1)) {
3386
3387 int wcaps = get_wcaps(codec, conn_list[0]);
3388 int wid_type = (wcaps & AC_WCAP_TYPE)
3389 >> AC_WCAP_TYPE_SHIFT;
3390 /* LR swap check, some stac925x have a mux that
3391 * changes the DACs output path instead of the
3392 * mono-mux path.
3393 */
3394 if (wid_type == AC_WID_AUD_SEL &&
3395 !(wcaps & AC_WCAP_LR_SWAP))
3396 spec->mono_nid = conn_list[0];
3397 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003398 if (dir) {
3399 hda_nid_t nid = spec->autocfg.mono_out_pin;
3400
3401 /* most mono outs have a least a mute/unmute switch */
3402 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3403 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3404 "Mono Playback Switch",
3405 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003406 if (err < 0)
3407 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003408 /* check for volume support for the amp */
3409 if ((caps & AC_AMPCAP_NUM_STEPS)
3410 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3411 err = stac92xx_add_control(spec,
3412 STAC_CTL_WIDGET_VOL,
3413 "Mono Playback Volume",
3414 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3415 if (err < 0)
3416 return err;
3417 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003418 }
3419
3420 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3421 AC_PINCTL_OUT_EN);
3422 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003423
Matt Porter403d1942005-11-29 15:00:51 +01003424 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3425 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003426 if (spec->multiout.num_dacs == 0)
3427 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3428 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003429
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003430 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3431
3432 if (err < 0)
3433 return err;
3434
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003435 /* setup analog beep controls */
3436 if (spec->anabeep_nid > 0) {
3437 err = stac92xx_auto_create_beep_ctls(codec,
3438 spec->anabeep_nid);
3439 if (err < 0)
3440 return err;
3441 }
3442
3443 /* setup digital beep controls and input device */
3444#ifdef CONFIG_SND_HDA_INPUT_BEEP
3445 if (spec->digbeep_nid > 0) {
3446 hda_nid_t nid = spec->digbeep_nid;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003447 unsigned int caps;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003448
3449 err = stac92xx_auto_create_beep_ctls(codec, nid);
3450 if (err < 0)
3451 return err;
3452 err = snd_hda_attach_beep_device(codec, nid);
3453 if (err < 0)
3454 return err;
Takashi Iwai4d4e9bb2008-11-12 16:45:04 +01003455 /* if no beep switch is available, make its own one */
3456 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3457 if (codec->beep &&
3458 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3459 err = stac92xx_beep_switch_ctl(codec);
3460 if (err < 0)
3461 return err;
3462 }
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003463 }
3464#endif
3465
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003466 if (hp_speaker_swap == 1) {
3467 /* Restore the hp_outs and line_outs */
3468 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3469 sizeof(spec->autocfg.line_out_pins));
3470 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3471 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3472 sizeof(spec->autocfg.speaker_pins));
3473 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3474 memset(spec->autocfg.speaker_pins, 0,
3475 sizeof(spec->autocfg.speaker_pins));
3476 spec->autocfg.speaker_outs = 0;
3477 }
3478
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003479 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3480
3481 if (err < 0)
3482 return err;
3483
3484 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3485
3486 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003487 return err;
3488
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003489 if (spec->mono_nid > 0) {
3490 err = stac92xx_auto_create_mono_output_ctls(codec);
3491 if (err < 0)
3492 return err;
3493 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003494 if (spec->num_amps > 0) {
Matthew Ranostay89385032008-09-11 09:49:39 -04003495 err = stac92xx_auto_create_amp_output_ctls(codec);
3496 if (err < 0)
3497 return err;
3498 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003499 if (spec->num_dmics > 0 && !spec->dinput_mux)
Matt Porter8b657272006-10-26 17:12:59 +02003500 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3501 &spec->autocfg)) < 0)
3502 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003503 if (spec->num_muxes > 0) {
3504 err = stac92xx_auto_create_mux_input_ctls(codec);
3505 if (err < 0)
3506 return err;
3507 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003508 if (spec->num_smuxes > 0) {
3509 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3510 if (err < 0)
3511 return err;
3512 }
Matt Porter8b657272006-10-26 17:12:59 +02003513
Mattc7d4b2f2005-06-27 14:59:41 +02003514 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003515 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003516 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003517
Takashi Iwai82bc9552006-03-21 11:24:42 +01003518 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003519 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003520 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003521 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003522
3523 if (spec->kctl_alloc)
3524 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3525
3526 spec->input_mux = &spec->private_imux;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04003527 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003528 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003529 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003530 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003531 return 1;
3532}
3533
Takashi Iwai82bc9552006-03-21 11:24:42 +01003534/* add playback controls for HP output */
3535static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3536 struct auto_pin_cfg *cfg)
3537{
3538 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003539 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003540 unsigned int wid_caps;
3541
3542 if (! pin)
3543 return 0;
3544
3545 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003546 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003547 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003548
3549 return 0;
3550}
3551
Richard Fish160ea0d2006-09-06 13:58:25 +02003552/* add playback controls for LFE output */
3553static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3554 struct auto_pin_cfg *cfg)
3555{
3556 struct sigmatel_spec *spec = codec->spec;
3557 int err;
3558 hda_nid_t lfe_pin = 0x0;
3559 int i;
3560
3561 /*
3562 * search speaker outs and line outs for a mono speaker pin
3563 * with an amp. If one is found, add LFE controls
3564 * for it.
3565 */
3566 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3567 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003568 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003569 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3570 if (wcaps == AC_WCAP_OUT_AMP)
3571 /* found a mono speaker with an amp, must be lfe */
3572 lfe_pin = pin;
3573 }
3574
3575 /* if speaker_outs is 0, then speakers may be in line_outs */
3576 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3577 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3578 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003579 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003580 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003581 AC_VERB_GET_CONFIG_DEFAULT,
3582 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003583 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003584 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003585 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3586 if (wcaps == AC_WCAP_OUT_AMP)
3587 /* found a mono speaker with an amp,
3588 must be lfe */
3589 lfe_pin = pin;
3590 }
3591 }
3592 }
3593
3594 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003595 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003596 if (err < 0)
3597 return err;
3598 }
3599
3600 return 0;
3601}
3602
Mattc7d4b2f2005-06-27 14:59:41 +02003603static int stac9200_parse_auto_config(struct hda_codec *codec)
3604{
3605 struct sigmatel_spec *spec = codec->spec;
3606 int err;
3607
Kailang Yangdf694da2005-12-05 19:42:22 +01003608 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003609 return err;
3610
3611 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3612 return err;
3613
Takashi Iwai82bc9552006-03-21 11:24:42 +01003614 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3615 return err;
3616
Richard Fish160ea0d2006-09-06 13:58:25 +02003617 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3618 return err;
3619
Takashi Iwai355a0ec2008-11-11 16:46:19 +01003620 if (spec->num_muxes > 0) {
3621 err = stac92xx_auto_create_mux_input_ctls(codec);
3622 if (err < 0)
3623 return err;
3624 }
3625
Takashi Iwai82bc9552006-03-21 11:24:42 +01003626 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003627 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003628 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003629 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003630
3631 if (spec->kctl_alloc)
3632 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3633
3634 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003635 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003636
3637 return 1;
3638}
3639
Sam Revitch62fe78e2006-05-10 15:09:17 +02003640/*
3641 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3642 * funky external mute control using GPIO pins.
3643 */
3644
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003645static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003646 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003647{
3648 unsigned int gpiostate, gpiomask, gpiodir;
3649
3650 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3651 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003652 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003653
3654 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3655 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003656 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003657
3658 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3659 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003660 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003661
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003662 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003663 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3664
3665 snd_hda_codec_write(codec, codec->afg, 0,
3666 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003667 snd_hda_codec_read(codec, codec->afg, 0,
3668 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003669
3670 msleep(1);
3671
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003672 snd_hda_codec_read(codec, codec->afg, 0,
3673 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003674}
3675
Takashi Iwai314634b2006-09-21 11:56:18 +02003676static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3677 unsigned int event)
3678{
3679 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003680 snd_hda_codec_write_cache(codec, nid, 0,
3681 AC_VERB_SET_UNSOLICITED_ENABLE,
3682 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003683}
3684
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003685static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3686{
3687 int i;
3688 for (i = 0; i < cfg->hp_outs; i++)
3689 if (cfg->hp_pins[i] == nid)
3690 return 1; /* nid is a HP-Out */
3691
3692 return 0; /* nid is not a HP-Out */
3693};
3694
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003695static void stac92xx_power_down(struct hda_codec *codec)
3696{
3697 struct sigmatel_spec *spec = codec->spec;
3698
3699 /* power down inactive DACs */
3700 hda_nid_t *dac;
3701 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003702 if (!is_in_dac_nids(spec, *dac) &&
3703 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003704 snd_hda_codec_write_cache(codec, *dac, 0,
3705 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3706}
3707
Takashi Iwaif73d3582008-11-25 08:21:51 +01003708static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3709 int enable);
3710
Mattc7d4b2f2005-06-27 14:59:41 +02003711static int stac92xx_init(struct hda_codec *codec)
3712{
3713 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003714 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003715 unsigned int gpio;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003716 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003717
Mattc7d4b2f2005-06-27 14:59:41 +02003718 snd_hda_sequence_write(codec, spec->init);
3719
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003720 /* power down adcs initially */
3721 if (spec->powerdown_adcs)
3722 for (i = 0; i < spec->num_adcs; i++)
3723 snd_hda_codec_write_cache(codec,
3724 spec->adc_nids[i], 0,
3725 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003726
3727 /* set up GPIO */
3728 gpio = spec->gpio_data;
3729 /* turn on EAPD statically when spec->eapd_switch isn't set.
3730 * otherwise, unsol event will turn it on/off dynamically
3731 */
3732 if (!spec->eapd_switch)
3733 gpio |= spec->eapd_mask;
3734 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3735
Takashi Iwai82bc9552006-03-21 11:24:42 +01003736 /* set up pins */
3737 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003738 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003739 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003740 enable_pin_detect(codec, cfg->hp_pins[i],
3741 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01003742 /* force to enable the first line-out; the others are set up
3743 * in unsol_event
3744 */
3745 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3746 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003747 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003748 /* fake event to set up pins */
3749 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3750 } else {
3751 stac92xx_auto_init_multi_out(codec);
3752 stac92xx_auto_init_hp_out(codec);
3753 }
3754 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003755 hda_nid_t nid = cfg->input_pins[i];
3756 if (nid) {
Takashi Iwai4f1e6bc2008-11-11 16:47:24 +01003757 unsigned int pinctl;
3758 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3759 /* for mic pins, force to initialize */
3760 pinctl = stac92xx_get_vref(codec, nid);
3761 } else {
3762 pinctl = snd_hda_codec_read(codec, nid, 0,
3763 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3764 /* if PINCTL already set then skip */
3765 if (pinctl & AC_PINCTL_IN_EN)
3766 continue;
3767 }
3768 pinctl |= AC_PINCTL_IN_EN;
Takashi Iwaic960a032006-03-23 17:06:28 +01003769 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3770 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003771 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003772 for (i = 0; i < spec->num_dmics; i++)
3773 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3774 AC_PINCTL_IN_EN);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003775 if (cfg->dig_out_pin)
3776 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3777 AC_PINCTL_OUT_EN);
3778 if (cfg->dig_in_pin)
3779 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3780 AC_PINCTL_IN_EN);
Takashi Iwaif73d3582008-11-25 08:21:51 +01003781 for (i = 0; i < spec->num_pwrs; i++) {
3782 hda_nid_t nid = spec->pwr_nids[i];
3783 int pinctl, def_conf;
3784 int event = STAC_PWR_EVENT;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003785
Takashi Iwaif73d3582008-11-25 08:21:51 +01003786 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3787 continue; /* already has an unsol event */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003788
Takashi Iwaif73d3582008-11-25 08:21:51 +01003789 pinctl = snd_hda_codec_read(codec, nid, 0,
3790 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3791 /* outputs are only ports capable of power management
3792 * any attempts on powering down a input port cause the
3793 * referenced VREF to act quirky.
3794 */
3795 if (pinctl & AC_PINCTL_IN_EN)
3796 continue;
3797 def_conf = snd_hda_codec_read(codec, nid, 0,
3798 AC_VERB_GET_CONFIG_DEFAULT, 0);
3799 def_conf = get_defcfg_connect(def_conf);
3800 /* skip any ports that don't have jacks since presence
3801 * detection is useless */
3802 if (def_conf != AC_JACK_PORT_COMPLEX) {
3803 if (def_conf != AC_JACK_PORT_NONE)
3804 stac_toggle_power_map(codec, nid, 1);
3805 continue;
3806 }
3807 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3808 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3809 }
3810 if (spec->dac_list)
3811 stac92xx_power_down(codec);
Mattc7d4b2f2005-06-27 14:59:41 +02003812 return 0;
3813}
3814
Matt2f2f4252005-04-13 14:45:30 +02003815static void stac92xx_free(struct hda_codec *codec)
3816{
Mattc7d4b2f2005-06-27 14:59:41 +02003817 struct sigmatel_spec *spec = codec->spec;
3818 int i;
3819
3820 if (! spec)
3821 return;
3822
3823 if (spec->kctl_alloc) {
3824 for (i = 0; i < spec->num_kctl_used; i++)
3825 kfree(spec->kctl_alloc[i].name);
3826 kfree(spec->kctl_alloc);
3827 }
3828
Richard Fish11b44bb2006-08-23 18:31:34 +02003829 if (spec->bios_pin_configs)
3830 kfree(spec->bios_pin_configs);
3831
Mattc7d4b2f2005-06-27 14:59:41 +02003832 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003833 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003834}
3835
Matt4e550962005-07-04 17:51:39 +02003836static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3837 unsigned int flag)
3838{
3839 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3840 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003841
Takashi Iwaif9acba42007-05-29 18:01:06 +02003842 if (pin_ctl & AC_PINCTL_IN_EN) {
3843 /*
3844 * we need to check the current set-up direction of
3845 * shared input pins since they can be switched via
3846 * "xxx as Output" mixer switch
3847 */
3848 struct sigmatel_spec *spec = codec->spec;
3849 struct auto_pin_cfg *cfg = &spec->autocfg;
3850 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3851 spec->line_switch) ||
3852 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3853 spec->mic_switch))
3854 return;
3855 }
3856
Steve Longerbeam7b043892007-05-03 20:50:03 +02003857 /* if setting pin direction bits, clear the current
3858 direction bits first */
3859 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3860 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3861
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003862 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003863 AC_VERB_SET_PIN_WIDGET_CONTROL,
3864 pin_ctl | flag);
3865}
3866
3867static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3868 unsigned int flag)
3869{
3870 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3871 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003872 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003873 AC_VERB_SET_PIN_WIDGET_CONTROL,
3874 pin_ctl & ~flag);
3875}
3876
Jiang Zhe40c1d302007-11-12 13:05:16 +01003877static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003878{
3879 if (!nid)
3880 return 0;
3881 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003882 & (1 << 31)) {
3883 unsigned int pinctl;
3884 pinctl = snd_hda_codec_read(codec, nid, 0,
3885 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3886 if (pinctl & AC_PINCTL_IN_EN)
3887 return 0; /* mic- or line-input */
3888 else
3889 return 1; /* HP-output */
3890 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003891 return 0;
3892}
3893
Takashi Iwaid7a89432008-11-12 09:48:04 +01003894/* return non-zero if the hp-pin of the given array index isn't
3895 * a jack-detection target
3896 */
3897static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3898{
3899 struct auto_pin_cfg *cfg = &spec->autocfg;
3900
3901 /* ignore sensing of shared line and mic jacks */
3902 if (spec->line_switch &&
3903 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3904 return 1;
3905 if (spec->mic_switch &&
3906 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3907 return 1;
3908 /* ignore if the pin is set as line-out */
3909 if (cfg->hp_pins[i] == spec->hp_switch)
3910 return 1;
3911 return 0;
3912}
3913
Takashi Iwai314634b2006-09-21 11:56:18 +02003914static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003915{
3916 struct sigmatel_spec *spec = codec->spec;
3917 struct auto_pin_cfg *cfg = &spec->autocfg;
3918 int i, presence;
3919
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003920 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003921 if (spec->gpio_mute)
3922 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3923 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3924
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003925 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003926 if (presence)
3927 break;
Takashi Iwaid7a89432008-11-12 09:48:04 +01003928 if (no_hp_sensing(spec, i))
3929 continue;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003930 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003931 }
Matt4e550962005-07-04 17:51:39 +02003932
3933 if (presence) {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003934 /* disable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003935 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003936 stac92xx_reset_pinctl(codec, spec->hp_switch,
3937 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003938 for (i = 0; i < cfg->line_outs; i++)
3939 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3940 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003941 for (i = 0; i < cfg->speaker_outs; i++)
3942 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3943 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003944 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003945 stac_gpio_set(codec, spec->gpio_mask,
3946 spec->gpio_dir, spec->gpio_data &
3947 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003948 } else {
Takashi Iwaid7a89432008-11-12 09:48:04 +01003949 /* enable lineouts */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003950 if (spec->hp_switch)
Takashi Iwaid7a89432008-11-12 09:48:04 +01003951 stac92xx_set_pinctl(codec, spec->hp_switch,
3952 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003953 for (i = 0; i < cfg->line_outs; i++)
3954 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3955 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003956 for (i = 0; i < cfg->speaker_outs; i++)
3957 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3958 AC_PINCTL_OUT_EN);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05003959 if (spec->eapd_mask && spec->eapd_switch)
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003960 stac_gpio_set(codec, spec->gpio_mask,
3961 spec->gpio_dir, spec->gpio_data |
3962 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003963 }
Takashi Iwaid7a89432008-11-12 09:48:04 +01003964 /* toggle hp outs */
3965 for (i = 0; i < cfg->hp_outs; i++) {
3966 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3967 if (no_hp_sensing(spec, i))
3968 continue;
3969 if (presence)
3970 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3971 else
3972 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3973 }
Matt4e550962005-07-04 17:51:39 +02003974}
3975
Takashi Iwaif73d3582008-11-25 08:21:51 +01003976static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3977 int enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003978{
3979 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaif73d3582008-11-25 08:21:51 +01003980 unsigned int idx, val;
3981
3982 for (idx = 0; idx < spec->num_pwrs; idx++) {
3983 if (spec->pwr_nids[idx] == nid)
3984 break;
3985 }
3986 if (idx >= spec->num_pwrs)
3987 return;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003988
3989 /* several codecs have two power down bits */
3990 if (spec->pwr_mapping)
3991 idx = spec->pwr_mapping[idx];
3992 else
3993 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003994
Takashi Iwaif73d3582008-11-25 08:21:51 +01003995 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
3996 if (enable)
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003997 val &= ~idx;
3998 else
3999 val |= idx;
4000
4001 /* power down unused output ports */
4002 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
Takashi Iwaif73d3582008-11-25 08:21:51 +01004003}
4004
4005static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4006{
4007 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4008}
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004009
Takashi Iwai314634b2006-09-21 11:56:18 +02004010static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4011{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004012 struct sigmatel_spec *spec = codec->spec;
4013 int idx = res >> 26 & 0x0f;
4014
Matthew Ranostay72474be2008-10-09 09:32:17 -04004015 switch ((res >> 26) & 0x70) {
Takashi Iwai314634b2006-09-21 11:56:18 +02004016 case STAC_HP_EVENT:
4017 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004018 /* fallthru */
4019 case STAC_PWR_EVENT:
4020 if (spec->num_pwrs > 0)
4021 stac92xx_pin_sense(codec, idx);
Matthew Ranostay72474be2008-10-09 09:32:17 -04004022 break;
4023 case STAC_VREF_EVENT: {
4024 int data = snd_hda_codec_read(codec, codec->afg, 0,
4025 AC_VERB_GET_GPIO_DATA, 0);
4026 /* toggle VREF state based on GPIOx status */
4027 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4028 !!(data & (1 << idx)));
4029 break;
4030 }
Takashi Iwai314634b2006-09-21 11:56:18 +02004031 }
4032}
4033
Takashi Iwaicb53c622007-08-10 17:21:45 +02004034#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004035static int stac92xx_resume(struct hda_codec *codec)
4036{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004037 struct sigmatel_spec *spec = codec->spec;
4038
Richard Fish11b44bb2006-08-23 18:31:34 +02004039 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004040 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004041 stac_gpio_set(codec, spec->gpio_mask,
4042 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004043 snd_hda_codec_resume_amp(codec);
4044 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004045 /* power down inactive DACs */
4046 if (spec->dac_list)
4047 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02004048 /* invoke unsolicited event to reset the HP state */
4049 if (spec->hp_detect)
4050 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02004051 return 0;
4052}
4053#endif
4054
Matt2f2f4252005-04-13 14:45:30 +02004055static struct hda_codec_ops stac92xx_patch_ops = {
4056 .build_controls = stac92xx_build_controls,
4057 .build_pcms = stac92xx_build_pcms,
4058 .init = stac92xx_init,
4059 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02004060 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004061#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02004062 .resume = stac92xx_resume,
4063#endif
Matt2f2f4252005-04-13 14:45:30 +02004064};
4065
4066static int patch_stac9200(struct hda_codec *codec)
4067{
4068 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004069 int err;
Matt2f2f4252005-04-13 14:45:30 +02004070
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004071 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004072 if (spec == NULL)
4073 return -ENOMEM;
4074
4075 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004076 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004077 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004078 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4079 stac9200_models,
4080 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02004081 if (spec->board_config < 0) {
4082 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4083 err = stac92xx_save_bios_config_regs(codec);
4084 if (err < 0) {
4085 stac92xx_free(codec);
4086 return err;
4087 }
4088 spec->pin_configs = spec->bios_pin_configs;
4089 } else {
Matt Porter403d1942005-11-29 15:00:51 +01004090 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4091 stac92xx_set_config_regs(codec);
4092 }
Matt2f2f4252005-04-13 14:45:30 +02004093
4094 spec->multiout.max_channels = 2;
4095 spec->multiout.num_dacs = 1;
4096 spec->multiout.dac_nids = stac9200_dac_nids;
4097 spec->adc_nids = stac9200_adc_nids;
4098 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02004099 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02004100 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004101 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004102 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004103
Tobin Davisbf277782008-02-03 20:31:47 +01004104 if (spec->board_config == STAC_9200_GATEWAY ||
4105 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02004106 spec->init = stac9200_eapd_init;
4107 else
4108 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004109 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004110
Takashi Iwai117f2572008-03-18 09:53:23 +01004111 if (spec->board_config == STAC_9200_PANASONIC) {
4112 spec->gpio_mask = spec->gpio_dir = 0x09;
4113 spec->gpio_data = 0x00;
4114 }
4115
Mattc7d4b2f2005-06-27 14:59:41 +02004116 err = stac9200_parse_auto_config(codec);
4117 if (err < 0) {
4118 stac92xx_free(codec);
4119 return err;
4120 }
Matt2f2f4252005-04-13 14:45:30 +02004121
4122 codec->patch_ops = stac92xx_patch_ops;
4123
4124 return 0;
4125}
4126
Tobin Davis8e21c342007-01-08 11:04:17 +01004127static int patch_stac925x(struct hda_codec *codec)
4128{
4129 struct sigmatel_spec *spec;
4130 int err;
4131
4132 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4133 if (spec == NULL)
4134 return -ENOMEM;
4135
4136 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004137 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01004138 spec->pin_nids = stac925x_pin_nids;
4139 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4140 stac925x_models,
4141 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004142 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01004143 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02004144 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4145 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01004146 err = stac92xx_save_bios_config_regs(codec);
4147 if (err < 0) {
4148 stac92xx_free(codec);
4149 return err;
4150 }
4151 spec->pin_configs = spec->bios_pin_configs;
4152 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4153 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4154 stac92xx_set_config_regs(codec);
4155 }
4156
4157 spec->multiout.max_channels = 2;
4158 spec->multiout.num_dacs = 1;
4159 spec->multiout.dac_nids = stac925x_dac_nids;
4160 spec->adc_nids = stac925x_adc_nids;
4161 spec->mux_nids = stac925x_mux_nids;
4162 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004163 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004164 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02004165 switch (codec->vendor_id) {
4166 case 0x83847632: /* STAC9202 */
4167 case 0x83847633: /* STAC9202D */
4168 case 0x83847636: /* STAC9251 */
4169 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02004170 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02004171 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004172 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4173 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02004174 break;
4175 default:
4176 spec->num_dmics = 0;
4177 break;
4178 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004179
4180 spec->init = stac925x_core_init;
4181 spec->mixer = stac925x_mixer;
4182
4183 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004184 if (!err) {
4185 if (spec->board_config < 0) {
4186 printk(KERN_WARNING "hda_codec: No auto-config is "
4187 "available, default to model=ref\n");
4188 spec->board_config = STAC_925x_REF;
4189 goto again;
4190 }
4191 err = -EINVAL;
4192 }
Tobin Davis8e21c342007-01-08 11:04:17 +01004193 if (err < 0) {
4194 stac92xx_free(codec);
4195 return err;
4196 }
4197
4198 codec->patch_ops = stac92xx_patch_ops;
4199
4200 return 0;
4201}
4202
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004203static struct hda_input_mux stac92hd73xx_dmux = {
4204 .num_items = 4,
4205 .items = {
4206 { "Analog Inputs", 0x0b },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004207 { "Digital Mic 1", 0x09 },
4208 { "Digital Mic 2", 0x0a },
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004209 { "CD", 0x08 },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004210 }
4211};
4212
4213static int patch_stac92hd73xx(struct hda_codec *codec)
4214{
4215 struct sigmatel_spec *spec;
4216 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4217 int err = 0;
4218
4219 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4220 if (spec == NULL)
4221 return -ENOMEM;
4222
4223 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02004224 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004225 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4226 spec->pin_nids = stac92hd73xx_pin_nids;
4227 spec->board_config = snd_hda_check_board_config(codec,
4228 STAC_92HD73XX_MODELS,
4229 stac92hd73xx_models,
4230 stac92hd73xx_cfg_tbl);
4231again:
4232 if (spec->board_config < 0) {
4233 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4234 " STAC92HD73XX, using BIOS defaults\n");
4235 err = stac92xx_save_bios_config_regs(codec);
4236 if (err < 0) {
4237 stac92xx_free(codec);
4238 return err;
4239 }
4240 spec->pin_configs = spec->bios_pin_configs;
4241 } else {
4242 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4243 stac92xx_set_config_regs(codec);
4244 }
4245
4246 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4247 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4248
4249 if (spec->multiout.num_dacs < 0) {
4250 printk(KERN_WARNING "hda_codec: Could not determine "
4251 "number of channels defaulting to DAC count\n");
4252 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4253 }
4254
4255 switch (spec->multiout.num_dacs) {
4256 case 0x3: /* 6 Channel */
4257 spec->mixer = stac92hd73xx_6ch_mixer;
4258 spec->init = stac92hd73xx_6ch_core_init;
4259 break;
4260 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004261 spec->mixer = stac92hd73xx_8ch_mixer;
4262 spec->init = stac92hd73xx_8ch_core_init;
4263 break;
4264 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004265 spec->mixer = stac92hd73xx_10ch_mixer;
4266 spec->init = stac92hd73xx_10ch_core_init;
4267 };
4268
4269 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4270 spec->aloopback_mask = 0x01;
4271 spec->aloopback_shift = 8;
4272
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004273 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004274 spec->mux_nids = stac92hd73xx_mux_nids;
4275 spec->adc_nids = stac92hd73xx_adc_nids;
4276 spec->dmic_nids = stac92hd73xx_dmic_nids;
4277 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004278 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004279 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004280 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004281
4282 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4283 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai1697055e2007-12-18 18:05:52 +01004284 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004285 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4286 sizeof(stac92hd73xx_dmux));
4287
Matthew Ranostaya7662642008-02-21 07:51:14 +01004288 switch (spec->board_config) {
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004289 case STAC_DELL_EQ:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004290 spec->init = dell_eq_core_init;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004291 /* fallthru */
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004292 case STAC_DELL_M6_AMIC:
4293 case STAC_DELL_M6_DMIC:
4294 case STAC_DELL_M6_BOTH:
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004295 spec->num_smuxes = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004296 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4297 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004298 spec->eapd_switch = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004299 spec->num_amps = 1;
Matthew Ranostay6b3ab212008-11-03 08:12:43 -05004300
4301 if (!spec->init)
4302 spec->init = dell_m6_core_init;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004303 switch (spec->board_config) {
4304 case STAC_DELL_M6_AMIC: /* Analog Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004305 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4306 spec->num_dmics = 0;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004307 spec->private_dimux.num_items = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004308 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004309 case STAC_DELL_M6_DMIC: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004310 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4311 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004312 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004313 break;
Takashi Iwai661cd8f2008-11-25 15:18:29 +01004314 case STAC_DELL_M6_BOTH: /* Both */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004315 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4316 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4317 spec->num_dmics = 1;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004318 spec->private_dimux.num_items = 2;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004319 break;
4320 }
4321 break;
4322 default:
4323 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004324 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004325 spec->eapd_switch = 1;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004326 }
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004327 if (spec->board_config > STAC_92HD73XX_REF) {
4328 /* GPIO0 High = Enable EAPD */
4329 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4330 spec->gpio_data = 0x01;
4331 }
Matthew Ranostay2a9c7812008-09-13 16:45:39 -04004332 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004333
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004334 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4335 spec->pwr_nids = stac92hd73xx_pwr_nids;
4336
Matthew Ranostayd9737752008-09-07 12:03:41 +02004337 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004338
4339 if (!err) {
4340 if (spec->board_config < 0) {
4341 printk(KERN_WARNING "hda_codec: No auto-config is "
4342 "available, default to model=ref\n");
4343 spec->board_config = STAC_92HD73XX_REF;
4344 goto again;
4345 }
4346 err = -EINVAL;
4347 }
4348
4349 if (err < 0) {
4350 stac92xx_free(codec);
4351 return err;
4352 }
4353
4354 codec->patch_ops = stac92xx_patch_ops;
4355
4356 return 0;
4357}
4358
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004359static struct hda_input_mux stac92hd83xxx_dmux = {
4360 .num_items = 3,
4361 .items = {
4362 { "Analog Inputs", 0x03 },
4363 { "Digital Mic 1", 0x04 },
4364 { "Digital Mic 2", 0x05 },
4365 }
4366};
4367
4368static int patch_stac92hd83xxx(struct hda_codec *codec)
4369{
4370 struct sigmatel_spec *spec;
4371 int err;
4372
4373 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4374 if (spec == NULL)
4375 return -ENOMEM;
4376
4377 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004378 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004379 spec->mono_nid = 0x19;
4380 spec->digbeep_nid = 0x21;
4381 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4382 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4383 spec->adc_nids = stac92hd83xxx_adc_nids;
4384 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4385 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4386 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4387 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4388
4389 spec->init = stac92hd83xxx_core_init;
4390 switch (codec->vendor_id) {
4391 case 0x111d7605:
4392 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4393 break;
4394 default:
4395 spec->num_pwrs--;
4396 spec->init++; /* switch to config #2 */
4397 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4398 }
4399
4400 spec->mixer = stac92hd83xxx_mixer;
4401 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4402 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4403 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4404 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4405 spec->dinput_mux = &stac92hd83xxx_dmux;
4406 spec->pin_nids = stac92hd83xxx_pin_nids;
4407 spec->board_config = snd_hda_check_board_config(codec,
4408 STAC_92HD83XXX_MODELS,
4409 stac92hd83xxx_models,
4410 stac92hd83xxx_cfg_tbl);
4411again:
4412 if (spec->board_config < 0) {
4413 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4414 " STAC92HD83XXX, using BIOS defaults\n");
4415 err = stac92xx_save_bios_config_regs(codec);
4416 if (err < 0) {
4417 stac92xx_free(codec);
4418 return err;
4419 }
4420 spec->pin_configs = spec->bios_pin_configs;
4421 } else {
4422 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4423 stac92xx_set_config_regs(codec);
4424 }
4425
4426 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4427 if (!err) {
4428 if (spec->board_config < 0) {
4429 printk(KERN_WARNING "hda_codec: No auto-config is "
4430 "available, default to model=ref\n");
4431 spec->board_config = STAC_92HD83XXX_REF;
4432 goto again;
4433 }
4434 err = -EINVAL;
4435 }
4436
4437 if (err < 0) {
4438 stac92xx_free(codec);
4439 return err;
4440 }
4441
4442 codec->patch_ops = stac92xx_patch_ops;
4443
4444 return 0;
4445}
4446
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004447#ifdef SND_HDA_NEEDS_RESUME
4448static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4449{
4450 struct sigmatel_spec *spec = codec->spec;
4451 int i;
4452 snd_hda_codec_write_cache(codec, codec->afg, 0,
4453 AC_VERB_SET_POWER_STATE, pwr);
4454
4455 msleep(1);
4456 for (i = 0; i < spec->num_adcs; i++) {
4457 snd_hda_codec_write_cache(codec,
4458 spec->adc_nids[i], 0,
4459 AC_VERB_SET_POWER_STATE, pwr);
4460 }
4461};
4462
4463static int stac92hd71xx_resume(struct hda_codec *codec)
4464{
4465 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4466 return stac92xx_resume(codec);
4467}
4468
4469static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4470{
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004471 struct sigmatel_spec *spec = codec->spec;
4472
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004473 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004474 if (spec->eapd_mask)
4475 stac_gpio_set(codec, spec->gpio_mask,
4476 spec->gpio_dir, spec->gpio_data &
4477 ~spec->eapd_mask);
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004478 return 0;
4479};
4480
4481#endif
4482
4483static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4484 .build_controls = stac92xx_build_controls,
4485 .build_pcms = stac92xx_build_pcms,
4486 .init = stac92xx_init,
4487 .free = stac92xx_free,
4488 .unsol_event = stac92xx_unsol_event,
4489#ifdef SND_HDA_NEEDS_RESUME
4490 .resume = stac92hd71xx_resume,
4491 .suspend = stac92hd71xx_suspend,
4492#endif
4493};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004494
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004495static struct hda_input_mux stac92hd71bxx_dmux = {
4496 .num_items = 4,
4497 .items = {
4498 { "Analog Inputs", 0x00 },
4499 { "Mixer", 0x01 },
4500 { "Digital Mic 1", 0x02 },
4501 { "Digital Mic 2", 0x03 },
4502 }
4503};
4504
Matthew Ranostaye035b842007-11-06 11:53:55 +01004505static int patch_stac92hd71bxx(struct hda_codec *codec)
4506{
4507 struct sigmatel_spec *spec;
4508 int err = 0;
4509
4510 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4511 if (spec == NULL)
4512 return -ENOMEM;
4513
4514 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004515 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004516 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004517 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004518 spec->pin_nids = stac92hd71bxx_pin_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004519 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4520 sizeof(stac92hd71bxx_dmux));
Matthew Ranostaye035b842007-11-06 11:53:55 +01004521 spec->board_config = snd_hda_check_board_config(codec,
4522 STAC_92HD71BXX_MODELS,
4523 stac92hd71bxx_models,
4524 stac92hd71bxx_cfg_tbl);
4525again:
4526 if (spec->board_config < 0) {
4527 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4528 " STAC92HD71BXX, using BIOS defaults\n");
4529 err = stac92xx_save_bios_config_regs(codec);
4530 if (err < 0) {
4531 stac92xx_free(codec);
4532 return err;
4533 }
4534 spec->pin_configs = spec->bios_pin_configs;
4535 } else {
4536 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4537 stac92xx_set_config_regs(codec);
4538 }
4539
Takashi Iwai41c3b642008-11-18 10:45:15 +01004540 if (spec->board_config > STAC_92HD71BXX_REF) {
4541 /* GPIO0 = EAPD */
4542 spec->gpio_mask = 0x01;
4543 spec->gpio_dir = 0x01;
4544 spec->gpio_data = 0x01;
4545 }
4546
Matthew Ranostay541eee82007-12-14 12:08:04 +01004547 switch (codec->vendor_id) {
4548 case 0x111d76b6: /* 4 Port without Analog Mixer */
4549 case 0x111d76b7:
4550 case 0x111d76b4: /* 6 Port without Analog Mixer */
4551 case 0x111d76b5:
4552 spec->mixer = stac92hd71bxx_mixer;
4553 spec->init = stac92hd71bxx_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 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004556 case 0x111d7608: /* 5 Port with Analog Mixer */
Takashi Iwai8e5f2622008-11-15 19:28:54 +01004557 switch (spec->board_config) {
4558 case STAC_HP_M4:
Matthew Ranostay72474be2008-10-09 09:32:17 -04004559 /* Enable VREF power saving on GPIO1 detect */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004560 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay72474be2008-10-09 09:32:17 -04004561 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4562 snd_hda_codec_write_cache(codec, codec->afg, 0,
4563 AC_VERB_SET_UNSOLICITED_ENABLE,
4564 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4565 spec->gpio_mask |= 0x02;
4566 break;
4567 }
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004568 if ((codec->revision_id & 0xf) == 0 ||
4569 (codec->revision_id & 0xf) == 1) {
4570#ifdef SND_HDA_NEEDS_RESUME
4571 codec->patch_ops = stac92hd71bxx_patch_ops;
4572#endif
4573 spec->stream_delay = 40; /* 40 milliseconds */
4574 }
4575
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004576 /* no output amps */
4577 spec->num_pwrs = 0;
4578 spec->mixer = stac92hd71bxx_analog_mixer;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004579 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004580
4581 /* disable VSW */
4582 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4583 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4584 break;
4585 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004586 if ((codec->revision_id & 0xf) == 1) {
4587#ifdef SND_HDA_NEEDS_RESUME
4588 codec->patch_ops = stac92hd71bxx_patch_ops;
4589#endif
4590 spec->stream_delay = 40; /* 40 milliseconds */
4591 }
4592
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004593 /* no output amps */
4594 spec->num_pwrs = 0;
4595 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004596 default:
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004597 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004598 spec->mixer = stac92hd71bxx_analog_mixer;
4599 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004600 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004601 }
4602
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004603 spec->aloopback_mask = 0x50;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004604 spec->aloopback_shift = 0;
4605
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004606 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004607 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004608 spec->mux_nids = stac92hd71bxx_mux_nids;
4609 spec->adc_nids = stac92hd71bxx_adc_nids;
4610 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004611 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004612 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004613 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004614
4615 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4616 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004617
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004618 switch (spec->board_config) {
4619 case STAC_HP_M4:
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004620 /* enable internal microphone */
Matthew Ranostayb9aea712008-10-09 08:37:28 -04004621 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4622 stac92xx_auto_set_pinctl(codec, 0x0e,
4623 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
Matthew Ranostay3a7abfd2008-11-20 21:21:43 -05004624 /* fallthru */
4625 case STAC_DELL_M4_2:
4626 spec->num_dmics = 0;
4627 spec->num_smuxes = 0;
4628 spec->num_dmuxes = 0;
4629 break;
4630 case STAC_DELL_M4_1:
4631 case STAC_DELL_M4_3:
4632 spec->num_dmics = 1;
4633 spec->num_smuxes = 0;
4634 spec->num_dmuxes = 0;
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004635 break;
4636 default:
4637 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4638 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4639 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4640 };
4641
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004642 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004643 spec->multiout.hp_nid = 0x11;
4644 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
Matthew Ranostay4b33c762008-10-10 09:07:23 -04004645 if (spec->dinput_mux)
4646 spec->private_dimux.num_items +=
4647 spec->num_dmics -
4648 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004649
4650 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4651 if (!err) {
4652 if (spec->board_config < 0) {
4653 printk(KERN_WARNING "hda_codec: No auto-config is "
4654 "available, default to model=ref\n");
4655 spec->board_config = STAC_92HD71BXX_REF;
4656 goto again;
4657 }
4658 err = -EINVAL;
4659 }
4660
4661 if (err < 0) {
4662 stac92xx_free(codec);
4663 return err;
4664 }
4665
Matthew Ranostaye035b842007-11-06 11:53:55 +01004666 return 0;
4667};
4668
Matt2f2f4252005-04-13 14:45:30 +02004669static int patch_stac922x(struct hda_codec *codec)
4670{
4671 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004672 int err;
Matt2f2f4252005-04-13 14:45:30 +02004673
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004674 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004675 if (spec == NULL)
4676 return -ENOMEM;
4677
4678 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004679 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004680 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004681 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4682 stac922x_models,
4683 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004684 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004685 spec->gpio_mask = spec->gpio_dir = 0x03;
4686 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004687 /* Intel Macs have all same PCI SSID, so we need to check
4688 * codec SSID to distinguish the exact models
4689 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004690 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004691 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004692
4693 case 0x106b0800:
4694 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004695 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004696 case 0x106b0600:
4697 case 0x106b0700:
4698 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004699 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004700 case 0x106b0e00:
4701 case 0x106b0f00:
4702 case 0x106b1600:
4703 case 0x106b1700:
4704 case 0x106b0200:
4705 case 0x106b1e00:
4706 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004707 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004708 case 0x106b1a00:
4709 case 0x00000100:
4710 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004711 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004712 case 0x106b0a00:
4713 case 0x106b2200:
4714 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004715 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004716 default:
4717 spec->board_config = STAC_INTEL_MAC_V3;
4718 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004719 }
4720 }
4721
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004722 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004723 if (spec->board_config < 0) {
4724 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4725 "using BIOS defaults\n");
4726 err = stac92xx_save_bios_config_regs(codec);
4727 if (err < 0) {
4728 stac92xx_free(codec);
4729 return err;
4730 }
4731 spec->pin_configs = spec->bios_pin_configs;
4732 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004733 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4734 stac92xx_set_config_regs(codec);
4735 }
Matt2f2f4252005-04-13 14:45:30 +02004736
Matt2f2f4252005-04-13 14:45:30 +02004737 spec->adc_nids = stac922x_adc_nids;
4738 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004739 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004740 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004741 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004742 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004743
4744 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004745 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004746
4747 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004748
Matt Porter3cc08dc2006-01-23 15:27:49 +01004749 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004750 if (!err) {
4751 if (spec->board_config < 0) {
4752 printk(KERN_WARNING "hda_codec: No auto-config is "
4753 "available, default to model=ref\n");
4754 spec->board_config = STAC_D945_REF;
4755 goto again;
4756 }
4757 err = -EINVAL;
4758 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004759 if (err < 0) {
4760 stac92xx_free(codec);
4761 return err;
4762 }
4763
4764 codec->patch_ops = stac92xx_patch_ops;
4765
Takashi Iwai807a46362007-05-29 19:01:37 +02004766 /* Fix Mux capture level; max to 2 */
4767 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4768 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4769 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4770 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4771 (0 << AC_AMPCAP_MUTE_SHIFT));
4772
Matt Porter3cc08dc2006-01-23 15:27:49 +01004773 return 0;
4774}
4775
4776static int patch_stac927x(struct hda_codec *codec)
4777{
4778 struct sigmatel_spec *spec;
4779 int err;
4780
4781 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4782 if (spec == NULL)
4783 return -ENOMEM;
4784
4785 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004786 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004787 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004788 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4789 stac927x_models,
4790 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004791 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004792 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4793 if (spec->board_config < 0)
4794 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4795 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004796 err = stac92xx_save_bios_config_regs(codec);
4797 if (err < 0) {
4798 stac92xx_free(codec);
4799 return err;
4800 }
4801 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004802 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004803 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4804 stac92xx_set_config_regs(codec);
4805 }
4806
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004807 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004808 spec->adc_nids = stac927x_adc_nids;
4809 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4810 spec->mux_nids = stac927x_mux_nids;
4811 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004812 spec->smux_nids = stac927x_smux_nids;
4813 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostay65973632008-09-16 10:39:37 -04004814 spec->spdif_labels = stac927x_spdif_labels;
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004815 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004816 spec->multiout.dac_nids = spec->dac_nids;
4817
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004818 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004819 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004820 case STAC_D965_5ST:
4821 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004822 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004823 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004824 spec->num_dmics = 0;
4825
Tobin Davis93ed1502006-09-01 21:03:12 +02004826 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004827 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004828 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004829 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004830 switch (codec->subsystem_id) {
4831 case 0x10280209:
4832 case 0x1028022e:
4833 /* correct the device field to SPDIF out */
4834 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4835 break;
4836 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004837 /* configure the analog microphone on some laptops */
4838 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004839 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004840 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004841 /* correct the front input jack as a mic */
4842 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4843 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004844 case STAC_DELL_3ST:
4845 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004846 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004847 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004848 spec->dmic_nids = stac927x_dmic_nids;
4849 spec->num_dmics = STAC927X_NUM_DMICS;
4850
Tobin Davis93ed1502006-09-01 21:03:12 +02004851 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004852 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004853 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004854 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004855 break;
4856 default:
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004857 if (spec->board_config > STAC_D965_REF) {
4858 /* GPIO0 High = Enable EAPD */
4859 spec->eapd_mask = spec->gpio_mask = 0x01;
4860 spec->gpio_dir = spec->gpio_data = 0x01;
4861 }
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004862 spec->num_dmics = 0;
4863
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004864 spec->init = stac927x_core_init;
4865 spec->mixer = stac927x_mixer;
4866 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004867
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004868 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004869 spec->aloopback_mask = 0x40;
4870 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004871 spec->eapd_switch = 1;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004872
Matt Porter3cc08dc2006-01-23 15:27:49 +01004873 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004874 if (!err) {
4875 if (spec->board_config < 0) {
4876 printk(KERN_WARNING "hda_codec: No auto-config is "
4877 "available, default to model=ref\n");
4878 spec->board_config = STAC_D965_REF;
4879 goto again;
4880 }
4881 err = -EINVAL;
4882 }
Mattc7d4b2f2005-06-27 14:59:41 +02004883 if (err < 0) {
4884 stac92xx_free(codec);
4885 return err;
4886 }
Matt2f2f4252005-04-13 14:45:30 +02004887
4888 codec->patch_ops = stac92xx_patch_ops;
4889
Takashi Iwai52987652008-01-16 16:09:47 +01004890 /*
4891 * !!FIXME!!
4892 * The STAC927x seem to require fairly long delays for certain
4893 * command sequences. With too short delays (even if the answer
4894 * is set to RIRB properly), it results in the silence output
4895 * on some hardwares like Dell.
4896 *
4897 * The below flag enables the longer delay (see get_response
4898 * in hda_intel.c).
4899 */
4900 codec->bus->needs_damn_long_delay = 1;
4901
Matt2f2f4252005-04-13 14:45:30 +02004902 return 0;
4903}
4904
Matt Porterf3302a52006-07-31 12:49:34 +02004905static int patch_stac9205(struct hda_codec *codec)
4906{
4907 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004908 int err;
Matt Porterf3302a52006-07-31 12:49:34 +02004909
4910 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4911 if (spec == NULL)
4912 return -ENOMEM;
4913
4914 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004915 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004916 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004917 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4918 stac9205_models,
4919 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004920 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004921 if (spec->board_config < 0) {
4922 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4923 err = stac92xx_save_bios_config_regs(codec);
4924 if (err < 0) {
4925 stac92xx_free(codec);
4926 return err;
4927 }
4928 spec->pin_configs = spec->bios_pin_configs;
4929 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02004930 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4931 stac92xx_set_config_regs(codec);
4932 }
4933
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004934 spec->digbeep_nid = 0x23;
Matt Porterf3302a52006-07-31 12:49:34 +02004935 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004936 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a52006-07-31 12:49:34 +02004937 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004938 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004939 spec->smux_nids = stac9205_smux_nids;
4940 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004941 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004942 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004943 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai1697055e2007-12-18 18:05:52 +01004944 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004945 spec->num_pwrs = 0;
Matt Porterf3302a52006-07-31 12:49:34 +02004946
4947 spec->init = stac9205_core_init;
4948 spec->mixer = stac9205_mixer;
4949
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004950 spec->aloopback_mask = 0x40;
4951 spec->aloopback_shift = 0;
Matthew Ranostay0253fdc2008-11-16 11:42:34 -05004952 spec->eapd_switch = 1;
Matt Porterf3302a52006-07-31 12:49:34 +02004953 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004954
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004955 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004956 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004957 /* Enable SPDIF in/out */
4958 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4959 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004960
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004961 /* Enable unsol response for GPIO4/Dock HP connection */
Takashi Iwaic5d08bb2008-11-18 10:55:36 +01004962 snd_hda_codec_write_cache(codec, codec->afg, 0,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004963 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4964 snd_hda_codec_write_cache(codec, codec->afg, 0,
4965 AC_VERB_SET_UNSOLICITED_ENABLE,
4966 (AC_USRSP_EN | STAC_HP_EVENT));
4967
4968 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004969 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004970 spec->gpio_mask = 0x1b;
4971 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004972 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004973 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004974 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004975 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004976 break;
Matthew Ranostayb2c4f4d2008-09-26 10:06:40 -04004977 case STAC_9205_REF:
4978 /* SPDIF-In enabled */
4979 break;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004980 default:
4981 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004982 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004983 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004984 break;
4985 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004986
Matt Porterf3302a52006-07-31 12:49:34 +02004987 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004988 if (!err) {
4989 if (spec->board_config < 0) {
4990 printk(KERN_WARNING "hda_codec: No auto-config is "
4991 "available, default to model=ref\n");
4992 spec->board_config = STAC_9205_REF;
4993 goto again;
4994 }
4995 err = -EINVAL;
4996 }
Matt Porterf3302a52006-07-31 12:49:34 +02004997 if (err < 0) {
4998 stac92xx_free(codec);
4999 return err;
5000 }
5001
5002 codec->patch_ops = stac92xx_patch_ops;
5003
5004 return 0;
5005}
5006
Matt2f2f4252005-04-13 14:45:30 +02005007/*
Guillaume Munch6d859062006-08-22 17:15:47 +02005008 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01005009 */
5010
Guillaume Munch99ccc562006-08-16 19:35:12 +02005011/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005012static hda_nid_t vaio_dacs[] = { 0x2 };
5013#define VAIO_HP_DAC 0x5
5014static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5015static hda_nid_t vaio_mux_nids[] = { 0x15 };
5016
5017static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02005018 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01005019 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02005020 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005021 { "Mic Jack", 0x1 },
5022 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01005023 { "PCM", 0x3 },
5024 }
5025};
5026
5027static struct hda_verb vaio_init[] = {
5028 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005029 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01005030 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5031 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5032 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005034 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01005035 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5037 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5039 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5040 {}
5041};
5042
Guillaume Munch6d859062006-08-22 17:15:47 +02005043static struct hda_verb vaio_ar_init[] = {
5044 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5045 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5046 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5047 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5048/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02005050 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02005051 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5052 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5053/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5054 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5057 {}
5058};
5059
Takashi Iwaidb064e52006-03-16 16:04:58 +01005060/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005061static struct hda_bind_ctls vaio_bind_master_vol = {
5062 .ops = &snd_hda_bind_vol,
5063 .values = {
5064 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5065 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5066 0
5067 },
5068};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005069
5070/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02005071static struct hda_bind_ctls vaio_bind_master_sw = {
5072 .ops = &snd_hda_bind_sw,
5073 .values = {
5074 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5075 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5076 0,
5077 },
5078};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005079
5080static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005081 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5082 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005083 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5084 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5085 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5086 {
5087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5088 .name = "Capture Source",
5089 .count = 1,
5090 .info = stac92xx_mux_enum_info,
5091 .get = stac92xx_mux_enum_get,
5092 .put = stac92xx_mux_enum_put,
5093 },
5094 {}
5095};
5096
Guillaume Munch6d859062006-08-22 17:15:47 +02005097static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02005098 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5099 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02005100 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5101 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5102 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5103 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5104 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5105 {
5106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5107 .name = "Capture Source",
5108 .count = 1,
5109 .info = stac92xx_mux_enum_info,
5110 .get = stac92xx_mux_enum_get,
5111 .put = stac92xx_mux_enum_put,
5112 },
5113 {}
5114};
5115
5116static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01005117 .build_controls = stac92xx_build_controls,
5118 .build_pcms = stac92xx_build_pcms,
5119 .init = stac92xx_init,
5120 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02005121#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01005122 .resume = stac92xx_resume,
5123#endif
5124};
5125
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005126static int stac9872_vaio_init(struct hda_codec *codec)
5127{
5128 int err;
5129
5130 err = stac92xx_init(codec);
5131 if (err < 0)
5132 return err;
5133 if (codec->patch_ops.unsol_event)
5134 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5135 return 0;
5136}
5137
5138static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5139{
Jiang Zhe40c1d302007-11-12 13:05:16 +01005140 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005141 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5142 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5143 } else {
5144 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5145 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5146 }
5147}
5148
5149static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5150{
5151 switch (res >> 26) {
5152 case STAC_HP_EVENT:
5153 stac9872_vaio_hp_detect(codec, res);
5154 break;
5155 }
5156}
5157
5158static struct hda_codec_ops stac9872_vaio_patch_ops = {
5159 .build_controls = stac92xx_build_controls,
5160 .build_pcms = stac92xx_build_pcms,
5161 .init = stac9872_vaio_init,
5162 .free = stac92xx_free,
5163 .unsol_event = stac9872_vaio_unsol_event,
5164#ifdef CONFIG_PM
5165 .resume = stac92xx_resume,
5166#endif
5167};
5168
Guillaume Munch6d859062006-08-22 17:15:47 +02005169enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5170 CXD9872RD_VAIO,
5171 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5172 STAC9872AK_VAIO,
5173 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5174 STAC9872K_VAIO,
5175 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005176 CXD9872AKD_VAIO,
5177 STAC_9872_MODELS,
5178};
Takashi Iwaidb064e52006-03-16 16:04:58 +01005179
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005180static const char *stac9872_models[STAC_9872_MODELS] = {
5181 [CXD9872RD_VAIO] = "vaio",
5182 [CXD9872AKD_VAIO] = "vaio-ar",
5183};
5184
5185static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5186 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5187 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5188 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01005189 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01005190 {}
5191};
5192
Guillaume Munch6d859062006-08-22 17:15:47 +02005193static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01005194{
5195 struct sigmatel_spec *spec;
5196 int board_config;
5197
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005198 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5199 stac9872_models,
5200 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01005201 if (board_config < 0)
5202 /* unknown config, let generic-parser do its job... */
5203 return snd_hda_parse_generic_codec(codec);
5204
5205 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5206 if (spec == NULL)
5207 return -ENOMEM;
5208
5209 codec->spec = spec;
5210 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02005211 case CXD9872RD_VAIO:
5212 case STAC9872AK_VAIO:
5213 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01005214 spec->mixer = vaio_mixer;
5215 spec->init = vaio_init;
5216 spec->multiout.max_channels = 2;
5217 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5218 spec->multiout.dac_nids = vaio_dacs;
5219 spec->multiout.hp_nid = VAIO_HP_DAC;
5220 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5221 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005222 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005223 spec->input_mux = &vaio_mux;
5224 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005225 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005226 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02005227
5228 case CXD9872AKD_VAIO:
5229 spec->mixer = vaio_ar_mixer;
5230 spec->init = vaio_ar_init;
5231 spec->multiout.max_channels = 2;
5232 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5233 spec->multiout.dac_nids = vaio_dacs;
5234 spec->multiout.hp_nid = VAIO_HP_DAC;
5235 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01005236 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02005237 spec->adc_nids = vaio_adcs;
5238 spec->input_mux = &vaio_mux;
5239 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02005240 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02005241 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01005242 }
5243
Takashi Iwaidb064e52006-03-16 16:04:58 +01005244 return 0;
5245}
5246
5247
5248/*
Matt2f2f4252005-04-13 14:45:30 +02005249 * patch entries
5250 */
5251struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5252 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5253 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5254 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5255 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5256 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5257 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5258 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02005259 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5260 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5261 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5262 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5263 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5264 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01005265 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5266 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5267 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5268 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5269 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5270 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5271 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5272 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5273 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5274 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01005275 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5276 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5277 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5278 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5279 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5280 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02005281 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5282 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02005283 /* The following does not take into account .id=0x83847661 when subsys =
5284 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5285 * currently not fully supported.
5286 */
5287 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5288 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5289 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02005290 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5291 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5292 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5293 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5294 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5295 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5296 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5297 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005298 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005299 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5300 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005301 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005302 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5303 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005304 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005305 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5306 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5307 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5308 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5309 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5310 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5311 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5312 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005313 {} /* terminator */
5314};