blob: e2b45b2f8f39a8c48445b0e7321ef96b66076c70 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
Matt2f2f4252005-04-13 14:45:30 +020027#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
Mattc7d4b2f2005-06-27 14:59:41 +020032#include <sound/asoundef.h>
Matt2f2f4252005-04-13 14:45:30 +020033#include "hda_codec.h"
34#include "hda_local.h"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010035#include "hda_patch.h"
Matthew Ranostay1cd22242008-07-18 18:20:52 +020036#include "hda_beep.h"
Matt2f2f4252005-04-13 14:45:30 +020037
Matt4e550962005-07-04 17:51:39 +020038#define NUM_CONTROL_ALLOC 32
Matthew Ranostaya64135a2008-01-10 16:55:06 +010039#define STAC_PWR_EVENT 0x20
40#define STAC_HP_EVENT 0x30
Matt4e550962005-07-04 17:51:39 +020041
Takashi Iwaif5fcc132006-11-24 17:07:44 +010042enum {
43 STAC_REF,
Tobin Davisbf277782008-02-03 20:31:47 +010044 STAC_9200_OQO,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020045 STAC_9200_DELL_D21,
46 STAC_9200_DELL_D22,
47 STAC_9200_DELL_D23,
48 STAC_9200_DELL_M21,
49 STAC_9200_DELL_M22,
50 STAC_9200_DELL_M23,
51 STAC_9200_DELL_M24,
52 STAC_9200_DELL_M25,
53 STAC_9200_DELL_M26,
54 STAC_9200_DELL_M27,
Takashi Iwai1194b5b2007-10-10 10:04:26 +020055 STAC_9200_GATEWAY,
Takashi Iwai117f2572008-03-18 09:53:23 +010056 STAC_9200_PANASONIC,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010057 STAC_9200_MODELS
58};
59
60enum {
61 STAC_9205_REF,
Takashi Iwaidfe495d2007-08-23 19:04:28 +020062 STAC_9205_DELL_M42,
Tobin Davisae0a8ed2007-08-13 15:50:29 +020063 STAC_9205_DELL_M43,
64 STAC_9205_DELL_M44,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010065 STAC_9205_MODELS
66};
67
68enum {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010069 STAC_92HD73XX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010070 STAC_DELL_M6,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +010071 STAC_92HD73XX_MODELS
72};
73
74enum {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +020075 STAC_92HD83XXX_REF,
76 STAC_92HD83XXX_MODELS
77};
78
79enum {
Matthew Ranostaye035b842007-11-06 11:53:55 +010080 STAC_92HD71BXX_REF,
Matthew Ranostaya7662642008-02-21 07:51:14 +010081 STAC_DELL_M4_1,
82 STAC_DELL_M4_2,
Matthew Ranostay6a14f582008-09-12 12:02:30 -040083 STAC_HP_M4,
Matthew Ranostaye035b842007-11-06 11:53:55 +010084 STAC_92HD71BXX_MODELS
85};
86
87enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010088 STAC_925x_REF,
89 STAC_M2_2,
90 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020091 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010092 STAC_925x_MODELS
93};
94
95enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010096 STAC_D945_REF,
97 STAC_D945GTP3,
98 STAC_D945GTP5,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020099 STAC_INTEL_MAC_V1,
100 STAC_INTEL_MAC_V2,
101 STAC_INTEL_MAC_V3,
102 STAC_INTEL_MAC_V4,
103 STAC_INTEL_MAC_V5,
Nicolas Boichat536319a2008-07-21 22:18:01 +0800104 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
105 * is given, one of the above models will be
106 * chosen according to the subsystem id. */
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200107 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100108 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100109 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100110 STAC_MACBOOK_PRO_V1,
111 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200112 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200113 STAC_IMAC_INTEL_20,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -0300114 STAC_ECS_202,
Takashi Iwaidfe495d2007-08-23 19:04:28 +0200115 STAC_922X_DELL_D81,
116 STAC_922X_DELL_D82,
117 STAC_922X_DELL_M81,
118 STAC_922X_DELL_M82,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100119 STAC_922X_MODELS
120};
121
122enum {
123 STAC_D965_REF,
124 STAC_D965_3ST,
125 STAC_D965_5ST,
Tobin Davis4ff076e2007-08-07 11:48:12 +0200126 STAC_DELL_3ST,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +0100127 STAC_DELL_BIOS,
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100128 STAC_927X_MODELS
129};
Matt Porter403d1942005-11-29 15:00:51 +0100130
Matt2f2f4252005-04-13 14:45:30 +0200131struct sigmatel_spec {
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100132 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +0200133 unsigned int num_mixers;
134
Matt Porter403d1942005-11-29 15:00:51 +0100135 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +0200136 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +0100137 unsigned int line_switch: 1;
138 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100139 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +0100140 unsigned int hp_detect: 1;
Mattc7d4b2f2005-06-27 14:59:41 +0200141
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100142 /* gpio lines */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +0200143 unsigned int eapd_mask;
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100144 unsigned int gpio_mask;
145 unsigned int gpio_dir;
146 unsigned int gpio_data;
147 unsigned int gpio_mute;
148
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200149 /* stream */
150 unsigned int stream_delay;
151
Matthew Ranostay4fe51952008-01-29 15:28:44 +0100152 /* analog loopback */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100153 unsigned char aloopback_mask;
154 unsigned char aloopback_shift;
Takashi Iwai82599802007-07-31 15:56:24 +0200155
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100156 /* power management */
157 unsigned int num_pwrs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200158 unsigned int *pwr_mapping;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100159 hda_nid_t *pwr_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -0400160 hda_nid_t *amp_nids;
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100161 hda_nid_t *dac_list;
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100162
Matt2f2f4252005-04-13 14:45:30 +0200163 /* playback */
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100164 struct hda_input_mux *mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400165 struct hda_input_mux *amp_mux;
166 unsigned int cur_amux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100167 unsigned int cur_mmux;
Matt2f2f4252005-04-13 14:45:30 +0200168 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100169 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200170
171 /* capture */
172 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200173 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200174 hda_nid_t *mux_nids;
175 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200176 hda_nid_t *dmic_nids;
177 unsigned int num_dmics;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100178 hda_nid_t *dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +0100179 unsigned int num_dmuxes;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200180 hda_nid_t *smux_nids;
181 unsigned int num_smuxes;
182
Mattdabbed62005-06-14 10:19:34 +0200183 hda_nid_t dig_in_nid;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100184 hda_nid_t mono_nid;
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200185 hda_nid_t anabeep_nid;
186 hda_nid_t digbeep_nid;
Matt2f2f4252005-04-13 14:45:30 +0200187
Matt2f2f4252005-04-13 14:45:30 +0200188 /* pin widgets */
189 hda_nid_t *pin_nids;
190 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200191 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200192 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200193
194 /* codec specific stuff */
195 struct hda_verb *init;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100196 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200197
198 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200199 struct hda_input_mux *dinput_mux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100200 unsigned int cur_dmux[2];
Mattc7d4b2f2005-06-27 14:59:41 +0200201 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100202 unsigned int cur_mux[3];
Matthew Ranostayd9737752008-09-07 12:03:41 +0200203 struct hda_input_mux *sinput_mux;
204 unsigned int cur_smux[2];
Matthew Ranostay8daaaa92008-08-15 07:45:52 +0200205 unsigned int powerdown_adcs;
Matt2f2f4252005-04-13 14:45:30 +0200206
Matt Porter403d1942005-11-29 15:00:51 +0100207 /* i/o switches */
208 unsigned int io_switch[2];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +0200209 unsigned int clfe_swap;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +0200210 unsigned int hp_switch;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200211 unsigned int aloopback;
Matt2f2f4252005-04-13 14:45:30 +0200212
Mattc7d4b2f2005-06-27 14:59:41 +0200213 struct hda_pcm pcm_rec[2]; /* PCM information */
214
215 /* dynamic controls and input_mux */
216 struct auto_pin_cfg autocfg;
217 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100218 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200219 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200220 struct hda_input_mux private_imux;
Matthew Ranostayd9737752008-09-07 12:03:41 +0200221 struct hda_input_mux private_smux;
Matthew Ranostay89385032008-09-11 09:49:39 -0400222 struct hda_input_mux private_amp_mux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100223 struct hda_input_mux private_mono_mux;
Matt2f2f4252005-04-13 14:45:30 +0200224};
225
226static hda_nid_t stac9200_adc_nids[1] = {
227 0x03,
228};
229
230static hda_nid_t stac9200_mux_nids[1] = {
231 0x0c,
232};
233
234static hda_nid_t stac9200_dac_nids[1] = {
235 0x02,
236};
237
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100238static hda_nid_t stac92hd73xx_pwr_nids[8] = {
239 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
240 0x0f, 0x10, 0x11
241};
242
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400243static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
244 0x26, 0,
245};
246
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100247static hda_nid_t stac92hd73xx_adc_nids[2] = {
248 0x1a, 0x1b
249};
250
Matthew Ranostay89385032008-09-11 09:49:39 -0400251static hda_nid_t stac92hd73xx_amp_nids[4] = {
252 0x0b, 0x0c, 0x0e, 0
253};
254
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100255#define STAC92HD73XX_NUM_DMICS 2
256static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
257 0x13, 0x14, 0
258};
259
260#define STAC92HD73_DAC_COUNT 5
261static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
262 0x15, 0x16, 0x17, 0x18, 0x19,
263};
264
265static hda_nid_t stac92hd73xx_mux_nids[4] = {
266 0x28, 0x29, 0x2a, 0x2b,
267};
268
269static hda_nid_t stac92hd73xx_dmux_nids[2] = {
270 0x20, 0x21,
271};
272
Matthew Ranostayd9737752008-09-07 12:03:41 +0200273static hda_nid_t stac92hd73xx_smux_nids[2] = {
274 0x22, 0x23,
275};
276
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200277#define STAC92HD83XXX_NUM_DMICS 2
278static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
279 0x11, 0x12, 0
280};
281
282#define STAC92HD81_DAC_COUNT 2
283#define STAC92HD83_DAC_COUNT 3
284static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
285 0x13, 0x14, 0x22,
286};
287
288static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
289 0x17, 0x18,
290};
291
292static hda_nid_t stac92hd83xxx_adc_nids[2] = {
293 0x15, 0x16,
294};
295
296static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
297 0xa, 0xb, 0xd, 0xe,
298};
299
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400300static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
301 0x1e, 0,
302};
303
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200304static unsigned int stac92hd83xxx_pwr_mapping[4] = {
305 0x03, 0x0c, 0x10, 0x40,
306};
307
Matthew Ranostaya64135a2008-01-10 16:55:06 +0100308static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
309 0x0a, 0x0d, 0x0f
310};
311
Matthew Ranostaye035b842007-11-06 11:53:55 +0100312static hda_nid_t stac92hd71bxx_adc_nids[2] = {
313 0x12, 0x13,
314};
315
316static hda_nid_t stac92hd71bxx_mux_nids[2] = {
317 0x1a, 0x1b
318};
319
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100320static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
321 0x1c,
322};
323
Matthew Ranostayd9737752008-09-07 12:03:41 +0200324static hda_nid_t stac92hd71bxx_smux_nids[2] = {
325 0x24, 0x25,
326};
327
Takashi Iwaiaea7bb02008-02-25 18:26:41 +0100328static hda_nid_t stac92hd71bxx_dac_nids[1] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100329 0x10, /*0x11, */
330};
331
332#define STAC92HD71BXX_NUM_DMICS 2
333static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
334 0x18, 0x19, 0
335};
336
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400337static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
338 0x22, 0
339};
340
Tobin Davis8e21c342007-01-08 11:04:17 +0100341static hda_nid_t stac925x_adc_nids[1] = {
342 0x03,
343};
344
345static hda_nid_t stac925x_mux_nids[1] = {
346 0x0f,
347};
348
349static hda_nid_t stac925x_dac_nids[1] = {
350 0x02,
351};
352
Takashi Iwaif6e98522007-10-16 14:27:04 +0200353#define STAC925X_NUM_DMICS 1
354static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
355 0x15, 0
Tobin Davis2c11f952007-05-17 09:36:34 +0200356};
357
Takashi Iwai16970552007-12-18 18:05:52 +0100358static hda_nid_t stac925x_dmux_nids[1] = {
359 0x14,
360};
361
Matt2f2f4252005-04-13 14:45:30 +0200362static hda_nid_t stac922x_adc_nids[2] = {
363 0x06, 0x07,
364};
365
366static hda_nid_t stac922x_mux_nids[2] = {
367 0x12, 0x13,
368};
369
Matt Porter3cc08dc2006-01-23 15:27:49 +0100370static hda_nid_t stac927x_adc_nids[3] = {
371 0x07, 0x08, 0x09
372};
373
374static hda_nid_t stac927x_mux_nids[3] = {
375 0x15, 0x16, 0x17
376};
377
Matthew Ranostayd9737752008-09-07 12:03:41 +0200378static hda_nid_t stac927x_smux_nids[1] = {
379 0x21,
380};
381
Matthew Ranostayb76c8502008-02-06 14:49:44 +0100382static hda_nid_t stac927x_dac_nids[6] = {
383 0x02, 0x03, 0x04, 0x05, 0x06, 0
384};
385
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100386static hda_nid_t stac927x_dmux_nids[1] = {
387 0x1b,
388};
389
Matthew Ranostay7f168592007-10-18 17:38:17 +0200390#define STAC927X_NUM_DMICS 2
391static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
392 0x13, 0x14, 0
393};
394
Matt Porterf3302a592006-07-31 12:49:34 +0200395static hda_nid_t stac9205_adc_nids[2] = {
396 0x12, 0x13
397};
398
399static hda_nid_t stac9205_mux_nids[2] = {
400 0x19, 0x1a
401};
402
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100403static hda_nid_t stac9205_dmux_nids[1] = {
Takashi Iwai16970552007-12-18 18:05:52 +0100404 0x1d,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100405};
406
Matthew Ranostayd9737752008-09-07 12:03:41 +0200407static hda_nid_t stac9205_smux_nids[1] = {
408 0x21,
409};
410
Takashi Iwaif6e98522007-10-16 14:27:04 +0200411#define STAC9205_NUM_DMICS 2
412static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
413 0x17, 0x18, 0
Matt Porter8b657272006-10-26 17:12:59 +0200414};
415
Mattc7d4b2f2005-06-27 14:59:41 +0200416static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200417 0x08, 0x09, 0x0d, 0x0e,
418 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200419};
420
Tobin Davis8e21c342007-01-08 11:04:17 +0100421static hda_nid_t stac925x_pin_nids[8] = {
422 0x07, 0x08, 0x0a, 0x0b,
423 0x0c, 0x0d, 0x10, 0x11,
424};
425
Matt2f2f4252005-04-13 14:45:30 +0200426static hda_nid_t stac922x_pin_nids[10] = {
427 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
428 0x0f, 0x10, 0x11, 0x15, 0x1b,
429};
430
Matthew Ranostaya7662642008-02-21 07:51:14 +0100431static hda_nid_t stac92hd73xx_pin_nids[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100432 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
433 0x0f, 0x10, 0x11, 0x12, 0x13,
Matthew Ranostayd9737752008-09-07 12:03:41 +0200434 0x14, 0x22, 0x23
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100435};
436
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200437static hda_nid_t stac92hd83xxx_pin_nids[14] = {
438 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
439 0x0f, 0x10, 0x11, 0x12, 0x13,
440 0x1d, 0x1e, 0x1f, 0x20
441};
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400442static hda_nid_t stac92hd71bxx_pin_nids[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +0100443 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
444 0x0f, 0x14, 0x18, 0x19, 0x1e,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -0400445 0x1f,
Matthew Ranostaye035b842007-11-06 11:53:55 +0100446};
447
Matt Porter3cc08dc2006-01-23 15:27:49 +0100448static hda_nid_t stac927x_pin_nids[14] = {
449 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
450 0x0f, 0x10, 0x11, 0x12, 0x13,
451 0x14, 0x21, 0x22, 0x23,
452};
453
Matt Porterf3302a592006-07-31 12:49:34 +0200454static hda_nid_t stac9205_pin_nids[12] = {
455 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
456 0x0f, 0x14, 0x16, 0x17, 0x18,
457 0x21, 0x22,
Matt Porterf3302a592006-07-31 12:49:34 +0200458};
459
Matthew Ranostay89385032008-09-11 09:49:39 -0400460#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
461
462static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
463 struct snd_ctl_elem_value *ucontrol)
464{
465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
466 struct sigmatel_spec *spec = codec->spec;
467 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
468
469 kcontrol->private_value ^= get_amp_nid(kcontrol);
470 kcontrol->private_value |= nid;
471
472 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
473}
474
475static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
476 struct snd_ctl_elem_value *ucontrol)
477{
478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
479 struct sigmatel_spec *spec = codec->spec;
480 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
481
482 kcontrol->private_value ^= get_amp_nid(kcontrol);
483 kcontrol->private_value |= nid;
484
485 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
486}
487
Matt Porter8b657272006-10-26 17:12:59 +0200488static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
489 struct snd_ctl_elem_info *uinfo)
490{
491 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
492 struct sigmatel_spec *spec = codec->spec;
493 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
494}
495
496static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
497 struct snd_ctl_elem_value *ucontrol)
498{
499 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
500 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100501 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200502
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100503 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
Matt Porter8b657272006-10-26 17:12:59 +0200504 return 0;
505}
506
507static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol)
509{
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100512 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Matt Porter8b657272006-10-26 17:12:59 +0200513
514 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100515 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
Matt Porter8b657272006-10-26 17:12:59 +0200516}
517
Matthew Ranostayd9737752008-09-07 12:03:41 +0200518static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
519 struct snd_ctl_elem_info *uinfo)
520{
521 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
522 struct sigmatel_spec *spec = codec->spec;
523 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
524}
525
526static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_value *ucontrol)
528{
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 struct sigmatel_spec *spec = codec->spec;
531 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
532
533 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
534 return 0;
535}
536
537static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_value *ucontrol)
539{
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 struct sigmatel_spec *spec = codec->spec;
542 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
543
544 return snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
545 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
546}
547
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100548static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200552 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200553}
554
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100555static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200556{
557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
558 struct sigmatel_spec *spec = codec->spec;
559 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
560
561 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
562 return 0;
563}
564
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100565static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200566{
567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
568 struct sigmatel_spec *spec = codec->spec;
569 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
570
Mattc7d4b2f2005-06-27 14:59:41 +0200571 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200572 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
573}
574
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100575static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_info *uinfo)
577{
578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
579 struct sigmatel_spec *spec = codec->spec;
580 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
581}
582
583static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_value *ucontrol)
585{
586 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
587 struct sigmatel_spec *spec = codec->spec;
588
589 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
590 return 0;
591}
592
593static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
594 struct snd_ctl_elem_value *ucontrol)
595{
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 struct sigmatel_spec *spec = codec->spec;
598
599 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
600 spec->mono_nid, &spec->cur_mmux);
601}
602
Matthew Ranostay89385032008-09-11 09:49:39 -0400603static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
604 struct snd_ctl_elem_info *uinfo)
605{
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
608 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
609}
610
611static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_value *ucontrol)
613{
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 struct sigmatel_spec *spec = codec->spec;
616
617 ucontrol->value.enumerated.item[0] = spec->cur_amux;
618 return 0;
619}
620
621static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
623{
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 struct snd_kcontrol *ctl =
627 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
628 if (!ctl)
629 return -EINVAL;
630
631 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
632 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
633
634 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
635 0, &spec->cur_amux);
636}
637
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200638#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
639
640static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100644 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200645 struct sigmatel_spec *spec = codec->spec;
646
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100647 ucontrol->value.integer.value[0] = !!(spec->aloopback &
648 (spec->aloopback_mask << idx));
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200649 return 0;
650}
651
652static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
654{
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100657 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200658 unsigned int dac_mode;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100659 unsigned int val, idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200660
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100661 idx_val = spec->aloopback_mask << idx;
662 if (ucontrol->value.integer.value[0])
663 val = spec->aloopback | idx_val;
664 else
665 val = spec->aloopback & ~idx_val;
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100666 if (spec->aloopback == val)
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200667 return 0;
668
Takashi Iwai68ea7b22007-11-15 15:54:38 +0100669 spec->aloopback = val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200670
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100671 /* Only return the bits defined by the shift value of the
672 * first two bytes of the mask
673 */
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200674 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100675 kcontrol->private_value & 0xFFFF, 0x0);
676 dac_mode >>= spec->aloopback_shift;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200677
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100678 if (spec->aloopback & idx_val) {
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200679 snd_hda_power_up(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100680 dac_mode |= idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200681 } else {
682 snd_hda_power_down(codec);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100683 dac_mode &= ~idx_val;
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200684 }
685
686 snd_hda_codec_write_cache(codec, codec->afg, 0,
687 kcontrol->private_value >> 16, dac_mode);
688
689 return 1;
690}
691
Mattc7d4b2f2005-06-27 14:59:41 +0200692static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200693 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200694 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200695 {}
696};
697
Takashi Iwai1194b5b2007-10-10 10:04:26 +0200698static struct hda_verb stac9200_eapd_init[] = {
699 /* set dac0mux for dac converter */
700 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
701 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
702 {}
703};
704
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100705static struct hda_verb stac92hd73xx_6ch_core_init[] = {
706 /* set master volume and direct control */
707 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
708 /* setup audio connections */
709 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
710 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
711 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
712 /* setup adcs to point to mixer */
713 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
714 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100715 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
716 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
717 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
718 /* setup import muxs */
719 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
720 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
721 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
722 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
723 {}
724};
725
Matthew Ranostayd654a662008-03-14 08:46:51 +0100726static struct hda_verb dell_eq_core_init[] = {
727 /* set master volume to max value without distortion
728 * and direct control */
729 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
730 /* setup audio connections */
731 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
Matthew Ranostayf7cf0a72008-09-13 10:36:58 -0400732 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
733 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayd654a662008-03-14 08:46:51 +0100734 /* setup adcs to point to mixer */
735 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
736 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
737 /* setup import muxs */
738 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
739 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
740 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
741 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
742 {}
743};
744
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100745static struct hda_verb dell_m6_core_init[] = {
Matthew Ranostay20f5f952008-09-01 08:17:56 +0200746 /* set master volume to max value without distortion
747 * and direct control */
748 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100749 /* setup audio connections */
Matthew Ranostay7747ecc2008-03-10 11:30:04 +0100750 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
751 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay52fe0f92008-02-29 12:08:20 +0100752 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
753 /* setup adcs to point to mixer */
754 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
755 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
756 /* setup import muxs */
757 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
758 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
761 {}
762};
763
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100764static struct hda_verb stac92hd73xx_8ch_core_init[] = {
765 /* set master volume and direct control */
766 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
767 /* setup audio connections */
768 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
769 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
771 /* connect hp ports to dac3 */
772 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
773 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
774 /* setup adcs to point to mixer */
775 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
776 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100777 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
778 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
779 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
780 /* setup import muxs */
781 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
782 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
783 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
784 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
785 {}
786};
787
788static struct hda_verb stac92hd73xx_10ch_core_init[] = {
789 /* set master volume and direct control */
790 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
791 /* setup audio connections */
792 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
793 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
794 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
795 /* dac3 is connected to import3 mux */
796 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
797 /* connect hp ports to dac4 */
798 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
799 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
800 /* setup adcs to point to mixer */
801 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
802 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100803 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
804 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
805 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
806 /* setup import muxs */
807 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
808 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
809 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
810 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
811 {}
812};
813
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200814static struct hda_verb stac92hd83xxx_core_init[] = {
815 /* start of config #1 */
816 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
817
818 /* start of config #2 */
819 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
820 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
821 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
822
823 /* power state controls amps */
824 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
825};
826
Matthew Ranostaye035b842007-11-06 11:53:55 +0100827static struct hda_verb stac92hd71bxx_core_init[] = {
828 /* set master volume and direct control */
829 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
830 /* connect headphone jack to dac1 */
831 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100832 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
833 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
834 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
835 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
836 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostay541eee82007-12-14 12:08:04 +0100837};
838
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200839#define HD_DISABLE_PORTF 3
Matthew Ranostay541eee82007-12-14 12:08:04 +0100840static struct hda_verb stac92hd71bxx_analog_core_init[] = {
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200841 /* start of config #1 */
842
843 /* connect port 0f to audio mixer */
844 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
845 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
846 /* unmute right and left channels for node 0x0f */
847 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
848 /* start of config #2 */
849
Matthew Ranostay541eee82007-12-14 12:08:04 +0100850 /* set master volume and direct control */
851 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
852 /* connect headphone jack to dac1 */
853 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200854 /* connect port 0d to audio mixer */
Matthew Ranostay9b359472007-11-07 13:03:12 +0100855 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
Matthew Ranostay9b359472007-11-07 13:03:12 +0100856 /* unmute dac0 input in audio mixer */
857 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
Matthew Ranostayaafc4412008-06-13 18:04:33 +0200858 /* unmute right and left channels for nodes 0x0a, 0xd */
Matthew Ranostaye035b842007-11-06 11:53:55 +0100859 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
860 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Matthew Ranostaye035b842007-11-06 11:53:55 +0100861 {}
862};
863
Tobin Davis8e21c342007-01-08 11:04:17 +0100864static struct hda_verb stac925x_core_init[] = {
865 /* set dac0mux for dac converter */
866 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
867 {}
868};
869
Mattc7d4b2f2005-06-27 14:59:41 +0200870static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200871 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200872 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200873 {}
874};
875
Tobin Davis93ed1502006-09-01 21:03:12 +0200876static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200877 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200878 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200879 /* unmute node 0x1b */
880 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
881 /* select node 0x03 as DAC */
882 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
883 {}
884};
885
Matt Porter3cc08dc2006-01-23 15:27:49 +0100886static struct hda_verb stac927x_core_init[] = {
887 /* set master volume and direct control */
888 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostay1cd22242008-07-18 18:20:52 +0200889 /* enable analog pc beep path */
890 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porter3cc08dc2006-01-23 15:27:49 +0100891 {}
892};
893
Matt Porterf3302a592006-07-31 12:49:34 +0200894static struct hda_verb stac9205_core_init[] = {
895 /* set master volume and direct control */
896 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +0200897 /* enable analog pc beep path */
898 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
Matt Porterf3302a592006-07-31 12:49:34 +0200899 {}
900};
901
Matthew Ranostayb22b4822008-01-22 12:32:30 +0100902#define STAC_MONO_MUX \
903 { \
904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
905 .name = "Mono Mux", \
906 .count = 1, \
907 .info = stac92xx_mono_mux_enum_info, \
908 .get = stac92xx_mono_mux_enum_get, \
909 .put = stac92xx_mono_mux_enum_put, \
910 }
911
Matthew Ranostay89385032008-09-11 09:49:39 -0400912#define STAC_AMP_MUX \
913 { \
914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
915 .name = "Amp Selector Capture Switch", \
916 .count = 1, \
917 .info = stac92xx_amp_mux_enum_info, \
918 .get = stac92xx_amp_mux_enum_get, \
919 .put = stac92xx_amp_mux_enum_put, \
920 }
921
922#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
923 { \
924 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
925 .name = xname, \
926 .index = 0, \
927 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
928 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
929 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
930 .info = stac92xx_amp_volume_info, \
931 .get = stac92xx_amp_volume_get, \
932 .put = stac92xx_amp_volume_put, \
933 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
934 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
935 }
936
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200937#define STAC_INPUT_SOURCE(cnt) \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200938 { \
939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
940 .name = "Input Source", \
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200941 .count = cnt, \
Maxim Levitskyca7c5a82007-08-31 12:52:19 +0200942 .info = stac92xx_mux_enum_info, \
943 .get = stac92xx_mux_enum_get, \
944 .put = stac92xx_mux_enum_put, \
945 }
946
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100947#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200948 { \
949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
950 .name = "Analog Loopback", \
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100951 .count = cnt, \
Maxim Levitsky5f10c4a2007-09-03 15:29:37 +0200952 .info = stac92xx_aloopback_info, \
953 .get = stac92xx_aloopback_get, \
954 .put = stac92xx_aloopback_put, \
955 .private_value = verb_read | (verb_write << 16), \
956 }
957
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +0100958static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200959 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
960 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +0200961 STAC_INPUT_SOURCE(1),
Matt2f2f4252005-04-13 14:45:30 +0200962 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
963 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200964 { } /* end */
965};
966
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100967static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100968 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
969
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100970 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
971 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
972
973 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
974 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
975
976 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
977 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
978
979 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
980 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
981
982 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
983 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
984
985 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
986 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
987
988 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
989 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
990 { } /* end */
991};
992
993static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100994 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
995
Matthew Ranostaye1f0d662007-12-13 17:47:21 +0100996 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
997 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
998
999 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1000 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1001
1002 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1003 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1004
1005 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1006 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1007
1008 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1009 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1010
1011 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1012 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1013
1014 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1015 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1016 { } /* end */
1017};
1018
1019static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001020 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1021
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1024
1025 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1026 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1027
1028 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1029 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1030
1031 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1032 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1033
1034 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1035 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1036
1037 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1038 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1039
1040 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1041 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1042 { } /* end */
1043};
1044
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001045
1046static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1047 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1048 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1049
1050 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1052
1053 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1054 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1055
1056 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1057 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1058
1059 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1060 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1061
1062 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1063 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1064
1065 /*
1066 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1068 */
1069 { } /* end */
1070};
1071
Matthew Ranostay541eee82007-12-14 12:08:04 +01001072static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001073 STAC_INPUT_SOURCE(2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001074
Matthew Ranostay9b359472007-11-07 13:03:12 +01001075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay9b359472007-11-07 13:03:12 +01001077
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001080 /* analog pc-beep replaced with digital beep support */
1081 /*
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001082 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1083 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
Matthew Ranostay1cd22242008-07-18 18:20:52 +02001084 */
Matthew Ranostayf7c5dda2008-07-10 17:49:11 +02001085
Matthew Ranostay9b359472007-11-07 13:03:12 +01001086 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
1087 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001088 { } /* end */
1089};
1090
Matthew Ranostay541eee82007-12-14 12:08:04 +01001091static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
Matthew Ranostay541eee82007-12-14 12:08:04 +01001092 STAC_INPUT_SOURCE(2),
1093 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1094
Matthew Ranostay541eee82007-12-14 12:08:04 +01001095 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1096 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001097
1098 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1099 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
Matthew Ranostay541eee82007-12-14 12:08:04 +01001100 { } /* end */
1101};
1102
Tobin Davis8e21c342007-01-08 11:04:17 +01001103static struct snd_kcontrol_new stac925x_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001104 STAC_INPUT_SOURCE(1),
Tobin Davis8e21c342007-01-08 11:04:17 +01001105 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
Mauro Carvalho Chehab587755f2008-05-25 18:20:06 +02001106 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
Tobin Davis8e21c342007-01-08 11:04:17 +01001107 { } /* end */
1108};
1109
Takashi Iwaid1d985f2006-11-23 19:27:12 +01001110static struct snd_kcontrol_new stac9205_mixer[] = {
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001111 STAC_INPUT_SOURCE(2),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001112 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001113
1114 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1115 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001116
1117 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1118 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001119 { } /* end */
1120};
1121
1122/* This needs to be generated dynamically based on sequence */
1123static struct snd_kcontrol_new stac922x_mixer[] = {
1124 STAC_INPUT_SOURCE(2),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001125 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1126 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001127
1128 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1129 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001130 { } /* end */
1131};
1132
1133
1134static struct snd_kcontrol_new stac927x_mixer[] = {
1135 STAC_INPUT_SOURCE(3),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001136 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001137
1138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001140
1141 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1142 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02001143
1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
Matt Porterf3302a592006-07-31 12:49:34 +02001146 { } /* end */
1147};
1148
Takashi Iwai16970552007-12-18 18:05:52 +01001149static struct snd_kcontrol_new stac_dmux_mixer = {
1150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1151 .name = "Digital Input Source",
1152 /* count set later */
1153 .info = stac92xx_dmux_enum_info,
1154 .get = stac92xx_dmux_enum_get,
1155 .put = stac92xx_dmux_enum_put,
1156};
1157
Matthew Ranostayd9737752008-09-07 12:03:41 +02001158static struct snd_kcontrol_new stac_smux_mixer = {
1159 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matthew Ranostaye3487972008-09-08 11:36:59 -04001160 .name = "IEC958 Playback Source",
Matthew Ranostayd9737752008-09-07 12:03:41 +02001161 /* count set later */
1162 .info = stac92xx_smux_enum_info,
1163 .get = stac92xx_smux_enum_get,
1164 .put = stac92xx_smux_enum_put,
1165};
1166
Takashi Iwai2134ea42008-01-10 16:53:55 +01001167static const char *slave_vols[] = {
1168 "Front Playback Volume",
1169 "Surround Playback Volume",
1170 "Center Playback Volume",
1171 "LFE Playback Volume",
1172 "Side Playback Volume",
1173 "Headphone Playback Volume",
1174 "Headphone Playback Volume",
1175 "Speaker Playback Volume",
1176 "External Speaker Playback Volume",
1177 "Speaker2 Playback Volume",
1178 NULL
1179};
1180
1181static const char *slave_sws[] = {
1182 "Front Playback Switch",
1183 "Surround Playback Switch",
1184 "Center Playback Switch",
1185 "LFE Playback Switch",
1186 "Side Playback Switch",
1187 "Headphone Playback Switch",
1188 "Headphone Playback Switch",
1189 "Speaker Playback Switch",
1190 "External Speaker Playback Switch",
1191 "Speaker2 Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001192 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001193 NULL
1194};
1195
Matt2f2f4252005-04-13 14:45:30 +02001196static int stac92xx_build_controls(struct hda_codec *codec)
1197{
1198 struct sigmatel_spec *spec = codec->spec;
1199 int err;
Mattc7d4b2f2005-06-27 14:59:41 +02001200 int i;
Matt2f2f4252005-04-13 14:45:30 +02001201
1202 err = snd_hda_add_new_ctls(codec, spec->mixer);
1203 if (err < 0)
1204 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001205
1206 for (i = 0; i < spec->num_mixers; i++) {
1207 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1208 if (err < 0)
1209 return err;
1210 }
Takashi Iwai16970552007-12-18 18:05:52 +01001211 if (spec->num_dmuxes > 0) {
1212 stac_dmux_mixer.count = spec->num_dmuxes;
1213 err = snd_ctl_add(codec->bus->card,
1214 snd_ctl_new1(&stac_dmux_mixer, codec));
1215 if (err < 0)
1216 return err;
1217 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02001218 if (spec->num_smuxes > 0) {
1219 stac_smux_mixer.count = spec->num_smuxes;
1220 err = snd_ctl_add(codec->bus->card,
1221 snd_ctl_new1(&stac_smux_mixer, codec));
1222 if (err < 0)
1223 return err;
1224 }
Mattc7d4b2f2005-06-27 14:59:41 +02001225
Mattdabbed62005-06-14 10:19:34 +02001226 if (spec->multiout.dig_out_nid) {
1227 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1228 if (err < 0)
1229 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001230 err = snd_hda_create_spdif_share_sw(codec,
1231 &spec->multiout);
1232 if (err < 0)
1233 return err;
1234 spec->multiout.share_spdif = 1;
Mattdabbed62005-06-14 10:19:34 +02001235 }
1236 if (spec->dig_in_nid) {
1237 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1238 if (err < 0)
1239 return err;
1240 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001241
1242 /* if we have no master control, let's create it */
1243 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001244 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001245 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001246 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001247 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001248 vmaster_tlv, slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001249 if (err < 0)
1250 return err;
1251 }
1252 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1253 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1254 NULL, slave_sws);
1255 if (err < 0)
1256 return err;
1257 }
1258
Mattdabbed62005-06-14 10:19:34 +02001259 return 0;
Matt2f2f4252005-04-13 14:45:30 +02001260}
1261
Matt Porter403d1942005-11-29 15:00:51 +01001262static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +02001263 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +02001264 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1265};
1266
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001267/*
1268 STAC 9200 pin configs for
1269 102801A8
1270 102801DE
1271 102801E8
1272*/
1273static unsigned int dell9200_d21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001274 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1275 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001276};
1277
1278/*
1279 STAC 9200 pin configs for
1280 102801C0
1281 102801C1
1282*/
1283static unsigned int dell9200_d22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001284 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1285 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001286};
1287
1288/*
1289 STAC 9200 pin configs for
1290 102801C4 (Dell Dimension E310)
1291 102801C5
1292 102801C7
1293 102801D9
1294 102801DA
1295 102801E3
1296*/
1297static unsigned int dell9200_d23_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001298 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1299 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001300};
1301
1302
1303/*
1304 STAC 9200-32 pin configs for
1305 102801B5 (Dell Inspiron 630m)
1306 102801D8 (Dell Inspiron 640m)
1307*/
1308static unsigned int dell9200_m21_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001309 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1310 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001311};
1312
1313/*
1314 STAC 9200-32 pin configs for
1315 102801C2 (Dell Latitude D620)
1316 102801C8
1317 102801CC (Dell Latitude D820)
1318 102801D4
1319 102801D6
1320*/
1321static unsigned int dell9200_m22_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001322 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1323 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001324};
1325
1326/*
1327 STAC 9200-32 pin configs for
1328 102801CE (Dell XPS M1710)
1329 102801CF (Dell Precision M90)
1330*/
1331static unsigned int dell9200_m23_pin_configs[8] = {
1332 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1333 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1334};
1335
1336/*
1337 STAC 9200-32 pin configs for
1338 102801C9
1339 102801CA
1340 102801CB (Dell Latitude 120L)
1341 102801D3
1342*/
1343static unsigned int dell9200_m24_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001344 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1345 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001346};
1347
1348/*
1349 STAC 9200-32 pin configs for
1350 102801BD (Dell Inspiron E1505n)
1351 102801EE
1352 102801EF
1353*/
1354static unsigned int dell9200_m25_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001355 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1356 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001357};
1358
1359/*
1360 STAC 9200-32 pin configs for
1361 102801F5 (Dell Inspiron 1501)
1362 102801F6
1363*/
1364static unsigned int dell9200_m26_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001365 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1366 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001367};
1368
1369/*
1370 STAC 9200-32
1371 102801CD (Dell Inspiron E1705/9400)
1372*/
1373static unsigned int dell9200_m27_pin_configs[8] = {
Takashi Iwaiaf6c0162007-09-05 23:46:03 +02001374 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1375 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001376};
1377
Tobin Davisbf277782008-02-03 20:31:47 +01001378static unsigned int oqo9200_pin_configs[8] = {
1379 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1380 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1381};
1382
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001383
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001384static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1385 [STAC_REF] = ref9200_pin_configs,
Tobin Davisbf277782008-02-03 20:31:47 +01001386 [STAC_9200_OQO] = oqo9200_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001387 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1388 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1389 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1390 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1391 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1392 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1393 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1394 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1395 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1396 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
Takashi Iwai117f2572008-03-18 09:53:23 +01001397 [STAC_9200_PANASONIC] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001398};
1399
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001400static const char *stac9200_models[STAC_9200_MODELS] = {
1401 [STAC_REF] = "ref",
Tobin Davisbf277782008-02-03 20:31:47 +01001402 [STAC_9200_OQO] = "oqo",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001403 [STAC_9200_DELL_D21] = "dell-d21",
1404 [STAC_9200_DELL_D22] = "dell-d22",
1405 [STAC_9200_DELL_D23] = "dell-d23",
1406 [STAC_9200_DELL_M21] = "dell-m21",
1407 [STAC_9200_DELL_M22] = "dell-m22",
1408 [STAC_9200_DELL_M23] = "dell-m23",
1409 [STAC_9200_DELL_M24] = "dell-m24",
1410 [STAC_9200_DELL_M25] = "dell-m25",
1411 [STAC_9200_DELL_M26] = "dell-m26",
1412 [STAC_9200_DELL_M27] = "dell-m27",
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001413 [STAC_9200_GATEWAY] = "gateway",
Takashi Iwai117f2572008-03-18 09:53:23 +01001414 [STAC_9200_PANASONIC] = "panasonic",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001415};
1416
1417static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1418 /* SigmaTel reference board */
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1420 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +01001421 /* Dell laptops have BIOS problem */
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1423 "unknown Dell", STAC_9200_DELL_D21),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001424 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001425 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1427 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1428 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1429 "unknown Dell", STAC_9200_DELL_D22),
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1431 "unknown Dell", STAC_9200_DELL_D22),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001432 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001433 "Dell Latitude D620", STAC_9200_DELL_M22),
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1435 "unknown Dell", STAC_9200_DELL_D23),
1436 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1437 "unknown Dell", STAC_9200_DELL_D23),
1438 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1439 "unknown Dell", STAC_9200_DELL_M22),
1440 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1441 "unknown Dell", STAC_9200_DELL_M24),
1442 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1443 "unknown Dell", STAC_9200_DELL_M24),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001444 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001445 "Dell Latitude 120L", STAC_9200_DELL_M24),
Cory T. Tusar877b8662007-01-30 17:30:55 +01001446 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001447 "Dell Latitude D820", STAC_9200_DELL_M22),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001448 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001449 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +01001450 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001451 "Dell XPS M1710", STAC_9200_DELL_M23),
Takashi Iwaif0f96742007-02-14 00:59:17 +01001452 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001453 "Dell Precision M90", STAC_9200_DELL_M23),
1454 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1455 "unknown Dell", STAC_9200_DELL_M22),
1456 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1457 "unknown Dell", STAC_9200_DELL_M22),
Daniel T Chen8286c532007-05-15 11:46:23 +02001458 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001459 "unknown Dell", STAC_9200_DELL_M22),
Tobin Davis49c605d2007-05-17 09:38:24 +02001460 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001461 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1463 "unknown Dell", STAC_9200_DELL_D23),
1464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1465 "unknown Dell", STAC_9200_DELL_D23),
1466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1467 "unknown Dell", STAC_9200_DELL_D21),
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1469 "unknown Dell", STAC_9200_DELL_D23),
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1471 "unknown Dell", STAC_9200_DELL_D21),
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1473 "unknown Dell", STAC_9200_DELL_M25),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1475 "unknown Dell", STAC_9200_DELL_M25),
Tobin Davis49c605d2007-05-17 09:38:24 +02001476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001477 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1479 "unknown Dell", STAC_9200_DELL_M26),
Tobin Davis49c605d2007-05-17 09:38:24 +02001480 /* Panasonic */
Takashi Iwai117f2572008-03-18 09:53:23 +01001481 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
Takashi Iwai1194b5b2007-10-10 10:04:26 +02001482 /* Gateway machines needs EAPD to be set on resume */
1483 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1484 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1485 STAC_9200_GATEWAY),
1486 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1487 STAC_9200_GATEWAY),
Tobin Davisbf277782008-02-03 20:31:47 +01001488 /* OQO Mobile */
1489 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
Matt Porter403d1942005-11-29 15:00:51 +01001490 {} /* terminator */
1491};
1492
Tobin Davis8e21c342007-01-08 11:04:17 +01001493static unsigned int ref925x_pin_configs[8] = {
1494 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
Matthew Ranostay09a99952008-01-24 11:49:21 +01001495 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001496};
1497
1498static unsigned int stac925x_MA6_pin_configs[8] = {
1499 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1500 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1501};
1502
Tobin Davis2c11f952007-05-17 09:36:34 +02001503static unsigned int stac925x_PA6_pin_configs[8] = {
1504 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1505 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1506};
1507
Tobin Davis8e21c342007-01-08 11:04:17 +01001508static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +02001509 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1510 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +01001511};
1512
1513static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1514 [STAC_REF] = ref925x_pin_configs,
1515 [STAC_M2_2] = stac925xM2_2_pin_configs,
1516 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +02001517 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +01001518};
1519
1520static const char *stac925x_models[STAC_925x_MODELS] = {
1521 [STAC_REF] = "ref",
1522 [STAC_M2_2] = "m2-2",
1523 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +02001524 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +01001525};
1526
1527static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1528 /* SigmaTel reference board */
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +02001530 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +01001531 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1532 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1533 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +02001534 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +01001535 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1536 {} /* terminator */
1537};
1538
Matthew Ranostaya7662642008-02-21 07:51:14 +01001539static unsigned int ref92hd73xx_pin_configs[13] = {
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001540 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1541 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1542 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001543 0x01452050,
1544};
1545
1546static unsigned int dell_m6_pin_configs[13] = {
1547 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02001548 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001549 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1550 0x4f0000f0,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001551};
1552
1553static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001554 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1555 [STAC_DELL_M6] = dell_m6_pin_configs,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001556};
1557
1558static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1559 [STAC_92HD73XX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001560 [STAC_DELL_M6] = "dell-m6",
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001561};
1562
1563static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1564 /* SigmaTel reference board */
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001566 "DFI LanParty", STAC_92HD73XX_REF),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1568 "unknown Dell", STAC_DELL_M6),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1570 "unknown Dell", STAC_DELL_M6),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1572 "unknown Dell", STAC_DELL_M6),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1574 "unknown Dell", STAC_DELL_M6),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1576 "unknown Dell", STAC_DELL_M6),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1578 "unknown Dell", STAC_DELL_M6),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1580 "unknown Dell", STAC_DELL_M6),
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01001581 {} /* terminator */
1582};
1583
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02001584static unsigned int ref92hd83xxx_pin_configs[14] = {
1585 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1586 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1587 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1588 0x01451160, 0x98560170,
1589};
1590
1591static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1592 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1593};
1594
1595static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1596 [STAC_92HD83XXX_REF] = "ref",
1597};
1598
1599static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1600 /* SigmaTel reference board */
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1602 "DFI LanParty", STAC_92HD71BXX_REF),
1603};
1604
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001605static unsigned int ref92hd71bxx_pin_configs[11] = {
Matthew Ranostaye035b842007-11-06 11:53:55 +01001606 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
Matthew Ranostayb22b4822008-01-22 12:32:30 +01001607 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001608 0x90a000f0, 0x01452050, 0x01452050,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001609};
1610
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001611static unsigned int dell_m4_1_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001612 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
Matthew Ranostay07bcb312008-03-20 12:10:57 +01001613 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001614 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001615};
1616
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001617static unsigned int dell_m4_2_pin_configs[11] = {
Matthew Ranostaya7662642008-02-21 07:51:14 +01001618 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1619 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04001620 0x40f000f0, 0x044413b0, 0x044413b0,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001621};
1622
Matthew Ranostaye035b842007-11-06 11:53:55 +01001623static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1624 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
Matthew Ranostaya7662642008-02-21 07:51:14 +01001625 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1626 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001627 [STAC_HP_M4] = NULL,
Matthew Ranostaye035b842007-11-06 11:53:55 +01001628};
1629
1630static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1631 [STAC_92HD71BXX_REF] = "ref",
Matthew Ranostaya7662642008-02-21 07:51:14 +01001632 [STAC_DELL_M4_1] = "dell-m4-1",
1633 [STAC_DELL_M4_2] = "dell-m4-2",
Matthew Ranostay6a14f582008-09-12 12:02:30 -04001634 [STAC_HP_M4] = "hp-m4",
Matthew Ranostaye035b842007-11-06 11:53:55 +01001635};
1636
1637static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1638 /* SigmaTel reference board */
1639 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1640 "DFI LanParty", STAC_92HD71BXX_REF),
Matthew Ranostaya7662642008-02-21 07:51:14 +01001641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1642 "unknown Dell", STAC_DELL_M4_1),
1643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1644 "unknown Dell", STAC_DELL_M4_1),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1646 "unknown Dell", STAC_DELL_M4_1),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1648 "unknown Dell", STAC_DELL_M4_1),
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1650 "unknown Dell", STAC_DELL_M4_1),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1652 "unknown Dell", STAC_DELL_M4_1),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1654 "unknown Dell", STAC_DELL_M4_1),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1656 "unknown Dell", STAC_DELL_M4_2),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1658 "unknown Dell", STAC_DELL_M4_2),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1660 "unknown Dell", STAC_DELL_M4_2),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1662 "unknown Dell", STAC_DELL_M4_2),
Matthew Ranostaye035b842007-11-06 11:53:55 +01001663 {} /* terminator */
1664};
1665
Matt Porter403d1942005-11-29 15:00:51 +01001666static unsigned int ref922x_pin_configs[10] = {
1667 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1668 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +02001669 0x40000100, 0x40000100,
1670};
1671
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001672/*
1673 STAC 922X pin configs for
1674 102801A7
1675 102801AB
1676 102801A9
1677 102801D1
1678 102801D2
1679*/
1680static unsigned int dell_922x_d81_pin_configs[10] = {
1681 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1682 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1683 0x01813122, 0x400001f2,
1684};
1685
1686/*
1687 STAC 922X pin configs for
1688 102801AC
1689 102801D0
1690*/
1691static unsigned int dell_922x_d82_pin_configs[10] = {
1692 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1693 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1694 0x01813122, 0x400001f1,
1695};
1696
1697/*
1698 STAC 922X pin configs for
1699 102801BF
1700*/
1701static unsigned int dell_922x_m81_pin_configs[10] = {
1702 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1703 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1704 0x40C003f1, 0x405003f0,
1705};
1706
1707/*
1708 STAC 9221 A1 pin configs for
1709 102801D7 (Dell XPS M1210)
1710*/
1711static unsigned int dell_922x_m82_pin_configs[10] = {
Jiang Zhe7f9310c2007-11-12 12:43:37 +01001712 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1713 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001714 0x508003f3, 0x405003f4,
1715};
1716
Matt Porter403d1942005-11-29 15:00:51 +01001717static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001718 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +01001719 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1720 0x02a19120, 0x40000100,
1721};
1722
1723static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +01001724 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1725 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +01001726 0x02a19320, 0x40000100,
1727};
1728
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001729static unsigned int intel_mac_v1_pin_configs[10] = {
1730 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1731 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001732 0x400000fc, 0x400000fb,
1733};
1734
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001735static unsigned int intel_mac_v2_pin_configs[10] = {
1736 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1737 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +02001738 0x400000fc, 0x400000fb,
1739};
1740
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001741static unsigned int intel_mac_v3_pin_configs[10] = {
1742 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1743 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1744 0x400000fc, 0x400000fb,
1745};
1746
1747static unsigned int intel_mac_v4_pin_configs[10] = {
1748 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1749 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1750 0x400000fc, 0x400000fb,
1751};
1752
1753static unsigned int intel_mac_v5_pin_configs[10] = {
1754 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1755 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1756 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001757};
1758
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001759static unsigned int ecs202_pin_configs[10] = {
1760 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1761 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1762 0x9037012e, 0x40e000f2,
1763};
Takashi Iwai76c08822007-06-19 12:17:42 +02001764
Takashi Iwai19039bd2006-06-28 15:52:16 +02001765static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001766 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +02001767 [STAC_D945GTP3] = d945gtp3_pin_configs,
1768 [STAC_D945GTP5] = d945gtp5_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001769 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1770 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1771 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1772 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1773 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001774 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001775 /* for backward compatibility */
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001776 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1777 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1778 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1779 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1780 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1781 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001782 [STAC_ECS_202] = ecs202_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001783 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1784 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1785 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1786 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +01001787};
1788
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001789static const char *stac922x_models[STAC_922X_MODELS] = {
1790 [STAC_D945_REF] = "ref",
1791 [STAC_D945GTP5] = "5stack",
1792 [STAC_D945GTP3] = "3stack",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02001793 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1794 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1795 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1796 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1797 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
Nicolas Boichat536319a2008-07-21 22:18:01 +08001798 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001799 /* for backward compatibility */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001800 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +01001801 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01001802 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1803 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +02001804 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +02001805 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001806 [STAC_ECS_202] = "ecs202",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001807 [STAC_922X_DELL_D81] = "dell-d81",
1808 [STAC_922X_DELL_D82] = "dell-d82",
1809 [STAC_922X_DELL_M81] = "dell-m81",
1810 [STAC_922X_DELL_M82] = "dell-m82",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001811};
1812
1813static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1814 /* SigmaTel reference board */
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1816 "DFI LanParty", STAC_D945_REF),
1817 /* Intel 945G based systems */
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1819 "Intel D945G", STAC_D945GTP3),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1821 "Intel D945G", STAC_D945GTP3),
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1823 "Intel D945G", STAC_D945GTP3),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1825 "Intel D945G", STAC_D945GTP3),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1827 "Intel D945G", STAC_D945GTP3),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1829 "Intel D945G", STAC_D945GTP3),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1831 "Intel D945G", STAC_D945GTP3),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1833 "Intel D945G", STAC_D945GTP3),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1835 "Intel D945G", STAC_D945GTP3),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1837 "Intel D945G", STAC_D945GTP3),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1839 "Intel D945G", STAC_D945GTP3),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1841 "Intel D945G", STAC_D945GTP3),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1843 "Intel D945G", STAC_D945GTP3),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1845 "Intel D945G", STAC_D945GTP3),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1847 "Intel D945G", STAC_D945GTP3),
1848 /* Intel D945G 5-stack systems */
1849 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1850 "Intel D945G", STAC_D945GTP5),
1851 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1852 "Intel D945G", STAC_D945GTP5),
1853 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1854 "Intel D945G", STAC_D945GTP5),
1855 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1856 "Intel D945G", STAC_D945GTP5),
1857 /* Intel 945P based systems */
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1859 "Intel D945P", STAC_D945GTP3),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1861 "Intel D945P", STAC_D945GTP3),
1862 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1863 "Intel D945P", STAC_D945GTP3),
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1865 "Intel D945P", STAC_D945GTP3),
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1867 "Intel D945P", STAC_D945GTP3),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1869 "Intel D945P", STAC_D945GTP5),
1870 /* other systems */
Nicolas Boichat536319a2008-07-21 22:18:01 +08001871 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001872 SND_PCI_QUIRK(0x8384, 0x7680,
Nicolas Boichat536319a2008-07-21 22:18:01 +08001873 "Mac", STAC_INTEL_MAC_AUTO),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001874 /* Dell systems */
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1876 "unknown Dell", STAC_922X_DELL_D81),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1878 "unknown Dell", STAC_922X_DELL_D81),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1880 "unknown Dell", STAC_922X_DELL_D81),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1882 "unknown Dell", STAC_922X_DELL_D82),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1884 "unknown Dell", STAC_922X_DELL_M81),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1886 "unknown Dell", STAC_922X_DELL_D82),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1888 "unknown Dell", STAC_922X_DELL_D81),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1890 "unknown Dell", STAC_922X_DELL_D81),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1892 "Dell XPS M1210", STAC_922X_DELL_M82),
Mauro Carvalho Chehab8c650082008-08-04 10:39:59 -03001893 /* ECS/PC Chips boards */
1894 SND_PCI_QUIRK(0x1019, 0x2144,
1895 "ECS/PC chips", STAC_ECS_202),
1896 SND_PCI_QUIRK(0x1019, 0x2608,
1897 "ECS/PC chips", STAC_ECS_202),
1898 SND_PCI_QUIRK(0x1019, 0x2633,
1899 "ECS/PC chips P17G/1333", STAC_ECS_202),
1900 SND_PCI_QUIRK(0x1019, 0x2811,
1901 "ECS/PC chips", STAC_ECS_202),
1902 SND_PCI_QUIRK(0x1019, 0x2812,
1903 "ECS/PC chips", STAC_ECS_202),
1904 SND_PCI_QUIRK(0x1019, 0x2813,
1905 "ECS/PC chips", STAC_ECS_202),
1906 SND_PCI_QUIRK(0x1019, 0x2814,
1907 "ECS/PC chips", STAC_ECS_202),
1908 SND_PCI_QUIRK(0x1019, 0x2815,
1909 "ECS/PC chips", STAC_ECS_202),
1910 SND_PCI_QUIRK(0x1019, 0x2816,
1911 "ECS/PC chips", STAC_ECS_202),
1912 SND_PCI_QUIRK(0x1019, 0x2817,
1913 "ECS/PC chips", STAC_ECS_202),
1914 SND_PCI_QUIRK(0x1019, 0x2818,
1915 "ECS/PC chips", STAC_ECS_202),
1916 SND_PCI_QUIRK(0x1019, 0x2819,
1917 "ECS/PC chips", STAC_ECS_202),
1918 SND_PCI_QUIRK(0x1019, 0x2820,
1919 "ECS/PC chips", STAC_ECS_202),
Matt Porter403d1942005-11-29 15:00:51 +01001920 {} /* terminator */
1921};
1922
Matt Porter3cc08dc2006-01-23 15:27:49 +01001923static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +02001924 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1925 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1926 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1927 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001928};
1929
Tobin Davis93ed1502006-09-01 21:03:12 +02001930static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001931 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1932 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1933 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1934 0x40000100, 0x40000100
1935};
1936
Tobin Davis93ed1502006-09-01 21:03:12 +02001937static unsigned int d965_5st_pin_configs[14] = {
1938 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1939 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1940 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1941 0x40000100, 0x40000100
1942};
1943
Tobin Davis4ff076e2007-08-07 11:48:12 +02001944static unsigned int dell_3st_pin_configs[14] = {
1945 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1946 0x01111212, 0x01116211, 0x01813050, 0x01112214,
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001947 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
Tobin Davis4ff076e2007-08-07 11:48:12 +02001948 0x40c003fc, 0x40000100
1949};
1950
Tobin Davis93ed1502006-09-01 21:03:12 +02001951static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001952 [STAC_D965_REF] = ref927x_pin_configs,
1953 [STAC_D965_3ST] = d965_3st_pin_configs,
1954 [STAC_D965_5ST] = d965_5st_pin_configs,
1955 [STAC_DELL_3ST] = dell_3st_pin_configs,
1956 [STAC_DELL_BIOS] = NULL,
Matt Porter3cc08dc2006-01-23 15:27:49 +01001957};
1958
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001959static const char *stac927x_models[STAC_927X_MODELS] = {
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001960 [STAC_D965_REF] = "ref",
1961 [STAC_D965_3ST] = "3stack",
1962 [STAC_D965_5ST] = "5stack",
1963 [STAC_DELL_3ST] = "dell-3stack",
1964 [STAC_DELL_BIOS] = "dell-bios",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001965};
1966
1967static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1968 /* SigmaTel reference board */
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1970 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001971 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001972 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +02001974 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1977 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1979 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1981 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001991 /* Dell 3 stack systems */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001992 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02001993 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
Tobin Davis4ff076e2007-08-07 11:48:12 +02001994 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001996 /* Dell 3 stack systems with verb table in BIOS */
Matthew Ranostay2f32d902008-01-10 13:06:26 +01001997 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01001999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
Takashi Iwai24918b62008-09-30 12:58:54 +02002000 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002001 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
Tobin Davis93ed1502006-09-01 21:03:12 +02002005 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +01002015 {} /* terminator */
2016};
2017
Matt Porterf3302a592006-07-31 12:49:34 +02002018static unsigned int ref9205_pin_configs[12] = {
2019 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002020 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
Matt Porter8b657272006-10-26 17:12:59 +02002021 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a592006-07-31 12:49:34 +02002022};
2023
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002024/*
2025 STAC 9205 pin configs for
2026 102801F1
2027 102801F2
2028 102801FC
2029 102801FD
2030 10280204
2031 1028021F
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002032 10280228 (Dell Vostro 1500)
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002033*/
2034static unsigned int dell_9205_m42_pin_configs[12] = {
2035 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2036 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2037 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2038};
2039
2040/*
2041 STAC 9205 pin configs for
2042 102801F9
2043 102801FA
2044 102801FE
2045 102801FF (Dell Precision M4300)
2046 10280206
2047 10280200
2048 10280201
2049*/
2050static unsigned int dell_9205_m43_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002051 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2052 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2053 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2054};
2055
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002056static unsigned int dell_9205_m44_pin_configs[12] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002057 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2058 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2059 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2060};
2061
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002062static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002063 [STAC_9205_REF] = ref9205_pin_configs,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002064 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2065 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2066 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
Matt Porterf3302a592006-07-31 12:49:34 +02002067};
2068
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002069static const char *stac9205_models[STAC_9205_MODELS] = {
2070 [STAC_9205_REF] = "ref",
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002071 [STAC_9205_DELL_M42] = "dell-m42",
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002072 [STAC_9205_DELL_M43] = "dell-m43",
2073 [STAC_9205_DELL_M44] = "dell-m44",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002074};
2075
2076static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2077 /* SigmaTel reference board */
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2079 "DFI LanParty", STAC_9205_REF),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2081 "unknown Dell", STAC_9205_DELL_M42),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2083 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
Matthew Ranostayb44ef2f2007-09-18 00:52:38 +02002085 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2087 "Dell Precision", STAC_9205_DELL_M43),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2089 "Dell Precision", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2091 "unknown Dell", STAC_9205_DELL_M42),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2093 "unknown Dell", STAC_9205_DELL_M42),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2095 "Dell Precision", STAC_9205_DELL_M43),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002097 "Dell Precision M4300", STAC_9205_DELL_M43),
Takashi Iwaidfe495d2007-08-23 19:04:28 +02002098 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2099 "unknown Dell", STAC_9205_DELL_M42),
Takashi Iwai45499152008-06-12 16:27:24 +02002100 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2101 "Dell Precision", STAC_9205_DELL_M43),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2103 "Dell Precision", STAC_9205_DELL_M43),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2105 "Dell Precision", STAC_9205_DELL_M43),
Tobin Davisae0a8ed2007-08-13 15:50:29 +02002106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2107 "Dell Inspiron", STAC_9205_DELL_M44),
Matthew Ranostay3fa2ef72008-01-11 11:39:06 +01002108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2109 "Dell Vostro 1500", STAC_9205_DELL_M42),
Matt Porterf3302a592006-07-31 12:49:34 +02002110 {} /* terminator */
2111};
2112
Richard Fish11b44bb2006-08-23 18:31:34 +02002113static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2114{
2115 int i;
2116 struct sigmatel_spec *spec = codec->spec;
2117
2118 if (! spec->bios_pin_configs) {
2119 spec->bios_pin_configs = kcalloc(spec->num_pins,
2120 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2121 if (! spec->bios_pin_configs)
2122 return -ENOMEM;
2123 }
2124
2125 for (i = 0; i < spec->num_pins; i++) {
2126 hda_nid_t nid = spec->pin_nids[i];
2127 unsigned int pin_cfg;
2128
2129 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2130 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2131 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2132 nid, pin_cfg);
2133 spec->bios_pin_configs[i] = pin_cfg;
2134 }
2135
2136 return 0;
2137}
2138
Matthew Ranostay87d48362007-07-17 11:52:24 +02002139static void stac92xx_set_config_reg(struct hda_codec *codec,
2140 hda_nid_t pin_nid, unsigned int pin_config)
2141{
2142 int i;
2143 snd_hda_codec_write(codec, pin_nid, 0,
2144 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2145 pin_config & 0x000000ff);
2146 snd_hda_codec_write(codec, pin_nid, 0,
2147 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2148 (pin_config & 0x0000ff00) >> 8);
2149 snd_hda_codec_write(codec, pin_nid, 0,
2150 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2151 (pin_config & 0x00ff0000) >> 16);
2152 snd_hda_codec_write(codec, pin_nid, 0,
2153 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2154 pin_config >> 24);
2155 i = snd_hda_codec_read(codec, pin_nid, 0,
2156 AC_VERB_GET_CONFIG_DEFAULT,
2157 0x00);
2158 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2159 pin_nid, i);
2160}
2161
Matt2f2f4252005-04-13 14:45:30 +02002162static void stac92xx_set_config_regs(struct hda_codec *codec)
2163{
2164 int i;
2165 struct sigmatel_spec *spec = codec->spec;
Matt2f2f4252005-04-13 14:45:30 +02002166
Matthew Ranostay87d48362007-07-17 11:52:24 +02002167 if (!spec->pin_configs)
2168 return;
Richard Fish11b44bb2006-08-23 18:31:34 +02002169
Matthew Ranostay87d48362007-07-17 11:52:24 +02002170 for (i = 0; i < spec->num_pins; i++)
2171 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2172 spec->pin_configs[i]);
Matt2f2f4252005-04-13 14:45:30 +02002173}
Matt2f2f4252005-04-13 14:45:30 +02002174
Matt2f2f4252005-04-13 14:45:30 +02002175/*
2176 * Analog playback callbacks
2177 */
2178static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2179 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002180 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002181{
2182 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002183 if (spec->stream_delay)
2184 msleep(spec->stream_delay);
Takashi Iwai9a081602008-02-12 18:37:26 +01002185 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2186 hinfo);
Matt2f2f4252005-04-13 14:45:30 +02002187}
2188
2189static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2190 struct hda_codec *codec,
2191 unsigned int stream_tag,
2192 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002193 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002194{
2195 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +01002196 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +02002197}
2198
2199static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2200 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002201 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002202{
2203 struct sigmatel_spec *spec = codec->spec;
2204 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2205}
2206
2207/*
Mattdabbed62005-06-14 10:19:34 +02002208 * Digital playback callbacks
2209 */
2210static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2211 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002212 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002213{
2214 struct sigmatel_spec *spec = codec->spec;
2215 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2216}
2217
2218static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2219 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002220 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +02002221{
2222 struct sigmatel_spec *spec = codec->spec;
2223 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2224}
2225
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002226static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2227 struct hda_codec *codec,
2228 unsigned int stream_tag,
2229 unsigned int format,
2230 struct snd_pcm_substream *substream)
2231{
2232 struct sigmatel_spec *spec = codec->spec;
2233 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2234 stream_tag, format, substream);
2235}
2236
Mattdabbed62005-06-14 10:19:34 +02002237
2238/*
Matt2f2f4252005-04-13 14:45:30 +02002239 * Analog capture callbacks
2240 */
2241static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2242 struct hda_codec *codec,
2243 unsigned int stream_tag,
2244 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002245 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002246{
2247 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002248 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002249
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002250 if (spec->powerdown_adcs) {
2251 msleep(40);
2252 snd_hda_codec_write_cache(codec, nid, 0,
2253 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2254 }
2255 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
Matt2f2f4252005-04-13 14:45:30 +02002256 return 0;
2257}
2258
2259static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002261 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +02002262{
2263 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002264 hda_nid_t nid = spec->adc_nids[substream->number];
Matt2f2f4252005-04-13 14:45:30 +02002265
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02002266 snd_hda_codec_cleanup_stream(codec, nid);
2267 if (spec->powerdown_adcs)
2268 snd_hda_codec_write_cache(codec, nid, 0,
2269 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Matt2f2f4252005-04-13 14:45:30 +02002270 return 0;
2271}
2272
Mattdabbed62005-06-14 10:19:34 +02002273static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2274 .substreams = 1,
2275 .channels_min = 2,
2276 .channels_max = 2,
2277 /* NID is set in stac92xx_build_pcms */
2278 .ops = {
2279 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002280 .close = stac92xx_dig_playback_pcm_close,
2281 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +02002282 },
2283};
2284
2285static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2286 .substreams = 1,
2287 .channels_min = 2,
2288 .channels_max = 2,
2289 /* NID is set in stac92xx_build_pcms */
2290};
2291
Matt2f2f4252005-04-13 14:45:30 +02002292static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2293 .substreams = 1,
2294 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +02002295 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +02002296 .nid = 0x02, /* NID to query formats and rates */
2297 .ops = {
2298 .open = stac92xx_playback_pcm_open,
2299 .prepare = stac92xx_playback_pcm_prepare,
2300 .cleanup = stac92xx_playback_pcm_cleanup
2301 },
2302};
2303
Matt Porter3cc08dc2006-01-23 15:27:49 +01002304static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2305 .substreams = 1,
2306 .channels_min = 2,
2307 .channels_max = 2,
2308 .nid = 0x06, /* NID to query formats and rates */
2309 .ops = {
2310 .open = stac92xx_playback_pcm_open,
2311 .prepare = stac92xx_playback_pcm_prepare,
2312 .cleanup = stac92xx_playback_pcm_cleanup
2313 },
2314};
2315
Matt2f2f4252005-04-13 14:45:30 +02002316static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
Matt2f2f4252005-04-13 14:45:30 +02002317 .channels_min = 2,
2318 .channels_max = 2,
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002319 /* NID + .substreams is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +02002320 .ops = {
2321 .prepare = stac92xx_capture_pcm_prepare,
2322 .cleanup = stac92xx_capture_pcm_cleanup
2323 },
2324};
2325
2326static int stac92xx_build_pcms(struct hda_codec *codec)
2327{
2328 struct sigmatel_spec *spec = codec->spec;
2329 struct hda_pcm *info = spec->pcm_rec;
2330
2331 codec->num_pcms = 1;
2332 codec->pcm_info = info;
2333
Mattc7d4b2f2005-06-27 14:59:41 +02002334 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02002335 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02002336 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002337 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02002338 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
Matt Porter3cc08dc2006-01-23 15:27:49 +01002339
2340 if (spec->alt_switch) {
2341 codec->num_pcms++;
2342 info++;
2343 info->name = "STAC92xx Analog Alt";
2344 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2345 }
Matt2f2f4252005-04-13 14:45:30 +02002346
Mattdabbed62005-06-14 10:19:34 +02002347 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2348 codec->num_pcms++;
2349 info++;
2350 info->name = "STAC92xx Digital";
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002351 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Mattdabbed62005-06-14 10:19:34 +02002352 if (spec->multiout.dig_out_nid) {
2353 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2354 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2355 }
2356 if (spec->dig_in_nid) {
2357 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2358 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2359 }
2360 }
2361
Matt2f2f4252005-04-13 14:45:30 +02002362 return 0;
2363}
2364
Takashi Iwaic960a032006-03-23 17:06:28 +01002365static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2366{
2367 unsigned int pincap = snd_hda_param_read(codec, nid,
2368 AC_PAR_PIN_CAP);
2369 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2370 if (pincap & AC_PINCAP_VREF_100)
2371 return AC_PINCTL_VREF_100;
2372 if (pincap & AC_PINCAP_VREF_80)
2373 return AC_PINCTL_VREF_80;
2374 if (pincap & AC_PINCAP_VREF_50)
2375 return AC_PINCTL_VREF_50;
2376 if (pincap & AC_PINCAP_VREF_GRD)
2377 return AC_PINCTL_VREF_GRD;
2378 return 0;
2379}
2380
Matt Porter403d1942005-11-29 15:00:51 +01002381static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2382
2383{
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002384 snd_hda_codec_write_cache(codec, nid, 0,
2385 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
Matt Porter403d1942005-11-29 15:00:51 +01002386}
2387
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002388#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2389
2390static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2391 struct snd_ctl_elem_value *ucontrol)
2392{
2393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2394 struct sigmatel_spec *spec = codec->spec;
2395
2396 ucontrol->value.integer.value[0] = spec->hp_switch;
2397 return 0;
2398}
2399
2400static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2401 struct snd_ctl_elem_value *ucontrol)
2402{
2403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2404 struct sigmatel_spec *spec = codec->spec;
2405
2406 spec->hp_switch = ucontrol->value.integer.value[0];
2407
2408 /* check to be sure that the ports are upto date with
2409 * switch changes
2410 */
2411 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2412
2413 return 1;
2414}
2415
Takashi Iwaia5ce8892007-07-23 15:42:26 +02002416#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
Matt Porter403d1942005-11-29 15:00:51 +01002417
2418static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2419{
2420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2421 struct sigmatel_spec *spec = codec->spec;
2422 int io_idx = kcontrol-> private_value & 0xff;
2423
2424 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2425 return 0;
2426}
2427
2428static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2429{
2430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2431 struct sigmatel_spec *spec = codec->spec;
2432 hda_nid_t nid = kcontrol->private_value >> 8;
2433 int io_idx = kcontrol-> private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002434 unsigned short val = !!ucontrol->value.integer.value[0];
Matt Porter403d1942005-11-29 15:00:51 +01002435
2436 spec->io_switch[io_idx] = val;
2437
2438 if (val)
2439 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01002440 else {
2441 unsigned int pinctl = AC_PINCTL_IN_EN;
2442 if (io_idx) /* set VREF for mic */
2443 pinctl |= stac92xx_get_vref(codec, nid);
2444 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2445 }
Jiang Zhe40c1d302007-11-12 13:05:16 +01002446
2447 /* check the auto-mute again: we need to mute/unmute the speaker
2448 * appropriately according to the pin direction
2449 */
2450 if (spec->hp_detect)
2451 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2452
Matt Porter403d1942005-11-29 15:00:51 +01002453 return 1;
2454}
2455
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002456#define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2457
2458static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2459 struct snd_ctl_elem_value *ucontrol)
2460{
2461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2462 struct sigmatel_spec *spec = codec->spec;
2463
2464 ucontrol->value.integer.value[0] = spec->clfe_swap;
2465 return 0;
2466}
2467
2468static int stac92xx_clfe_switch_put(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 hda_nid_t nid = kcontrol->private_value & 0xff;
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002474 unsigned int val = !!ucontrol->value.integer.value[0];
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002475
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002476 if (spec->clfe_swap == val)
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002477 return 0;
2478
Takashi Iwai68ea7b22007-11-15 15:54:38 +01002479 spec->clfe_swap = val;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002480
2481 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2482 spec->clfe_swap ? 0x4 : 0x0);
2483
2484 return 1;
2485}
2486
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002487#define STAC_CODEC_HP_SWITCH(xname) \
2488 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2489 .name = xname, \
2490 .index = 0, \
2491 .info = stac92xx_hp_switch_info, \
2492 .get = stac92xx_hp_switch_get, \
2493 .put = stac92xx_hp_switch_put, \
2494 }
2495
Matt Porter403d1942005-11-29 15:00:51 +01002496#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2497 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2498 .name = xname, \
2499 .index = 0, \
2500 .info = stac92xx_io_switch_info, \
2501 .get = stac92xx_io_switch_get, \
2502 .put = stac92xx_io_switch_put, \
2503 .private_value = xpval, \
2504 }
2505
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002506#define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2507 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2508 .name = xname, \
2509 .index = 0, \
2510 .info = stac92xx_clfe_switch_info, \
2511 .get = stac92xx_clfe_switch_get, \
2512 .put = stac92xx_clfe_switch_put, \
2513 .private_value = xpval, \
2514 }
Matt Porter403d1942005-11-29 15:00:51 +01002515
Mattc7d4b2f2005-06-27 14:59:41 +02002516enum {
2517 STAC_CTL_WIDGET_VOL,
2518 STAC_CTL_WIDGET_MUTE,
Matthew Ranostay09a99952008-01-24 11:49:21 +01002519 STAC_CTL_WIDGET_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002520 STAC_CTL_WIDGET_AMP_MUX,
2521 STAC_CTL_WIDGET_AMP_VOL,
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002522 STAC_CTL_WIDGET_HP_SWITCH,
Matt Porter403d1942005-11-29 15:00:51 +01002523 STAC_CTL_WIDGET_IO_SWITCH,
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002524 STAC_CTL_WIDGET_CLFE_SWITCH
Mattc7d4b2f2005-06-27 14:59:41 +02002525};
2526
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002527static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02002528 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2529 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matthew Ranostay09a99952008-01-24 11:49:21 +01002530 STAC_MONO_MUX,
Matthew Ranostay89385032008-09-11 09:49:39 -04002531 STAC_AMP_MUX,
2532 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002533 STAC_CODEC_HP_SWITCH(NULL),
Matt Porter403d1942005-11-29 15:00:51 +01002534 STAC_CODEC_IO_SWITCH(NULL, 0),
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002535 STAC_CODEC_CLFE_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02002536};
2537
2538/* add dynamic controls */
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002539static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2540 int idx, const char *name, unsigned long val)
Mattc7d4b2f2005-06-27 14:59:41 +02002541{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002542 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02002543
2544 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2545 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2546
2547 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2548 if (! knew)
2549 return -ENOMEM;
2550 if (spec->kctl_alloc) {
2551 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2552 kfree(spec->kctl_alloc);
2553 }
2554 spec->kctl_alloc = knew;
2555 spec->num_kctl_alloc = num;
2556 }
2557
2558 knew = &spec->kctl_alloc[spec->num_kctl_used];
2559 *knew = stac92xx_control_templates[type];
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002560 knew->index = idx;
Takashi Iwai82fe0c52005-06-30 10:54:33 +02002561 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02002562 if (! knew->name)
2563 return -ENOMEM;
2564 knew->private_value = val;
2565 spec->num_kctl_used++;
2566 return 0;
2567}
2568
Matthew Ranostay4682eee2008-08-15 07:43:24 +02002569
2570/* add dynamic controls */
2571static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2572 const char *name, unsigned long val)
2573{
2574 return stac92xx_add_control_idx(spec, type, 0, name, val);
2575}
2576
Matt Porter403d1942005-11-29 15:00:51 +01002577/* flag inputs as additional dynamic lineouts */
2578static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2579{
2580 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002581 unsigned int wcaps, wtype;
2582 int i, num_dacs = 0;
2583
2584 /* use the wcaps cache to count all DACs available for line-outs */
2585 for (i = 0; i < codec->num_nodes; i++) {
2586 wcaps = codec->wcaps[i];
2587 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01002588
Steve Longerbeam7b043892007-05-03 20:50:03 +02002589 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2590 num_dacs++;
2591 }
Matt Porter403d1942005-11-29 15:00:51 +01002592
Steve Longerbeam7b043892007-05-03 20:50:03 +02002593 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2594
Matt Porter403d1942005-11-29 15:00:51 +01002595 switch (cfg->line_outs) {
2596 case 3:
2597 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002598 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002599 cfg->line_out_pins[cfg->line_outs] =
2600 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002601 spec->line_switch = 1;
2602 cfg->line_outs++;
2603 }
2604 break;
2605 case 2:
2606 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002607 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002608 cfg->line_out_pins[cfg->line_outs] =
2609 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002610 spec->line_switch = 1;
2611 cfg->line_outs++;
2612 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002613 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002614 cfg->line_out_pins[cfg->line_outs] =
2615 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002616 spec->mic_switch = 1;
2617 cfg->line_outs++;
2618 }
2619 break;
2620 case 1:
2621 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02002622 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002623 cfg->line_out_pins[cfg->line_outs] =
2624 cfg->input_pins[AUTO_PIN_LINE];
Matt Porter403d1942005-11-29 15:00:51 +01002625 spec->line_switch = 1;
2626 cfg->line_outs++;
2627 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002628 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Takashi Iwaic480f792007-09-03 09:43:38 +02002629 cfg->line_out_pins[cfg->line_outs] =
2630 cfg->input_pins[AUTO_PIN_MIC];
Matt Porter403d1942005-11-29 15:00:51 +01002631 spec->mic_switch = 1;
2632 cfg->line_outs++;
2633 }
2634 break;
2635 }
2636
2637 return 0;
2638}
2639
Steve Longerbeam7b043892007-05-03 20:50:03 +02002640
2641static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2642{
2643 int i;
2644
2645 for (i = 0; i < spec->multiout.num_dacs; i++) {
2646 if (spec->multiout.dac_nids[i] == nid)
2647 return 1;
2648 }
2649
2650 return 0;
2651}
2652
Matt Porter3cc08dc2006-01-23 15:27:49 +01002653/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02002654 * Fill in the dac_nids table from the parsed pin configuration
2655 * This function only works when every pin in line_out_pins[]
2656 * contains atleast one DAC in its connection list. Some 92xx
2657 * codecs are not connected directly to a DAC, such as the 9200
2658 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01002659 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02002660static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaidf802952007-07-02 19:18:00 +02002661 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002662{
2663 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002664 int i, j, conn_len = 0;
2665 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2666 unsigned int wcaps, wtype;
2667
Mattc7d4b2f2005-06-27 14:59:41 +02002668 for (i = 0; i < cfg->line_outs; i++) {
2669 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02002670 conn_len = snd_hda_get_connections(codec, nid, conn,
2671 HDA_MAX_CONNECTIONS);
2672 for (j = 0; j < conn_len; j++) {
2673 wcaps = snd_hda_param_read(codec, conn[j],
2674 AC_PAR_AUDIO_WIDGET_CAP);
2675 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Steve Longerbeam7b043892007-05-03 20:50:03 +02002676 if (wtype != AC_WID_AUD_OUT ||
2677 (wcaps & AC_WCAP_DIGITAL))
2678 continue;
2679 /* conn[j] is a DAC routed to this line-out */
2680 if (!is_in_dac_nids(spec, conn[j]))
2681 break;
2682 }
2683
2684 if (j == conn_len) {
Takashi Iwaidf802952007-07-02 19:18:00 +02002685 if (spec->multiout.num_dacs > 0) {
2686 /* we have already working output pins,
2687 * so let's drop the broken ones again
2688 */
2689 cfg->line_outs = spec->multiout.num_dacs;
2690 break;
2691 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02002692 /* error out, no available DAC found */
2693 snd_printk(KERN_ERR
2694 "%s: No available DAC for pin 0x%x\n",
2695 __func__, nid);
2696 return -ENODEV;
2697 }
2698
2699 spec->multiout.dac_nids[i] = conn[j];
2700 spec->multiout.num_dacs++;
2701 if (conn_len > 1) {
2702 /* select this DAC in the pin's input mux */
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002703 snd_hda_codec_write_cache(codec, nid, 0,
2704 AC_VERB_SET_CONNECT_SEL, j);
Steve Longerbeam7b043892007-05-03 20:50:03 +02002705
2706 }
Mattc7d4b2f2005-06-27 14:59:41 +02002707 }
2708
Steve Longerbeam7b043892007-05-03 20:50:03 +02002709 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2710 spec->multiout.num_dacs,
2711 spec->multiout.dac_nids[0],
2712 spec->multiout.dac_nids[1],
2713 spec->multiout.dac_nids[2],
2714 spec->multiout.dac_nids[3],
2715 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02002716 return 0;
2717}
2718
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002719/* create volume control/switch for the given prefx type */
2720static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2721{
2722 char name[32];
2723 int err;
2724
2725 sprintf(name, "%s Playback Volume", pfx);
2726 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2727 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2728 if (err < 0)
2729 return err;
2730 sprintf(name, "%s Playback Switch", pfx);
2731 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2732 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2733 if (err < 0)
2734 return err;
2735 return 0;
2736}
2737
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002738static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2739{
2740 if (!spec->multiout.hp_nid)
2741 spec->multiout.hp_nid = nid;
2742 else if (spec->multiout.num_dacs > 4) {
2743 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2744 return 1;
2745 } else {
2746 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2747 spec->multiout.num_dacs++;
2748 }
2749 return 0;
2750}
2751
2752static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2753{
2754 if (is_in_dac_nids(spec, nid))
2755 return 1;
2756 if (spec->multiout.hp_nid == nid)
2757 return 1;
2758 return 0;
2759}
2760
Mattc7d4b2f2005-06-27 14:59:41 +02002761/* add playback controls from the parsed DAC table */
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002762static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
Takashi Iwai19039bd2006-06-28 15:52:16 +02002763 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002764{
Takashi Iwai19039bd2006-06-28 15:52:16 +02002765 static const char *chname[4] = {
2766 "Front", "Surround", NULL /*CLFE*/, "Side"
2767 };
Mattc7d4b2f2005-06-27 14:59:41 +02002768 hda_nid_t nid;
2769 int i, err;
2770
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002771 struct sigmatel_spec *spec = codec->spec;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002772 unsigned int wid_caps, pincap;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002773
2774
Takashi Iwai40ac8c42008-02-29 14:16:17 +01002775 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01002776 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02002777 continue;
2778
2779 nid = spec->multiout.dac_nids[i];
2780
2781 if (i == 2) {
2782 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002783 err = create_controls(spec, "Center", nid, 1);
2784 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002785 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002786 err = create_controls(spec, "LFE", nid, 2);
2787 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002788 return err;
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02002789
2790 wid_caps = get_wcaps(codec, nid);
2791
2792 if (wid_caps & AC_WCAP_LR_SWAP) {
2793 err = stac92xx_add_control(spec,
2794 STAC_CTL_WIDGET_CLFE_SWITCH,
2795 "Swap Center/LFE Playback Switch", nid);
2796
2797 if (err < 0)
2798 return err;
2799 }
2800
Mattc7d4b2f2005-06-27 14:59:41 +02002801 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002802 err = create_controls(spec, chname[i], nid, 3);
2803 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02002804 return err;
2805 }
2806 }
2807
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02002808 if (cfg->hp_outs > 1) {
2809 err = stac92xx_add_control(spec,
2810 STAC_CTL_WIDGET_HP_SWITCH,
2811 "Headphone as Line Out Switch", 0);
2812 if (err < 0)
2813 return err;
2814 }
2815
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002816 if (spec->line_switch) {
2817 nid = cfg->input_pins[AUTO_PIN_LINE];
2818 pincap = snd_hda_param_read(codec, nid,
2819 AC_PAR_PIN_CAP);
2820 if (pincap & AC_PINCAP_OUT) {
2821 err = stac92xx_add_control(spec,
2822 STAC_CTL_WIDGET_IO_SWITCH,
2823 "Line In as Output Switch", nid << 8);
2824 if (err < 0)
2825 return err;
2826 }
2827 }
Matt Porter403d1942005-11-29 15:00:51 +01002828
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002829 if (spec->mic_switch) {
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002830 unsigned int def_conf;
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002831 unsigned int mic_pin = AUTO_PIN_MIC;
2832again:
2833 nid = cfg->input_pins[mic_pin];
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002834 def_conf = snd_hda_codec_read(codec, nid, 0,
2835 AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002836 /* some laptops have an internal analog microphone
2837 * which can't be used as a output */
2838 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2839 pincap = snd_hda_param_read(codec, nid,
2840 AC_PAR_PIN_CAP);
2841 if (pincap & AC_PINCAP_OUT) {
2842 err = stac92xx_add_control(spec,
2843 STAC_CTL_WIDGET_IO_SWITCH,
2844 "Mic as Output Switch", (nid << 8) | 1);
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002845 nid = snd_hda_codec_read(codec, nid, 0,
2846 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2847 if (!check_in_dac_nids(spec, nid))
2848 add_spec_dacs(spec, nid);
Matthew Ranostaycace16f2008-01-30 14:58:38 +01002849 if (err < 0)
2850 return err;
2851 }
Matthew Ranostayae0afd82008-02-22 17:55:05 +01002852 } else if (mic_pin == AUTO_PIN_MIC) {
2853 mic_pin = AUTO_PIN_FRONT_MIC;
2854 goto again;
Matthew Ranostayb5895dc2008-01-25 15:24:50 +01002855 }
2856 }
Matt Porter403d1942005-11-29 15:00:51 +01002857
Mattc7d4b2f2005-06-27 14:59:41 +02002858 return 0;
2859}
2860
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002861/* add playback controls for Speaker and HP outputs */
2862static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2863 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02002864{
2865 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002866 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002867 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02002868
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002869 old_num_dacs = spec->multiout.num_dacs;
2870 for (i = 0; i < cfg->hp_outs; i++) {
2871 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2872 if (wid_caps & AC_WCAP_UNSOL_CAP)
2873 spec->hp_detect = 1;
2874 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2875 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2876 if (check_in_dac_nids(spec, nid))
2877 nid = 0;
2878 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02002879 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002880 add_spec_dacs(spec, nid);
2881 }
2882 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02002883 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002884 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2885 if (check_in_dac_nids(spec, nid))
2886 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002887 if (! nid)
2888 continue;
2889 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02002890 }
Matthew Ranostay1b290a52007-07-12 15:17:34 +02002891 for (i = 0; i < cfg->line_outs; i++) {
2892 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2893 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2894 if (check_in_dac_nids(spec, nid))
2895 nid = 0;
2896 if (! nid)
2897 continue;
2898 add_spec_dacs(spec, nid);
2899 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002900 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2901 static const char *pfxs[] = {
2902 "Speaker", "External Speaker", "Speaker2",
2903 };
2904 err = create_controls(spec, pfxs[i - old_num_dacs],
2905 spec->multiout.dac_nids[i], 3);
2906 if (err < 0)
2907 return err;
2908 }
2909 if (spec->multiout.hp_nid) {
Takashi Iwai2626a262008-03-14 09:18:32 +01002910 err = create_controls(spec, "Headphone",
2911 spec->multiout.hp_nid, 3);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02002912 if (err < 0)
2913 return err;
2914 }
Mattc7d4b2f2005-06-27 14:59:41 +02002915
2916 return 0;
2917}
2918
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002919/* labels for mono mux outputs */
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02002920static const char *stac92xx_mono_labels[4] = {
2921 "DAC0", "DAC1", "Mixer", "DAC2"
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002922};
2923
2924/* create mono mux for mono out on capable codecs */
2925static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2926{
2927 struct sigmatel_spec *spec = codec->spec;
2928 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2929 int i, num_cons;
2930 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2931
2932 num_cons = snd_hda_get_connections(codec,
2933 spec->mono_nid,
2934 con_lst,
2935 HDA_MAX_NUM_INPUTS);
2936 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2937 return -EINVAL;
2938
2939 for (i = 0; i < num_cons; i++) {
2940 mono_mux->items[mono_mux->num_items].label =
2941 stac92xx_mono_labels[i];
2942 mono_mux->items[mono_mux->num_items].index = i;
2943 mono_mux->num_items++;
2944 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01002945
2946 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2947 "Mono Mux", spec->mono_nid);
Matthew Ranostayb22b4822008-01-22 12:32:30 +01002948}
2949
Matthew Ranostay89385032008-09-11 09:49:39 -04002950/* labels for amp mux outputs */
2951static const char *stac92xx_amp_labels[3] = {
2952 "Front Microphone", "Microphone", "Line In"
2953};
2954
2955/* create amp out controls mux on capable codecs */
2956static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
2957{
2958 struct sigmatel_spec *spec = codec->spec;
2959 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
2960 int i, err;
2961
2962 for (i = 0; i < ARRAY_SIZE(stac92xx_amp_labels); i++) {
2963 amp_mux->items[amp_mux->num_items].label =
2964 stac92xx_amp_labels[i];
2965 amp_mux->items[amp_mux->num_items].index = i;
2966 amp_mux->num_items++;
2967 }
2968
2969 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
2970 "Amp Selector Capture Switch", 0);
2971 if (err < 0)
2972 return err;
2973 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
2974 "Amp Capture Volume",
2975 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
2976}
2977
2978
Matthew Ranostay1cd22242008-07-18 18:20:52 +02002979/* create PC beep volume controls */
2980static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2981 hda_nid_t nid)
2982{
2983 struct sigmatel_spec *spec = codec->spec;
2984 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2985 int err;
2986
2987 /* check for mute support for the the amp */
2988 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2989 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2990 "PC Beep Playback Switch",
2991 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2992 if (err < 0)
2993 return err;
2994 }
2995
2996 /* check to see if there is volume support for the amp */
2997 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2998 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2999 "PC Beep Playback Volume",
3000 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3001 if (err < 0)
3002 return err;
3003 }
3004 return 0;
3005}
3006
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003007static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3008{
3009 struct sigmatel_spec *spec = codec->spec;
3010 int wcaps, nid, i, err = 0;
3011
3012 for (i = 0; i < spec->num_muxes; i++) {
3013 nid = spec->mux_nids[i];
3014 wcaps = get_wcaps(codec, nid);
3015
3016 if (wcaps & AC_WCAP_OUT_AMP) {
3017 err = stac92xx_add_control_idx(spec,
3018 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3019 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3020 if (err < 0)
3021 return err;
3022 }
3023 }
3024 return 0;
3025};
3026
Matthew Ranostayd9737752008-09-07 12:03:41 +02003027static const char *stac92xx_spdif_labels[3] = {
3028 "Digital Playback", "Analog Mux 1", "Analog Mux 2"
3029};
3030
3031static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3032{
3033 struct sigmatel_spec *spec = codec->spec;
3034 struct hda_input_mux *spdif_mux = &spec->private_smux;
3035 int i, num_cons;
3036 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_spdif_labels)];
3037
3038 num_cons = snd_hda_get_connections(codec,
3039 spec->smux_nids[0],
3040 con_lst,
3041 HDA_MAX_NUM_INPUTS);
3042 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_spdif_labels))
3043 return -EINVAL;
3044
3045 for (i = 0; i < num_cons; i++) {
3046 spdif_mux->items[spdif_mux->num_items].label =
3047 stac92xx_spdif_labels[i];
3048 spdif_mux->items[spdif_mux->num_items].index = i;
3049 spdif_mux->num_items++;
3050 }
3051
3052 return 0;
3053}
3054
Matt Porter8b657272006-10-26 17:12:59 +02003055/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01003056static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02003057 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3058 "Digital Mic 3", "Digital Mic 4"
3059};
3060
3061/* create playback/capture controls for input pins on dmic capable codecs */
3062static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3063 const struct auto_pin_cfg *cfg)
3064{
3065 struct sigmatel_spec *spec = codec->spec;
3066 struct hda_input_mux *dimux = &spec->private_dimux;
3067 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003068 int err, i, j;
3069 char name[32];
Matt Porter8b657272006-10-26 17:12:59 +02003070
3071 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3072 dimux->items[dimux->num_items].index = 0;
3073 dimux->num_items++;
3074
3075 for (i = 0; i < spec->num_dmics; i++) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003076 hda_nid_t nid;
Matt Porter8b657272006-10-26 17:12:59 +02003077 int index;
3078 int num_cons;
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003079 unsigned int wcaps;
Matt Porter8b657272006-10-26 17:12:59 +02003080 unsigned int def_conf;
3081
3082 def_conf = snd_hda_codec_read(codec,
3083 spec->dmic_nids[i],
3084 0,
3085 AC_VERB_GET_CONFIG_DEFAULT,
3086 0);
3087 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3088 continue;
3089
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003090 nid = spec->dmic_nids[i];
Matt Porter8b657272006-10-26 17:12:59 +02003091 num_cons = snd_hda_get_connections(codec,
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003092 spec->dmux_nids[0],
Matt Porter8b657272006-10-26 17:12:59 +02003093 con_lst,
3094 HDA_MAX_NUM_INPUTS);
3095 for (j = 0; j < num_cons; j++)
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003096 if (con_lst[j] == nid) {
Matt Porter8b657272006-10-26 17:12:59 +02003097 index = j;
3098 goto found;
3099 }
3100 continue;
3101found:
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003102 wcaps = get_wcaps(codec, nid) &
3103 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003104
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003105 if (wcaps) {
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003106 sprintf(name, "%s Capture Volume",
3107 stac92xx_dmic_labels[dimux->num_items]);
3108
3109 err = stac92xx_add_control(spec,
3110 STAC_CTL_WIDGET_VOL,
3111 name,
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003112 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3113 (wcaps & AC_WCAP_OUT_AMP) ?
3114 HDA_OUTPUT : HDA_INPUT));
Matthew Ranostay0678acc2008-01-08 12:10:50 +01003115 if (err < 0)
3116 return err;
3117 }
3118
Matt Porter8b657272006-10-26 17:12:59 +02003119 dimux->items[dimux->num_items].label =
3120 stac92xx_dmic_labels[dimux->num_items];
3121 dimux->items[dimux->num_items].index = index;
3122 dimux->num_items++;
3123 }
3124
3125 return 0;
3126}
3127
Mattc7d4b2f2005-06-27 14:59:41 +02003128/* create playback/capture controls for input pins */
3129static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3130{
3131 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003132 struct hda_input_mux *imux = &spec->private_imux;
3133 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3134 int i, j, k;
3135
3136 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003137 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02003138
Takashi Iwai314634b2006-09-21 11:56:18 +02003139 if (!cfg->input_pins[i])
3140 continue;
3141 index = -1;
3142 for (j = 0; j < spec->num_muxes; j++) {
3143 int num_cons;
3144 num_cons = snd_hda_get_connections(codec,
3145 spec->mux_nids[j],
3146 con_lst,
3147 HDA_MAX_NUM_INPUTS);
3148 for (k = 0; k < num_cons; k++)
3149 if (con_lst[k] == cfg->input_pins[i]) {
3150 index = k;
3151 goto found;
3152 }
Mattc7d4b2f2005-06-27 14:59:41 +02003153 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003154 continue;
3155 found:
3156 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3157 imux->items[imux->num_items].index = index;
3158 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02003159 }
3160
Steve Longerbeam7b043892007-05-03 20:50:03 +02003161 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02003162 /*
3163 * Set the current input for the muxes.
3164 * The STAC9221 has two input muxes with identical source
3165 * NID lists. Hopefully this won't get confused.
3166 */
3167 for (i = 0; i < spec->num_muxes; i++) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003168 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3169 AC_VERB_SET_CONNECT_SEL,
3170 imux->items[0].index);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003171 }
3172 }
3173
Mattc7d4b2f2005-06-27 14:59:41 +02003174 return 0;
3175}
3176
Mattc7d4b2f2005-06-27 14:59:41 +02003177static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3178{
3179 struct sigmatel_spec *spec = codec->spec;
3180 int i;
3181
3182 for (i = 0; i < spec->autocfg.line_outs; i++) {
3183 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3184 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3185 }
3186}
3187
3188static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3189{
3190 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003191 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003192
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003193 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3194 hda_nid_t pin;
3195 pin = spec->autocfg.hp_pins[i];
3196 if (pin) /* connect to front */
3197 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3198 }
3199 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3200 hda_nid_t pin;
3201 pin = spec->autocfg.speaker_pins[i];
3202 if (pin) /* connect to front */
3203 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3204 }
Mattc7d4b2f2005-06-27 14:59:41 +02003205}
3206
Matt Porter3cc08dc2006-01-23 15:27:49 +01003207static 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 +02003208{
3209 struct sigmatel_spec *spec = codec->spec;
3210 int err;
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003211 int hp_speaker_swap = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003212
Matt Porter8b657272006-10-26 17:12:59 +02003213 if ((err = snd_hda_parse_pin_def_config(codec,
3214 &spec->autocfg,
3215 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003216 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003217 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01003218 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02003219
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003220 /* If we have no real line-out pin and multiple hp-outs, HPs should
3221 * be set up as multi-channel outputs.
3222 */
3223 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3224 spec->autocfg.hp_outs > 1) {
3225 /* Copy hp_outs to line_outs, backup line_outs in
3226 * speaker_outs so that the following routines can handle
3227 * HP pins as primary outputs.
3228 */
3229 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3230 sizeof(spec->autocfg.line_out_pins));
3231 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3232 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3233 sizeof(spec->autocfg.hp_pins));
3234 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3235 hp_speaker_swap = 1;
3236 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003237 if (spec->autocfg.mono_out_pin) {
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003238 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3239 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
Matthew Ranostay09a99952008-01-24 11:49:21 +01003240 u32 caps = query_amp_caps(codec,
3241 spec->autocfg.mono_out_pin, dir);
3242 hda_nid_t conn_list[1];
3243
3244 /* get the mixer node and then the mono mux if it exists */
3245 if (snd_hda_get_connections(codec,
3246 spec->autocfg.mono_out_pin, conn_list, 1) &&
3247 snd_hda_get_connections(codec, conn_list[0],
3248 conn_list, 1)) {
3249
3250 int wcaps = get_wcaps(codec, conn_list[0]);
3251 int wid_type = (wcaps & AC_WCAP_TYPE)
3252 >> AC_WCAP_TYPE_SHIFT;
3253 /* LR swap check, some stac925x have a mux that
3254 * changes the DACs output path instead of the
3255 * mono-mux path.
3256 */
3257 if (wid_type == AC_WID_AUD_SEL &&
3258 !(wcaps & AC_WCAP_LR_SWAP))
3259 spec->mono_nid = conn_list[0];
3260 }
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003261 if (dir) {
3262 hda_nid_t nid = spec->autocfg.mono_out_pin;
3263
3264 /* most mono outs have a least a mute/unmute switch */
3265 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3266 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3267 "Mono Playback Switch",
3268 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
Matthew Ranostay09a99952008-01-24 11:49:21 +01003269 if (err < 0)
3270 return err;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003271 /* check for volume support for the amp */
3272 if ((caps & AC_AMPCAP_NUM_STEPS)
3273 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3274 err = stac92xx_add_control(spec,
3275 STAC_CTL_WIDGET_VOL,
3276 "Mono Playback Volume",
3277 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3278 if (err < 0)
3279 return err;
3280 }
Matthew Ranostay09a99952008-01-24 11:49:21 +01003281 }
3282
3283 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3284 AC_PINCTL_OUT_EN);
3285 }
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003286
Matt Porter403d1942005-11-29 15:00:51 +01003287 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3288 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02003289 if (spec->multiout.num_dacs == 0)
3290 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3291 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02003292
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003293 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3294
3295 if (err < 0)
3296 return err;
3297
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003298 /* setup analog beep controls */
3299 if (spec->anabeep_nid > 0) {
3300 err = stac92xx_auto_create_beep_ctls(codec,
3301 spec->anabeep_nid);
3302 if (err < 0)
3303 return err;
3304 }
3305
3306 /* setup digital beep controls and input device */
3307#ifdef CONFIG_SND_HDA_INPUT_BEEP
3308 if (spec->digbeep_nid > 0) {
3309 hda_nid_t nid = spec->digbeep_nid;
3310
3311 err = stac92xx_auto_create_beep_ctls(codec, nid);
3312 if (err < 0)
3313 return err;
3314 err = snd_hda_attach_beep_device(codec, nid);
3315 if (err < 0)
3316 return err;
3317 }
3318#endif
3319
Jiang Zhebcecd9b2007-11-12 12:57:03 +01003320 if (hp_speaker_swap == 1) {
3321 /* Restore the hp_outs and line_outs */
3322 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3323 sizeof(spec->autocfg.line_out_pins));
3324 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3325 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3326 sizeof(spec->autocfg.speaker_pins));
3327 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3328 memset(spec->autocfg.speaker_pins, 0,
3329 sizeof(spec->autocfg.speaker_pins));
3330 spec->autocfg.speaker_outs = 0;
3331 }
3332
Maxim Levitsky0fb87bb2007-09-03 15:29:04 +02003333 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3334
3335 if (err < 0)
3336 return err;
3337
3338 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3339
3340 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003341 return err;
3342
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003343 if (spec->mono_nid > 0) {
3344 err = stac92xx_auto_create_mono_output_ctls(codec);
3345 if (err < 0)
3346 return err;
3347 }
Matthew Ranostay89385032008-09-11 09:49:39 -04003348 if (spec->amp_nids) {
3349 err = stac92xx_auto_create_amp_output_ctls(codec);
3350 if (err < 0)
3351 return err;
3352 }
Matt Porter8b657272006-10-26 17:12:59 +02003353 if (spec->num_dmics > 0)
3354 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3355 &spec->autocfg)) < 0)
3356 return err;
Matthew Ranostay4682eee2008-08-15 07:43:24 +02003357 if (spec->num_muxes > 0) {
3358 err = stac92xx_auto_create_mux_input_ctls(codec);
3359 if (err < 0)
3360 return err;
3361 }
Matthew Ranostayd9737752008-09-07 12:03:41 +02003362 if (spec->num_smuxes > 0) {
3363 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3364 if (err < 0)
3365 return err;
3366 }
Matt Porter8b657272006-10-26 17:12:59 +02003367
Mattc7d4b2f2005-06-27 14:59:41 +02003368 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01003369 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02003370 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02003371
Takashi Iwai82bc9552006-03-21 11:24:42 +01003372 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003373 spec->multiout.dig_out_nid = dig_out;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003374 if (dig_in && spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01003375 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02003376
3377 if (spec->kctl_alloc)
3378 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3379
3380 spec->input_mux = &spec->private_imux;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003381 if (!spec->dinput_mux)
3382 spec->dinput_mux = &spec->private_dimux;
Matthew Ranostayd9737752008-09-07 12:03:41 +02003383 spec->sinput_mux = &spec->private_smux;
Matthew Ranostayb22b4822008-01-22 12:32:30 +01003384 spec->mono_mux = &spec->private_mono_mux;
Matthew Ranostay89385032008-09-11 09:49:39 -04003385 spec->amp_mux = &spec->private_amp_mux;
Mattc7d4b2f2005-06-27 14:59:41 +02003386 return 1;
3387}
3388
Takashi Iwai82bc9552006-03-21 11:24:42 +01003389/* add playback controls for HP output */
3390static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3391 struct auto_pin_cfg *cfg)
3392{
3393 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003394 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01003395 unsigned int wid_caps;
3396
3397 if (! pin)
3398 return 0;
3399
3400 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02003401 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01003402 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003403
3404 return 0;
3405}
3406
Richard Fish160ea0d2006-09-06 13:58:25 +02003407/* add playback controls for LFE output */
3408static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3409 struct auto_pin_cfg *cfg)
3410{
3411 struct sigmatel_spec *spec = codec->spec;
3412 int err;
3413 hda_nid_t lfe_pin = 0x0;
3414 int i;
3415
3416 /*
3417 * search speaker outs and line outs for a mono speaker pin
3418 * with an amp. If one is found, add LFE controls
3419 * for it.
3420 */
3421 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3422 hda_nid_t pin = spec->autocfg.speaker_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003423 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003424 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3425 if (wcaps == AC_WCAP_OUT_AMP)
3426 /* found a mono speaker with an amp, must be lfe */
3427 lfe_pin = pin;
3428 }
3429
3430 /* if speaker_outs is 0, then speakers may be in line_outs */
3431 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3432 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3433 hda_nid_t pin = spec->autocfg.line_out_pins[i];
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003434 unsigned int defcfg;
Harvey Harrison8b551782008-02-29 11:56:48 +01003435 defcfg = snd_hda_codec_read(codec, pin, 0,
Richard Fish160ea0d2006-09-06 13:58:25 +02003436 AC_VERB_GET_CONFIG_DEFAULT,
3437 0x00);
Harvey Harrison8b551782008-02-29 11:56:48 +01003438 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
Takashi Iwai64ed0df2008-02-29 11:57:53 +01003439 unsigned int wcaps = get_wcaps(codec, pin);
Richard Fish160ea0d2006-09-06 13:58:25 +02003440 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3441 if (wcaps == AC_WCAP_OUT_AMP)
3442 /* found a mono speaker with an amp,
3443 must be lfe */
3444 lfe_pin = pin;
3445 }
3446 }
3447 }
3448
3449 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003450 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02003451 if (err < 0)
3452 return err;
3453 }
3454
3455 return 0;
3456}
3457
Mattc7d4b2f2005-06-27 14:59:41 +02003458static int stac9200_parse_auto_config(struct hda_codec *codec)
3459{
3460 struct sigmatel_spec *spec = codec->spec;
3461 int err;
3462
Kailang Yangdf694da2005-12-05 19:42:22 +01003463 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02003464 return err;
3465
3466 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3467 return err;
3468
Takashi Iwai82bc9552006-03-21 11:24:42 +01003469 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3470 return err;
3471
Richard Fish160ea0d2006-09-06 13:58:25 +02003472 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3473 return err;
3474
Takashi Iwai82bc9552006-03-21 11:24:42 +01003475 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003476 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003477 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02003478 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02003479
3480 if (spec->kctl_alloc)
3481 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3482
3483 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02003484 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02003485
3486 return 1;
3487}
3488
Sam Revitch62fe78e2006-05-10 15:09:17 +02003489/*
3490 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3491 * funky external mute control using GPIO pins.
3492 */
3493
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003494static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003495 unsigned int dir_mask, unsigned int data)
Sam Revitch62fe78e2006-05-10 15:09:17 +02003496{
3497 unsigned int gpiostate, gpiomask, gpiodir;
3498
3499 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3500 AC_VERB_GET_GPIO_DATA, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003501 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003502
3503 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3504 AC_VERB_GET_GPIO_MASK, 0);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003505 gpiomask |= mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003506
3507 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3508 AC_VERB_GET_GPIO_DIRECTION, 0);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003509 gpiodir |= dir_mask;
Sam Revitch62fe78e2006-05-10 15:09:17 +02003510
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003511 /* Configure GPIOx as CMOS */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003512 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3513
3514 snd_hda_codec_write(codec, codec->afg, 0,
3515 AC_VERB_SET_GPIO_MASK, gpiomask);
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003516 snd_hda_codec_read(codec, codec->afg, 0,
3517 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003518
3519 msleep(1);
3520
Takashi Iwai76e1ddf2008-01-15 11:39:08 +01003521 snd_hda_codec_read(codec, codec->afg, 0,
3522 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
Sam Revitch62fe78e2006-05-10 15:09:17 +02003523}
3524
Takashi Iwai314634b2006-09-21 11:56:18 +02003525static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3526 unsigned int event)
3527{
3528 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003529 snd_hda_codec_write_cache(codec, nid, 0,
3530 AC_VERB_SET_UNSOLICITED_ENABLE,
3531 (AC_USRSP_EN | event));
Takashi Iwai314634b2006-09-21 11:56:18 +02003532}
3533
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003534static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3535{
3536 int i;
3537 for (i = 0; i < cfg->hp_outs; i++)
3538 if (cfg->hp_pins[i] == nid)
3539 return 1; /* nid is a HP-Out */
3540
3541 return 0; /* nid is not a HP-Out */
3542};
3543
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003544static void stac92xx_power_down(struct hda_codec *codec)
3545{
3546 struct sigmatel_spec *spec = codec->spec;
3547
3548 /* power down inactive DACs */
3549 hda_nid_t *dac;
3550 for (dac = spec->dac_list; *dac; dac++)
Matthew Ranostay44510892008-02-21 07:49:31 +01003551 if (!is_in_dac_nids(spec, *dac) &&
3552 spec->multiout.hp_nid != *dac)
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003553 snd_hda_codec_write_cache(codec, *dac, 0,
3554 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3555}
3556
Mattc7d4b2f2005-06-27 14:59:41 +02003557static int stac92xx_init(struct hda_codec *codec)
3558{
3559 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003560 struct auto_pin_cfg *cfg = &spec->autocfg;
3561 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02003562
Mattc7d4b2f2005-06-27 14:59:41 +02003563 snd_hda_sequence_write(codec, spec->init);
3564
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02003565 /* power down adcs initially */
3566 if (spec->powerdown_adcs)
3567 for (i = 0; i < spec->num_adcs; i++)
3568 snd_hda_codec_write_cache(codec,
3569 spec->adc_nids[i], 0,
3570 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003571 /* set up pins */
3572 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02003573 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003574 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02003575 enable_pin_detect(codec, cfg->hp_pins[i],
3576 STAC_HP_EVENT);
Takashi Iwai0a07aca2007-03-13 10:40:23 +01003577 /* force to enable the first line-out; the others are set up
3578 * in unsol_event
3579 */
3580 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3581 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02003582 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003583 /* fake event to set up pins */
3584 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3585 } else {
3586 stac92xx_auto_init_multi_out(codec);
3587 stac92xx_auto_init_hp_out(codec);
3588 }
3589 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01003590 hda_nid_t nid = cfg->input_pins[i];
3591 if (nid) {
3592 unsigned int pinctl = AC_PINCTL_IN_EN;
3593 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3594 pinctl |= stac92xx_get_vref(codec, nid);
3595 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3596 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01003597 }
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003598 for (i = 0; i < spec->num_dmics; i++)
3599 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3600 AC_PINCTL_IN_EN);
3601 for (i = 0; i < spec->num_pwrs; i++) {
3602 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3603 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3604 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3605 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003606 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3607 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003608 def_conf = get_defcfg_connect(def_conf);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003609 /* outputs are only ports capable of power management
3610 * any attempts on powering down a input port cause the
3611 * referenced VREF to act quirky.
3612 */
3613 if (pinctl & AC_PINCTL_IN_EN)
3614 continue;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02003615 /* skip any ports that don't have jacks since presence
3616 * detection is useless */
3617 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
Matthew Ranostaybce6c2b2008-02-29 12:07:43 +01003618 continue;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003619 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3620 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3621 }
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003622 if (spec->dac_list)
3623 stac92xx_power_down(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01003624 if (cfg->dig_out_pin)
3625 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3626 AC_PINCTL_OUT_EN);
3627 if (cfg->dig_in_pin)
3628 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3629 AC_PINCTL_IN_EN);
3630
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003631 stac_gpio_set(codec, spec->gpio_mask,
3632 spec->gpio_dir, spec->gpio_data);
Sam Revitch62fe78e2006-05-10 15:09:17 +02003633
Mattc7d4b2f2005-06-27 14:59:41 +02003634 return 0;
3635}
3636
Matt2f2f4252005-04-13 14:45:30 +02003637static void stac92xx_free(struct hda_codec *codec)
3638{
Mattc7d4b2f2005-06-27 14:59:41 +02003639 struct sigmatel_spec *spec = codec->spec;
3640 int i;
3641
3642 if (! spec)
3643 return;
3644
3645 if (spec->kctl_alloc) {
3646 for (i = 0; i < spec->num_kctl_used; i++)
3647 kfree(spec->kctl_alloc[i].name);
3648 kfree(spec->kctl_alloc);
3649 }
3650
Richard Fish11b44bb2006-08-23 18:31:34 +02003651 if (spec->bios_pin_configs)
3652 kfree(spec->bios_pin_configs);
3653
Mattc7d4b2f2005-06-27 14:59:41 +02003654 kfree(spec);
Matthew Ranostay1cd22242008-07-18 18:20:52 +02003655 snd_hda_detach_beep_device(codec);
Matt2f2f4252005-04-13 14:45:30 +02003656}
3657
Matt4e550962005-07-04 17:51:39 +02003658static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3659 unsigned int flag)
3660{
3661 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3662 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02003663
Takashi Iwaif9acba42007-05-29 18:01:06 +02003664 if (pin_ctl & AC_PINCTL_IN_EN) {
3665 /*
3666 * we need to check the current set-up direction of
3667 * shared input pins since they can be switched via
3668 * "xxx as Output" mixer switch
3669 */
3670 struct sigmatel_spec *spec = codec->spec;
3671 struct auto_pin_cfg *cfg = &spec->autocfg;
3672 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3673 spec->line_switch) ||
3674 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3675 spec->mic_switch))
3676 return;
3677 }
3678
Steve Longerbeam7b043892007-05-03 20:50:03 +02003679 /* if setting pin direction bits, clear the current
3680 direction bits first */
3681 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3682 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3683
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003684 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003685 AC_VERB_SET_PIN_WIDGET_CONTROL,
3686 pin_ctl | flag);
3687}
3688
3689static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3690 unsigned int flag)
3691{
3692 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3693 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003694 snd_hda_codec_write_cache(codec, nid, 0,
Matt4e550962005-07-04 17:51:39 +02003695 AC_VERB_SET_PIN_WIDGET_CONTROL,
3696 pin_ctl & ~flag);
3697}
3698
Jiang Zhe40c1d302007-11-12 13:05:16 +01003699static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwai314634b2006-09-21 11:56:18 +02003700{
3701 if (!nid)
3702 return 0;
3703 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
Jiang Zhe40c1d302007-11-12 13:05:16 +01003704 & (1 << 31)) {
3705 unsigned int pinctl;
3706 pinctl = snd_hda_codec_read(codec, nid, 0,
3707 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3708 if (pinctl & AC_PINCTL_IN_EN)
3709 return 0; /* mic- or line-input */
3710 else
3711 return 1; /* HP-output */
3712 }
Takashi Iwai314634b2006-09-21 11:56:18 +02003713 return 0;
3714}
3715
3716static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02003717{
3718 struct sigmatel_spec *spec = codec->spec;
3719 struct auto_pin_cfg *cfg = &spec->autocfg;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003720 int nid = cfg->hp_pins[cfg->hp_outs - 1];
Matt4e550962005-07-04 17:51:39 +02003721 int i, presence;
3722
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003723 presence = 0;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003724 if (spec->gpio_mute)
3725 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3726 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3727
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003728 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003729 if (presence)
3730 break;
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003731 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3732 break;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003733 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003734 }
Matt4e550962005-07-04 17:51:39 +02003735
3736 if (presence) {
3737 /* disable lineouts, enable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003738 if (spec->hp_switch)
3739 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003740 for (i = 0; i < cfg->line_outs; i++)
3741 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3742 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003743 for (i = 0; i < cfg->speaker_outs; i++)
3744 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3745 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003746 if (spec->eapd_mask)
3747 stac_gpio_set(codec, spec->gpio_mask,
3748 spec->gpio_dir, spec->gpio_data &
3749 ~spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003750 } else {
3751 /* enable lineouts, disable hp */
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003752 if (spec->hp_switch)
3753 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003754 for (i = 0; i < cfg->line_outs; i++)
3755 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3756 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003757 for (i = 0; i < cfg->speaker_outs; i++)
3758 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3759 AC_PINCTL_OUT_EN);
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02003760 if (spec->eapd_mask)
3761 stac_gpio_set(codec, spec->gpio_mask,
3762 spec->gpio_dir, spec->gpio_data |
3763 spec->eapd_mask);
Matt4e550962005-07-04 17:51:39 +02003764 }
Matthew Ranostay7c2ba972008-04-16 13:13:59 +02003765 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3766 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02003767}
3768
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003769static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3770{
3771 struct sigmatel_spec *spec = codec->spec;
3772 hda_nid_t nid = spec->pwr_nids[idx];
3773 int presence, val;
3774 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3775 & 0x000000ff;
3776 presence = get_hp_pin_presence(codec, nid);
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02003777
3778 /* several codecs have two power down bits */
3779 if (spec->pwr_mapping)
3780 idx = spec->pwr_mapping[idx];
3781 else
3782 idx = 1 << idx;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003783
3784 if (presence)
3785 val &= ~idx;
3786 else
3787 val |= idx;
3788
3789 /* power down unused output ports */
3790 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3791};
3792
Takashi Iwai314634b2006-09-21 11:56:18 +02003793static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3794{
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003795 struct sigmatel_spec *spec = codec->spec;
3796 int idx = res >> 26 & 0x0f;
3797
3798 switch ((res >> 26) & 0x30) {
Takashi Iwai314634b2006-09-21 11:56:18 +02003799 case STAC_HP_EVENT:
3800 stac92xx_hp_detect(codec, res);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003801 /* fallthru */
3802 case STAC_PWR_EVENT:
3803 if (spec->num_pwrs > 0)
3804 stac92xx_pin_sense(codec, idx);
Takashi Iwai314634b2006-09-21 11:56:18 +02003805 }
3806}
3807
Takashi Iwaicb53c622007-08-10 17:21:45 +02003808#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003809static int stac92xx_resume(struct hda_codec *codec)
3810{
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003811 struct sigmatel_spec *spec = codec->spec;
3812
Richard Fish11b44bb2006-08-23 18:31:34 +02003813 stac92xx_set_config_regs(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003814 snd_hda_sequence_write(codec, spec->init);
Matthew Ranostay4fe51952008-01-29 15:28:44 +01003815 stac_gpio_set(codec, spec->gpio_mask,
3816 spec->gpio_dir, spec->gpio_data);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003817 snd_hda_codec_resume_amp(codec);
3818 snd_hda_codec_resume_cache(codec);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01003819 /* power down inactive DACs */
3820 if (spec->dac_list)
3821 stac92xx_power_down(codec);
Takashi Iwaidc81bed2007-09-03 09:36:36 +02003822 /* invoke unsolicited event to reset the HP state */
3823 if (spec->hp_detect)
3824 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
Mattff6fdc32005-06-27 15:06:52 +02003825 return 0;
3826}
3827#endif
3828
Matt2f2f4252005-04-13 14:45:30 +02003829static struct hda_codec_ops stac92xx_patch_ops = {
3830 .build_controls = stac92xx_build_controls,
3831 .build_pcms = stac92xx_build_pcms,
3832 .init = stac92xx_init,
3833 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02003834 .unsol_event = stac92xx_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003835#ifdef SND_HDA_NEEDS_RESUME
Mattff6fdc32005-06-27 15:06:52 +02003836 .resume = stac92xx_resume,
3837#endif
Matt2f2f4252005-04-13 14:45:30 +02003838};
3839
3840static int patch_stac9200(struct hda_codec *codec)
3841{
3842 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02003843 int err;
Matt2f2f4252005-04-13 14:45:30 +02003844
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003845 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02003846 if (spec == NULL)
3847 return -ENOMEM;
3848
3849 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003850 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02003851 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003852 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3853 stac9200_models,
3854 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02003855 if (spec->board_config < 0) {
3856 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3857 err = stac92xx_save_bios_config_regs(codec);
3858 if (err < 0) {
3859 stac92xx_free(codec);
3860 return err;
3861 }
3862 spec->pin_configs = spec->bios_pin_configs;
3863 } else {
Matt Porter403d1942005-11-29 15:00:51 +01003864 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3865 stac92xx_set_config_regs(codec);
3866 }
Matt2f2f4252005-04-13 14:45:30 +02003867
3868 spec->multiout.max_channels = 2;
3869 spec->multiout.num_dacs = 1;
3870 spec->multiout.dac_nids = stac9200_dac_nids;
3871 spec->adc_nids = stac9200_adc_nids;
3872 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02003873 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02003874 spec->num_dmics = 0;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003875 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003876 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02003877
Tobin Davisbf277782008-02-03 20:31:47 +01003878 if (spec->board_config == STAC_9200_GATEWAY ||
3879 spec->board_config == STAC_9200_OQO)
Takashi Iwai1194b5b2007-10-10 10:04:26 +02003880 spec->init = stac9200_eapd_init;
3881 else
3882 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02003883 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02003884
Takashi Iwai117f2572008-03-18 09:53:23 +01003885 if (spec->board_config == STAC_9200_PANASONIC) {
3886 spec->gpio_mask = spec->gpio_dir = 0x09;
3887 spec->gpio_data = 0x00;
3888 }
3889
Mattc7d4b2f2005-06-27 14:59:41 +02003890 err = stac9200_parse_auto_config(codec);
3891 if (err < 0) {
3892 stac92xx_free(codec);
3893 return err;
3894 }
Matt2f2f4252005-04-13 14:45:30 +02003895
3896 codec->patch_ops = stac92xx_patch_ops;
3897
3898 return 0;
3899}
3900
Tobin Davis8e21c342007-01-08 11:04:17 +01003901static int patch_stac925x(struct hda_codec *codec)
3902{
3903 struct sigmatel_spec *spec;
3904 int err;
3905
3906 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3907 if (spec == NULL)
3908 return -ENOMEM;
3909
3910 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02003911 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
Tobin Davis8e21c342007-01-08 11:04:17 +01003912 spec->pin_nids = stac925x_pin_nids;
3913 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3914 stac925x_models,
3915 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003916 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01003917 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02003918 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3919 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01003920 err = stac92xx_save_bios_config_regs(codec);
3921 if (err < 0) {
3922 stac92xx_free(codec);
3923 return err;
3924 }
3925 spec->pin_configs = spec->bios_pin_configs;
3926 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3927 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3928 stac92xx_set_config_regs(codec);
3929 }
3930
3931 spec->multiout.max_channels = 2;
3932 spec->multiout.num_dacs = 1;
3933 spec->multiout.dac_nids = stac925x_dac_nids;
3934 spec->adc_nids = stac925x_adc_nids;
3935 spec->mux_nids = stac925x_mux_nids;
3936 spec->num_muxes = 1;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02003937 spec->num_adcs = 1;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01003938 spec->num_pwrs = 0;
Tobin Davis2c11f952007-05-17 09:36:34 +02003939 switch (codec->vendor_id) {
3940 case 0x83847632: /* STAC9202 */
3941 case 0x83847633: /* STAC9202D */
3942 case 0x83847636: /* STAC9251 */
3943 case 0x83847637: /* STAC9251D */
Takashi Iwaif6e98522007-10-16 14:27:04 +02003944 spec->num_dmics = STAC925X_NUM_DMICS;
Tobin Davis2c11f952007-05-17 09:36:34 +02003945 spec->dmic_nids = stac925x_dmic_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01003946 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3947 spec->dmux_nids = stac925x_dmux_nids;
Tobin Davis2c11f952007-05-17 09:36:34 +02003948 break;
3949 default:
3950 spec->num_dmics = 0;
3951 break;
3952 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003953
3954 spec->init = stac925x_core_init;
3955 spec->mixer = stac925x_mixer;
3956
3957 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01003958 if (!err) {
3959 if (spec->board_config < 0) {
3960 printk(KERN_WARNING "hda_codec: No auto-config is "
3961 "available, default to model=ref\n");
3962 spec->board_config = STAC_925x_REF;
3963 goto again;
3964 }
3965 err = -EINVAL;
3966 }
Tobin Davis8e21c342007-01-08 11:04:17 +01003967 if (err < 0) {
3968 stac92xx_free(codec);
3969 return err;
3970 }
3971
3972 codec->patch_ops = stac92xx_patch_ops;
3973
3974 return 0;
3975}
3976
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003977static struct hda_input_mux stac92hd73xx_dmux = {
3978 .num_items = 4,
3979 .items = {
3980 { "Analog Inputs", 0x0b },
3981 { "CD", 0x08 },
3982 { "Digital Mic 1", 0x09 },
3983 { "Digital Mic 2", 0x0a },
3984 }
3985};
3986
3987static int patch_stac92hd73xx(struct hda_codec *codec)
3988{
3989 struct sigmatel_spec *spec;
3990 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3991 int err = 0;
3992
3993 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3994 if (spec == NULL)
3995 return -ENOMEM;
3996
3997 codec->spec = spec;
Matthew Ranostaye99d32b2008-09-09 10:46:38 +02003998 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01003999 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4000 spec->pin_nids = stac92hd73xx_pin_nids;
4001 spec->board_config = snd_hda_check_board_config(codec,
4002 STAC_92HD73XX_MODELS,
4003 stac92hd73xx_models,
4004 stac92hd73xx_cfg_tbl);
4005again:
4006 if (spec->board_config < 0) {
4007 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4008 " STAC92HD73XX, using BIOS defaults\n");
4009 err = stac92xx_save_bios_config_regs(codec);
4010 if (err < 0) {
4011 stac92xx_free(codec);
4012 return err;
4013 }
4014 spec->pin_configs = spec->bios_pin_configs;
4015 } else {
4016 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4017 stac92xx_set_config_regs(codec);
4018 }
4019
4020 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4021 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4022
4023 if (spec->multiout.num_dacs < 0) {
4024 printk(KERN_WARNING "hda_codec: Could not determine "
4025 "number of channels defaulting to DAC count\n");
4026 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4027 }
4028
4029 switch (spec->multiout.num_dacs) {
4030 case 0x3: /* 6 Channel */
4031 spec->mixer = stac92hd73xx_6ch_mixer;
4032 spec->init = stac92hd73xx_6ch_core_init;
4033 break;
4034 case 0x4: /* 8 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004035 spec->mixer = stac92hd73xx_8ch_mixer;
4036 spec->init = stac92hd73xx_8ch_core_init;
4037 break;
4038 case 0x5: /* 10 Channel */
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004039 spec->mixer = stac92hd73xx_10ch_mixer;
4040 spec->init = stac92hd73xx_10ch_core_init;
4041 };
4042
4043 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4044 spec->aloopback_mask = 0x01;
4045 spec->aloopback_shift = 8;
4046
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004047 spec->digbeep_nid = 0x1c;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004048 spec->mux_nids = stac92hd73xx_mux_nids;
4049 spec->adc_nids = stac92hd73xx_adc_nids;
4050 spec->dmic_nids = stac92hd73xx_dmic_nids;
4051 spec->dmux_nids = stac92hd73xx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004052 spec->smux_nids = stac92hd73xx_smux_nids;
Matthew Ranostay89385032008-09-11 09:49:39 -04004053 spec->amp_nids = stac92hd73xx_amp_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004054
4055 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4056 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
Takashi Iwai16970552007-12-18 18:05:52 +01004057 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004058 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004059 spec->dinput_mux = &stac92hd73xx_dmux;
4060 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004061 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004062 spec->gpio_data = 0x01;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004063
Matthew Ranostaya7662642008-02-21 07:51:14 +01004064 switch (spec->board_config) {
4065 case STAC_DELL_M6:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004066 spec->init = dell_eq_core_init;
Matthew Ranostaya7662642008-02-21 07:51:14 +01004067 switch (codec->subsystem_id) {
4068 case 0x1028025e: /* Analog Mics */
4069 case 0x1028025f:
4070 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4071 spec->num_dmics = 0;
4072 break;
Matthew Ranostayd654a662008-03-14 08:46:51 +01004073 case 0x10280271: /* Digital Mics */
Matthew Ranostaya7662642008-02-21 07:51:14 +01004074 case 0x10280272:
Matthew Ranostayd654a662008-03-14 08:46:51 +01004075 spec->init = dell_m6_core_init;
4076 /* fall-through */
4077 case 0x10280254:
4078 case 0x10280255:
Matthew Ranostaya7662642008-02-21 07:51:14 +01004079 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4080 spec->num_dmics = 1;
4081 break;
4082 case 0x10280256: /* Both */
4083 case 0x10280057:
4084 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4085 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4086 spec->num_dmics = 1;
4087 break;
4088 }
4089 break;
4090 default:
4091 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4092 }
4093
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004094 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4095 spec->pwr_nids = stac92hd73xx_pwr_nids;
4096
Matthew Ranostayd9737752008-09-07 12:03:41 +02004097 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004098
4099 if (!err) {
4100 if (spec->board_config < 0) {
4101 printk(KERN_WARNING "hda_codec: No auto-config is "
4102 "available, default to model=ref\n");
4103 spec->board_config = STAC_92HD73XX_REF;
4104 goto again;
4105 }
4106 err = -EINVAL;
4107 }
4108
4109 if (err < 0) {
4110 stac92xx_free(codec);
4111 return err;
4112 }
4113
4114 codec->patch_ops = stac92xx_patch_ops;
4115
4116 return 0;
4117}
4118
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004119static struct hda_input_mux stac92hd83xxx_dmux = {
4120 .num_items = 3,
4121 .items = {
4122 { "Analog Inputs", 0x03 },
4123 { "Digital Mic 1", 0x04 },
4124 { "Digital Mic 2", 0x05 },
4125 }
4126};
4127
4128static int patch_stac92hd83xxx(struct hda_codec *codec)
4129{
4130 struct sigmatel_spec *spec;
4131 int err;
4132
4133 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4134 if (spec == NULL)
4135 return -ENOMEM;
4136
4137 codec->spec = spec;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004138 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004139 spec->mono_nid = 0x19;
4140 spec->digbeep_nid = 0x21;
4141 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4142 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4143 spec->adc_nids = stac92hd83xxx_adc_nids;
4144 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4145 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4146 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4147 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4148
4149 spec->init = stac92hd83xxx_core_init;
4150 switch (codec->vendor_id) {
4151 case 0x111d7605:
4152 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4153 break;
4154 default:
4155 spec->num_pwrs--;
4156 spec->init++; /* switch to config #2 */
4157 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4158 }
4159
4160 spec->mixer = stac92hd83xxx_mixer;
4161 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4162 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4163 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4164 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4165 spec->dinput_mux = &stac92hd83xxx_dmux;
4166 spec->pin_nids = stac92hd83xxx_pin_nids;
4167 spec->board_config = snd_hda_check_board_config(codec,
4168 STAC_92HD83XXX_MODELS,
4169 stac92hd83xxx_models,
4170 stac92hd83xxx_cfg_tbl);
4171again:
4172 if (spec->board_config < 0) {
4173 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4174 " STAC92HD83XXX, using BIOS defaults\n");
4175 err = stac92xx_save_bios_config_regs(codec);
4176 if (err < 0) {
4177 stac92xx_free(codec);
4178 return err;
4179 }
4180 spec->pin_configs = spec->bios_pin_configs;
4181 } else {
4182 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4183 stac92xx_set_config_regs(codec);
4184 }
4185
4186 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4187 if (!err) {
4188 if (spec->board_config < 0) {
4189 printk(KERN_WARNING "hda_codec: No auto-config is "
4190 "available, default to model=ref\n");
4191 spec->board_config = STAC_92HD83XXX_REF;
4192 goto again;
4193 }
4194 err = -EINVAL;
4195 }
4196
4197 if (err < 0) {
4198 stac92xx_free(codec);
4199 return err;
4200 }
4201
4202 codec->patch_ops = stac92xx_patch_ops;
4203
4204 return 0;
4205}
4206
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004207#ifdef SND_HDA_NEEDS_RESUME
4208static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4209{
4210 struct sigmatel_spec *spec = codec->spec;
4211 int i;
4212 snd_hda_codec_write_cache(codec, codec->afg, 0,
4213 AC_VERB_SET_POWER_STATE, pwr);
4214
4215 msleep(1);
4216 for (i = 0; i < spec->num_adcs; i++) {
4217 snd_hda_codec_write_cache(codec,
4218 spec->adc_nids[i], 0,
4219 AC_VERB_SET_POWER_STATE, pwr);
4220 }
4221};
4222
4223static int stac92hd71xx_resume(struct hda_codec *codec)
4224{
4225 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4226 return stac92xx_resume(codec);
4227}
4228
4229static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4230{
4231 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4232 return 0;
4233};
4234
4235#endif
4236
4237static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4238 .build_controls = stac92xx_build_controls,
4239 .build_pcms = stac92xx_build_pcms,
4240 .init = stac92xx_init,
4241 .free = stac92xx_free,
4242 .unsol_event = stac92xx_unsol_event,
4243#ifdef SND_HDA_NEEDS_RESUME
4244 .resume = stac92hd71xx_resume,
4245 .suspend = stac92hd71xx_suspend,
4246#endif
4247};
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02004248
Matthew Ranostaye035b842007-11-06 11:53:55 +01004249static int patch_stac92hd71bxx(struct hda_codec *codec)
4250{
4251 struct sigmatel_spec *spec;
4252 int err = 0;
4253
4254 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4255 if (spec == NULL)
4256 return -ENOMEM;
4257
4258 codec->spec = spec;
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004259 codec->patch_ops = stac92xx_patch_ops;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004260 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004261 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004262 spec->pin_nids = stac92hd71bxx_pin_nids;
4263 spec->board_config = snd_hda_check_board_config(codec,
4264 STAC_92HD71BXX_MODELS,
4265 stac92hd71bxx_models,
4266 stac92hd71bxx_cfg_tbl);
4267again:
4268 if (spec->board_config < 0) {
4269 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4270 " STAC92HD71BXX, using BIOS defaults\n");
4271 err = stac92xx_save_bios_config_regs(codec);
4272 if (err < 0) {
4273 stac92xx_free(codec);
4274 return err;
4275 }
4276 spec->pin_configs = spec->bios_pin_configs;
4277 } else {
4278 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4279 stac92xx_set_config_regs(codec);
4280 }
4281
Matthew Ranostay541eee82007-12-14 12:08:04 +01004282 switch (codec->vendor_id) {
4283 case 0x111d76b6: /* 4 Port without Analog Mixer */
4284 case 0x111d76b7:
4285 case 0x111d76b4: /* 6 Port without Analog Mixer */
4286 case 0x111d76b5:
4287 spec->mixer = stac92hd71bxx_mixer;
4288 spec->init = stac92hd71bxx_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004289 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004290 break;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004291 case 0x111d7608: /* 5 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004292 if ((codec->revision_id & 0xf) == 0 ||
4293 (codec->revision_id & 0xf) == 1) {
4294#ifdef SND_HDA_NEEDS_RESUME
4295 codec->patch_ops = stac92hd71bxx_patch_ops;
4296#endif
4297 spec->stream_delay = 40; /* 40 milliseconds */
4298 }
4299
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004300 /* no output amps */
4301 spec->num_pwrs = 0;
4302 spec->mixer = stac92hd71bxx_analog_mixer;
4303
4304 /* disable VSW */
4305 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4306 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4307 break;
4308 case 0x111d7603: /* 6 Port with Analog Mixer */
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004309 if ((codec->revision_id & 0xf) == 1) {
4310#ifdef SND_HDA_NEEDS_RESUME
4311 codec->patch_ops = stac92hd71bxx_patch_ops;
4312#endif
4313 spec->stream_delay = 40; /* 40 milliseconds */
4314 }
4315
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004316 /* no output amps */
4317 spec->num_pwrs = 0;
4318 /* fallthru */
Matthew Ranostay541eee82007-12-14 12:08:04 +01004319 default:
4320 spec->mixer = stac92hd71bxx_analog_mixer;
4321 spec->init = stac92hd71bxx_analog_core_init;
Matthew Ranostay0ffa9802008-09-08 11:20:05 -04004322 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
Matthew Ranostay541eee82007-12-14 12:08:04 +01004323 }
4324
4325 spec->aloopback_mask = 0x20;
4326 spec->aloopback_shift = 0;
4327
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004328 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004329 spec->gpio_mask = 0x01;
4330 spec->gpio_dir = 0x01;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004331 spec->gpio_data = 0x01;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004332
Matthew Ranostay8daaaa92008-08-15 07:45:52 +02004333 spec->powerdown_adcs = 1;
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004334 spec->digbeep_nid = 0x26;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004335 spec->mux_nids = stac92hd71bxx_mux_nids;
4336 spec->adc_nids = stac92hd71bxx_adc_nids;
4337 spec->dmic_nids = stac92hd71bxx_dmic_nids;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004338 spec->dmux_nids = stac92hd71bxx_dmux_nids;
Matthew Ranostayd9737752008-09-07 12:03:41 +02004339 spec->smux_nids = stac92hd71bxx_smux_nids;
Matthew Ranostayaafc4412008-06-13 18:04:33 +02004340 spec->pwr_nids = stac92hd71bxx_pwr_nids;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004341
4342 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4343 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
Takashi Iwai16970552007-12-18 18:05:52 +01004344 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
Matthew Ranostaye035b842007-11-06 11:53:55 +01004345
Matthew Ranostay6a14f582008-09-12 12:02:30 -04004346 switch (spec->board_config) {
4347 case STAC_HP_M4:
4348 spec->num_dmics = 0;
4349 spec->num_smuxes = 1;
4350 spec->num_dmuxes = 0;
4351
4352 /* enable internal microphone */
4353 snd_hda_codec_write_cache(codec, 0x0e, 0,
4354 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80);
4355 break;
4356 default:
4357 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4358 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4359 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4360 };
4361
Takashi Iwaiaea7bb02008-02-25 18:26:41 +01004362 spec->multiout.num_dacs = 1;
Matthew Ranostaye035b842007-11-06 11:53:55 +01004363 spec->multiout.hp_nid = 0x11;
4364 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4365
4366 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4367 if (!err) {
4368 if (spec->board_config < 0) {
4369 printk(KERN_WARNING "hda_codec: No auto-config is "
4370 "available, default to model=ref\n");
4371 spec->board_config = STAC_92HD71BXX_REF;
4372 goto again;
4373 }
4374 err = -EINVAL;
4375 }
4376
4377 if (err < 0) {
4378 stac92xx_free(codec);
4379 return err;
4380 }
4381
Matthew Ranostaye035b842007-11-06 11:53:55 +01004382 return 0;
4383};
4384
Matt2f2f4252005-04-13 14:45:30 +02004385static int patch_stac922x(struct hda_codec *codec)
4386{
4387 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02004388 int err;
Matt2f2f4252005-04-13 14:45:30 +02004389
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004390 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02004391 if (spec == NULL)
4392 return -ENOMEM;
4393
4394 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004395 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004396 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004397 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4398 stac922x_models,
4399 stac922x_cfg_tbl);
Nicolas Boichat536319a2008-07-21 22:18:01 +08004400 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004401 spec->gpio_mask = spec->gpio_dir = 0x03;
4402 spec->gpio_data = 0x03;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004403 /* Intel Macs have all same PCI SSID, so we need to check
4404 * codec SSID to distinguish the exact models
4405 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004406 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004407 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004408
4409 case 0x106b0800:
4410 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02004411 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004412 case 0x106b0600:
4413 case 0x106b0700:
4414 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01004415 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004416 case 0x106b0e00:
4417 case 0x106b0f00:
4418 case 0x106b1600:
4419 case 0x106b1700:
4420 case 0x106b0200:
4421 case 0x106b1e00:
4422 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004423 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004424 case 0x106b1a00:
4425 case 0x00000100:
4426 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02004427 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02004428 case 0x106b0a00:
4429 case 0x106b2200:
4430 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02004431 break;
Nicolas Boichat536319a2008-07-21 22:18:01 +08004432 default:
4433 spec->board_config = STAC_INTEL_MAC_V3;
4434 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01004435 }
4436 }
4437
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004438 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004439 if (spec->board_config < 0) {
4440 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4441 "using BIOS defaults\n");
4442 err = stac92xx_save_bios_config_regs(codec);
4443 if (err < 0) {
4444 stac92xx_free(codec);
4445 return err;
4446 }
4447 spec->pin_configs = spec->bios_pin_configs;
4448 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01004449 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4450 stac92xx_set_config_regs(codec);
4451 }
Matt2f2f4252005-04-13 14:45:30 +02004452
Matt2f2f4252005-04-13 14:45:30 +02004453 spec->adc_nids = stac922x_adc_nids;
4454 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004455 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004456 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004457 spec->num_dmics = 0;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004458 spec->num_pwrs = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02004459
4460 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02004461 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02004462
4463 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02004464
Matt Porter3cc08dc2006-01-23 15:27:49 +01004465 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004466 if (!err) {
4467 if (spec->board_config < 0) {
4468 printk(KERN_WARNING "hda_codec: No auto-config is "
4469 "available, default to model=ref\n");
4470 spec->board_config = STAC_D945_REF;
4471 goto again;
4472 }
4473 err = -EINVAL;
4474 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004475 if (err < 0) {
4476 stac92xx_free(codec);
4477 return err;
4478 }
4479
4480 codec->patch_ops = stac92xx_patch_ops;
4481
Takashi Iwai807a46362007-05-29 19:01:37 +02004482 /* Fix Mux capture level; max to 2 */
4483 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4484 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4485 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4486 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4487 (0 << AC_AMPCAP_MUTE_SHIFT));
4488
Matt Porter3cc08dc2006-01-23 15:27:49 +01004489 return 0;
4490}
4491
4492static int patch_stac927x(struct hda_codec *codec)
4493{
4494 struct sigmatel_spec *spec;
4495 int err;
4496
4497 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4498 if (spec == NULL)
4499 return -ENOMEM;
4500
4501 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004502 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004503 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004504 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4505 stac927x_models,
4506 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004507 again:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004508 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4509 if (spec->board_config < 0)
4510 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4511 "STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02004512 err = stac92xx_save_bios_config_regs(codec);
4513 if (err < 0) {
4514 stac92xx_free(codec);
4515 return err;
4516 }
4517 spec->pin_configs = spec->bios_pin_configs;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004518 } else {
Matt Porter3cc08dc2006-01-23 15:27:49 +01004519 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4520 stac92xx_set_config_regs(codec);
4521 }
4522
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004523 spec->digbeep_nid = 0x23;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004524 spec->adc_nids = stac927x_adc_nids;
4525 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4526 spec->mux_nids = stac927x_mux_nids;
4527 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004528 spec->smux_nids = stac927x_smux_nids;
4529 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
Matthew Ranostayb76c8502008-02-06 14:49:44 +01004530 spec->dac_list = stac927x_dac_nids;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004531 spec->multiout.dac_nids = spec->dac_nids;
4532
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004533 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02004534 case STAC_D965_3ST:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004535 case STAC_D965_5ST:
4536 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004537 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004538 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004539 spec->num_dmics = 0;
4540
Tobin Davis93ed1502006-09-01 21:03:12 +02004541 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004542 spec->mixer = stac927x_mixer;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004543 break;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004544 case STAC_DELL_BIOS:
Matthew Ranostay780c8be2008-04-14 13:32:27 +02004545 switch (codec->subsystem_id) {
4546 case 0x10280209:
4547 case 0x1028022e:
4548 /* correct the device field to SPDIF out */
4549 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4550 break;
4551 };
Matthew Ranostay03d7ca12008-02-21 07:51:46 +01004552 /* configure the analog microphone on some laptops */
4553 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
Matthew Ranostay2f32d902008-01-10 13:06:26 +01004554 /* correct the front output jack as a hp out */
Matthew Ranostay7989fba2008-02-21 07:50:12 +01004555 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
Matthew Ranostayc481fca2008-01-07 12:18:28 +01004556 /* correct the front input jack as a mic */
4557 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4558 /* fallthru */
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004559 case STAC_DELL_3ST:
4560 /* GPIO2 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004561 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004562 spec->gpio_data = 0x04;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004563 spec->dmic_nids = stac927x_dmic_nids;
4564 spec->num_dmics = STAC927X_NUM_DMICS;
4565
Tobin Davis93ed1502006-09-01 21:03:12 +02004566 spec->init = d965_core_init;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004567 spec->mixer = stac927x_mixer;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004568 spec->dmux_nids = stac927x_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004569 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004570 break;
4571 default:
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004572 /* GPIO0 High = Enable EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004573 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004574 spec->gpio_data = 0x01;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004575 spec->num_dmics = 0;
4576
Tobin Davis81d3dbd2006-08-22 19:44:45 +02004577 spec->init = stac927x_core_init;
4578 spec->mixer = stac927x_mixer;
4579 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01004580
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004581 spec->num_pwrs = 0;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004582 spec->aloopback_mask = 0x40;
4583 spec->aloopback_shift = 0;
Matthew Ranostay8e9068b2007-12-17 11:58:13 +01004584
Matt Porter3cc08dc2006-01-23 15:27:49 +01004585 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004586 if (!err) {
4587 if (spec->board_config < 0) {
4588 printk(KERN_WARNING "hda_codec: No auto-config is "
4589 "available, default to model=ref\n");
4590 spec->board_config = STAC_D965_REF;
4591 goto again;
4592 }
4593 err = -EINVAL;
4594 }
Mattc7d4b2f2005-06-27 14:59:41 +02004595 if (err < 0) {
4596 stac92xx_free(codec);
4597 return err;
4598 }
Matt2f2f4252005-04-13 14:45:30 +02004599
4600 codec->patch_ops = stac92xx_patch_ops;
4601
Takashi Iwai52987652008-01-16 16:09:47 +01004602 /*
4603 * !!FIXME!!
4604 * The STAC927x seem to require fairly long delays for certain
4605 * command sequences. With too short delays (even if the answer
4606 * is set to RIRB properly), it results in the silence output
4607 * on some hardwares like Dell.
4608 *
4609 * The below flag enables the longer delay (see get_response
4610 * in hda_intel.c).
4611 */
4612 codec->bus->needs_damn_long_delay = 1;
4613
Matt2f2f4252005-04-13 14:45:30 +02004614 return 0;
4615}
4616
Matt Porterf3302a592006-07-31 12:49:34 +02004617static int patch_stac9205(struct hda_codec *codec)
4618{
4619 struct sigmatel_spec *spec;
Takashi Iwai82599802007-07-31 15:56:24 +02004620 int err;
Matt Porterf3302a592006-07-31 12:49:34 +02004621
4622 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4623 if (spec == NULL)
4624 return -ENOMEM;
4625
4626 codec->spec = spec;
Takashi Iwaia4eed132007-07-06 18:17:04 +02004627 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
Richard Fish11b44bb2006-08-23 18:31:34 +02004628 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004629 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4630 stac9205_models,
4631 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004632 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02004633 if (spec->board_config < 0) {
4634 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4635 err = stac92xx_save_bios_config_regs(codec);
4636 if (err < 0) {
4637 stac92xx_free(codec);
4638 return err;
4639 }
4640 spec->pin_configs = spec->bios_pin_configs;
4641 } else {
Matt Porterf3302a592006-07-31 12:49:34 +02004642 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4643 stac92xx_set_config_regs(codec);
4644 }
4645
Matthew Ranostay1cd22242008-07-18 18:20:52 +02004646 spec->digbeep_nid = 0x23;
Matt Porterf3302a592006-07-31 12:49:34 +02004647 spec->adc_nids = stac9205_adc_nids;
Maxim Levitsky9e05b7a2007-09-03 15:31:02 +02004648 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
Matt Porterf3302a592006-07-31 12:49:34 +02004649 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01004650 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matthew Ranostayd9737752008-09-07 12:03:41 +02004651 spec->smux_nids = stac9205_smux_nids;
4652 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02004653 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwaif6e98522007-10-16 14:27:04 +02004654 spec->num_dmics = STAC9205_NUM_DMICS;
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004655 spec->dmux_nids = stac9205_dmux_nids;
Takashi Iwai16970552007-12-18 18:05:52 +01004656 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004657 spec->num_pwrs = 0;
Matt Porterf3302a592006-07-31 12:49:34 +02004658
4659 spec->init = stac9205_core_init;
4660 spec->mixer = stac9205_mixer;
4661
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01004662 spec->aloopback_mask = 0x40;
4663 spec->aloopback_shift = 0;
Matt Porterf3302a592006-07-31 12:49:34 +02004664 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay87d48362007-07-17 11:52:24 +02004665
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004666 switch (spec->board_config){
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004667 case STAC_9205_DELL_M43:
Matthew Ranostay87d48362007-07-17 11:52:24 +02004668 /* Enable SPDIF in/out */
4669 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4670 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
Matt Porter33382402006-12-18 13:17:28 +01004671
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004672 /* Enable unsol response for GPIO4/Dock HP connection */
4673 snd_hda_codec_write(codec, codec->afg, 0,
4674 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4675 snd_hda_codec_write_cache(codec, codec->afg, 0,
4676 AC_VERB_SET_UNSOLICITED_ENABLE,
4677 (AC_USRSP_EN | STAC_HP_EVENT));
4678
4679 spec->gpio_dir = 0x0b;
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004680 spec->eapd_mask = 0x01;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004681 spec->gpio_mask = 0x1b;
4682 spec->gpio_mute = 0x10;
Matthew Ranostaye2e7d622008-01-24 15:32:15 +01004683 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004684 * GPIO3 Low = DRM
Matthew Ranostay87d48362007-07-17 11:52:24 +02004685 */
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004686 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004687 break;
4688 default:
4689 /* GPIO0 High = EAPD */
Matthew Ranostay0fc9dec2008-04-14 13:32:54 +02004690 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
Matthew Ranostay4fe51952008-01-29 15:28:44 +01004691 spec->gpio_data = 0x01;
Tobin Davisae0a8ed2007-08-13 15:50:29 +02004692 break;
4693 }
Matthew Ranostay87d48362007-07-17 11:52:24 +02004694
Matt Porterf3302a592006-07-31 12:49:34 +02004695 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01004696 if (!err) {
4697 if (spec->board_config < 0) {
4698 printk(KERN_WARNING "hda_codec: No auto-config is "
4699 "available, default to model=ref\n");
4700 spec->board_config = STAC_9205_REF;
4701 goto again;
4702 }
4703 err = -EINVAL;
4704 }
Matt Porterf3302a592006-07-31 12:49:34 +02004705 if (err < 0) {
4706 stac92xx_free(codec);
4707 return err;
4708 }
4709
4710 codec->patch_ops = stac92xx_patch_ops;
4711
4712 return 0;
4713}
4714
Matt2f2f4252005-04-13 14:45:30 +02004715/*
Guillaume Munch6d859062006-08-22 17:15:47 +02004716 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01004717 */
4718
Guillaume Munch99ccc562006-08-16 19:35:12 +02004719/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004720static hda_nid_t vaio_dacs[] = { 0x2 };
4721#define VAIO_HP_DAC 0x5
4722static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4723static hda_nid_t vaio_mux_nids[] = { 0x15 };
4724
4725static struct hda_input_mux vaio_mux = {
Takashi Iwaia3a2f422007-10-11 11:21:21 +02004726 .num_items = 3,
Takashi Iwaidb064e52006-03-16 16:04:58 +01004727 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02004728 /* { "HP", 0x0 }, */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004729 { "Mic Jack", 0x1 },
4730 { "Internal Mic", 0x2 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01004731 { "PCM", 0x3 },
4732 }
4733};
4734
4735static struct hda_verb vaio_init[] = {
4736 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004737 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
Takashi Iwaidb064e52006-03-16 16:04:58 +01004738 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4739 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4740 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004742 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Takashi Iwaidb064e52006-03-16 16:04:58 +01004743 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4747 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4748 {}
4749};
4750
Guillaume Munch6d859062006-08-22 17:15:47 +02004751static struct hda_verb vaio_ar_init[] = {
4752 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4753 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4754 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4755 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4756/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
Takashi Iwai1624cb92007-07-05 13:10:51 +02004758 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
Guillaume Munch6d859062006-08-22 17:15:47 +02004759 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4760 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4761/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4762 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4763 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4765 {}
4766};
4767
Takashi Iwaidb064e52006-03-16 16:04:58 +01004768/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004769static struct hda_bind_ctls vaio_bind_master_vol = {
4770 .ops = &snd_hda_bind_vol,
4771 .values = {
4772 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4773 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4774 0
4775 },
4776};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004777
4778/* bind volumes of both NID 0x02 and 0x05 */
Takashi Iwaicca3b372007-08-10 17:12:15 +02004779static struct hda_bind_ctls vaio_bind_master_sw = {
4780 .ops = &snd_hda_bind_sw,
4781 .values = {
4782 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4783 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4784 0,
4785 },
4786};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004787
4788static struct snd_kcontrol_new vaio_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004789 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4790 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004791 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4792 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4793 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4794 {
4795 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4796 .name = "Capture Source",
4797 .count = 1,
4798 .info = stac92xx_mux_enum_info,
4799 .get = stac92xx_mux_enum_get,
4800 .put = stac92xx_mux_enum_put,
4801 },
4802 {}
4803};
4804
Guillaume Munch6d859062006-08-22 17:15:47 +02004805static struct snd_kcontrol_new vaio_ar_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02004806 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4807 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
Guillaume Munch6d859062006-08-22 17:15:47 +02004808 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4809 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4810 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4811 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4812 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4813 {
4814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4815 .name = "Capture Source",
4816 .count = 1,
4817 .info = stac92xx_mux_enum_info,
4818 .get = stac92xx_mux_enum_get,
4819 .put = stac92xx_mux_enum_put,
4820 },
4821 {}
4822};
4823
4824static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01004825 .build_controls = stac92xx_build_controls,
4826 .build_pcms = stac92xx_build_pcms,
4827 .init = stac92xx_init,
4828 .free = stac92xx_free,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004829#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaidb064e52006-03-16 16:04:58 +01004830 .resume = stac92xx_resume,
4831#endif
4832};
4833
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004834static int stac9872_vaio_init(struct hda_codec *codec)
4835{
4836 int err;
4837
4838 err = stac92xx_init(codec);
4839 if (err < 0)
4840 return err;
4841 if (codec->patch_ops.unsol_event)
4842 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4843 return 0;
4844}
4845
4846static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4847{
Jiang Zhe40c1d302007-11-12 13:05:16 +01004848 if (get_hp_pin_presence(codec, 0x0a)) {
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004849 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4850 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4851 } else {
4852 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4853 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4854 }
4855}
4856
4857static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4858{
4859 switch (res >> 26) {
4860 case STAC_HP_EVENT:
4861 stac9872_vaio_hp_detect(codec, res);
4862 break;
4863 }
4864}
4865
4866static struct hda_codec_ops stac9872_vaio_patch_ops = {
4867 .build_controls = stac92xx_build_controls,
4868 .build_pcms = stac92xx_build_pcms,
4869 .init = stac9872_vaio_init,
4870 .free = stac92xx_free,
4871 .unsol_event = stac9872_vaio_unsol_event,
4872#ifdef CONFIG_PM
4873 .resume = stac92xx_resume,
4874#endif
4875};
4876
Guillaume Munch6d859062006-08-22 17:15:47 +02004877enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4878 CXD9872RD_VAIO,
4879 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4880 STAC9872AK_VAIO,
4881 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4882 STAC9872K_VAIO,
4883 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004884 CXD9872AKD_VAIO,
4885 STAC_9872_MODELS,
4886};
Takashi Iwaidb064e52006-03-16 16:04:58 +01004887
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004888static const char *stac9872_models[STAC_9872_MODELS] = {
4889 [CXD9872RD_VAIO] = "vaio",
4890 [CXD9872AKD_VAIO] = "vaio-ar",
4891};
4892
4893static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4894 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4895 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4896 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01004897 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01004898 {}
4899};
4900
Guillaume Munch6d859062006-08-22 17:15:47 +02004901static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01004902{
4903 struct sigmatel_spec *spec;
4904 int board_config;
4905
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004906 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4907 stac9872_models,
4908 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01004909 if (board_config < 0)
4910 /* unknown config, let generic-parser do its job... */
4911 return snd_hda_parse_generic_codec(codec);
4912
4913 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4914 if (spec == NULL)
4915 return -ENOMEM;
4916
4917 codec->spec = spec;
4918 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02004919 case CXD9872RD_VAIO:
4920 case STAC9872AK_VAIO:
4921 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01004922 spec->mixer = vaio_mixer;
4923 spec->init = vaio_init;
4924 spec->multiout.max_channels = 2;
4925 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4926 spec->multiout.dac_nids = vaio_dacs;
4927 spec->multiout.hp_nid = VAIO_HP_DAC;
4928 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4929 spec->adc_nids = vaio_adcs;
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004930 spec->num_pwrs = 0;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004931 spec->input_mux = &vaio_mux;
4932 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004933 codec->patch_ops = stac9872_vaio_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004934 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02004935
4936 case CXD9872AKD_VAIO:
4937 spec->mixer = vaio_ar_mixer;
4938 spec->init = vaio_ar_init;
4939 spec->multiout.max_channels = 2;
4940 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4941 spec->multiout.dac_nids = vaio_dacs;
4942 spec->multiout.hp_nid = VAIO_HP_DAC;
4943 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
Matthew Ranostaya64135a2008-01-10 16:55:06 +01004944 spec->num_pwrs = 0;
Guillaume Munch6d859062006-08-22 17:15:47 +02004945 spec->adc_nids = vaio_adcs;
4946 spec->input_mux = &vaio_mux;
4947 spec->mux_nids = vaio_mux_nids;
Takashi Iwai72e7b0d2007-08-16 17:33:55 +02004948 codec->patch_ops = stac9872_patch_ops;
Guillaume Munch6d859062006-08-22 17:15:47 +02004949 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01004950 }
4951
Takashi Iwaidb064e52006-03-16 16:04:58 +01004952 return 0;
4953}
4954
4955
4956/*
Matt2f2f4252005-04-13 14:45:30 +02004957 * patch entries
4958 */
4959struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4960 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4961 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4962 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4963 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4964 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4965 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4966 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02004967 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4968 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4969 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4970 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4971 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4972 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01004973 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4974 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4975 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4976 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4977 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4978 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4979 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4980 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4981 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4982 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01004983 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4984 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4985 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4986 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4987 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4988 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Takashi Iwai7bd3c0f2008-05-02 12:28:02 +02004989 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4990 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02004991 /* The following does not take into account .id=0x83847661 when subsys =
4992 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4993 * currently not fully supported.
4994 */
4995 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4996 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4997 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a592006-07-31 12:49:34 +02004998 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4999 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5000 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5001 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5002 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5003 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5004 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5005 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005006 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
Matthew Ranostayd0513fc2008-07-27 10:30:30 +02005007 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5008 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
Matthew Ranostayaafc4412008-06-13 18:04:33 +02005009 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
Matthew Ranostay541eee82007-12-14 12:08:04 +01005010 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5011 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
Matthew Ranostaye1f0d662007-12-13 17:47:21 +01005012 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
Matthew Ranostay541eee82007-12-14 12:08:04 +01005013 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5014 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5015 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5016 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5017 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5018 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5019 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5020 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
Matt2f2f4252005-04-13 14:45:30 +02005021 {} /* terminator */
5022};