meson: add more sections to main meson.build
[qemu/ar7.git] / hw / display / ramfb-standalone.c
bloba96e7ebcd9fa57989475e25b75599990acbe884f
1 #include "qemu/osdep.h"
2 #include "migration/vmstate.h"
3 #include "qapi/error.h"
4 #include "qemu/module.h"
5 #include "hw/loader.h"
6 #include "hw/qdev-properties.h"
7 #include "hw/display/ramfb.h"
8 #include "ui/console.h"
9 #include "qom/object.h"
11 typedef struct RAMFBStandaloneState RAMFBStandaloneState;
12 DECLARE_INSTANCE_CHECKER(RAMFBStandaloneState, RAMFB,
13 TYPE_RAMFB_DEVICE)
15 struct RAMFBStandaloneState {
16 SysBusDevice parent_obj;
17 QemuConsole *con;
18 RAMFBState *state;
19 bool migrate;
22 static void display_update_wrapper(void *dev)
24 RAMFBStandaloneState *ramfb = RAMFB(dev);
26 if (0 /* native driver active */) {
27 /* non-standalone device would run native display update here */;
28 } else {
29 ramfb_display_update(ramfb->con, ramfb->state);
33 static const GraphicHwOps wrapper_ops = {
34 .gfx_update = display_update_wrapper,
37 static void ramfb_realizefn(DeviceState *dev, Error **errp)
39 RAMFBStandaloneState *ramfb = RAMFB(dev);
41 ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
42 ramfb->state = ramfb_setup(errp);
45 static bool migrate_needed(void *opaque)
47 RAMFBStandaloneState *ramfb = RAMFB(opaque);
49 return ramfb->migrate;
52 static const VMStateDescription ramfb_dev_vmstate = {
53 .name = "ramfb-dev",
54 .version_id = 1,
55 .minimum_version_id = 1,
56 .needed = migrate_needed,
57 .fields = (VMStateField[]) {
58 VMSTATE_STRUCT_POINTER(state, RAMFBStandaloneState, ramfb_vmstate, RAMFBState),
59 VMSTATE_END_OF_LIST()
63 static Property ramfb_properties[] = {
64 DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate, true),
65 DEFINE_PROP_END_OF_LIST(),
68 static void ramfb_class_initfn(ObjectClass *klass, void *data)
70 DeviceClass *dc = DEVICE_CLASS(klass);
72 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
73 dc->vmsd = &ramfb_dev_vmstate;
74 dc->realize = ramfb_realizefn;
75 dc->desc = "ram framebuffer standalone device";
76 dc->user_creatable = true;
77 device_class_set_props(dc, ramfb_properties);
80 static const TypeInfo ramfb_info = {
81 .name = TYPE_RAMFB_DEVICE,
82 .parent = TYPE_SYS_BUS_DEVICE,
83 .instance_size = sizeof(RAMFBStandaloneState),
84 .class_init = ramfb_class_initfn,
87 static void ramfb_register_types(void)
89 type_register_static(&ramfb_info);
92 type_init(ramfb_register_types)