Skip to content

Commit

Permalink
hw/display/pl110: Pass frame buffer memory region as link property
Browse files Browse the repository at this point in the history
Add the PL110::'framebuffer-memory' property. Have the different
ARM boards set it. We don't need to call sysbus_address_space()
anymore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240226173805.289-3-philmd@linaro.org>
  • Loading branch information
philmd committed Feb 26, 2024
1 parent 49aff03 commit c209366
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions hw/arm/integratorcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ static void integratorcp_init(MachineState *machine)
}

dev = qdev_new("pl110");
object_property_set_link(OBJECT(dev), "framebuffer-memory",
OBJECT(address_space_mem), &error_fatal);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xc0000000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[22]);
Expand Down
2 changes: 2 additions & 0 deletions hw/arm/realview.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ static void realview_init(MachineState *machine,
gpio2 = sysbus_create_simple("pl061", 0x10015000, pic[8]);

dev = qdev_new("pl111");
object_property_set_link(OBJECT(dev), "framebuffer-memory",
OBJECT(sysmem), &error_fatal);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x10020000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[23]);
Expand Down
2 changes: 2 additions & 0 deletions hw/arm/versatilepb.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ static void versatile_init(MachineState *machine, int board_id)
/* The versatile/PB actually has a modified Color LCD controller
that includes hardware cursor support from the PL111. */
dev = qdev_new("pl110_versatile");
object_property_set_link(OBJECT(dev), "framebuffer-memory",
OBJECT(sysmem), &error_fatal);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x10120000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[16]);
Expand Down
5 changes: 5 additions & 0 deletions hw/arm/vexpress.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ static void a9_daughterboard_init(VexpressMachineState *vms,

/* 0x10020000 PL111 CLCD (daughterboard) */
dev = qdev_new("pl111");
object_property_set_link(OBJECT(dev), "framebuffer-memory",
OBJECT(sysmem), &error_fatal);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x10020000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[44]);

Expand Down Expand Up @@ -654,6 +657,8 @@ static void vexpress_common_init(MachineState *machine)
/* VE_COMPACTFLASH: not modelled */

dev = qdev_new("pl111");
object_property_set_link(OBJECT(dev), "framebuffer-memory",
OBJECT(sysmem), &error_fatal);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, map[VE_CLCD]);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[14]);
Expand Down
20 changes: 16 additions & 4 deletions hw/display/pl110.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#include "qemu/osdep.h"
#include "hw/irq.h"
#include "hw/sysbus.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
#include "ui/console.h"
#include "framebuffer.h"
#include "ui/pixel_ops.h"
#include "qemu/timer.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "qapi/error.h"
#include "qom/object.h"

#define PL110_CR_EN 0x001
Expand Down Expand Up @@ -74,6 +76,7 @@ struct PL110State {
uint32_t palette[256];
uint32_t raw_palette[128];
qemu_irq irq;
MemoryRegion *fbmem;
};

static int vmstate_pl110_post_load(void *opaque, int version_id);
Expand Down Expand Up @@ -210,7 +213,6 @@ static int pl110_enabled(PL110State *s)
static void pl110_update_display(void *opaque)
{
PL110State *s = (PL110State *)opaque;
SysBusDevice *sbd;
DisplaySurface *surface = qemu_console_surface(s->con);
drawfn fn;
int src_width;
Expand All @@ -222,8 +224,6 @@ static void pl110_update_display(void *opaque)
return;
}

sbd = SYS_BUS_DEVICE(s);

if (s->cr & PL110_CR_BGR)
bpp_offset = 0;
else
Expand Down Expand Up @@ -290,7 +290,7 @@ static void pl110_update_display(void *opaque)
first = 0;
if (s->invalidate) {
framebuffer_update_memory_section(&s->fbsection,
sysbus_address_space(sbd),
s->fbmem,
s->upbase,
s->rows, src_width);
}
Expand Down Expand Up @@ -535,11 +535,22 @@ static const GraphicHwOps pl110_gfx_ops = {
.gfx_update = pl110_update_display,
};

static Property pl110_properties[] = {
DEFINE_PROP_LINK("framebuffer-memory", PL110State, fbmem,
TYPE_MEMORY_REGION, MemoryRegion *),
DEFINE_PROP_END_OF_LIST(),
};

static void pl110_realize(DeviceState *dev, Error **errp)
{
PL110State *s = PL110(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);

if (!s->fbmem) {
error_setg(errp, "'framebuffer-memory' property was not set");
return;
}

memory_region_init_io(&s->iomem, OBJECT(s), &pl110_ops, s, "pl110", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
sysbus_init_irq(sbd, &s->irq);
Expand Down Expand Up @@ -577,6 +588,7 @@ static void pl110_class_init(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->vmsd = &vmstate_pl110;
dc->realize = pl110_realize;
device_class_set_props(dc, pl110_properties);
}

static const TypeInfo pl110_info = {
Expand Down

0 comments on commit c209366

Please sign in to comment.