This source file includes following definitions.
- can_select_option
- think_positively
- ask_value
- ask_int_choice
- rebuild_file
- use_old_config
- build_defines
- ask_parameters
- dump_script
- dump_fixed_local
- dump_fixed_defines
- main
- bin2hex
1
2
3
4
5 #define DISABLED_OPTIONS (B(OPT_PNP)|B(OPT_AEDSP16))
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #include <stdio.h>
35 #include <unistd.h>
36 #include <stdlib.h>
37
38 #define B(x) (1 << (x))
39
40
41
42
43
44 #define OPT_PAS 0
45 #define OPT_SB 1
46 #define OPT_ADLIB 2
47 #define OPT_LAST_MUTUAL 2
48
49 #define OPT_GUS 3
50 #define OPT_MPU401 4
51 #define OPT_UART6850 5
52 #define OPT_PSS 6
53 #define OPT_GUS16 7
54 #define OPT_GUSMAX 8
55 #define OPT_MSS 9
56 #define OPT_SSCAPE 10
57 #define OPT_TRIX 11
58 #define OPT_MAD16 12
59 #define OPT_CS4232 13
60 #define OPT_MAUI 14
61 #define OPT_PNP 15
62
63 #define OPT_HIGHLEVEL 16
64 #define OPT_SBPRO 16
65 #define OPT_SB16 17
66 #define OPT_AEDSP16 18
67 #define OPT_AUDIO 19
68 #define OPT_MIDI_AUTO 20
69 #define OPT_MIDI 21
70 #define OPT_YM3812_AUTO 22
71 #define OPT_YM3812 23
72 #define OPT_SEQUENCER 24
73 #define OPT_LAST 24
74
75 #define DUMMY_OPTS (B(OPT_MIDI_AUTO)|B(OPT_YM3812_AUTO))
76
77 #define ANY_DEVS (B(OPT_AUDIO)|B(OPT_MIDI)|B(OPT_SEQUENCER)|B(OPT_GUS)| \
78 B(OPT_MPU401)|B(OPT_PSS)|B(OPT_GUS16)|B(OPT_GUSMAX)| \
79 B(OPT_MSS)|B(OPT_SSCAPE)|B(OPT_UART6850)|B(OPT_TRIX)| \
80 B(OPT_MAD16)|B(OPT_CS4232)|B(OPT_MAUI))
81 #define AUDIO_CARDS (B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_GUS) | \
82 B (OPT_MSS) | B (OPT_GUS16) | B (OPT_GUSMAX) | B (OPT_TRIX) | \
83 B (OPT_SSCAPE)| B(OPT_MAD16) | B(OPT_CS4232))
84 #define MIDI_CARDS (B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_MPU401) | \
85 B (OPT_GUS) | B (OPT_TRIX) | B (OPT_SSCAPE)|B(OPT_MAD16) | \
86 B (OPT_CS4232)|B(OPT_MAUI))
87 #define MPU_DEVS (B(OPT_PSS)|B(OPT_SSCAPE)|B(OPT_TRIX)|B(OPT_MAD16)|\
88 B(OPT_CS4232)|B(OPT_PNP)|B(OPT_MAUI))
89 #define AD1848_DEVS (B(OPT_GUS16)|B(OPT_MSS)|B(OPT_PSS)|B(OPT_GUSMAX)|\
90 B(OPT_SSCAPE)|B(OPT_TRIX)|B(OPT_MAD16)|B(OPT_CS4232)|\
91 B(OPT_PNP))
92
93
94
95
96
97
98 typedef struct
99 {
100 unsigned long conditions;
101 unsigned long exclusive_options;
102 char macro[20];
103 int verify;
104 int alias;
105 int default_answ;
106 }
107
108 hw_entry;
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125 hw_entry hw_table[] =
126 {
127
128
129
130 {0, 0, "PAS", 1, 0, 0},
131 {0, 0, "SB", 1, 0, 0},
132 {0, B (OPT_PAS) | B (OPT_SB), "ADLIB", 1, 0, 0},
133
134 {0, 0, "GUS", 1, 0, 0},
135 {0, 0, "MPU401", 1, 0, 0},
136 {0, 0, "UART6850", 1, 0, 0},
137 {0, 0, "PSS", 1, 0, 0},
138 {B (OPT_GUS), 0, "GUS16", 1, 0, 0},
139 {B (OPT_GUS), B (OPT_GUS16), "GUSMAX", 1, 0, 0},
140 {0, 0, "MSS", 1, 0, 0},
141 {0, 0, "SSCAPE", 1, 0, 0},
142 {0, 0, "TRIX", 1, 0, 0},
143 {0, 0, "MAD16", 1, 0, 0},
144 {0, 0, "CS4232", 1, 0, 0},
145 {0, 0, "MAUI", 1, 0, 0},
146 {0, 0, "PNP", 1, 0, 0},
147
148 {B (OPT_SB), B (OPT_PAS), "SBPRO", 1, 0, 1},
149 {B (OPT_SB) | B (OPT_SBPRO), B (OPT_PAS), "SB16", 1, 0, 1},
150 {B (OPT_SBPRO) | B (OPT_MSS) | B (OPT_MPU401), 0, "AEDSP16", 1, 0, 0},
151 {AUDIO_CARDS, 0, "AUDIO", 1, 0, 1},
152 {B (OPT_MPU401) | B (OPT_MAUI), 0, "MIDI_AUTO", 0, OPT_MIDI, 0},
153 {MIDI_CARDS, 0, "MIDI", 1, 0, 1},
154 {B (OPT_ADLIB), 0, "YM3812_AUTO", 0, OPT_YM3812, 0},
155 {B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_ADLIB) | B (OPT_MSS) | B (OPT_PSS), B (OPT_YM3812_AUTO), "YM3812", 1, 0, 1},
156 {B (OPT_MIDI) | B (OPT_YM3812) | B (OPT_YM3812_AUTO) | B (OPT_GUS), 0, "SEQUENCER", 0, 0, 1}
157 };
158
159 char *questions[] =
160 {
161 "ProAudioSpectrum 16 support",
162 "SoundBlaster support",
163 "Generic OPL2/OPL3 FM synthesizer support",
164 "Gravis Ultrasound support",
165 "MPU-401 support (NOT for SB16)",
166 "6850 UART Midi support",
167 "PSS (ECHO-ADI2111) support",
168 "16 bit sampling option of GUS (_NOT_ GUS MAX)",
169 "GUS MAX support",
170 "Microsoft Sound System support",
171 "Ensoniq Soundscape support",
172 "MediaTriX AudioTriX Pro support",
173 "Support for MAD16 and/or Mozart based cards",
174 "Support for Crystal CS4232 based (PnP) cards",
175 "Support for Turtle Beach Wave Front (Maui, Tropez) synthesizers",
176 "Support for PnP soundcards (_EXPERIMENTAL_)",
177
178 "SoundBlaster Pro support",
179 "SoundBlaster 16 support",
180 "Audio Excel DSP 16 initialization support",
181 "/dev/dsp and /dev/audio supports (usually required)",
182 "This should not be asked",
183 "MIDI interface support",
184 "This should not be asked",
185 "FM synthesizer (YM3812/OPL-3) support",
186 "/dev/sequencer support",
187 "Is the sky really falling"
188 };
189
190 struct kludge
191 {
192 char *name;
193 int mask;
194 }
195 extra_options[] =
196 {
197 {
198 "MPU_EMU", MPU_DEVS
199 }
200 ,
201 {
202 "AD1848", AD1848_DEVS
203 }
204 ,
205 {
206 NULL, 0
207 }
208 };
209
210 char *oldconf = "/etc/soundconf";
211
212 int old_config_used = 0;
213 int def_size, sb_base = 0;
214
215 unsigned long selected_options = 0;
216 int sb_dma = 0;
217
218 int dump_only = 0;
219
220 void build_defines (void);
221
222 #include "hex2hex.h"
223 int bin2hex (char *path, char *target, char *varname);
224
225 int
226 can_select_option (int nr)
227 {
228
229 if (hw_table[nr].conditions)
230 if (!(hw_table[nr].conditions & selected_options))
231 return 0;
232
233 if (hw_table[nr].exclusive_options)
234 if (hw_table[nr].exclusive_options & selected_options)
235 return 0;
236
237 if (DISABLED_OPTIONS & B (nr))
238 return 0;
239
240 return 1;
241 }
242
243 int
244 think_positively (int def_answ)
245 {
246 char answ[512];
247 int len;
248
249 if ((len = read (0, answ, sizeof (answ))) < 1)
250 {
251 fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
252
253 perror ("stdin");
254 printf ("invalid_configuration__run_make_config_again\n");
255 exit (-1);
256 }
257
258 if (len < 2)
259
260
261 return def_answ;
262
263 answ[len - 1] = 0;
264
265 if (!strcmp (answ, "y") || !strcmp (answ, "Y"))
266 return 1;
267
268 return 0;
269 }
270
271 int
272 ask_value (char *format, int default_answer)
273 {
274 char answ[512];
275 int len, num;
276
277 play_it_again_Sam:
278
279 if ((len = read (0, answ, sizeof (answ))) < 1)
280 {
281 fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
282
283 perror ("stdin");
284 printf ("invalid_configuration__run_make_config_again\n");
285 exit (-1);
286 }
287
288 if (len < 2)
289
290
291 return default_answer;
292
293 answ[len - 1] = 0;
294
295 if (sscanf (answ, format, &num) != 1)
296 {
297 fprintf (stderr, "Illegal format. Try again: ");
298 goto play_it_again_Sam;
299 }
300
301 return num;
302 }
303
304 #define FMT_HEX 1
305 #define FMT_INT 2
306
307 void
308 ask_int_choice (int mask, char *macro,
309 char *question,
310 int format,
311 int defa,
312 char *choices)
313 {
314 int num, i;
315
316 if (dump_only)
317 {
318
319 for (i = 0; i < OPT_LAST; i++)
320 if (mask == B (i))
321 {
322 int j;
323
324 for (j = 0; j < strlen (choices); j++)
325 if (choices[j] == '\'')
326 choices[j] = '_';
327
328 printf ("\nif [ \"$CONFIG_%s\" = \"y\" ]; then\n",
329 hw_table[i].macro);
330 if (format == FMT_INT)
331 printf ("int '%s %s' %s %d\n", question, choices, macro, defa);
332 else
333 printf ("hex '%s %s' %s %x\n", question, choices, macro, defa);
334 printf ("fi\n");
335 }
336 }
337 else
338 {
339 if (!(mask & selected_options))
340 return;
341
342 fprintf (stderr, "\n%s\n", question);
343 fprintf (stderr, "Possible values are: %s\n", choices);
344
345 if (format == FMT_INT)
346 {
347 if (defa == -1)
348 fprintf (stderr, "\t(-1 disables this feature)\n");
349 fprintf (stderr, "The default value is %d\n", defa);
350 fprintf (stderr, "Enter the value: ");
351 num = ask_value ("%d", defa);
352 if (num == -1)
353 return;
354 fprintf (stderr, "%s set to %d.\n", question, num);
355 printf ("#define %s %d\n", macro, num);
356 }
357 else
358 {
359 if (defa == 0)
360 fprintf (stderr, "\t(0 disables this feature)\n");
361 fprintf (stderr, "The default value is %x\n", defa);
362 fprintf (stderr, "Enter the value: ");
363 num = ask_value ("%x", defa);
364 if (num == 0)
365 return;
366 fprintf (stderr, "%s set to %x.\n", question, num);
367 printf ("#define %s 0x%x\n", macro, num);
368 }
369 }
370 }
371
372 void
373 rebuild_file (char *line)
374 {
375 char *method, *new, *old, *var, *p;
376
377 method = p = line;
378
379 while (*p && *p != ' ')
380 p++;
381 *p++ = 0;
382
383 old = p;
384 while (*p && *p != ' ')
385 p++;
386 *p++ = 0;
387
388 new = p;
389 while (*p && *p != ' ')
390 p++;
391 *p++ = 0;
392
393 var = p;
394 while (*p && *p != ' ')
395 p++;
396 *p++ = 0;
397
398 fprintf (stderr, "Rebuilding file %s (%s %s)\n", new, method, old);
399
400 if (strcmp (method, "bin2hex") == 0)
401 {
402 if (!bin2hex (old, new, var))
403 {
404 fprintf (stderr, "Rebuild failed\n");
405 exit (-1);
406 }
407 }
408 else if (strcmp (method, "hex2hex") == 0)
409 {
410 if (!hex2hex (old, new, var))
411 {
412 fprintf (stderr, "Rebuild failed\n");
413 exit (-1);
414 }
415 }
416 else
417 {
418 fprintf (stderr, "Failed to build '%s' - unknown method %s\n",
419 new, method);
420 exit (-1);
421 }
422 }
423
424 int
425 use_old_config (char *filename)
426 {
427 char buf[1024];
428 int i = 0;
429
430 FILE *oldf;
431
432 fprintf (stderr, "Copying old configuration from %s\n", filename);
433
434 if ((oldf = fopen (filename, "r")) == NULL)
435 {
436 fprintf (stderr, "Couldn't open previous configuration file\n");
437 perror (filename);
438 return 0;
439 }
440
441 while (fgets (buf, 1024, oldf) != NULL)
442 {
443 char tmp[100];
444
445 if (buf[0] != '#')
446 {
447 printf ("%s", buf);
448
449 strncpy (tmp, buf, 8);
450 tmp[8] = 0;
451
452 if (strcmp (tmp, "/*build ") == 0)
453 rebuild_file (&buf[8]);
454
455 continue;
456 }
457
458 strncpy (tmp, buf, 8);
459 tmp[8] = 0;
460
461 if (strcmp (tmp, "#define ") == 0)
462 {
463 char *id = &buf[8];
464
465 i = 0;
466 while (id[i] && id[i] != ' ' &&
467 id[i] != '\t' && id[i] != '\n')
468 i++;
469
470 strncpy (tmp, id, i);
471 tmp[i] = 0;
472
473 if (strcmp (tmp, "SELECTED_SOUND_OPTIONS") == 0)
474 continue;
475
476 if (strcmp (tmp, "KERNEL_SOUNDCARD") == 0)
477 continue;
478
479 tmp[8] = 0;
480 if (strcmp (tmp, "EXCLUDE_") == 0)
481 continue;
482
483 strncpy (tmp, id, i);
484 tmp[7] = 0;
485
486 if (strcmp (tmp, "CONFIG_") == 0)
487 {
488 strncpy (tmp, &id[7], i - 7);
489 tmp[i - 7] = 0;
490
491 for (i = 0; i <= OPT_LAST; i++)
492 if (strcmp (hw_table[i].macro, tmp) == 0)
493 {
494 selected_options |= (1 << i);
495 break;
496 }
497 continue;
498 }
499
500 printf ("%s", buf);
501 continue;
502 }
503
504 if (strcmp (tmp, "#undef ") == 0)
505 {
506 char *id = &buf[8];
507
508 i = 0;
509 while (id[i] && id[i] != ' ' &&
510 id[i] != '\t' && id[i] != '\n')
511 i++;
512
513 strncpy (tmp, id, i);
514 tmp[7] = 0;
515 if (strcmp (tmp, "CONFIG_") == 0)
516 continue;
517
518 strncpy (tmp, id, i);
519
520 tmp[8] = 0;
521 if (strcmp (tmp, "EXCLUDE_") != 0)
522 continue;
523 strncpy (tmp, &id[8], i - 8);
524 tmp[i - 8] = 0;
525
526 for (i = 0; i <= OPT_LAST; i++)
527 if (strcmp (hw_table[i].macro, tmp) == 0)
528 {
529 selected_options |= (1 << i);
530 break;
531 }
532 continue;
533 }
534
535 printf ("%s", buf);
536 }
537 fclose (oldf);
538
539 for (i = 0; i <= OPT_LAST; i++)
540 if (!hw_table[i].alias)
541 if (selected_options & B (i))
542 printf ("#define CONFIG_%s\n", hw_table[i].macro);
543 else
544 printf ("#undef CONFIG_%s\n", hw_table[i].macro);
545
546
547 printf ("\n");
548
549 i = 0;
550
551 while (extra_options[i].name != NULL)
552 {
553 if (selected_options & extra_options[i].mask)
554 printf ("#define CONFIG_%s\n", extra_options[i].name);
555 else
556 printf ("#undef CONFIG_%s\n", extra_options[i].name);
557 i++;
558 }
559
560 printf ("\n");
561
562 printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n", selected_options);
563 fprintf (stderr, "Old configuration copied.\n");
564
565 build_defines ();
566 old_config_used = 1;
567 return 1;
568 }
569
570 void
571 build_defines (void)
572 {
573 FILE *optf;
574 int i;
575
576 if ((optf = fopen (".defines", "w")) == NULL)
577 {
578 perror (".defines");
579 exit (-1);
580 }
581
582
583 for (i = 0; i <= OPT_LAST; i++)
584 if (!hw_table[i].alias)
585 if (selected_options & B (i))
586 fprintf (optf, "CONFIG_%s=y\n", hw_table[i].macro);
587
588
589 fprintf (optf, "\n");
590
591 i = 0;
592
593 while (extra_options[i].name != NULL)
594 {
595 if (selected_options & extra_options[i].mask)
596 fprintf (optf, "CONFIG_%s=y\n", extra_options[i].name);
597 i++;
598 }
599
600 fprintf (optf, "\n");
601 fclose (optf);
602 }
603
604 void
605 ask_parameters (void)
606 {
607 int num;
608
609 build_defines ();
610
611
612
613
614 ask_int_choice (B (OPT_AEDSP16), "AEDSP16_BASE",
615 "I/O base for Audio Excel DSP 16",
616 FMT_HEX,
617 0x220,
618 "220 or 240");
619
620 ask_int_choice (B (OPT_SB), "SBC_BASE",
621 "I/O base for SB",
622 FMT_HEX,
623 0x220,
624 "");
625
626 ask_int_choice (B (OPT_SB), "SBC_IRQ",
627 "SoundBlaster IRQ",
628 FMT_INT,
629 7,
630 "");
631
632 ask_int_choice (B (OPT_SB), "SBC_DMA",
633 "SoundBlaster DMA",
634 FMT_INT,
635 1,
636 "");
637
638 ask_int_choice (B (OPT_SB), "SB_DMA2",
639 "SoundBlaster 16 bit DMA (if required)",
640 FMT_INT,
641 -1,
642 "5, 6 or 7");
643
644 ask_int_choice (B (OPT_SB), "SB_MPU_BASE",
645 "MPU401 I/O base of SB16, Jazz16 and ES1688",
646 FMT_HEX,
647 0,
648 "");
649
650 ask_int_choice (B (OPT_SB), "SB_MPU_IRQ",
651 "SB MPU401 IRQ (SB16, Jazz16 and ES1688)",
652 FMT_INT,
653 -1,
654 "");
655
656 ask_int_choice (B (OPT_PAS), "PAS_IRQ",
657 "PAS16 IRQ",
658 FMT_INT,
659 10,
660 "");
661
662 ask_int_choice (B (OPT_PAS), "PAS_DMA",
663 "PAS16 DMA",
664 FMT_INT,
665 3,
666 "");
667
668 if (selected_options & B (OPT_PAS))
669 {
670 fprintf (stderr, "\nEnable Joystick port on ProAudioSpectrum (y/N) ? ");
671 if (think_positively (0))
672 printf ("#define PAS_JOYSTICK_ENABLE\n");
673
674
675 fprintf (stderr, "PAS16 could be noisy with some mother boards\n"
676 "There is a command line switch (was it :T?)\n"
677 "in the DOS driver for PAS16 which solves this.\n"
678 "Don't enable this feature unless you have problems!\n"
679 "Do you have to use this switch with DOS (Y/n) ?");
680 if (think_positively (0))
681 printf ("#define BROKEN_BUS_CLOCK\n");
682 }
683
684
685 ask_int_choice (B (OPT_GUS), "GUS_BASE",
686 "I/O base for GUS",
687 FMT_HEX,
688 0x220,
689 "210, 220, 230, 240, 250 or 260");
690
691
692 ask_int_choice (B (OPT_GUS), "GUS_IRQ",
693 "GUS IRQ",
694 FMT_INT,
695 15,
696 "");
697
698 ask_int_choice (B (OPT_GUS), "GUS_DMA",
699 "GUS DMA",
700 FMT_INT,
701 6,
702 "");
703
704 ask_int_choice (B (OPT_GUS), "GUS_DMA2",
705 "Second DMA channel for GUS",
706 FMT_INT,
707 -1,
708 "");
709
710 ask_int_choice (B (OPT_GUS16), "GUS16_BASE",
711 "I/O base for the 16 bit daughtercard of GUS",
712 FMT_HEX,
713 0x530,
714 "530, 604, E80 or F40");
715
716
717 ask_int_choice (B (OPT_GUS16), "GUS16_IRQ",
718 "GUS 16 bit daughtercard IRQ",
719 FMT_INT,
720 7,
721 "3, 4, 5, 7, or 9");
722
723 ask_int_choice (B (OPT_GUS16), "GUS16_DMA",
724 "GUS DMA",
725 FMT_INT,
726 3,
727 "0, 1 or 3");
728
729 ask_int_choice (B (OPT_MPU401), "MPU_BASE",
730 "I/O base for MPU401",
731 FMT_HEX,
732 0x330,
733 "");
734
735 ask_int_choice (B (OPT_MPU401), "MPU_IRQ",
736 "MPU401 IRQ",
737 FMT_INT,
738 9,
739 "");
740
741 ask_int_choice (B (OPT_MAUI), "MAUI_BASE",
742 "I/O base for Maui",
743 FMT_HEX,
744 0x330,
745 "210, 230, 260, 290, 300, 320, 338 or 330");
746
747 ask_int_choice (B (OPT_MAUI), "MAUI_IRQ",
748 "Maui IRQ",
749 FMT_INT,
750 9,
751 "5, 9, 12 or 15");
752
753 ask_int_choice (B (OPT_UART6850), "U6850_BASE",
754 "I/O base for UART 6850 MIDI port",
755 FMT_HEX,
756 0,
757 "(Unknown)");
758
759 ask_int_choice (B (OPT_UART6850), "U6850_IRQ",
760 "UART6850 IRQ",
761 FMT_INT,
762 -1,
763 "(Unknown)");
764
765 ask_int_choice (B (OPT_PSS), "PSS_BASE",
766 "PSS I/O base",
767 FMT_HEX,
768 0x220,
769 "220 or 240");
770
771 ask_int_choice (B (OPT_PSS), "PSS_MSS_BASE",
772 "PSS audio I/O base",
773 FMT_HEX,
774 0x530,
775 "530, 604, E80 or F40");
776
777 ask_int_choice (B (OPT_PSS), "PSS_MSS_IRQ",
778 "PSS audio IRQ",
779 FMT_INT,
780 11,
781 "7, 9, 10 or 11");
782
783 ask_int_choice (B (OPT_PSS), "PSS_MSS_DMA",
784 "PSS audio DMA",
785 FMT_INT,
786 3,
787 "0, 1 or 3");
788
789 ask_int_choice (B (OPT_PSS), "PSS_MPU_BASE",
790 "PSS MIDI I/O base",
791 FMT_HEX,
792 0x330,
793 "");
794
795 ask_int_choice (B (OPT_PSS), "PSS_MPU_IRQ",
796 "PSS MIDI IRQ",
797 FMT_INT,
798 9,
799 "3, 4, 5, 7 or 9");
800
801 ask_int_choice (B (OPT_MSS), "MSS_BASE",
802 "MSS/WSS I/O base",
803 FMT_HEX,
804 0x530,
805 "530, 604, E80 or F40");
806
807 ask_int_choice (B (OPT_MSS), "MSS_IRQ",
808 "MSS/WSS IRQ",
809 FMT_INT,
810 11,
811 "7, 9, 10 or 11");
812
813 ask_int_choice (B (OPT_MSS), "MSS_DMA",
814 "MSS/WSS DMA",
815 FMT_INT,
816 3,
817 "0, 1 or 3");
818
819 ask_int_choice (B (OPT_SSCAPE), "SSCAPE_BASE",
820 "Soundscape MIDI I/O base",
821 FMT_HEX,
822 0x330,
823 "");
824
825 ask_int_choice (B (OPT_SSCAPE), "SSCAPE_IRQ",
826 "Soundscape MIDI IRQ",
827 FMT_INT,
828 9,
829 "");
830
831 ask_int_choice (B (OPT_SSCAPE), "SSCAPE_DMA",
832 "Soundscape initialization DMA",
833 FMT_INT,
834 3,
835 "0, 1 or 3");
836
837 ask_int_choice (B (OPT_SSCAPE), "SSCAPE_MSS_BASE",
838 "Soundscape audio I/O base",
839 FMT_HEX,
840 0x534,
841 "534, 608, E84 or F44");
842
843 ask_int_choice (B (OPT_SSCAPE), "SSCAPE_MSS_IRQ",
844 "Soundscape audio IRQ",
845 FMT_INT,
846 11,
847 "7, 9, 10 or 11");
848
849 ask_int_choice (B (OPT_SSCAPE), "SSCAPE_MSS_DMA",
850 "Soundscape audio DMA",
851 FMT_INT,
852 0,
853 "0, 1 or 3");
854
855 if (selected_options & B (OPT_SSCAPE))
856 {
857 int reveal_spea;
858
859 fprintf (stderr, "Is your SoundScape card made/marketed by Reveal or Spea? ");
860 reveal_spea = think_positively (0);
861 if (reveal_spea)
862 printf ("#define REVEAL_SPEA\n");
863
864 }
865
866 ask_int_choice (B (OPT_TRIX), "TRIX_BASE",
867 "AudioTriX audio I/O base",
868 FMT_HEX,
869 0x530,
870 "530, 604, E80 or F40");
871
872 ask_int_choice (B (OPT_TRIX), "TRIX_IRQ",
873 "AudioTriX audio IRQ",
874 FMT_INT,
875 11,
876 "7, 9, 10 or 11");
877
878 ask_int_choice (B (OPT_TRIX), "TRIX_DMA",
879 "AudioTriX audio DMA",
880 FMT_INT,
881 0,
882 "0, 1 or 3");
883
884 ask_int_choice (B (OPT_TRIX), "TRIX_DMA2",
885 "AudioTriX second (duplex) DMA",
886 FMT_INT,
887 3,
888 "0, 1 or 3");
889
890 ask_int_choice (B (OPT_TRIX), "TRIX_MPU_BASE",
891 "AudioTriX MIDI I/O base",
892 FMT_HEX,
893 0x330,
894 "330, 370, 3B0 or 3F0");
895
896 ask_int_choice (B (OPT_TRIX), "TRIX_MPU_IRQ",
897 "AudioTriX MIDI IRQ",
898 FMT_INT,
899 9,
900 "3, 4, 5, 7 or 9");
901
902 ask_int_choice (B (OPT_TRIX), "TRIX_SB_BASE",
903 "AudioTriX SB I/O base",
904 FMT_HEX,
905 0x220,
906 "220, 210, 230, 240, 250, 260 or 270");
907
908 ask_int_choice (B (OPT_TRIX), "TRIX_SB_IRQ",
909 "AudioTriX SB IRQ",
910 FMT_INT,
911 7,
912 "3, 4, 5 or 7");
913
914 ask_int_choice (B (OPT_TRIX), "TRIX_SB_DMA",
915 "AudioTriX SB DMA",
916 FMT_INT,
917 1,
918 "1 or 3");
919
920 ask_int_choice (B (OPT_CS4232), "CS4232_BASE",
921 "CS4232 audio I/O base",
922 FMT_HEX,
923 0x530,
924 "530, 604, E80 or F40");
925
926 ask_int_choice (B (OPT_CS4232), "CS4232_IRQ",
927 "CS4232 audio IRQ",
928 FMT_INT,
929 11,
930 "5, 7, 9, 11, 12 or 15");
931
932 ask_int_choice (B (OPT_CS4232), "CS4232_DMA",
933 "CS4232 audio DMA",
934 FMT_INT,
935 0,
936 "0, 1 or 3");
937
938 ask_int_choice (B (OPT_CS4232), "CS4232_DMA2",
939 "CS4232 second (duplex) DMA",
940 FMT_INT,
941 3,
942 "0, 1 or 3");
943
944 ask_int_choice (B (OPT_CS4232), "CS4232_MPU_BASE",
945 "CS4232 MIDI I/O base",
946 FMT_HEX,
947 0x330,
948 "330, 370, 3B0 or 3F0");
949
950 ask_int_choice (B (OPT_CS4232), "CS4232_MPU_IRQ",
951 "CS4232 MIDI IRQ",
952 FMT_INT,
953 9,
954 "5, 7, 9, 11, 12 or 15");
955
956 ask_int_choice (B (OPT_MAD16), "MAD16_BASE",
957 "MAD16 audio I/O base",
958 FMT_HEX,
959 0x530,
960 "530, 604, E80 or F40");
961
962 ask_int_choice (B (OPT_MAD16), "MAD16_IRQ",
963 "MAD16 audio IRQ",
964 FMT_INT,
965 11,
966 "7, 9, 10 or 11");
967
968 ask_int_choice (B (OPT_MAD16), "MAD16_DMA",
969 "MAD16 audio DMA",
970 FMT_INT,
971 3,
972 "0, 1 or 3");
973
974 ask_int_choice (B (OPT_MAD16), "MAD16_DMA2",
975 "MAD16 second (duplex) DMA",
976 FMT_INT,
977 0,
978 "0, 1 or 3");
979
980 ask_int_choice (B (OPT_MAD16), "MAD16_MPU_BASE",
981 "MAD16 MIDI I/O base",
982 FMT_HEX,
983 0x330,
984 "300, 310, 320 or 330 (0 disables)");
985
986 ask_int_choice (B (OPT_MAD16), "MAD16_MPU_IRQ",
987 "MAD16 MIDI IRQ",
988 FMT_INT,
989 9,
990 "5, 7, 9 or 10");
991 ask_int_choice (B (OPT_AUDIO), "DSP_BUFFSIZE",
992 "Audio DMA buffer size",
993 FMT_INT,
994 65536,
995 "4096, 16384, 32768 or 65536");
996 }
997
998 void
999 dump_script (void)
1000 {
1001 int i;
1002
1003 for (i = 0; i <= OPT_LAST; i++)
1004 if (!(DUMMY_OPTS & B (i)))
1005 if (!(DISABLED_OPTIONS & B (i)))
1006 {
1007 printf ("bool '%s' CONFIG_%s\n", questions[i], hw_table[i].macro);
1008 }
1009
1010 dump_only = 1;
1011 selected_options = 0;
1012 ask_parameters ();
1013
1014 printf ("#\n$MAKE -C drivers/sound kernelconfig || exit 1\n");
1015 }
1016
1017 void
1018 dump_fixed_local (void)
1019 {
1020 int i = 0;
1021
1022 printf ("/* Computer generated file. Please don't edit! */\n\n");
1023 printf ("#define KERNEL_COMPATIBLE_CONFIG\n\n");
1024 printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n\n", selected_options);
1025
1026 while (extra_options[i].name != NULL)
1027 {
1028 int n = 0, j;
1029
1030 printf ("#if ");
1031
1032 for (j = 0; j < OPT_LAST; j++)
1033 if (!(DISABLED_OPTIONS & B (j)))
1034 if (extra_options[i].mask & B (j))
1035 {
1036 if (n)
1037 printf (" || ");
1038 if (!(n++ % 2))
1039 printf ("\\\n ");
1040
1041 printf ("defined(CONFIG_%s)", hw_table[j].macro);
1042 }
1043
1044 printf ("\n");
1045 printf ("#\tdefine CONFIG_%s\n", extra_options[i].name);
1046 printf ("#endif\n\n");
1047 i++;
1048 }
1049 }
1050
1051 void
1052 dump_fixed_defines (void)
1053 {
1054 int i = 0;
1055
1056 printf ("# Computer generated file. Please don't edit\n\n");
1057
1058 while (extra_options[i].name != NULL)
1059 {
1060 int n = 0, j;
1061
1062 for (j = 0; j < OPT_LAST; j++)
1063 if (!(DISABLED_OPTIONS & B (j)))
1064 if (extra_options[i].mask & B (j))
1065 {
1066 printf ("ifdef CONFIG_%s\n", hw_table[j].macro);
1067 printf ("CONFIG_%s=y\n", extra_options[i].name);
1068 printf ("endif\n\n");
1069 }
1070
1071 i++;
1072 }
1073 }
1074
1075 int
1076 main (int argc, char *argv[])
1077 {
1078 int i, num, full_driver = 1;
1079 char answ[10];
1080 char old_config_file[200];
1081
1082 if (getuid () != 0)
1083 {
1084 char *home;
1085
1086 if ((home = getenv ("HOME")) != NULL)
1087 {
1088 sprintf (old_config_file, "%s/.soundconf", home);
1089 oldconf = old_config_file;
1090 }
1091 }
1092
1093 if (argc > 1)
1094 {
1095 if (strcmp (argv[1], "-o") == 0 &&
1096 use_old_config (oldconf))
1097 exit (0);
1098 else if (strcmp (argv[1], "script") == 0)
1099 {
1100 dump_script ();
1101 exit (0);
1102 }
1103 else if (strcmp (argv[1], "fixedlocal") == 0)
1104 {
1105 dump_fixed_local ();
1106 exit (0);
1107 }
1108 else if (strcmp (argv[1], "fixeddefines") == 0)
1109 {
1110 dump_fixed_defines ();
1111 exit (0);
1112 }
1113 }
1114
1115 fprintf (stderr, "\nConfiguring the sound support\n\n");
1116
1117 if (access (oldconf, R_OK) == 0)
1118 {
1119 fprintf (stderr, "Old configuration exists in %s. Use it (Y/n) ? ",
1120 oldconf);
1121 if (think_positively (1))
1122 if (use_old_config (oldconf))
1123 exit (0);
1124
1125 }
1126
1127 printf ("/*\tGenerated by configure. Don't edit!!!!\t*/\n");
1128 printf ("/*\tMaking changes to this file is not as simple as it may look.\t*/\n\n");
1129 printf ("/*\tIf you change the CONFIG_ settings in local.h you\t*/\n");
1130 printf ("/*\t_have_ to edit .defines too.\t*/\n\n");
1131
1132 {
1133
1134
1135
1136
1137 full_driver = 0;
1138
1139 for (i = 0; i <= OPT_LAST; i++)
1140 if (can_select_option (i))
1141 {
1142 if (!(selected_options & B (i)))
1143
1144
1145 if (!hw_table[i].verify)
1146 {
1147 if (hw_table[i].alias)
1148 selected_options |= B (hw_table[i].alias);
1149 else
1150 selected_options |= B (i);
1151 }
1152 else
1153 {
1154 int def_answ = hw_table[i].default_answ;
1155
1156 fprintf (stderr,
1157 def_answ ? " %s (Y/n) ? " : " %s (y/N) ? ",
1158 questions[i]);
1159 if (think_positively (def_answ))
1160 if (hw_table[i].alias)
1161 selected_options |= B (hw_table[i].alias);
1162 else
1163 selected_options |= B (i);
1164 }
1165 }
1166 }
1167
1168 if (selected_options & B (OPT_SBPRO))
1169 {
1170 fprintf (stderr, "Do you want support for the mixer of SG NX Pro ? ");
1171 if (think_positively (0))
1172 printf ("#define __SGNXPRO__\n");
1173 }
1174
1175 if (selected_options & B (OPT_SB))
1176 {
1177 fprintf (stderr, "Do you want support for the MV Jazz16 (ProSonic etc.) ? ");
1178 if (think_positively (0))
1179 {
1180 fprintf (stderr, "Do you have SoundMan Wave (y/N) ? ");
1181
1182 if (think_positively (0))
1183 {
1184 printf ("#define SM_WAVE\n");
1185
1186 midi0001_again:
1187 fprintf
1188 (stderr,
1189 "Logitech SoundMan Wave has a microcontroller which must be initialized\n"
1190 "before MIDI emulation works. This is possible only if the microcode\n"
1191 "file is compiled into the driver.\n"
1192 "Do you have access to the MIDI0001.BIN file (Y/n) ? ");
1193 if (think_positively (1))
1194 {
1195 char path[512];
1196
1197 fprintf (stderr,
1198 "Enter full name of the MIDI0001.BIN file (pwd is sound): ");
1199 scanf ("%s", path);
1200 fprintf (stderr, "including microcode file %s\n", path);
1201
1202 if (!bin2hex (path, "smw-midi0001.h", "smw_ucode"))
1203 {
1204 fprintf (stderr, "couldn't open %s file\n",
1205 path);
1206 fprintf (stderr, "try again with correct path? ");
1207 if (think_positively (1))
1208 goto midi0001_again;
1209 }
1210 else
1211 {
1212 printf ("#define SMW_MIDI0001_INCLUDED\n");
1213 printf ("/*build bin2hex %s smw-midi0001.h smw_ucode */\n", path);
1214 }
1215 }
1216 }
1217 }
1218 }
1219
1220 if (selected_options & B (OPT_SBPRO))
1221 {
1222 fprintf (stderr, "\n\nThe Logitech SoundMan Games supports 44 kHz in stereo\n"
1223 "while the standard SB Pro supports just 22 kHz/stereo\n"
1224 "You have an option to enable the SM Games mode.\n"
1225 "However do enable it only if you are _sure_ that your\n"
1226 "card is a SM Games. Enabling this feature with a\n"
1227 "plain old SB Pro _will_ cause troubles with stereo mode.\n"
1228 "\n"
1229 "DANGER! Read the above once again before answering 'y'\n"
1230 "Answer 'n' in case you are unsure what to do!\n");
1231 fprintf (stderr, "Do you have a Logitech SoundMan Games (y/N) ? ");
1232 if (think_positively (0))
1233 printf ("#define SM_GAMES\n");
1234 }
1235
1236 if (selected_options & B (OPT_SB16))
1237 selected_options |= B (OPT_SBPRO);
1238
1239 if (selected_options & B (OPT_AEDSP16))
1240 {
1241 int sel1 = 0;
1242
1243 if (selected_options & B (OPT_SBPRO))
1244 {
1245 fprintf (stderr, "Do you want support for the Audio Excel SoundBlaster pro mode ? ");
1246 if (think_positively (1))
1247 {
1248 printf ("#define AEDSP16_SBPRO\n");
1249 sel1 = 1;
1250 }
1251 }
1252
1253 if ((selected_options & B (OPT_MSS)) && (sel1 == 0))
1254 {
1255 fprintf (stderr, "Do you want support for the Audio Excel Microsoft Sound System mode? ");
1256 if (think_positively (1))
1257 {
1258 printf ("#define AEDSP16_MSS\n");
1259 sel1 = 1;
1260 }
1261 }
1262
1263 if (sel1 == 0)
1264 {
1265 printf ("invalid_configuration__run_make_config_again\n");
1266 fprintf (stderr, "ERROR!!!!!\nYou must select at least one mode when using Audio Excel!\n");
1267 exit (-1);
1268 }
1269 if (selected_options & B (OPT_MPU401))
1270 printf ("#define AEDSP16_MPU401\n");
1271 }
1272
1273 if (selected_options & B (OPT_PSS))
1274 {
1275 genld_again:
1276 fprintf
1277 (stderr,
1278 "if you wish to emulate the soundblaster and you have a DSPxxx.LD.\n"
1279 "then you must include the LD in the kernel.\n"
1280 "Do you wish to include a LD (Y/n) ? ");
1281 if (think_positively (1))
1282 {
1283 char path[512];
1284
1285 fprintf (stderr,
1286 "Enter the path to your LD file (pwd is sound): ");
1287 scanf ("%s", path);
1288 fprintf (stderr, "including LD file %s\n", path);
1289
1290 if (!bin2hex (path, "synth-ld.h", "pss_synth"))
1291 {
1292 fprintf (stderr, "couldn't open %s as the ld file\n",
1293 path);
1294 fprintf (stderr, "try again with correct path? ");
1295 if (think_positively (1))
1296 goto genld_again;
1297 }
1298 else
1299 {
1300 printf ("#define PSS_HAVE_LD\n");
1301 printf ("/*build bin2hex %s synth-ld.h pss_synth */\n", path);
1302 }
1303 }
1304 else
1305 {
1306 FILE *sf = fopen ("synth-ld.h", "w");
1307
1308 fprintf (sf, "/* automaticaly generated by configure */\n");
1309 fprintf (sf, "unsigned char pss_synth[1];\n"
1310 "#define pss_synthLen 0\n");
1311 fclose (sf);
1312 }
1313 }
1314
1315 if (selected_options & B (OPT_TRIX))
1316 {
1317 hex2hex_again:
1318 fprintf (stderr, "MediaTriX audioTriX Pro has a onboard microcontroller\n"
1319 "which needs to be initialized by downloading\n"
1320 "the code from file TRXPRO.HEX in the DOS driver\n"
1321 "directory. If you don't have the TRXPRO.HEX handy\n"
1322 "you may skip this step. However SB and MPU-401\n"
1323 "modes of AudioTriX Pro will not work without\n"
1324 "this file!\n"
1325 "\n"
1326 "Do you want to include TRXPRO.HEX in your kernel (Y/n) ? ");
1327
1328 if (think_positively (1))
1329 {
1330 char path[512];
1331
1332 fprintf (stderr,
1333 "Enter the path to your TRXPRO.HEX file (pwd is sound): ");
1334 scanf ("%s", path);
1335 fprintf (stderr, "including HEX file %s\n", path);
1336
1337 if (!hex2hex (path, "trix_boot.h", "trix_boot"))
1338 goto hex2hex_again;
1339 printf ("/*build hex2hex %s trix_boot.h trix_boot */\n", path);
1340 printf ("#define INCLUDE_TRIX_BOOT\n");
1341 }
1342 }
1343
1344 if (!(selected_options & ANY_DEVS))
1345 {
1346 printf ("invalid_configuration__run_make_config_again\n");
1347 fprintf (stderr, "\n*** This combination is useless. Sound driver disabled!!! ***\n\n");
1348 exit (0);
1349 }
1350
1351 for (i = 0; i <= OPT_LAST; i++)
1352 if (!hw_table[i].alias)
1353 if (selected_options & B (i))
1354 printf ("#define CONFIG_%s\n", hw_table[i].macro);
1355 else
1356 printf ("#undef CONFIG_%s\n", hw_table[i].macro);
1357
1358
1359 printf ("\n");
1360
1361 i = 0;
1362
1363 while (extra_options[i].name != NULL)
1364 {
1365 if (selected_options & extra_options[i].mask)
1366 printf ("#define CONFIG_%s\n", extra_options[i].name);
1367 else
1368 printf ("#undef CONFIG_%s\n", extra_options[i].name);
1369 i++;
1370 }
1371
1372 printf ("\n");
1373
1374 ask_parameters ();
1375
1376 printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n", selected_options);
1377 fprintf (stderr, "The sound driver is now configured.\n");
1378
1379 #if defined(SCO) || defined(ISC) || defined(SYSV)
1380 fprintf (stderr, "Remember to update the System file\n");
1381 #endif
1382
1383 if (!old_config_used)
1384 {
1385 fprintf (stderr, "Save copy of this configuration to %s (Y/n)", oldconf);
1386 if (think_positively (1))
1387 {
1388 char cmd[200];
1389
1390 sprintf (cmd, "cp local.h %s", oldconf);
1391
1392 fclose (stdout);
1393 if (system (cmd) != 0)
1394 perror (cmd);
1395 }
1396 }
1397 exit (0);
1398 }
1399
1400 int
1401 bin2hex (char *path, char *target, char *varname)
1402 {
1403 int fd;
1404 int count;
1405 char c;
1406 int i = 0;
1407
1408 if ((fd = open (path, 0)) > 0)
1409 {
1410 FILE *sf = fopen (target, "w");
1411
1412 fprintf (sf, "/* automaticaly generated by configure */\n");
1413 fprintf (sf, "static unsigned char %s[] = {\n", varname);
1414 while (1)
1415 {
1416 count = read (fd, &c, 1);
1417 if (count == 0)
1418 break;
1419 if (i != 0 && (i % 10) == 0)
1420 fprintf (sf, "\n");
1421 fprintf (sf, "0x%02x,", c & 0xFFL);
1422 i++;
1423 }
1424 fprintf (sf, "};\n"
1425 "#define %sLen %d\n", varname, i);
1426 fclose (sf);
1427 close (fd);
1428 return 1;
1429 }
1430
1431 return 0;
1432 }