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. ask_int_choice
  5. rebuild_file
  6. use_old_config
  7. build_defines
  8. ask_parameters
  9. dump_script
  10. dump_fixed_local
  11. dump_fixed_defines
  12. main
  13. bin2hex

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

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