source: GPL/alsa-kernel/isa/ad1848/ad1848.c@ 1

Last change on this file since 1 was 1, checked in by vladest, 20 years ago

initial import

File size: 5.3 KB
Line 
1/*
2 * Generic driver for AD1848/AD1847/CS4248 chips (0.1 Alpha)
3 * Copyright (c) by Tugrul Galatali <galatalt@stuy.edu>,
4 * Jaroslav Kysela <perex@suse.cz>
5 * Based on card-4232.c by Jaroslav Kysela <perex@suse.cz>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#define SNDRV_MAIN_OBJECT_FILE
25#include <sound/driver.h>
26#include <sound/ad1848.h>
27#define SNDRV_GET_ID
28#include <sound/initval.h>
29
30#define chip_t ad1848_t
31
32EXPORT_NO_SYMBOLS;
33MODULE_DESCRIPTION("AD1848/AD1847/CS4248");
34MODULE_CLASSES("{sound}");
35MODULE_DEVICES("{{Analog Devices,AD1848},"
36 "{Analog Devices,AD1847},"
37 "{Crystal Semiconductors,CS4248}}");
38
39static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
40static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
41static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
42static long snd_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
43static int snd_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
44static int snd_dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
45
46MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
47MODULE_PARM_DESC(snd_index, "Index value for AD1848 soundcard.");
48MODULE_PARM_SYNTAX(snd_index, SNDRV_INDEX_DESC);
49MODULE_PARM(snd_id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
50MODULE_PARM_DESC(snd_id, "ID string for AD1848 soundcard.");
51MODULE_PARM_SYNTAX(snd_id, SNDRV_ID_DESC);
52MODULE_PARM(snd_enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
53MODULE_PARM_DESC(snd_enable, "Enable AD1848 soundcard.");
54MODULE_PARM_SYNTAX(snd_enable, SNDRV_ENABLE_DESC);
55MODULE_PARM(snd_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
56MODULE_PARM_DESC(snd_port, "Port # for AD1848 driver.");
57MODULE_PARM_SYNTAX(snd_port, SNDRV_PORT12_DESC);
58MODULE_PARM(snd_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
59MODULE_PARM_DESC(snd_irq, "IRQ # for AD1848 driver.");
60MODULE_PARM_SYNTAX(snd_irq, SNDRV_IRQ_DESC);
61MODULE_PARM(snd_dma1, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
62MODULE_PARM_DESC(snd_dma1, "DMA1 # for AD1848 driver.");
63MODULE_PARM_SYNTAX(snd_dma1, SNDRV_DMA_DESC);
64
65static snd_card_t *snd_ad1848_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
66
67
68static int __init snd_card_ad1848_probe(int dev)
69{
70 snd_card_t *card;
71 ad1848_t *chip;
72 snd_pcm_t *pcm;
73 int err;
74
75 if (snd_port[dev] == SNDRV_AUTO_PORT) {
76 snd_printk("specify snd_port\n");
77 return -EINVAL;
78 }
79 if (snd_irq[dev] == SNDRV_AUTO_IRQ) {
80 snd_printk("specify snd_irq\n");
81 return -EINVAL;
82 }
83 if (snd_dma1[dev] == SNDRV_AUTO_DMA) {
84 snd_printk("specify snd_dma1\n");
85 return -EINVAL;
86 }
87
88 card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE, 0);
89 if (card == NULL)
90 return -ENOMEM;
91
92 if ((err = snd_ad1848_create(card, snd_port[dev],
93 snd_irq[dev],
94 snd_dma1[dev],
95 AD1848_HW_DETECT,
96 &chip)) < 0) {
97 snd_card_free(card);
98 return err;
99 }
100
101 if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) {
102 snd_card_free(card);
103 return err;
104 }
105 if ((err = snd_ad1848_mixer(chip)) < 0) {
106 snd_card_free(card);
107 return err;
108 }
109 strcpy(card->driver, "AD1848");
110 strcpy(card->shortname, pcm->name);
111
112 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
113 pcm->name, chip->port, snd_irq[dev], snd_dma1[dev]);
114
115 if ((err = snd_card_register(card)) < 0) {
116 snd_card_free(card);
117 return err;
118 }
119 snd_ad1848_cards[dev] = card;
120 return 0;
121}
122
123static int __init alsa_card_ad1848_init(void)
124{
125 int dev, cards;
126
127 for (dev = cards = 0; dev < SNDRV_CARDS && snd_enable[dev]; dev++)
128 if (snd_card_ad1848_probe(dev) >= 0)
129 cards++;
130
131 if (!cards) {
132#ifdef MODULE
133 snd_printk("AD1848 soundcard not found or device busy\n");
134#endif
135 return -ENODEV;
136 }
137 return 0;
138}
139
140static void __exit alsa_card_ad1848_exit(void)
141{
142 int idx;
143
144 for (idx = 0; idx < SNDRV_CARDS; idx++)
145 snd_card_free(snd_ad1848_cards[idx]);
146}
147
148module_init(alsa_card_ad1848_init)
149module_exit(alsa_card_ad1848_exit)
150
151#ifndef MODULE
152
153/* format is: snd-card-ad1848=snd_enable,snd_index,snd_id,snd_port,
154 snd_irq,snd_dma1 */
155
156static int __init alsa_card_ad1848_setup(char *str)
157{
158 static unsigned __initdata nr_dev = 0;
159
160 if (nr_dev >= SNDRV_CARDS)
161 return 0;
162 (void)(get_option(&str,&snd_enable[nr_dev]) == 2 &&
163 get_option(&str,&snd_index[nr_dev]) == 2 &&
164 get_id(&str,&snd_id[nr_dev]) == 2 &&
165 get_option(&str,(int *)&snd_port[nr_dev]) == 2 &&
166 get_option(&str,&snd_irq[nr_dev]) == 2 &&
167 get_option(&str,&snd_dma1[nr_dev]) == 2);
168 nr_dev++;
169 return 1;
170}
171
172__setup("snd-card-ad1848=", alsa_card_ad1848_setup);
173
174#endif /* ifndef MODULE */
Note: See TracBrowser for help on using the repository browser.