~ubuntu-branches/ubuntu/vivid/oss4/vivid

« back to all changes in this revision

Viewing changes to .pc/os_cmd.patch/os_cmd/Linux/ossdetect/ossdetect.c

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis, Samuel Thibault, Romain Beauxis, Sebastien NOEL
  • Date: 2011-06-14 10:06:56 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110614100656-cx4oc7u426zn812z
Tags: 4.2-build2004-1
[ Samuel Thibault ]
* debian/control: Add liboss4-salsa2, liboss4-salsa-dev and
  liboss4-salsa-asound2 packages, equivalent to (and will replace) those from
  the oss-libsalsa package (Closes: #589127).
* debian/patches/liboss4-salsa.patch: New patch to rename libsalsa into
  liboss4-salsa to avoid conflicts in the archive for no good reason.
* debian/rules: Make in libOSSlib and libsalsa.
* debian/liboss4-salsa-dev.install, debian/liboss4-salsa2.install,
  debian/liboss4-salsa-asound2.links, debian/liboss4-salsa-dev.links:
  Install liboss4-salsa libraries like was done in the oss-libsalsa package.
* include-alsa: Add a copy of ALSA 1.0.5 headers: Cf ALSA_1.0.* symbols in
  libsalsa, this is the roughly supported version.
* debian/copyright: Update for new include-alsa files.
* alsa.pc: New file for compatibility with libasound-dev.
* debian/control:
  - Add Vcs-Browser and Vcs-Svn fields.
  - Use linux-any instead of the list of Linux archs (Closes: #604679).
  - Make dkms dependency linux-any only.
* debian/patches/hurd_iot.patch: New patch to fix soundcard.h usage in
  libsalsa on hurd-i386.
* debian/patches/libsalsa_fixes.patch: New patch to fix some printf usages
  and ioctl declaration in libsalsa.
* debian/patches/no_EBADE.patch: New patch to cope with hurd-i386 not having
  EBADE.
* debian/patches/CFLAGS.patch: New patch to make oss4 take debian/rules
  CFLAGS into account.
* debian/patches/snd_asoundlib_version.patch: New patch to add
  snd_asoundlib_version().
* debian/patches/generic_srccconf.patch: New patch to fix source
  configuration on unknown archs.

[ Romain Beauxis ]
* Fixed README.Debian to only mention dkms' modules.
* Switch to dpkg-source 3.0 (quilt) format
* Added DM-Upload-Allowed: yes

[ Sebastien NOEL ]
* New upstream release (Closes: #595298, #619272).
* Fix typo in initscript (Closes: #627149).
* debian/control: adjust linux-headers dependencies (Closes: #628879).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Purpose: OSS device autodetection utility for Linux
 
3
 *
 
4
 */
 
5
/*
 
6
 *
 
7
 * This file is part of Open Sound System.
 
8
 *
 
9
 * Copyright (C) 4Front Technologies 1996-2008.
 
10
 *
 
11
 * This this source file is released under GPL v2 license (no other versions).
 
12
 * See the COPYING file included in the main directory of this source
 
13
 * distribution for the license terms and conditions.
 
14
 *
 
15
 */
 
16
 
 
17
#include <errno.h>
 
18
#include <fcntl.h>
 
19
#include <stdio.h>
 
20
#include <stdlib.h>
 
21
#include <string.h>
 
22
#include <unistd.h>
 
23
#include <sys/types.h>
 
24
#include <sys/stat.h>
 
25
#include <sys/dir.h>
 
26
 
 
27
#define PCI_PASS        0
 
28
#define USB_PASS        1
 
29
#define PSEUDO_PASS     2
 
30
#define MAX_PASS        3
 
31
 
 
32
#define OSSLIBDIRLEN 512
 
33
static char *osslibdir = NULL;
 
34
 
 
35
static int usb_ok = 0;
 
36
 
 
37
static int verbose = 0;
 
38
 
 
39
typedef struct
 
40
{
 
41
  char *key, *driver, *name;
 
42
  int is_3rdparty;
 
43
  int detected;
 
44
  int pass;
 
45
} driver_def_t;
 
46
 
 
47
typedef struct drv_slist
 
48
{
 
49
  const char * drv_name;
 
50
  struct drv_slist * next;
 
51
} drvlist_t;
 
52
static drvlist_t * drvl = NULL;
 
53
 
 
54
#define MAX_DRIVERS     1000
 
55
static driver_def_t drivers[MAX_DRIVERS];
 
56
static int ndrivers = 0;
 
57
 
 
58
static int add_drv (const char *, int);
 
59
static int decode_descriptor (unsigned char *, int);
 
60
static void create_devlinks (mode_t);
 
61
static char * get_mapname (void);
 
62
static unsigned short get_uint16 (unsigned char *);
 
63
static int is_audio (unsigned char *, int);
 
64
static void load_license (const char *);
 
65
static void load_devlist (const char *, int);
 
66
static void pci_checkdevice (char *);
 
67
static void pci_detect (char *);
 
68
static drvlist_t * prepend_drvlist (const char *);
 
69
static int remove_devlinks (const char *);
 
70
static void usb_checkdevice (char *);
 
71
static void usb_scandir (char *);
 
72
static void usb_detect (void);
 
73
 
 
74
static char *
 
75
get_mapname (void)
 
76
{
 
77
  FILE *f;
 
78
  static char name[OSSLIBDIRLEN], tmp[OSSLIBDIRLEN+11];
 
79
  struct stat st;
 
80
 
 
81
  if ((f = fopen ("/etc/oss.conf", "r")) == NULL)
 
82
    {
 
83
      perror ("/etc/oss.conf");
 
84
      goto oexit2;
 
85
    }
 
86
 
 
87
  while (fgets (tmp, sizeof (tmp), f) != NULL)
 
88
    {
 
89
      int l = strlen (tmp);
 
90
      if (l > 0 && tmp[l - 1] == '\n')
 
91
        tmp[l - 1] = '\0';
 
92
 
 
93
      if (strncmp (tmp, "OSSLIBDIR=", 10) == 0)
 
94
        {
 
95
          l = snprintf (name, sizeof (name), "%s", &tmp[10]);
 
96
          if ((l >= OSSLIBDIRLEN) || (l < 0))
 
97
            {
 
98
              fprintf (stderr, "String in /etc/oss.conf is too long!\n");
 
99
              goto oexit;
 
100
            }
 
101
          if ((stat (name, &st) == -1) || !S_ISDIR(st.st_mode))
 
102
            {
 
103
              fprintf (stderr, "Directory %s from /etc/oss.conf cannot "
 
104
                               "be used!\n", name);
 
105
              goto oexit;
 
106
            }
 
107
          fclose (f);
 
108
          return name;
 
109
        }
 
110
    }
 
111
 
 
112
  fprintf (stderr, "OSSLIBDIR not set in /etc/oss.conf, using default "
 
113
                   "/usr/lib/oss\n");
 
114
oexit:
 
115
  fclose (f);
 
116
oexit2:
 
117
  snprintf (name, sizeof (name), "/usr/lib/oss");
 
118
  return name;
 
119
}
 
120
 
 
121
static void
 
122
load_license (const char *fname)
 
123
{
 
124
  struct stat st;
 
125
  char cmd[2*OSSLIBDIRLEN];
 
126
  int n;
 
127
 
 
128
  if (stat (fname, &st) == -1)
 
129
    return;                     /* Doesn't exist */
 
130
 
 
131
  if (stat ("/usr/sbin/osslic", &st) == -1)
 
132
    return;                     /* No osslic utility in the system. No need to install license. */
 
133
 
 
134
  n = snprintf (cmd, sizeof (cmd), "/usr/sbin/osslic -q %s/%s", osslibdir,
 
135
                fname);
 
136
  if (n >= sizeof (cmd) || n < 0) return;
 
137
  if (((n = system (cmd)) == -1))
 
138
    fprintf (stderr, "Cannot run osslic!\n");
 
139
}
 
140
 
 
141
static void
 
142
load_devlist (const char *fname, int is_3rdparty)
 
143
{
 
144
  FILE *f;
 
145
  char line[256], *p, rfname[2*OSSLIBDIRLEN];
 
146
  char *driver, *key, *name;
 
147
 
 
148
  snprintf (rfname, sizeof (rfname), "%s/%s", osslibdir, fname);
 
149
 
 
150
  if ((f = fopen (rfname, "r")) == NULL)
 
151
    {
 
152
      perror (rfname);
 
153
      exit (-1);
 
154
    }
 
155
 
 
156
  while (fgets (line, sizeof (line), f) != NULL)
 
157
    {
 
158
      p = line;
 
159
      while (*p)
 
160
        {
 
161
          if (*p == '#' || *p == '\n')
 
162
            *p = '\0';
 
163
          p++;
 
164
        }
 
165
 
 
166
      /* Drivers with upper case names are unsupported ones */
 
167
      if ((*line >= 'A' && *line <= 'Z') || (*line == '\0'))
 
168
        continue;
 
169
 
 
170
      driver = line;
 
171
      p = line;
 
172
 
 
173
      while (*p && *p != '\t' && *p != ' ')
 
174
        p++;
 
175
      if (*p)
 
176
        *p++ = 0;
 
177
      key = p;
 
178
 
 
179
      while (*p && *p != '\t')
 
180
        p++;
 
181
      if (*p)
 
182
        *p++ = 0;
 
183
      name = p;
 
184
 
 
185
      if (verbose > 1)
 
186
        printf ("device=%s, name=%s, driver=%s\n", key, name, driver);
 
187
 
 
188
      if (ndrivers >= MAX_DRIVERS)
 
189
        {
 
190
          printf ("Too many drivers defined in drivers.list\n");
 
191
          exit (-1);
 
192
        }
 
193
 
 
194
      drivers[ndrivers].key = strdup (key);
 
195
      drivers[ndrivers].driver = strdup (driver);
 
196
      drivers[ndrivers].name = strdup (name);
 
197
      drivers[ndrivers].is_3rdparty = is_3rdparty;
 
198
      drivers[ndrivers].detected = 0;
 
199
 
 
200
      ndrivers++;
 
201
    }
 
202
 
 
203
  fclose (f);
 
204
}
 
205
 
 
206
static int
 
207
add_drv (const char * id, int pass)
 
208
{
 
209
  int i;
 
210
 
 
211
  for (i = 0; i < ndrivers; i++)
 
212
    {
 
213
      if (strcmp (id, drivers[i].key) == 0)
 
214
        {
 
215
          if (verbose > 0)
 
216
            printf ("Detected %s\n", drivers[i].name);
 
217
          drivers[i].detected = 1;
 
218
          drivers[i].pass = pass;
 
219
          return 1;
 
220
        }
 
221
    }
 
222
 
 
223
  return 0;
 
224
}
 
225
 
 
226
static unsigned short
 
227
get_uint16 (unsigned char *p)
 
228
{
 
229
  return *p + (p[1] << 8);
 
230
}
 
231
 
 
232
static int
 
233
decode_descriptor (unsigned char *d, int desclen)
 
234
{
 
235
  switch (d[1])
 
236
    {
 
237
    case 0x04:
 
238
      if (d[5] == 1)            // Audio
 
239
        return 1;
 
240
      break;
 
241
    }
 
242
 
 
243
  return 0;
 
244
}
 
245
 
 
246
static int
 
247
is_audio (unsigned char *desc, int datalen)
 
248
{
 
249
  int l, pos, desclen;
 
250
 
 
251
  if (desc[0] == 9 && desc[1] == 2)     /* Config descriptor */
 
252
    {
 
253
      l = get_uint16 (desc + 2);
 
254
 
 
255
      if (datalen > l)
 
256
        datalen = l;
 
257
    }
 
258
 
 
259
  pos = 0;
 
260
 
 
261
  while (pos < datalen)
 
262
    {
 
263
      unsigned char *d;
 
264
      desclen = desc[pos];
 
265
 
 
266
      if (desclen < 2 || desclen > (datalen - pos))
 
267
        {
 
268
          return 0;
 
269
        }
 
270
 
 
271
      d = &desc[pos];
 
272
      if (decode_descriptor (d, desclen))
 
273
        return 1;
 
274
      pos += desclen;
 
275
    }
 
276
 
 
277
  return 0;
 
278
}
 
279
 
 
280
static void
 
281
usb_checkdevice (char *fname)
 
282
{
 
283
  int fd, l;
 
284
  unsigned char buf[4096];
 
285
  char tmp[64];
 
286
  int vendor, device;
 
287
 
 
288
  if ((fd = open (fname, O_RDONLY, 0)) == -1)
 
289
    {
 
290
      perror (fname);
 
291
      return;
 
292
    }
 
293
 
 
294
  if ((l = read (fd, buf, sizeof (buf))) == -1)
 
295
    {
 
296
      perror (fname);
 
297
      return;
 
298
    }
 
299
 
 
300
  close (fd);
 
301
 
 
302
  if (l < 12 || buf[1] != 1)
 
303
    return;
 
304
 
 
305
  vendor = buf[8] | (buf[9] << 8);
 
306
  device = buf[10] | (buf[11] << 8);
 
307
 
 
308
  sprintf (tmp, "usb%x,%x", vendor, device);
 
309
  if (add_drv (tmp, USB_PASS))
 
310
    return;
 
311
 
 
312
  sprintf (tmp, "usbif%x,%x", vendor, device);
 
313
  if (add_drv (tmp, USB_PASS))
 
314
    return;
 
315
 
 
316
  if (is_audio (buf, l))        /* USB audio class */
 
317
    {
 
318
      if (add_drv ("usbif,class1", USB_PASS))
 
319
        return;
 
320
    }
 
321
}
 
322
 
 
323
static void
 
324
usb_scandir (char *dirname)
 
325
{
 
326
  char path[PATH_MAX];
 
327
  DIR *dr;
 
328
  struct dirent *de;
 
329
  struct stat st;
 
330
 
 
331
  if ((dr = opendir (dirname)) == NULL)
 
332
    {
 
333
      return;
 
334
    }
 
335
 
 
336
  while ((de = readdir (dr)) != NULL)
 
337
    {
 
338
      if (de->d_name[0] < '0' || de->d_name[0] > '9')   /* Ignore non-numeric names */
 
339
        continue;
 
340
 
 
341
      snprintf (path, sizeof (path), "%s/%s", dirname, de->d_name);
 
342
 
 
343
      if (stat (path, &st) == -1)
 
344
        continue;
 
345
 
 
346
      if (S_ISDIR (st.st_mode))
 
347
        {
 
348
          usb_scandir (path);
 
349
          continue;
 
350
        }
 
351
 
 
352
      usb_checkdevice (path);
 
353
    }
 
354
 
 
355
  closedir (dr);
 
356
}
 
357
 
 
358
static void
 
359
usb_detect (void)
 
360
{
 
361
  struct stat st;
 
362
#if 0
 
363
  char path[OSSLIBDIRLEN + 25];
 
364
 
 
365
  sprintf (path, "%s/modules/oss_usb.o", osslibdir);
 
366
 
 
367
  if (stat (path, &st) == -1)   /* USB module not available */
 
368
    {
 
369
      fprintf (stderr, "USB module not available, aborting USB detect\n");
 
370
      return;
 
371
    }
 
372
#endif
 
373
 
 
374
  if (stat ("/dev/bus/usb", &st) != -1)
 
375
    {
 
376
      usb_ok = 1;
 
377
      usb_scandir ("/dev/bus/usb");
 
378
    }
 
379
  else if (stat ("/proc/bus/usb", &st) != -1)
 
380
    {
 
381
      usb_ok = 1;
 
382
      usb_scandir ("/proc/bus/usb");
 
383
    }
 
384
}
 
385
 
 
386
static void
 
387
pci_checkdevice (char *path)
 
388
{
 
389
  unsigned char buf[256];
 
390
  char id[32];
 
391
  int fd;
 
392
  int vendor, device;
 
393
  int subvendor, subdevice;
 
394
 
 
395
  if ((fd = open (path, O_RDONLY, 0)) == -1)
 
396
    {
 
397
      perror (path);
 
398
      return;
 
399
    }
 
400
 
 
401
  if (read (fd, buf, sizeof (buf)) != sizeof (buf))
 
402
    {
 
403
      perror (path);
 
404
      close (fd);
 
405
      return;
 
406
    }
 
407
  close (fd);
 
408
  vendor = buf[0] | (buf[1] << 8);
 
409
  device = buf[2] | (buf[3] << 8);
 
410
  subvendor = buf[0x2c] | (buf[0x2d] << 8);
 
411
  subdevice = buf[0x2e] | (buf[0x2f] << 8);
 
412
  sprintf (id, "pcs%x,%x", subvendor, subdevice);
 
413
  if (add_drv (id, PCI_PASS))
 
414
    return;
 
415
  sprintf (id, "pci%x,%x", vendor, device);
 
416
  add_drv (id, PCI_PASS);
 
417
}
 
418
 
 
419
static void
 
420
pci_detect (char *dirname)
 
421
{
 
422
  char path[PATH_MAX];
 
423
  DIR *dr;
 
424
  struct dirent *de;
 
425
  struct stat st;
 
426
 
 
427
  if (dirname == NULL)
 
428
    {
 
429
      dirname = "/proc/bus/pci";
 
430
    }
 
431
 
 
432
  if ((dr = opendir (dirname)) == NULL)
 
433
    {
 
434
      return;
 
435
    }
 
436
 
 
437
  while ((de = readdir (dr)) != NULL)
 
438
    {
 
439
      if (de->d_name[0] < '0' || de->d_name[0] > '9')   /* Ignore non-numeric names */
 
440
        continue;
 
441
 
 
442
      snprintf (path, sizeof (path), "%s/%s", dirname, de->d_name);
 
443
 
 
444
      if (stat (path, &st) == -1)
 
445
        continue;
 
446
 
 
447
      if (S_ISDIR (st.st_mode))
 
448
        {
 
449
          pci_detect (path);
 
450
          continue;
 
451
        }
 
452
 
 
453
      pci_checkdevice (path);
 
454
    }
 
455
 
 
456
  closedir (dr);
 
457
}
 
458
 
 
459
static int
 
460
remove_devlinks (const char * dirname)
 
461
{
 
462
  char path[PATH_MAX];
 
463
  DIR * dr;
 
464
  struct dirent * de;
 
465
  struct stat st;
 
466
 
 
467
  if ((dr = opendir (dirname)) == NULL)
 
468
    {
 
469
      if (errno == ENONET) return 0;
 
470
      perror ("opendir");
 
471
      return -1;
 
472
    }
 
473
 
 
474
  while ((de = readdir (dr)) != NULL)
 
475
    {
 
476
      if ((!strcmp (de->d_name, ".")) || (!strcmp (de->d_name, ".."))) continue;
 
477
 
 
478
      snprintf (path, sizeof (path), "%s/%s", dirname, de->d_name);
 
479
 
 
480
      if ((stat (path, &st) != -1) && (S_ISDIR (st.st_mode))) remove_devlinks (path);
 
481
      else
 
482
        {
 
483
          if (verbose > 2) fprintf (stderr, "Removing %s\n", path);
 
484
          unlink (path);
 
485
        }
 
486
    }
 
487
 
 
488
  closedir (dr);
 
489
  if (verbose > 2) fprintf (stderr, "Removing %s\n", path);
 
490
  if (rmdir (dirname) == -1)
 
491
    {
 
492
      fprintf (stderr, "Couldn't remove %s\n", path);
 
493
      return -1;
 
494
    }
 
495
  return 0;
 
496
}
 
497
 
 
498
static void
 
499
create_devlinks (mode_t node_m)
 
500
{
 
501
  FILE *f;
 
502
  char line[256], tmp[300], *p, *s;
 
503
  mode_t perm;
 
504
  int minor, major;
 
505
 
 
506
  if ((f = fopen ("/proc/opensound/devfiles", "r")) == NULL)
 
507
    {
 
508
      perror ("/proc/opensound/devfiles");
 
509
      fprintf (stderr, "Cannot connect to the OSS kernel module.\n");
 
510
      fprintf (stderr, "Perhaps you need to execute 'soundon' to load OSS\n");
 
511
      exit (-1);
 
512
    }
 
513
 
 
514
  remove_devlinks ("/dev/oss");
 
515
  perm = umask (0);
 
516
  mkdir ("/dev/oss", 0755);
 
517
 
 
518
  while (fgets (line, sizeof (line), f) != NULL)
 
519
    {
 
520
      char dev[64] = "/dev/";
 
521
 
 
522
      s = strchr (line, '\n');
 
523
      if (s) *s = '\0';
 
524
 
 
525
      if (sscanf (line, "%s %d %d", dev + 5, &major, &minor) != 3)
 
526
        {
 
527
          fprintf (stderr, "Syntax error in /proc/opensound/devfiles\n");
 
528
          fprintf (stderr, "%s\n", line);
 
529
          exit (-1);
 
530
        }
 
531
 
 
532
/*
 
533
 * Check if the device is located in a subdirectory (say /dev/oss/sblive0/pcm0).
 
534
 */
 
535
      strcpy (tmp, dev);
 
536
 
 
537
      s = tmp + 5;
 
538
      p = s;
 
539
      while (*s)
 
540
        {
 
541
          if (*s == '/')
 
542
            p = s;
 
543
          s++;
 
544
        }
 
545
 
 
546
      if (*p == '/')
 
547
        {
 
548
          *p = 0;               /* Extract the directory name part */
 
549
          mkdir (tmp, 0755);
 
550
        }
 
551
 
 
552
      unlink (dev);
 
553
      if (verbose)
 
554
        printf ("mknod %s c %d %d -m %o\n", dev, major, minor, node_m);
 
555
      if (mknod (dev, node_m, makedev (major, minor)) == -1)
 
556
        perror (dev);
 
557
    }
 
558
 
 
559
  umask (perm);
 
560
  fclose (f);
 
561
}
 
562
 
 
563
static drvlist_t *
 
564
prepend_drvlist (const char * name)
 
565
{
 
566
  drvlist_t * dp;
 
567
 
 
568
  dp = malloc (sizeof (drvlist_t));
 
569
  if (dp == NULL)
 
570
    {
 
571
      fprintf (stderr, "Can't allocate memory!\n");
 
572
      exit (-1);
 
573
    }
 
574
 
 
575
  dp->drv_name = name;
 
576
  dp->next = drvl;
 
577
  return dp;
 
578
}
 
579
 
 
580
int
 
581
main (int argc, char *argv[])
 
582
{
 
583
  char instfname[2*OSSLIBDIRLEN], *p;
 
584
  int i, do_license = 0, make_devs = 0, pass;
 
585
  mode_t node_m = S_IFCHR | 0666;
 
586
  struct stat st;
 
587
  FILE *f;
 
588
 
 
589
  while ((i = getopt(argc, argv, "L:a:dilm:uv")) != EOF)
 
590
    switch (i)
 
591
      {
 
592
        case 'v':
 
593
          verbose++;
 
594
          break;
 
595
 
 
596
        case 'd':
 
597
          make_devs = 1;
 
598
          break;
 
599
 
 
600
        case 'i':
 
601
          drvl = prepend_drvlist ("oss_imux");
 
602
          break;
 
603
 
 
604
        case 'u':
 
605
          drvl = prepend_drvlist ("oss_userdev");
 
606
          break;
 
607
 
 
608
        case 'a':
 
609
          drvl = prepend_drvlist (optarg);
 
610
          break;
 
611
 
 
612
        case 'l':
 
613
          do_license = 1;
 
614
          break;
 
615
 
 
616
        case 'L':
 
617
          osslibdir = optarg;
 
618
          break;
 
619
 
 
620
        case 'm':
 
621
          p = optarg;
 
622
          node_m = 0;
 
623
          while ((*p >= '0') && (*p <= '7')) node_m = node_m * 8 + *p++ - '0';
 
624
          if ((*p) || (node_m & ~(S_IRWXU|S_IRWXG|S_IRWXO)))
 
625
            {
 
626
              fprintf (stderr, "Invalid permissions: %s\n", optarg);
 
627
              exit(1);
 
628
            }
 
629
          node_m |= S_IFCHR;
 
630
          break;
 
631
 
 
632
        default:
 
633
          fprintf (stderr, "%s: bad usage\n", argv[0]);
 
634
          exit (-1);
 
635
      }
 
636
 
 
637
  if (osslibdir == NULL) osslibdir = get_mapname ();
 
638
 
 
639
  if (make_devs == 1)
 
640
    {
 
641
      create_devlinks (node_m);
 
642
      exit (0);
 
643
    }
 
644
 
 
645
  if (do_license == 1)
 
646
    {
 
647
      load_license ("etc/license.asc");
 
648
      exit (0);
 
649
    }
 
650
 
 
651
  load_devlist ("etc/devices.list", 0);
 
652
 
 
653
  if (stat ("/etc/oss_3rdparty", &st) != -1)
 
654
    load_devlist ("/etc/oss_3rdparty", 1);
 
655
 
 
656
  pci_detect (NULL);
 
657
  usb_detect ();
 
658
 
 
659
  if (usb_ok)
 
660
    {
 
661
      if (verbose)
 
662
        printf ("USB support available in the system, adding USB driver\n");
 
663
      add_drv ("usbif,class1", USB_PASS);
 
664
    }
 
665
  else if (verbose)
 
666
    printf ("No USB support detected in the system - skipping USB\n");
 
667
 
 
668
  while (drvl != NULL)
 
669
    {
 
670
      drvlist_t * d = drvl;
 
671
      add_drv (drvl->drv_name, PSEUDO_PASS);
 
672
      drvl = drvl->next;
 
673
      free (d);
 
674
    }
 
675
 
 
676
  snprintf (instfname, sizeof (instfname), "%s/%s", osslibdir,
 
677
            "etc/installed_drivers");
 
678
 
 
679
  if ((f = fopen (instfname, "w")) == NULL)
 
680
    {
 
681
      perror (instfname);
 
682
      exit (-1);
 
683
    }
 
684
 
 
685
  for (pass = 0; pass < MAX_PASS; pass++)
 
686
    for (i = 0; i < ndrivers; i++)
 
687
      if (drivers[i].pass == pass && drivers[i].detected)
 
688
        {
 
689
          fprintf (f, "%s #%s\n", drivers[i].driver, drivers[i].name);
 
690
        }
 
691
 
 
692
  fclose (f);
 
693
 
 
694
  exit (0);
 
695
}