29 #include <linux/slab.h>
123 static void se200pci_WM8740_set_pro_rate(
struct snd_ice1712 *ice,
134 static void se200pci_WM8766_write(
struct snd_ice1712 *ice,
135 unsigned int addr,
unsigned int data)
140 const unsigned int DATA = 0x010000;
141 const unsigned int CLOCK = 0x020000;
142 const unsigned int LOAD = 0x040000;
145 snd_ice1712_save_gpio_status(ice);
147 st = ((addr & 0x7f) << 9) | (data & 0x1ff);
148 snd_ice1712_gpio_set_dir(ice, ice->
gpio.direction | ALL_MASK);
149 snd_ice1712_gpio_set_mask(ice, ice->
gpio.write_mask & ~ALL_MASK);
150 bits = snd_ice1712_gpio_read(ice) & ~ALL_MASK;
152 snd_ice1712_gpio_write(ice, bits);
153 for (i = 0; i < 16; i++) {
162 snd_ice1712_gpio_write(ice, bits);
166 snd_ice1712_gpio_write(ice, bits);
171 snd_ice1712_gpio_write(ice, bits);
174 bits |= (DATA |
CLOCK);
175 snd_ice1712_gpio_write(ice, bits);
177 snd_ice1712_restore_gpio_status(ice);
180 static void se200pci_WM8766_set_volume(
struct snd_ice1712 *ice,
int ch,
181 unsigned int vol1,
unsigned int vol2)
185 se200pci_WM8766_write(ice, 0x000, vol1);
186 se200pci_WM8766_write(ice, 0x001, vol2 | 0x100);
189 se200pci_WM8766_write(ice, 0x004, vol1);
190 se200pci_WM8766_write(ice, 0x005, vol2 | 0x100);
193 se200pci_WM8766_write(ice, 0x006, vol1);
194 se200pci_WM8766_write(ice, 0x007, vol2 | 0x100);
201 se200pci_WM8766_write(ice, 0x1f, 0x000);
204 se200pci_WM8766_set_volume(ice, 0, 0, 0);
205 se200pci_WM8766_set_volume(ice, 1, 0, 0);
206 se200pci_WM8766_set_volume(ice, 2, 0, 0);
208 se200pci_WM8766_write(ice, 0x03, 0x022);
209 se200pci_WM8766_write(ice, 0x0a, 0x080);
210 se200pci_WM8766_write(ice, 0x12, 0x000);
211 se200pci_WM8766_write(ice, 0x15, 0x000);
212 se200pci_WM8766_write(ice, 0x09, 0x000);
214 se200pci_WM8766_write(ice, 0x02, 0x124);
215 se200pci_WM8766_write(ice, 0x02, 0x120);
218 static void se200pci_WM8766_set_pro_rate(
struct snd_ice1712 *ice,
222 se200pci_WM8766_write(ice, 0x0a, 0x000);
224 se200pci_WM8766_write(ice, 0x0a, 0x080);
232 static void se200pci_WM8776_write(
struct snd_ice1712 *ice,
233 unsigned int addr,
unsigned int data)
237 val = (addr << 9) | data;
242 static void se200pci_WM8776_set_output_volume(
struct snd_ice1712 *ice,
243 unsigned int vol1,
unsigned int vol2)
245 se200pci_WM8776_write(ice, 0x03, vol1);
246 se200pci_WM8776_write(ice, 0x04, vol2 | 0x100);
249 static void se200pci_WM8776_set_input_volume(
struct snd_ice1712 *ice,
250 unsigned int vol1,
unsigned int vol2)
252 se200pci_WM8776_write(ice, 0x0e, vol1);
253 se200pci_WM8776_write(ice, 0x0f, vol2 | 0x100);
256 static const char *se200pci_sel[] = {
257 "LINE-IN",
"CD-IN",
"MIC-IN",
"ALL-MIX",
NULL
260 static void se200pci_WM8776_set_input_selector(
struct snd_ice1712 *ice,
263 static unsigned char vals[] = {
265 0x10, 0x04, 0x08, 0x1c, 0x03
269 se200pci_WM8776_write(ice, 0x15, vals[sel]);
272 static void se200pci_WM8776_set_afl(
struct snd_ice1712 *ice,
unsigned int afl)
276 se200pci_WM8776_write(ice, 0x16, 0x005);
278 se200pci_WM8776_write(ice, 0x16, 0x001);
281 static const char *se200pci_agc[] = {
282 "Off",
"LimiterMode",
"ALCMode",
NULL
285 static void se200pci_WM8776_set_agc(
struct snd_ice1712 *ice,
unsigned int agc)
290 se200pci_WM8776_write(ice, 0x11, 0x000);
293 se200pci_WM8776_write(ice, 0x10, 0x07b);
294 se200pci_WM8776_write(ice, 0x11, 0x100);
297 se200pci_WM8776_write(ice, 0x10, 0x1fb);
298 se200pci_WM8776_write(ice, 0x11, 0x100);
309 0x000, 0x090, 0x000, 0x000,
311 0x008, 0x0cf, 0x0cf, 0x07b, 0x000,
312 0x032, 0x000, 0x0a6, 0x001, 0x001
315 se200pci_WM8776_write(ice, 0x17, 0x000);
320 for (i = 0; i <
ARRAY_SIZE(default_values); i++)
321 se200pci_WM8776_write(ice, i, default_values[i]);
323 se200pci_WM8776_set_input_selector(ice, 0);
324 se200pci_WM8776_set_afl(ice, 0);
325 se200pci_WM8776_set_agc(ice, 0);
326 se200pci_WM8776_set_input_volume(ice, 0, 0);
327 se200pci_WM8776_set_output_volume(ice, 0, 0);
330 se200pci_WM8776_write(ice, 0x00, 0);
331 se200pci_WM8776_write(ice, 0x01, 0);
332 se200pci_WM8776_write(ice, 0x02, 0x100);
333 se200pci_WM8776_write(ice, 0x0d, 0x080);
336 static void se200pci_WM8776_set_pro_rate(
struct snd_ice1712 *ice,
347 static void se200pci_set_pro_rate(
struct snd_ice1712 *ice,
unsigned int rate)
349 se200pci_WM8740_set_pro_rate(ice, rate);
350 se200pci_WM8766_set_pro_rate(ice, rate);
351 se200pci_WM8776_set_pro_rate(ice, rate);
372 .name =
"Front Playback Volume",
375 .comment =
"Front(green)"
378 .name =
"Side Playback Volume",
382 .comment =
"Surround(orange)"
385 .name =
"Surround Playback Volume",
389 .comment =
"SurroundBack(white)"
392 .name =
"CLFE Playback Volume",
396 .comment =
"Center(Lch)&SubWoofer(Rch)(black)"
399 .name =
"Capture Volume",
404 .name =
"Capture Select",
407 .member = se200pci_sel
410 .name =
"AGC Capture Mode",
413 .member = se200pci_agc
416 .name =
"AFL Bypass Playback Switch",
422 static int se200pci_get_enum_count(
int n)
427 member = se200pci_cont[
n].
member;
430 for (c = 0; member[
c]; c++)
445 #define se200pci_cont_boolean_info snd_ctl_boolean_mono_info
453 c = se200pci_get_enum_count(n);
472 uc->
value.integer.value[0] = spec->
vol[
n].ch1;
473 uc->
value.integer.value[1] = spec->
vol[
n].ch2;
483 uc->
value.integer.value[0] = spec->
vol[
n].ch1;
493 uc->
value.enumerated.item[0] = spec->
vol[
n].ch1;
497 static void se200pci_cont_update(
struct snd_ice1712 *ice,
int n)
500 switch (se200pci_cont[n].
target) {
502 se200pci_WM8766_set_volume(ice,
509 se200pci_WM8776_set_input_volume(ice,
515 se200pci_WM8776_set_output_volume(ice,
521 se200pci_WM8776_set_input_selector(ice,
526 se200pci_WM8776_set_agc(ice, spec->
vol[n].ch1);
530 se200pci_WM8776_set_afl(ice, spec->
vol[n].ch1);
544 unsigned int vol1, vol2;
548 vol1 = uc->
value.integer.value[0] & 0xff;
549 vol2 = uc->
value.integer.value[1] & 0xff;
550 if (spec->
vol[n].ch1 != vol1) {
551 spec->
vol[
n].ch1 = vol1;
554 if (spec->
vol[n].ch2 != vol2) {
555 spec->
vol[
n].ch2 = vol2;
559 se200pci_cont_update(ice, n);
564 static int se200pci_cont_boolean_put(
struct snd_kcontrol *kc,
572 vol1 = !!uc->
value.integer.value[0];
573 if (spec->
vol[n].ch1 != vol1) {
574 spec->
vol[
n].ch1 = vol1;
575 se200pci_cont_update(ice, n);
581 static int se200pci_cont_enum_put(
struct snd_kcontrol *kc,
589 vol1 = uc->
value.enumerated.item[0];
590 if (vol1 >= se200pci_get_enum_count(n))
592 if (spec->
vol[n].ch1 != vol1) {
593 spec->
vol[
n].ch1 = vol1;
594 se200pci_cont_update(ice, n);
611 for (i = 0; i <
ARRAY_SIZE(se200pci_cont); i++) {
612 cont.private_value =
i;
616 switch (se200pci_cont[i].
type) {
619 cont.info = se200pci_cont_volume_info;
620 cont.get = se200pci_cont_volume_get;
621 cont.put = se200pci_cont_volume_put;
623 if (se200pci_cont[i].type == VOLUME1)
624 cont.tlv.p = db_scale_gain1;
626 cont.tlv.p = db_scale_gain2;
630 cont.get = se200pci_cont_boolean_get;
631 cont.put = se200pci_cont_boolean_put;
634 cont.info = se200pci_cont_enum_info;
635 cont.get = se200pci_cont_enum_get;
636 cont.put = se200pci_cont_enum_put;
699 se200pci_WM8740_init(ice);
700 se200pci_WM8766_init(ice);
701 se200pci_WM8776_init(ice);
702 ice->
gpio.set_pro_rate = se200pci_set_pro_rate;
716 err = se200pci_add_controls(ice);
745 static unsigned char se90pci_eeprom[] __devinitdata = {
757 .name =
"ONKYO SE200PCI",
759 .chip_init = se_init,
760 .build_controls = se_add_controls,
761 .eeprom_size =
sizeof(se200pci_eeprom),
766 .name =
"ONKYO SE90PCI",
768 .chip_init = se_init,
769 .build_controls = se_add_controls,
770 .eeprom_size =
sizeof(se90pci_eeprom),