summaryrefslogtreecommitdiff
blob: e32094f6ada7f567c1b9aa305d5968fcf162130b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Common subdirectories: hwsetup-1.0.fastprobe/debian and hwsetup-1.0/debian
diff -u hwsetup-1.0.fastprobe/hwsetup.c hwsetup-1.0/hwsetup.c
--- hwsetup-1.0.fastprobe/hwsetup.c	2005-06-10 16:29:24.000000000 -0400
+++ hwsetup-1.0/hwsetup.c	2005-06-10 16:30:40.000000000 -0400
@@ -7,6 +7,7 @@
 \****************************************************************************/
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
@@ -24,7 +25,7 @@
 
 #define VERSION "HWSETUP 1.0, an automatic hardware configuration tool\n" \
                 "(C) 2002 Klaus Knopper <knoppix@knopper.net>\n" \
-                "Modifications (C) 2004 Ren� Rh�aume <rener@mediom.qc.ca>\n"
+                "Modifications (C) 2004,2005 Ren� Rh�aume <rener@mediom.qc.ca>\n"
 
 #define CARDSDB "/usr/share/hwdata/Cards"
 #define XPATH "/usr/X11R6/bin/"
@@ -88,7 +89,8 @@
          "\t\t-a\tignore audio devices\n"
          "\t\t-s\tignore scsi controllers\n"
          "\t\t-n\tprobe only, don't configure anything\n"
-         "\t\t-f\trun a fast probe.");
+         "\t\t-f\trun a fast probe\n"
+         "\t\t-l\ttry to load an ALSA sound module.");
  return option?1:0;
 }
 
@@ -526,10 +528,11 @@
  return 0;
 }
 
-int hw_setup(enum deviceClass dc, int verbose, int probeonly, int skip, int fastprobe)
+int hw_setup(enum deviceClass dc, int verbose, int probeonly, int skip, int fastprobe, int tryalsa)
 {
- int i,mouse=0,cdrom=0,modem=0,scanner=0;
+ int i,mouse=0,cdrom=0,modem=0,scanner=0,alsaok=0;
  int probeopt=fastprobe?PROBE_SAFE:PROBE_ALL;
+ const char *alsadriver=NULL;
  struct device **currentDevs, *d, *serialmouse=NULL, *usbmouse=NULL;
  if(verbose&VERBOSE_PROMPT) wpid=startwheel();
  if((currentDevs=probeDevices(dc,BUS_UNSPEC,probeopt))==NULL) return -1;
@@ -564,8 +567,23 @@
        case CLASS_VIDEO:   writeconfig("/etc/sysconfig/xserver",d,verbose);
                            break;
        case CLASS_AUDIO:   if(skip&SKIP_AUDIO) break;
+                           if(tryalsa)
+                            {
+                             alsaok=0;
+                             asprintf(&alsadriver, "snd-%s", d->driver);
+                             if (load_mod(alsadriver,verbose) == 0)
+                              {
+                               d->driver=alsadriver;
+                               writeconfig("/etc/sysconfig/sound",d,verbose);
+                               alsaok=1;
+                              }
+                            }
+                           if(!alsaok) /* fallback */
+                            {
                            writeconfig("/etc/sysconfig/sound",d,verbose);
                            load_mod(d->driver,verbose); break;
+                            }
+                           break;
        case CLASS_NETWORK: writeconfig("/etc/sysconfig/netcard",d,verbose);
                            load_mod(d->driver,verbose); break;
        case CLASS_FLOPPY:  writeconfig("/etc/sysconfig/floppy",d,verbose);
@@ -581,12 +599,13 @@
       }
     }
   }
+ if(alsadriver!=NULL) free(alsadriver);
  return 0;
 }
 
 int main(int argc, char **argv)
 {
- int i, verbose=0, probeonly=0, skip=0, fast=0;
+ int i, verbose=0, probeonly=0, skip=0, fast=0, alsaaudio=0;
  enum deviceClass dc=CLASS_UNSPEC;
  for(i=1;i<argc;i++)
   {
@@ -596,6 +615,7 @@
    else if(!strcasecmp(argv[i],"-s")) skip|=SKIP_SCSI;
    else if(!strcasecmp(argv[i],"-n")) probeonly=1;
    else if(!strcasecmp(argv[i],"-f")) fast=1;
+   else if(!strcasecmp(argv[i],"-l")) alsaaudio=1;
    else return syntax(argv[i]);
   }
  /* Allow SIGTERM, SIGINT: rmmod depends on this. */
@@ -604,5 +624,5 @@
 #ifdef BLACKLIST
  gen_blacklist();
 #endif
- return hw_setup(dc,verbose,probeonly,skip,fast);
+ return hw_setup(dc,verbose,probeonly,skip,fast,alsaaudio);
 }