~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/isa/gus/gusclassic.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/isa/gus/gusclassic.c (Version linux-6.12-rc7) and /sound/isa/gus/gusclassic.c (Version linux-5.8.18)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /*
  3  *  Driver for Gravis UltraSound Classic sound      3  *  Driver for Gravis UltraSound Classic soundcard
  4  *  Copyright (c) by Jaroslav Kysela <perex@pe      4  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  5  */                                                 5  */
  6                                                     6 
  7 #include <linux/init.h>                             7 #include <linux/init.h>
  8 #include <linux/err.h>                              8 #include <linux/err.h>
  9 #include <linux/isa.h>                              9 #include <linux/isa.h>
 10 #include <linux/delay.h>                           10 #include <linux/delay.h>
 11 #include <linux/time.h>                            11 #include <linux/time.h>
 12 #include <linux/module.h>                          12 #include <linux/module.h>
 13 #include <asm/dma.h>                               13 #include <asm/dma.h>
 14 #include <sound/core.h>                            14 #include <sound/core.h>
 15 #include <sound/gus.h>                             15 #include <sound/gus.h>
 16 #define SNDRV_LEGACY_FIND_FREE_IRQ                 16 #define SNDRV_LEGACY_FIND_FREE_IRQ
 17 #define SNDRV_LEGACY_FIND_FREE_DMA                 17 #define SNDRV_LEGACY_FIND_FREE_DMA
 18 #include <sound/initval.h>                         18 #include <sound/initval.h>
 19                                                    19 
 20 #define CRD_NAME "Gravis UltraSound Classic"       20 #define CRD_NAME "Gravis UltraSound Classic"
 21 #define DEV_NAME "gusclassic"                      21 #define DEV_NAME "gusclassic"
 22                                                    22 
 23 MODULE_DESCRIPTION(CRD_NAME);                      23 MODULE_DESCRIPTION(CRD_NAME);
 24 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz     24 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 25 MODULE_LICENSE("GPL");                             25 MODULE_LICENSE("GPL");
                                                   >>  26 MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}");
 26                                                    27 
 27 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_     28 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
 28 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_S     29 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
 29 static bool enable[SNDRV_CARDS] = SNDRV_DEFAUL     30 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
 30 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_     31 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x230,0x240,0x250,0x260 */
 31 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IR     32 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;        /* 3,5,9,11,12,15 */
 32 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_D     33 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* 1,3,5,6,7 */
 33 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_D     34 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* 1,3,5,6,7 */
 34 static int joystick_dac[SNDRV_CARDS] = {[0 ...     35 static int joystick_dac[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 29};
 35                                 /* 0 to 31, (0     36                                 /* 0 to 31, (0.59V-4.52V or 0.389V-2.98V) */
 36 static int channels[SNDRV_CARDS] = {[0 ... (SN     37 static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
 37 static int pcm_channels[SNDRV_CARDS] = {[0 ...     38 static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
 38                                                    39 
 39 module_param_array(index, int, NULL, 0444);        40 module_param_array(index, int, NULL, 0444);
 40 MODULE_PARM_DESC(index, "Index value for " CRD     41 MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
 41 module_param_array(id, charp, NULL, 0444);         42 module_param_array(id, charp, NULL, 0444);
 42 MODULE_PARM_DESC(id, "ID string for " CRD_NAME     43 MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
 43 module_param_array(enable, bool, NULL, 0444);      44 module_param_array(enable, bool, NULL, 0444);
 44 MODULE_PARM_DESC(enable, "Enable " CRD_NAME "      45 MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
 45 module_param_hw_array(port, long, ioport, NULL     46 module_param_hw_array(port, long, ioport, NULL, 0444);
 46 MODULE_PARM_DESC(port, "Port # for " CRD_NAME      47 MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
 47 module_param_hw_array(irq, int, irq, NULL, 044     48 module_param_hw_array(irq, int, irq, NULL, 0444);
 48 MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME "      49 MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
 49 module_param_hw_array(dma1, int, dma, NULL, 04     50 module_param_hw_array(dma1, int, dma, NULL, 0444);
 50 MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME      51 MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
 51 module_param_hw_array(dma2, int, dma, NULL, 04     52 module_param_hw_array(dma2, int, dma, NULL, 0444);
 52 MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME      53 MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
 53 module_param_array(joystick_dac, int, NULL, 04     54 module_param_array(joystick_dac, int, NULL, 0444);
 54 MODULE_PARM_DESC(joystick_dac, "Joystick DAC l     55 MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver.");
 55 module_param_array(channels, int, NULL, 0444);     56 module_param_array(channels, int, NULL, 0444);
 56 MODULE_PARM_DESC(channels, "GF1 channels for "     57 MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver.");
 57 module_param_array(pcm_channels, int, NULL, 04     58 module_param_array(pcm_channels, int, NULL, 0444);
 58 MODULE_PARM_DESC(pcm_channels, "Reserved PCM c     59 MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
 59                                                    60 
 60 static int snd_gusclassic_match(struct device      61 static int snd_gusclassic_match(struct device *dev, unsigned int n)
 61 {                                                  62 {
 62         return enable[n];                          63         return enable[n];
 63 }                                                  64 }
 64                                                    65 
 65 static int snd_gusclassic_create(struct snd_ca     66 static int snd_gusclassic_create(struct snd_card *card,
 66                                  struct device     67                                  struct device *dev, unsigned int n,
 67                                  struct snd_gu     68                                  struct snd_gus_card **rgus)
 68 {                                                  69 {
 69         static const long possible_ports[] = {     70         static const long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260};
 70         static const int possible_irqs[] = {5,     71         static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
 71         static const int possible_dmas[] = {5,     72         static const int possible_dmas[] = {5, 6, 7, 1, 3, -1};
 72                                                    73 
 73         int i, error;                              74         int i, error;
 74                                                    75 
 75         if (irq[n] == SNDRV_AUTO_IRQ) {            76         if (irq[n] == SNDRV_AUTO_IRQ) {
 76                 irq[n] = snd_legacy_find_free_     77                 irq[n] = snd_legacy_find_free_irq(possible_irqs);
 77                 if (irq[n] < 0) {                  78                 if (irq[n] < 0) {
 78                         dev_err(dev, "unable t     79                         dev_err(dev, "unable to find a free IRQ\n");
 79                         return -EBUSY;             80                         return -EBUSY;
 80                 }                                  81                 }
 81         }                                          82         }
 82         if (dma1[n] == SNDRV_AUTO_DMA) {           83         if (dma1[n] == SNDRV_AUTO_DMA) {
 83                 dma1[n] = snd_legacy_find_free     84                 dma1[n] = snd_legacy_find_free_dma(possible_dmas);
 84                 if (dma1[n] < 0) {                 85                 if (dma1[n] < 0) {
 85                         dev_err(dev, "unable t     86                         dev_err(dev, "unable to find a free DMA1\n");
 86                         return -EBUSY;             87                         return -EBUSY;
 87                 }                                  88                 }
 88         }                                          89         }
 89         if (dma2[n] == SNDRV_AUTO_DMA) {           90         if (dma2[n] == SNDRV_AUTO_DMA) {
 90                 dma2[n] = snd_legacy_find_free     91                 dma2[n] = snd_legacy_find_free_dma(possible_dmas);
 91                 if (dma2[n] < 0) {                 92                 if (dma2[n] < 0) {
 92                         dev_err(dev, "unable t     93                         dev_err(dev, "unable to find a free DMA2\n");
 93                         return -EBUSY;             94                         return -EBUSY;
 94                 }                                  95                 }
 95         }                                          96         }
 96                                                    97 
 97         if (port[n] != SNDRV_AUTO_PORT)            98         if (port[n] != SNDRV_AUTO_PORT)
 98                 return snd_gus_create(card, po     99                 return snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n],
 99                                 0, channels[n]    100                                 0, channels[n], pcm_channels[n], 0, rgus);
100                                                   101 
101         i = 0;                                    102         i = 0;
102         do {                                      103         do {
103                 port[n] = possible_ports[i];      104                 port[n] = possible_ports[i];
104                 error = snd_gus_create(card, p    105                 error = snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n],
105                                 0, channels[n]    106                                 0, channels[n], pcm_channels[n], 0, rgus);
106         } while (error < 0 && ++i < ARRAY_SIZE    107         } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
107                                                   108 
108         return error;                             109         return error;
109 }                                                 110 }
110                                                   111 
111 static int snd_gusclassic_detect(struct snd_gu    112 static int snd_gusclassic_detect(struct snd_gus_card *gus)
112 {                                                 113 {
113         unsigned char d;                          114         unsigned char d;
114                                                   115 
115         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES    116         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0);   /* reset GF1 */
116         d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_ !! 117         if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
117         if ((d & 0x07) != 0) {                 !! 118                 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
118                 dev_dbg(gus->card->dev, "[0x%l << 
119                 return -ENODEV;                   119                 return -ENODEV;
120         }                                         120         }
121         udelay(160);                              121         udelay(160);
122         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RES    122         snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1);   /* release reset */
123         udelay(160);                              123         udelay(160);
124         d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_ !! 124         if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
125         if ((d & 0x07) != 1) {                 !! 125                 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
126                 dev_dbg(gus->card->dev, "[0x%l << 
127                 return -ENODEV;                   126                 return -ENODEV;
128         }                                         127         }
129         return 0;                                 128         return 0;
130 }                                                 129 }
131                                                   130 
132 static int snd_gusclassic_probe(struct device     131 static int snd_gusclassic_probe(struct device *dev, unsigned int n)
133 {                                                 132 {
134         struct snd_card *card;                    133         struct snd_card *card;
135         struct snd_gus_card *gus;                 134         struct snd_gus_card *gus;
136         int error;                                135         int error;
137                                                   136 
138         error = snd_devm_card_new(dev, index[n !! 137         error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
139         if (error < 0)                            138         if (error < 0)
140                 return error;                     139                 return error;
141                                                   140 
142         if (pcm_channels[n] < 2)                  141         if (pcm_channels[n] < 2)
143                 pcm_channels[n] = 2;              142                 pcm_channels[n] = 2;
144                                                   143 
145         error = snd_gusclassic_create(card, de    144         error = snd_gusclassic_create(card, dev, n, &gus);
146         if (error < 0)                            145         if (error < 0)
147                 return error;                  !! 146                 goto out;
148                                                   147 
149         error = snd_gusclassic_detect(gus);       148         error = snd_gusclassic_detect(gus);
150         if (error < 0)                            149         if (error < 0)
151                 return error;                  !! 150                 goto out;
152                                                   151 
153         gus->joystick_dac = joystick_dac[n];      152         gus->joystick_dac = joystick_dac[n];
154                                                   153 
155         error = snd_gus_initialize(gus);          154         error = snd_gus_initialize(gus);
156         if (error < 0)                            155         if (error < 0)
157                 return error;                  !! 156                 goto out;
158                                                   157 
159         error = -ENODEV;                          158         error = -ENODEV;
160         if (gus->max_flag || gus->ess_flag) {     159         if (gus->max_flag || gus->ess_flag) {
161                 dev_err(dev, "GUS Classic or A    160                 dev_err(dev, "GUS Classic or ACE soundcard was "
162                         "not detected at 0x%lx    161                         "not detected at 0x%lx\n", gus->gf1.port);
163                 return error;                  !! 162                 goto out;
164         }                                         163         }
165                                                   164 
166         error = snd_gf1_new_mixer(gus);           165         error = snd_gf1_new_mixer(gus);
167         if (error < 0)                            166         if (error < 0)
168                 return error;                  !! 167                 goto out;
169                                                   168 
170         error = snd_gf1_pcm_new(gus, 0, 0);       169         error = snd_gf1_pcm_new(gus, 0, 0);
171         if (error < 0)                            170         if (error < 0)
172                 return error;                  !! 171                 goto out;
173                                                   172 
174         if (!gus->ace_flag) {                     173         if (!gus->ace_flag) {
175                 error = snd_gf1_rawmidi_new(gu    174                 error = snd_gf1_rawmidi_new(gus, 0);
176                 if (error < 0)                    175                 if (error < 0)
177                         return error;          !! 176                         goto out;
178         }                                         177         }
179                                                   178 
180         sprintf(card->longname + strlen(card->    179         sprintf(card->longname + strlen(card->longname),
181                 " at 0x%lx, irq %d, dma %d",      180                 " at 0x%lx, irq %d, dma %d",
182                 gus->gf1.port, gus->gf1.irq, g    181                 gus->gf1.port, gus->gf1.irq, gus->gf1.dma1);
183                                                   182 
184         if (gus->gf1.dma2 >= 0)                   183         if (gus->gf1.dma2 >= 0)
185                 sprintf(card->longname + strle    184                 sprintf(card->longname + strlen(card->longname),
186                         "&%d", gus->gf1.dma2);    185                         "&%d", gus->gf1.dma2);
187                                                   186 
188         error = snd_card_register(card);          187         error = snd_card_register(card);
189         if (error < 0)                            188         if (error < 0)
190                 return error;                  !! 189                 goto out;
191                                                   190 
192         dev_set_drvdata(dev, card);               191         dev_set_drvdata(dev, card);
193         return 0;                                 192         return 0;
                                                   >> 193 
                                                   >> 194 out:    snd_card_free(card);
                                                   >> 195         return error;
                                                   >> 196 }
                                                   >> 197 
                                                   >> 198 static int snd_gusclassic_remove(struct device *dev, unsigned int n)
                                                   >> 199 {
                                                   >> 200         snd_card_free(dev_get_drvdata(dev));
                                                   >> 201         return 0;
194 }                                                 202 }
195                                                   203 
196 static struct isa_driver snd_gusclassic_driver    204 static struct isa_driver snd_gusclassic_driver = {
197         .match          = snd_gusclassic_match    205         .match          = snd_gusclassic_match,
198         .probe          = snd_gusclassic_probe    206         .probe          = snd_gusclassic_probe,
                                                   >> 207         .remove         = snd_gusclassic_remove,
199 #if 0   /* FIXME */                               208 #if 0   /* FIXME */
200         .suspend        = snd_gusclassic_suspe    209         .suspend        = snd_gusclassic_suspend,
                                                   >> 210         .remove         = snd_gusclassic_remove,
201 #endif                                            211 #endif
202         .driver         = {                       212         .driver         = {
203                 .name   = DEV_NAME                213                 .name   = DEV_NAME
204         }                                         214         }
205 };                                                215 };
206                                                   216 
207 module_isa_driver(snd_gusclassic_driver, SNDRV    217 module_isa_driver(snd_gusclassic_driver, SNDRV_CARDS);
208                                                   218 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php