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

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