Skip to contentSkip to conversation

audio: deprecate -soundhw

PATCH Superseded Gerd Hoffmann 2 participants 23 messages Jun 24, 2020

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover audio: deprecate -soundhw

v2:
- use g_assert_not_reached() for stubs.
- add deprecation notice.

v3:
- rebase to latest master.
- adapt to armbru's device initialization changes.

v4:
- reorder patches, drop temporary -global setup, go straight to -machine pcspk-audiodev= instead.
- update error messages and documentation accordingly.

Gerd Hoffmann (20):
stubs: add isa_create_simple
stubs: add pci_create_simple
audio: add deprecated_register_soundhw
audio: deprecate -soundhw ac97
audio: deprecate -soundhw es1370
audio: deprecate -soundhw adlib
audio: deprecate -soundhw cs4231a
audio: deprecate -soundhw gus
audio: deprecate -soundhw sb16
audio: deprecate -soundhw hda
pc_basic_device_init: pass PCMachineState
pc_basic_device_init: drop has_pit arg
pc_basic_device_init: drop no_vmport arg
softmmu: initialize spice and audio earlier
audio: rework pcspk_init()
audio: create pcspk device early
audio: deprecate -soundhw pcspk
audio: add soundhw deprecation notice
pcspk: update docs/system/target-i386-desc.rst.inc
audio: set default value for pcspk.iobase property

 include/hw/audio/pcspk.h             | 12 ++----------
 include/hw/audio/soundhw.h           |  2 ++
 include/hw/i386/pc.h                 |  6 +++---
 hw/audio/ac97.c                      |  9 ++-------
 hw/audio/adlib.c                     |  8 +-------
 hw/audio/cs4231a.c                   |  8 +-------
 hw/audio/es1370.c                    |  9 ++-------
 hw/audio/gus.c                       |  8 +-------
 hw/audio/intel-hda.c                 |  3 +++
 hw/audio/pcspk.c                     | 26 ++++++++++++++++++++++----
 hw/audio/sb16.c                      |  9 ++-------
 hw/audio/soundhw.c                   | 24 +++++++++++++++++++++++-
 hw/i386/pc.c                         | 14 ++++++++------
 hw/i386/pc_piix.c                    |  3 +--
 hw/i386/pc_q35.c                     |  3 +--
 hw/isa/i82378.c                      |  2 +-
 qdev-monitor.c                       |  2 ++
 softmmu/vl.c                         | 12 ++++++------
 stubs/isa-bus.c                      |  7 +++++++
 stubs/pci-bus.c                      |  7 +++++++
 docs/system/deprecated.rst           |  9 +++++++++
 docs/system/target-i386-desc.rst.inc | 13 ++++++++++++-
 stubs/Makefile.objs                  |  2 ++
 23 files changed, 120 insertions(+), 78 deletions(-)
 create mode 100644 stubs/isa-bus.c
 create mode 100644 stubs/pci-bus.c
Signature · 1 line
2.18.4
#1 lore raw

PATCH v4 1/20 stubs: add isa_create_simple

Needed for -soundhw cleanup.

---
 stubs/isa-bus.c     | 7 +++++++
 stubs/Makefile.objs | 1 +
 2 files changed, 8 insertions(+)
 create mode 100644 stubs/isa-bus.c
stubs/isa-bus.c new file +7 -0
new file mode 100644
index 000000000000..522f448997d4
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "hw/isa/isa.h"
+
+ISADevice *isa_create_simple(ISABus *bus, const char *name)
+{
+    g_assert_not_reached();
+}
stubs/Makefile.objs +1 -0
index 28e48171d1f3..869204668231 100644
@@ -7,6 +7,7 @@ stub-obj-y += fdset.o
 stub-obj-y += gdbstub.o
 stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
+stub-obj-y += isa-bus.o
 stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
 stub-obj-y += monitor-core.o
Signature · 1 line
2.18.4
#2 lore raw

PATCH v4 2/20 stubs: add pci_create_simple

In reply to Gerd Hoffmann

Needed for -soundhw cleanup.

---
 stubs/pci-bus.c     | 7 +++++++
 stubs/Makefile.objs | 1 +
 2 files changed, 8 insertions(+)
 create mode 100644 stubs/pci-bus.c
stubs/pci-bus.c new file +7 -0
new file mode 100644
index 000000000000..a8932fa93250
@@ -0,0 +1,7 @@
+#include "qemu/osdep.h"
+#include "hw/pci/pci.h"
+
+PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
+{
+    g_assert_not_reached();
+}
stubs/Makefile.objs +1 -0
index 869204668231..5d61e0d0da5b 100644
@@ -12,6 +12,7 @@ stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
 stub-obj-y += monitor-core.o
 stub-obj-y += notify-event.o
+stub-obj-y += pci-bus.o
 stub-obj-y += qmp_memory_device.o
 stub-obj-y += qtest.o
 stub-obj-y += ramfb.o
Signature · 1 line
2.18.4
#3 lore raw

PATCH v4 3/20 audio: add deprecated_register_soundhw

In reply to Gerd Hoffmann

Add helper function for -soundhw deprecation. It can replace the simple init functions which just call {isa,pci}_create_simple() with a hardcoded type. It also prints a deprecation message.

---
 include/hw/audio/soundhw.h |  2 ++
 hw/audio/soundhw.c         | 24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
include/hw/audio/soundhw.h +2 -0
index c8eef8241846..f09a297854af 100644
@@ -6,6 +6,8 @@ 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 deprecated_register_soundhw(const char *name, const char *descr,
+                                 int isa, const char *typename);
 
 void soundhw_init(void);
 void select_soundhw(const char *optarg);
hw/audio/soundhw.c +23 -1
index c750473c8f0c..173b674ff53a 100644
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/option.h"
 #include "qemu/help_option.h"
 #include "qemu/error-report.h"
 #include "qom/object.h"
@@ -32,6 +33,7 @@
 struct soundhw {
     const char *name;
     const char *descr;
+    const char *typename;
     int enabled;
     int isa;
     union {
@@ -65,6 +67,17 @@ void pci_register_soundhw(const char *name, const char *descr,
     soundhw_count++;
 }
 
+void deprecated_register_soundhw(const char *name, const char *descr,
+                                 int isa, const char *typename)
+{
+    assert(soundhw_count < ARRAY_SIZE(soundhw) - 1);
+    soundhw[soundhw_count].name = name;
+    soundhw[soundhw_count].descr = descr;
+    soundhw[soundhw_count].isa = isa;
+    soundhw[soundhw_count].typename = typename;
+    soundhw_count++;
+}
+
 void select_soundhw(const char *optarg)
 {
     struct soundhw *c;
@@ -136,7 +149,16 @@ void soundhw_init(void)
 
     for (c = soundhw; c->name; ++c) {
         if (c->enabled) {
-            if (c->isa) {
+            if (c->typename) {
+                warn_report("'-soundhw %s' is deprecated, "
+                            "please use '-device %s' instead",
+                            c->name, c->typename);
+                if (c->isa) {
+                    isa_create_simple(isa_bus, c->typename);
+                } else {
+                    pci_create_simple(pci_bus, -1, c->typename);
+                }
+            } else if (c->isa) {
                 if (!isa_bus) {
                     error_report("ISA bus not available for %s", c->name);
                     exit(1);
Signature · 1 line
2.18.4
#4 lore raw

PATCH v4 4/20 audio: deprecate -soundhw ac97

In reply to Gerd Hoffmann

Switch to deprecated_register_soundhw(). Remove the now obsolete init function. Add an alias so both ac97 and AC97 are working with -device.

---
 hw/audio/ac97.c | 9 ++-------
 qdev-monitor.c  | 1 +
 2 files changed, 3 insertions(+), 7 deletions(-)
hw/audio/ac97.c +2 -7
index 8a9b9924c495..38522cf0ba44 100644
@@ -1393,12 +1393,6 @@ static void ac97_exit(PCIDevice *dev)
     AUD_remove_card(&s->card);
 }
 
-static int ac97_init (PCIBus *bus)
-{
-    pci_create_simple(bus, -1, TYPE_AC97);
-    return 0;
-}
-
 static Property ac97_properties[] = {
     DEFINE_AUDIO_PROPERTIES(AC97LinkState, card),
     DEFINE_PROP_END_OF_LIST (),
@@ -1436,7 +1430,8 @@ static const TypeInfo ac97_info = {
 static void ac97_register_types (void)
 {
     type_register_static (&ac97_info);
-    pci_register_soundhw("ac97", "Intel 82801AA AC97 Audio", ac97_init);
+    deprecated_register_soundhw("ac97", "Intel 82801AA AC97 Audio",
+                                0, TYPE_AC97);
 }
 
 type_init (ac97_register_types)
qdev-monitor.c +1 -0
index 22da107484c5..105d9792ecdf 100644
@@ -53,6 +53,7 @@ typedef struct QDevAlias
 
 /* Please keep this table sorted by typename. */
 static const QDevAlias qdev_alias_table[] = {
+    { "AC97", "ac97" }, /* -soundhw name */
     { "e1000", "e1000-82540em" },
     { "ich9-ahci", "ahci" },
     { "lsi53c895a", "lsi" },
Signature · 1 line
2.18.4
#5 lore raw

PATCH v4 5/20 audio: deprecate -soundhw es1370

In reply to Gerd Hoffmann

Switch to deprecated_register_soundhw(). Remove the now obsolete init function. Add an alias so both es1370 and ES1370 are working with -device.

---
 hw/audio/es1370.c | 9 ++-------
 qdev-monitor.c    | 1 +
 2 files changed, 3 insertions(+), 7 deletions(-)
hw/audio/es1370.c +2 -7
index 5f8a83ff5624..4255463a49ff 100644
@@ -884,12 +884,6 @@ static void es1370_exit(PCIDevice *dev)
     AUD_remove_card(&s->card);
 }
 
-static int es1370_init (PCIBus *bus)
-{
-    pci_create_simple (bus, -1, TYPE_ES1370);
-    return 0;
-}
-
 static Property es1370_properties[] = {
     DEFINE_AUDIO_PROPERTIES(ES1370State, card),
     DEFINE_PROP_END_OF_LIST(),
@@ -928,7 +922,8 @@ static const TypeInfo es1370_info = {
 static void es1370_register_types (void)
 {
     type_register_static (&es1370_info);
-    pci_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370", es1370_init);
+    deprecated_register_soundhw("es1370", "ENSONIQ AudioPCI ES1370",
+                                0, TYPE_ES1370);
 }
 
 type_init (es1370_register_types)
qdev-monitor.c +1 -0
index 105d9792ecdf..e3083fae394b 100644
@@ -55,6 +55,7 @@ typedef struct QDevAlias
 static const QDevAlias qdev_alias_table[] = {
     { "AC97", "ac97" }, /* -soundhw name */
     { "e1000", "e1000-82540em" },
+    { "ES1370", "es1370" }, /* -soundhw name */
     { "ich9-ahci", "ahci" },
     { "lsi53c895a", "lsi" },
     { "virtio-9p-ccw", "virtio-9p", QEMU_ARCH_S390X },
Signature · 1 line
2.18.4
#6 lore raw

PATCH v4 6/20 audio: deprecate -soundhw adlib

In reply to Gerd Hoffmann

Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

---
 hw/audio/adlib.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
hw/audio/adlib.c +1 -7
index 7c3b67dcfb8c..65dff5b6fca4 100644
@@ -319,16 +319,10 @@ static const TypeInfo adlib_info = {
     .class_init    = adlib_class_initfn,
 };
 
-static int Adlib_init (ISABus *bus)
-{
-    isa_create_simple (bus, TYPE_ADLIB);
-    return 0;
-}
-
 static void adlib_register_types (void)
 {
     type_register_static (&adlib_info);
-    isa_register_soundhw("adlib", ADLIB_DESC, Adlib_init);
+    deprecated_register_soundhw("adlib", ADLIB_DESC, 1, TYPE_ADLIB);
 }
 
 type_init (adlib_register_types)
Signature · 1 line
2.18.4
#7 lore raw

PATCH v4 7/20 audio: deprecate -soundhw cs4231a

In reply to Gerd Hoffmann

Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

---
 hw/audio/cs4231a.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
hw/audio/cs4231a.c +1 -7
index ffdbb58d6a11..59705a8d4701 100644
@@ -683,12 +683,6 @@ static void cs4231a_realizefn (DeviceState *dev, Error **errp)
     AUD_register_card ("cs4231a", &s->card);
 }
 
-static int cs4231a_init (ISABus *bus)
-{
-    isa_create_simple (bus, TYPE_CS4231A);
-    return 0;
-}
-
 static Property cs4231a_properties[] = {
     DEFINE_AUDIO_PROPERTIES(CSState, card),
     DEFINE_PROP_UINT32 ("iobase",  CSState, port, 0x534),
@@ -720,7 +714,7 @@ static const TypeInfo cs4231a_info = {
 static void cs4231a_register_types (void)
 {
     type_register_static (&cs4231a_info);
-    isa_register_soundhw("cs4231a", "CS4231A", cs4231a_init);
+    deprecated_register_soundhw("cs4231a", "CS4231A", 1, TYPE_CS4231A);
 }
 
 type_init (cs4231a_register_types)
Signature · 1 line
2.18.4
#8 lore raw

PATCH v4 8/20 audio: deprecate -soundhw gus

In reply to Gerd Hoffmann

Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

---
 hw/audio/gus.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
hw/audio/gus.c +1 -7
index c8df2bde6b32..7e4a8cadad6f 100644
@@ -286,12 +286,6 @@ static void gus_realizefn (DeviceState *dev, Error **errp)
     AUD_set_active_out (s->voice, 1);
 }
 
-static int GUS_init (ISABus *bus)
-{
-    isa_create_simple (bus, TYPE_GUS);
-    return 0;
-}
-
 static Property gus_properties[] = {
     DEFINE_AUDIO_PROPERTIES(GUSState, card),
     DEFINE_PROP_UINT32 ("freq",    GUSState, freq,        44100),
@@ -322,7 +316,7 @@ static const TypeInfo gus_info = {
 static void gus_register_types (void)
 {
     type_register_static (&gus_info);
-    isa_register_soundhw("gus", "Gravis Ultrasound GF1", GUS_init);
+    deprecated_register_soundhw("gus", "Gravis Ultrasound GF1", 1, TYPE_GUS);
 }
 
 type_init (gus_register_types)
Signature · 1 line
2.18.4
#9 lore raw

PATCH v4 9/20 audio: deprecate -soundhw sb16

In reply to Gerd Hoffmann

Switch to deprecated_register_soundhw().
Remove the now obsolete init function.

---
 hw/audio/sb16.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
hw/audio/sb16.c +2 -7
index df6f755a37f8..2d9e50f99b5d 100644
@@ -1415,12 +1415,6 @@ static void sb16_realizefn (DeviceState *dev, Error **errp)
     AUD_register_card ("sb16", &s->card);
 }
 
-static int SB16_init (ISABus *bus)
-{
-    isa_create_simple (bus, TYPE_SB16);
-    return 0;
-}
-
 static Property sb16_properties[] = {
     DEFINE_AUDIO_PROPERTIES(SB16State, card),
     DEFINE_PROP_UINT32 ("version", SB16State, ver,  0x0405), /* 4.5 */
@@ -1453,7 +1447,8 @@ static const TypeInfo sb16_info = {
 static void sb16_register_types (void)
 {
     type_register_static (&sb16_info);
-    isa_register_soundhw("sb16", "Creative Sound Blaster 16", SB16_init);
+    deprecated_register_soundhw("sb16", "Creative Sound Blaster 16",
+                                1, TYPE_SB16);
 }
 
 type_init (sb16_register_types)
Signature · 1 line
2.18.4
#10 lore raw

PATCH v4 10/20 audio: deprecate -soundhw hda

In reply to Gerd Hoffmann

Add deprecation message to the audio init function.

---
 hw/audio/intel-hda.c | 3 +++
 1 file changed, 3 insertions(+)
hw/audio/intel-hda.c +3 -0
index f673b8317a84..f6cea49686d7 100644
@@ -25,6 +25,7 @@
 #include "qemu/bitops.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
+#include "qemu/error-report.h"
 #include "hw/audio/soundhw.h"
 #include "intel-hda.h"
 #include "migration/vmstate.h"
@@ -1307,6 +1308,8 @@ static int intel_hda_and_codec_init(PCIBus *bus)
     BusState *hdabus;
     DeviceState *codec;
 
+    warn_report("'-soundhw hda' is deprecated, "
+                "please use '-device intel-hda -device hda-duplex' instead");
     controller = DEVICE(pci_create_simple(bus, -1, "intel-hda"));
     hdabus = QLIST_FIRST(&controller->child_bus);
     codec = qdev_new("hda-duplex");
Signature · 1 line
2.18.4
#11 lore raw

PATCH v4 11/20 pc_basic_device_init: pass PCMachineState

In reply to Gerd Hoffmann

Need access to pcms for pcspk initialization.
Just preparation, no functional change.

---
 include/hw/i386/pc.h | 3 ++-
 hw/i386/pc.c         | 3 ++-
 hw/i386/pc_piix.c    | 2 +-
 hw/i386/pc_q35.c     | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)
include/hw/i386/pc.h +2 -1
index e6135c34d656..9b94926410c0 100644
@@ -160,7 +160,8 @@ void pc_memory_init(PCMachineState *pcms,
                     MemoryRegion **ram_memory);
 uint64_t pc_pci_hole64_start(void);
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
-void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
+void pc_basic_device_init(struct PCMachineState *pcms,
+                          ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
                           bool no_vmport,
hw/i386/pc.c +2 -1
index d103b8c0ab82..9afb003dfc21 100644
@@ -1176,7 +1176,8 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
     g_free(a20_line);
 }
 
-void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
+void pc_basic_device_init(struct PCMachineState *pcms,
+                          ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
                           bool no_vmport,
hw/i386/pc_piix.c +1 -1
index 1497d0e4ae94..605252fe7936 100644
@@ -235,7 +235,7 @@ static void pc_init1(MachineState *machine,
     }
 
     /* init basic PC hardware */
-    pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, true,
+    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, true,
                          (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
                          0x4);
 
hw/i386/pc_q35.c +1 -1
index 46cd06524c68..e4b15f27227a 100644
@@ -275,7 +275,7 @@ static void pc_q35_init(MachineState *machine)
     }
 
     /* init basic PC hardware */
-    pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
+    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
                          (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
                          0xff0104);
 
Signature · 1 line
2.18.4
#12 lore raw

PATCH v4 12/20 pc_basic_device_init: drop has_pit arg

In reply to Gerd Hoffmann

Now that we pass pcms anyway, we don't need the has_pit arg any more. No functional change.

---
 include/hw/i386/pc.h | 1 -
 hw/i386/pc.c         | 3 +--
 hw/i386/pc_piix.c    | 2 +-
 hw/i386/pc_q35.c     | 2 +-
 4 files changed, 3 insertions(+), 5 deletions(-)
include/hw/i386/pc.h +0 -1
index 9b94926410c0..3512dcfd3d27 100644
@@ -165,7 +165,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
                           bool no_vmport,
-                          bool has_pit,
                           uint32_t hpet_irqs);
 void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
 void pc_cmos_init(PCMachineState *pcms,
hw/i386/pc.c +1 -2
index 9afb003dfc21..dfe8ba07e982 100644
@@ -1181,7 +1181,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
                           bool no_vmport,
-                          bool has_pit,
                           uint32_t hpet_irqs)
 {
     int i;
@@ -1232,7 +1231,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
 
     qemu_register_boot_set(pc_boot_set, *rtc_state);
 
-    if (!xen_enabled() && has_pit) {
+    if (!xen_enabled() && pcms->pit_enabled) {
         if (kvm_pit_in_kernel()) {
             pit = kvm_pit_init(isa_bus, 0x40);
         } else {
hw/i386/pc_piix.c +1 -1
index 605252fe7936..1242ed811804 100644
@@ -236,7 +236,7 @@ static void pc_init1(MachineState *machine,
 
     /* init basic PC hardware */
     pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, true,
-                         (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
+                         (pcms->vmport != ON_OFF_AUTO_ON),
                          0x4);
 
     pc_nic_init(pcmc, isa_bus, pci_bus);
hw/i386/pc_q35.c +1 -1
index e4b15f27227a..25dc40896673 100644
@@ -276,7 +276,7 @@ static void pc_q35_init(MachineState *machine)
 
     /* init basic PC hardware */
     pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
-                         (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
+                         (pcms->vmport != ON_OFF_AUTO_ON),
                          0xff0104);
 
     /* connect pm stuff to lpc */
Signature · 1 line
2.18.4
#13 lore raw

PATCH v4 13/20 pc_basic_device_init: drop no_vmport arg

In reply to Gerd Hoffmann

Now that we pass pcms anyway, we don't need the no_vmport arg any more. No functional change.

---
 include/hw/i386/pc.h | 1 -
 hw/i386/pc.c         | 3 +--
 hw/i386/pc_piix.c    | 1 -
 hw/i386/pc_q35.c     | 1 -
 4 files changed, 1 insertion(+), 5 deletions(-)
include/hw/i386/pc.h +0 -1
index 3512dcfd3d27..283754f42bd5 100644
@@ -164,7 +164,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
                           ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
-                          bool no_vmport,
                           uint32_t hpet_irqs);
 void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
 void pc_cmos_init(PCMachineState *pcms,
hw/i386/pc.c +1 -2
index dfe8ba07e982..ba88e1dfb80f 100644
@@ -1180,7 +1180,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
                           ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
-                          bool no_vmport,
                           uint32_t hpet_irqs)
 {
     int i;
@@ -1247,7 +1246,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
     i8257_dma_init(isa_bus, 0);
 
     /* Super I/O */
-    pc_superio_init(isa_bus, create_fdctrl, no_vmport);
+    pc_superio_init(isa_bus, create_fdctrl, pcms->vmport != ON_OFF_AUTO_ON);
 }
 
 void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus)
hw/i386/pc_piix.c +0 -1
index 1242ed811804..2752b108001c 100644
@@ -236,7 +236,6 @@ static void pc_init1(MachineState *machine,
 
     /* init basic PC hardware */
     pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, true,
-                         (pcms->vmport != ON_OFF_AUTO_ON),
                          0x4);
 
     pc_nic_init(pcmc, isa_bus, pci_bus);
hw/i386/pc_q35.c +0 -1
index 25dc40896673..b8c8eaa691f6 100644
@@ -276,7 +276,6 @@ static void pc_q35_init(MachineState *machine)
 
     /* init basic PC hardware */
     pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, !mc->no_floppy,
-                         (pcms->vmport != ON_OFF_AUTO_ON),
                          0xff0104);
 
     /* connect pm stuff to lpc */
Signature · 1 line
2.18.4
#14 lore raw

PATCH v4 14/20 softmmu: initialize spice and audio earlier

In reply to Gerd Hoffmann

audiodev must be initialized before machine_set_property so the machine can have audiodev property aliases.

spice must initialize before audiodev because the default audiodev is spice only in case spice is actually enabled.

---
 softmmu/vl.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
softmmu/vl.c +6 -6
index f669c06ede4a..3bfb9d29fd60 100644
@@ -4131,12 +4131,17 @@ void qemu_init(int argc, char **argv, char **envp)
                       fsdev_init_func, NULL, &error_fatal);
 #endif
 
+    /* spice needs the timers to be initialized by this point */
+    /* spice must initialize before audio as it changes the default auiodev */
+    qemu_spice_init();
+
     /*
-     * Note: we need to create block backends before
+     * Note: we need to create audio and block backends before
      * machine_set_property(), so machine properties can refer to
      * them.
      */
     configure_blockdev(&bdo_queue, machine_class, snapshot);
+    audio_init_audiodevs();
 
     machine_opts = qemu_get_machine_opts();
     qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
@@ -4230,9 +4235,6 @@ void qemu_init(int argc, char **argv, char **envp)
         semihosting_arg_fallback(kernel_filename, kernel_cmdline);
     }
 
-    /* spice needs the timers to be initialized by this point */
-    qemu_spice_init();
-
     cpu_ticks_init();
 
     if (default_net) {
@@ -4342,8 +4344,6 @@ void qemu_init(int argc, char **argv, char **envp)
         create_default_memdev(current_machine, mem_path);
     }
 
-    audio_init_audiodevs();
-
     /* from here on runstate is RUN_STATE_PRELAUNCH */
     machine_run_board_init(current_machine);
 
Signature · 1 line
2.18.4
#15 lore raw

PATCH v4 15/20 audio: rework pcspk_init()

In reply to Gerd Hoffmann

Instead of creating and returning the pc speaker accept it as argument. That allows to rework the initialization workflow in followup patches.

---
 include/hw/audio/pcspk.h | 6 +-----
 hw/i386/pc.c             | 2 +-
 hw/isa/i82378.c          | 2 +-
 3 files changed, 3 insertions(+), 7 deletions(-)
include/hw/audio/pcspk.h +1 -5
index 7e7f5f49dcb0..8b485602675f 100644
@@ -31,18 +31,14 @@
 
 #define TYPE_PC_SPEAKER "isa-pcspk"
 
-static inline ISADevice *pcspk_init(ISABus *bus, ISADevice *pit)
+static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
 {
     DeviceState *dev;
-    ISADevice *isadev;
 
-    isadev = isa_new(TYPE_PC_SPEAKER);
     dev = DEVICE(isadev);
     qdev_prop_set_uint32(dev, "iobase", 0x61);
     object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
     isa_realize_and_unref(isadev, bus, &error_fatal);
-
-    return isadev;
 }
 
 #endif /* HW_PCSPK_H */
hw/i386/pc.c +1 -1
index ba88e1dfb80f..3f1d42b05102 100644
@@ -1240,7 +1240,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
             /* connect PIT to output control line of the HPET */
             qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
         }
-        pcspk_init(isa_bus, pit);
+        pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
     }
 
     i8257_dma_init(isa_bus, 0);
hw/isa/i82378.c +1 -1
index d9e6c7fa0096..75a2da288157 100644
@@ -102,7 +102,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
     pit = i8254_pit_init(isabus, 0x40, 0, NULL);
 
     /* speaker */
-    pcspk_init(isabus, pit);
+    pcspk_init(isa_new(TYPE_PC_SPEAKER), isabus, pit);
 
     /* 2 82C37 (dma) */
     isa_create_simple(isabus, "i82374");
Signature · 1 line
2.18.4
#16 lore raw

PATCH v4 16/20 audio: create pcspk device early

In reply to Gerd Hoffmann

Create the pcspk device early, so it exists at
machine type initialization time.

---
 include/hw/i386/pc.h | 1 +
 hw/i386/pc.c         | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/hw/i386/pc.h +1 -0
index 283754f42bd5..3290b0b93097 100644
@@ -33,6 +33,7 @@ struct PCMachineState {
     PCIBus *bus;
     I2CBus *smbus;
     PFlashCFI01 *flash[2];
+    ISADevice *pcspk;
 
     /* Configuration options: */
     uint64_t max_ram_below_4g;
hw/i386/pc.c +2 -1
index 3f1d42b05102..f7ca8d981afa 100644
@@ -1240,7 +1240,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
             /* connect PIT to output control line of the HPET */
             qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(DEVICE(pit), 0));
         }
-        pcspk_init(isa_new(TYPE_PC_SPEAKER), isa_bus, pit);
+        pcspk_init(pcms->pcspk, isa_bus, pit);
     }
 
     i8257_dma_init(isa_bus, 0);
@@ -1912,6 +1912,7 @@ static void pc_machine_initfn(Object *obj)
     pcms->pit_enabled = true;
 
     pc_system_flash_create(pcms);
+    pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
 }
 
 static void pc_machine_reset(MachineState *machine)
Signature · 1 line
2.18.4
#17 lore raw

PATCH v4 17/20 audio: deprecate -soundhw pcspk

In reply to Gerd Hoffmann

Add deprecation message to the audio init function.

Factor out audio initialization and call that from both audio init and realize, so setting the audiodev property is enough to properly initialize pcspk.

Add a property alias to the machine type to set the audio device, so pcspk can be initialized using:
"-machine pcspk-audiodev=<name>"

Using "-global isa-pcspk.audiodev=<name>" works too but is not recommended.

---
 hw/audio/pcspk.c | 24 +++++++++++++++++++++---
 hw/i386/pc.c     |  2 ++
 2 files changed, 23 insertions(+), 3 deletions(-)
hw/audio/pcspk.c +21 -3
index c37a3878612e..4c7e339ac2b5 100644
@@ -28,6 +28,7 @@
 #include "audio/audio.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
+#include "qemu/error-report.h"
 #include "hw/timer/i8254.h"
 #include "migration/vmstate.h"
 #include "hw/audio/pcspk.h"
@@ -112,11 +113,15 @@ static void pcspk_callback(void *opaque, int free)
     }
 }
 
-static int pcspk_audio_init(ISABus *bus)
+static int pcspk_audio_init(PCSpkState *s)
 {
-    PCSpkState *s = pcspk_state;
     struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUDIO_FORMAT_U8, 0};
 
+    if (s->voice) {
+        /* already initialized */
+        return 0;
+    }
+
     AUD_register_card(s_spk, &s->card);
 
     s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
@@ -185,6 +190,10 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
 
     isa_register_ioport(isadev, &s->ioport, s->iobase);
 
+    if (s->card.state) {
+        pcspk_audio_init(s);
+    }
+
     pcspk_state = s;
 }
 
@@ -236,9 +245,18 @@ static const TypeInfo pcspk_info = {
     .class_init     = pcspk_class_initfn,
 };
 
+static int pcspk_audio_init_soundhw(ISABus *bus)
+{
+    PCSpkState *s = pcspk_state;
+
+    warn_report("'-soundhw pcspk' is deprecated, "
+                "please set a backend using '-machine pcspk-audiodev=<name>' instead");
+    return pcspk_audio_init(s);
+}
+
 static void pcspk_register(void)
 {
     type_register_static(&pcspk_info);
-    isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init);
+    isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init_soundhw);
 }
 type_init(pcspk_register)
hw/i386/pc.c +2 -0
index f7ca8d981afa..bd393f82377f 100644
@@ -1913,6 +1913,8 @@ static void pc_machine_initfn(Object *obj)
 
     pc_system_flash_create(pcms);
     pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
+    object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
+                              OBJECT(pcms->pcspk), "audiodev");
 }
 
 static void pc_machine_reset(MachineState *machine)
Signature · 1 line
2.18.4
#18 lore raw

PATCH v4 18/20 audio: add soundhw deprecation notice

In reply to Gerd Hoffmann
---
 docs/system/deprecated.rst | 9 +++++++++
 1 file changed, 9 insertions(+)
docs/system/deprecated.rst +9 -0
index 3a255591c341..4cbf3bba3944 100644
@@ -82,6 +82,15 @@ should specify an ``audiodev=`` property.  Additionally, when using
 vnc, you should specify an ``audiodev=`` propery if you plan to
 transmit audio through the VNC protocol.
 
+Creating sound card devices using ``-soundhw`` (since 5.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Sound card devices should be created using ``-device`` instead.  The
+names are the same for most devices.  The exceptions are ``hda`` which
+needs two devices (``-device intel-hda --device hda-duplex``) and
+``pcspk`` which can be activated using ``-machine
+pcspk-audiodev=<name>``.
+
 ``-mon ...,control=readline,pretty=on|off`` (since 4.1)
 '''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
Signature · 1 line
2.18.4
#19 lore raw

Re: [PATCH v4 18/20] audio: add soundhw deprecation notice

Quoted 10 lines · Gerd Hoffmann
---
  docs/system/deprecated.rst | 9 +++++++++
  1 file changed, 9 insertions(+)
docs/system/deprecated.rst +0 -0
index 3a255591c341..4cbf3bba3944 100644

docs/system/deprecated.rst should specify an ``audiodev=`` property. Additionally, when using · line 90

Quoted 9 lines
docs/system/deprecated.rst +6 -0
@@ -82,6 +82,15 @@ should specify an ``audiodev=`` property.  Additionally, when using
  vnc, you should specify an ``audiodev=`` propery if you plan to
  transmit audio through the VNC protocol.
 
+Creating sound card devices using ``-soundhw`` (since 5.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Sound card devices should be created using ``-device`` instead.  The
+names are the same for most devices.  The exceptions are ``hda`` which
+needs two devices (``-device intel-hda --device hda-duplex``) and

Both spellings work, but it looks inconsistent to have one -device and the other --device.

Quoted 7 lines
docs/system/deprecated.rst +3 -0
+``pcspk`` which can be activated using ``-machine
+pcspk-audiodev=<name>``.
+
  ``-mon ...,control=readline,pretty=on|off`` (since 4.1)
  '''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#20 lore raw

PATCH v4 19/20 pcspk: update docs/system/target-i386-desc.rst.inc

In reply to Gerd Hoffmann

Add PC speaker with config hints.

---
 docs/system/target-i386-desc.rst.inc | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
docs/system/target-i386-desc.rst.inc +12 -1
index 47a169e0ae2a..7d1fffacbea3 100644
@@ -31,6 +31,8 @@ The QEMU PC System emulator simulates the following peripherals:
 
 -  CS4231A compatible sound card
 
+-  PC speaker
+
 -  PCI UHCI, OHCI, EHCI or XHCI USB controller and a virtual USB-1.1
    hub.
 
@@ -49,7 +51,7 @@ must be told to not have parallel ports to have working GUS.
 
 .. parsed-literal::
 
-   |qemu_system_x86| dos.img -soundhw gus -parallel none
+   |qemu_system_x86| dos.img -device gus -parallel none
 
 Alternatively:
 
@@ -60,3 +62,12 @@ Alternatively:
 Or some other unclaimed IRQ.
 
 CS4231A is the chip used in Windows Sound System and GUSMAX products
+
+The PC speaker audio device can be configured using the pcspk-audiodev
+machine property, i.e.
+
+.. parsed-literal::
+
+   |qemu_system_x86| some.img \
+   -audiodev <backend>,id=<name> \
+   -machine pcspk-audiodev=<name>
Signature · 1 line
2.18.4
#21 lore raw

PATCH v4 20/20 audio: set default value for pcspk.iobase property

In reply to Gerd Hoffmann

Allows to drop the explicit qdev_prop_set_uint32 call in pcspk_init.

---
 include/hw/audio/pcspk.h | 6 +-----
 hw/audio/pcspk.c         | 2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)
include/hw/audio/pcspk.h +1 -5
index 8b485602675f..06cba00b8376 100644
@@ -33,11 +33,7 @@
 
 static inline void pcspk_init(ISADevice *isadev, ISABus *bus, ISADevice *pit)
 {
-    DeviceState *dev;
-
-    dev = DEVICE(isadev);
-    qdev_prop_set_uint32(dev, "iobase", 0x61);
-    object_property_set_link(OBJECT(dev), OBJECT(pit), "pit", NULL);
+    object_property_set_link(OBJECT(isadev), OBJECT(pit), "pit", NULL);
     isa_realize_and_unref(isadev, bus, &error_fatal);
 }
 
hw/audio/pcspk.c +1 -1
index 4c7e339ac2b5..ea539e7605a8 100644
@@ -219,7 +219,7 @@ static const VMStateDescription vmstate_spk = {
 
 static Property pcspk_properties[] = {
     DEFINE_AUDIO_PROPERTIES(PCSpkState, card),
-    DEFINE_PROP_UINT32("iobase", PCSpkState, iobase,  -1),
+    DEFINE_PROP_UINT32("iobase", PCSpkState, iobase,  0x61),
     DEFINE_PROP_BOOL("migrate", PCSpkState, migrate,  true),
     DEFINE_PROP_END_OF_LIST(),
 };
Signature · 1 line
2.18.4
#22 lore raw

Re: [PATCH v4 20/20] audio: set default value for pcspk.iobase property

Quoted 1 line · Gerd Hoffmann

Allows to drop the explicit qdev_prop_set_uint32 call in pcspk_init.

"allows to $verb" is not idiomatic, better is "allows ${verb}ing" [Allows dropping] or "allows $subject to $verb" [Allows us to drop].

Quoted 7 lines
---
  include/hw/audio/pcspk.h | 6 +-----
  hw/audio/pcspk.c         | 2 +-
  2 files changed, 2 insertions(+), 6 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org