blob: 6661f65a6f2e9ac56abcabc6b6b1e0e4940fa424 [file] [log] [blame]
Shin-ya Okadaf31639b2007-10-23 15:08:18 +02001/*
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
3 *
4 * Lowlevel functions for ONKYO WAVIO SE-90PCI and SE-200PCI
5 *
6 * Copyright (c) 2007 Shin-ya Okada sh_okada(at)d4.dion.ne.jp
7 * (at) -> @
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
Shin-ya Okadaf31639b2007-10-23 15:08:18 +020025#include <asm/io.h>
26#include <linux/delay.h>
27#include <linux/interrupt.h>
28#include <linux/init.h>
29#include <linux/slab.h>
30#include <sound/core.h>
31#include <sound/tlv.h>
32
33#include "ice1712.h"
34#include "envy24ht.h"
35#include "se.h"
36
37
38/****************************************************************************/
39/* ONKYO WAVIO SE-200PCI */
40/****************************************************************************/
41/*
42 * system configuration ICE_EEP2_SYSCONF=0x4b
43 * XIN1 49.152MHz
44 * not have UART
45 * one stereo ADC and a S/PDIF receiver connected
46 * four stereo DACs connected
47 *
48 * AC-Link configuration ICE_EEP2_ACLINK=0x80
49 * use I2C, not use AC97
50 *
51 * I2S converters feature ICE_EEP2_I2S=0x78
52 * I2S codec has no volume/mute control feature
53 * I2S codec supports 96KHz and 192KHz
54 * I2S codec 24bits
55 *
56 * S/PDIF configuration ICE_EEP2_SPDIF=0xc3
57 * Enable integrated S/PDIF transmitter
58 * internal S/PDIF out implemented
59 * S/PDIF is stereo
60 * External S/PDIF out implemented
61 *
62 *
63 * ** connected chips **
64 *
65 * WM8740
66 * A 2ch-DAC of main outputs.
67 * It setuped as I2S mode by wire, so no way to setup from software.
68 * The sample-rate are automatically changed.
69 * ML/I2S (28pin) --------+
70 * MC/DM1 (27pin) -- 5V |
71 * MD/DM0 (26pin) -- GND |
72 * MUTEB (25pin) -- NC |
73 * MODE (24pin) -- GND |
74 * CSBIW (23pin) --------+
75 * |
76 * RSTB (22pin) --R(1K)-+
77 * Probably it reduce the noise from the control line.
78 *
79 * WM8766
80 * A 6ch-DAC for surrounds.
81 * It's control wire was connected to GPIOxx (3-wire serial interface)
82 * ML/I2S (11pin) -- GPIO18
83 * MC/IWL (12pin) -- GPIO17
84 * MD/DM (13pin) -- GPIO16
85 * MUTE (14pin) -- GPIO01
86 *
87 * WM8776
88 * A 2ch-ADC(with 10ch-selector) plus 2ch-DAC.
89 * It's control wire was connected to SDA/SCLK (2-wire serial interface)
90 * MODE (16pin) -- R(1K) -- GND
91 * CE (17pin) -- R(1K) -- GND 2-wire mode (address=0x34)
92 * DI (18pin) -- SDA
93 * CL (19pin) -- SCLK
94 *
95 *
96 * ** output pins and device names **
97 *
98 * 7.1ch name -- output connector color -- device (-D option)
99 *
100 * FRONT 2ch -- green -- plughw:0,0
101 * CENTER(Lch) SUBWOOFER(Rch) -- black -- plughw:0,2,0
102 * SURROUND 2ch -- orange -- plughw:0,2,1
103 * SURROUND BACK 2ch -- white -- plughw:0,2,2
104 *
105 */
106
107
108/****************************************************************************/
109/* WM8740 interface */
110/****************************************************************************/
111
112static void __devinit se200pci_WM8740_init(struct snd_ice1712 *ice)
113{
114 /* nothing to do */
115}
116
117
118static void se200pci_WM8740_set_pro_rate(struct snd_ice1712 *ice,
119 unsigned int rate)
120{
121 /* nothing to do */
122}
123
124
125/****************************************************************************/
126/* WM8766 interface */
127/****************************************************************************/
128
129static void se200pci_WM8766_write(struct snd_ice1712 *ice,
130 unsigned int addr, unsigned int data)
131{
132 unsigned int st;
133 unsigned int bits;
134 int i;
135 const unsigned int DATA = 0x010000;
136 const unsigned int CLOCK = 0x020000;
137 const unsigned int LOAD = 0x040000;
138 const unsigned int ALL_MASK = (DATA | CLOCK | LOAD);
139
140 snd_ice1712_save_gpio_status(ice);
141
142 st = ((addr & 0x7f) << 9) | (data & 0x1ff);
143 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction | ALL_MASK);
144 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask & ~ALL_MASK);
145 bits = snd_ice1712_gpio_read(ice) & ~ALL_MASK;
146
147 snd_ice1712_gpio_write(ice, bits);
148 for (i = 0; i < 16; i++) {
149 udelay(1);
150 bits &= ~CLOCK;
151 st = (st << 1);
152 if (st & 0x10000)
153 bits |= DATA;
154 else
155 bits &= ~DATA;
156
157 snd_ice1712_gpio_write(ice, bits);
158
159 udelay(1);
160 bits |= CLOCK;
161 snd_ice1712_gpio_write(ice, bits);
162 }
163
164 udelay(1);
165 bits |= LOAD;
166 snd_ice1712_gpio_write(ice, bits);
167
168 udelay(1);
169 bits |= (DATA | CLOCK);
170 snd_ice1712_gpio_write(ice, bits);
171
172 snd_ice1712_restore_gpio_status(ice);
173}
174
175static void se200pci_WM8766_set_volume(struct snd_ice1712 *ice, int ch,
176 unsigned int vol1, unsigned int vol2)
177{
178 switch (ch) {
179 case 0:
180 se200pci_WM8766_write(ice, 0x000, vol1);
181 se200pci_WM8766_write(ice, 0x001, vol2 | 0x100);
182 break;
183 case 1:
184 se200pci_WM8766_write(ice, 0x004, vol1);
185 se200pci_WM8766_write(ice, 0x005, vol2 | 0x100);
186 break;
187 case 2:
188 se200pci_WM8766_write(ice, 0x006, vol1);
189 se200pci_WM8766_write(ice, 0x007, vol2 | 0x100);
190 break;
191 }
192}
193
194static void __devinit se200pci_WM8766_init(struct snd_ice1712 *ice)
195{
196 se200pci_WM8766_write(ice, 0x1f, 0x000); /* RESET ALL */
197 udelay(10);
198
199 se200pci_WM8766_set_volume(ice, 0, 0, 0); /* volume L=0 R=0 */
200 se200pci_WM8766_set_volume(ice, 1, 0, 0); /* volume L=0 R=0 */
201 se200pci_WM8766_set_volume(ice, 2, 0, 0); /* volume L=0 R=0 */
202
203 se200pci_WM8766_write(ice, 0x03, 0x022); /* serial mode I2S-24bits */
204 se200pci_WM8766_write(ice, 0x0a, 0x080); /* MCLK=256fs */
205 se200pci_WM8766_write(ice, 0x12, 0x000); /* MDP=0 */
206 se200pci_WM8766_write(ice, 0x15, 0x000); /* MDP=0 */
207 se200pci_WM8766_write(ice, 0x09, 0x000); /* demp=off mute=off */
208
209 se200pci_WM8766_write(ice, 0x02, 0x124); /* ch-assign L=L R=R RESET */
210 se200pci_WM8766_write(ice, 0x02, 0x120); /* ch-assign L=L R=R */
211}
212
213static void se200pci_WM8766_set_pro_rate(struct snd_ice1712 *ice,
214 unsigned int rate)
215{
216 if (rate > 96000)
217 se200pci_WM8766_write(ice, 0x0a, 0x000); /* MCLK=128fs */
218 else
219 se200pci_WM8766_write(ice, 0x0a, 0x080); /* MCLK=256fs */
220}
221
222
223/****************************************************************************/
224/* WM8776 interface */
225/****************************************************************************/
226
227static void se200pci_WM8776_write(struct snd_ice1712 *ice,
228 unsigned int addr, unsigned int data)
229{
230 unsigned int val;
231
232 val = (addr << 9) | data;
233 snd_vt1724_write_i2c(ice, 0x34, val >> 8, val & 0xff);
234}
235
236
237static void se200pci_WM8776_set_output_volume(struct snd_ice1712 *ice,
238 unsigned int vol1, unsigned int vol2)
239{
240 se200pci_WM8776_write(ice, 0x03, vol1);
241 se200pci_WM8776_write(ice, 0x04, vol2 | 0x100);
242}
243
244static void se200pci_WM8776_set_input_volume(struct snd_ice1712 *ice,
245 unsigned int vol1, unsigned int vol2)
246{
247 se200pci_WM8776_write(ice, 0x0e, vol1);
248 se200pci_WM8776_write(ice, 0x0f, vol2 | 0x100);
249}
250
251static const char *se200pci_sel[] = {
252 "LINE-IN", "CD-IN", "MIC-IN", "ALL-MIX", NULL
253};
254
255static void se200pci_WM8776_set_input_selector(struct snd_ice1712 *ice,
256 unsigned int sel)
257{
258 static unsigned char vals[] = {
259 /* LINE, CD, MIC, ALL, GND */
260 0x10, 0x04, 0x08, 0x1c, 0x03
261 };
262 if (sel > 4)
263 sel = 4;
264 se200pci_WM8776_write(ice, 0x15, vals[sel]);
265}
266
267static void se200pci_WM8776_set_afl(struct snd_ice1712 *ice, unsigned int afl)
268{
269 /* AFL -- After Fader Listening */
270 if (afl)
271 se200pci_WM8776_write(ice, 0x16, 0x005);
272 else
273 se200pci_WM8776_write(ice, 0x16, 0x001);
274}
275
276static const char *se200pci_agc[] = {
277 "Off", "LimiterMode", "ALCMode", NULL
278};
279
280static void se200pci_WM8776_set_agc(struct snd_ice1712 *ice, unsigned int agc)
281{
282 /* AGC -- Auto Gain Control of the input */
283 switch (agc) {
284 case 0:
285 se200pci_WM8776_write(ice, 0x11, 0x000); /* Off */
286 break;
287 case 1:
288 se200pci_WM8776_write(ice, 0x10, 0x07b);
289 se200pci_WM8776_write(ice, 0x11, 0x100); /* LimiterMode */
290 break;
291 case 2:
292 se200pci_WM8776_write(ice, 0x10, 0x1fb);
293 se200pci_WM8776_write(ice, 0x11, 0x100); /* ALCMode */
294 break;
295 }
296}
297
298static void __devinit se200pci_WM8776_init(struct snd_ice1712 *ice)
299{
300 int i;
301 static unsigned short __devinitdata default_values[] = {
302 0x100, 0x100, 0x100,
303 0x100, 0x100, 0x100,
304 0x000, 0x090, 0x000, 0x000,
305 0x022, 0x022, 0x022,
306 0x008, 0x0cf, 0x0cf, 0x07b, 0x000,
307 0x032, 0x000, 0x0a6, 0x001, 0x001
308 };
309
310 se200pci_WM8776_write(ice, 0x17, 0x000); /* reset all */
311 /* ADC and DAC interface is I2S 24bits mode */
312 /* The sample-rate are automatically changed */
313 udelay(10);
314 /* BUT my board can not do reset all, so I load all by manually. */
315 for (i = 0; i < ARRAY_SIZE(default_values); i++)
316 se200pci_WM8776_write(ice, i, default_values[i]);
317
318 se200pci_WM8776_set_input_selector(ice, 0);
319 se200pci_WM8776_set_afl(ice, 0);
320 se200pci_WM8776_set_agc(ice, 0);
321 se200pci_WM8776_set_input_volume(ice, 0, 0);
322 se200pci_WM8776_set_output_volume(ice, 0, 0);
323
324 /* head phone mute and power down */
325 se200pci_WM8776_write(ice, 0x00, 0);
326 se200pci_WM8776_write(ice, 0x01, 0);
327 se200pci_WM8776_write(ice, 0x02, 0x100);
328 se200pci_WM8776_write(ice, 0x0d, 0x080);
329}
330
331static void se200pci_WM8776_set_pro_rate(struct snd_ice1712 *ice,
332 unsigned int rate)
333{
334 /* nothing to do */
335}
336
337
338/****************************************************************************/
339/* runtime interface */
340/****************************************************************************/
341
342static void se200pci_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate)
343{
344 se200pci_WM8740_set_pro_rate(ice, rate);
345 se200pci_WM8766_set_pro_rate(ice, rate);
346 se200pci_WM8776_set_pro_rate(ice, rate);
347}
348
349struct se200pci_control {
350 char *name;
351 enum {
352 WM8766,
353 WM8776in,
354 WM8776out,
355 WM8776sel,
356 WM8776agc,
357 WM8776afl
358 } target;
359 enum { VOLUME1, VOLUME2, BOOLEAN, ENUM } type;
360 int ch;
361 const char **member;
362 const char *comment;
363};
364
365static const struct se200pci_control se200pci_cont[] = {
366 {
367 .name = "Front Playback Volume",
368 .target = WM8776out,
369 .type = VOLUME1,
370 .comment = "Front(green)"
371 },
372 {
373 .name = "Side Playback Volume",
374 .target = WM8766,
375 .type = VOLUME1,
376 .ch = 1,
377 .comment = "Surround(orange)"
378 },
379 {
380 .name = "Surround Playback Volume",
381 .target = WM8766,
382 .type = VOLUME1,
383 .ch = 2,
384 .comment = "SurroundBack(white)"
385 },
386 {
387 .name = "CLFE Playback Volume",
388 .target = WM8766,
389 .type = VOLUME1,
390 .ch = 0,
391 .comment = "Center(Lch)&SubWoofer(Rch)(black)"
392 },
393 {
394 .name = "Capture Volume",
395 .target = WM8776in,
396 .type = VOLUME2
397 },
398 {
399 .name = "Capture Select",
400 .target = WM8776sel,
401 .type = ENUM,
402 .member = se200pci_sel
403 },
404 {
405 .name = "AGC Capture Mode",
406 .target = WM8776agc,
407 .type = ENUM,
408 .member = se200pci_agc
409 },
410 {
411 .name = "AFL Bypass Playback Switch",
412 .target = WM8776afl,
413 .type = BOOLEAN
414 }
415};
416
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100417static int se200pci_get_enum_count(int n)
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200418{
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200419 const char **member;
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100420 int c;
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200421
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100422 member = se200pci_cont[n].member;
423 if (!member)
424 return 0;
425 for (c = 0; member[c]; c++)
426 ;
427 return c;
428}
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200429
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100430static int se200pci_cont_volume_info(struct snd_kcontrol *kc,
431 struct snd_ctl_elem_info *uinfo)
432{
433 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
434 uinfo->count = 2;
435 uinfo->value.integer.min = 0; /* mute */
436 uinfo->value.integer.max = 0xff; /* 0dB */
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200437 return 0;
438}
439
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100440#define se200pci_cont_boolean_info snd_ctl_boolean_mono_info
441
442static int se200pci_cont_enum_info(struct snd_kcontrol *kc,
443 struct snd_ctl_elem_info *uinfo)
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200444{
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100445 int n, c;
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200446
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200447 n = kc->private_value;
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100448 c = se200pci_get_enum_count(n);
449 if (!c)
450 return -EINVAL;
451 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
452 uinfo->count = 1;
453 uinfo->value.enumerated.items = c;
454 if (uinfo->value.enumerated.item >= c)
455 uinfo->value.enumerated.item = c - 1;
456 strcpy(uinfo->value.enumerated.name,
457 se200pci_cont[n].member[uinfo->value.enumerated.item]);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200458 return 0;
459}
460
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100461static int se200pci_cont_volume_get(struct snd_kcontrol *kc,
462 struct snd_ctl_elem_value *uc)
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200463{
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100464 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
465 int n = kc->private_value;
466 uc->value.integer.value[0] = ice->spec.se.vol[n].ch1;
467 uc->value.integer.value[1] = ice->spec.se.vol[n].ch2;
468 return 0;
469}
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200470
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100471static int se200pci_cont_boolean_get(struct snd_kcontrol *kc,
472 struct snd_ctl_elem_value *uc)
473{
474 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
475 int n = kc->private_value;
476 uc->value.integer.value[0] = ice->spec.se.vol[n].ch1;
477 return 0;
478}
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200479
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100480static int se200pci_cont_enum_get(struct snd_kcontrol *kc,
481 struct snd_ctl_elem_value *uc)
482{
483 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
484 int n = kc->private_value;
485 uc->value.enumerated.item[0] = ice->spec.se.vol[n].ch1;
486 return 0;
487}
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200488
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100489static void se200pci_cont_update(struct snd_ice1712 *ice, int n)
490{
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200491 switch (se200pci_cont[n].target) {
492 case WM8766:
493 se200pci_WM8766_set_volume(ice,
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100494 se200pci_cont[n].ch,
495 ice->spec.se.vol[n].ch1,
496 ice->spec.se.vol[n].ch2);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200497 break;
498
499 case WM8776in:
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100500 se200pci_WM8776_set_input_volume(ice,
501 ice->spec.se.vol[n].ch1,
502 ice->spec.se.vol[n].ch2);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200503 break;
504
505 case WM8776out:
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100506 se200pci_WM8776_set_output_volume(ice,
507 ice->spec.se.vol[n].ch1,
508 ice->spec.se.vol[n].ch2);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200509 break;
510
511 case WM8776sel:
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100512 se200pci_WM8776_set_input_selector(ice,
513 ice->spec.se.vol[n].ch1);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200514 break;
515
516 case WM8776agc:
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100517 se200pci_WM8776_set_agc(ice, ice->spec.se.vol[n].ch1);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200518 break;
519
520 case WM8776afl:
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100521 se200pci_WM8776_set_afl(ice, ice->spec.se.vol[n].ch1);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200522 break;
523
524 default:
525 break;
526 }
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100527}
528
529static int se200pci_cont_volume_put(struct snd_kcontrol *kc,
530 struct snd_ctl_elem_value *uc)
531{
532 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
533 int n = kc->private_value;
534 unsigned int vol1, vol2;
535 int changed;
536
537 changed = 0;
538 vol1 = uc->value.integer.value[0] & 0xff;
539 vol2 = uc->value.integer.value[1] & 0xff;
540 if (ice->spec.se.vol[n].ch1 != vol1) {
541 ice->spec.se.vol[n].ch1 = vol1;
542 changed = 1;
543 }
544 if (ice->spec.se.vol[n].ch2 != vol2) {
545 ice->spec.se.vol[n].ch2 = vol2;
546 changed = 1;
547 }
548 if (changed)
549 se200pci_cont_update(ice, n);
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200550
551 return changed;
552}
553
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100554static int se200pci_cont_boolean_put(struct snd_kcontrol *kc,
555 struct snd_ctl_elem_value *uc)
556{
557 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
558 int n = kc->private_value;
559 unsigned int vol1;
560
561 vol1 = !!uc->value.integer.value[0];
562 if (ice->spec.se.vol[n].ch1 != vol1) {
563 ice->spec.se.vol[n].ch1 = vol1;
564 se200pci_cont_update(ice, n);
565 return 1;
566 }
567 return 0;
568}
569
570static int se200pci_cont_enum_put(struct snd_kcontrol *kc,
571 struct snd_ctl_elem_value *uc)
572{
573 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
574 int n = kc->private_value;
575 unsigned int vol1;
576
577 vol1 = uc->value.enumerated.item[0];
578 if (vol1 >= se200pci_get_enum_count(n))
579 return -EINVAL;
580 if (ice->spec.se.vol[n].ch1 != vol1) {
581 ice->spec.se.vol[n].ch1 = vol1;
582 se200pci_cont_update(ice, n);
583 return 1;
584 }
585 return 0;
586}
587
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200588static const DECLARE_TLV_DB_SCALE(db_scale_gain1, -12750, 50, 1);
589static const DECLARE_TLV_DB_SCALE(db_scale_gain2, -10350, 50, 1);
590
591static int __devinit se200pci_add_controls(struct snd_ice1712 *ice)
592{
593 int i;
594 struct snd_kcontrol_new cont;
595 int err;
596
597 memset(&cont, 0, sizeof(cont));
598 cont.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200599 for (i = 0; i < ARRAY_SIZE(se200pci_cont); i++) {
600 cont.private_value = i;
601 cont.name = se200pci_cont[i].name;
602 cont.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
603 cont.tlv.p = NULL;
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100604 switch (se200pci_cont[i].type) {
605 case VOLUME1:
606 case VOLUME2:
607 cont.info = se200pci_cont_volume_info;
608 cont.get = se200pci_cont_volume_get;
609 cont.put = se200pci_cont_volume_put;
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200610 cont.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200611 if (se200pci_cont[i].type == VOLUME1)
612 cont.tlv.p = db_scale_gain1;
613 else
614 cont.tlv.p = db_scale_gain2;
Takashi Iwai9c45ba12007-11-15 16:05:26 +0100615 break;
616 case BOOLEAN:
617 cont.info = se200pci_cont_boolean_info;
618 cont.get = se200pci_cont_boolean_get;
619 cont.put = se200pci_cont_boolean_put;
620 break;
621 case ENUM:
622 cont.info = se200pci_cont_enum_info;
623 cont.get = se200pci_cont_enum_get;
624 cont.put = se200pci_cont_enum_put;
625 break;
626 default:
627 snd_BUG();
628 return -EINVAL;
Shin-ya Okadaf31639b2007-10-23 15:08:18 +0200629 }
630 err = snd_ctl_add(ice->card, snd_ctl_new1(&cont, ice));
631 if (err < 0)
632 return err;
633 }
634
635 return 0;
636}
637
638
639/****************************************************************************/
640/* ONKYO WAVIO SE-90PCI */
641/****************************************************************************/
642/*
643 * system configuration ICE_EEP2_SYSCONF=0x4b
644 * AC-Link configuration ICE_EEP2_ACLINK=0x80
645 * I2S converters feature ICE_EEP2_I2S=0x78
646 * S/PDIF configuration ICE_EEP2_SPDIF=0xc3
647 *
648 * ** connected chip **
649 *
650 * WM8716
651 * A 2ch-DAC of main outputs.
652 * It setuped as I2S mode by wire, so no way to setup from software.
653 * ML/I2S (28pin) -- +5V
654 * MC/DM1 (27pin) -- GND
655 * MC/DM0 (26pin) -- GND
656 * MUTEB (25pin) -- open (internal pull-up)
657 * MODE (24pin) -- GND
658 * CSBIWO (23pin) -- +5V
659 *
660 */
661
662 /* Nothing to do for this chip. */
663
664
665/****************************************************************************/
666/* probe/initialize/setup */
667/****************************************************************************/
668
669static int __devinit se_init(struct snd_ice1712 *ice)
670{
671 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE90PCI) {
672 ice->num_total_dacs = 2;
673 ice->num_total_adcs = 0;
674 ice->vt1720 = 1;
675 return 0;
676
677 } else if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE200PCI) {
678 ice->num_total_dacs = 8;
679 ice->num_total_adcs = 2;
680 se200pci_WM8740_init(ice);
681 se200pci_WM8766_init(ice);
682 se200pci_WM8776_init(ice);
683 ice->gpio.set_pro_rate = se200pci_set_pro_rate;
684 return 0;
685 }
686
687 return -ENOENT;
688}
689
690static int __devinit se_add_controls(struct snd_ice1712 *ice)
691{
692 int err;
693
694 err = 0;
695 /* nothing to do for VT1724_SUBDEVICE_SE90PCI */
696 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE200PCI)
697 err = se200pci_add_controls(ice);
698
699 return err;
700}
701
702
703/****************************************************************************/
704/* entry point */
705/****************************************************************************/
706
707static unsigned char se200pci_eeprom[] __devinitdata = {
708 [ICE_EEP2_SYSCONF] = 0x4b, /* 49.152Hz, spdif-in/ADC, 4DACs */
709 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
710 [ICE_EEP2_I2S] = 0x78, /* 96k-ok, 24bit, 192k-ok */
711 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
712
713 [ICE_EEP2_GPIO_DIR] = 0x02, /* WM8766 mute 1=output */
714 [ICE_EEP2_GPIO_DIR1] = 0x00, /* not used */
715 [ICE_EEP2_GPIO_DIR2] = 0x07, /* WM8766 ML/MC/MD 1=output */
716
717 [ICE_EEP2_GPIO_MASK] = 0x00, /* 0=writable */
718 [ICE_EEP2_GPIO_MASK1] = 0x00, /* 0=writable */
719 [ICE_EEP2_GPIO_MASK2] = 0x00, /* 0=writable */
720
721 [ICE_EEP2_GPIO_STATE] = 0x00, /* WM8766 mute=0 */
722 [ICE_EEP2_GPIO_STATE1] = 0x00, /* not used */
723 [ICE_EEP2_GPIO_STATE2] = 0x07, /* WM8766 ML/MC/MD */
724};
725
726static unsigned char se90pci_eeprom[] __devinitdata = {
727 [ICE_EEP2_SYSCONF] = 0x4b, /* 49.152Hz, spdif-in/ADC, 4DACs */
728 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
729 [ICE_EEP2_I2S] = 0x78, /* 96k-ok, 24bit, 192k-ok */
730 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
731
732 /* ALL GPIO bits are in input mode */
733};
734
735struct snd_ice1712_card_info snd_vt1724_se_cards[] __devinitdata = {
736 {
737 .subvendor = VT1724_SUBDEVICE_SE200PCI,
738 .name = "ONKYO SE200PCI",
739 .model = "se200pci",
740 .chip_init = se_init,
741 .build_controls = se_add_controls,
742 .eeprom_size = sizeof(se200pci_eeprom),
743 .eeprom_data = se200pci_eeprom,
744 },
745 {
746 .subvendor = VT1724_SUBDEVICE_SE90PCI,
747 .name = "ONKYO SE90PCI",
748 .model = "se90pci",
749 .chip_init = se_init,
750 .build_controls = se_add_controls,
751 .eeprom_size = sizeof(se90pci_eeprom),
752 .eeprom_data = se90pci_eeprom,
753 },
754 {} /*terminator*/
755};