aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/es1688/es1688.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/isa/es1688/es1688.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'sound/isa/es1688/es1688.c')
-rw-r--r--sound/isa/es1688/es1688.c204
1 files changed, 204 insertions, 0 deletions
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
new file mode 100644
index 000000000000..c5eaec087b46
--- /dev/null
+++ b/sound/isa/es1688/es1688.c
@@ -0,0 +1,204 @@
1/*
2 * Driver for generic ESS AudioDrive ESx688 soundcards
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
4 *
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
22#include <sound/driver.h>
23#include <asm/dma.h>
24#include <linux/init.h>
25#include <linux/time.h>
26#include <linux/wait.h>
27#include <linux/moduleparam.h>
28#include <sound/core.h>
29#include <sound/es1688.h>
30#include <sound/mpu401.h>
31#include <sound/opl3.h>
32#define SNDRV_LEGACY_AUTO_PROBE
33#define SNDRV_LEGACY_FIND_FREE_IRQ
34#define SNDRV_LEGACY_FIND_FREE_DMA
35#include <sound/initval.h>
36
37MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
38MODULE_DESCRIPTION("ESS ESx688 AudioDrive");
39MODULE_LICENSE("GPL");
40MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100},"
41 "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102},"
42 "{ESS,ES688 AudioDrive,pnp:ESS6881},"
43 "{ESS,ES1688 AudioDrive,pnp:ESS1681}}");
44
45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
48static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
49static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
50static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
51static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
52static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */
53
54module_param_array(index, int, NULL, 0444);
55MODULE_PARM_DESC(index, "Index value for ESx688 soundcard.");
56module_param_array(id, charp, NULL, 0444);
57MODULE_PARM_DESC(id, "ID string for ESx688 soundcard.");
58module_param_array(enable, bool, NULL, 0444);
59MODULE_PARM_DESC(enable, "Enable ESx688 soundcard.");
60module_param_array(port, long, NULL, 0444);
61MODULE_PARM_DESC(port, "Port # for ESx688 driver.");
62module_param_array(mpu_port, long, NULL, 0444);
63MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ESx688 driver.");
64module_param_array(irq, int, NULL, 0444);
65MODULE_PARM_DESC(irq, "IRQ # for ESx688 driver.");
66module_param_array(mpu_irq, int, NULL, 0444);
67MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver.");
68module_param_array(dma8, int, NULL, 0444);
69MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver.");
70
71static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
72
73
74static int __init snd_audiodrive_probe(int dev)
75{
76 static int possible_irqs[] = {5, 9, 10, 7, -1};
77 static int possible_dmas[] = {1, 3, 0, -1};
78 int xirq, xdma, xmpu_irq;
79 snd_card_t *card;
80 es1688_t *chip;
81 opl3_t *opl3;
82 snd_pcm_t *pcm;
83 int err;
84
85 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
86 if (card == NULL)
87 return -ENOMEM;
88
89 xirq = irq[dev];
90 if (xirq == SNDRV_AUTO_IRQ) {
91 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
92 snd_card_free(card);
93 snd_printk("unable to find a free IRQ\n");
94 return -EBUSY;
95 }
96 }
97 xmpu_irq = mpu_irq[dev];
98 xdma = dma8[dev];
99 if (xdma == SNDRV_AUTO_DMA) {
100 if ((xdma = snd_legacy_find_free_dma(possible_dmas)) < 0) {
101 snd_card_free(card);
102 snd_printk("unable to find a free DMA\n");
103 return -EBUSY;
104 }
105 }
106
107 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev],
108 xirq, xmpu_irq, xdma,
109 ES1688_HW_AUTO, &chip)) < 0) {
110 snd_card_free(card);
111 return err;
112 }
113 if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) {
114 snd_card_free(card);
115 return err;
116 }
117 if ((err = snd_es1688_mixer(chip)) < 0) {
118 snd_card_free(card);
119 return err;
120 }
121
122 strcpy(card->driver, "ES1688");
123 strcpy(card->shortname, pcm->name);
124 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma);
125
126 if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) {
127 printk(KERN_ERR "es1688: opl3 not detected at 0x%lx\n", chip->port);
128 } else {
129 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
130 snd_card_free(card);
131 return err;
132 }
133 }
134
135 if (xmpu_irq >= 0 && xmpu_irq != SNDRV_AUTO_IRQ && chip->mpu_port > 0) {
136 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
137 chip->mpu_port, 0,
138 xmpu_irq,
139 SA_INTERRUPT,
140 NULL)) < 0) {
141 snd_card_free(card);
142 return err;
143 }
144 }
145 if ((err = snd_card_register(card)) < 0) {
146 snd_card_free(card);
147 return err;
148 }
149 snd_audiodrive_cards[dev] = card;
150 return 0;
151
152}
153
154static int __init snd_audiodrive_legacy_auto_probe(unsigned long xport)
155{
156 static int dev;
157 int res;
158
159 for ( ; dev < SNDRV_CARDS; dev++) {
160 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT)
161 continue;
162 port[dev] = xport;
163 res = snd_audiodrive_probe(dev);
164 if (res < 0)
165 port[dev] = SNDRV_AUTO_PORT;
166 return res;
167 }
168 return -ENODEV;
169}
170
171static int __init alsa_card_es1688_init(void)
172{
173 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1};
174 int dev, cards = 0, i;
175
176 for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) {
177 if (port[dev] == SNDRV_AUTO_PORT)
178 continue;
179 if (snd_audiodrive_probe(dev) >= 0)
180 cards++;
181 }
182 i = snd_legacy_auto_probe(possible_ports, snd_audiodrive_legacy_auto_probe);
183 if (i > 0)
184 cards += i;
185
186 if (!cards) {
187#ifdef MODULE
188 printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n");
189#endif
190 return -ENODEV;
191 }
192 return 0;
193}
194
195static void __exit alsa_card_es1688_exit(void)
196{
197 int idx;
198
199 for (idx = 0; idx < SNDRV_CARDS; idx++)
200 snd_card_free(snd_audiodrive_cards[idx]);
201}
202
203module_init(alsa_card_es1688_init)
204module_exit(alsa_card_es1688_exit)