diff options
Diffstat (limited to 'sound/isa/opti9xx/opti92x-ad1848.c')
-rw-r--r-- | sound/isa/opti9xx/opti92x-ad1848.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 106be6e471f7..ea4a67120468 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/io.h> | 33 | #include <asm/io.h> |
34 | #include <asm/dma.h> | 34 | #include <asm/dma.h> |
35 | #include <sound/core.h> | 35 | #include <sound/core.h> |
36 | #include <sound/tlv.h> | ||
36 | #include <sound/wss.h> | 37 | #include <sound/wss.h> |
37 | #include <sound/mpu401.h> | 38 | #include <sound/mpu401.h> |
38 | #include <sound/opl3.h> | 39 | #include <sound/opl3.h> |
@@ -546,6 +547,85 @@ __skip_mpu: | |||
546 | 547 | ||
547 | #ifdef OPTi93X | 548 | #ifdef OPTi93X |
548 | 549 | ||
550 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); | ||
551 | |||
552 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | ||
553 | WSS_DOUBLE("Master Playback Switch", 0, | ||
554 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | ||
555 | WSS_DOUBLE_TLV("Master Playback Volume", 0, | ||
556 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, | ||
557 | db_scale_6bit), | ||
558 | WSS_DOUBLE("PCM Playback Volume", 0, | ||
559 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1), | ||
560 | WSS_DOUBLE("FM Playback Volume", 0, | ||
561 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1), | ||
562 | WSS_DOUBLE("Line Playback Switch", 0, | ||
563 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | ||
564 | WSS_DOUBLE("Line Playback Volume", 0, | ||
565 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1), | ||
566 | WSS_DOUBLE("Mic Playback Switch", 0, | ||
567 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), | ||
568 | WSS_DOUBLE("Mic Playback Volume", 0, | ||
569 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1), | ||
570 | WSS_DOUBLE("CD Playback Volume", 0, | ||
571 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1), | ||
572 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
573 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), | ||
574 | WSS_DOUBLE("Aux Playback Volume", 0, | ||
575 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1), | ||
576 | }; | ||
577 | |||
578 | static int __devinit snd_opti93x_mixer(struct snd_wss *chip) | ||
579 | { | ||
580 | struct snd_card *card; | ||
581 | unsigned int idx; | ||
582 | struct snd_ctl_elem_id id1, id2; | ||
583 | int err; | ||
584 | |||
585 | if (snd_BUG_ON(!chip || !chip->pcm)) | ||
586 | return -EINVAL; | ||
587 | |||
588 | card = chip->card; | ||
589 | |||
590 | strcpy(card->mixername, chip->pcm->name); | ||
591 | |||
592 | memset(&id1, 0, sizeof(id1)); | ||
593 | memset(&id2, 0, sizeof(id2)); | ||
594 | id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
595 | /* reassign AUX0 switch to CD */ | ||
596 | strcpy(id1.name, "Aux Playback Switch"); | ||
597 | strcpy(id2.name, "CD Playback Switch"); | ||
598 | err = snd_ctl_rename_id(card, &id1, &id2); | ||
599 | if (err < 0) { | ||
600 | snd_printk(KERN_ERR "Cannot rename opti93x control\n"); | ||
601 | return err; | ||
602 | } | ||
603 | /* reassign AUX1 switch to FM */ | ||
604 | strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; | ||
605 | strcpy(id2.name, "FM Playback Switch"); | ||
606 | err = snd_ctl_rename_id(card, &id1, &id2); | ||
607 | if (err < 0) { | ||
608 | snd_printk(KERN_ERR "Cannot rename opti93x control\n"); | ||
609 | return err; | ||
610 | } | ||
611 | /* remove AUX1 volume */ | ||
612 | strcpy(id1.name, "Aux Playback Volume"); id1.index = 1; | ||
613 | snd_ctl_remove_id(card, &id1); | ||
614 | |||
615 | /* Replace WSS volume controls with OPTi93x volume controls */ | ||
616 | id1.index = 0; | ||
617 | for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { | ||
618 | strcpy(id1.name, snd_opti93x_controls[idx].name); | ||
619 | snd_ctl_remove_id(card, &id1); | ||
620 | |||
621 | err = snd_ctl_add(card, | ||
622 | snd_ctl_new1(&snd_opti93x_controls[idx], chip)); | ||
623 | if (err < 0) | ||
624 | return err; | ||
625 | } | ||
626 | return 0; | ||
627 | } | ||
628 | |||
549 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | 629 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) |
550 | { | 630 | { |
551 | struct snd_wss *codec = dev_id; | 631 | struct snd_wss *codec = dev_id; |
@@ -752,6 +832,11 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
752 | error = snd_wss_mixer(codec); | 832 | error = snd_wss_mixer(codec); |
753 | if (error < 0) | 833 | if (error < 0) |
754 | return error; | 834 | return error; |
835 | #ifdef OPTi93X | ||
836 | error = snd_opti93x_mixer(codec); | ||
837 | if (error < 0) | ||
838 | return error; | ||
839 | #endif | ||
755 | #ifdef CS4231 | 840 | #ifdef CS4231 |
756 | error = snd_wss_timer(codec, 0, &timer); | 841 | error = snd_wss_timer(codec, 0, &timer); |
757 | if (error < 0) | 842 | if (error < 0) |