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

TOMOYO Linux Cross Reference
Linux/sound/isa/ad1816a/ad1816a.c

Version: ~ [ linux-5.10-rc1 ] ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 
  2 /*
  3     card-ad1816a.c - driver for ADI SoundPort AD1816A based soundcards.
  4     Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
  5 
  6     This program is free software; you can redistribute it and/or modify
  7     it under the terms of the GNU General Public License as published by
  8     the Free Software Foundation; either version 2 of the License, or
  9     (at your option) any later version.
 10 
 11     This program is distributed in the hope that it will be useful,
 12     but WITHOUT ANY WARRANTY; without even the implied warranty of
 13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14     GNU General Public License for more details.
 15 
 16     You should have received a copy of the GNU General Public License
 17     along with this program; if not, write to the Free Software
 18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 19 */
 20 
 21 #include <sound/driver.h>
 22 #include <linux/init.h>
 23 #include <linux/time.h>
 24 #include <linux/wait.h>
 25 #include <linux/pnp.h>
 26 #include <sound/core.h>
 27 #define SNDRV_GET_ID
 28 #include <sound/initval.h>
 29 #include <sound/ad1816a.h>
 30 #include <sound/mpu401.h>
 31 #include <sound/opl3.h>
 32 
 33 #define chip_t ad1816a_t
 34 
 35 #define PFX "ad1816a: "
 36 
 37 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
 38 MODULE_DESCRIPTION("AD1816A, AD1815");
 39 MODULE_LICENSE("GPL");
 40 MODULE_CLASSES("{sound}");
 41 MODULE_DEVICES("{{Highscreen,Sound-Boostar 16 3D},"
 42                 "{Analog Devices,AD1815},"
 43                 "{Analog Devices,AD1816A},"
 44                 "{TerraTec,Base 64},"
 45                 "{TerraTec,AudioSystem EWS64S},"
 46                 "{Aztech/Newcom SC-16 3D},"
 47                 "{Shark Predator ISA}}");
 48 
 49 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 1-MAX */
 50 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
 51 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;   /* Enable this card */
 52 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
 53 static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
 54 static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;  /* PnP setup */
 55 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;        /* Pnp setup */
 56 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;    /* Pnp setup */
 57 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* PnP setup */
 58 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* PnP setup */
 59 
 60 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 61 MODULE_PARM_DESC(index, "Index value for ad1816a based soundcard.");
 62 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
 63 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
 64 MODULE_PARM_DESC(id, "ID string for ad1816a based soundcard.");
 65 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
 66 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 67 MODULE_PARM_DESC(enable, "Enable ad1816a based soundcard.");
 68 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
 69 MODULE_PARM(port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
 70 MODULE_PARM_DESC(port, "Port # for ad1816a driver.");
 71 MODULE_PARM_SYNTAX(port, SNDRV_PORT12_DESC);
 72 MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
 73 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ad1816a driver.");
 74 MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT12_DESC);
 75 MODULE_PARM(fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
 76 MODULE_PARM_DESC(fm_port, "FM port # for ad1816a driver.");
 77 MODULE_PARM_SYNTAX(fm_port, SNDRV_PORT12_DESC);
 78 MODULE_PARM(irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 79 MODULE_PARM_DESC(irq, "IRQ # for ad1816a driver.");
 80 MODULE_PARM_SYNTAX(irq, SNDRV_IRQ_DESC);
 81 MODULE_PARM(mpu_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 82 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ad1816a driver.");
 83 MODULE_PARM_SYNTAX(mpu_irq, SNDRV_IRQ_DESC);
 84 MODULE_PARM(dma1, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 85 MODULE_PARM_DESC(dma1, "1st DMA # for ad1816a driver.");
 86 MODULE_PARM_SYNTAX(dma1, SNDRV_DMA_DESC);
 87 MODULE_PARM(dma2, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 88 MODULE_PARM_DESC(dma2, "2nd DMA # for ad1816a driver.");
 89 MODULE_PARM_SYNTAX(dma2, SNDRV_DMA_DESC);
 90 
 91 struct snd_card_ad1816a {
 92         struct pnp_dev *dev;
 93         struct pnp_dev *devmpu;
 94 };
 95 
 96 static struct pnp_card_device_id snd_ad1816a_pnpids[] = {
 97         /* Analog Devices AD1815 */
 98         { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } },
 99         /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */
100         { .id = "ADS7181", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
101         /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */
102         { .id = "AZT1022", .devs = { { .id = "AZT1018" }, { .id = "AZT2002" } } },
103         /* Highscreen Sound-Boostar 16 3D - added by Stefan Behnel */
104         { .id = "LWC1061", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
105         /* Highscreen Sound-Boostar 16 3D */
106         { .id = "MDK1605", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
107         /* Shark Predator ISA - added by Ken Arromdee */
108         { .id = "SMM7180", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
109         /* Analog Devices AD1816A - Terratec AudioSystem EWS64S */
110         { .id = "TER1112", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
111         /* Analog Devices AD1816A - Terratec Base 64 */
112         { .id = "TER1411", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
113         /* end */
114         { .id = "" }
115 };
116 
117 MODULE_DEVICE_TABLE(pnp_card, snd_ad1816a_pnpids);
118 
119 
120 #define DRIVER_NAME     "snd-card-ad1816a"
121 
122 
123 static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acard,
124                                           struct pnp_card_link *card,
125                                           const struct pnp_card_device_id *id)
126 {
127         struct pnp_dev *pdev;
128         struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
129         int err;
130 
131         acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
132         if (acard->dev == NULL) {
133                 kfree(cfg);
134                 return -EBUSY;
135         }
136         acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL);
137         if (acard->devmpu == NULL) {
138                 kfree(cfg);
139                 return -EBUSY;
140         }
141 
142         pdev = acard->dev;
143         pnp_init_resource_table(cfg);
144 
145         if (port[dev] != SNDRV_AUTO_PORT)
146                 pnp_resource_change(&cfg->port_resource[2], port[dev], 16);
147         if (fm_port[dev] != SNDRV_AUTO_PORT)
148                 pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4);
149         if (dma1[dev] != SNDRV_AUTO_DMA)
150                 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1);
151         if (dma2[dev] != SNDRV_AUTO_DMA)
152                 pnp_resource_change(&cfg->dma_resource[1], dma2[dev], 1);
153         if (irq[dev] != SNDRV_AUTO_IRQ)
154                 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1);
155 
156         if (pnp_manual_config_dev(pdev, cfg, 0) < 0)
157                 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n");
158         err = pnp_activate_dev(pdev);
159         if (err < 0) {
160                 printk(KERN_ERR PFX "AUDIO PnP configure failure\n");
161                 kfree(cfg);
162                 return -EBUSY;
163         }
164 
165         port[dev] = pnp_port_start(pdev, 2);
166         fm_port[dev] = pnp_port_start(pdev, 1);
167         dma1[dev] = pnp_dma(pdev, 0);
168         dma2[dev] = pnp_dma(pdev, 1);
169         irq[dev] = pnp_irq(pdev, 0);
170 
171         pdev = acard->devmpu;
172         pnp_init_resource_table(cfg);
173 
174         if (mpu_port[dev] != SNDRV_AUTO_PORT)
175                 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2);
176         if (mpu_irq[dev] != SNDRV_AUTO_IRQ)
177                 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1);
178 
179         if (pnp_manual_config_dev(pdev, cfg, 0) < 0)
180                 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n");
181         err = pnp_activate_dev(pdev);
182         if (err < 0) {
183                 printk(KERN_ERR PFX "MPU401 PnP configure failure\n");
184                 mpu_port[dev] = -1;
185                 acard->devmpu = NULL;
186         } else {
187                 mpu_port[dev] = pnp_port_start(pdev, 0);
188                 mpu_irq[dev] = pnp_irq(pdev, 0);
189         }
190 
191         kfree(cfg);
192         return 0;
193 }
194 
195 static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
196                                             const struct pnp_card_device_id *pid)
197 {
198         int error;
199         snd_card_t *card;
200         struct snd_card_ad1816a *acard;
201         ad1816a_t *chip;
202         opl3_t *opl3;
203 
204         if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
205                                  sizeof(struct snd_card_ad1816a))) == NULL)
206                 return -ENOMEM;
207         acard = (struct snd_card_ad1816a *)card->private_data;
208 
209         if ((error = snd_card_ad1816a_pnp(dev, acard, pcard, pid))) {
210                 snd_card_free(card);
211                 return error;
212         }
213 
214         if ((error = snd_ad1816a_create(card, port[dev],
215                                         irq[dev],
216                                         dma1[dev],
217                                         dma2[dev],
218                                         &chip)) < 0) {
219                 snd_card_free(card);
220                 return error;
221         }
222 
223         if ((error = snd_ad1816a_pcm(chip, 0, NULL)) < 0) {
224                 snd_card_free(card);
225                 return error;
226         }
227 
228         if ((error = snd_ad1816a_mixer(chip)) < 0) {
229                 snd_card_free(card);
230                 return error;
231         }
232 
233         if (mpu_port[dev] > 0) {
234                 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
235                                         mpu_port[dev], 0, mpu_irq[dev], SA_INTERRUPT,
236                                         NULL) < 0)
237                         printk(KERN_ERR PFX "no MPU-401 device at 0x%lx.\n", mpu_port[dev]);
238         }
239 
240         if (fm_port[dev] > 0) {
241                 if (snd_opl3_create(card,
242                                     fm_port[dev], fm_port[dev] + 2,
243                                     OPL3_HW_AUTO, 0, &opl3) < 0) {
244                         printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx.\n", fm_port[dev], fm_port[dev] + 2);
245                 } else {
246                         if ((error = snd_opl3_timer_new(opl3, 1, 2)) < 0) {
247                                 snd_card_free(card);
248                                 return error;
249                         }
250                         if ((error = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
251                                 snd_card_free(card);
252                                 return error;
253                         }
254                 }
255         }
256 
257         strcpy(card->driver, "AD1816A");
258         strcpy(card->shortname, "ADI SoundPort AD1816A");
259         sprintf(card->longname, "%s soundcard, SS at 0x%lx, irq %d, dma %d&%d",
260                 card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]);
261 
262         if ((error = snd_card_register(card)) < 0) {
263                 snd_card_free(card);
264                 return error;
265         }
266         pnp_set_card_drvdata(pcard, card);
267         return 0;
268 }
269 
270 static int __devinit snd_ad1816a_pnp_detect(struct pnp_card_link *card,
271                                             const struct pnp_card_device_id *id)
272 {
273         static int dev;
274         int res;
275 
276         for ( ; dev < SNDRV_CARDS; dev++) {
277                 if (!enable[dev])
278                         continue;
279                 res = snd_card_ad1816a_probe(dev, card, id);
280                 if (res < 0)
281                         return res;
282                 dev++;
283                 return 0;
284         }
285         return -ENODEV;
286 }
287 
288 static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard)
289 {
290         snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard);
291 
292         snd_card_disconnect(card);
293         snd_card_free_in_thread(card);
294 }
295 
296 static struct pnp_card_driver ad1816a_pnpc_driver = {
297         .flags          = PNP_DRIVER_RES_DISABLE,
298         .name           = "ad1816a",
299         .id_table       = snd_ad1816a_pnpids,
300         .probe          = snd_ad1816a_pnp_detect,
301         .remove         = __devexit_p(snd_ad1816a_pnp_remove),
302 };
303 
304 static int __init alsa_card_ad1816a_init(void)
305 {
306         int cards = 0;
307 
308         cards += pnp_register_card_driver(&ad1816a_pnpc_driver);
309 #ifdef MODULE
310         if (!cards) {
311                 pnp_unregister_card_driver(&ad1816a_pnpc_driver);
312                 printk(KERN_ERR "no AD1816A based soundcards found.\n");
313         }
314 #endif  /* MODULE */
315         return cards ? 0 : -ENODEV;
316 }
317 
318 static void __exit alsa_card_ad1816a_exit(void)
319 {
320         pnp_unregister_card_driver(&ad1816a_pnpc_driver);
321 }
322 
323 module_init(alsa_card_ad1816a_init)
324 module_exit(alsa_card_ad1816a_exit)
325 
326 #ifndef MODULE
327 
328 /* format is: snd-ad1816a=enable,index,id,port,
329                           mpu_port,fm_port,irq,mpu_irq,
330                           dma1,dma2 */
331 
332 static int __init alsa_card_ad1816a_setup(char *str)
333 {
334         static unsigned __initdata nr_dev = 0;
335 
336         if (nr_dev >= SNDRV_CARDS)
337                 return 0;
338         (void)(get_option(&str,&enable[nr_dev]) == 2 &&
339                get_option(&str,&index[nr_dev]) == 2 &&
340                get_id(&str,&id[nr_dev]) == 2 &&
341                get_option(&str,(int *)&port[nr_dev]) == 2 &&
342                get_option(&str,(int *)&mpu_port[nr_dev]) == 2 &&
343                get_option(&str,(int *)&fm_port[nr_dev]) == 2 &&
344                get_option(&str,&irq[nr_dev]) == 2 &&
345                get_option(&str,&mpu_irq[nr_dev]) == 2 &&
346                get_option(&str,&dma1[nr_dev]) == 2 &&
347                get_option(&str,&dma2[nr_dev]) == 2);
348         nr_dev++;
349         return 1;
350 }
351 
352 __setup("snd-ad1816a=", alsa_card_ad1816a_setup);
353 
354 #endif /* ifndef MODULE */
355 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp