2018-06-13 15:29:46 +03:00
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "qapi/error.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2018-06-13 15:29:46 +03:00
|
|
|
#include "hw/loader.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2019-05-13 14:57:31 +03:00
|
|
|
#include "hw/isa/isa.h"
|
2018-06-13 15:29:46 +03:00
|
|
|
#include "hw/display/ramfb.h"
|
|
|
|
#include "ui/console.h"
|
|
|
|
|
|
|
|
#define RAMFB(obj) OBJECT_CHECK(RAMFBStandaloneState, (obj), TYPE_RAMFB_DEVICE)
|
|
|
|
|
|
|
|
typedef struct RAMFBStandaloneState {
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
QemuConsole *con;
|
|
|
|
RAMFBState *state;
|
2019-05-13 14:57:31 +03:00
|
|
|
uint32_t xres;
|
|
|
|
uint32_t yres;
|
2018-06-13 15:29:46 +03:00
|
|
|
} 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);
|
2019-05-13 14:57:31 +03:00
|
|
|
ramfb->state = ramfb_setup(dev, errp);
|
2018-06-13 15:29:46 +03:00
|
|
|
}
|
|
|
|
|
2019-05-13 14:57:31 +03:00
|
|
|
static Property ramfb_properties[] = {
|
|
|
|
DEFINE_PROP_UINT32("xres", RAMFBStandaloneState, xres, 0),
|
|
|
|
DEFINE_PROP_UINT32("yres", RAMFBStandaloneState, yres, 0),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
2018-06-13 15:29:46 +03:00
|
|
|
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;
|
2019-05-13 14:57:31 +03:00
|
|
|
dc->props = ramfb_properties;
|
2018-06-13 15:29:46 +03:00
|
|
|
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)
|