Skip to contentSkip to conversation

arch_init: Move soundhw code to hw/audio/soundhw.c

PATCH In review Eduardo Habkost 6 participants 14 messages May 8, 2017 – May 16, 2017

lore
Share & tools
lore
#0 lore raw

v3 cover arch_init: Move soundhw code to hw/audio/soundhw.c

Changes v2 -> v3:
* Build fix: update hw/ppc/prep.c too

Changes v1 -> v2:
* Rebase to latest qemu.git master

This moves the arch_init.c soundhw code to its own file, renames audio_init() to soundhw_init(), and renames hw/audio/audio.h to hw/audio/soundhw.h.

Eduardo Habkost (3):
audio: Move arch_init audio code to hw/audio/soundhw.c
audio: Rename audio_init() to soundhw_init()
audio: Rename hw/audio/audio.h to hw/audio/soundhw.h

 include/hw/audio/{audio.h => soundhw.h} |   3 +
 include/sysemu/arch_init.h              |   2 -
 arch_init.c                             | 126 +-------------------------
 hw/audio/ac97.c                         |   2 +-
 hw/audio/adlib.c                        |   2 +-
 hw/audio/cs4231a.c                      |   2 +-
 hw/audio/es1370.c                       |   2 +-
 hw/audio/gus.c                          |   2 +-
 hw/audio/intel-hda.c                    |   2 +-
 hw/audio/pcspk.c                        |   2 +-
 hw/audio/sb16.c                         |   2 +-
 hw/audio/soundhw.c                      | 156 ++++++++++++++++++++++++++++++++
 hw/ppc/prep.c                           |   3 +-
 vl.c                                    |   3 +-
 hw/audio/Makefile.objs                  |   2 +
 15 files changed, 174 insertions(+), 137 deletions(-)
 rename include/hw/audio/{audio.h => soundhw.h} (81%)
 create mode 100644 hw/audio/soundhw.c
Signature · 1 line
2.11.0.259.g40922b1
#1 lore raw

PATCH v3 1/3 audio: Move arch_init audio code to hw/audio/soundhw.c

There's no reason to keep the soundhw table in arch_init.c. Move that code to a new hw/audio/soundhw.c file.

While moving the code, trivial coding style issues were fixed.

---
Changes v2 -> v3:
* Update hw/ppc/prep.c to include hw/audio/audio.h too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/audio.h   |   3 +
 include/sysemu/arch_init.h |   2 -
 arch_init.c                | 124 -----------------------------------
 hw/audio/soundhw.c         | 156 +++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/prep.c              |   1 +
 vl.c                       |   1 +
 hw/audio/Makefile.objs     |   2 +
 7 files changed, 163 insertions(+), 126 deletions(-)
 create mode 100644 hw/audio/soundhw.c
include/hw/audio/audio.h +3 -0
index 55d40f71bf..259bb2cf96 100644
@@ -7,4 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
 void pci_register_soundhw(const char *name, const char *descr,
                           int (*init_pci)(PCIBus *bus));
 
+void audio_init(void);
+void select_soundhw(const char *optarg);
+
 #endif
include/sysemu/arch_init.h +0 -2
index 2bf16b203c..8751c468ed 100644
@@ -28,8 +28,6 @@ enum {
 
 extern const uint32_t arch_type;
 
-void select_soundhw(const char *optarg);
-void audio_init(void);
 int kvm_available(void);
 int xen_available(void);
 
arch_init.c +0 -124

130 lines not on this page · raw message

hw/audio/soundhw.c new file +156 -0

156 lines not on this page · raw message

hw/ppc/prep.c +1 -0
index 961230c569..96a4813b3f 100644
@@ -36,6 +36,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/ppc.h"
 #include "hw/boards.h"
+#include "hw/audio/audio.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "hw/ide.h"
vl.c +1 -0
index 560288fe0c..a2400e1ab6 100644
@@ -89,6 +89,7 @@ int main(int argc, char **argv)
 #include "migration/block.h"
 #include "sysemu/tpm.h"
 #include "sysemu/dma.h"
+#include "hw/audio/audio.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
 #include "sysemu/cpus.h"
hw/audio/Makefile.objs +2 -0
index bb6f07a91e..63db383709 100644
@@ -14,3 +14,5 @@ common-obj-$(CONFIG_PL041) += pl041.o lm4549.o
 common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
+
+common-obj-y += soundhw.o
Signature · 1 line
2.11.0.259.g40922b1
Reviewed-by on v3 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH v3 1/3] audio: Move arch_init audio code to hw/audio/soundhw.c

Quoted 6 lines · Eduardo Habkost

There's no reason to keep the soundhw table in arch_init.c. Move that code to a new hw/audio/soundhw.c file.

While moving the code, trivial coding style issues were fixed.

Quoted 373 lines

---
Changes v2 -> v3:
* Update hw/ppc/prep.c to include hw/audio/audio.h too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/audio.h   |   3 +
 include/sysemu/arch_init.h |   2 -
 arch_init.c                | 124 -----------------------------------
 hw/audio/soundhw.c         | 156 +++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/prep.c              |   1 +
 vl.c                       |   1 +
 hw/audio/Makefile.objs     |   2 +
 7 files changed, 163 insertions(+), 126 deletions(-)
 create mode 100644 hw/audio/soundhw.c
include/hw/audio/audio.h +3 -0
index 55d40f71bf..259bb2cf96 100644
@@ -7,4 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
 void pci_register_soundhw(const char *name, const char *descr,
                           int (*init_pci)(PCIBus *bus));
 
+void audio_init(void);
+void select_soundhw(const char *optarg);
+
 #endif
include/sysemu/arch_init.h +0 -2
index 2bf16b203c..8751c468ed 100644
@@ -28,8 +28,6 @@ enum {
 
 extern const uint32_t arch_type;
 
-void select_soundhw(const char *optarg);
-void audio_init(void);
 int kvm_available(void);
 int xen_available(void);
 
arch_init.c +0 -124
index 0810116144..74ca62f508 100644
@@ -85,130 +85,6 @@ int graphic_depth = 32;
 
 const uint32_t arch_type = QEMU_ARCH;
 
-struct soundhw {
-    const char *name;
-    const char *descr;
-    int enabled;
-    int isa;
-    union {
-        int (*init_isa) (ISABus *bus);
-        int (*init_pci) (PCIBus *bus);
-    } init;
-};
-
-static struct soundhw soundhw[9];
-static int soundhw_count;
-
-void isa_register_soundhw(const char *name, const char *descr,
-                          int (*init_isa)(ISABus *bus))
-{
-    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
-    soundhw[soundhw_count].name = name;
-    soundhw[soundhw_count].descr = descr;
-    soundhw[soundhw_count].isa = 1;
-    soundhw[soundhw_count].init.init_isa = init_isa;
-    soundhw_count++;
-}
-
-void pci_register_soundhw(const char *name, const char *descr,
-                          int (*init_pci)(PCIBus *bus))
-{
-    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
-    soundhw[soundhw_count].name = name;
-    soundhw[soundhw_count].descr = descr;
-    soundhw[soundhw_count].isa = 0;
-    soundhw[soundhw_count].init.init_pci = init_pci;
-    soundhw_count++;
-}
-
-void select_soundhw(const char *optarg)
-{
-    struct soundhw *c;
-
-    if (is_help_option(optarg)) {
-    show_valid_cards:
-
-        if (soundhw_count) {
-             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");
-        } else {
-             printf("Machine has no user-selectable audio hardware "
-                    "(it may or may not have always-present audio hardware).\n");
-        }
-        exit(!is_help_option(optarg));
-    }
-    else {
-        size_t l;
-        const char *p;
-        char *e;
-        int bad_card = 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 (c = soundhw; c->name; ++c) {
-                if (!strncmp(c->name, p, l) && !c->name[l]) {
-                    c->enabled = 1;
-                    break;
-                }
-            }
-
-            if (!c->name) {
-                if (l > 80) {
-                    error_report("Unknown sound card name (too big to show)");
-                }
-                else {
-                    error_report("Unknown sound card name `%.*s'",
-                                 (int) l, p);
-                }
-                bad_card = 1;
-            }
-            p += l + (e != NULL);
-        }
-
-        if (bad_card) {
-            goto show_valid_cards;
-        }
-    }
-}
-
-void audio_init(void)
-{
-    struct soundhw *c;
-    ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);
-    PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, NULL);
-
-    for (c = soundhw; c->name; ++c) {
-        if (c->enabled) {
-            if (c->isa) {
-                if (!isa_bus) {
-                    error_report("ISA bus not available for %s", c->name);
-                    exit(1);
-                }
-                c->init.init_isa(isa_bus);
-            } else {
-                if (!pci_bus) {
-                    error_report("PCI bus not available for %s", c->name);
-                    exit(1);
-                }
-                c->init.init_pci(pci_bus);
-            }
-        }
-    }
-}
-
 int kvm_available(void)
 {
 #ifdef CONFIG_KVM
hw/audio/soundhw.c new file +156 -0
new file mode 100644
index 0000000000..5e96b73c81
@@ -0,0 +1,156 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/help_option.h"
+#include "qemu/error-report.h"
+#include "qom/object.h"
+#include "hw/isa/isa.h"
+#include "hw/pci/pci.h"
+#include "hw/audio/audio.h"
+
+struct soundhw {
+    const char *name;
+    const char *descr;
+    int enabled;
+    int isa;
+    union {
+        int (*init_isa) (ISABus *bus);
+        int (*init_pci) (PCIBus *bus);
+    } init;
+};
+
+static struct soundhw soundhw[9];
+static int soundhw_count;
+
+void isa_register_soundhw(const char *name, const char *descr,
+                          int (*init_isa)(ISABus *bus))
+{
+    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
+    soundhw[soundhw_count].name = name;
+    soundhw[soundhw_count].descr = descr;
+    soundhw[soundhw_count].isa = 1;
+    soundhw[soundhw_count].init.init_isa = init_isa;
+    soundhw_count++;
+}
+
+void pci_register_soundhw(const char *name, const char *descr,
+                          int (*init_pci)(PCIBus *bus))
+{
+    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
+    soundhw[soundhw_count].name = name;
+    soundhw[soundhw_count].descr = descr;
+    soundhw[soundhw_count].isa = 0;
+    soundhw[soundhw_count].init.init_pci = init_pci;
+    soundhw_count++;
+}
+
+void select_soundhw(const char *optarg)
+{
+    struct soundhw *c;
+
+    if (is_help_option(optarg)) {
+    show_valid_cards:
+
+        if (soundhw_count) {
+             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");
+        } else {
+             printf("Machine has no user-selectable audio hardware "
+                    "(it may or may not have always-present audio hardware).\n");
+        }
+        exit(!is_help_option(optarg));
+    }
+    else {
+        size_t l;
+        const char *p;
+        char *e;
+        int bad_card = 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 (c = soundhw; c->name; ++c) {
+                if (!strncmp(c->name, p, l) && !c->name[l]) {
+                    c->enabled = 1;
+                    break;
+                }
+            }
+
+            if (!c->name) {
+                if (l > 80) {
+                    error_report("Unknown sound card name (too big to show)");
+                }
+                else {
+                    error_report("Unknown sound card name `%.*s'",
+                                 (int) l, p);
+                }
+                bad_card = 1;
+            }
+            p += l + (e != NULL);
+        }
+
+        if (bad_card) {
+            goto show_valid_cards;
+        }
+    }
+}
+
+void audio_init(void)
+{
+    struct soundhw *c;
+    ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);
+    PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, NULL);
+
+    for (c = soundhw; c->name; ++c) {
+        if (c->enabled) {
+            if (c->isa) {
+                if (!isa_bus) {
+                    error_report("ISA bus not available for %s", c->name);
+                    exit(1);
+                }
+                c->init.init_isa(isa_bus);
+            } else {
+                if (!pci_bus) {
+                    error_report("PCI bus not available for %s", c->name);
+                    exit(1);
+                }
+                c->init.init_pci(pci_bus);
+            }
+        }
+    }
+}
+
hw/ppc/prep.c +1 -0
index 961230c569..96a4813b3f 100644
@@ -36,6 +36,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/ppc.h"
 #include "hw/boards.h"
+#include "hw/audio/audio.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "hw/ide.h"
vl.c +1 -0
index 560288fe0c..a2400e1ab6 100644
@@ -89,6 +89,7 @@ int main(int argc, char **argv)
 #include "migration/block.h"
 #include "sysemu/tpm.h"
 #include "sysemu/dma.h"
+#include "hw/audio/audio.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
 #include "sysemu/cpus.h"
hw/audio/Makefile.objs +2 -0
index bb6f07a91e..63db383709 100644
@@ -14,3 +14,5 @@ common-obj-$(CONFIG_PL041) += pl041.o lm4549.o
 common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
+
+common-obj-y += soundhw.o
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Reviewed-by on v3 1/3
#3 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 1/3] audio: Move arch_init audio code to hw/audio/soundhw.c

In reply to Eduardo Habkost
Quoted 12 lines · Eduardo Habkost

There's no reason to keep the soundhw table in arch_init.c. Move that code to a new hw/audio/soundhw.c file.

While moving the code, trivial coding style issues were fixed.

---
Changes v2 -> v3:
* Update hw/ppc/prep.c to include hw/audio/audio.h too

Changes v1 -> v2:
* Rebase to latest qemu.git master

Quoted 10 lines
---
 include/hw/audio/audio.h   |   3 +
 include/sysemu/arch_init.h |   2 -
 arch_init.c                | 124 -----------------------------------
 hw/audio/soundhw.c         | 156 +++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/prep.c              |   1 +
 vl.c                       |   1 +
 hw/audio/Makefile.objs     |   2 +
 7 files changed, 163 insertions(+), 126 deletions(-)
 create mode 100644 hw/audio/soundhw.c

Good idea!

Reviewed-by on v3 1/3
#4 lore raw

Re: [Qemu-devel] [PATCH v3 1/3] audio: Move arch_init audio code to hw/audio/soundhw.c

In reply to Eduardo Habkost
Quoted 6 lines · Eduardo Habkost

There's no reason to keep the soundhw table in arch_init.c. Move that code to a new hw/audio/soundhw.c file.

While moving the code, trivial coding style issues were fixed.

Quoted 374 lines

---
Changes v2 -> v3:
* Update hw/ppc/prep.c to include hw/audio/audio.h too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/audio.h   |   3 +
 include/sysemu/arch_init.h |   2 -
 arch_init.c                | 124 -----------------------------------
 hw/audio/soundhw.c         | 156 +++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/prep.c              |   1 +
 vl.c                       |   1 +
 hw/audio/Makefile.objs     |   2 +
 7 files changed, 163 insertions(+), 126 deletions(-)
 create mode 100644 hw/audio/soundhw.c
include/hw/audio/audio.h +3 -0
index 55d40f71bf..259bb2cf96 100644
@@ -7,4 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
 void pci_register_soundhw(const char *name, const char *descr,
                           int (*init_pci)(PCIBus *bus));
 
+void audio_init(void);
+void select_soundhw(const char *optarg);
+
 #endif
include/sysemu/arch_init.h +0 -2
index 2bf16b203c..8751c468ed 100644
@@ -28,8 +28,6 @@ enum {
 
 extern const uint32_t arch_type;
 
-void select_soundhw(const char *optarg);
-void audio_init(void);
 int kvm_available(void);
 int xen_available(void);
 
arch_init.c +0 -124
index 0810116144..74ca62f508 100644
@@ -85,130 +85,6 @@ int graphic_depth = 32;
 
 const uint32_t arch_type = QEMU_ARCH;
 
-struct soundhw {
-    const char *name;
-    const char *descr;
-    int enabled;
-    int isa;
-    union {
-        int (*init_isa) (ISABus *bus);
-        int (*init_pci) (PCIBus *bus);
-    } init;
-};
-
-static struct soundhw soundhw[9];
-static int soundhw_count;
-
-void isa_register_soundhw(const char *name, const char *descr,
-                          int (*init_isa)(ISABus *bus))
-{
-    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
-    soundhw[soundhw_count].name = name;
-    soundhw[soundhw_count].descr = descr;
-    soundhw[soundhw_count].isa = 1;
-    soundhw[soundhw_count].init.init_isa = init_isa;
-    soundhw_count++;
-}
-
-void pci_register_soundhw(const char *name, const char *descr,
-                          int (*init_pci)(PCIBus *bus))
-{
-    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
-    soundhw[soundhw_count].name = name;
-    soundhw[soundhw_count].descr = descr;
-    soundhw[soundhw_count].isa = 0;
-    soundhw[soundhw_count].init.init_pci = init_pci;
-    soundhw_count++;
-}
-
-void select_soundhw(const char *optarg)
-{
-    struct soundhw *c;
-
-    if (is_help_option(optarg)) {
-    show_valid_cards:
-
-        if (soundhw_count) {
-             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");
-        } else {
-             printf("Machine has no user-selectable audio hardware "
-                    "(it may or may not have always-present audio hardware).\n");
-        }
-        exit(!is_help_option(optarg));
-    }
-    else {
-        size_t l;
-        const char *p;
-        char *e;
-        int bad_card = 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 (c = soundhw; c->name; ++c) {
-                if (!strncmp(c->name, p, l) && !c->name[l]) {
-                    c->enabled = 1;
-                    break;
-                }
-            }
-
-            if (!c->name) {
-                if (l > 80) {
-                    error_report("Unknown sound card name (too big to show)");
-                }
-                else {
-                    error_report("Unknown sound card name `%.*s'",
-                                 (int) l, p);
-                }
-                bad_card = 1;
-            }
-            p += l + (e != NULL);
-        }
-
-        if (bad_card) {
-            goto show_valid_cards;
-        }
-    }
-}
-
-void audio_init(void)
-{
-    struct soundhw *c;
-    ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);
-    PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, NULL);
-
-    for (c = soundhw; c->name; ++c) {
-        if (c->enabled) {
-            if (c->isa) {
-                if (!isa_bus) {
-                    error_report("ISA bus not available for %s", c->name);
-                    exit(1);
-                }
-                c->init.init_isa(isa_bus);
-            } else {
-                if (!pci_bus) {
-                    error_report("PCI bus not available for %s", c->name);
-                    exit(1);
-                }
-                c->init.init_pci(pci_bus);
-            }
-        }
-    }
-}
-
 int kvm_available(void)
 {
 #ifdef CONFIG_KVM
hw/audio/soundhw.c new file +156 -0
new file mode 100644
index 0000000000..5e96b73c81
@@ -0,0 +1,156 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/help_option.h"
+#include "qemu/error-report.h"
+#include "qom/object.h"
+#include "hw/isa/isa.h"
+#include "hw/pci/pci.h"
+#include "hw/audio/audio.h"
+
+struct soundhw {
+    const char *name;
+    const char *descr;
+    int enabled;
+    int isa;
+    union {
+        int (*init_isa) (ISABus *bus);
+        int (*init_pci) (PCIBus *bus);
+    } init;
+};
+
+static struct soundhw soundhw[9];
+static int soundhw_count;
+
+void isa_register_soundhw(const char *name, const char *descr,
+                          int (*init_isa)(ISABus *bus))
+{
+    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
+    soundhw[soundhw_count].name = name;
+    soundhw[soundhw_count].descr = descr;
+    soundhw[soundhw_count].isa = 1;
+    soundhw[soundhw_count].init.init_isa = init_isa;
+    soundhw_count++;
+}
+
+void pci_register_soundhw(const char *name, const char *descr,
+                          int (*init_pci)(PCIBus *bus))
+{
+    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
+    soundhw[soundhw_count].name = name;
+    soundhw[soundhw_count].descr = descr;
+    soundhw[soundhw_count].isa = 0;
+    soundhw[soundhw_count].init.init_pci = init_pci;
+    soundhw_count++;
+}
+
+void select_soundhw(const char *optarg)
+{
+    struct soundhw *c;
+
+    if (is_help_option(optarg)) {
+    show_valid_cards:
+
+        if (soundhw_count) {
+             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");
+        } else {
+             printf("Machine has no user-selectable audio hardware "
+                    "(it may or may not have always-present audio hardware).\n");
+        }
+        exit(!is_help_option(optarg));
+    }
+    else {
+        size_t l;
+        const char *p;
+        char *e;
+        int bad_card = 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 (c = soundhw; c->name; ++c) {
+                if (!strncmp(c->name, p, l) && !c->name[l]) {
+                    c->enabled = 1;
+                    break;
+                }
+            }
+
+            if (!c->name) {
+                if (l > 80) {
+                    error_report("Unknown sound card name (too big to show)");
+                }
+                else {
+                    error_report("Unknown sound card name `%.*s'",
+                                 (int) l, p);
+                }
+                bad_card = 1;
+            }
+            p += l + (e != NULL);
+        }
+
+        if (bad_card) {
+            goto show_valid_cards;
+        }
+    }
+}
+
+void audio_init(void)
+{
+    struct soundhw *c;
+    ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);
+    PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, NULL);
+
+    for (c = soundhw; c->name; ++c) {
+        if (c->enabled) {
+            if (c->isa) {
+                if (!isa_bus) {
+                    error_report("ISA bus not available for %s", c->name);
+                    exit(1);
+                }
+                c->init.init_isa(isa_bus);
+            } else {
+                if (!pci_bus) {
+                    error_report("PCI bus not available for %s", c->name);
+                    exit(1);
+                }
+                c->init.init_pci(pci_bus);
+            }
+        }
+    }
+}
+
hw/ppc/prep.c +1 -0
index 961230c569..96a4813b3f 100644
@@ -36,6 +36,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/ppc.h"
 #include "hw/boards.h"
+#include "hw/audio/audio.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "hw/ide.h"
vl.c +1 -0
index 560288fe0c..a2400e1ab6 100644
@@ -89,6 +89,7 @@ int main(int argc, char **argv)
 #include "migration/block.h"
 #include "sysemu/tpm.h"
 #include "sysemu/dma.h"
+#include "hw/audio/audio.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
 #include "sysemu/cpus.h"
hw/audio/Makefile.objs +2 -0
index bb6f07a91e..63db383709 100644
@@ -14,3 +14,5 @@ common-obj-$(CONFIG_PL041) += pl041.o lm4549.o
 common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
+
+common-obj-y += soundhw.o
#5 lore raw

PATCH v3 2/3 audio: Rename audio_init() to soundhw_init()

In reply to Eduardo Habkost

To make it consistent with the remaining soundhw.c functions and avoid confusion with the audio_init() function in audio/audio.c, rename audio_init() to soundhw_init().

---
Changes v2 -> v3:
* Update hw/ppc/prep.c audio_init() call too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/audio.h | 2 +-
 hw/audio/soundhw.c       | 2 +-
 hw/ppc/prep.c            | 2 +-
 vl.c                     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
include/hw/audio/audio.h +1 -1
index 259bb2cf96..119f7d78d5 100644
@@ -7,7 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
 void pci_register_soundhw(const char *name, const char *descr,
                           int (*init_pci)(PCIBus *bus));
 
-void audio_init(void);
+void soundhw_init(void);
 void select_soundhw(const char *optarg);
 
 #endif
hw/audio/soundhw.c +1 -1
index 5e96b73c81..29565da93d 100644
@@ -129,7 +129,7 @@ void select_soundhw(const char *optarg)
     }
 }
 
-void audio_init(void)
+void soundhw_init(void)
 {
     struct soundhw *c;
     ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);
hw/ppc/prep.c +1 -1
index 96a4813b3f..4a7d2cfbe0 100644
@@ -783,7 +783,7 @@ static void ibm_40p_init(MachineState *machine)
                        &cmos_checksum);
 
     /* initialize audio subsystem */
-    audio_init();
+    soundhw_init();
 
     /* add some more devices */
     if (defaults_enabled()) {
vl.c +1 -1
index a2400e1ab6..42fd66ac0d 100644
@@ -4569,7 +4569,7 @@ int main(int argc, char **argv, char **envp)
 
     realtime_init();
 
-    audio_init();
+    soundhw_init();
 
     if (hax_enabled()) {
         hax_sync_vcpus();
Signature · 1 line
2.11.0.259.g40922b1
Reviewed-by on v3 2/3
#6 lore raw

Re: [Qemu-devel] [PATCH v3 2/3] audio: Rename audio_init() to soundhw_init()

Quoted 5 lines · Eduardo Habkost

To make it consistent with the remaining soundhw.c functions and avoid confusion with the audio_init() function in audio/audio.c, rename audio_init() to soundhw_init().

Quoted 65 lines

---
Changes v2 -> v3:
* Update hw/ppc/prep.c audio_init() call too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/audio.h | 2 +-
 hw/audio/soundhw.c       | 2 +-
 hw/ppc/prep.c            | 2 +-
 vl.c                     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
include/hw/audio/audio.h +1 -1
index 259bb2cf96..119f7d78d5 100644
@@ -7,7 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
 void pci_register_soundhw(const char *name, const char *descr,
                           int (*init_pci)(PCIBus *bus));
 
-void audio_init(void);
+void soundhw_init(void);
 void select_soundhw(const char *optarg);
 
 #endif
hw/audio/soundhw.c +1 -1
index 5e96b73c81..29565da93d 100644
@@ -129,7 +129,7 @@ void select_soundhw(const char *optarg)
     }
 }
 
-void audio_init(void)
+void soundhw_init(void)
 {
     struct soundhw *c;
     ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);
hw/ppc/prep.c +1 -1
index 96a4813b3f..4a7d2cfbe0 100644
@@ -783,7 +783,7 @@ static void ibm_40p_init(MachineState *machine)
                        &cmos_checksum);
 
     /* initialize audio subsystem */
-    audio_init();
+    soundhw_init();
 
     /* add some more devices */
     if (defaults_enabled()) {
vl.c +1 -1
index a2400e1ab6..42fd66ac0d 100644
@@ -4569,7 +4569,7 @@ int main(int argc, char **argv, char **envp)
 
     realtime_init();
 
-    audio_init();
+    soundhw_init();
 
     if (hax_enabled()) {
         hax_sync_vcpus();
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw

Re: [Qemu-devel] [PATCH v3 2/3] audio: Rename audio_init() to soundhw_init()

In reply to Eduardo Habkost
Quoted 5 lines · Eduardo Habkost

To make it consistent with the remaining soundhw.c functions and avoid confusion with the audio_init() function in audio/audio.c, rename audio_init() to soundhw_init().

You should probably add a patch before 1/3 to remove the two audio_init()/soundhw_init() calls in hw/ppc/prep.c. That way, you won't need to change hw/ppc/prep.c in 1/3 and 2/3.

Regards,

Hervé

Quoted 66 lines

---
Changes v2 -> v3:
* Update hw/ppc/prep.c audio_init() call too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/audio.h | 2 +-
 hw/audio/soundhw.c       | 2 +-
 hw/ppc/prep.c            | 2 +-
 vl.c                     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
include/hw/audio/audio.h +1 -1
index 259bb2cf96..119f7d78d5 100644
@@ -7,7 +7,7 @@ void isa_register_soundhw(const char *name, const char *descr,
 void pci_register_soundhw(const char *name, const char *descr,
                           int (*init_pci)(PCIBus *bus));
 
-void audio_init(void);
+void soundhw_init(void);
 void select_soundhw(const char *optarg);
 
 #endif
hw/audio/soundhw.c +1 -1
index 5e96b73c81..29565da93d 100644
@@ -129,7 +129,7 @@ void select_soundhw(const char *optarg)
     }
 }
 
-void audio_init(void)
+void soundhw_init(void)
 {
     struct soundhw *c;
     ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);
hw/ppc/prep.c +1 -1
index 96a4813b3f..4a7d2cfbe0 100644
@@ -783,7 +783,7 @@ static void ibm_40p_init(MachineState *machine)
                        &cmos_checksum);
 
     /* initialize audio subsystem */
-    audio_init();
+    soundhw_init();
 
     /* add some more devices */
     if (defaults_enabled()) {
vl.c +1 -1
index a2400e1ab6..42fd66ac0d 100644
@@ -4569,7 +4569,7 @@ int main(int argc, char **argv, char **envp)
 
     realtime_init();
 
-    audio_init();
+    soundhw_init();
 
     if (hax_enabled()) {
         hax_sync_vcpus();
#8 lore raw

PATCH v3 3/3 audio: Rename hw/audio/audio.h to hw/audio/soundhw.h

In reply to Eduardo Habkost

All the functions in hw/audio/audio.h are called "soundhw_*()" and live in hw/audio/audiohw.c. Rename the header file for consistency.

---
Changes v2 -> v3:
* Update header name at hw/ppc/prep.c too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/{audio.h => soundhw.h} | 0
 arch_init.c                             | 2 +-
 hw/audio/ac97.c                         | 2 +-
 hw/audio/adlib.c                        | 2 +-
 hw/audio/cs4231a.c                      | 2 +-
 hw/audio/es1370.c                       | 2 +-
 hw/audio/gus.c                          | 2 +-
 hw/audio/intel-hda.c                    | 2 +-
 hw/audio/pcspk.c                        | 2 +-
 hw/audio/sb16.c                         | 2 +-
 hw/audio/soundhw.c                      | 2 +-
 hw/ppc/prep.c                           | 2 +-
 vl.c                                    | 2 +-
 13 files changed, 12 insertions(+), 12 deletions(-)
 rename include/hw/audio/{audio.h => soundhw.h} (100%)
include/hw/audio/soundhw.h renamed from include/hw/audio/audio.h +0 -0
similarity index 100%
rename from include/hw/audio/audio.h
rename to include/hw/audio/soundhw.h
arch_init.c +1 -1
index 74ca62f508..a0b8ed6167 100644
@@ -27,7 +27,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/arch_init.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "qmp-commands.h"
hw/audio/ac97.c +1 -1
index c30657501c..959c786261 100644
@@ -19,7 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
hw/audio/adlib.c +1 -1
index 09b8248cda..c6e0f10c16 100644
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 
hw/audio/cs4231a.c +1 -1
index 3ecd0582bf..096e8e98d7 100644
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
hw/audio/es1370.c +1 -1
index fe64c1ac37..dd7c23d185 100644
@@ -28,7 +28,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
hw/audio/gus.c +1 -1
index ec103a4db9..3e864cd36d 100644
@@ -24,7 +24,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "gusemu.h"
hw/audio/intel-hda.c +1 -1
index 2c497eb174..06acc98f7b 100644
@@ -22,7 +22,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/msi.h"
 #include "qemu/timer.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "intel-hda.h"
 #include "intel-hda-defs.h"
 #include "sysemu/dma.h"
hw/audio/pcspk.c +1 -1
index 798002277b..c815a2b9ca 100644
@@ -26,7 +26,7 @@
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "qemu/timer.h"
 #include "hw/timer/i8254.h"
hw/audio/sb16.c +1 -1
index 6b4427f242..6ab2f6f89a 100644
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
hw/audio/soundhw.c +1 -1
index 29565da93d..e698909d34 100644
@@ -28,7 +28,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 
 struct soundhw {
     const char *name;
hw/ppc/prep.c +1 -1
index 4a7d2cfbe0..d16646c95d 100644
@@ -36,7 +36,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/ppc.h"
 #include "hw/boards.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "hw/ide.h"
vl.c +1 -1
index 42fd66ac0d..54b44937e6 100644
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
 #include "migration/block.h"
 #include "sysemu/tpm.h"
 #include "sysemu/dma.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
 #include "sysemu/cpus.h"
Signature · 1 line
2.11.0.259.g40922b1
Reviewed-by on v3 3/3
#9 lore raw

Re: [Qemu-devel] [PATCH v3 3/3] audio: Rename hw/audio/audio.h to hw/audio/soundhw.h

Quoted 5 lines · Eduardo Habkost

All the functions in hw/audio/audio.h are called "soundhw_*()" and live in hw/audio/audiohw.c. Rename the header file for consistency.

Quoted 183 lines

---
Changes v2 -> v3:
* Update header name at hw/ppc/prep.c too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/{audio.h => soundhw.h} | 0
 arch_init.c                             | 2 +-
 hw/audio/ac97.c                         | 2 +-
 hw/audio/adlib.c                        | 2 +-
 hw/audio/cs4231a.c                      | 2 +-
 hw/audio/es1370.c                       | 2 +-
 hw/audio/gus.c                          | 2 +-
 hw/audio/intel-hda.c                    | 2 +-
 hw/audio/pcspk.c                        | 2 +-
 hw/audio/sb16.c                         | 2 +-
 hw/audio/soundhw.c                      | 2 +-
 hw/ppc/prep.c                           | 2 +-
 vl.c                                    | 2 +-
 13 files changed, 12 insertions(+), 12 deletions(-)
 rename include/hw/audio/{audio.h => soundhw.h} (100%)
include/hw/audio/soundhw.h renamed from include/hw/audio/audio.h +0 -0
similarity index 100%
rename from include/hw/audio/audio.h
rename to include/hw/audio/soundhw.h
arch_init.c +1 -1
index 74ca62f508..a0b8ed6167 100644
@@ -27,7 +27,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/arch_init.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "qmp-commands.h"
hw/audio/ac97.c +1 -1
index c30657501c..959c786261 100644
@@ -19,7 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
hw/audio/adlib.c +1 -1
index 09b8248cda..c6e0f10c16 100644
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 
hw/audio/cs4231a.c +1 -1
index 3ecd0582bf..096e8e98d7 100644
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
hw/audio/es1370.c +1 -1
index fe64c1ac37..dd7c23d185 100644
@@ -28,7 +28,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
hw/audio/gus.c +1 -1
index ec103a4db9..3e864cd36d 100644
@@ -24,7 +24,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "gusemu.h"
hw/audio/intel-hda.c +1 -1
index 2c497eb174..06acc98f7b 100644
@@ -22,7 +22,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/msi.h"
 #include "qemu/timer.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "intel-hda.h"
 #include "intel-hda-defs.h"
 #include "sysemu/dma.h"
hw/audio/pcspk.c +1 -1
index 798002277b..c815a2b9ca 100644
@@ -26,7 +26,7 @@
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "qemu/timer.h"
 #include "hw/timer/i8254.h"
hw/audio/sb16.c +1 -1
index 6b4427f242..6ab2f6f89a 100644
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
hw/audio/soundhw.c +1 -1
index 29565da93d..e698909d34 100644
@@ -28,7 +28,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 
 struct soundhw {
     const char *name;
hw/ppc/prep.c +1 -1
index 4a7d2cfbe0..d16646c95d 100644
@@ -36,7 +36,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/ppc.h"
 #include "hw/boards.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "hw/ide.h"
vl.c +1 -1
index 42fd66ac0d..54b44937e6 100644
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
 #include "migration/block.h"
 #include "sysemu/tpm.h"
 #include "sysemu/dma.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
 #include "sysemu/cpus.h"
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Reviewed-by on v3 3/3
#10 lore raw

Re: [Qemu-devel] [PATCH v3 3/3] audio: Rename hw/audio/audio.h to hw/audio/soundhw.h

In reply to Eduardo Habkost
Quoted 5 lines · Eduardo Habkost

All the functions in hw/audio/audio.h are called "soundhw_*()" and live in hw/audio/audiohw.c. Rename the header file for consistency.

Quoted 184 lines

---
Changes v2 -> v3:
* Update header name at hw/ppc/prep.c too

Changes v1 -> v2:
* Rebase to latest qemu.git master

---
 include/hw/audio/{audio.h => soundhw.h} | 0
 arch_init.c                             | 2 +-
 hw/audio/ac97.c                         | 2 +-
 hw/audio/adlib.c                        | 2 +-
 hw/audio/cs4231a.c                      | 2 +-
 hw/audio/es1370.c                       | 2 +-
 hw/audio/gus.c                          | 2 +-
 hw/audio/intel-hda.c                    | 2 +-
 hw/audio/pcspk.c                        | 2 +-
 hw/audio/sb16.c                         | 2 +-
 hw/audio/soundhw.c                      | 2 +-
 hw/ppc/prep.c                           | 2 +-
 vl.c                                    | 2 +-
 13 files changed, 12 insertions(+), 12 deletions(-)
 rename include/hw/audio/{audio.h => soundhw.h} (100%)
include/hw/audio/soundhw.h renamed from include/hw/audio/audio.h +0 -0
similarity index 100%
rename from include/hw/audio/audio.h
rename to include/hw/audio/soundhw.h
arch_init.c +1 -1
index 74ca62f508..a0b8ed6167 100644
@@ -27,7 +27,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/arch_init.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "qmp-commands.h"
hw/audio/ac97.c +1 -1
index c30657501c..959c786261 100644
@@ -19,7 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
hw/audio/adlib.c +1 -1
index 09b8248cda..c6e0f10c16 100644
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 
hw/audio/cs4231a.c +1 -1
index 3ecd0582bf..096e8e98d7 100644
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
hw/audio/es1370.c +1 -1
index fe64c1ac37..dd7c23d185 100644
@@ -28,7 +28,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/pci/pci.h"
 #include "sysemu/dma.h"
hw/audio/gus.c +1 -1
index ec103a4db9..3e864cd36d 100644
@@ -24,7 +24,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "gusemu.h"
hw/audio/intel-hda.c +1 -1
index 2c497eb174..06acc98f7b 100644
@@ -22,7 +22,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/msi.h"
 #include "qemu/timer.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "intel-hda.h"
 #include "intel-hda-defs.h"
 #include "sysemu/dma.h"
hw/audio/pcspk.c +1 -1
index 798002277b..c815a2b9ca 100644
@@ -26,7 +26,7 @@
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "qemu/timer.h"
 #include "hw/timer/i8254.h"
hw/audio/sb16.c +1 -1
index 6b4427f242..6ab2f6f89a 100644
@@ -23,7 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev.h"
hw/audio/soundhw.c +1 -1
index 29565da93d..e698909d34 100644
@@ -28,7 +28,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "hw/pci/pci.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 
 struct soundhw {
     const char *name;
hw/ppc/prep.c +1 -1
index 4a7d2cfbe0..d16646c95d 100644
@@ -36,7 +36,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/ppc.h"
 #include "hw/boards.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "hw/ide.h"
vl.c +1 -1
index 42fd66ac0d..54b44937e6 100644
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
 #include "migration/block.h"
 #include "sysemu/tpm.h"
 #include "sysemu/dma.h"
-#include "hw/audio/audio.h"
+#include "hw/audio/soundhw.h"
 #include "audio/audio.h"
 #include "migration/migration.h"
 #include "sysemu/cpus.h"
#11 lore raw
In reply to Eduardo Habkost
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [Qemu-devel] [PATCH v3 0/3] arch_init: Move soundhw code to hw/audio/soundhw.c
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
ca059cc audio: Rename hw/audio/audio.h to hw/audio/soundhw.h 8cc8396 audio: Rename audio_init() to soundhw_init() e19b303 audio: Move arch_init audio code to hw/audio/soundhw.c

=== OUTPUT BEGIN ===
Checking PATCH 1/3: audio: Move arch_init audio code to hw/audio/soundhw.c...
ERROR: suspect code indent for conditional statements (8, 13) #240: FILE: hw/audio/soundhw.c:76:
+ if (soundhw_count) {
+ printf("Valid sound card names (comma separated):\n");

ERROR: suspect code indent for conditional statements (13, 17) #242: FILE: hw/audio/soundhw.c:78:
+ for (c = soundhw; c->name; ++c) {
+ printf ("%-11s %s\n", c->name, c->descr);

ERROR: space prohibited between function name and open parenthesis '(' #243: FILE: hw/audio/soundhw.c:79:
+ printf ("%-11s %s\n", c->name, c->descr);

ERROR: else should follow close brace '}'
#252: FILE: hw/audio/soundhw.c:88:
+ }
+ else {

ERROR: else should follow close brace '}'
#281: FILE: hw/audio/soundhw.c:117:
+ }
+ else {

WARNING: line over 80 characters
#299: FILE: hw/audio/soundhw.c:135:
+ ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);

WARNING: line over 80 characters
#300: FILE: hw/audio/soundhw.c:136:
+ PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, NULL);

total: 5 errors, 2 warnings, 320 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 2/3: audio: Rename audio_init() to soundhw_init()... Checking PATCH 3/3: audio: Rename hw/audio/audio.h to hw/audio/soundhw.h... === OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#12 lore raw

On Mon, May 08, 2017 at 03:54:18PM -0700, [email protected] wrote:
[...]

Quoted 34 lines

=== OUTPUT BEGIN ===
Checking PATCH 1/3: audio: Move arch_init audio code to hw/audio/soundhw.c...
ERROR: suspect code indent for conditional statements (8, 13) #240: FILE: hw/audio/soundhw.c:76:

(quoted diff) +2 -0
+        if (soundhw_count) {
+             printf("Valid sound card names (comma separated):\n");

ERROR: suspect code indent for conditional statements (13, 17) #242: FILE: hw/audio/soundhw.c:78:

(quoted diff) +2 -0
+             for (c = soundhw; c->name; ++c) {
+                 printf ("%-11s %s\n", c->name, c->descr);

ERROR: space prohibited between function name and open parenthesis '(' #243: FILE: hw/audio/soundhw.c:79:
+ printf ("%-11s %s\n", c->name, c->descr);

ERROR: else should follow close brace '}'
#252: FILE: hw/audio/soundhw.c:88:

(quoted diff) +2 -0
+    }
+    else {

ERROR: else should follow close brace '}'
#281: FILE: hw/audio/soundhw.c:117:

(quoted diff) +2 -0
+                }
+                else {

WARNING: line over 80 characters
#299: FILE: hw/audio/soundhw.c:135:
+ ISABus *isa_bus = (ISABus *) object_resolve_path_type("", TYPE_ISA_BUS, NULL);

WARNING: line over 80 characters
#300: FILE: hw/audio/soundhw.c:136:
+ PCIBus *pci_bus = (PCIBus *) object_resolve_path_type("", TYPE_PCI_BUS, NULL);

Quoted 5 lines

total: 5 errors, 2 warnings, 320 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

The style problems are not in new code, but in code being moved to another file. If anybody wants to volunteer to fix those issues, they should be addressed in follow-up patches.

Signature · 1 line
Eduardo
#13 lore raw
In reply to Eduardo Habkost

Ping?

Quoted 38 lines · Eduardo Habkost

Changes v2 -> v3:
* Build fix: update hw/ppc/prep.c too

Changes v1 -> v2:
* Rebase to latest qemu.git master

This moves the arch_init.c soundhw code to its own file, renames audio_init() to soundhw_init(), and renames hw/audio/audio.h to hw/audio/soundhw.h.

Eduardo Habkost (3):
audio: Move arch_init audio code to hw/audio/soundhw.c
audio: Rename audio_init() to soundhw_init()
audio: Rename hw/audio/audio.h to hw/audio/soundhw.h

 include/hw/audio/{audio.h => soundhw.h} |   3 +
 include/sysemu/arch_init.h              |   2 -
 arch_init.c                             | 126 +-------------------------
 hw/audio/ac97.c                         |   2 +-
 hw/audio/adlib.c                        |   2 +-
 hw/audio/cs4231a.c                      |   2 +-
 hw/audio/es1370.c                       |   2 +-
 hw/audio/gus.c                          |   2 +-
 hw/audio/intel-hda.c                    |   2 +-
 hw/audio/pcspk.c                        |   2 +-
 hw/audio/sb16.c                         |   2 +-
 hw/audio/soundhw.c                      | 156 ++++++++++++++++++++++++++++++++
 hw/ppc/prep.c                           |   3 +-
 vl.c                                    |   3 +-
 hw/audio/Makefile.objs                  |   2 +
 15 files changed, 174 insertions(+), 137 deletions(-)
 rename include/hw/audio/{audio.h => soundhw.h} (81%)
 create mode 100644 hw/audio/soundhw.c
Signature · 1 line
2.11.0.259.g40922b1
Signature · 1 line
Eduardo