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

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