aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/se.c
blob: 69673b95869da9bfd855aa4aa05acdf24f4c6835 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
/*
 *   ALSA driver for ICEnsemble VT1724 (Envy24HT)
 *
 *   Lowlevel functions for ONKYO WAVIO SE-90PCI and SE-200PCI
 *
 *	Copyright (c) 2007 Shin-ya Okada  sh_okada(at)d4.dion.ne.jp
 *                                        (at) -> @
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 */      

#include <asm/io.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/tlv.h>

#include "ice1712.h"
#include "envy24ht.h"
#include "se.h"

struct se_spec {
	struct {
		unsigned char ch1, ch2;
	} vol[8];
};

/****************************************************************************/
/*  ONKYO WAVIO SE-200PCI                                                   */
/****************************************************************************/
/*
 *  system configuration ICE_EEP2_SYSCONF=0x4b
 *    XIN1 49.152MHz
 *    not have UART
 *    one stereo ADC and a S/PDIF receiver connected
 *    four stereo DACs connected
 *
 *  AC-Link configuration ICE_EEP2_ACLINK=0x80
 *    use I2C, not use AC97
 *
 *  I2S converters feature ICE_EEP2_I2S=0x78
 *    I2S codec has no volume/mute control feature
 *    I2S codec supports 96KHz and 192KHz
 *    I2S codec 24bits
 *
 *  S/PDIF configuration ICE_EEP2_SPDIF=0xc3
 *    Enable integrated S/PDIF transmitter
 *    internal S/PDIF out implemented
 *    S/PDIF is stereo
 *    External S/PDIF out implemented
 *
 *
 * ** connected chips **
 *
 *  WM8740
 *      A 2ch-DAC of main outputs.
 *      It setuped as I2S mode by wire, so no way to setup from software.
 *      The sample-rate are automatically changed. 
 *          ML/I2S (28pin) --------+
 *          MC/DM1 (27pin) -- 5V   |
 *          MD/DM0 (26pin) -- GND  |
 *          MUTEB  (25pin) -- NC   |
 *          MODE   (24pin) -- GND  |
 *          CSBIW  (23pin) --------+
 *                                 |
 *          RSTB   (22pin) --R(1K)-+
 *      Probably it reduce the noise from the control line.
 *
 *  WM8766
 *      A 6ch-DAC for surrounds.
 *      It's control wire was connected to GPIOxx (3-wire serial interface)
 *          ML/I2S (11pin) -- GPIO18
 *          MC/IWL (12pin) -- GPIO17
 *          MD/DM  (13pin) -- GPIO16
 *          MUTE   (14pin) -- GPIO01
 *
 *  WM8776
 *     A 2ch-ADC(with 10ch-selector) plus 2ch-DAC.
 *     It's control wire was connected to SDA/SCLK (2-wire serial interface)
 *          MODE (16pin) -- R(1K) -- GND
 *          CE   (17pin) -- R(1K) -- GND  2-wire mode (address=0x34)
 *          DI   (18pin) -- SDA
 *          CL   (19pin) -- SCLK
 *
 *
 * ** output pins and device names **
 *
 *   7.1ch name -- output connector color -- device (-D option)
 *
 *      FRONT 2ch                  -- green  -- plughw:0,0
 *      CENTER(Lch) SUBWOOFER(Rch) -- black  -- plughw:0,2,0
 *      SURROUND 2ch               -- orange -- plughw:0,2,1
 *      SURROUND BACK 2ch          -- white  -- plughw:0,2,2
 *
 */


/****************************************************************************/
/*  WM8740 interface                                                        */
/****************************************************************************/

static void __devinit se200pci_WM8740_init(struct snd_ice1712 *ice)
{
	/* nothing to do */
}


static void se200pci_WM8740_set_pro_rate(struct snd_ice1712 *ice,
						unsigned int rate)
{
	/* nothing to do */
}


/****************************************************************************/
/*  WM8766 interface                                                        */
/****************************************************************************/

static void se200pci_WM8766_write(struct snd_ice1712 *ice,
					unsigned int addr, unsigned int data)
{
	unsigned int st;
	unsigned int bits;
	int i;
	const unsigned int DATA  = 0x010000;
	const unsigned int CLOCK = 0x020000;
	const unsigned int LOAD  = 0x040000;
	const unsigned int ALL_MASK = (DATA | CLOCK | LOAD);

	snd_ice1712_save_gpio_status(ice);

	st = ((addr & 0x7f) << 9) | (data & 0x1ff);
	snd_ice1712_gpio_set_dir(ice, ice->gpio.direction | ALL_MASK);
	snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask & ~ALL_MASK);
	bits = snd_ice1712_gpio_read(ice) & ~ALL_MASK;

	snd_ice1712_gpio_write(ice, bits);
	for (i = 0; i < 16; i++) {
		udelay(1);
		bits &= ~CLOCK;
		st = (st << 1);
		if (st & 0x10000)
			bits |= DATA;
		else
			bits &= ~DATA;

		snd_ice1712_gpio_write(ice, bits);

		udelay(1);
		bits |= CLOCK;
		snd_ice1712_gpio_write(ice, bits);
	}

	udelay(1);
	bits |= LOAD;
	snd_ice1712_gpio_write(ice, bits);

	udelay(1);
	bits |= (DATA | CLOCK);
	snd_ice1712_gpio_write(ice, bits);

	snd_ice1712_restore_gpio_status(ice);
}

static void se200pci_WM8766_set_volume(struct snd_ice1712 *ice, int ch,
					unsigned int vol1, unsigned int vol2)
{
	switch (ch) {
	case 0:
		se200pci_WM8766_write(ice, 0x000, vol1);
		se200pci_WM8766_write(ice, 0x001, vol2 | 0x100);
		break;
	case 1:
		se200pci_WM8766_write(ice, 0x004, vol1);
		se200pci_WM8766_write(ice, 0x005, vol2 | 0x100);
		break;
	case 2:
		se200pci_WM8766_write(ice, 0x006, vol1);
		se200pci_WM8766_write(ice, 0x007, vol2 | 0x100);
		break;
	}
}

static void __devinit se200pci_WM8766_init(struct snd_ice1712 *ice)
{
	se200pci_WM8766_write(ice, 0x1f, 0x000); /* RESET ALL */
	udelay(10);

	se200pci_WM8766_set_volume(ice, 0, 0, 0); /* volume L=0 R=0 */
	se200pci_WM8766_set_volume(ice, 1, 0, 0); /* volume L=0 R=0 */
	se200pci_WM8766_set_volume(ice, 2, 0, 0); /* volume L=0 R=0 */

	se200pci_WM8766_write(ice, 0x03, 0x022); /* serial mode I2S-24bits */
	se200pci_WM8766_write(ice, 0x0a, 0x080); /* MCLK=256fs */
	se200pci_WM8766_write(ice, 0x12, 0x000); /* MDP=0 */
	se200pci_WM8766_write(ice, 0x15, 0x000); /* MDP=0 */
	se200pci_WM8766_write(ice, 0x09, 0x000); /* demp=off mute=off */

	se200pci_WM8766_write(ice, 0x02, 0x124); /* ch-assign L=L R=R RESET */
	se200pci_WM8766_write(ice, 0x02, 0x120); /* ch-assign L=L R=R */
}

static void se200pci_WM8766_set_pro_rate(struct snd_ice1712 *ice,
					unsigned int rate)
{
	if (rate > 96000)
		se200pci_WM8766_write(ice, 0x0a, 0x000); /* MCLK=128fs */
	else
		se200pci_WM8766_write(ice, 0x0a, 0x080); /* MCLK=256fs */
}


/****************************************************************************/
/*  WM8776 interface                                                        */
/****************************************************************************/

static void se200pci_WM8776_write(struct snd_ice1712 *ice,
					unsigned int addr, unsigned int data)
{
	unsigned int val;

	val = (addr << 9) | data;
	snd_vt1724_write_i2c(ice, 0x34, val >> 8, val & 0xff);
}


static void se200pci_WM8776_set_output_volume(struct snd_ice1712 *ice,
					unsigned int vol1, unsigned int vol2)
{
	se200pci_WM8776_write(ice, 0x03, vol1);
	se200pci_WM8776_write(ice, 0x04, vol2 | 0x100);
}

static void se200pci_WM8776_set_input_volume(struct snd_ice1712 *ice,
					unsigned int vol1, unsigned int vol2)
{
	se200pci_WM8776_write(ice, 0x0e, vol1);
	se200pci_WM8776_write(ice, 0x0f, vol2 | 0x100);
}

static const char *se200pci_sel[] = {
	"LINE-IN", "CD-IN", "MIC-IN", "ALL-MIX", NULL
};

static void se200pci_WM8776_set_input_selector(struct snd_ice1712 *ice,
					       unsigned int sel)
{
	static unsigned char vals[] = {
		/* LINE, CD, MIC, ALL, GND */
		0x10, 0x04, 0x08, 0x1c, 0x03
	};
	if (sel > 4)
		sel = 4;
	se200pci_WM8776_write(ice, 0x15, vals[sel]);
}

static void se200pci_WM8776_set_afl(struct snd_ice1712 *ice, unsigned int afl)
{
	/* AFL -- After Fader Listening */
	if (afl)
		se200pci_WM8776_write(ice, 0x16, 0x005);
	else
		se200pci_WM8776_write(ice, 0x16, 0x001);
}

static const char *se200pci_agc[] = {
	"Off", "LimiterMode", "ALCMode", NULL
};

static void se200pci_WM8776_set_agc(struct snd_ice1712 *ice, unsigned int agc)
{
	/* AGC -- Auto Gain Control of the input */
	switch (agc) {
	case 0:
		se200pci_WM8776_write(ice, 0x11, 0x000); /* Off */
		break;
	case 1:
		se200pci_WM8776_write(ice, 0x10, 0x07b);
		se200pci_WM8776_write(ice, 0x11, 0x100); /* LimiterMode */
		break;
	case 2:
		se200pci_WM8776_write(ice, 0x10, 0x1fb);
		se200pci_WM8776_write(ice, 0x11, 0x100); /* ALCMode */
		break;
	}
}

static void __devinit se200pci_WM8776_init(struct snd_ice1712 *ice)
{
	int i;
	static unsigned short __devinitdata default_values[] = {
		0x100, 0x100, 0x100,
		0x100, 0x100, 0x100,
		0x000, 0x090, 0x000, 0x000,
		0x022, 0x022, 0x022,
		0x008, 0x0cf, 0x0cf, 0x07b, 0x000,
		0x032, 0x000, 0x0a6, 0x001, 0x001
	};

	se200pci_WM8776_write(ice, 0x17, 0x000); /* reset all */
	/* ADC and DAC interface is I2S 24bits mode */
 	/* The sample-rate are automatically changed */
	udelay(10);
	/* BUT my board can not do reset all, so I load all by manually. */
	for (i = 0; i < ARRAY_SIZE(default_values); i++)
		se200pci_WM8776_write(ice, i, default_values[i]);

	se200pci_WM8776_set_input_selector(ice, 0);
	se200pci_WM8776_set_afl(ice, 0);
	se200pci_WM8776_set_agc(ice, 0);
	se200pci_WM8776_set_input_volume(ice, 0, 0);
	se200pci_WM8776_set_output_volume(ice, 0, 0);

	/* head phone mute and power down */
	se200pci_WM8776_write(ice, 0x00, 0);
	se200pci_WM8776_write(ice, 0x01, 0);
	se200pci_WM8776_write(ice, 0x02, 0x100);
	se200pci_WM8776_write(ice, 0x0d, 0x080);
}

static void se200pci_WM8776_set_pro_rate(struct snd_ice1712 *ice,
						unsigned int rate)
{
	/* nothing to do */
}


/****************************************************************************/
/*  runtime interface                                                       */
/****************************************************************************/

static void se200pci_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate)
{
	se200pci_WM8740_set_pro_rate(ice, rate);
	se200pci_WM8766_set_pro_rate(ice, rate);
	se200pci_WM8776_set_pro_rate(ice, rate);
}

struct se200pci_control {
	char *name;
	enum {
		WM8766,
		WM8776in,
		WM8776out,
		WM8776sel,
		WM8776agc,
		WM8776afl
	} target;
	enum { VOLUME1, VOLUME2, BOOLEAN, ENUM } type;
	int ch;
	const char **member;
	const char *comment;
};

static const struct se200pci_control se200pci_cont[] = {
	{
		.name = "Front Playback Volume",
		.target = WM8776out,
		.type = VOLUME1,
		.comment = "Front(green)"
	},
	{
		.name = "Side Playback Volume",
		.target = WM8766,
		.type = VOLUME1,
		.ch = 1,
		.comment = "Surround(orange)"
	},
	{
		.name = "Surround Playback Volume",
		.target = WM8766,
		.type = VOLUME1,
		.ch = 2,
		.comment = "SurroundBack(white)"
	},
	{
		.name = "CLFE Playback Volume",
		.target = WM8766,
		.type = VOLUME1,
		.ch = 0,
		.comment = "Center(Lch)&SubWoofer(Rch)(black)"
	},
	{
		.name = "Capture Volume",
		.target = WM8776in,
		.type = VOLUME2
	},
	{
		.name = "Capture Select",
		.target = WM8776sel,
		.type = ENUM,
		.member = se200pci_sel
	},
	{
		.name = "AGC Capture Mode",
		.target = WM8776agc,
		.type = ENUM,
		.member = se200pci_agc
	},
	{
		.name = "AFL Bypass Playback Switch",
		.target = WM8776afl,
		.type = BOOLEAN
	}
};

static int se200pci_get_enum_count(int n)
{
	const char **member;
	int c;

	member = se200pci_cont[n].member;
	if (!member)
		return 0;
	for (c = 0; member[c]; c++)
		;
	return c;
}

static int se200pci_cont_volume_info(struct snd_kcontrol *kc,
				     struct snd_ctl_elem_info *uinfo)
{
	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
	uinfo->count = 2;
	uinfo->value.integer.min = 0; /* mute */
	uinfo->value.integer.max = 0xff; /* 0dB */
	return 0;
}

#define se200pci_cont_boolean_info	snd_ctl_boolean_mono_info

static int se200pci_cont_enum_info(struct snd_kcontrol *kc,
				   struct snd_ctl_elem_info *uinfo)
{
	int n, c;

	n = kc->private_value;
	c = se200pci_get_enum_count(n);
	if (!c)
		return -EINVAL;
	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
	uinfo->count = 1;
	uinfo->value.enumerated.items = c;
	if (uinfo->value.enumerated.item >= c)
		uinfo->value.enumerated.item = c - 1;
	strcpy(uinfo->value.enumerated.name,
	       se200pci_cont[n].member[uinfo->value.enumerated.item]);
	return 0;
}

static int se200pci_cont_volume_get(struct snd_kcontrol *kc,
				    struct snd_ctl_elem_value *uc)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
	struct se_spec *spec = ice->spec;
	int n = kc->private_value;
	uc->value.integer.value[0] = spec->vol[n].ch1;
	uc->value.integer.value[1] = spec->vol[n].ch2;
	return 0;
}

static int se200pci_cont_boolean_get(struct snd_kcontrol *kc,
				     struct snd_ctl_elem_value *uc)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
	struct se_spec *spec = ice->spec;
	int n = kc->private_value;
	uc->value.integer.value[0] = spec->vol[n].ch1;
	return 0;
}

static int se200pci_cont_enum_get(struct snd_kcontrol *kc,
				  struct snd_ctl_elem_value *uc)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
	struct se_spec *spec = ice->spec;
	int n = kc->private_value;
	uc->value.enumerated.item[0] = spec->vol[n].ch1;
	return 0;
}

static void se200pci_cont_update(struct snd_ice1712 *ice, int n)
{
	struct se_spec *spec = ice->spec;
	switch (se200pci_cont[n].target) {
	case WM8766:
		se200pci_WM8766_set_volume(ice,
					   se200pci_cont[n].ch,
					   spec->vol[n].ch1,
					   spec->vol[n].ch2);
		break;

	case WM8776in:
		se200pci_WM8776_set_input_volume(ice,
						 spec->vol[n].ch1,
						 spec->vol[n].ch2);
		break;

	case WM8776out:
		se200pci_WM8776_set_output_volume(ice,
						  spec->vol[n].ch1,
						  spec->vol[n].ch2);
		break;

	case WM8776sel:
		se200pci_WM8776_set_input_selector(ice,
						   spec->vol[n].ch1);
		break;

	case WM8776agc:
		se200pci_WM8776_set_agc(ice, spec->vol[n].ch1);
		break;

	case WM8776afl:
		se200pci_WM8776_set_afl(ice, spec->vol[n].ch1);
		break;

	default:
		break;
	}
}

static int se200pci_cont_volume_put(struct snd_kcontrol *kc,
				    struct snd_ctl_elem_value *uc)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
	struct se_spec *spec = ice->spec;
	int n = kc->private_value;
	unsigned int vol1, vol2;
	int changed;

	changed = 0;
	vol1 = uc->value.integer.value[0] & 0xff;
	vol2 = uc->value.integer.value[1] & 0xff;
	if (spec->vol[n].ch1 != vol1) {
		spec->vol[n].ch1 = vol1;
		changed = 1;
	}
	if (spec->vol[n].ch2 != vol2) {
		spec->vol[n].ch2 = vol2;
		changed = 1;
	}
	if (changed)
		se200pci_cont_update(ice, n);

	return changed;
}

static int se200pci_cont_boolean_put(struct snd_kcontrol *kc,
				     struct snd_ctl_elem_value *uc)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
	struct se_spec *spec = ice->spec;
	int n = kc->private_value;
	unsigned int vol1;

	vol1 = !!uc->value.integer.value[0];
	if (spec->vol[n].ch1 != vol1) {
		spec->vol[n].ch1 = vol1;
		se200pci_cont_update(ice, n);
		return 1;
	}
	return 0;
}

static int se200pci_cont_enum_put(struct snd_kcontrol *kc,
				  struct snd_ctl_elem_value *uc)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
	struct se_spec *spec = ice->spec;
	int n = kc->private_value;
	unsigned int vol1;

	vol1 = uc->value.enumerated.item[0];
	if (vol1 >= se200pci_get_enum_count(n))
		return -EINVAL;
	if (spec->vol[n].ch1 != vol1) {
		spec->vol[n].ch1 = vol1;
		se200pci_cont_update(ice, n);
		return 1;
	}
	return 0;
}

static const DECLARE_TLV_DB_SCALE(db_scale_gain1, -12750, 50, 1);
static const DECLARE_TLV_DB_SCALE(db_scale_gain2, -10350, 50, 1);

static int __devinit se200pci_add_controls(struct snd_ice1712 *ice)
{
	int i;
	struct snd_kcontrol_new cont;
	int err;

	memset(&cont, 0, sizeof(cont));
	cont.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
	for (i = 0; i < ARRAY_SIZE(se200pci_cont); i++) {
		cont.private_value = i;
		cont.name = se200pci_cont[i].name;
		cont.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
		cont.tlv.p = NULL;
		switch (se200pci_cont[i].type) {
		case VOLUME1:
		case VOLUME2:
			cont.info = se200pci_cont_volume_info;
			cont.get = se200pci_cont_volume_get;
			cont.put = se200pci_cont_volume_put;
			cont.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
			if (se200pci_cont[i].type == VOLUME1)
				cont.tlv.p = db_scale_gain1;
			else
				cont.tlv.p = db_scale_gain2;
			break;
		case BOOLEAN:
			cont.info = se200pci_cont_boolean_info;
			cont.get = se200pci_cont_boolean_get;
			cont.put = se200pci_cont_boolean_put;
			break;
		case ENUM:
			cont.info = se200pci_cont_enum_info;
			cont.get = se200pci_cont_enum_get;
			cont.put = se200pci_cont_enum_put;
			break;
		default:
			snd_BUG();
			return -EINVAL;
		}
		err = snd_ctl_add(ice->card, snd_ctl_new1(&cont, ice));
		if (err < 0)
			return err;
	}

	return 0;
}


/****************************************************************************/
/*  ONKYO WAVIO SE-90PCI                                                    */
/****************************************************************************/
/*
 *  system configuration ICE_EEP2_SYSCONF=0x4b
 *  AC-Link configuration ICE_EEP2_ACLINK=0x80
 *  I2S converters feature ICE_EEP2_I2S=0x78
 *  S/PDIF configuration ICE_EEP2_SPDIF=0xc3
 *
 *  ** connected chip **
 *
 *   WM8716
 *      A 2ch-DAC of main outputs.
 *      It setuped as I2S mode by wire, so no way to setup from software.
 *         ML/I2S (28pin) -- +5V
 *         MC/DM1 (27pin) -- GND
 *         MC/DM0 (26pin) -- GND
 *         MUTEB  (25pin) -- open (internal pull-up)
 *         MODE   (24pin) -- GND
 *         CSBIWO (23pin) -- +5V
 *
 */

 /* Nothing to do for this chip. */


/****************************************************************************/
/*  probe/initialize/setup                                                  */
/****************************************************************************/

static int __devinit se_init(struct snd_ice1712 *ice)
{
	struct se_spec *spec;

	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
	if (!spec)
		return -ENOMEM;
	ice->spec = spec;

	if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE90PCI) {
		ice->num_total_dacs = 2;
		ice->num_total_adcs = 0;
		ice->vt1720 = 1;
		return 0;

	} else if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE200PCI) {
		ice->num_total_dacs = 8;
		ice->num_total_adcs = 2;
		se200pci_WM8740_init(ice);
		se200pci_WM8766_init(ice);
		se200pci_WM8776_init(ice);
		ice->gpio.set_pro_rate = se200pci_set_pro_rate;
		return 0;
	}

	return -ENOENT;
}

static int __devinit se_add_controls(struct snd_ice1712 *ice)
{
	int err;

	err = 0;
	/* nothing to do for VT1724_SUBDEVICE_SE90PCI */
	if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE200PCI)
		err = se200pci_add_controls(ice);

	return err;
}


/****************************************************************************/
/*  entry point                                                             */
/****************************************************************************/

static unsigned char se200pci_eeprom[] __devinitdata = {
	[ICE_EEP2_SYSCONF]	= 0x4b,	/* 49.152Hz, spdif-in/ADC, 4DACs */
	[ICE_EEP2_ACLINK]	= 0x80,	/* I2S */
	[ICE_EEP2_I2S]		= 0x78,	/* 96k-ok, 24bit, 192k-ok */
	[ICE_EEP2_SPDIF]	= 0xc3,	/* out-en, out-int, spdif-in */

	[ICE_EEP2_GPIO_DIR]	= 0x02, /* WM8766 mute      1=output */
	[ICE_EEP2_GPIO_DIR1]	= 0x00, /* not used */
	[ICE_EEP2_GPIO_DIR2]	= 0x07, /* WM8766 ML/MC/MD  1=output */

	[ICE_EEP2_GPIO_MASK]	= 0x00, /* 0=writable */
	[ICE_EEP2_GPIO_MASK1]	= 0x00, /* 0=writable */
	[ICE_EEP2_GPIO_MASK2]	= 0x00, /* 0=writable */

	[ICE_EEP2_GPIO_STATE]	= 0x00, /* WM8766 mute=0 */
	[ICE_EEP2_GPIO_STATE1]	= 0x00, /* not used */
	[ICE_EEP2_GPIO_STATE2]	= 0x07, /* WM8766 ML/MC/MD */
};

static unsigned char se90pci_eeprom[] __devinitdata = {
	[ICE_EEP2_SYSCONF]	= 0x4b,	/* 49.152Hz, spdif-in/ADC, 4DACs */
	[ICE_EEP2_ACLINK]	= 0x80,	/* I2S */
	[ICE_EEP2_I2S]		= 0x78,	/* 96k-ok, 24bit, 192k-ok */
	[ICE_EEP2_SPDIF]	= 0xc3,	/* out-en, out-int, spdif-in */

	/* ALL GPIO bits are in input mode */
};

struct snd_ice1712_card_info snd_vt1724_se_cards[] __devinitdata = {
	{
		.subvendor = VT1724_SUBDEVICE_SE200PCI,
		.name = "ONKYO SE200PCI",
		.model = "se200pci",
		.chip_init = se_init,
		.build_controls = se_add_controls,
		.eeprom_size = sizeof(se200pci_eeprom),
		.eeprom_data = se200pci_eeprom,
	},
	{
		.subvendor = VT1724_SUBDEVICE_SE90PCI,
		.name = "ONKYO SE90PCI",
		.model = "se90pci",
		.chip_init = se_init,
		.build_controls = se_add_controls,
		.eeprom_size = sizeof(se90pci_eeprom),
		.eeprom_data = se90pci_eeprom,
	},
	{} /*terminator*/
};