^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Driver for Gravis UltraSound Extreme soundcards
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/isa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/dma.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <sound/gus.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <sound/es1688.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <sound/mpu401.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <sound/opl3.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define SNDRV_LEGACY_AUTO_PROBE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define SNDRV_LEGACY_FIND_FREE_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define SNDRV_LEGACY_FIND_FREE_DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <sound/initval.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define CRD_NAME "Gravis UltraSound Extreme"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define DEV_NAME "gusextreme"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) MODULE_DESCRIPTION(CRD_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static long gf1_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS) - 1] = -1}; /* 0x210,0x220,0x230,0x240,0x250,0x260,0x270 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS) - 1] = -1}; /* 0x300,0x310,0x320 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static int gf1_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 2,3,5,9,11,12,15 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static int joystick_dac[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 29};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* 0 to 31, (0.59V-4.52V or 0.389V-2.98V) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) module_param_array(index, int, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) module_param_array(id, charp, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) module_param_array(enable, bool, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) module_param_hw_array(port, long, ioport, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) module_param_hw_array(gf1_port, long, ioport, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) MODULE_PARM_DESC(gf1_port, "GF1 port # for " CRD_NAME " driver (optional).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) module_param_hw_array(irq, int, irq, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) module_param_hw_array(mpu_irq, int, irq, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) module_param_hw_array(gf1_irq, int, irq, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) module_param_hw_array(dma8, int, dma, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) module_param_hw_array(dma1, int, dma, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) MODULE_PARM_DESC(dma1, "GF1 DMA # for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) module_param_array(joystick_dac, int, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) module_param_array(channels, int, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) module_param_array(pcm_channels, int, NULL, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static int snd_gusextreme_match(struct device *dev, unsigned int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return enable[n];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static int snd_gusextreme_es1688_create(struct snd_card *card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct snd_es1688 *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct device *dev, unsigned int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static const long possible_ports[] = {0x220, 0x240, 0x260};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static const int possible_irqs[] = {5, 9, 10, 7, -1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) static const int possible_dmas[] = {1, 3, 0, -1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int i, error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (irq[n] == SNDRV_AUTO_IRQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) irq[n] = snd_legacy_find_free_irq(possible_irqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (irq[n] < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) dev_err(dev, "unable to find a free IRQ for ES1688\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (dma8[n] == SNDRV_AUTO_DMA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) dma8[n] = snd_legacy_find_free_dma(possible_dmas);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (dma8[n] < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) dev_err(dev, "unable to find a free DMA for ES1688\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) if (port[n] != SNDRV_AUTO_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) return snd_es1688_create(card, chip, port[n], mpu_port[n],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) irq[n], mpu_irq[n], dma8[n], ES1688_HW_1688);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) port[n] = possible_ports[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) error = snd_es1688_create(card, chip, port[n], mpu_port[n],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) irq[n], mpu_irq[n], dma8[n], ES1688_HW_1688);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int snd_gusextreme_gus_card_create(struct snd_card *card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct device *dev, unsigned int n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct snd_gus_card **rgus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static const int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static const int possible_dmas[] = {5, 6, 7, 3, 1, -1};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (gf1_irq[n] == SNDRV_AUTO_IRQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (gf1_irq[n] < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) dev_err(dev, "unable to find a free IRQ for GF1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (dma1[n] == SNDRV_AUTO_DMA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) dma1[n] = snd_legacy_find_free_dma(possible_dmas);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if (dma1[n] < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) dev_err(dev, "unable to find a free DMA for GF1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) return snd_gus_create(card, gf1_port[n], gf1_irq[n], dma1[n], -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 0, channels[n], pcm_channels[n], 0, rgus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static int snd_gusextreme_detect(struct snd_gus_card *gus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct snd_es1688 *es1688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) unsigned char d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * This is main stuff - enable access to GF1 chip...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * I'm not sure, if this will work for card which have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * ES1688 chip in another place than 0x220.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * I used reverse-engineering in DOSEMU. [--jk]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * ULTRINIT.EXE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * 0x230 = 0,2,3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * 0x240 = 2,0,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * 0x250 = 2,0,3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * 0x260 = 2,2,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) spin_lock_irqsave(&es1688->mixer_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) spin_unlock_irqrestore(&es1688->mixer_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) spin_lock_irqsave(&es1688->reg_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) outb(gus->gf1.port & 0x040 ? 2 : 0, ES1688P(es1688, INIT1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) outb(0, 0x201);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) outb(gus->gf1.port & 0x020 ? 2 : 0, ES1688P(es1688, INIT1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) outb(0, 0x201);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) outb(gus->gf1.port & 0x010 ? 3 : 1, ES1688P(es1688, INIT1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) spin_unlock_irqrestore(&es1688->reg_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) udelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) udelay(160);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) udelay(160);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static int snd_gusextreme_mixer(struct snd_card *card)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct snd_ctl_elem_id id1, id2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) memset(&id1, 0, sizeof(id1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) memset(&id2, 0, sizeof(id2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /* reassign AUX to SYNTHESIZER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) strcpy(id1.name, "Aux Playback Volume");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) strcpy(id2.name, "Synth Playback Volume");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) error = snd_ctl_rename_id(card, &id1, &id2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* reassign Master Playback Switch to Synth Playback Switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) strcpy(id1.name, "Master Playback Switch");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) strcpy(id2.name, "Synth Playback Switch");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) error = snd_ctl_rename_id(card, &id1, &id2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static int snd_gusextreme_probe(struct device *dev, unsigned int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct snd_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct snd_gus_card *gus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct snd_es1688 *es1688;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct snd_opl3 *opl3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) error = snd_card_new(dev, index[n], id[n], THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) sizeof(struct snd_es1688), &card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) es1688 = card->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (mpu_port[n] == SNDRV_AUTO_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) mpu_port[n] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (mpu_irq[n] > 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) mpu_irq[n] = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) error = snd_gusextreme_es1688_create(card, es1688, dev, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (gf1_port[n] < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) gf1_port[n] = es1688->port + 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) error = snd_gusextreme_gus_card_create(card, dev, n, &gus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) error = snd_gusextreme_detect(gus, es1688);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) gus->joystick_dac = joystick_dac[n];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) error = snd_gus_initialize(gus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) error = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (!gus->ess_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) dev_err(dev, "GUS Extreme soundcard was not "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) "detected at 0x%lx\n", gus->gf1.port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) gus->codec_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) error = snd_es1688_pcm(card, es1688, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) error = snd_es1688_mixer(card, es1688);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) snd_component_add(card, "ES1688");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (pcm_channels[n] > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) error = snd_gf1_pcm_new(gus, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) error = snd_gf1_new_mixer(gus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) error = snd_gusextreme_mixer(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) if (snd_opl3_create(card, es1688->port, es1688->port + 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) OPL3_HW_OPL3, 0, &opl3) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) dev_warn(dev, "opl3 not detected at 0x%lx\n", es1688->port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) error = snd_opl3_hwdep_new(opl3, 0, 2, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) if (es1688->mpu_port >= 0x300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) es1688->mpu_port, 0, mpu_irq[n], NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) "irq %i&%i, dma %i&%i", es1688->port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) error = snd_card_register(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) dev_set_drvdata(dev, card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) out: snd_card_free(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static int snd_gusextreme_remove(struct device *dev, unsigned int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) snd_card_free(dev_get_drvdata(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) static struct isa_driver snd_gusextreme_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) .match = snd_gusextreme_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) .probe = snd_gusextreme_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) .remove = snd_gusextreme_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) #if 0 /* FIXME */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) .suspend = snd_gusextreme_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) .resume = snd_gusextreme_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) .name = DEV_NAME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) module_isa_driver(snd_gusextreme_driver, SNDRV_CARDS);