root/drivers/sound/configure.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. can_select_option
  2. think_positively
  3. ask_value
  4. rebuild_file
  5. use_old_config
  6. build_defines
  7. main
  8. bin2hex

   1 #define DISABLED_OPTIONS        (B(OPT_PNP))
   2 /*
   3  * sound/configure.c  - Configuration program for the Linux Sound Driver
   4  *
   5  * Copyright by Hannu Savolainen 1993-1995
   6  *
   7  * Redistribution and use in source and binary forms, with or without
   8  * modification, are permitted provided that the following conditions are
   9  * met: 1. Redistributions of source code must retain the above copyright
  10  * notice, this list of conditions and the following disclaimer. 2.
  11  * Redistributions in binary form must reproduce the above copyright notice,
  12  * this list of conditions and the following disclaimer in the documentation
  13  * and/or other materials provided with the distribution.
  14  *
  15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
  16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25  * SUCH DAMAGE.
  26  *
  27  */
  28 
  29 #include <stdio.h>
  30 #include <unistd.h>
  31 #include <stdlib.h>
  32 
  33 #define B(x)    (1 << (x))
  34 
  35 /*
  36  * Option numbers
  37  */
  38 
  39 #define OPT_PAS         0
  40 #define OPT_SB          1
  41 #define OPT_ADLIB       2
  42 #define OPT_LAST_MUTUAL 2
  43 
  44 #define OPT_GUS         3
  45 #define OPT_MPU401      4
  46 #define OPT_UART6850    5
  47 #define OPT_PSS         6
  48 #define OPT_GUS16       7
  49 #define OPT_GUSMAX      8
  50 #define OPT_MSS         9
  51 #define OPT_SSCAPE      10
  52 #define OPT_TRIX        11
  53 #define OPT_MAD16       12
  54 #define OPT_CS4232      13
  55 #define OPT_MAUI        14
  56 #define OPT_PNP         15
  57 
  58 #define OPT_HIGHLEVEL   16      /* This must be same than the next one */
  59 #define OPT_SBPRO       16
  60 #define OPT_SB16        17
  61 #define OPT_AEDSP16     18
  62 #define OPT_AUDIO       19
  63 #define OPT_MIDI_AUTO   20
  64 #define OPT_MIDI        21
  65 #define OPT_YM3812_AUTO 22
  66 #define OPT_YM3812      23
  67 #define OPT_SEQUENCER   24
  68 #define OPT_LAST        24      /* Last defined OPT number */
  69 
  70 
  71 #define ANY_DEVS (B(OPT_AUDIO)|B(OPT_MIDI)|B(OPT_SEQUENCER)|B(OPT_GUS)| \
  72                   B(OPT_MPU401)|B(OPT_PSS)|B(OPT_GUS16)|B(OPT_GUSMAX)| \
  73                   B(OPT_MSS)|B(OPT_SSCAPE)|B(OPT_UART6850)|B(OPT_TRIX)| \
  74                   B(OPT_MAD16)|B(OPT_CS4232)|B(OPT_MAUI))
  75 #define AUDIO_CARDS (B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_GUS) | \
  76                 B (OPT_MSS) | B (OPT_GUS16) | B (OPT_GUSMAX) | B (OPT_TRIX) | \
  77                 B (OPT_SSCAPE)| B(OPT_MAD16) | B(OPT_CS4232))
  78 #define MIDI_CARDS (B (OPT_PSS) | B (OPT_SB) | B (OPT_PAS) | B (OPT_MPU401) | \
  79                     B (OPT_GUS) | B (OPT_TRIX) | B (OPT_SSCAPE)|B(OPT_MAD16) | \
  80                     B (OPT_CS4232)|B(OPT_MAUI))
  81 #define MPU_DEVS (B(OPT_PSS)|B(OPT_SSCAPE)|B(OPT_TRIX)|B(OPT_MAD16)|\
  82                   B(OPT_CS4232)|B(OPT_PNP)|B(OPT_MAUI))
  83 #define AD1848_DEVS (B(OPT_GUS16)|B(OPT_MSS)|B(OPT_PSS)|B(OPT_GUSMAX)|\
  84                      B(OPT_SSCAPE)|B(OPT_TRIX)|B(OPT_MAD16)|B(OPT_CS4232)|\
  85                      B(OPT_PNP))
  86 /*
  87  * Options that have been disabled for some reason (incompletely implemented
  88  * and/or tested). Don't remove from this list before looking at file
  89  * experimental.txt for further info.
  90  */
  91 
  92 typedef struct
  93   {
  94     unsigned long   conditions;
  95     unsigned long   exclusive_options;
  96     char            macro[20];
  97     int             verify;
  98     int             alias;
  99     int             default_answ;
 100   }
 101 
 102 hw_entry;
 103 
 104 
 105 /*
 106  * The rule table for the driver options. The first field defines a set of
 107  * options which must be selected before this entry can be selected. The
 108  * second field is a set of options which are not allowed with this one. If
 109  * the fourth field is zero, the option is selected without asking
 110  * confirmation from the user.
 111  *
 112  * With this version of the rule table it is possible to select just one type of
 113  * hardware.
 114  *
 115  * NOTE!        Keep the following table and the questions array in sync with the
 116  * option numbering!
 117  */
 118 
 119 hw_entry        hw_table[] =
 120 {
 121 /*
 122  * 0
 123  */
 124   {0, 0, "PAS", 1, 0, 0},
 125   {0, 0, "SB", 1, 0, 0},
 126   {0, B (OPT_PAS) | B (OPT_SB), "ADLIB", 1, 0, 0},
 127 
 128   {0, 0, "GUS", 1, 0, 0},
 129   {0, 0, "MPU401", 1, 0, 0},
 130   {0, 0, "UART6850", 1, 0, 0},
 131   {0, 0, "PSS", 1, 0, 0},
 132   {B (OPT_GUS), 0, "GUS16", 1, 0, 0},
 133   {B (OPT_GUS), B (OPT_GUS16), "GUSMAX", 1, 0, 0},
 134   {0, 0, "MSS", 1, 0, 0},
 135   {0, 0, "SSCAPE", 1, 0, 0},
 136   {0, 0, "TRIX", 1, 0, 0},
 137   {0, 0, "MAD16", 1, 0, 0},
 138   {0, 0, "CS4232", 1, 0, 0},
 139   {0, 0, "MAUI", 1, 0, 0},
 140   {0, 0, "PNP", 1, 0, 0},
 141 
 142   {B (OPT_SB), B (OPT_PAS), "SBPRO", 1, 0, 1},
 143   {B (OPT_SB) | B (OPT_SBPRO), B (OPT_PAS), "SB16", 1, 0, 1},
 144   {B (OPT_SBPRO) | B (OPT_MSS) | B (OPT_MPU401), 0, "AEDSP16", 1, 0, 0},
 145   {AUDIO_CARDS, 0, "AUDIO", 1, 0, 1},
 146   {B (OPT_MPU401) | B (OPT_MAUI), 0, "MIDI_AUTO", 0, OPT_MIDI, 0},
 147   {MIDI_CARDS, 0, "MIDI", 1, 0, 1},
 148   {B (OPT_ADLIB), 0, "YM3812_AUTO", 0, OPT_YM3812, 0},
 149   {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},
 150   {B (OPT_MIDI) | B (OPT_YM3812) | B (OPT_YM3812_AUTO) | B (OPT_GUS), 0, "SEQUENCER", 0, 0, 1}
 151 };
 152 
 153 char           *questions[] =
 154 {
 155   "ProAudioSpectrum 16 support",
 156   "SoundBlaster support",
 157   "Generic OPL2/OPL3 FM synthesizer support",
 158   "Gravis Ultrasound support",
 159   "MPU-401 support (NOT for SB16)",
 160   "6850 UART Midi support",
 161   "PSS (ECHO-ADI2111) support",
 162   "16 bit sampling option of GUS (_NOT_ GUS MAX)",
 163   "GUS MAX support",
 164   "Microsoft Sound System support",
 165   "Ensoniq Soundscape support",
 166   "MediaTriX AudioTriX Pro support",
 167   "Support for MAD16 and/or Mozart based cards",
 168   "Support for Crystal CS4232 based (PnP) cards",
 169   "Support for Turtle Beach Wave Front (Maui, Tropez) synthesizers",
 170   "Support for PnP soundcards (_EXPERIMENTAL_)",
 171 
 172   "SoundBlaster Pro support",
 173   "SoundBlaster 16 support",
 174   "Audio Excel DSP 16 initialization support",
 175   "/dev/dsp and /dev/audio supports (usually required)",
 176   "This should not be asked",
 177   "MIDI interface support",
 178   "This should not be asked",
 179   "FM synthesizer (YM3812/OPL-3) support",
 180   "/dev/sequencer support",
 181   "Is the sky really falling"
 182 };
 183 
 184 struct kludge
 185   {
 186     char           *name;
 187     int             mask;
 188   }
 189 extra_options[] =
 190 {
 191   {
 192     "MPU_EMU", MPU_DEVS
 193   }
 194   ,
 195   {
 196     "AD1848", AD1848_DEVS
 197   }
 198   ,
 199   {
 200     NULL, 0
 201   }
 202 };
 203 
 204 char           *oldconf = "/etc/soundconf";
 205 
 206 int             old_config_used = 0;
 207 
 208 unsigned long   selected_options = 0;
 209 int             sb_dma = 0;
 210 
 211 void            build_defines (void);
 212 
 213 #include "hex2hex.h"
 214 int             bin2hex (char *path, char *target, char *varname);
 215 
 216 int
 217 can_select_option (int nr)
     /* [previous][next][first][last][top][bottom][index][help] */
 218 {
 219 
 220   if (hw_table[nr].conditions)
 221     if (!(hw_table[nr].conditions & selected_options))
 222       return 0;
 223 
 224   if (hw_table[nr].exclusive_options)
 225     if (hw_table[nr].exclusive_options & selected_options)
 226       return 0;
 227 
 228   if (DISABLED_OPTIONS & B (nr))
 229     return 0;
 230 
 231   return 1;
 232 }
 233 
 234 int
 235 think_positively (int def_answ)
     /* [previous][next][first][last][top][bottom][index][help] */
 236 {
 237   char            answ[512];
 238   int             len;
 239 
 240   if ((len = read (0, answ, sizeof (answ))) < 1)
 241     {
 242       fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
 243 
 244       perror ("stdin");
 245       printf ("#undef CONFIGURE_SOUNDCARD\n");
 246       printf ("#undef KERNEL_SOUNDCARD\n");
 247       exit (-1);
 248     }
 249 
 250   if (len < 2)                  /*
 251                                  * There is an additional LF at the end
 252                                  */
 253     return def_answ;
 254 
 255   answ[len - 1] = 0;
 256 
 257   if (!strcmp (answ, "y") || !strcmp (answ, "Y"))
 258     return 1;
 259 
 260   return 0;
 261 }
 262 
 263 int
 264 ask_value (char *format, int default_answer)
     /* [previous][next][first][last][top][bottom][index][help] */
 265 {
 266   char            answ[512];
 267   int             len, num;
 268 
 269 play_it_again_Sam:
 270 
 271   if ((len = read (0, answ, sizeof (answ))) < 1)
 272     {
 273       fprintf (stderr, "\n\nERROR! Cannot read stdin\n");
 274 
 275       perror ("stdin");
 276       printf ("#undef CONFIGURE_SOUNDCARD\n");
 277       printf ("#undef KERNEL_SOUNDCARD\n");
 278       exit (-1);
 279     }
 280 
 281   if (len < 2)                  /*
 282                                  * There is an additional LF at the end
 283                                  */
 284     return default_answer;
 285 
 286   answ[len - 1] = 0;
 287 
 288   if (sscanf (answ, format, &num) != 1)
 289     {
 290       fprintf (stderr, "Illegal format. Try again: ");
 291       goto play_it_again_Sam;
 292     }
 293 
 294   return num;
 295 }
 296 
 297 void
 298 rebuild_file (char *line)
     /* [previous][next][first][last][top][bottom][index][help] */
 299 {
 300   char           *method, *new, *old, *var, *p;
 301 
 302   method = p = line;
 303 
 304   while (*p && *p != ' ')
 305     p++;
 306   *p++ = 0;
 307 
 308   old = p;
 309   while (*p && *p != ' ')
 310     p++;
 311   *p++ = 0;
 312 
 313   new = p;
 314   while (*p && *p != ' ')
 315     p++;
 316   *p++ = 0;
 317 
 318   var = p;
 319   while (*p && *p != ' ')
 320     p++;
 321   *p++ = 0;
 322 
 323   fprintf (stderr, "Rebuilding file %s (%s %s)\n", new, method, old);
 324 
 325   if (strcmp (method, "bin2hex") == 0)
 326     {
 327       if (!bin2hex (old, new, var))
 328         {
 329           fprintf (stderr, "Rebuild failed\n");
 330           exit (-1);
 331         }
 332     }
 333   else if (strcmp (method, "hex2hex") == 0)
 334     {
 335       if (!hex2hex (old, new, var))
 336         {
 337           fprintf (stderr, "Rebuild failed\n");
 338           exit (-1);
 339         }
 340     }
 341   else
 342     {
 343       fprintf (stderr, "Failed to build '%s' - unknown method %s\n",
 344                new, method);
 345       exit (-1);
 346     }
 347 }
 348 
 349 int
 350 use_old_config (char *filename)
     /* [previous][next][first][last][top][bottom][index][help] */
 351 {
 352   char            buf[1024];
 353   int             i = 0;
 354 
 355   FILE           *oldf;
 356 
 357   fprintf (stderr, "Copying old configuration from %s\n", filename);
 358 
 359   if ((oldf = fopen (filename, "r")) == NULL)
 360     {
 361       fprintf (stderr, "Couldn't open previous configuration file\n");
 362       perror (filename);
 363       return 0;
 364     }
 365 
 366   while (fgets (buf, 1024, oldf) != NULL)
 367     {
 368       char            tmp[100];
 369 
 370       if (buf[0] != '#')
 371         {
 372           printf ("%s", buf);
 373 
 374           strncpy (tmp, buf, 8);
 375           tmp[8] = 0;
 376 
 377           if (strcmp (tmp, "/*build ") == 0)
 378             rebuild_file (&buf[8]);
 379 
 380           continue;
 381         }
 382 
 383       strncpy (tmp, buf, 8);
 384       tmp[8] = 0;
 385 
 386       if (strcmp (tmp, "#define ") == 0)
 387         {
 388           char           *id = &buf[8];
 389 
 390           i = 0;
 391           while (id[i] && id[i] != ' ' &&
 392                  id[i] != '\t' && id[i] != '\n')
 393             i++;
 394 
 395           strncpy (tmp, id, i);
 396           tmp[i] = 0;
 397 
 398           if (strcmp (tmp, "SELECTED_SOUND_OPTIONS") == 0)
 399             continue;
 400 
 401           tmp[8] = 0;           /* Truncate the string */
 402           if (strcmp (tmp, "EXCLUDE_") == 0)
 403             continue;           /* Skip excludes */
 404 
 405           printf ("%s", buf);
 406           continue;
 407         }
 408 
 409       if (strcmp (tmp, "#undef  ") == 0)
 410         {
 411           char           *id = &buf[8];
 412 
 413           i = 0;
 414           while (id[i] && id[i] != ' ' &&
 415                  id[i] != '\t' && id[i] != '\n')
 416             i++;
 417 
 418           strncpy (tmp, id, i);
 419           tmp[i] = 0;
 420 
 421           tmp[8] = 0;           /* Truncate the string */
 422           if (strcmp (tmp, "EXCLUDE_") != 0)
 423             continue;           /* Not a #undef  EXCLUDE_ line */
 424           strncpy (tmp, &id[8], i - 8);
 425           tmp[i - 8] = 0;
 426 
 427           for (i = 0; i <= OPT_LAST; i++)
 428             if (strcmp (hw_table[i].macro, tmp) == 0)
 429               {
 430                 selected_options |= (1 << i);
 431                 break;
 432               }
 433           continue;
 434         }
 435 
 436       printf ("%s", buf);
 437     }
 438   fclose (oldf);
 439 
 440   for (i = 0; i <= OPT_LAST; i++)
 441     if (!hw_table[i].alias)
 442       if (selected_options & B (i))
 443         printf ("#undef  EXCLUDE_%s\n", hw_table[i].macro);
 444       else
 445         printf ("#define EXCLUDE_%s\n", hw_table[i].macro);
 446 
 447 
 448   printf ("\n");
 449 
 450   i = 0;
 451 
 452   while (extra_options[i].name != NULL)
 453     {
 454       if (selected_options & extra_options[i].mask)
 455         printf ("#undef  EXCLUDE_%s\n", extra_options[i].name);
 456       else
 457         printf ("#define EXCLUDE_%s\n", extra_options[i].name);
 458       i++;
 459     }
 460 
 461   printf ("\n");
 462 
 463   printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n", selected_options);
 464   fprintf (stderr, "Old configuration copied.\n");
 465 
 466   build_defines ();
 467   old_config_used = 1;
 468   return 1;
 469 }
 470 
 471 void
 472 build_defines (void)
     /* [previous][next][first][last][top][bottom][index][help] */
 473 {
 474   FILE           *optf;
 475   int             i;
 476 
 477   if ((optf = fopen (".defines", "w")) == NULL)
 478     {
 479       perror (".defines");
 480       exit (-1);
 481     }
 482 
 483 
 484   for (i = 0; i <= OPT_LAST; i++)
 485     if (!hw_table[i].alias)
 486       if (selected_options & B (i))
 487         fprintf (optf, "CONFIG_%s=y\n", hw_table[i].macro);
 488 
 489 
 490   fprintf (optf, "\n");
 491 
 492   i = 0;
 493 
 494   while (extra_options[i].name != NULL)
 495     {
 496       if (selected_options & extra_options[i].mask)
 497         fprintf (optf, "CONFIG_%s=y\n", extra_options[i].name);
 498       i++;
 499     }
 500 
 501   fprintf (optf, "\n");
 502   fclose (optf);
 503 }
 504 
 505 int
 506 main (int argc, char *argv[])
     /* [previous][next][first][last][top][bottom][index][help] */
 507 {
 508   int             i, num, def_size, full_driver = 1;
 509   char            answ[10];
 510   int             sb_base = 0;
 511   char            old_config_file[200];
 512 
 513   fprintf (stderr, "\nConfiguring the sound support\n\n");
 514 
 515   if (getuid () != 0)           /* Not root */
 516     {
 517       char           *home;
 518 
 519       if ((home = getenv ("HOME")) != NULL)
 520         {
 521           sprintf (old_config_file, "%s/.soundconf", home);
 522           oldconf = old_config_file;
 523         }
 524     }
 525 
 526   if (argc > 1)
 527     {
 528       if (strcmp (argv[1], "-o") == 0 &&
 529           use_old_config (oldconf))
 530         exit (0);
 531     }
 532 
 533   if (access (oldconf, R_OK) == 0)
 534     {
 535       fprintf (stderr, "Old configuration exists in %s. Use it (y/n) ? ",
 536                oldconf);
 537       if (think_positively (1))
 538         if (use_old_config (oldconf))
 539           exit (0);
 540 
 541     }
 542 
 543   printf ("/*\tGenerated by configure. Don't edit!!!!\t*/\n\n");
 544 
 545   {
 546     /*
 547      * Partial driver
 548      */
 549 
 550     full_driver = 0;
 551 
 552     for (i = 0; i <= OPT_LAST; i++)
 553       if (can_select_option (i))
 554         {
 555           if (!(selected_options & B (i)))      /*
 556                                                  * Not selected yet
 557                                                  */
 558             if (!hw_table[i].verify)
 559               {
 560                 if (hw_table[i].alias)
 561                   selected_options |= B (hw_table[i].alias);
 562                 else
 563                   selected_options |= B (i);
 564               }
 565             else
 566               {
 567                 int             def_answ = hw_table[i].default_answ;
 568 
 569                 fprintf (stderr,
 570                          def_answ ? "  %s (y/n) ? " : "  %s (n/y) ? ",
 571                          questions[i]);
 572                 if (think_positively (def_answ))
 573                   if (hw_table[i].alias)
 574                     selected_options |= B (hw_table[i].alias);
 575                   else
 576                     selected_options |= B (i);
 577               }
 578         }
 579   }
 580 
 581   if (selected_options & B (OPT_SBPRO))
 582     {
 583       fprintf (stderr, "Do you want support for the mixer of SG NX Pro ? ");
 584       if (think_positively (0))
 585         printf ("#define __SGNXPRO__\n");
 586     }
 587 
 588   if (selected_options & B (OPT_SB))
 589     {
 590       fprintf (stderr, "Do you want support for the MV Jazz16 (ProSonic etc.) ? ");
 591       if (think_positively (0))
 592         {
 593           printf ("#define JAZZ16\n");
 594           do
 595             {
 596               fprintf (stderr, "\tValid 16 bit DMA channels for ProSonic/Jazz 16 are\n");
 597               fprintf (stderr, "\t1, 3, 5 (default), 7\n");
 598               fprintf (stderr, "\tEnter 16bit DMA channel for Prosonic : ");
 599               num = ask_value ("%d", 5);
 600             }
 601           while (num != 1 && num != 3 && num != 5 && num != 7);
 602           fprintf (stderr, "ProSonic 16 bit DMA set to %d\n", num);
 603           printf ("#define JAZZ_DMA16 %d\n", num);
 604 
 605           fprintf (stderr, "Do you have SoundMan Wave (n/y) ? ");
 606 
 607           if (think_positively (0))
 608             {
 609               printf ("#define SM_WAVE\n");
 610 
 611             midi0001_again:
 612               fprintf
 613                 (stderr,
 614                  "Logitech SoundMan Wave has a microcontroller which must be initialized\n"
 615                  "before MIDI emulation works. This is possible only if the microcode\n"
 616                  "file is compiled into the driver.\n"
 617                  "Do you have access to the MIDI0001.BIN file (y/n) ? ");
 618               if (think_positively (1))
 619                 {
 620                   char            path[512];
 621 
 622                   fprintf (stderr,
 623                            "Enter full name of the MIDI0001.BIN file (pwd is sound): ");
 624                   scanf ("%s", path);
 625                   fprintf (stderr, "including microcode file %s\n", path);
 626 
 627                   if (!bin2hex (path, "smw-midi0001.h", "smw_ucode"))
 628                     {
 629                       fprintf (stderr, "couldn't open %s file\n",
 630                                path);
 631                       fprintf (stderr, "try again with correct path? ");
 632                       if (think_positively (1))
 633                         goto midi0001_again;
 634                     }
 635                   else
 636                     {
 637                       printf ("#define SMW_MIDI0001_INCLUDED\n");
 638                       printf ("/*build bin2hex %s smw-midi0001.h smw_ucode */\n", path);
 639                     }
 640                 }
 641             }
 642         }
 643     }
 644 
 645   if (selected_options & B (OPT_SBPRO))
 646     {
 647       fprintf (stderr, "\n\nThe Logitech SoundMan Games supports 44 kHz in stereo\n"
 648                "while the standard SB Pro supports just 22 kHz/stereo\n"
 649                "You have an option to enable the SM Games mode.\n"
 650                "However do enable it only if you are _sure_ that your\n"
 651                "card is a SM Games. Enabling this feature with a\n"
 652                "plain old SB Pro _will_ cause troubles with stereo mode.\n"
 653                "\n"
 654                "DANGER! Read the above once again before answering 'y'\n"
 655                "Answer 'n' in case you are unsure what to do!\n");
 656       fprintf (stderr, "Do you have a Logitech SoundMan Games (n/y) ? ");
 657       if (think_positively (0))
 658         printf ("#define SM_GAMES\n");
 659     }
 660 
 661   if (selected_options & B (OPT_SB16))
 662     selected_options |= B (OPT_SBPRO);
 663 
 664   if (selected_options & B (OPT_AEDSP16))
 665     {
 666       int             sel1 = 0;
 667 
 668       if (selected_options & B (OPT_SBPRO))
 669         {
 670           fprintf (stderr, "Do you want support for the Audio Excel SoundBlaster pro mode ? ");
 671           if (think_positively (1))
 672             {
 673               printf ("#define AEDSP16_SBPRO\n");
 674               sel1 = 1;
 675             }
 676         }
 677 
 678       if ((selected_options & B (OPT_MSS)) && (sel1 == 0))
 679         {
 680           fprintf (stderr, "Do you want support for the Audio Excel Microsoft Sound System mode? ");
 681           if (think_positively (1))
 682             {
 683               printf ("#define AEDSP16_MSS\n");
 684               sel1 = 1;
 685             }
 686         }
 687 
 688       if (sel1 == 0)
 689         {
 690           printf ("#undef CONFIGURE_SOUNDCARD\n");
 691           printf ("#undef KERNEL_SOUNDCARD\n");
 692           fprintf (stderr, "ERROR!!!!!\nYou loose: you must select at least one mode when using Audio Excel!\n");
 693           exit (-1);
 694         }
 695       if (selected_options & B (OPT_MPU401))
 696         printf ("#define AEDSP16_MPU401\n");
 697     }
 698 
 699   if (selected_options & B (OPT_PSS))
 700     {
 701     genld_again:
 702       fprintf
 703         (stderr,
 704        "if you wish to emulate the soundblaster and you have a DSPxxx.LD.\n"
 705          "then you must include the LD in the kernel.\n"
 706          "Do you wish to include a LD (y/n) ? ");
 707       if (think_positively (1))
 708         {
 709           char            path[512];
 710 
 711           fprintf (stderr,
 712                    "Enter the path to your LD file (pwd is sound): ");
 713           scanf ("%s", path);
 714           fprintf (stderr, "including LD file %s\n", path);
 715 
 716           if (!bin2hex (path, "synth-ld.h", "pss_synth"))
 717             {
 718               fprintf (stderr, "couldn't open %s as the ld file\n",
 719                        path);
 720               fprintf (stderr, "try again with correct path? ");
 721               if (think_positively (1))
 722                 goto genld_again;
 723             }
 724           else
 725             {
 726               printf ("#define PSS_HAVE_LD\n");
 727               printf ("/*build bin2hex %s synth-ld.h pss_synth */\n", path);
 728             }
 729         }
 730       else
 731         {
 732           FILE           *sf = fopen ("synth-ld.h", "w");
 733 
 734           fprintf (sf, "/* automaticaly generated by configure */\n");
 735           fprintf (sf, "unsigned char pss_synth[1];\n"
 736                    "#define pss_synthLen 0\n");
 737           fclose (sf);
 738         }
 739     }
 740 
 741   if (selected_options & B (OPT_TRIX))
 742     {
 743     hex2hex_again:
 744       fprintf (stderr, "MediaTriX audioTriX Pro has a onboard microcontroller\n"
 745                "which needs to be initialized by downloading\n"
 746                "the code from file TRXPRO.HEX in the DOS driver\n"
 747                "directory. If you don't have the TRXPRO.HEX handy\n"
 748                "you may skip this step. However SB and MPU-401\n"
 749                "modes of AudioTriX Pro will not work without\n"
 750                "this file!\n"
 751                "\n"
 752                "Do you want to include TRXPRO.HEX in your kernel (y/n) ? ");
 753 
 754       if (think_positively (1))
 755         {
 756           char            path[512];
 757 
 758           fprintf (stderr,
 759                  "Enter the path to your TRXPRO.HEX file (pwd is sound): ");
 760           scanf ("%s", path);
 761           fprintf (stderr, "including HEX file %s\n", path);
 762 
 763           if (!hex2hex (path, "trix_boot.h", "trix_boot"))
 764             goto hex2hex_again;
 765           printf ("/*build hex2hex %s trix_boot.h trix_boot */\n", path);
 766           printf ("#define INCLUDE_TRIX_BOOT\n");
 767         }
 768     }
 769 
 770   if (!(selected_options & ANY_DEVS))
 771     {
 772       printf ("#undef CONFIGURE_SOUNDCARD\n");
 773       printf ("#undef KERNEL_SOUNDCARD\n");
 774       fprintf (stderr, "\n*** This combination is useless. Sound driver disabled!!! ***\n\n");
 775       exit (0);
 776     }
 777   else
 778     printf ("#define KERNEL_SOUNDCARD\n");
 779 
 780   for (i = 0; i <= OPT_LAST; i++)
 781     if (!hw_table[i].alias)
 782       if (selected_options & B (i))
 783         printf ("#undef  EXCLUDE_%s\n", hw_table[i].macro);
 784       else
 785         printf ("#define EXCLUDE_%s\n", hw_table[i].macro);
 786 
 787 
 788   printf ("\n");
 789 
 790   i = 0;
 791 
 792   while (extra_options[i].name != NULL)
 793     {
 794       if (selected_options & extra_options[i].mask)
 795         printf ("#undef  EXCLUDE_%s\n", extra_options[i].name);
 796       else
 797         printf ("#define EXCLUDE_%s\n", extra_options[i].name);
 798       i++;
 799     }
 800 
 801   printf ("\n");
 802 
 803 
 804 
 805   build_defines ();
 806   /*
 807    * IRQ and DMA settings
 808    */
 809 
 810   if (selected_options & B (OPT_AEDSP16))
 811     {
 812       fprintf (stderr, "\nI/O base for Audio Excel DSP 16 ?\n"
 813                "Warning:\n"
 814                "If you are using Audio Excel SoundBlaster emulation,\n"
 815         "you must use the same I/O base for Audio Excel and SoundBlaster.\n"
 816                "The factory default is 220 (other possible value is 240)\n"
 817                "Enter the Audio Excel DSP 16 I/O base: ");
 818 
 819       num = ask_value ("%x", 0x220);
 820       fprintf (stderr, "Audio Excel DSP 16 I/O base set to %03x\n", num);
 821       printf ("#define AEDSP16_BASE 0x%03x\n", num);
 822     }
 823 
 824   if ((selected_options & B (OPT_SB)) && selected_options & (B (OPT_AUDIO) | B (OPT_MIDI)))
 825     {
 826       fprintf (stderr, "\nI/O base for SB?\n"
 827                "The factory default is 220\n"
 828                "Enter the SB I/O base: ");
 829 
 830       sb_base = num = ask_value ("%x", 0x220);
 831       fprintf (stderr, "SB I/O base set to %03x\n", num);
 832       printf ("#define SBC_BASE 0x%03x\n", num);
 833 
 834       fprintf (stderr, "\nIRQ number for SoundBlaster?\n"
 835                "The IRQ address is defined by the jumpers on your card.\n"
 836           "The factory default is either 5 or 7 (depending on the model).\n"
 837                "Valid values are 9(=2), 5, 7 and 10.\n"
 838                "Enter the value: ");
 839 
 840       num = ask_value ("%d", 7);
 841       if (num != 9 && num != 5 && num != 7 && num != 10)
 842         {
 843 
 844           fprintf (stderr, "*** Illegal input! ***\n");
 845           num = 7;
 846         }
 847       fprintf (stderr, "SoundBlaster IRQ set to %d\n", num);
 848 
 849       printf ("#define SBC_IRQ %d\n", num);
 850 
 851       if (selected_options & (B (OPT_SBPRO) | B (OPT_PAS)))
 852         {
 853           fprintf (stderr, "\nDMA channel for SoundBlaster?\n"
 854                    "For SB 1.0, 1.5 and 2.0 this MUST be 1\n"
 855                    "SB Pro supports DMA channels 0, 1 and 3 (jumper)\n"
 856                    "For SB16 give the 8 bit DMA# here\n"
 857                    "The default value is 1\n"
 858                    "Enter the value: ");
 859 
 860           num = ask_value ("%d", 1);
 861           if (num < 0 || num > 3)
 862             {
 863 
 864               fprintf (stderr, "*** Illegal input! ***\n");
 865               num = 1;
 866             }
 867           fprintf (stderr, "SoundBlaster DMA set to %d\n", num);
 868           printf ("#define SBC_DMA %d\n", num);
 869           sb_dma = num;
 870         }
 871 
 872       if (selected_options & B (OPT_SB16))
 873         {
 874 
 875           fprintf (stderr, "\n16 bit DMA channel for SoundBlaster 16?\n"
 876                    "Possible values are 5, 6 or 7\n"
 877                    "The default value is 6\n"
 878                    "Enter the value: ");
 879 
 880           num = ask_value ("%d", 6);
 881           if ((num < 5 || num > 7) && (num != sb_dma))
 882             {
 883 
 884               fprintf (stderr, "*** Illegal input! ***\n");
 885               num = 6;
 886             }
 887           fprintf (stderr, "SoundBlaster DMA set to %d\n", num);
 888           printf ("#define SB16_DMA %d\n", num);
 889 
 890           fprintf (stderr, "\nI/O base for SB16 Midi?\n"
 891                    "Possible values are 300 and 330\n"
 892                    "The factory default is 330\n"
 893                    "Enter the SB16 Midi I/O base: ");
 894 
 895           num = ask_value ("%x", 0x330);
 896           fprintf (stderr, "SB16 Midi I/O base set to %03x\n", num);
 897           printf ("#define SB16MIDI_BASE 0x%03x\n", num);
 898         }
 899     }
 900 
 901   if (selected_options & B (OPT_PAS))
 902     {
 903 
 904       if (selected_options & (B (OPT_AUDIO) | B (OPT_MIDI)))
 905         {
 906           fprintf (stderr, "\nIRQ number for ProAudioSpectrum?\n"
 907                    "The recommended value is the IRQ used under DOS.\n"
 908                    "Please refer to the ProAudioSpectrum User's Guide.\n"
 909                    "The default value is 10.\n"
 910                    "Enter the value: ");
 911 
 912           num = ask_value ("%d", 10);
 913           if (num == 6 || num < 3 || num > 15 || num == 2)      /*
 914                                                                  * Illegal
 915                                                                  */
 916             {
 917 
 918               fprintf (stderr, "*** Illegal input! ***\n");
 919               num = 10;
 920             }
 921           fprintf (stderr, "ProAudioSpectrum IRQ set to %d\n", num);
 922           printf ("#define PAS_IRQ %d\n", num);
 923         }
 924 
 925       if (selected_options & B (OPT_AUDIO))
 926         {
 927           fprintf (stderr, "\nDMA number for ProAudioSpectrum?\n"
 928                    "The recommended value is the DMA channel under DOS.\n"
 929                    "Please refer to the ProAudioSpectrum User's Guide.\n"
 930                    "The default value is 3\n"
 931                    "Enter the value: ");
 932 
 933           num = ask_value ("%d", 3);
 934           if (num == 4 || num < 0 || num > 7)
 935             {
 936 
 937               fprintf (stderr, "*** Illegal input! ***\n");
 938               num = 3;
 939             }
 940           fprintf (stderr, "\nProAudioSpectrum DMA set to %d\n", num);
 941           printf ("#define PAS_DMA %d\n", num);
 942         }
 943       fprintf (stderr, "\nEnable Joystick port on ProAudioSpectrum (n/y) ? ");
 944       if (think_positively (0))
 945         printf ("#define PAS_JOYSTICK_ENABLE\n");
 946 
 947       fprintf (stderr, "PAS16 could be noisy with some mother boards\n"
 948                "There is a command line switch (was it :T?)\n"
 949                "in the DOS driver for PAS16 which solves this.\n"
 950                "Don't enable this feature unless you have problems!\n"
 951                "Do you have to use this switch with DOS (y/n) ?");
 952       if (think_positively (0))
 953         printf ("#define BROKEN_BUS_CLOCK\n");
 954     }
 955 
 956   if (selected_options & B (OPT_GUS))
 957     {
 958       fprintf (stderr, "\nI/O base for Gravis Ultrasound?\n"
 959                "Valid choices are 210, 220, 230, 240, 250 or 260\n"
 960                "The factory default is 220\n"
 961                "Enter the GUS I/O base: ");
 962 
 963       num = ask_value ("%x", 0x220);
 964       if ((num > 0x260) || ((num & 0xf0f) != 0x200) || ((num & 0x0f0) > 0x060))
 965         {
 966 
 967           fprintf (stderr, "*** Illegal input! ***\n");
 968           num = 0x220;
 969         }
 970 
 971       if ((selected_options & B (OPT_SB)) && (num == sb_base))
 972         {
 973           fprintf (stderr, "FATAL ERROR!!!!!!!!!!!!!!\n"
 974                    "\t0x220 cannot be used if SoundBlaster is enabled.\n"
 975                    "\tRun the config again.\n");
 976           printf ("#undef CONFIGURE_SOUNDCARD\n");
 977           printf ("#undef KERNEL_SOUNDCARD\n");
 978           exit (-1);
 979         }
 980       fprintf (stderr, "GUS I/O base set to %03x\n", num);
 981       printf ("#define GUS_BASE 0x%03x\n", num);
 982 
 983       fprintf (stderr, "\nIRQ number for Gravis UltraSound?\n"
 984                "The recommended value is the IRQ used under DOS.\n"
 985                "Please refer to the Gravis Ultrasound User's Guide.\n"
 986                "The default value is 15.\n"
 987                "Enter the value: ");
 988 
 989       num = ask_value ("%d", 15);
 990       if (num == 6 || num < 3 || num > 15 || num == 2)  /*
 991                                                          * Invalid
 992                                                          */
 993         {
 994 
 995           fprintf (stderr, "*** Illegal input! ***\n");
 996           num = 15;
 997         }
 998       fprintf (stderr, "Gravis UltraSound IRQ set to %d\n", num);
 999       printf ("#define GUS_IRQ %d\n", num);
1000 
1001       fprintf (stderr, "\nDMA number for Gravis UltraSound?\n"
1002                "The recommended value is the DMA channel under DOS.\n"
1003                "Please refer to the Gravis Ultrasound User's Guide.\n"
1004                "The default value is 6\n"
1005                "Enter the value: ");
1006 
1007       num = ask_value ("%d", 6);
1008       if (num == 4 || num < 0 || num > 7)
1009         {
1010           fprintf (stderr, "*** Illegal input! ***\n");
1011           num = 6;
1012         }
1013       fprintf (stderr, "\nGravis UltraSound DMA set to %d\n", num);
1014       printf ("#define GUS_DMA %d\n", num);
1015 
1016       fprintf (stderr, "\nSecond DMA channel for GUS (optional)?\n"
1017                "The default value is 7 (-1 disables)\n"
1018                "Enter the value: ");
1019 
1020       num = ask_value ("%d", 7);
1021       if (num > 7)
1022         {
1023           fprintf (stderr, "*** Illegal input! ***\n");
1024           num = 7;
1025         }
1026 
1027       fprintf (stderr, "\nGUS DMA2 set to %d\n", num);
1028       printf ("#define GUS_DMA2 %d\n", num);
1029 
1030       if (selected_options & B (OPT_GUS16))
1031         {
1032           fprintf (stderr, "\nI/O base for GUS16 (GUS 16 bit sampling option)?\n"
1033                    "The factory default is 530\n"
1034                    "Other possible values are  604, E80 or F40\n"
1035                    "Enter the GUS16 I/O base: ");
1036 
1037           num = ask_value ("%x", 0x530);
1038           fprintf (stderr, "GUS16 I/O base set to %03x\n", num);
1039           printf ("#define GUS16_BASE 0x%03x\n", num);
1040 
1041           fprintf (stderr, "\nIRQ number for GUS16?\n"
1042                    "Valid numbers are: 3, 4, 5, 7, or 9(=2).\n"
1043                    "The default value is 7.\n"
1044                    "Enter the value: ");
1045 
1046           num = ask_value ("%d", 7);
1047           if (num == 6 || num < 3 || num > 15)
1048             {
1049               fprintf (stderr, "*** Illegal input! ***\n");
1050               num = 7;
1051             }
1052           fprintf (stderr, "GUS16 IRQ set to %d\n", num);
1053           printf ("#define GUS16_IRQ %d\n", num);
1054 
1055           fprintf (stderr, "\nDMA number for GUS16?\n"
1056                    "The default value is 3\n"
1057                    "Enter the value: ");
1058 
1059           num = ask_value ("%d", 3);
1060           if (num < 0 || num > 3)
1061             {
1062               fprintf (stderr, "*** Illegal input! ***\n");
1063               num = 3;
1064             }
1065           fprintf (stderr, "\nGUS16 DMA set to %d\n", num);
1066           printf ("#define GUS16_DMA %d\n", num);
1067         }
1068     }
1069 
1070   if (selected_options & B (OPT_MPU401))
1071     {
1072       fprintf (stderr, "\nI/O base for MPU-401?\n"
1073                "The factory default is 330\n"
1074                "Enter the MPU-401 I/O base: ");
1075 
1076       num = ask_value ("%x", 0x330);
1077       fprintf (stderr, "MPU-401 I/O base set to %03x\n", num);
1078       printf ("#define MPU_BASE 0x%03x\n", num);
1079 
1080       fprintf (stderr, "\nIRQ number for MPU-401?\n"
1081                "Valid numbers are: 3, 4, 5, 7 and 9(=2).\n"
1082                "The default value is 9.\n"
1083                "Enter the value: ");
1084 
1085       num = ask_value ("%d", 9);
1086       if (num == 6 || num < 3 || num > 15)
1087         {
1088 
1089           fprintf (stderr, "*** Illegal input! ***\n");
1090           num = 5;
1091         }
1092       fprintf (stderr, "MPU-401 IRQ set to %d\n", num);
1093       printf ("#define MPU_IRQ %d\n", num);
1094     }
1095 
1096   if (selected_options & B (OPT_MAUI))
1097     {
1098       fprintf (stderr, "\nI/O base for TB Maui (MIDI I/O of TB Tropez)?\n"
1099                "The factory default is 330\n"
1100         "Valid alternatives are 210, 230, 260, 290, 300, 320, 338 and 330\n"
1101                "Enter the Maui/Tropez MIDI I/O base: ");
1102 
1103       num = ask_value ("%x", 0x330);
1104       fprintf (stderr, "Maui I/O base set to %03x\n", num);
1105       printf ("#define MAUI_BASE 0x%03x\n", num);
1106 
1107       fprintf (stderr, "\nIRQ number for TB Maui (TB Tropez MIDI)?\n"
1108                "Valid numbers are: 5, 9, 12 and 15.\n"
1109                "The default value is 9.\n"
1110                "Enter the value: ");
1111 
1112       num = ask_value ("%d", 9);
1113       if (num == 6 || num < 3 || num > 15)
1114         {
1115 
1116           fprintf (stderr, "*** Illegal input! ***\n");
1117           num = 5;
1118         }
1119       fprintf (stderr, "Maui/Tropez MIDI IRQ set to %d\n", num);
1120       printf ("#define MAUI_IRQ %d\n", num);
1121     }
1122 
1123   if (selected_options & B (OPT_UART6850))
1124     {
1125       fprintf (stderr, "\nI/O base for 6850 UART Midi?\n"
1126                "Be carefull. No defaults.\n"
1127                "Enter the 6850 UART I/O base: ");
1128 
1129       num = ask_value ("%x", 0);
1130       if (num == 0)
1131         {
1132           /*
1133              * Invalid value entered
1134            */
1135           printf ("#define EXCLUDE_UART6850\n");
1136         }
1137       else
1138         {
1139           fprintf (stderr, "6850 UART I/O base set to %03x\n", num);
1140           printf ("#define U6850_BASE 0x%03x\n", num);
1141 
1142           fprintf (stderr, "\nIRQ number for 6850 UART?\n"
1143                    "Valid numbers are: 3, 4, 5, 7 and 9(=2).\n"
1144                    "The default value is 5.\n"
1145                    "Enter the value: ");
1146 
1147           num = ask_value ("%d", 5);
1148           if (num == 6 || num < 3 || num > 15)
1149             {
1150 
1151               fprintf (stderr, "*** Illegal input! ***\n");
1152               num = 5;
1153             }
1154           fprintf (stderr, "6850 UART IRQ set to %d\n", num);
1155           printf ("#define U6850_IRQ %d\n", num);
1156         }
1157     }
1158 
1159   if (selected_options & B (OPT_PSS))
1160     {
1161       fprintf (stderr, "\nI/O base for PSS?\n"
1162                "The factory default is 220 (240 also possible)\n"
1163                "Enter the PSS I/O base: ");
1164 
1165       num = ask_value ("%x", 0x220);
1166       fprintf (stderr, "PSS I/O base set to %03x\n", num);
1167       printf ("#define PSS_BASE 0x%03x\n", num);
1168 
1169 #if YOU_WANT_TO_WASTE_RESOURCES
1170       fprintf (stderr, "\nIRQ number for PSS?\n"
1171                "Valid numbers are: 3, 4, 5, 7, 9(=2) or 10.\n"
1172                "The default value is 10.\n"
1173                "Enter the value: ");
1174 
1175       num = ask_value ("%d", 10);
1176       if (num == 6 || num < 3 || num > 15)
1177         {
1178           fprintf (stderr, "*** Illegal input! ***\n");
1179           num = 7;
1180         }
1181       fprintf (stderr, "PSS IRQ set to %d\n", num);
1182       printf ("#define PSS_IRQ %d\n", num);
1183 
1184       fprintf (stderr, "\nDMA number for ECHO-PSS?\n"
1185                "The default value is 5\n"
1186                "Valid values are 5, 6 and 7\n"
1187                "Enter the value: ");
1188 
1189       num = ask_value ("%d", 5);
1190       if (num < 5 || num > 7)
1191         {
1192           fprintf (stderr, "*** Illegal input! ***\n");
1193           num = 5;
1194         }
1195       fprintf (stderr, "\nECHO-PSS DMA set to %d\n", num);
1196       printf ("#define PSS_DMA %d\n", num);
1197 #endif
1198 
1199       fprintf (stderr, "\nMSS (MS Sound System) I/O base for the PSS card?\n"
1200                "The factory default is 530\n"
1201                "Other possible values are  604, E80 or F40\n"
1202                "Enter the MSS I/O base: ");
1203 
1204       num = ask_value ("%x", 0x530);
1205       fprintf (stderr, "PSS/MSS I/O base set to %03x\n", num);
1206       printf ("#define PSS_MSS_BASE 0x%03x\n", num);
1207 
1208       fprintf (stderr, "\nIRQ number for the MSS mode of PSS ?\n"
1209                "Valid numbers are: 7, 9(=2), 10 and 11.\n"
1210                "The default value is 11.\n"
1211                "Enter the value: ");
1212 
1213       num = ask_value ("%d", 11);
1214       if (num == 6 || num < 3 || num > 15)
1215         {
1216           fprintf (stderr, "*** Illegal input! ***\n");
1217           num = 11;
1218         }
1219       fprintf (stderr, "PSS/MSS IRQ set to %d\n", num);
1220       printf ("#define PSS_MSS_IRQ %d\n", num);
1221 
1222       fprintf (stderr, "\nMSS DMA number for PSS?\n"
1223                "Valid values are 0, 1 and 3.\n"
1224                "The default value is 3\n"
1225                "Enter the value: ");
1226 
1227       num = ask_value ("%d", 3);
1228       if (num == 4 || num < 0 || num > 7)
1229         {
1230           fprintf (stderr, "*** Illegal input! ***\n");
1231           num = 3;
1232         }
1233       fprintf (stderr, "\nPSS/MSS DMA set to %d\n", num);
1234       printf ("#define PSS_MSS_DMA %d\n", num);
1235 
1236       fprintf (stderr, "\nMIDI I/O base for PSS?\n"
1237                "The factory default is 330\n"
1238                "Enter the PSS MIDI I/O base: ");
1239 
1240       num = ask_value ("%x", 0x330);
1241       fprintf (stderr, "PSS/MIDI I/O base set to %03x\n", num);
1242       printf ("#define PSS_MPU_BASE 0x%03x\n", num);
1243 
1244       fprintf (stderr, "\nIRQ number for PSS MIDI?\n"
1245                "Valid numbers are: 3, 4, 5, 7 and 9(=2).\n"
1246                "The default value is 9.\n"
1247                "Enter the value: ");
1248 
1249       num = ask_value ("%d", 9);
1250       if (num == 6 || num < 3 || num > 15)
1251         {
1252 
1253           fprintf (stderr, "*** Illegal input! ***\n");
1254           num = 5;
1255         }
1256       fprintf (stderr, "PSS MIDI IRQ set to %d\n", num);
1257       printf ("#define PSS_MPU_IRQ %d\n", num);
1258     }
1259 
1260   if (selected_options & B (OPT_MSS))
1261     {
1262       fprintf (stderr, "\nI/O base for MSS (MS Sound System)?\n"
1263                "The factory default is 530\n"
1264                "Other possible values are  604, E80 or F40\n"
1265                "Enter the MSS I/O base: ");
1266 
1267       num = ask_value ("%x", 0x530);
1268       fprintf (stderr, "MSS I/O base set to %03x\n", num);
1269       printf ("#define MSS_BASE 0x%03x\n", num);
1270 
1271       fprintf (stderr, "\nIRQ number for MSS?\n"
1272                "Valid numbers are: 7, 9(=2), 10 and 11.\n"
1273                "The default value is 10.\n"
1274                "Enter the value: ");
1275 
1276       num = ask_value ("%d", 10);
1277       if (num == 6 || num < 3 || num > 15)
1278         {
1279           fprintf (stderr, "*** Illegal input! ***\n");
1280           num = 7;
1281         }
1282       fprintf (stderr, "MSS IRQ set to %d\n", num);
1283       printf ("#define MSS_IRQ %d\n", num);
1284 
1285       fprintf (stderr, "\nDMA number for MSS?\n"
1286                "Valid values are 0, 1 and 3.\n"
1287                "The default value is 3\n"
1288                "Enter the value: ");
1289 
1290       num = ask_value ("%d", 3);
1291       if (num == 4 || num < 0 || num > 7)
1292         {
1293           fprintf (stderr, "*** Illegal input! ***\n");
1294           num = 3;
1295         }
1296       fprintf (stderr, "\nMSS DMA set to %d\n", num);
1297       printf ("#define MSS_DMA %d\n", num);
1298     }
1299 
1300   if (selected_options & B (OPT_SSCAPE))
1301     {
1302       int             reveal_spea;
1303 
1304       fprintf (stderr, "\n(MIDI) I/O base for Ensoniq Soundscape?\n"
1305                "The factory default is 330\n"
1306                "Other possible values are 320, 340 or 350\n"
1307                "Enter the Soundscape I/O base: ");
1308 
1309       num = ask_value ("%x", 0x330);
1310       fprintf (stderr, "Soundscape I/O base set to %03x\n", num);
1311       printf ("#define SSCAPE_BASE 0x%03x\n", num);
1312 
1313       fprintf (stderr, "Is your SoundScape card made/marketed by Reveal or Spea? ");
1314       reveal_spea = think_positively (0);
1315       if (reveal_spea)
1316         printf ("#define REVEAL_SPEA\n");
1317 
1318       fprintf (stderr, "\nIRQ number for Soundscape?\n");
1319 
1320       if (reveal_spea)
1321         fprintf (stderr, "Check valid interrupts from the manual of your card.\n");
1322       else
1323         fprintf (stderr, "Valid numbers are: 5, 7, 9(=2) and 10.\n");
1324 
1325       fprintf (stderr, "The default value is 9.\n"
1326                "Enter the value: ");
1327 
1328       num = ask_value ("%d", 9);
1329       if (num == 6 || num < 3 || num > 15)
1330         {
1331           fprintf (stderr, "*** Illegal input! ***\n");
1332           num = 9;
1333         }
1334       fprintf (stderr, "Soundscape IRQ set to %d\n", num);
1335       printf ("#define SSCAPE_IRQ %d\n", num);
1336 
1337       fprintf (stderr, "\nDMA number for Soundscape?\n"
1338                "Valid values are 1 and 3 (sometimes 0)"
1339                "The default value is 3\n"
1340                "Enter the value: ");
1341 
1342       num = ask_value ("%d", 3);
1343       if (num == 4 || num < 0 || num > 7)
1344         {
1345           fprintf (stderr, "*** Illegal input! ***\n");
1346           num = 3;
1347         }
1348       fprintf (stderr, "\nSoundscape DMA set to %d\n", num);
1349       printf ("#define SSCAPE_DMA %d\n", num);
1350 
1351       fprintf (stderr, "\nMSS (MS Sound System) I/O base for the SSCAPE card?\n"
1352                "The factory default is 534\n"
1353                "Other possible values are  608, E84 or F44\n"
1354                "Enter the MSS I/O base: ");
1355 
1356       num = ask_value ("%x", 0x534);
1357       fprintf (stderr, "SSCAPE/MSS I/O base set to %03x\n", num);
1358       printf ("#define SSCAPE_MSS_BASE 0x%03x\n", num);
1359 
1360       fprintf (stderr, "\nIRQ number for the MSS mode of SSCAPE ?\n");
1361       if (reveal_spea)
1362         fprintf (stderr, "Valid numbers are: 5, 7, 9(=2) and 15.\n");
1363       else
1364         fprintf (stderr, "Valid numbers are: 5, 7, 9(=2) and 10.\n");
1365       fprintf (stderr, "The default value is 5.\n"
1366                "Enter the value: ");
1367 
1368       num = ask_value ("%d", 5);
1369       if (num == 6 || num < 3 || num > 15)
1370         {
1371           fprintf (stderr, "*** Illegal input! ***\n");
1372           num = 10;
1373         }
1374       fprintf (stderr, "SSCAPE/MSS IRQ set to %d\n", num);
1375       printf ("#define SSCAPE_MSS_IRQ %d\n", num);
1376 
1377       fprintf (stderr, "\nMSS DMA number for SSCAPE?\n"
1378                "Valid values are 0, 1 and 3.\n"
1379                "The default value is 3\n"
1380                "Enter the value: ");
1381 
1382       num = ask_value ("%d", 3);
1383       if (num == 4 || num < 0 || num > 7)
1384         {
1385           fprintf (stderr, "*** Illegal input! ***\n");
1386           num = 3;
1387         }
1388       fprintf (stderr, "\nSSCAPE/MSS DMA set to %d\n", num);
1389       printf ("#define SSCAPE_MSS_DMA %d\n", num);
1390     }
1391   if (selected_options & B (OPT_TRIX))
1392     {
1393 
1394       fprintf (stderr, "\nWindows Sound System I/O base for the AudioTriX card?\n"
1395                "The factory default is 530\n"
1396                "Other possible values are  604, E80 or F40\n"
1397                "Enter the MSS I/O base: ");
1398 
1399       num = ask_value ("%x", 0x530);
1400       fprintf (stderr, "AudioTriX MSS I/O base set to %03x\n", num);
1401       printf ("#define TRIX_BASE 0x%03x\n", num);
1402 
1403       fprintf (stderr, "\nIRQ number for the WSS mode of AudioTriX ?\n"
1404                "Valid numbers are: 5, 7, 9(=2), 10 and 11.\n"
1405                "The default value is 11.\n"
1406                "Enter the value: ");
1407 
1408       num = ask_value ("%d", 11);
1409       if (num != 5 && num != 7 && num != 9 && num != 10 && num != 11)
1410         {
1411           fprintf (stderr, "*** Illegal input! ***\n");
1412           num = 11;
1413         }
1414       fprintf (stderr, " AudioTriX WSS IRQ set to %d\n", num);
1415       printf ("#define TRIX_IRQ %d\n", num);
1416 
1417       fprintf (stderr, "\nWSS DMA number for AudioTriX?\n"
1418                "Valid values are 0, 1 and 3.\n"
1419                "The default value is 3\n"
1420                "Enter the value: ");
1421 
1422       num = ask_value ("%d", 3);
1423       if (num != 0 && num != 1 && num != 3)
1424         {
1425           fprintf (stderr, "*** Illegal input! ***\n");
1426           num = 3;
1427         }
1428       fprintf (stderr, "\nAudioTriX/WSS DMA set to %d\n", num);
1429       printf ("#define TRIX_DMA %d\n", num);
1430 
1431       fprintf (stderr, "\nSecond (capture) DMA number for AudioTriX?\n"
1432                "Valid values are 0, 1 and 3.\n"
1433                "The default value is 0\n"
1434                "(-1 disables the second DMA)\n"
1435                "Enter the value: ");
1436 
1437       num = ask_value ("%d", 0);
1438       if (num != 0 && num != 1 && num != 3 || num != -1)
1439         {
1440           fprintf (stderr, "*** Illegal input! ***\n");
1441           num = 0;
1442         }
1443       fprintf (stderr, "\nAudioTriX/WSS DMA2 set to %d\n", num);
1444       printf ("#define TRIX_DMA2 %d\n", num);
1445 
1446       fprintf (stderr, "\nSoundBlaster I/O address for the AudioTriX card?\n"
1447                "The factory default is 220\n"
1448           "Other possible values are 200, 210, 230, 240, 250, 260 and 270\n"
1449                "Enter the MSS I/O base: ");
1450 
1451       num = ask_value ("%x", 0x220);
1452       fprintf (stderr, "AudioTriX SB I/O base set to %03x\n", num);
1453       printf ("#define TRIX_SB_BASE 0x%03x\n", num);
1454 
1455       fprintf (stderr, "\nIRQ number for the SB mode of AudioTriX ?\n"
1456                "Valid numbers are: 3, 4, 5 and 7.\n"
1457                "The default value is 7.\n"
1458                "Enter the value: ");
1459 
1460       num = ask_value ("%d", 7);
1461       if (num != 3 && num != 4 && num != 5 && num != 7)
1462         {
1463           fprintf (stderr, "*** Illegal input! ***\n");
1464           num = 7;
1465         }
1466       fprintf (stderr, " AudioTriX SB IRQ set to %d\n", num);
1467       printf ("#define TRIX_SB_IRQ %d\n", num);
1468 
1469       fprintf (stderr, "\nSB DMA number for AudioTriX?\n"
1470                "Valid values are 1 and 3.\n"
1471                "The default value is 1\n"
1472                "Enter the value: ");
1473 
1474       num = ask_value ("%d", 1);
1475       if (num != 1 && num != 3)
1476         {
1477           fprintf (stderr, "*** Illegal input! ***\n");
1478           num = 1;
1479         }
1480       fprintf (stderr, "\nAudioTriX/SB DMA set to %d\n", num);
1481       printf ("#define TRIX_SB_DMA %d\n", num);
1482 
1483       fprintf (stderr, "\nMIDI (MPU-401) I/O address for the AudioTriX card?\n"
1484                "The factory default is 330\n"
1485                "Other possible values are 330, 370, 3B0 and 3F0\n"
1486                "Enter the MPU I/O base: ");
1487 
1488       num = ask_value ("%x", 0x330);
1489       fprintf (stderr, "AudioTriX MIDI I/O base set to %03x\n", num);
1490       printf ("#define TRIX_MPU_BASE 0x%03x\n", num);
1491 
1492       fprintf (stderr, "\nMIDI IRQ number for the AudioTriX ?\n"
1493                "Valid numbers are: 3, 4, 5, 7 and 9(=2).\n"
1494                "The default value is 5.\n"
1495                "Enter the value: ");
1496 
1497       num = ask_value ("%d", 5);
1498       if (num != 3 && num != 4 && num != 5 && num != 7 && num != 9)
1499         {
1500           fprintf (stderr, "*** Illegal input! ***\n");
1501           num = 5;
1502         }
1503       fprintf (stderr, " AudioTriX MIDI IRQ set to %d\n", num);
1504       printf ("#define TRIX_MPU_IRQ %d\n", num);
1505     }
1506 
1507   if (selected_options & B (OPT_CS4232))
1508     {
1509       int             dma1;
1510 
1511       fprintf (stderr, "\nWindows Sound System I/O base for CS4232?\n"
1512                "The factory default is 534\n"
1513                "Other possible values are  608, E84 or F44\n"
1514                "Enter the MSS I/O base: ");
1515 
1516       num = ask_value ("%x", 0x534);
1517       fprintf (stderr, "CS4232 MSS I/O base set to %03x\n", num);
1518       printf ("#define CS4232_BASE 0x%03x\n", num);
1519 
1520       fprintf (stderr, "\nIRQ number for the WSS mode of CS4232 ?\n"
1521                "Valid numbers are: 5, 7, 9(=2), 11, 12 or 15.\n"
1522                "The default value is 11.\n"
1523                "Enter the value: ");
1524 
1525       num = ask_value ("%d", 11);
1526       if (num != 5 && num != 7 && num != 9 && num != 11 && num != 12 || num != 15)
1527         {
1528           fprintf (stderr, "*** Illegal input! ***\n");
1529           num = 11;
1530         }
1531       fprintf (stderr, " CS4232 WSS IRQ set to %d\n", num);
1532       printf ("#define CS4232_IRQ %d\n", num);
1533 
1534       fprintf (stderr, "\nWSS DMA number for CS4232?\n"
1535                "Valid values are 0, 1 and 3.\n"
1536                "The default value is 0\n"
1537                "(select the lowes possible one if you want to\n"
1538                "use full duplex mode)\n"
1539                "Enter the value: ");
1540 
1541       num = ask_value ("%d", 0);
1542       if (num != 0 && num != 1 && num != 3)
1543         {
1544           fprintf (stderr, "*** Illegal input! ***\n");
1545           num = 0;
1546         }
1547       fprintf (stderr, "\nCS4232/WSS DMA set to %d\n", num);
1548       printf ("#define CS4232_DMA %d\n", num);
1549       dma1 = num;
1550 
1551       fprintf (stderr, "\n Second WSS DMA number for CS4232?\n"
1552                "Valid values are 0, 1 and 3.\n"
1553                "The default value is 3\n"
1554                "Enter the value (-1 disables duplex mode): ");
1555 
1556       num = ask_value ("%d", 3);
1557       if (num == dma1 || (num != -1 && num != 0 && num != 1 && num != 3))
1558         {
1559           fprintf (stderr, "*** Illegal input! ***\n");
1560           num = 3;
1561         }
1562       fprintf (stderr, "\nCS4232/WSS DMA2 set to %d\n", num);
1563       printf ("#define CS4232_DMA2 %d\n", num);
1564 
1565       fprintf (stderr, "\nMIDI (MPU-401) I/O address for the CS4232 card?\n"
1566                "The factory default is 330\n"
1567                "Other possible values are 330, 370, 3B0 and 3F0\n"
1568                "Enter the MPU I/O base: ");
1569 
1570       num = ask_value ("%x", 0x330);
1571       fprintf (stderr, "CS4232 MIDI I/O base set to %03x\n", num);
1572       printf ("#define CS4232_MPU_BASE 0x%03x\n", num);
1573 
1574       fprintf (stderr, "\nMIDI IRQ number for CS4232?\n"
1575                "Valid numbers are: 5, 7, 9(=2), 11, 12 or 15.\n"
1576                "The default value is 5.\n"
1577                "Enter the value: ");
1578 
1579       num = ask_value ("%d", 5);
1580       if (num != 5 && num != 7 && num != 9 && num != 11 && num != 12 || num != 15)
1581         {
1582           fprintf (stderr, "*** Illegal input! ***\n");
1583           num = 5;
1584         }
1585       fprintf (stderr, " CS4232 MIDI IRQ set to %d\n", num);
1586       printf ("#define CS4232_MPU_IRQ %d\n", num);
1587     }
1588 
1589   if (selected_options & B (OPT_MAD16))
1590     {
1591       fprintf (stderr, "\n*** Options for the MAD16 and Mozart based cards ***\n\n");
1592 
1593       fprintf (stderr, "\nWindows Sound System I/O base for the MAD16/Mozart card?\n"
1594                "The factory default is 530\n"
1595                "Other possible values are  604, E80 or F40\n"
1596                "(Check which ones are supported by your card!!!!!!)\n"
1597                "Enter the MSS I/O base: ");
1598 
1599       num = ask_value ("%x", 0x530);
1600       fprintf (stderr, "MAD16 MSS I/O base set to %03x\n", num);
1601       printf ("#define MAD16_BASE 0x%03x\n", num);
1602 
1603       if ((sb_base == 0x220 && (num == 0x530 || num == 0x480)) ||
1604           (sb_base == 0x240 && (num == 0xf40 || num == 0x604)))
1605         {
1606           fprintf (stderr, "FATAL ERROR!!!!!!!!!!!!!!\n"
1607                    "\tThis I/O port selection makes MAD16/Mozart\n"
1608                    "\tto use 0x%03x as the SB port.\n"
1609                    "\tThis conflicts with the true SB card.\n"
1610                    "\tRun the config again and select another I/O base.\n",
1611                    sb_base);
1612           printf ("#undef CONFIGURE_SOUNDCARD\n");
1613           printf ("#undef KERNEL_SOUNDCARD\n");
1614           exit (-1);
1615         }
1616 
1617       fprintf (stderr, "\nIRQ number for the WSS mode of MAD16/Mozart ?\n"
1618                "Valid numbers are: 7, 9(=2), 10 and 11.\n"
1619                "The default value is 11.\n"
1620                "Enter the value: ");
1621 
1622       num = ask_value ("%d", 11);
1623       if (num != 7 && num != 9 && num != 10 && num != 11)
1624         {
1625           fprintf (stderr, "*** Illegal input! ***\n");
1626           num = 11;
1627         }
1628       fprintf (stderr, " MAD16 WSS IRQ set to %d\n", num);
1629       printf ("#define MAD16_IRQ %d\n", num);
1630 
1631       fprintf (stderr, "\nWSS DMA (playback) number for MAD16/Mozart?\n"
1632                "Valid values are 0, 1 and 3.\n"
1633                "The default value is 3\n"
1634                "Enter the value: ");
1635 
1636       num = ask_value ("%d", 3);
1637       if (num != 0 && num != 1 && num != 3)
1638         {
1639           fprintf (stderr, "*** Illegal input! ***\n");
1640           num = 3;
1641         }
1642       fprintf (stderr, "\nMAD16/WSS DMA set to %d\n", num);
1643       printf ("#define MAD16_DMA %d\n", num);
1644 
1645       num = (num == 0) ? 1 : 0;
1646 
1647       fprintf (stderr, "\nMAD16/Mozart supports full duplex mode if the\n"
1648                "card has a suitable codec chip (CS423x or AD1845).\n"
1649                "This mode requires another DMA channel (DMA%d)\n"
1650                "Do you want to enable this mode? (n/y)", num);
1651 
1652       if (think_positively (0))
1653         {
1654           fprintf (stderr, "\nMAD16/WSS capture DMA set to %d\n", num);
1655           printf ("#define MAD16_DMA2 %d\n", num);
1656         }
1657       else
1658         printf ("#define MAD16_DMA2 -1\n");
1659 
1660 
1661       fprintf (stderr, "\nMIDI (MPU-401/SB) I/O address for the MAD16 card?\n"
1662                "(This is the second MIDI port in TB Tropez)\n"
1663                "Other possible values are 330, 320, 310 and 300\n"
1664                "For 82C928 and Mozart you may use any nonzero value\n"
1665                "since the driver ignores this setting.\n"
1666                "The factory default is 330 (use 0 to disable)\n"
1667                "Enter the MIDI I/O base: ");
1668 
1669       num = ask_value ("%x", 0x330);
1670       if (num == 0)
1671         fprintf (stderr, "MAD16/Mozart MIDI port disabled\n");
1672       else
1673         {
1674           fprintf (stderr, "MAD16 MIDI I/O base set to %03x\n", num);
1675           printf ("#define MAD16_MPU_BASE 0x%03x\n", num);
1676 
1677           fprintf (stderr, "\nMIDI IRQ number for the MAD16 ?\n"
1678                    "Valid numbers are: 5, 7, 9(=2) and 10.\n"
1679                    "The default value is 5.\n"
1680                    "Enter the value: ");
1681 
1682           num = ask_value ("%d", 5);
1683           if (num != 3 && num != 4 && num != 5 && num != 7 && num != 9)
1684             {
1685               fprintf (stderr, "*** Illegal input! ***\n");
1686               num = 5;
1687             }
1688           fprintf (stderr, " MAD16 MIDI IRQ set to %d\n", num);
1689           printf ("#define MAD16_MPU_IRQ %d\n", num);
1690         }
1691     }
1692 
1693   if (selected_options & B (OPT_AUDIO))
1694     {
1695       def_size = 65536;
1696 
1697       fprintf (stderr, "\nSelect the DMA buffer size (4096, 16384, 32768 or 65536 bytes)\n"
1698                "%d is recommended value for this configuration.\n"
1699                "Enter the value: ", def_size);
1700 
1701       num = ask_value ("%d", def_size);
1702       if (num != 4096 && num != 16384 && num != 32768 && num != 65536)
1703         {
1704 
1705           fprintf (stderr, "*** Illegal input! ***\n");
1706           num = def_size;
1707         }
1708       fprintf (stderr, "The DMA buffer size set to %d\n", num);
1709       printf ("#define DSP_BUFFSIZE %d\n", num);
1710     }
1711 
1712   printf ("#define SELECTED_SOUND_OPTIONS\t0x%08x\n", selected_options);
1713   fprintf (stderr, "The sound driver is now configured.\n");
1714 
1715 #if defined(SCO) || defined(ISC) || defined(SYSV)
1716   fprintf (stderr, "Remember to update the System file\n");
1717 #endif
1718 
1719   if (!old_config_used)
1720     {
1721       fprintf (stderr, "Save copy of this configuration to %s (y/n)", oldconf);
1722       if (think_positively (1))
1723         {
1724           char            cmd[200];
1725 
1726           sprintf (cmd, "cp local.h %s", oldconf);
1727 
1728           fclose (stdout);
1729           if (system (cmd) != 0)
1730             perror (cmd);
1731         }
1732     }
1733   exit (0);
1734 }
1735 
1736 int
1737 bin2hex (char *path, char *target, char *varname)
     /* [previous][next][first][last][top][bottom][index][help] */
1738 {
1739   int             fd;
1740   int             count;
1741   char            c;
1742   int             i = 0;
1743 
1744   if ((fd = open (path, 0)) > 0)
1745     {
1746       FILE           *sf = fopen (target, "w");
1747 
1748       fprintf (sf, "/* automaticaly generated by configure */\n");
1749       fprintf (sf, "static unsigned char %s[] = {\n", varname);
1750       while (1)
1751         {
1752           count = read (fd, &c, 1);
1753           if (count == 0)
1754             break;
1755           if (i != 0 && (i % 10) == 0)
1756             fprintf (sf, "\n");
1757           fprintf (sf, "0x%02x,", c & 0xFFL);
1758           i++;
1759         }
1760       fprintf (sf, "};\n"
1761                "#define %sLen %d\n", varname, i);
1762       fclose (sf);
1763       close (fd);
1764       return 1;
1765     }
1766 
1767   return 0;
1768 }

/* [previous][next][first][last][top][bottom][index][help] */