suppressed -enable-audio and simplified -soundhw option handling (malc)
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 18 Dec 2005 20:34:32 +0000 (20:34 +0000)
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 18 Dec 2005 20:34:32 +0000 (20:34 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1725 c046a42c-6fe2-441c-8c8c-71466251a162

hw/pc.c
qemu-doc.texi
vl.c
vl.h

diff --git a/hw/pc.c b/hw/pc.c
index 41cfdcf..8e750b6 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -574,6 +574,38 @@ static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
 static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
 static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
 
+#ifdef HAS_AUDIO
+static void audio_init (PCIBus *pci_bus)
+{
+    struct soundhw *c;
+    int audio_enabled = 0;
+
+    for (c = soundhw; !audio_enabled && c->name; ++c) {
+        audio_enabled = c->enabled;
+    }
+
+    if (audio_enabled) {
+        AudioState *s;
+
+        s = AUD_init ();
+        if (s) {
+            for (c = soundhw; c->name; ++c) {
+                if (c->enabled) {
+                    if (c->isa) {
+                        c->init.init_isa (s);
+                    }
+                    else {
+                        if (pci_bus) {
+                            c->init.init_pci (pci_bus, s);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+#endif
+
 /* PC hardware initialisation */
 static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
@@ -789,26 +821,9 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
 
     kbd_init();
     DMA_init(0);
-
-    if (audio_enabled) {
-        AudioState *audio;
-
-        audio = AUD_init();
-        if (audio) {
-            if (sb16_enabled)
-                SB16_init (audio);
-#ifdef CONFIG_ADLIB
-            if (adlib_enabled)
-                Adlib_init (audio);
-#endif
-#ifdef CONFIG_GUS
-            if (gus_enabled)
-                GUS_init (audio);
+#ifdef HAS_AUDIO
+    audio_init(pci_enabled ? pci_bus : NULL);
 #endif
-            if (pci_enabled && es1370_enabled)
-                es1370_init (pci_bus, audio);
-        }
-    }
 
     floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
 
index 244781e..94d6fbd 100644 (file)
@@ -201,16 +201,12 @@ de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
 
 The default is @code{en-us}.
 
-@item -enable-audio
-
-Will enable audio and all the sound hardware QEMU was built with.
-
 @item -audio-help
 
 Will show the audio subsystem help: list of drivers, tunable
 parameters.
 
-@item -soundhw card1,card2,...
+@item -soundhw card1,card2,... or -soundhw all
 
 Enable audio and selected sound hardware. Use ? to print all
 available sound hardware.
@@ -218,6 +214,7 @@ available sound hardware.
 @example
 qemu -soundhw sb16,adlib hda
 qemu -soundhw es1370 hda
+qemu -soundhw all hda
 qemu -soundhw ?
 @end example
 
diff --git a/vl.c b/vl.c
index 6f01077..70da053 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -124,13 +124,6 @@ int nb_nics;
 NICInfo nd_table[MAX_NICS];
 QEMUTimer *gui_timer;
 int vm_running;
-#ifdef HAS_AUDIO
-int audio_enabled = 0;
-int sb16_enabled = 0;
-int adlib_enabled = 0;
-int gus_enabled = 0;
-int es1370_enabled = 0;
-#endif
 int rtc_utc = 1;
 int cirrus_vga_enabled = 1;
 #ifdef TARGET_SPARC
@@ -3977,11 +3970,11 @@ void help(void)
           "-k language     use keyboard layout (for example \"fr\" for French)\n"
 #endif
 #ifdef HAS_AUDIO
-           "-enable-audio   enable audio support, and all the sound cards\n"
            "-audio-help     print list of audio drivers and their options\n"
            "-soundhw c1,... enable audio support\n"
            "                and only specified sound cards (comma separated list)\n"
            "                use -soundhw ? to get the list of supported cards\n"
+           "                use -soundhw all to enable all of them\n"
 #endif
            "-localtime      set the real time clock to local time [default=utc]\n"
            "-full-screen    start in full screen\n"
@@ -4097,7 +4090,6 @@ enum {
     QEMU_OPTION_m,
     QEMU_OPTION_nographic,
 #ifdef HAS_AUDIO
-    QEMU_OPTION_enable_audio,
     QEMU_OPTION_audio_help,
     QEMU_OPTION_soundhw,
 #endif
@@ -4159,7 +4151,6 @@ const QEMUOption qemu_options[] = {
     { "nographic", 0, QEMU_OPTION_nographic },
     { "k", HAS_ARG, QEMU_OPTION_k },
 #ifdef HAS_AUDIO
-    { "enable-audio", 0, QEMU_OPTION_enable_audio },
     { "audio-help", 0, QEMU_OPTION_audio_help },
     { "soundhw", HAS_ARG, QEMU_OPTION_soundhw },
 #endif
@@ -4280,58 +4271,90 @@ void register_machines(void)
 }
 
 #ifdef HAS_AUDIO
-static void select_soundhw (const char *optarg)
-{
-    if (*optarg == '?') {
-    show_valid_cards:
-        printf ("Valid sound card names (comma separated):\n");
-        printf ("sb16       Creative Sound Blaster 16\n");
+struct soundhw soundhw[] = {
+    {
+        "sb16",
+        "Creative Sound Blaster 16",
+        0,
+        1,
+        { .init_isa = SB16_init }
+    },
+
 #ifdef CONFIG_ADLIB
+    {
+        "adlib",
 #ifdef HAS_YMF262
-        printf ("adlib      Yamaha YMF262 (OPL3)\n");
+        "Yamaha YMF262 (OPL3)",
 #else
-        printf ("adlib      Yamaha YM3812 (OPL2)\n");
+        "Yamaha YM3812 (OPL2)",
 #endif
+        0,
+        1,
+        { .init_isa = Adlib_init }
+    },
 #endif
+
 #ifdef CONFIG_GUS
-        printf ("gus        Gravis Ultrasound GF1\n");
+    {
+        "gus",
+        "Gravis Ultrasound GF1",
+        0,
+        1,
+        { .init_isa = GUS_init }
+    },
 #endif
-        printf ("es1370     ENSONIQ AudioPCI ES1370\n");
+
+    {
+        "es1370",
+        "ENSONIQ AudioPCI ES1370",
+        0,
+        0,
+        { .init_pci = es1370_init }
+    },
+
+    { NULL, NULL, 0, 0, { NULL } }
+};
+
+static void select_soundhw (const char *optarg)
+{
+    struct soundhw *c;
+
+    if (*optarg == '?') {
+    show_valid_cards:
+
+        printf ("Valid sound card names (comma separated):\n");
+        for (c = soundhw; c->name; ++c) {
+            printf ("%-11s %s\n", c->name, c->descr);
+        }
+        printf ("\n-soundhw all will enable all of the above\n");
         exit (*optarg != '?');
     }
     else {
-        struct {
-            char *name;
-            int *enabledp;
-        } soundhw_tab[] = {
-            { "sb16", &sb16_enabled },
-#ifdef CONFIG_ADLIB
-            { "adlib", &adlib_enabled },
-#endif
-#ifdef CONFIG_GUS
-            { "gus", &gus_enabled },
-#endif
-            { "es1370", &es1370_enabled },
-        };
-        size_t tablen, l, i;
+        size_t l;
         const char *p;
         char *e;
         int bad_card = 0;
 
-        p = optarg;
-        tablen = sizeof (soundhw_tab) / sizeof (soundhw_tab[0]);
+        if (!strcmp (optarg, "all")) {
+            for (c = soundhw; c->name; ++c) {
+                c->enabled = 1;
+            }
+            return;
+        }
 
+        p = optarg;
         while (*p) {
             e = strchr (p, ',');
             l = !e ? strlen (p) : (size_t) (e - p);
-            for (i = 0; i < tablen; ++i) {
-                if (!strncmp (soundhw_tab[i].name, p, l)) {
-                    audio_enabled = 1;
-                    *soundhw_tab[i].enabledp = 1;
+
+            for (c = soundhw; c->name; ++c) {
+                if (!strncmp (c->name, p, l)) {
+                    c->enabled = 1;
                     break;
                 }
             }
-            if (i == tablen) {
+
+            if (!c->name) {
                 if (l > 80) {
                     fprintf (stderr,
                              "Unknown sound card name (too big to show)\n");
@@ -4592,13 +4615,6 @@ int main(int argc, char **argv)
                 break;
 #endif
 #ifdef HAS_AUDIO
-            case QEMU_OPTION_enable_audio:
-                audio_enabled = 1;
-                sb16_enabled = 1;
-                adlib_enabled = 1;
-                gus_enabled = 1;
-                es1370_enabled = 1;
-                break;
             case QEMU_OPTION_audio_help:
                 AUD_help ();
                 exit (0);
diff --git a/vl.h b/vl.h
index fbac807..7a10728 100644 (file)
--- a/vl.h
+++ b/vl.h
@@ -126,11 +126,6 @@ void qemu_system_powerdown(void);
 
 void main_loop_wait(int timeout);
 
-extern int audio_enabled;
-extern int sb16_enabled;
-extern int adlib_enabled;
-extern int gus_enabled;
-extern int es1370_enabled;
 extern int ram_size;
 extern int bios_size;
 extern int rtc_utc;
@@ -621,6 +616,21 @@ typedef struct HeathrowPICS HeathrowPICS;
 void heathrow_pic_set_irq(void *opaque, int num, int level);
 HeathrowPICS *heathrow_pic_init(int *pmem_index);
 
+#ifdef HAS_AUDIO
+struct soundhw {
+    const char *name;
+    const char *descr;
+    int enabled;
+    int isa;
+    union {
+        int (*init_isa) (AudioState *s);
+        int (*init_pci) (PCIBus *bus, AudioState *s);
+    } init;
+};
+
+extern struct soundhw soundhw[];
+#endif
+
 /* vga.c */
 
 #define VGA_RAM_SIZE (4096 * 1024)