aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/es1688/es1688_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/es1688/es1688_lib.c')
-rw-r--r--sound/isa/es1688/es1688_lib.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index c76bb00c9d15..07676200496a 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -99,7 +99,7 @@ static unsigned char snd_es1688_mixer_read(struct snd_es1688 *chip, unsigned cha
99 return result; 99 return result;
100} 100}
101 101
102static int snd_es1688_reset(struct snd_es1688 *chip) 102int snd_es1688_reset(struct snd_es1688 *chip)
103{ 103{
104 int i; 104 int i;
105 105
@@ -115,6 +115,7 @@ static int snd_es1688_reset(struct snd_es1688 *chip)
115 snd_es1688_dsp_command(chip, 0xc6); /* enable extended mode */ 115 snd_es1688_dsp_command(chip, 0xc6); /* enable extended mode */
116 return 0; 116 return 0;
117} 117}
118EXPORT_SYMBOL(snd_es1688_reset);
118 119
119static int snd_es1688_probe(struct snd_es1688 *chip) 120static int snd_es1688_probe(struct snd_es1688 *chip)
120{ 121{
@@ -620,7 +621,6 @@ static int snd_es1688_free(struct snd_es1688 *chip)
620 disable_dma(chip->dma8); 621 disable_dma(chip->dma8);
621 free_dma(chip->dma8); 622 free_dma(chip->dma8);
622 } 623 }
623 kfree(chip);
624 return 0; 624 return 0;
625} 625}
626 626
@@ -638,23 +638,20 @@ static const char *snd_es1688_chip_id(struct snd_es1688 *chip)
638} 638}
639 639
640int snd_es1688_create(struct snd_card *card, 640int snd_es1688_create(struct snd_card *card,
641 struct snd_es1688 *chip,
641 unsigned long port, 642 unsigned long port,
642 unsigned long mpu_port, 643 unsigned long mpu_port,
643 int irq, 644 int irq,
644 int mpu_irq, 645 int mpu_irq,
645 int dma8, 646 int dma8,
646 unsigned short hardware, 647 unsigned short hardware)
647 struct snd_es1688 **rchip)
648{ 648{
649 static struct snd_device_ops ops = { 649 static struct snd_device_ops ops = {
650 .dev_free = snd_es1688_dev_free, 650 .dev_free = snd_es1688_dev_free,
651 }; 651 };
652 652
653 struct snd_es1688 *chip;
654 int err; 653 int err;
655 654
656 *rchip = NULL;
657 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
658 if (chip == NULL) 655 if (chip == NULL)
659 return -ENOMEM; 656 return -ENOMEM;
660 chip->irq = -1; 657 chip->irq = -1;
@@ -662,25 +659,21 @@ int snd_es1688_create(struct snd_card *card,
662 659
663 if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) { 660 if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) {
664 snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4); 661 snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
665 snd_es1688_free(chip);
666 return -EBUSY; 662 return -EBUSY;
667 } 663 }
668 if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) { 664 if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) {
669 snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq); 665 snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
670 snd_es1688_free(chip);
671 return -EBUSY; 666 return -EBUSY;
672 } 667 }
673 chip->irq = irq; 668 chip->irq = irq;
674 if (request_dma(dma8, "ES1688")) { 669 if (request_dma(dma8, "ES1688")) {
675 snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8); 670 snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
676 snd_es1688_free(chip);
677 return -EBUSY; 671 return -EBUSY;
678 } 672 }
679 chip->dma8 = dma8; 673 chip->dma8 = dma8;
680 674
681 spin_lock_init(&chip->reg_lock); 675 spin_lock_init(&chip->reg_lock);
682 spin_lock_init(&chip->mixer_lock); 676 spin_lock_init(&chip->mixer_lock);
683 chip->card = card;
684 chip->port = port; 677 chip->port = port;
685 mpu_port &= ~0x000f; 678 mpu_port &= ~0x000f;
686 if (mpu_port < 0x300 || mpu_port > 0x330) 679 if (mpu_port < 0x300 || mpu_port > 0x330)
@@ -689,23 +682,16 @@ int snd_es1688_create(struct snd_card *card,
689 chip->mpu_irq = mpu_irq; 682 chip->mpu_irq = mpu_irq;
690 chip->hardware = hardware; 683 chip->hardware = hardware;
691 684
692 if ((err = snd_es1688_probe(chip)) < 0) { 685 err = snd_es1688_probe(chip);
693 snd_es1688_free(chip); 686 if (err < 0)
694 return err; 687 return err;
695 }
696 if ((err = snd_es1688_init(chip, 1)) < 0) {
697 snd_es1688_free(chip);
698 return err;
699 }
700 688
701 /* Register device */ 689 err = snd_es1688_init(chip, 1);
702 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 690 if (err < 0)
703 snd_es1688_free(chip);
704 return err; 691 return err;
705 }
706 692
707 *rchip = chip; 693 /* Register device */
708 return 0; 694 return snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
709} 695}
710 696
711static struct snd_pcm_ops snd_es1688_playback_ops = { 697static struct snd_pcm_ops snd_es1688_playback_ops = {
@@ -730,12 +716,14 @@ static struct snd_pcm_ops snd_es1688_capture_ops = {
730 .pointer = snd_es1688_capture_pointer, 716 .pointer = snd_es1688_capture_pointer,
731}; 717};
732 718
733int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm) 719int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip,
720 int device, struct snd_pcm **rpcm)
734{ 721{
735 struct snd_pcm *pcm; 722 struct snd_pcm *pcm;
736 int err; 723 int err;
737 724
738 if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0) 725 err = snd_pcm_new(card, "ESx688", device, 1, 1, &pcm);
726 if (err < 0)
739 return err; 727 return err;
740 728
741 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1688_playback_ops); 729 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1688_playback_ops);
@@ -1009,18 +997,15 @@ static unsigned char snd_es1688_init_table[][2] = {
1009 { ES1688_REC_DEV, 0x17 } 997 { ES1688_REC_DEV, 0x17 }
1010}; 998};
1011 999
1012int snd_es1688_mixer(struct snd_es1688 *chip) 1000int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip)
1013{ 1001{
1014 struct snd_card *card;
1015 unsigned int idx; 1002 unsigned int idx;
1016 int err; 1003 int err;
1017 unsigned char reg, val; 1004 unsigned char reg, val;
1018 1005
1019 if (snd_BUG_ON(!chip || !chip->card)) 1006 if (snd_BUG_ON(!chip || !card))
1020 return -EINVAL; 1007 return -EINVAL;
1021 1008
1022 card = chip->card;
1023
1024 strcpy(card->mixername, snd_es1688_chip_id(chip)); 1009 strcpy(card->mixername, snd_es1688_chip_id(chip));
1025 1010
1026 for (idx = 0; idx < ARRAY_SIZE(snd_es1688_controls); idx++) { 1011 for (idx = 0; idx < ARRAY_SIZE(snd_es1688_controls); idx++) {