2016-03-16 20:06:01 +03:00
|
|
|
/*
|
|
|
|
* Raspberry Pi emulation (c) 2012 Gregory Estrade
|
|
|
|
* Refactoring for Pi2 Copyright (c) 2015, Microsoft. Written by Andrew Baumann.
|
|
|
|
*
|
|
|
|
* Heavily based on milkymist-vgafb.c, copyright terms below:
|
|
|
|
* QEMU model of the Milkymist VGA framebuffer.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010-2012 Michael Walle <michael@walle.cc>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 11:01:28 +03:00
|
|
|
#include "qapi/error.h"
|
2016-03-16 20:06:01 +03:00
|
|
|
#include "hw/display/bcm2835_fb.h"
|
2019-08-12 08:23:48 +03:00
|
|
|
#include "hw/hw.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2018-05-03 22:50:31 +03:00
|
|
|
#include "framebuffer.h"
|
2016-03-16 20:06:01 +03:00
|
|
|
#include "ui/pixel_ops.h"
|
|
|
|
#include "hw/misc/bcm2835_mbox_defs.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2019-08-12 08:23:45 +03:00
|
|
|
#include "migration/vmstate.h"
|
2015-12-15 15:16:16 +03:00
|
|
|
#include "qemu/log.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2016-03-16 20:06:01 +03:00
|
|
|
|
|
|
|
#define DEFAULT_VCRAM_SIZE 0x4000000
|
|
|
|
#define BCM2835_FB_OFFSET 0x00100000
|
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
/* Maximum permitted framebuffer size; experimentally determined on an rpi2 */
|
|
|
|
#define XRES_MAX 3840
|
|
|
|
#define YRES_MAX 2560
|
|
|
|
/* Framebuffer size used if guest requests zero size */
|
|
|
|
#define XRES_SMALL 592
|
|
|
|
#define YRES_SMALL 488
|
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
static void fb_invalidate_display(void *opaque)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = BCM2835_FB(opaque);
|
|
|
|
|
|
|
|
s->invalidate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_line_src16(void *opaque, uint8_t *dst, const uint8_t *src,
|
|
|
|
int width, int deststep)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = opaque;
|
|
|
|
uint16_t rgb565;
|
|
|
|
uint32_t rgb888;
|
|
|
|
uint8_t r, g, b;
|
|
|
|
DisplaySurface *surface = qemu_console_surface(s->con);
|
|
|
|
int bpp = surface_bits_per_pixel(surface);
|
|
|
|
|
|
|
|
while (width--) {
|
2018-08-24 15:17:48 +03:00
|
|
|
switch (s->config.bpp) {
|
2016-03-16 20:06:01 +03:00
|
|
|
case 8:
|
|
|
|
/* lookup palette starting at video ram base
|
|
|
|
* TODO: cache translation, rather than doing this each time!
|
|
|
|
*/
|
|
|
|
rgb888 = ldl_le_phys(&s->dma_as, s->vcram_base + (*src << 2));
|
|
|
|
r = (rgb888 >> 0) & 0xff;
|
|
|
|
g = (rgb888 >> 8) & 0xff;
|
|
|
|
b = (rgb888 >> 16) & 0xff;
|
|
|
|
src++;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
rgb565 = lduw_le_p(src);
|
|
|
|
r = ((rgb565 >> 11) & 0x1f) << 3;
|
|
|
|
g = ((rgb565 >> 5) & 0x3f) << 2;
|
|
|
|
b = ((rgb565 >> 0) & 0x1f) << 3;
|
|
|
|
src += 2;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
rgb888 = ldl_le_p(src);
|
|
|
|
r = (rgb888 >> 0) & 0xff;
|
|
|
|
g = (rgb888 >> 8) & 0xff;
|
|
|
|
b = (rgb888 >> 16) & 0xff;
|
|
|
|
src += 3;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
rgb888 = ldl_le_p(src);
|
|
|
|
r = (rgb888 >> 0) & 0xff;
|
|
|
|
g = (rgb888 >> 8) & 0xff;
|
|
|
|
b = (rgb888 >> 16) & 0xff;
|
|
|
|
src += 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
r = 0;
|
|
|
|
g = 0;
|
|
|
|
b = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-08-24 15:17:48 +03:00
|
|
|
if (s->config.pixo == 0) {
|
2016-03-16 20:06:01 +03:00
|
|
|
/* swap to BGR pixel format */
|
|
|
|
uint8_t tmp = r;
|
|
|
|
r = b;
|
|
|
|
b = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (bpp) {
|
|
|
|
case 8:
|
|
|
|
*dst++ = rgb_to_pixel8(r, g, b);
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
*(uint16_t *)dst = rgb_to_pixel15(r, g, b);
|
|
|
|
dst += 2;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
*(uint16_t *)dst = rgb_to_pixel16(r, g, b);
|
|
|
|
dst += 2;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
rgb888 = rgb_to_pixel24(r, g, b);
|
|
|
|
*dst++ = rgb888 & 0xff;
|
|
|
|
*dst++ = (rgb888 >> 8) & 0xff;
|
|
|
|
*dst++ = (rgb888 >> 16) & 0xff;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
*(uint32_t *)dst = rgb_to_pixel32(r, g, b);
|
|
|
|
dst += 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 15:17:49 +03:00
|
|
|
static bool fb_use_offsets(BCM2835FBConfig *config)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Return true if we should use the viewport offsets.
|
|
|
|
* Experimentally, the hardware seems to do this only if the
|
|
|
|
* viewport size is larger than the physical screen. (It doesn't
|
|
|
|
* prevent the guest setting this silly viewport setting, though...)
|
|
|
|
*/
|
|
|
|
return config->xres_virtual > config->xres &&
|
|
|
|
config->yres_virtual > config->yres;
|
|
|
|
}
|
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
static void fb_update_display(void *opaque)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = opaque;
|
|
|
|
DisplaySurface *surface = qemu_console_surface(s->con);
|
|
|
|
int first = 0;
|
|
|
|
int last = 0;
|
|
|
|
int src_width = 0;
|
|
|
|
int dest_width = 0;
|
2018-08-24 15:17:49 +03:00
|
|
|
uint32_t xoff = 0, yoff = 0;
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2018-08-24 15:17:48 +03:00
|
|
|
if (s->lock || !s->config.xres) {
|
2016-03-16 20:06:01 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-24 15:17:49 +03:00
|
|
|
src_width = bcm2835_fb_get_pitch(&s->config);
|
2018-08-24 15:17:49 +03:00
|
|
|
if (fb_use_offsets(&s->config)) {
|
|
|
|
xoff = s->config.xoffset;
|
|
|
|
yoff = s->config.yoffset;
|
|
|
|
}
|
|
|
|
|
2018-08-24 15:17:48 +03:00
|
|
|
dest_width = s->config.xres;
|
2016-03-16 20:06:01 +03:00
|
|
|
|
|
|
|
switch (surface_bits_per_pixel(surface)) {
|
|
|
|
case 0:
|
|
|
|
return;
|
|
|
|
case 8:
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
dest_width *= 2;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
dest_width *= 2;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
dest_width *= 3;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
dest_width *= 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
hw_error("bcm2835_fb: bad color depth\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->invalidate) {
|
2018-10-08 16:55:05 +03:00
|
|
|
hwaddr base = s->config.base + xoff + (hwaddr)yoff * src_width;
|
2018-08-24 15:17:48 +03:00
|
|
|
framebuffer_update_memory_section(&s->fbsection, s->dma_mr,
|
2018-08-24 15:17:49 +03:00
|
|
|
base,
|
2018-08-24 15:17:48 +03:00
|
|
|
s->config.yres, src_width);
|
2016-03-16 20:06:01 +03:00
|
|
|
}
|
|
|
|
|
2018-08-24 15:17:48 +03:00
|
|
|
framebuffer_update_display(surface, &s->fbsection,
|
|
|
|
s->config.xres, s->config.yres,
|
2016-03-16 20:06:01 +03:00
|
|
|
src_width, dest_width, 0, s->invalidate,
|
|
|
|
draw_line_src16, s, &first, &last);
|
|
|
|
|
|
|
|
if (first >= 0) {
|
2018-08-24 15:17:49 +03:00
|
|
|
dpy_gfx_update(s->con, 0, first, s->config.xres,
|
|
|
|
last - first + 1);
|
2016-03-16 20:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
s->invalidate = false;
|
|
|
|
}
|
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
void bcm2835_fb_validate_config(BCM2835FBConfig *config)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Validate the config, and clip any bogus values into range,
|
|
|
|
* as the hardware does. Note that fb_update_display() relies on
|
|
|
|
* this happening to prevent it from performing out-of-range
|
|
|
|
* accesses on redraw.
|
|
|
|
*/
|
|
|
|
config->xres = MIN(config->xres, XRES_MAX);
|
|
|
|
config->xres_virtual = MIN(config->xres_virtual, XRES_MAX);
|
|
|
|
config->yres = MIN(config->yres, YRES_MAX);
|
|
|
|
config->yres_virtual = MIN(config->yres_virtual, YRES_MAX);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are not minima: a 40x40 framebuffer will be accepted.
|
|
|
|
* They're only used as defaults if the guest asks for zero size.
|
|
|
|
*/
|
|
|
|
if (config->xres == 0) {
|
|
|
|
config->xres = XRES_SMALL;
|
|
|
|
}
|
|
|
|
if (config->yres == 0) {
|
|
|
|
config->yres = YRES_SMALL;
|
|
|
|
}
|
|
|
|
if (config->xres_virtual == 0) {
|
|
|
|
config->xres_virtual = config->xres;
|
|
|
|
}
|
|
|
|
if (config->yres_virtual == 0) {
|
|
|
|
config->yres_virtual = config->yres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fb_use_offsets(config)) {
|
|
|
|
/* Clip the offsets so the viewport is within the physical screen */
|
|
|
|
config->xoffset = MIN(config->xoffset,
|
|
|
|
config->xres_virtual - config->xres);
|
|
|
|
config->yoffset = MIN(config->yoffset,
|
|
|
|
config->yres_virtual - config->yres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
|
|
|
|
{
|
|
|
|
s->lock = true;
|
|
|
|
|
|
|
|
s->config = *newconfig;
|
|
|
|
|
|
|
|
s->invalidate = true;
|
|
|
|
qemu_console_resize(s->con, s->config.xres, s->config.yres);
|
|
|
|
s->lock = false;
|
|
|
|
}
|
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
|
|
|
|
{
|
2018-08-24 15:17:49 +03:00
|
|
|
uint32_t pitch;
|
|
|
|
uint32_t size;
|
2018-08-24 15:17:50 +03:00
|
|
|
BCM2835FBConfig newconf;
|
2018-08-24 15:17:49 +03:00
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
value &= ~0xf;
|
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
newconf.xres = ldl_le_phys(&s->dma_as, value);
|
|
|
|
newconf.yres = ldl_le_phys(&s->dma_as, value + 4);
|
|
|
|
newconf.xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
|
|
|
|
newconf.yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
|
|
|
|
newconf.bpp = ldl_le_phys(&s->dma_as, value + 20);
|
|
|
|
newconf.xoffset = ldl_le_phys(&s->dma_as, value + 24);
|
|
|
|
newconf.yoffset = ldl_le_phys(&s->dma_as, value + 28);
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
newconf.base = s->vcram_base | (value & 0xc0000000);
|
|
|
|
newconf.base += BCM2835_FB_OFFSET;
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
/* Copy fields which we don't want to change from the existing config */
|
|
|
|
newconf.pixo = s->config.pixo;
|
|
|
|
newconf.alpha = s->config.alpha;
|
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
bcm2835_fb_validate_config(&newconf);
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
pitch = bcm2835_fb_get_pitch(&newconf);
|
|
|
|
size = bcm2835_fb_get_size(&newconf);
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2018-08-24 15:17:49 +03:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, pitch);
|
2018-08-24 15:17:50 +03:00
|
|
|
stl_le_phys(&s->dma_as, value + 32, newconf.base);
|
2018-08-24 15:17:49 +03:00
|
|
|
stl_le_phys(&s->dma_as, value + 36, size);
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2018-08-24 15:17:50 +03:00
|
|
|
bcm2835_fb_reconfigure(s, &newconf);
|
2016-03-16 20:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t bcm2835_fb_read(void *opaque, hwaddr offset, unsigned size)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = opaque;
|
|
|
|
uint32_t res = 0;
|
|
|
|
|
|
|
|
switch (offset) {
|
|
|
|
case MBOX_AS_DATA:
|
|
|
|
res = MBOX_CHAN_FB;
|
|
|
|
s->pending = false;
|
|
|
|
qemu_set_irq(s->mbox_irq, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MBOX_AS_PENDING:
|
|
|
|
res = s->pending;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
|
|
|
|
__func__, offset);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_fb_write(void *opaque, hwaddr offset, uint64_t value,
|
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = opaque;
|
|
|
|
|
|
|
|
switch (offset) {
|
|
|
|
case MBOX_AS_DATA:
|
|
|
|
/* bcm2835_mbox should check our pending status before pushing */
|
|
|
|
assert(!s->pending);
|
|
|
|
s->pending = true;
|
|
|
|
bcm2835_fb_mbox_push(s, value);
|
|
|
|
qemu_set_irq(s->mbox_irq, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
|
|
|
|
__func__, offset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps bcm2835_fb_ops = {
|
|
|
|
.read = bcm2835_fb_read,
|
|
|
|
.write = bcm2835_fb_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid.min_access_size = 4,
|
|
|
|
.valid.max_access_size = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_bcm2835_fb = {
|
|
|
|
.name = TYPE_BCM2835_FB,
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_BOOL(lock, BCM2835FBState),
|
|
|
|
VMSTATE_BOOL(invalidate, BCM2835FBState),
|
|
|
|
VMSTATE_BOOL(pending, BCM2835FBState),
|
2018-08-24 15:17:48 +03:00
|
|
|
VMSTATE_UINT32(config.xres, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.yres, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.xres_virtual, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.yres_virtual, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.xoffset, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.yoffset, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.bpp, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.base, BCM2835FBState),
|
2018-08-24 15:17:49 +03:00
|
|
|
VMSTATE_UNUSED(8), /* Was pitch and size */
|
2018-08-24 15:17:48 +03:00
|
|
|
VMSTATE_UINT32(config.pixo, BCM2835FBState),
|
|
|
|
VMSTATE_UINT32(config.alpha, BCM2835FBState),
|
2016-03-16 20:06:01 +03:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const GraphicHwOps vgafb_ops = {
|
|
|
|
.invalidate = fb_invalidate_display,
|
|
|
|
.gfx_update = fb_update_display,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2835_fb_init(Object *obj)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = BCM2835_FB(obj);
|
|
|
|
|
|
|
|
memory_region_init_io(&s->iomem, obj, &bcm2835_fb_ops, s, TYPE_BCM2835_FB,
|
|
|
|
0x10);
|
|
|
|
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
|
|
|
|
sysbus_init_irq(SYS_BUS_DEVICE(s), &s->mbox_irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_fb_reset(DeviceState *dev)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = BCM2835_FB(dev);
|
|
|
|
|
|
|
|
s->pending = false;
|
|
|
|
|
2018-08-24 15:17:49 +03:00
|
|
|
s->config = s->initial_config;
|
2016-03-16 20:06:01 +03:00
|
|
|
|
|
|
|
s->invalidate = true;
|
|
|
|
s->lock = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
BCM2835FBState *s = BCM2835_FB(dev);
|
|
|
|
Object *obj;
|
|
|
|
|
|
|
|
if (s->vcram_base == 0) {
|
|
|
|
error_setg(errp, "%s: required vcram-base property not set", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:05:52 +03:00
|
|
|
obj = object_property_get_link(OBJECT(dev), "dma-mr", &error_abort);
|
2016-03-16 20:06:01 +03:00
|
|
|
|
2018-08-24 15:17:49 +03:00
|
|
|
/* Fill in the parts of initial_config that are not set by QOM properties */
|
|
|
|
s->initial_config.xres_virtual = s->initial_config.xres;
|
|
|
|
s->initial_config.yres_virtual = s->initial_config.yres;
|
|
|
|
s->initial_config.xoffset = 0;
|
|
|
|
s->initial_config.yoffset = 0;
|
|
|
|
s->initial_config.base = s->vcram_base + BCM2835_FB_OFFSET;
|
|
|
|
|
2016-03-16 20:06:01 +03:00
|
|
|
s->dma_mr = MEMORY_REGION(obj);
|
hw/arm/bcm2835_peripherals: Name various address spaces
Various address spaces from the BCM2835 are reported as
'anonymous' in memory tree:
(qemu) info mtree
address-space: anonymous
0000000000000000-000000000000008f (prio 0, i/o): bcm2835-mbox
0000000000000010-000000000000001f (prio 0, i/o): bcm2835-fb
0000000000000080-000000000000008f (prio 0, i/o): bcm2835-property
address-space: anonymous
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
[...]
Since the address_space_init() function takes a 'name' argument,
set it to correctly describe each address space:
(qemu) info mtree
address-space: bcm2835-mbox-memory
0000000000000000-000000000000008f (prio 0, i/o): bcm2835-mbox
0000000000000010-000000000000001f (prio 0, i/o): bcm2835-fb
0000000000000080-000000000000008f (prio 0, i/o): bcm2835-property
address-space: bcm2835-fb-memory
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
address-space: bcm2835-property-memory
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
address-space: bcm2835-dma-memory
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Message-id: 20190926173428.10713-4-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-09-26 20:34:11 +03:00
|
|
|
address_space_init(&s->dma_as, s->dma_mr, TYPE_BCM2835_FB "-memory");
|
2016-03-16 20:06:01 +03:00
|
|
|
|
|
|
|
bcm2835_fb_reset(dev);
|
|
|
|
|
|
|
|
s->con = graphic_console_init(dev, 0, &vgafb_ops, s);
|
2018-08-24 15:17:48 +03:00
|
|
|
qemu_console_resize(s->con, s->config.xres, s->config.yres);
|
2016-03-16 20:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static Property bcm2835_fb_props[] = {
|
|
|
|
DEFINE_PROP_UINT32("vcram-base", BCM2835FBState, vcram_base, 0),/*required*/
|
|
|
|
DEFINE_PROP_UINT32("vcram-size", BCM2835FBState, vcram_size,
|
|
|
|
DEFAULT_VCRAM_SIZE),
|
2018-08-24 15:17:49 +03:00
|
|
|
DEFINE_PROP_UINT32("xres", BCM2835FBState, initial_config.xres, 640),
|
|
|
|
DEFINE_PROP_UINT32("yres", BCM2835FBState, initial_config.yres, 480),
|
|
|
|
DEFINE_PROP_UINT32("bpp", BCM2835FBState, initial_config.bpp, 16),
|
|
|
|
DEFINE_PROP_UINT32("pixo", BCM2835FBState,
|
|
|
|
initial_config.pixo, 1), /* 1=RGB, 0=BGR */
|
|
|
|
DEFINE_PROP_UINT32("alpha", BCM2835FBState,
|
|
|
|
initial_config.alpha, 2), /* alpha ignored */
|
2016-03-16 20:06:01 +03:00
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2835_fb_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
2020-01-10 18:30:32 +03:00
|
|
|
device_class_set_props(dc, bcm2835_fb_props);
|
2016-03-16 20:06:01 +03:00
|
|
|
dc->realize = bcm2835_fb_realize;
|
|
|
|
dc->reset = bcm2835_fb_reset;
|
|
|
|
dc->vmsd = &vmstate_bcm2835_fb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static TypeInfo bcm2835_fb_info = {
|
|
|
|
.name = TYPE_BCM2835_FB,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(BCM2835FBState),
|
|
|
|
.class_init = bcm2835_fb_class_init,
|
|
|
|
.instance_init = bcm2835_fb_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2835_fb_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&bcm2835_fb_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(bcm2835_fb_register_types)
|