Create the pcspk device early enough that we can create an audiodev
property alias for the machine type.
pcspk init works now with "-audiodev <backend>,id=<name> -M
pc.pcspk-audiodev=<name>".
Signed-off-by: Gerd Hoffmann <kraxel(a)redhat.com>
---
include/hw/i386/pc.h | 1 +
hw/i386/pc.c | 5 ++++-
softmmu/vl.c | 4 ++--
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 283754f42bd5..3290b0b93097 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -33,6 +33,7 @@ struct PCMachineState {
PCIBus *bus;
I2CBus *smbus;
PFlashCFI01 *flash[2];
+ ISADevice *pcspk;
/* Configuration options: */
uint64_t max_ram_below_4g;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3f1d42b05102..bd393f82377f 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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,9 @@ static void pc_machine_initfn(Object *obj)
pcms->pit_enabled = true;
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)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index b8dc1f5a0e86..e8580ccaa2c6 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4287,6 +4287,8 @@ void qemu_init(int argc, char **argv, char **envp)
exit (i == 1 ? 1 : 0);
}
+ audio_init_audiodevs();
+
/* This checkpoint is required by replay to separate prior clock
reading from the other reads, because timer polling functions query
clock values from the log. */
@@ -4344,8 +4346,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);
--
2.18.4