1 | /*
|
---|
2 | * The driver for the EMU10K1 (SB Live!) based 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 <linux/init.h>
|
---|
24 | #include <linux/time.h>
|
---|
25 | #include <sound/core.h>
|
---|
26 | #include <sound/emu10k1.h>
|
---|
27 | #define SNDRV_GET_ID
|
---|
28 | #include <sound/initval.h>
|
---|
29 |
|
---|
30 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
|
---|
31 | MODULE_DESCRIPTION("EMU10K1");
|
---|
32 | MODULE_LICENSE("GPL");
|
---|
33 | MODULE_CLASSES("{sound}");
|
---|
34 | MODULE_DEVICES("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
|
---|
35 | "{Creative Labs,SB Audigy}}");
|
---|
36 |
|
---|
37 | #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
|
---|
38 | #define ENABLE_SYNTH
|
---|
39 | #include <sound/emu10k1_synth.h>
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
---|
43 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
---|
44 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
|
---|
45 |
|
---|
46 | #ifdef TARGET_OS2
|
---|
47 | static int extin[SNDRV_CARDS] = {0,0,0,0,0,0,0,0};
|
---|
48 | static int extout[SNDRV_CARDS] = {0,0,0,0,0,0,0,0};
|
---|
49 | static int seq_ports[SNDRV_CARDS] = {4,4,4,4,4,4,4,4};
|
---|
50 | static int max_synth_voices[SNDRV_CARDS] = {64,64,64,64,64,64,64,64};
|
---|
51 | static int max_buffer_size[SNDRV_CARDS] = {128,128,128,128,128,128,128,128};
|
---|
52 | static int enable_ir[SNDRV_CARDS] = {0,0,0,0,0,0,0,0};
|
---|
53 | static uint subsystem[SNDRV_CARDS] = {0,0,0,0,0,0,0,0}; /* Force card subsystem model */
|
---|
54 | #else
|
---|
55 | static int extin[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
|
---|
56 | static int extout[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
|
---|
57 | static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
|
---|
58 | static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64};
|
---|
59 | static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
|
---|
60 | static int enable_ir[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
64 | MODULE_PARM_DESC(index, "Index value for the EMU10K1 soundcard.");
|
---|
65 | MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
|
---|
66 | MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
|
---|
67 | MODULE_PARM_DESC(id, "ID string for the EMU10K1 soundcard.");
|
---|
68 | MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
|
---|
69 | MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
70 | MODULE_PARM_DESC(enable, "Enable the EMU10K1 soundcard.");
|
---|
71 | MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
|
---|
72 | MODULE_PARM(extin, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
73 | MODULE_PARM_DESC(extin, "Available external inputs for FX8010. Zero=default.");
|
---|
74 | MODULE_PARM_SYNTAX(extin, SNDRV_ENABLED "allows:{{0,0x0ffff}},base:16");
|
---|
75 | MODULE_PARM(extout, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
76 | MODULE_PARM_DESC(extout, "Available external outputs for FX8010. Zero=default.");
|
---|
77 | MODULE_PARM_SYNTAX(extout, SNDRV_ENABLED "allows:{{0,0x0ffff}},base:16");
|
---|
78 | MODULE_PARM(seq_ports, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
79 | MODULE_PARM_DESC(seq_ports, "Allocated sequencer ports for internal synthesizer.");
|
---|
80 | MODULE_PARM_SYNTAX(seq_ports, SNDRV_ENABLED "allows:{{0,32}}");
|
---|
81 | MODULE_PARM(max_synth_voices, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
82 | MODULE_PARM_DESC(max_synth_voices, "Maximum number of voices for WaveTable.");
|
---|
83 | MODULE_PARM_SYNTAX(max_synth_voices, SNDRV_ENABLED);
|
---|
84 | MODULE_PARM(max_buffer_size, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
85 | MODULE_PARM_DESC(max_buffer_size, "Maximum sample buffer size in MB.");
|
---|
86 | MODULE_PARM_SYNTAX(max_buffer_size, SNDRV_ENABLED);
|
---|
87 | MODULE_PARM(enable_ir, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
88 | MODULE_PARM_DESC(enable_ir, "Enable IR.");
|
---|
89 | MODULE_PARM_SYNTAX(enable_ir, SNDRV_ENABLE_DESC);
|
---|
90 | //module_param_array(subsystem, uint, NULL, 0444);
|
---|
91 | MODULE_PARM_DESC(subsystem, "Force card subsystem model.");
|
---|
92 | /*
|
---|
93 | * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400
|
---|
94 | */
|
---|
95 |
|
---|
96 | static struct pci_device_id snd_emu10k1_ids[] = {
|
---|
97 | { 0x1102, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* EMU10K1 */
|
---|
98 | { 0x1102, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, /* Audigy */
|
---|
99 | { 0x1102, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, /* Audigy 2 Value SB0400 */
|
---|
100 | { 0, }
|
---|
101 | };
|
---|
102 | /*
|
---|
103 | * Audigy 2 Value notes:
|
---|
104 | * A_IOCFG Input (GPIO)
|
---|
105 | * 0x400 = Front analog jack plugged in. (Green socket)
|
---|
106 | * 0x1000 = Read analog jack plugged in. (Black socket)
|
---|
107 | * 0x2000 = Center/LFE analog jack plugged in. (Orange socket)
|
---|
108 | * A_IOCFG Output (GPIO)
|
---|
109 | * 0x60 = Sound out of front Left.
|
---|
110 | * Win sets it to 0xXX61
|
---|
111 | */
|
---|
112 |
|
---|
113 | MODULE_DEVICE_TABLE(pci, snd_emu10k1_ids);
|
---|
114 |
|
---|
115 | static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
|
---|
116 | const struct pci_device_id *pci_id)
|
---|
117 | {
|
---|
118 | #ifdef TARGET_OS2
|
---|
119 | static int dev = 0;
|
---|
120 | #else
|
---|
121 | static int dev;
|
---|
122 | #endif
|
---|
123 | snd_card_t *card;
|
---|
124 | emu10k1_t *emu;
|
---|
125 | #ifdef ENABLE_SYNTH
|
---|
126 | snd_seq_device_t *wave = NULL;
|
---|
127 | #endif
|
---|
128 | int err;
|
---|
129 |
|
---|
130 | if (dev >= SNDRV_CARDS)
|
---|
131 | return -ENODEV;
|
---|
132 | if (!enable[dev]) {
|
---|
133 | dev++;
|
---|
134 | return -ENOENT;
|
---|
135 | }
|
---|
136 |
|
---|
137 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
---|
138 | if (card == NULL)
|
---|
139 | return -ENOMEM;
|
---|
140 | if (max_buffer_size[dev] < 32)
|
---|
141 | max_buffer_size[dev] = 32;
|
---|
142 | else if (max_buffer_size[dev] > 1024)
|
---|
143 | max_buffer_size[dev] = 1024;
|
---|
144 | if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev],
|
---|
145 | (long)max_buffer_size[dev] * 1024 * 1024,
|
---|
146 | enable_ir[dev], subsystem[dev],
|
---|
147 | &emu)) < 0) {
|
---|
148 | snd_card_free(card);
|
---|
149 | return err;
|
---|
150 | }
|
---|
151 | if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) {
|
---|
152 | snd_card_free(card);
|
---|
153 | return err;
|
---|
154 | }
|
---|
155 | if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) {
|
---|
156 | snd_card_free(card);
|
---|
157 | return err;
|
---|
158 | }
|
---|
159 | if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) {
|
---|
160 | snd_card_free(card);
|
---|
161 | return err;
|
---|
162 | }
|
---|
163 | /* This stores the periods table. */
|
---|
164 | if (emu->card_capabilities->ca0151_chip) { /* P16V */
|
---|
165 | if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &emu->p16v_buffer) < 0) {
|
---|
166 | snd_p16v_free(emu);
|
---|
167 | return -ENOMEM;
|
---|
168 | }
|
---|
169 | }
|
---|
170 | if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) {
|
---|
171 | snd_card_free(card);
|
---|
172 | return err;
|
---|
173 | }
|
---|
174 |
|
---|
175 | if ((err = snd_emu10k1_timer(emu, 0)) < 0) {
|
---|
176 | snd_card_free(card);
|
---|
177 | return err;
|
---|
178 | }
|
---|
179 |
|
---|
180 | if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) {
|
---|
181 | snd_card_free(card);
|
---|
182 | return err;
|
---|
183 | }
|
---|
184 |
|
---|
185 | if (emu->card_capabilities->ca0151_chip) { /* P16V */
|
---|
186 | if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) {
|
---|
187 | snd_card_free(card);
|
---|
188 | return err;
|
---|
189 | }
|
---|
190 | }
|
---|
191 | #ifdef TARGET_OS2
|
---|
192 | if (emu->audigy) {
|
---|
193 | if ((err = snd_emu10k1_audigy_midi(emu)) < 0) {
|
---|
194 | snd_card_free(card);
|
---|
195 | return err;
|
---|
196 | }
|
---|
197 | } else {
|
---|
198 | if ((err = snd_emu10k1_midi(emu)) < 0) {
|
---|
199 | snd_card_free(card);
|
---|
200 | return err;
|
---|
201 | }
|
---|
202 | }
|
---|
203 | #endif
|
---|
204 | if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) {
|
---|
205 | snd_card_free(card);
|
---|
206 | return err;
|
---|
207 | }
|
---|
208 | #ifdef ENABLE_SYNTH
|
---|
209 | if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
|
---|
210 | sizeof(snd_emu10k1_synth_arg_t), &wave) < 0 ||
|
---|
211 | wave == NULL) {
|
---|
212 | snd_printk("can't initialize Emu10k1 wavetable synth\n");
|
---|
213 | } else {
|
---|
214 | snd_emu10k1_synth_arg_t *arg;
|
---|
215 | arg = SNDRV_SEQ_DEVICE_ARGPTR(wave);
|
---|
216 | strcpy(wave->name, "Emu-10k1 Synth");
|
---|
217 | arg->hwptr = emu;
|
---|
218 | arg->index = 1;
|
---|
219 | arg->seq_ports = seq_ports[dev];
|
---|
220 | arg->max_voices = max_synth_voices[dev];
|
---|
221 | }
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | strcpy(card->driver, emu->card_capabilities->driver);
|
---|
225 | strcpy(card->shortname, emu->card_capabilities->name);
|
---|
226 | sprintf(card->longname, "%s (rev.%d) at 0x%lx, irq %i", card->shortname, emu->revision, emu->port, emu->irq);
|
---|
227 |
|
---|
228 | // DebugInt3();
|
---|
229 |
|
---|
230 | if ((err = snd_card_register(card)) < 0) {
|
---|
231 | snd_card_free(card);
|
---|
232 | return err;
|
---|
233 | }
|
---|
234 | pci_set_drvdata(pci, card);
|
---|
235 | dev++;
|
---|
236 | return 0;
|
---|
237 | }
|
---|
238 |
|
---|
239 | static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci)
|
---|
240 | {
|
---|
241 | snd_card_free(pci_get_drvdata(pci));
|
---|
242 | pci_set_drvdata(pci, NULL);
|
---|
243 | }
|
---|
244 |
|
---|
245 | #ifdef TARGET_OS2
|
---|
246 | static struct pci_driver driver = {
|
---|
247 | 0, 0, 0,
|
---|
248 | /* name: */ "EMU10K1/Audigy",
|
---|
249 | /* id_table:*/ snd_emu10k1_ids,
|
---|
250 | /* probe: */ snd_card_emu10k1_probe,
|
---|
251 | /* remove: */ snd_card_emu10k1_remove,
|
---|
252 | 0, 0
|
---|
253 | };
|
---|
254 | #else
|
---|
255 | static struct pci_driver driver = {
|
---|
256 | name: "EMU10K1/Audigy",
|
---|
257 | id_table: snd_emu10k1_ids,
|
---|
258 | probe: snd_card_emu10k1_probe,
|
---|
259 | remove: __devexit_p(snd_card_emu10k1_remove),
|
---|
260 | };
|
---|
261 | #endif
|
---|
262 |
|
---|
263 | static int __init alsa_card_emu10k1_init(void)
|
---|
264 | {
|
---|
265 | int err;
|
---|
266 |
|
---|
267 | if ((err = pci_module_init(&driver)) < 0) {
|
---|
268 | #ifdef MODULE
|
---|
269 | // printk(KERN_ERR "EMU10K1/Audigy soundcard not found or device busy\n");
|
---|
270 | #endif
|
---|
271 | return err;
|
---|
272 | }
|
---|
273 | return 0;
|
---|
274 | }
|
---|
275 |
|
---|
276 | static void __exit alsa_card_emu10k1_exit(void)
|
---|
277 | {
|
---|
278 | pci_unregister_driver(&driver);
|
---|
279 | }
|
---|
280 |
|
---|
281 | module_init(alsa_card_emu10k1_init)
|
---|
282 | module_exit(alsa_card_emu10k1_exit)
|
---|
283 |
|
---|
284 | #ifndef MODULE
|
---|
285 |
|
---|
286 | /* format is: snd-emu10k1=enable,index,id,
|
---|
287 | seq_ports,max_synth_voices */
|
---|
288 |
|
---|
289 | static int __init alsa_card_emu10k1_setup(char *str)
|
---|
290 | {
|
---|
291 | static unsigned __initdata nr_dev = 0;
|
---|
292 |
|
---|
293 | if (nr_dev >= SNDRV_CARDS)
|
---|
294 | return 0;
|
---|
295 | (void)(get_option(&str,&enable[nr_dev]) == 2 &&
|
---|
296 | get_option(&str,&index[nr_dev]) == 2 &&
|
---|
297 | get_id(&str,&id[nr_dev]) == 2 &&
|
---|
298 | get_option(&str,&seq_ports[nr_dev]) == 2 &&
|
---|
299 | get_option(&str,&max_synth_voices[nr_dev]) == 2);
|
---|
300 | nr_dev++;
|
---|
301 | return 1;
|
---|
302 | }
|
---|
303 |
|
---|
304 | __setup("snd-emu10k1=", alsa_card_emu10k1_setup);
|
---|
305 |
|
---|
306 | #endif /* ifndef MODULE */
|
---|