#include "qapi/error.h"
#include "qemu/module.h"
#include "virtio-vga.h"
+#include "qom/object.h"
static void virtio_vga_base_invalidate_display(void *opaque)
{
VirtIOGPUBase *g = vvga->vgpu;
if (g->enable) {
- virtio_gpu_ops.invalidate(g);
+ g->hw_ops->invalidate(g);
} else {
vvga->vga.hw_ops->invalidate(&vvga->vga);
}
VirtIOGPUBase *g = vvga->vgpu;
if (g->enable) {
- virtio_gpu_ops.gfx_update(g);
+ g->hw_ops->gfx_update(g);
} else {
vvga->vga.hw_ops->gfx_update(&vvga->vga);
}
VirtIOGPUBase *g = vvga->vgpu;
if (g->enable) {
- if (virtio_gpu_ops.text_update) {
- virtio_gpu_ops.text_update(g, chardata);
+ if (g->hw_ops->text_update) {
+ g->hw_ops->text_update(g, chardata);
}
} else {
if (vvga->vga.hw_ops->text_update) {
VirtIOVGABase *vvga = opaque;
VirtIOGPUBase *g = vvga->vgpu;
- if (virtio_gpu_ops.ui_info) {
- return virtio_gpu_ops.ui_info(g, idx, info);
+ if (g->hw_ops->ui_info) {
+ return g->hw_ops->ui_info(g, idx, info);
}
return -1;
}
VirtIOVGABase *vvga = opaque;
VirtIOGPUBase *g = vvga->vgpu;
- if (virtio_gpu_ops.gl_block) {
- virtio_gpu_ops.gl_block(g, block);
+ if (g->hw_ops->gl_block) {
+ g->hw_ops->gl_block(g, block);
}
}
+static void virtio_vga_base_gl_flushed(void *opaque)
+{
+ VirtIOVGABase *vvga = opaque;
+ VirtIOGPUBase *g = vvga->vgpu;
+
+ if (g->hw_ops->gl_flushed) {
+ g->hw_ops->gl_flushed(g);
+ }
+}
+
+static int virtio_vga_base_get_flags(void *opaque)
+{
+ VirtIOVGABase *vvga = opaque;
+ VirtIOGPUBase *g = vvga->vgpu;
+
+ return g->hw_ops->get_flags(g);
+}
+
static const GraphicHwOps virtio_vga_base_ops = {
+ .get_flags = virtio_vga_base_get_flags,
.invalidate = virtio_vga_base_invalidate_display,
.gfx_update = virtio_vga_base_update_display,
.text_update = virtio_vga_base_text_update,
.ui_info = virtio_vga_base_ui_info,
.gl_block = virtio_vga_base_gl_block,
+ .gl_flushed = virtio_vga_base_gl_flushed,
};
static const VMStateDescription vmstate_virtio_vga_base = {
VirtIOVGABase *vvga = VIRTIO_VGA_BASE(vpci_dev);
VirtIOGPUBase *g = vvga->vgpu;
VGACommonState *vga = &vvga->vga;
- Error *err = NULL;
uint32_t offset;
int i;
*/
vpci_dev->modern_mem_bar_idx = 2;
vpci_dev->msix_bar_idx = 4;
+ vpci_dev->modern_io_bar_idx = 5;
if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) {
/*
vpci_dev->common.offset = offset;
/* init virtio bits */
- qdev_set_parent_bus(DEVICE(g), BUS(&vpci_dev->bus));
virtio_pci_force_virtio_1(vpci_dev);
- object_property_set_bool(OBJECT(g), true, "realized", &err);
- if (err) {
- error_propagate(errp, err);
+ if (!qdev_realize(DEVICE(g), BUS(&vpci_dev->bus), errp)) {
return;
}
graphic_console_set_hwops(vga->con, &virtio_vga_base_ops, vvga);
for (i = 0; i < g->conf.max_outputs; i++) {
- object_property_set_link(OBJECT(g->scanout[i].con),
- OBJECT(vpci_dev),
- "device", errp);
+ object_property_set_link(OBJECT(g->scanout[i].con), "device",
+ OBJECT(vpci_dev), &error_abort);
}
}
vga_dirty_log_start(&vvga->vga);
}
+static bool virtio_vga_get_big_endian_fb(Object *obj, Error **errp)
+{
+ VirtIOVGABase *d = VIRTIO_VGA_BASE(obj);
+
+ return d->vga.big_endian_fb;
+}
+
+static void virtio_vga_set_big_endian_fb(Object *obj, bool value, Error **errp)
+{
+ VirtIOVGABase *d = VIRTIO_VGA_BASE(obj);
+
+ d->vga.big_endian_fb = value;
+}
+
static Property virtio_vga_base_properties[] = {
DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
DEFINE_PROP_END_OF_LIST(),
PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
- dc->props = virtio_vga_base_properties;
+ device_class_set_props(dc, virtio_vga_base_properties);
dc->vmsd = &vmstate_virtio_vga_base;
dc->hotpluggable = false;
device_class_set_parent_reset(dc, virtio_vga_base_reset,
k->realize = virtio_vga_base_realize;
pcidev_k->romfile = "vgabios-virtio.bin";
pcidev_k->class_id = PCI_CLASS_DISPLAY_VGA;
+
+ /* Expose framebuffer byteorder via QOM */
+ object_class_property_add_bool(klass, "big-endian-framebuffer",
+ virtio_vga_get_big_endian_fb,
+ virtio_vga_set_big_endian_fb);
}
static TypeInfo virtio_vga_base_info = {
.name = TYPE_VIRTIO_VGA_BASE,
.parent = TYPE_VIRTIO_PCI,
- .instance_size = sizeof(struct VirtIOVGABase),
- .class_size = sizeof(struct VirtIOVGABaseClass),
+ .instance_size = sizeof(VirtIOVGABase),
+ .class_size = sizeof(VirtIOVGABaseClass),
.class_init = virtio_vga_base_class_init,
.abstract = true,
};
#define TYPE_VIRTIO_VGA "virtio-vga"
-#define VIRTIO_VGA(obj) \
- OBJECT_CHECK(VirtIOVGA, (obj), TYPE_VIRTIO_VGA)
+typedef struct VirtIOVGA VirtIOVGA;
+DECLARE_INSTANCE_CHECKER(VirtIOVGA, VIRTIO_VGA,
+ TYPE_VIRTIO_VGA)
-typedef struct VirtIOVGA {
+struct VirtIOVGA {
VirtIOVGABase parent_obj;
VirtIOGPU vdev;
-} VirtIOVGA;
+};
static void virtio_vga_inst_initfn(Object *obj)
{
static VirtioPCIDeviceTypeInfo virtio_vga_info = {
.generic_name = TYPE_VIRTIO_VGA,
.parent = TYPE_VIRTIO_VGA_BASE,
- .instance_size = sizeof(struct VirtIOVGA),
+ .instance_size = sizeof(VirtIOVGA),
.instance_init = virtio_vga_inst_initfn,
};