meson: convert hw/vfio
[qemu.git] / hw / display / ramfb-standalone.c
1 #include "qemu/osdep.h"
2 #include "qapi/error.h"
3 #include "qemu/module.h"
4 #include "hw/loader.h"
5 #include "hw/qdev-properties.h"
6 #include "hw/display/ramfb.h"
7 #include "ui/console.h"
8
9 #define RAMFB(obj) OBJECT_CHECK(RAMFBStandaloneState, (obj), TYPE_RAMFB_DEVICE)
10
11 typedef struct RAMFBStandaloneState {
12 SysBusDevice parent_obj;
13 QemuConsole *con;
14 RAMFBState *state;
15 } RAMFBStandaloneState;
16
17 static void display_update_wrapper(void *dev)
18 {
19 RAMFBStandaloneState *ramfb = RAMFB(dev);
20
21 if (0 /* native driver active */) {
22 /* non-standalone device would run native display update here */;
23 } else {
24 ramfb_display_update(ramfb->con, ramfb->state);
25 }
26 }
27
28 static const GraphicHwOps wrapper_ops = {
29 .gfx_update = display_update_wrapper,
30 };
31
32 static void ramfb_realizefn(DeviceState *dev, Error **errp)
33 {
34 RAMFBStandaloneState *ramfb = RAMFB(dev);
35
36 ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
37 ramfb->state = ramfb_setup(errp);
38 }
39
40 static void ramfb_class_initfn(ObjectClass *klass, void *data)
41 {
42 DeviceClass *dc = DEVICE_CLASS(klass);
43
44 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
45 dc->realize = ramfb_realizefn;
46 dc->desc = "ram framebuffer standalone device";
47 dc->user_creatable = true;
48 }
49
50 static const TypeInfo ramfb_info = {
51 .name = TYPE_RAMFB_DEVICE,
52 .parent = TYPE_SYS_BUS_DEVICE,
53 .instance_size = sizeof(RAMFBStandaloneState),
54 .class_init = ramfb_class_initfn,
55 };
56
57 static void ramfb_register_types(void)
58 {
59 type_register_static(&ramfb_info);
60 }
61
62 type_init(ramfb_register_types)