diff options
Diffstat (limited to 'sound/isa/gus/gusmax.c')
| -rw-r--r-- | sound/isa/gus/gusmax.c | 190 |
1 files changed, 73 insertions, 117 deletions
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 652d5d834620..b572411c4422 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -1,22 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Driver for Gravis UltraSound MAX soundcard * Copyright (c) by Jaroslav Kysela <perex@perex.cz> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * */ #include <linux/init.h> @@ -36,7 +21,6 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); MODULE_DESCRIPTION("Gravis UltraSound MAX"); MODULE_LICENSE("GPL"); -MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound MAX}}"); static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ @@ -56,13 +40,13 @@ module_param_array(id, charp, NULL, 0444); MODULE_PARM_DESC(id, "ID string for GUS MAX soundcard."); module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable GUS MAX soundcard."); -module_param_array(port, long, NULL, 0444); +module_param_hw_array(port, long, ioport, NULL, 0444); MODULE_PARM_DESC(port, "Port # for GUS MAX driver."); -module_param_array(irq, int, NULL, 0444); +module_param_hw_array(irq, int, irq, NULL, 0444); MODULE_PARM_DESC(irq, "IRQ # for GUS MAX driver."); -module_param_array(dma1, int, NULL, 0444); +module_param_hw_array(dma1, int, dma, NULL, 0444); MODULE_PARM_DESC(dma1, "DMA1 # for GUS MAX driver."); -module_param_array(dma2, int, NULL, 0444); +module_param_hw_array(dma2, int, dma, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for GUS MAX driver."); module_param_array(joystick_dac, int, NULL, 0444); MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS MAX driver."); @@ -80,22 +64,22 @@ struct snd_gusmax { unsigned short pcm_status_reg; }; -#define PFX "gusmax: " - static int snd_gusmax_detect(struct snd_gus_card *gus) { unsigned char d; snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { - snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); + d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET); + if ((d & 0x07) != 0) { + dev_dbg(gus->card->dev, "[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; } udelay(160); snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ udelay(160); - if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) { - snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); + d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET); + if ((d & 0x07) != 1) { + dev_dbg(gus->card->dev, "[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); return -ENODEV; } @@ -150,22 +134,26 @@ static int snd_gusmax_mixer(struct snd_wss *chip) memset(&id2, 0, sizeof(id2)); id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; /* reassign AUXA to SYNTHESIZER */ - strcpy(id1.name, "Aux Playback Switch"); - strcpy(id2.name, "Synth Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + strscpy(id1.name, "Aux Playback Switch"); + strscpy(id2.name, "Synth Playback Switch"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) return err; - strcpy(id1.name, "Aux Playback Volume"); - strcpy(id2.name, "Synth Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + strscpy(id1.name, "Aux Playback Volume"); + strscpy(id2.name, "Synth Playback Volume"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) return err; /* reassign AUXB to CD */ - strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; - strcpy(id2.name, "CD Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + strscpy(id1.name, "Aux Playback Switch"); id1.index = 1; + strscpy(id2.name, "CD Playback Switch"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) return err; - strcpy(id1.name, "Aux Playback Volume"); - strcpy(id2.name, "CD Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + strscpy(id1.name, "Aux Playback Volume"); + strscpy(id2.name, "CD Playback Volume"); + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) return err; #if 0 /* reassign Mono Input to MIC */ @@ -189,16 +177,6 @@ static int snd_gusmax_mixer(struct snd_wss *chip) return 0; } -static void snd_gusmax_free(struct snd_card *card) -{ - struct snd_gusmax *maxcard = card->private_data; - - if (maxcard == NULL) - return; - if (maxcard->irq >= 0) - free_irq(maxcard->irq, (void *)maxcard); -} - static int snd_gusmax_match(struct device *pdev, unsigned int dev) { return enable[dev]; @@ -206,45 +184,44 @@ static int snd_gusmax_match(struct device *pdev, unsigned int dev) static int snd_gusmax_probe(struct device *pdev, unsigned int dev) { - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; - static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; + static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; + static const int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2, err; struct snd_card *card; struct snd_gus_card *gus = NULL; struct snd_wss *wss; struct snd_gusmax *maxcard; - err = snd_card_create(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_gusmax), &card); + err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_gusmax), &card); if (err < 0) return err; - card->private_free = snd_gusmax_free; maxcard = card->private_data; maxcard->card = card; maxcard->irq = -1; xirq = irq[dev]; if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; + xirq = snd_legacy_find_free_irq(possible_irqs); + if (xirq < 0) { + dev_err(pdev, "unable to find a free IRQ\n"); + return -EBUSY; } } xdma1 = dma1[dev]; if (xdma1 == SNDRV_AUTO_DMA) { - if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); - err = -EBUSY; - goto _err; + xdma1 = snd_legacy_find_free_dma(possible_dmas); + if (xdma1 < 0) { + dev_err(pdev, "unable to find a free DMA1\n"); + return -EBUSY; } } xdma2 = dma2[dev]; if (xdma2 == SNDRV_AUTO_DMA) { - if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); - err = -EBUSY; - goto _err; + xdma2 = snd_legacy_find_free_dma(possible_dmas); + if (xdma2 < 0) { + dev_err(pdev, "unable to find a free DMA2\n"); + return -EBUSY; } } @@ -256,7 +233,7 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) pcm_channels[dev], 0, &gus); } else { - static unsigned long possible_ports[] = { + static const unsigned long possible_ports[] = { 0x220, 0x230, 0x240, 0x250, 0x260 }; int i; @@ -274,30 +251,32 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) } } if (err < 0) - goto _err; + return err; - if ((err = snd_gusmax_detect(gus)) < 0) - goto _err; + err = snd_gusmax_detect(gus); + if (err < 0) + return err; maxcard->gus_status_reg = gus->gf1.reg_irqstat; maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; snd_gusmax_init(dev, card, gus); - if ((err = snd_gus_initialize(gus)) < 0) - goto _err; + err = snd_gus_initialize(gus); + if (err < 0) + return err; if (!gus->max_flag) { - snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); - err = -ENODEV; - goto _err; + dev_err(pdev, "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); + return -ENODEV; } - if (request_irq(xirq, snd_gusmax_interrupt, 0, "GUS MAX", (void *)maxcard)) { - snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); - err = -EBUSY; - goto _err; + if (devm_request_irq(card->dev, xirq, snd_gusmax_interrupt, 0, + "GUS MAX", (void *)maxcard)) { + dev_err(pdev, "unable to grab IRQ %d\n", xirq); + return -EBUSY; } maxcard->irq = xirq; - + card->sync_irq = maxcard->irq; + err = snd_wss_create(card, gus->gf1.port + 0x10c, -1, xirq, xdma2 < 0 ? xdma1 : xdma2, xdma1, @@ -307,57 +286,46 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) WSS_HWSHARE_DMA2, &wss); if (err < 0) - goto _err; + return err; - err = snd_wss_pcm(wss, 0, NULL); + err = snd_wss_pcm(wss, 0); if (err < 0) - goto _err; + return err; err = snd_wss_mixer(wss); if (err < 0) - goto _err; + return err; - err = snd_wss_timer(wss, 2, NULL); + err = snd_wss_timer(wss, 2); if (err < 0) - goto _err; + return err; if (pcm_channels[dev] > 0) { - if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) - goto _err; + err = snd_gf1_pcm_new(gus, 1, 1); + if (err < 0) + return err; } err = snd_gusmax_mixer(wss); if (err < 0) - goto _err; + return err; - err = snd_gf1_rawmidi_new(gus, 0, NULL); + err = snd_gf1_rawmidi_new(gus, 0); if (err < 0) - goto _err; + return err; sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); - snd_card_set_dev(card, pdev); - err = snd_card_register(card); if (err < 0) - goto _err; + return err; maxcard->gus = gus; maxcard->wss = wss; dev_set_drvdata(pdev, card); return 0; - - _err: - snd_card_free(card); - return err; -} - -static int snd_gusmax_remove(struct device *devptr, unsigned int dev) -{ - snd_card_free(dev_get_drvdata(devptr)); - return 0; } #define DEV_NAME "gusmax" @@ -365,22 +333,10 @@ static int snd_gusmax_remove(struct device *devptr, unsigned int dev) static struct isa_driver snd_gusmax_driver = { .match = snd_gusmax_match, .probe = snd_gusmax_probe, - .remove = snd_gusmax_remove, /* FIXME: suspend/resume */ .driver = { .name = DEV_NAME }, }; -static int __init alsa_card_gusmax_init(void) -{ - return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS); -} - -static void __exit alsa_card_gusmax_exit(void) -{ - isa_unregister_driver(&snd_gusmax_driver); -} - -module_init(alsa_card_gusmax_init) -module_exit(alsa_card_gusmax_exit) +module_isa_driver(snd_gusmax_driver, SNDRV_CARDS); |
