aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/se.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-01-18 07:36:07 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:30:05 -0500
commit7cda8ba9f4e471dfba914ecf67fd14ebffb17c16 (patch)
tree5786b450d9099809b974929ea356b444c9f2bc07 /sound/pci/ice1712/se.c
parent797760ab14db4e82a50c06a9916dd5c6147b415b (diff)
[ALSA] ice1712, ice1724 - Code clean up
Clean up ice1712/ice1724 codes. The board-specific data is allocated locally in each code instead of having an ungly union in struct ice1712. Also, fix coding issues in prodigy_hifi.c. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/ice1712/se.c')
-rw-r--r--sound/pci/ice1712/se.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/sound/pci/ice1712/se.c b/sound/pci/ice1712/se.c
index 6661f65a6f2e..69673b95869d 100644
--- a/sound/pci/ice1712/se.c
+++ b/sound/pci/ice1712/se.c
@@ -34,6 +34,11 @@
34#include "envy24ht.h" 34#include "envy24ht.h"
35#include "se.h" 35#include "se.h"
36 36
37struct se_spec {
38 struct {
39 unsigned char ch1, ch2;
40 } vol[8];
41};
37 42
38/****************************************************************************/ 43/****************************************************************************/
39/* ONKYO WAVIO SE-200PCI */ 44/* ONKYO WAVIO SE-200PCI */
@@ -462,9 +467,10 @@ static int se200pci_cont_volume_get(struct snd_kcontrol *kc,
462 struct snd_ctl_elem_value *uc) 467 struct snd_ctl_elem_value *uc)
463{ 468{
464 struct snd_ice1712 *ice = snd_kcontrol_chip(kc); 469 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
470 struct se_spec *spec = ice->spec;
465 int n = kc->private_value; 471 int n = kc->private_value;
466 uc->value.integer.value[0] = ice->spec.se.vol[n].ch1; 472 uc->value.integer.value[0] = spec->vol[n].ch1;
467 uc->value.integer.value[1] = ice->spec.se.vol[n].ch2; 473 uc->value.integer.value[1] = spec->vol[n].ch2;
468 return 0; 474 return 0;
469} 475}
470 476
@@ -472,8 +478,9 @@ static int se200pci_cont_boolean_get(struct snd_kcontrol *kc,
472 struct snd_ctl_elem_value *uc) 478 struct snd_ctl_elem_value *uc)
473{ 479{
474 struct snd_ice1712 *ice = snd_kcontrol_chip(kc); 480 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
481 struct se_spec *spec = ice->spec;
475 int n = kc->private_value; 482 int n = kc->private_value;
476 uc->value.integer.value[0] = ice->spec.se.vol[n].ch1; 483 uc->value.integer.value[0] = spec->vol[n].ch1;
477 return 0; 484 return 0;
478} 485}
479 486
@@ -481,44 +488,46 @@ static int se200pci_cont_enum_get(struct snd_kcontrol *kc,
481 struct snd_ctl_elem_value *uc) 488 struct snd_ctl_elem_value *uc)
482{ 489{
483 struct snd_ice1712 *ice = snd_kcontrol_chip(kc); 490 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
491 struct se_spec *spec = ice->spec;
484 int n = kc->private_value; 492 int n = kc->private_value;
485 uc->value.enumerated.item[0] = ice->spec.se.vol[n].ch1; 493 uc->value.enumerated.item[0] = spec->vol[n].ch1;
486 return 0; 494 return 0;
487} 495}
488 496
489static void se200pci_cont_update(struct snd_ice1712 *ice, int n) 497static void se200pci_cont_update(struct snd_ice1712 *ice, int n)
490{ 498{
499 struct se_spec *spec = ice->spec;
491 switch (se200pci_cont[n].target) { 500 switch (se200pci_cont[n].target) {
492 case WM8766: 501 case WM8766:
493 se200pci_WM8766_set_volume(ice, 502 se200pci_WM8766_set_volume(ice,
494 se200pci_cont[n].ch, 503 se200pci_cont[n].ch,
495 ice->spec.se.vol[n].ch1, 504 spec->vol[n].ch1,
496 ice->spec.se.vol[n].ch2); 505 spec->vol[n].ch2);
497 break; 506 break;
498 507
499 case WM8776in: 508 case WM8776in:
500 se200pci_WM8776_set_input_volume(ice, 509 se200pci_WM8776_set_input_volume(ice,
501 ice->spec.se.vol[n].ch1, 510 spec->vol[n].ch1,
502 ice->spec.se.vol[n].ch2); 511 spec->vol[n].ch2);
503 break; 512 break;
504 513
505 case WM8776out: 514 case WM8776out:
506 se200pci_WM8776_set_output_volume(ice, 515 se200pci_WM8776_set_output_volume(ice,
507 ice->spec.se.vol[n].ch1, 516 spec->vol[n].ch1,
508 ice->spec.se.vol[n].ch2); 517 spec->vol[n].ch2);
509 break; 518 break;
510 519
511 case WM8776sel: 520 case WM8776sel:
512 se200pci_WM8776_set_input_selector(ice, 521 se200pci_WM8776_set_input_selector(ice,
513 ice->spec.se.vol[n].ch1); 522 spec->vol[n].ch1);
514 break; 523 break;
515 524
516 case WM8776agc: 525 case WM8776agc:
517 se200pci_WM8776_set_agc(ice, ice->spec.se.vol[n].ch1); 526 se200pci_WM8776_set_agc(ice, spec->vol[n].ch1);
518 break; 527 break;
519 528
520 case WM8776afl: 529 case WM8776afl:
521 se200pci_WM8776_set_afl(ice, ice->spec.se.vol[n].ch1); 530 se200pci_WM8776_set_afl(ice, spec->vol[n].ch1);
522 break; 531 break;
523 532
524 default: 533 default:
@@ -530,6 +539,7 @@ static int se200pci_cont_volume_put(struct snd_kcontrol *kc,
530 struct snd_ctl_elem_value *uc) 539 struct snd_ctl_elem_value *uc)
531{ 540{
532 struct snd_ice1712 *ice = snd_kcontrol_chip(kc); 541 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
542 struct se_spec *spec = ice->spec;
533 int n = kc->private_value; 543 int n = kc->private_value;
534 unsigned int vol1, vol2; 544 unsigned int vol1, vol2;
535 int changed; 545 int changed;
@@ -537,12 +547,12 @@ static int se200pci_cont_volume_put(struct snd_kcontrol *kc,
537 changed = 0; 547 changed = 0;
538 vol1 = uc->value.integer.value[0] & 0xff; 548 vol1 = uc->value.integer.value[0] & 0xff;
539 vol2 = uc->value.integer.value[1] & 0xff; 549 vol2 = uc->value.integer.value[1] & 0xff;
540 if (ice->spec.se.vol[n].ch1 != vol1) { 550 if (spec->vol[n].ch1 != vol1) {
541 ice->spec.se.vol[n].ch1 = vol1; 551 spec->vol[n].ch1 = vol1;
542 changed = 1; 552 changed = 1;
543 } 553 }
544 if (ice->spec.se.vol[n].ch2 != vol2) { 554 if (spec->vol[n].ch2 != vol2) {
545 ice->spec.se.vol[n].ch2 = vol2; 555 spec->vol[n].ch2 = vol2;
546 changed = 1; 556 changed = 1;
547 } 557 }
548 if (changed) 558 if (changed)
@@ -555,12 +565,13 @@ static int se200pci_cont_boolean_put(struct snd_kcontrol *kc,
555 struct snd_ctl_elem_value *uc) 565 struct snd_ctl_elem_value *uc)
556{ 566{
557 struct snd_ice1712 *ice = snd_kcontrol_chip(kc); 567 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
568 struct se_spec *spec = ice->spec;
558 int n = kc->private_value; 569 int n = kc->private_value;
559 unsigned int vol1; 570 unsigned int vol1;
560 571
561 vol1 = !!uc->value.integer.value[0]; 572 vol1 = !!uc->value.integer.value[0];
562 if (ice->spec.se.vol[n].ch1 != vol1) { 573 if (spec->vol[n].ch1 != vol1) {
563 ice->spec.se.vol[n].ch1 = vol1; 574 spec->vol[n].ch1 = vol1;
564 se200pci_cont_update(ice, n); 575 se200pci_cont_update(ice, n);
565 return 1; 576 return 1;
566 } 577 }
@@ -571,14 +582,15 @@ static int se200pci_cont_enum_put(struct snd_kcontrol *kc,
571 struct snd_ctl_elem_value *uc) 582 struct snd_ctl_elem_value *uc)
572{ 583{
573 struct snd_ice1712 *ice = snd_kcontrol_chip(kc); 584 struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
585 struct se_spec *spec = ice->spec;
574 int n = kc->private_value; 586 int n = kc->private_value;
575 unsigned int vol1; 587 unsigned int vol1;
576 588
577 vol1 = uc->value.enumerated.item[0]; 589 vol1 = uc->value.enumerated.item[0];
578 if (vol1 >= se200pci_get_enum_count(n)) 590 if (vol1 >= se200pci_get_enum_count(n))
579 return -EINVAL; 591 return -EINVAL;
580 if (ice->spec.se.vol[n].ch1 != vol1) { 592 if (spec->vol[n].ch1 != vol1) {
581 ice->spec.se.vol[n].ch1 = vol1; 593 spec->vol[n].ch1 = vol1;
582 se200pci_cont_update(ice, n); 594 se200pci_cont_update(ice, n);
583 return 1; 595 return 1;
584 } 596 }
@@ -668,6 +680,13 @@ static int __devinit se200pci_add_controls(struct snd_ice1712 *ice)
668 680
669static int __devinit se_init(struct snd_ice1712 *ice) 681static int __devinit se_init(struct snd_ice1712 *ice)
670{ 682{
683 struct se_spec *spec;
684
685 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
686 if (!spec)
687 return -ENOMEM;
688 ice->spec = spec;
689
671 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE90PCI) { 690 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE90PCI) {
672 ice->num_total_dacs = 2; 691 ice->num_total_dacs = 2;
673 ice->num_total_adcs = 0; 692 ice->num_total_adcs = 0;