OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [sound/] [configure.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.