1 /* 2 * sound/configure.c - Configuration program for the Linux Sound Driver 3 * 4 * Copyright by Hannu Savolainen 1993 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 2. 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27
28 #include <stdio.h>
29
30 #defineB(x) (1 << (x))
31
32 /* 33 * Option numbers 34 */ 35
36 #defineOPT_PAS 0
37 #defineOPT_SB 1
38 #defineOPT_ADLIB 2
39 #defineOPT_LAST_MUTUAL 2
40
41 #defineOPT_GUS 3
42 #defineOPT_MPU401 4
43
44 #defineOPT_HIGHLEVEL 5
45 #defineOPT_SBPRO 5
46 #defineOPT_SB16 6
47 #defineOPT_AUDIO 7
48 #define OPT_MIDI_AUTO 8
49 #defineOPT_MIDI 9
50 #defineOPT_YM3812_AUTO 10 /* Select this automaticly if user selects 51 * MIDI or AdLib driver */ 52 #defineOPT_YM3812 11 /* Select this if the previous one was not 53 * selected */ 54 #defineOPT_SEQUENCER 12
55 #define OPT_CHIP_MIDI 13 /* New support added at UW - Milwauklee UW - 56 * Milwauklee */ 57 #defineOPT_LAST 12
58
59 #defineANY_DEVS (B(OPT_AUDIO)|B(OPT_MIDI)|B(OPT_SEQUENCER)|B(OPT_GUS)|B(OPT_MPU401))
60
61 typedefstruct 62 { 63 unsignedlongconditions;
64 unsignedlongexclusive_options;
65 charmacro[20];
66 intverify;
67 intalias;
68 intdefault_answ;
69 } 70
71 hw_entry;
72
73
74 /* 75 * The rule table for the driver options. The first field defines a set of 76 * options which must be selected before this entry can be selected. The 77 * second field is a set of options which are not allowed with this one. If 78 * the fourth field is zero, the option is selected without asking 79 * confirmation from the user. 80 * 81 * With this version of the rule table it is possible to select just one type of 82 * hardware. 83 * 84 * NOTE! Keep the following table and the questions array in sync with the 85 * option numbering! 86 */ 87
88 hw_entryhw_table[] =
89 { 90 /* 0 */ 91 {0, 0, "PAS", 1, 0, 0},
92 {0, 0, "SB", 1, 0, 0},
93 {0, B (OPT_PAS) | B (OPT_SB), "ADLIB", 1, 0, 0},
94
95 /* 3 */ 96 {0, 0, "GUS", 1, 0, 0},
97 {0, 0, "MPU401", 1, 0, 0},
98 {B (OPT_SB), B (OPT_PAS), "SBPRO", 1, 0, 1},
99 {B (OPT_SB) | B (OPT_SBPRO), B (OPT_PAS), "SB16", 1, 0, 1},
100 {B (OPT_SB) | B (OPT_PAS) | B (OPT_GUS), 0, "AUDIO", 1, 0, 1},
101 {B (OPT_MPU401), 0, "MIDI_AUTO", 0, OPT_MIDI, 0},
102 {B (OPT_SB) | B (OPT_PAS) | B (OPT_MPU401) | B (OPT_GUS), 0, "MIDI", 1, 0, 1},
103 {B (OPT_ADLIB), 0, "YM3812_AUTO", 0, OPT_YM3812, 0},
104 {B (OPT_SB) | B (OPT_PAS) | B (OPT_ADLIB), B (OPT_YM3812_AUTO), "YM3812", 1, 0, 1},
105 /* 10 */ 106 {B (OPT_MIDI) | B (OPT_YM3812) | B (OPT_YM3812_AUTO) | B (OPT_GUS), 0, "SEQUENCER", 0, 0, 1},
107 {0, 0, "CHIP_MIDI", 1, 0, 0} 108 };
109
110 char *questions[] =
111 { 112 "ProAudioSpectrum 16 support",
113 "SoundBlaster support",
114 "AdLib support",
115 "Gravis Ultrasound support",
116 "MPU-401 support (NOT for SB16)",
117
118 "SoundBlaster Pro support",
119 "SoundBlaster 16 support",
120 "digitized voice support",
121 "This should not be asked",
122 "MIDI interface support",
123 "This should not be asked",
124 "FM synthesizer (YM3812/OPL-3) support",
125 "/dev/sequencer support",
126 "MIDI on CHIP support"
127 };
128
129 unsignedlongselected_options = 0;
130 intsb_dma = 0;
131
132 int 133 can_select_option (intnr)
/* */ 134 { 135 switch (nr)
136 { 137 case 0:
138 fprintf (stderr, "The SoundBlaster, AdLib and ProAudioSpectrum\n"
139 "cards cannot be installed at the same time\n");
140 fprintf (stderr, "\nSelect at most one of them:\n");
141 fprintf (stderr, " - ProAudioSpectrum 16\n");
142 fprintf (stderr, " - SoundBlaster / SB Pro\n");
143 fprintf (stderr, " (Could be selected with PAS16 also\n"
144 " since there is a SB emulation on it)\n");
145 fprintf (stderr, " - AdLib\n");
146 fprintf (stderr, "\nDon't enable SoundBlaster if you have GUS at 0x220!\n\n");
147 break;
148
149 caseOPT_LAST_MUTUAL + 1:
150 fprintf (stderr, "\nThe following cards should work with any other cards.\n"
151 "CAUTION! Don't enable MPU-401 if you don't have it.\n");
152 break;
153
154 caseOPT_HIGHLEVEL:
155 fprintf (stderr, "\nSelect one or more of the following options\n");
156 break;
157
158
159 } 160
161 if (hw_table[nr].conditions)
162 if (!(hw_table[nr].conditions & selected_options))
163 return 0;
164
165 if (hw_table[nr].exclusive_options)
166 if (hw_table[nr].exclusive_options & selected_options)
167 return 0;
168
169 return 1;
170 } 171
172 int 173 think_positively (intdef_answ)
/* */ 174 { 175 charansw[512];
176 intlen;
177
178 if ((len = read (0, &answ, sizeof (answ))) < 1)
179 { 180 fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
181
182 perror ("stdin");
183 printf ("#undef CONFIGURE_SOUNDCARD\n");
184 printf ("#undef KERNEL_SOUNDCARD\n");
185 exit (-1);
186 } 187
188 if (len < 2) /* There is an additional LF at the end */ 189 returndef_answ;
190
191 answ[len - 1] = 0;
192
193 if (!strcmp (answ, "y") || !strcmp (answ, "Y"))
194 return 1;
195
196 return 0;
197 } 198
199 int 200 ask_value (char *format, intdefault_answer)
/* */ 201 { 202 charansw[512];
203 intlen, num;
204
205 play_it_again_Sam:
206
207 if ((len = read (0, &answ, sizeof (answ))) < 1)
208 { 209 fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
210
211 perror ("stdin");
212 printf ("#undef CONFIGURE_SOUNDCARD\n");
213 printf ("#undef KERNEL_SOUNDCARD\n");
214 exit (-1);
215 } 216
217 if (len < 2) /* There is an additional LF at the end */ 218 returndefault_answer;
219
220 answ[len - 1] = 0;
221
222 if (sscanf (answ, format, &num) != 1)
223 { 224 fprintf (stderr, "Illegal format. Try again: ");
225 gotoplay_it_again_Sam;
226 } 227
228 returnnum;
229 } 230
231 int 232 main (intargc, char *argv[])
/* */ 233 { 234 inti, num, def_size, full_driver = 1;
235 charansw[10];
236
237 printf ("/*\tGenerated by configure. Don't edit!!!!\t*/\n\n");
238
239 fprintf (stderr, "\nConfiguring the sound support\n\n");
240
241 fprintf (stderr, "Do you want to include full version of the sound driver (n/y) ? ");
242
243 if (think_positively (0))
244 { 245 selected_options = 0xffffffff & ~B (OPT_MPU401);
246 fprintf (stderr, "Note! MPU-401 driver was not enabled\n");
247 full_driver = 1;
248 } 249 else 250 { 251 fprintf (stderr, "Do you want to DISABLE the Sound Driver (n/y) ?");
252 if (think_positively (0))
253 { 254 printf ("#undef CONFIGURE_SOUNDCARD\n");
255 printf ("#undef KERNEL_SOUNDCARD\n");
256 exit (0);
257 } 258 /* Partial driver */ 259
260 full_driver = 0;
261
262 for (i = 0; i <= OPT_LAST; i++)
263 if (can_select_option (i))
264 { 265 if (!(selected_options & B (i))) /* Not selected yet */ 266 if (!hw_table[i].verify)
267 { 268 if (hw_table[i].alias)
269 selected_options |= B (hw_table[i].alias);
270 else 271 selected_options |= B (i);
272 } 273 else 274 { 275 intdef_answ = hw_table[i].default_answ;
276
277 fprintf (stderr,
278 def_answ ? " %s (y/n) ? " : " %s (n/y) ? ",
279 questions[i]);
280 if (think_positively (def_answ))
281 if (hw_table[i].alias)
282 selected_options |= B (hw_table[i].alias);
283 else 284 selected_options |= B (i);
285 } 286 } 287 } 288
289 if (selected_options & B (OPT_SB16))
290 selected_options |= B (OPT_SBPRO);
291
292 if (!(selected_options & ANY_DEVS))
293 { 294 printf ("#undef CONFIGURE_SOUNDCARD\n");
295 printf ("#undef KERNEL_SOUNDCARD\n");
296 fprintf (stderr, "\n*** This combination is useless. Sound driver disabled!!! ***\n\n");
297 exit (0);
298 } 299 else 300 printf ("#define KERNEL_SOUNDCARD\n");
301
302 for (i = 0; i <= OPT_LAST; i++)
303 if (!hw_table[i].alias)
304 if (selected_options & B (i))
305 printf ("#undef EXCLUDE_%s\n", hw_table[i].macro);
306 else 307 printf ("#define EXCLUDE_%s\n", hw_table[i].macro);
308
309
310 printf ("#define EXCLUDE_PRO_MIDI\n");
311 printf ("#define EXCLUDE_CHIP_MIDI\n");
312
313 /* 314 * IRQ and DMA settings 315 */ 316 printf ("\n");
317
318 #ifdefined(linux)
319 if (selected_options & B (OPT_SB) && selected_options & (B (OPT_AUDIO) | B (OPT_MIDI)))
320 { 321 fprintf (stderr, "\nIRQ number for SoundBlaster?\n"
322 "The IRQ address is defined by the jumpers on your card.\n"
323 "The factory default is either 5 or 7 (depending on the model).\n"
324 "Valid values are 9, 5, 7 and 10.\n"
325 "Enter the value: ");
326
327 num = ask_value ("%d", 7);
328 if (num != 9 && num != 5 && num != 7 && num != 10)
329 { 330
331 fprintf (stderr, "*** Illegal input! ***\n");
332 num = 7;
333 } 334 fprintf (stderr, "SoundBlaster IRQ set to %d\n", num);
335 printf ("#define SBC_BASE 0x220\n");
336 printf ("#define SBC_IRQ %d\n", num);
337
338 if (selected_options & (B (OPT_SBPRO) | B (OPT_PAS)))
339 { 340
341 fprintf (stderr, "\nDMA channel for SoundBlaster?\n"
342 "For SB 1.0, 1.5 and 2.0 this MUST be 1\n"
343 "SB Pro supports DMA channels 0, 1 and 3 (jumper)\n"
344 "For SB16 give the 8 bit DMA# here\n"
345 "The default value is 1\n"
346 "Enter the value: ");
347
348 num = ask_value ("%d", 1);
349 if (num < 0 || num > 3)
350 { 351
352 fprintf (stderr, "*** Illegal input! ***\n");
353 num = 1;
354 } 355 fprintf (stderr, "SoundBlaster DMA set to %d\n", num);
356 printf ("#define SBC_DMA %d\n", num);
357 sb_dma = num;
358 } 359
360 if (selected_options & B (OPT_SB16))
361 { 362
363 fprintf (stderr, "\n16 bit DMA channel for SoundBlaster 16?\n"
364 "Possible values are 5, 6 or 7\n"
365 "The default value is 6\n"
366 "Enter the value: ");
367
368 num = ask_value ("%d", 6);
369 if ((num < 5 || num > 7) && (num != sb_dma))
370 { 371
372 fprintf (stderr, "*** Illegal input! ***\n");
373 num = 6;
374 } 375 fprintf (stderr, "SoundBlaster DMA set to %d\n", num);
376 printf ("#define SB16_DMA %d\n", num);
377
378 fprintf (stderr, "\nI/O base for SB16 Midi?\n"
379 "Possible values are 300 and 330\n"
380 "The factory default is 330\n"
381 "Enter the SB16 Midi I/O base: ");
382
383 num = ask_value ("%x", 0x330);
384 fprintf (stderr, "SB16 Midi I/O base set to %03x\n", num);
385 printf ("#define SB16MIDI_BASE 0x%03x\n", num);
386 } 387 } 388
389 if (selected_options & B (OPT_PAS))
390 { 391 if (selected_options & (B (OPT_AUDIO) | B (OPT_MIDI)))
392 { 393 fprintf (stderr, "\nIRQ number for ProAudioSpectrum?\n"
394 "The recommended value is the IRQ used under DOS.\n"
395 "Please refer to the ProAudioSpectrum User's Guide.\n"
396 "The default value is 10.\n"
397 "Enter the value: ");
398
399 num = ask_value ("%d", 10);
400 if (num == 6 || num < 3 || num > 15 || num == 2) /* Illegal */ 401 { 402
403 fprintf (stderr, "*** Illegal input! ***\n");
404 num = 10;
405 } 406 fprintf (stderr, "ProAudioSpectrum IRQ set to %d\n", num);
407 printf ("#define PAS_IRQ %d\n", num);
408 } 409
410 if (selected_options & B (OPT_AUDIO))
411 { 412 fprintf (stderr, "\nDMA number for ProAudioSpectrum?\n"
413 "The recommended value is the DMA channel under DOS.\n"
414 "Please refer to the ProAudioSpectrum User's Guide.\n"
415 "The default value is 3\n"
416 "Enter the value: ");
417
418 num = ask_value ("%d", 3);
419 if (num == 4 || num < 0 || num > 7)
420 { 421
422 fprintf (stderr, "*** Illegal input! ***\n");
423 num = 3;
424 } 425 fprintf (stderr, "\nProAudioSpectrum DMA set to %d\n", num);
426 printf ("#define PAS_DMA %d\n", num);
427 } 428 } 429
430 if (selected_options & B (OPT_GUS))
431 { 432 fprintf (stderr, "\nI/O base for Gravis Ultrasound?\n"
433 "Valid choices are 210, 220, 230, 240, 250 or 260\n"
434 "The factory default is 220\n"
435 "Enter the GUS I/O base: ");
436
437 num = ask_value ("%x", 0x220);
438 if ((num > 0x260) || ((num & 0xf0f) != 0x200) || ((num & 0x0f0) > 0x060))
439 { 440
441 fprintf (stderr, "*** Illegal input! ***\n");
442 num = 0x220;
443 } 444
445 if ((selected_options & B (OPT_SB)) && (num == 0x220))
446 { 447 fprintf (stderr, "FATAL ERROR!!!!!!!!!!!!!!\n"
448 "\t0x220 cannot be used if SoundBlaster is enabled.\n"
449 "\tRun the config again.\n");
450 printf ("#undef CONFIGURE_SOUNDCARD\n");
451 printf ("#undef KERNEL_SOUNDCARD\n");
452 exit (-1);
453 } 454 fprintf (stderr, "GUS I/O base set to %03x\n", num);
455 printf ("#define GUS_BASE 0x%03x\n", num);
456
457 fprintf (stderr, "\nIRQ number for Gravis UltraSound?\n"
458 "The recommended value is the IRQ used under DOS.\n"
459 "Please refer to the Gravis Ultrasound User's Guide.\n"
460 "The default value is 15.\n"
461 "Enter the value: ");
462
463 num = ask_value ("%d", 15);
464 if (num == 6 || num < 3 || num > 15 || num == 2) /* Invalid */ 465 { 466
467 fprintf (stderr, "*** Illegal input! ***\n");
468 num = 15;
469 } 470 fprintf (stderr, "Gravis UltraSound IRQ set to %d\n", num);
471 printf ("#define GUS_IRQ %d\n", num);
472
473 fprintf (stderr, "\nDMA number for Gravis UltraSound?\n"
474 "The recommended value is the DMA channel under DOS.\n"
475 "Please refer to the Gravis Ultrasound User's Guide.\n"
476 "The default value is 6\n"
477 "Enter the value: ");
478
479 num = ask_value ("%d", 6);
480 if (num == 4 || num < 0 || num > 7)
481 { 482 fprintf (stderr, "*** Illegal input! ***\n");
483 num = 6;
484 } 485 fprintf (stderr, "\nGravis UltraSound DMA set to %d\n", num);
486 printf ("#define GUS_DMA %d\n", num);
487 } 488
489 if (selected_options & B (OPT_MPU401))
490 { 491 fprintf (stderr, "\nI/O base for MPU-401?\n"
492 "The factory default is 330\n"
493 "Enter the MPU-401 I/O base: ");
494
495 num = ask_value ("%x", 0x330);
496 fprintf (stderr, "MPU-401 I/O base set to %03x\n", num);
497 printf ("#define MPU_BASE 0x%03x\n", num);
498
499 fprintf (stderr, "\nIRQ number for MPU-401?\n"
500 "Valid numbers are: 3, 4, 5, 7 and 9(=2).\n"
501 "The default value is 5.\n"
502 "Enter the value: ");
503
504 num = ask_value ("%d", 5);
505 if (num == 6 || num < 3 || num > 15) /* Used for floppy */ 506 { 507
508 fprintf (stderr, "*** Illegal input! ***\n");
509 num = 5;
510 } 511 fprintf (stderr, "MPU-401 IRQ set to %d\n", num);
512 printf ("#define MPU_IRQ %d\n", num);
513 } 514 #endif 515
516 if (selected_options & B (OPT_AUDIO))
517 { 518 def_size = 16384;
519
520 if (selected_options & (B (OPT_SBPRO) | B (OPT_PAS) | B (OPT_SB16)))
521 def_size = 32768;
522
523 #ifndef__386BSD__ 524 if (((selected_options & B (OPT_PAS)) || (selected_options & B (OPT_SB16))) &&
525 !full_driver)
526 def_size = 65536; /* PAS16 or SB16 */ 527 #endif 528
529 fprintf (stderr, "\nSelect the DMA buffer size (4096, 16384, 32768 or 65536 bytes)\n"
530 "%d is recommended value for this configuration.\n"
531 "Enter the value: ", def_size);
532
533 num = ask_value ("%d", def_size);
534 if (num != 4096 && num != 16384 && num != 32768 && num != 65536)
535 { 536
537 fprintf (stderr, "*** Illegal input! ***\n");
538 num = def_size;
539 } 540 fprintf (stderr, "The DMA buffer size set to %d\n", num);
541 printf ("#define DSP_BUFFSIZE %d\n", num);
542 } 543
544 printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n", selected_options);
545 fprintf (stderr, "The sound driver is now configured.\n");
546
547 #ifdefined(SCO) || defined(ISC) || defined(SYSV)
548 fprintf (stderr, "Remember to update the System file\n");
549 #endif 550
551 exit (0);
552 }