hw/arm: Support machine-default audiodev with fallback
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index b109ece..d176e9a 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -27,6 +27,7 @@
#include "hw/irq.h"
#include "hw/sd/sd.h"
#include "qom/object.h"
+#include "audio/audio.h"
#define TYPE_INTEGRATOR_CM "integrator_core"
OBJECT_DECLARE_SIMPLE_TYPE(IntegratorCMState, INTEGRATOR_CM)
@@ -660,7 +661,13 @@
&error_fatal);
}
- sysbus_create_varargs("pl041", 0x1d000000, pic[25], NULL);
+ dev = qdev_new("pl041");
+ if (machine->audiodev) {
+ qdev_prop_set_string(dev, "audiodev", machine->audiodev);
+ }
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x1d000000);
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[25]);
if (nd_table[0].used)
smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
@@ -678,6 +685,8 @@
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926");
mc->default_ram_id = "integrator.ram";
+
+ machine_add_audiodev_property(mc);
}
DEFINE_MACHINE("integratorcp", integratorcp_machine_init)
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index dc4e43e..9703bfb 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -37,9 +37,9 @@
#include "qemu/cutils.h"
#include "qom/object.h"
#include "hw/net/mv88w8618_eth.h"
+#include "audio/audio.h"
#include "qemu/error-report.h"
-
#define MP_MISC_BASE 0x80002000
#define MP_MISC_SIZE 0x00001000
@@ -1326,7 +1326,12 @@
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
}
- wm8750_dev = i2c_slave_create_simple(i2c, TYPE_WM8750, MP_WM_ADDR);
+ wm8750_dev = i2c_slave_new(TYPE_WM8750, MP_WM_ADDR);
+ if (machine->audiodev) {
+ qdev_prop_set_string(DEVICE(wm8750_dev), "audiodev", machine->audiodev);
+ }
+ i2c_slave_realize_and_unref(wm8750_dev, i2c, &error_abort);
+
dev = qdev_new(TYPE_MV88W8618_AUDIO);
s = SYS_BUS_DEVICE(dev);
object_property_set_link(OBJECT(dev), "wm8750", OBJECT(wm8750_dev),
@@ -1347,6 +1352,8 @@
mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926");
mc->default_ram_size = MP_RAM_DEFAULT_SIZE;
mc->default_ram_id = "musicpal.ram";
+
+ machine_add_audiodev_property(mc);
}
DEFINE_MACHINE("musicpal", musicpal_machine_init)
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 9e49e9e..35aff46 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -1432,6 +1432,8 @@
/* Actually two chips of 0x4000000 bytes each */
mc->default_ram_size = 0x08000000;
mc->default_ram_id = "omap2.dram";
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo n800_type = {
@@ -1452,6 +1454,8 @@
/* Actually two chips of 0x4000000 bytes each */
mc->default_ram_size = 0x08000000;
mc->default_ram_id = "omap2.dram";
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo n810_type = {
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index d5a2ae7..41b1f59 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -37,6 +37,7 @@
#include "hw/block/flash.h"
#include "hw/arm/soc_dma.h"
#include "hw/sysbus.h"
+#include "hw/boards.h"
#include "audio/audio.h"
/* Enhanced Audio Controller (CODEC only) */
@@ -609,6 +610,10 @@
s->codec.txdrq = *drq;
omap_eac_reset(s);
+ if (current_machine->audiodev) {
+ s->codec.card.name = g_strdup(current_machine->audiodev);
+ s->codec.card.state = audio_state_by_name(s->codec.card.name, &error_fatal);
+ }
AUD_register_card("OMAP EAC", &s->codec.card);
memory_region_init_io(&s->iomem, NULL, &omap_eac_ops, s, "omap.eac",
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
index 17c11ac..b86f2c3 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -310,6 +310,8 @@
mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
mc->default_ram_size = 0x02000000;
mc->default_ram_id = "omap1.dram";
+
+ machine_add_audiodev_property(mc);
}
DEFINE_MACHINE("cheetah", palmte_machine_init)
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index a5aa2f0..8f89526 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -29,6 +29,7 @@
#include "hw/irq.h"
#include "hw/i2c/arm_sbcon_i2c.h"
#include "hw/sd/sd.h"
+#include "audio/audio.h"
#define SMP_BOOT_ADDR 0xe0000000
#define SMP_BOOTREG_ADDR 0x10000030
@@ -207,6 +208,9 @@
pl041 = qdev_new("pl041");
qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512);
+ if (machine->audiodev) {
+ qdev_prop_set_string(pl041, "audiodev", machine->audiodev);
+ }
sysbus_realize_and_unref(SYS_BUS_DEVICE(pl041), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, 0x10004000);
sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, pic[19]);
@@ -412,6 +416,8 @@
mc->block_default_type = IF_SCSI;
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926");
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo realview_eb_type = {
@@ -430,6 +436,8 @@
mc->max_cpus = 4;
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm11mpcore");
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo realview_eb_mpcore_type = {
@@ -446,6 +454,8 @@
mc->init = realview_pb_a8_init;
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo realview_pb_a8_type = {
@@ -463,6 +473,8 @@
mc->max_cpus = 4;
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo realview_pbx_a9_type = {
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index f732fe0..cc268c6 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -35,6 +35,7 @@
#include "exec/address-spaces.h"
#include "cpu.h"
#include "qom/object.h"
+#include "audio/audio.h"
enum spitz_model_e { spitz, akita, borzoi, terrier };
@@ -774,15 +775,19 @@
i2c_slave_set_address(wm, SPITZ_WM_ADDRL);
}
-static void spitz_i2c_setup(PXA2xxState *cpu)
+static void spitz_i2c_setup(MachineState *machine, PXA2xxState *cpu)
{
/* Attach the CPU on one end of our I2C bus. */
I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
- DeviceState *wm;
-
/* Attach a WM8750 to the bus */
- wm = DEVICE(i2c_slave_create_simple(bus, TYPE_WM8750, 0));
+ I2CSlave *i2c_dev = i2c_slave_new(TYPE_WM8750, 0);
+ DeviceState *wm = DEVICE(i2c_dev);
+
+ if (machine->audiodev) {
+ qdev_prop_set_string(wm, "audiodev", machine->audiodev);
+ }
+ i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
spitz_wm8750_addr(wm, 0, 0);
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM,
@@ -1013,7 +1018,7 @@
spitz_gpio_setup(mpu, (model == akita) ? 1 : 2);
- spitz_i2c_setup(mpu);
+ spitz_i2c_setup(machine, mpu);
if (model == akita)
spitz_akita_i2c_setup(mpu);
@@ -1037,6 +1042,8 @@
mc->block_default_type = IF_IDE;
mc->ignore_memory_transaction_failures = true;
mc->init = spitz_common_init;
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo spitz_common_info = {
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 05b9462..2f22dc8 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -26,6 +26,7 @@
#include "hw/char/pl011.h"
#include "hw/sd/sd.h"
#include "qom/object.h"
+#include "audio/audio.h"
#define VERSATILE_FLASH_ADDR 0x34000000
#define VERSATILE_FLASH_SIZE (64 * 1024 * 1024)
@@ -343,6 +344,9 @@
/* Add PL041 AACI Interface to the LM4549 codec */
pl041 = qdev_new("pl041");
qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512);
+ if (machine->audiodev) {
+ qdev_prop_set_string(pl041, "audiodev", machine->audiodev);
+ }
sysbus_realize_and_unref(SYS_BUS_DEVICE(pl041), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, 0x10004000);
sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, sic[24]);
@@ -416,6 +420,8 @@
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926");
mc->default_ram_id = "versatile.ram";
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo versatilepb_type = {
@@ -434,6 +440,8 @@
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926");
mc->default_ram_id = "versatile.ram";
+
+ machine_add_audiodev_property(mc);
}
static const TypeInfo versatileab_type = {
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 56abadd..8ff37f5 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -44,6 +44,7 @@
#include "hw/i2c/arm_sbcon_i2c.h"
#include "hw/sd/sd.h"
#include "qom/object.h"
+#include "audio/audio.h"
#define VEXPRESS_BOARD_ID 0x8e0
#define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024)
@@ -613,6 +614,9 @@
pl041 = qdev_new("pl041");
qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512);
+ if (machine->audiodev) {
+ qdev_prop_set_string(pl041, "audiodev", machine->audiodev);
+ }
sysbus_realize_and_unref(SYS_BUS_DEVICE(pl041), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, map[VE_PL041]);
sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, pic[11]);
@@ -776,6 +780,7 @@
mc->ignore_memory_transaction_failures = true;
mc->default_ram_id = "vexpress.highmem";
+ machine_add_audiodev_property(mc);
object_class_property_add_bool(oc, "secure", vexpress_get_secure,
vexpress_set_secure);
object_class_property_set_description(oc, "secure",
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
index 21483f7..c5a07cf 100644
--- a/hw/arm/xlnx-zcu102.c
+++ b/hw/arm/xlnx-zcu102.c
@@ -24,6 +24,7 @@
#include "sysemu/device_tree.h"
#include "qom/object.h"
#include "net/can_emu.h"
+#include "audio/audio.h"
struct XlnxZCU102 {
MachineState parent_obj;
@@ -143,6 +144,10 @@
object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_XLNX_ZYNQMP);
+ if (machine->audiodev) {
+ qdev_prop_set_string(DEVICE(&s->soc.dp), "audiodev", machine->audiodev);
+ }
+
object_property_set_link(OBJECT(&s->soc), "ddr-ram", OBJECT(machine->ram),
&error_abort);
object_property_set_bool(OBJECT(&s->soc), "secure", s->secure,
@@ -275,6 +280,7 @@
mc->default_cpus = XLNX_ZYNQMP_NUM_APU_CPUS;
mc->default_ram_id = "ddr-ram";
+ machine_add_audiodev_property(mc);
object_class_property_add_bool(oc, "secure", zcu102_get_secure,
zcu102_set_secure);
object_class_property_set_description(oc, "secure",
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index dc25304..d9a08fa 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -27,6 +27,7 @@
#include "exec/address-spaces.h"
#include "cpu.h"
#include "qom/object.h"
+#include "qapi/error.h"
#ifdef DEBUG_Z2
#define DPRINTF(fmt, ...) \
@@ -307,6 +308,7 @@
void *z2_lcd;
I2CBus *bus;
DeviceState *wm;
+ I2CSlave *i2c_dev;
/* Setup CPU & memory */
mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type);
@@ -328,8 +330,17 @@
type_register_static(&aer915_info);
z2_lcd = ssi_create_peripheral(mpu->ssp[1], TYPE_ZIPIT_LCD);
bus = pxa2xx_i2c_bus(mpu->i2c[0]);
+
i2c_slave_create_simple(bus, TYPE_AER915, 0x55);
- wm = DEVICE(i2c_slave_create_simple(bus, TYPE_WM8750, 0x1b));
+
+ i2c_dev = i2c_slave_new(TYPE_WM8750, 0x1b);
+ wm = DEVICE(i2c_dev);
+
+ if (machine->audiodev) {
+ qdev_prop_set_string(wm, "audiodev", machine->audiodev);
+ }
+ i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
+
mpu->i2s->opaque = wm;
mpu->i2s->codec_out = wm8750_dac_dat;
mpu->i2s->codec_in = wm8750_adc_dat;
@@ -348,6 +359,8 @@
mc->init = z2_init;
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c5");
+
+ machine_add_audiodev_property(mc);
}
DEFINE_MACHINE("z2", z2_machine_init)
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
index f568759..e7960a5 100644
--- a/hw/input/tsc210x.c
+++ b/hw/input/tsc210x.c
@@ -27,6 +27,7 @@
#include "sysemu/reset.h"
#include "ui/console.h"
#include "hw/arm/omap.h" /* For I2SCodec */
+#include "hw/boards.h" /* for current_machine */
#include "hw/input/tsc2xxx.h"
#include "hw/irq.h"
#include "migration/vmstate.h"
@@ -1097,6 +1098,10 @@
qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1, name);
+ if (current_machine->audiodev) {
+ s->card.name = g_strdup(current_machine->audiodev);
+ s->card.state = audio_state_by_name(s->card.name, &error_fatal);
+ }
AUD_register_card(s->name, &s->card);
qemu_register_reset((void *) tsc210x_reset, s);