hw/display: add standalone ramfb device

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 20180613122948.18149-3-kraxel@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2018-06-13 14:29:46 +02:00
parent 995b30179b
commit 94692dcd71
7 changed files with 79 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#include "hw/vfio/vfio-platform.h" #include "hw/vfio/vfio-platform.h"
#include "hw/vfio/vfio-calxeda-xgmac.h" #include "hw/vfio/vfio-calxeda-xgmac.h"
#include "hw/vfio/vfio-amd-xgbe.h" #include "hw/vfio/vfio-amd-xgbe.h"
#include "hw/display/ramfb.h"
#include "hw/arm/fdt.h" #include "hw/arm/fdt.h"
/* /*
@ -406,12 +407,18 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque)
#endif /* CONFIG_LINUX */ #endif /* CONFIG_LINUX */
static int no_fdt_node(SysBusDevice *sbdev, void *opaque)
{
return 0;
}
/* list of supported dynamic sysbus devices */ /* list of supported dynamic sysbus devices */
static const NodeCreationPair add_fdt_node_functions[] = { static const NodeCreationPair add_fdt_node_functions[] = {
#ifdef CONFIG_LINUX #ifdef CONFIG_LINUX
{TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node}, {TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node},
{TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node}, {TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node},
#endif #endif
{TYPE_RAMFB_DEVICE, no_fdt_node},
{"", NULL}, /* last element */ {"", NULL}, /* last element */
}; };

View File

@ -36,6 +36,7 @@
#include "hw/arm/virt.h" #include "hw/arm/virt.h"
#include "hw/vfio/vfio-calxeda-xgmac.h" #include "hw/vfio/vfio-calxeda-xgmac.h"
#include "hw/vfio/vfio-amd-xgbe.h" #include "hw/vfio/vfio-amd-xgbe.h"
#include "hw/display/ramfb.h"
#include "hw/devices.h" #include "hw/devices.h"
#include "net/net.h" #include "net/net.h"
#include "sysemu/device_tree.h" #include "sysemu/device_tree.h"
@ -1659,6 +1660,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
mc->max_cpus = 255; mc->max_cpus = 255;
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_CALXEDA_XGMAC); machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_CALXEDA_XGMAC);
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_AMD_XGBE); machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_AMD_XGBE);
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
mc->block_default_type = IF_VIRTIO; mc->block_default_type = IF_VIRTIO;
mc->no_cdrom = 1; mc->no_cdrom = 1;
mc->pci_allow_0_address = true; mc->pci_allow_0_address = true;

View File

@ -1,4 +1,5 @@
common-obj-y += ramfb.o common-obj-y += ramfb.o
common-obj-y += ramfb-standalone.o
common-obj-$(CONFIG_ADS7846) += ads7846.o common-obj-$(CONFIG_ADS7846) += ads7846.o
common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o

View File

@ -0,0 +1,62 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "hw/loader.h"
#include "hw/isa/isa.h"
#include "hw/display/ramfb.h"
#include "ui/console.h"
#include "sysemu/sysemu.h"
#define RAMFB(obj) OBJECT_CHECK(RAMFBStandaloneState, (obj), TYPE_RAMFB_DEVICE)
typedef struct RAMFBStandaloneState {
SysBusDevice parent_obj;
QemuConsole *con;
RAMFBState *state;
} RAMFBStandaloneState;
static void display_update_wrapper(void *dev)
{
RAMFBStandaloneState *ramfb = RAMFB(dev);
if (0 /* native driver active */) {
/* non-standalone device would run native display update here */;
} else {
ramfb_display_update(ramfb->con, ramfb->state);
}
}
static const GraphicHwOps wrapper_ops = {
.gfx_update = display_update_wrapper,
};
static void ramfb_realizefn(DeviceState *dev, Error **errp)
{
RAMFBStandaloneState *ramfb = RAMFB(dev);
ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
ramfb->state = ramfb_setup(errp);
}
static void ramfb_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->realize = ramfb_realizefn;
dc->desc = "ram framebuffer standalone device";
dc->user_creatable = true;
}
static const TypeInfo ramfb_info = {
.name = TYPE_RAMFB_DEVICE,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(RAMFBStandaloneState),
.class_init = ramfb_class_initfn,
};
static void ramfb_register_types(void)
{
type_register_static(&ramfb_info);
}
type_init(ramfb_register_types)

View File

@ -28,6 +28,7 @@
#include "hw/loader.h" #include "hw/loader.h"
#include "hw/i386/pc.h" #include "hw/i386/pc.h"
#include "hw/i386/apic.h" #include "hw/i386/apic.h"
#include "hw/display/ramfb.h"
#include "hw/smbios/smbios.h" #include "hw/smbios/smbios.h"
#include "hw/pci/pci.h" #include "hw/pci/pci.h"
#include "hw/pci/pci_ids.h" #include "hw/pci/pci_ids.h"
@ -423,6 +424,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
m->desc = "Standard PC (i440FX + PIIX, 1996)"; m->desc = "Standard PC (i440FX + PIIX, 1996)";
m->default_machine_opts = "firmware=bios-256k.bin"; m->default_machine_opts = "firmware=bios-256k.bin";
m->default_display = "std"; m->default_display = "std";
machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
} }
static void pc_i440fx_3_0_machine_options(MachineClass *m) static void pc_i440fx_3_0_machine_options(MachineClass *m)

View File

@ -45,6 +45,7 @@
#include "hw/i386/ich9.h" #include "hw/i386/ich9.h"
#include "hw/i386/amd_iommu.h" #include "hw/i386/amd_iommu.h"
#include "hw/i386/intel_iommu.h" #include "hw/i386/intel_iommu.h"
#include "hw/display/ramfb.h"
#include "hw/smbios/smbios.h" #include "hw/smbios/smbios.h"
#include "hw/ide/pci.h" #include "hw/ide/pci.h"
#include "hw/ide/ahci.h" #include "hw/ide/ahci.h"
@ -305,6 +306,7 @@ static void pc_q35_machine_options(MachineClass *m)
m->no_floppy = 1; m->no_floppy = 1;
machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE);
machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
m->max_cpus = 288; m->max_cpus = 288;
} }

View File

@ -6,4 +6,7 @@ typedef struct RAMFBState RAMFBState;
void ramfb_display_update(QemuConsole *con, RAMFBState *s); void ramfb_display_update(QemuConsole *con, RAMFBState *s);
RAMFBState *ramfb_setup(Error **errp); RAMFBState *ramfb_setup(Error **errp);
/* ramfb-standalone.c */
#define TYPE_RAMFB_DEVICE "ramfb"
#endif /* RAMFB_H */ #endif /* RAMFB_H */