aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/es1688.h10
-rw-r--r--sound/isa/es1688/es1688.c23
-rw-r--r--sound/isa/es1688/es1688_lib.c44
-rw-r--r--sound/isa/gus/gusextreme.c26
4 files changed, 46 insertions, 57 deletions
diff --git a/include/sound/es1688.h b/include/sound/es1688.h
index 10fcf1465810..4c29572effb2 100644
--- a/include/sound/es1688.h
+++ b/include/sound/es1688.h
@@ -44,7 +44,6 @@ struct snd_es1688 {
44 unsigned char pad; 44 unsigned char pad;
45 unsigned int dma_size; 45 unsigned int dma_size;
46 46
47 struct snd_card *card;
48 struct snd_pcm *pcm; 47 struct snd_pcm *pcm;
49 struct snd_pcm_substream *playback_substream; 48 struct snd_pcm_substream *playback_substream;
50 struct snd_pcm_substream *capture_substream; 49 struct snd_pcm_substream *capture_substream;
@@ -108,14 +107,15 @@ struct snd_es1688 {
108void snd_es1688_mixer_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data); 107void snd_es1688_mixer_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data);
109 108
110int snd_es1688_create(struct snd_card *card, 109int snd_es1688_create(struct snd_card *card,
110 struct snd_es1688 *chip,
111 unsigned long port, 111 unsigned long port,
112 unsigned long mpu_port, 112 unsigned long mpu_port,
113 int irq, 113 int irq,
114 int mpu_irq, 114 int mpu_irq,
115 int dma8, 115 int dma8,
116 unsigned short hardware, 116 unsigned short hardware);
117 struct snd_es1688 ** rchip); 117int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device,
118int snd_es1688_pcm(struct snd_es1688 *chip, int device, struct snd_pcm ** rpcm); 118 struct snd_pcm **rpcm);
119int snd_es1688_mixer(struct snd_es1688 *chip); 119int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip);
120 120
121#endif /* __SOUND_ES1688_H */ 121#endif /* __SOUND_ES1688_H */
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 07df201ed8fa..281679493fb4 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -79,8 +79,8 @@ static int __devinit snd_es1688_match(struct device *dev, unsigned int n)
79 return enable[n]; 79 return enable[n];
80} 80}
81 81
82static int __devinit snd_es1688_legacy_create(struct snd_card *card, 82static int __devinit snd_es1688_legacy_create(struct snd_card *card,
83 struct device *dev, unsigned int n, struct snd_es1688 **rchip) 83 struct snd_es1688 *chip, struct device *dev, unsigned int n)
84{ 84{
85 static long possible_ports[] = {0x220, 0x240, 0x260}; 85 static long possible_ports[] = {0x220, 0x240, 0x260};
86 static int possible_irqs[] = {5, 9, 10, 7, -1}; 86 static int possible_irqs[] = {5, 9, 10, 7, -1};
@@ -104,14 +104,14 @@ static int __devinit snd_es1688_legacy_create(struct snd_card *card,
104 } 104 }
105 105
106 if (port[n] != SNDRV_AUTO_PORT) 106 if (port[n] != SNDRV_AUTO_PORT)
107 return snd_es1688_create(card, port[n], mpu_port[n], irq[n], 107 return snd_es1688_create(card, chip, port[n], mpu_port[n],
108 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip); 108 irq[n], mpu_irq[n], dma8[n], ES1688_HW_AUTO);
109 109
110 i = 0; 110 i = 0;
111 do { 111 do {
112 port[n] = possible_ports[i]; 112 port[n] = possible_ports[i];
113 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n], 113 error = snd_es1688_create(card, chip, port[n], mpu_port[n],
114 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip); 114 irq[n], mpu_irq[n], dma8[n], ES1688_HW_AUTO);
115 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports)); 115 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
116 116
117 return error; 117 return error;
@@ -125,19 +125,22 @@ static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
125 struct snd_pcm *pcm; 125 struct snd_pcm *pcm;
126 int error; 126 int error;
127 127
128 error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); 128 error = snd_card_create(index[n], id[n], THIS_MODULE,
129 sizeof(struct snd_es1688), &card);
129 if (error < 0) 130 if (error < 0)
130 return error; 131 return error;
131 132
132 error = snd_es1688_legacy_create(card, dev, n, &chip); 133 chip = card->private_data;
134
135 error = snd_es1688_legacy_create(card, chip, dev, n);
133 if (error < 0) 136 if (error < 0)
134 goto out; 137 goto out;
135 138
136 error = snd_es1688_pcm(chip, 0, &pcm); 139 error = snd_es1688_pcm(card, chip, 0, &pcm);
137 if (error < 0) 140 if (error < 0)
138 goto out; 141 goto out;
139 142
140 error = snd_es1688_mixer(chip); 143 error = snd_es1688_mixer(card, chip);
141 if (error < 0) 144 if (error < 0)
142 goto out; 145 goto out;
143 146
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index c76bb00c9d15..fdd440417bf0 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -620,7 +620,6 @@ static int snd_es1688_free(struct snd_es1688 *chip)
620 disable_dma(chip->dma8); 620 disable_dma(chip->dma8);
621 free_dma(chip->dma8); 621 free_dma(chip->dma8);
622 } 622 }
623 kfree(chip);
624 return 0; 623 return 0;
625} 624}
626 625
@@ -638,23 +637,20 @@ static const char *snd_es1688_chip_id(struct snd_es1688 *chip)
638} 637}
639 638
640int snd_es1688_create(struct snd_card *card, 639int snd_es1688_create(struct snd_card *card,
640 struct snd_es1688 *chip,
641 unsigned long port, 641 unsigned long port,
642 unsigned long mpu_port, 642 unsigned long mpu_port,
643 int irq, 643 int irq,
644 int mpu_irq, 644 int mpu_irq,
645 int dma8, 645 int dma8,
646 unsigned short hardware, 646 unsigned short hardware)
647 struct snd_es1688 **rchip)
648{ 647{
649 static struct snd_device_ops ops = { 648 static struct snd_device_ops ops = {
650 .dev_free = snd_es1688_dev_free, 649 .dev_free = snd_es1688_dev_free,
651 }; 650 };
652 651
653 struct snd_es1688 *chip;
654 int err; 652 int err;
655 653
656 *rchip = NULL;
657 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
658 if (chip == NULL) 654 if (chip == NULL)
659 return -ENOMEM; 655 return -ENOMEM;
660 chip->irq = -1; 656 chip->irq = -1;
@@ -662,25 +658,21 @@ int snd_es1688_create(struct snd_card *card,
662 658
663 if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) { 659 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); 660 snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
665 snd_es1688_free(chip);
666 return -EBUSY; 661 return -EBUSY;
667 } 662 }
668 if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) { 663 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); 664 snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
670 snd_es1688_free(chip);
671 return -EBUSY; 665 return -EBUSY;
672 } 666 }
673 chip->irq = irq; 667 chip->irq = irq;
674 if (request_dma(dma8, "ES1688")) { 668 if (request_dma(dma8, "ES1688")) {
675 snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8); 669 snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
676 snd_es1688_free(chip);
677 return -EBUSY; 670 return -EBUSY;
678 } 671 }
679 chip->dma8 = dma8; 672 chip->dma8 = dma8;
680 673
681 spin_lock_init(&chip->reg_lock); 674 spin_lock_init(&chip->reg_lock);
682 spin_lock_init(&chip->mixer_lock); 675 spin_lock_init(&chip->mixer_lock);
683 chip->card = card;
684 chip->port = port; 676 chip->port = port;
685 mpu_port &= ~0x000f; 677 mpu_port &= ~0x000f;
686 if (mpu_port < 0x300 || mpu_port > 0x330) 678 if (mpu_port < 0x300 || mpu_port > 0x330)
@@ -689,23 +681,16 @@ int snd_es1688_create(struct snd_card *card,
689 chip->mpu_irq = mpu_irq; 681 chip->mpu_irq = mpu_irq;
690 chip->hardware = hardware; 682 chip->hardware = hardware;
691 683
692 if ((err = snd_es1688_probe(chip)) < 0) { 684 err = snd_es1688_probe(chip);
693 snd_es1688_free(chip); 685 if (err < 0)
694 return err; 686 return err;
695 }
696 if ((err = snd_es1688_init(chip, 1)) < 0) {
697 snd_es1688_free(chip);
698 return err;
699 }
700 687
701 /* Register device */ 688 err = snd_es1688_init(chip, 1);
702 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 689 if (err < 0)
703 snd_es1688_free(chip);
704 return err; 690 return err;
705 }
706 691
707 *rchip = chip; 692 /* Register device */
708 return 0; 693 return snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
709} 694}
710 695
711static struct snd_pcm_ops snd_es1688_playback_ops = { 696static struct snd_pcm_ops snd_es1688_playback_ops = {
@@ -730,12 +715,14 @@ static struct snd_pcm_ops snd_es1688_capture_ops = {
730 .pointer = snd_es1688_capture_pointer, 715 .pointer = snd_es1688_capture_pointer,
731}; 716};
732 717
733int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm) 718int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip,
719 int device, struct snd_pcm **rpcm)
734{ 720{
735 struct snd_pcm *pcm; 721 struct snd_pcm *pcm;
736 int err; 722 int err;
737 723
738 if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0) 724 err = snd_pcm_new(card, "ESx688", device, 1, 1, &pcm);
725 if (err < 0)
739 return err; 726 return err;
740 727
741 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1688_playback_ops); 728 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1688_playback_ops);
@@ -1009,18 +996,15 @@ static unsigned char snd_es1688_init_table[][2] = {
1009 { ES1688_REC_DEV, 0x17 } 996 { ES1688_REC_DEV, 0x17 }
1010}; 997};
1011 998
1012int snd_es1688_mixer(struct snd_es1688 *chip) 999int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip)
1013{ 1000{
1014 struct snd_card *card;
1015 unsigned int idx; 1001 unsigned int idx;
1016 int err; 1002 int err;
1017 unsigned char reg, val; 1003 unsigned char reg, val;
1018 1004
1019 if (snd_BUG_ON(!chip || !chip->card)) 1005 if (snd_BUG_ON(!chip || !card))
1020 return -EINVAL; 1006 return -EINVAL;
1021 1007
1022 card = chip->card;
1023
1024 strcpy(card->mixername, snd_es1688_chip_id(chip)); 1008 strcpy(card->mixername, snd_es1688_chip_id(chip));
1025 1009
1026 for (idx = 0; idx < ARRAY_SIZE(snd_es1688_controls); idx++) { 1010 for (idx = 0; idx < ARRAY_SIZE(snd_es1688_controls); idx++) {
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index 65e4b18581a6..008e8e5bfa37 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -95,7 +95,7 @@ static int __devinit snd_gusextreme_match(struct device *dev, unsigned int n)
95} 95}
96 96
97static int __devinit snd_gusextreme_es1688_create(struct snd_card *card, 97static int __devinit snd_gusextreme_es1688_create(struct snd_card *card,
98 struct device *dev, unsigned int n, struct snd_es1688 **rchip) 98 struct snd_es1688 *chip, struct device *dev, unsigned int n)
99{ 99{
100 static long possible_ports[] = {0x220, 0x240, 0x260}; 100 static long possible_ports[] = {0x220, 0x240, 0x260};
101 static int possible_irqs[] = {5, 9, 10, 7, -1}; 101 static int possible_irqs[] = {5, 9, 10, 7, -1};
@@ -119,14 +119,14 @@ static int __devinit snd_gusextreme_es1688_create(struct snd_card *card,
119 } 119 }
120 120
121 if (port[n] != SNDRV_AUTO_PORT) 121 if (port[n] != SNDRV_AUTO_PORT)
122 return snd_es1688_create(card, port[n], mpu_port[n], irq[n], 122 return snd_es1688_create(card, chip, port[n], mpu_port[n],
123 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip); 123 irq[n], mpu_irq[n], dma8[n], ES1688_HW_1688);
124 124
125 i = 0; 125 i = 0;
126 do { 126 do {
127 port[n] = possible_ports[i]; 127 port[n] = possible_ports[i];
128 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n], 128 error = snd_es1688_create(card, chip, port[n], mpu_port[n],
129 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip); 129 irq[n], mpu_irq[n], dma8[n], ES1688_HW_1688);
130 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports)); 130 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
131 131
132 return error; 132 return error;
@@ -206,9 +206,8 @@ static int __devinit snd_gusextreme_detect(struct snd_gus_card *gus,
206 return 0; 206 return 0;
207} 207}
208 208
209static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip) 209static int __devinit snd_gusextreme_mixer(struct snd_card *card)
210{ 210{
211 struct snd_card *card = chip->card;
212 struct snd_ctl_elem_id id1, id2; 211 struct snd_ctl_elem_id id1, id2;
213 int error; 212 int error;
214 213
@@ -241,17 +240,20 @@ static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
241 struct snd_opl3 *opl3; 240 struct snd_opl3 *opl3;
242 int error; 241 int error;
243 242
244 error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card); 243 error = snd_card_create(index[n], id[n], THIS_MODULE,
244 sizeof(struct snd_es1688), &card);
245 if (error < 0) 245 if (error < 0)
246 return error; 246 return error;
247 247
248 es1688 = card->private_data;
249
248 if (mpu_port[n] == SNDRV_AUTO_PORT) 250 if (mpu_port[n] == SNDRV_AUTO_PORT)
249 mpu_port[n] = 0; 251 mpu_port[n] = 0;
250 252
251 if (mpu_irq[n] > 15) 253 if (mpu_irq[n] > 15)
252 mpu_irq[n] = -1; 254 mpu_irq[n] = -1;
253 255
254 error = snd_gusextreme_es1688_create(card, dev, n, &es1688); 256 error = snd_gusextreme_es1688_create(card, es1688, dev, n);
255 if (error < 0) 257 if (error < 0)
256 goto out; 258 goto out;
257 259
@@ -280,11 +282,11 @@ static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
280 } 282 }
281 gus->codec_flag = 1; 283 gus->codec_flag = 1;
282 284
283 error = snd_es1688_pcm(es1688, 0, NULL); 285 error = snd_es1688_pcm(card, es1688, 0, NULL);
284 if (error < 0) 286 if (error < 0)
285 goto out; 287 goto out;
286 288
287 error = snd_es1688_mixer(es1688); 289 error = snd_es1688_mixer(card, es1688);
288 if (error < 0) 290 if (error < 0)
289 goto out; 291 goto out;
290 292
@@ -300,7 +302,7 @@ static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
300 if (error < 0) 302 if (error < 0)
301 goto out; 303 goto out;
302 304
303 error = snd_gusextreme_mixer(es1688); 305 error = snd_gusextreme_mixer(card);
304 if (error < 0) 306 if (error < 0)
305 goto out; 307 goto out;
306 308