mirror of https://github.com/xemu-project/xemu.git
vga: ati-vga bugfix, ramfb cleanups and fixes.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABCgAGBQJewqXLAAoJEEy22O7T6HE4nm8P/iU4skgab1U6tf/rkCEfGkG2 RBF/0tToJzNQpTlXgolNszQceys99bLQqcE+U4fIut7FBH+710N7UVMv81LOm8vG ZLEBhbBw1RYE+NZsoXob89zUkC9HaWY3gLbvBYpzjeeZgoJNAVUv36+FjCZrvdGp Xx5Z30Q3yu7M3Aioi3qsWQS5WHeOzuqnKAHRRWlAZp6Qe5b8z06Jy4XToCUdL5G1 OiGobByhBNHqPb6zd+dBC5koS9OWW5XtWxoqa1ordnIAAhvds2pjKvbUuwE7Pwyq Arxs0tH6q3o/uZro/nTj1WpU/1v0EtOrVdyTpQ1V3n5xcqe7N8pHiO8onhEU1aJS dSwJoKlhRWfecAzqpQPwz0gzmVOwBE9MTqsXG3dyVWdFW0VRnrVjGXTYeXzyWnHO 3ivLbA5sJAzV+jQE9jZakVhPaM0nWvhOhjeU8Mmpvdk1KE6KjwmITn5i0cuuu5nZ LZsOyX0RJ8poaDwzLW/M9sYeCggDp3ZqPBYQgdTQ6F+T0vuIE2qUFOTKOT86R+eg KcjccC91GsHuje8CSPn9iiIPZCXALjriEuv0bepH8mnsPEyQNixylkqZOpKkntmk +sJXh3kPZnQIvsKmiLE8saMIUJ0WsIiY0Nzg58+53+U39LcdbDCBZ1QNPMK+daQq JUn3rqtN7L8GYAGqSmsR =Rq52 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200518-pull-request' into staging vga: ati-vga bugfix, ramfb cleanups and fixes. # gpg: Signature made Mon 18 May 2020 16:12:11 BST # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/vga-20200518-pull-request: ramfb: fix size calculation ramfb: add sanity checks to ramfb_create_display_surface ramfb: don't update RAMFBState on errors ramfb: drop leftover debug message Revert "hw/display/ramfb: lock guest resolution after it's set" Revert "hw/display/ramfb: initialize fw-config space with xres/ yres" hw/display: Include local 'framebuffer.h' ati-vga: Do not allow unaligned access via index register Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
a28c9c8c9f
|
@ -21,7 +21,7 @@
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "ui/console.h"
|
#include "ui/console.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "hw/display/framebuffer.h"
|
#include "framebuffer.h"
|
||||||
|
|
||||||
#define TYPE_ARTIST "artist"
|
#define TYPE_ARTIST "artist"
|
||||||
#define ARTIST(obj) OBJECT_CHECK(ARTISTState, (obj), TYPE_ARTIST)
|
#define ARTIST(obj) OBJECT_CHECK(ARTISTState, (obj), TYPE_ARTIST)
|
||||||
|
|
|
@ -511,7 +511,7 @@ static void ati_mm_write(void *opaque, hwaddr addr,
|
||||||
}
|
}
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case MM_INDEX:
|
case MM_INDEX:
|
||||||
s->regs.mm_index = data;
|
s->regs.mm_index = data & ~3;
|
||||||
break;
|
break;
|
||||||
case MM_DATA ... MM_DATA + 3:
|
case MM_DATA ... MM_DATA + 3:
|
||||||
/* indexed access to regs or memory */
|
/* indexed access to regs or memory */
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "hw/hw.h"
|
#include "hw/hw.h"
|
||||||
#include "hw/boards.h"
|
#include "hw/boards.h"
|
||||||
#include "hw/loader.h"
|
#include "hw/loader.h"
|
||||||
#include "hw/display/framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "ui/pixel_ops.h"
|
#include "ui/pixel_ops.h"
|
||||||
#include "hw/m68k/next-cube.h"
|
#include "hw/m68k/next-cube.h"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "qemu/module.h"
|
#include "qemu/module.h"
|
||||||
#include "hw/loader.h"
|
#include "hw/loader.h"
|
||||||
#include "hw/qdev-properties.h"
|
#include "hw/qdev-properties.h"
|
||||||
#include "hw/isa/isa.h"
|
|
||||||
#include "hw/display/ramfb.h"
|
#include "hw/display/ramfb.h"
|
||||||
#include "ui/console.h"
|
#include "ui/console.h"
|
||||||
|
|
||||||
|
@ -13,8 +12,6 @@ typedef struct RAMFBStandaloneState {
|
||||||
SysBusDevice parent_obj;
|
SysBusDevice parent_obj;
|
||||||
QemuConsole *con;
|
QemuConsole *con;
|
||||||
RAMFBState *state;
|
RAMFBState *state;
|
||||||
uint32_t xres;
|
|
||||||
uint32_t yres;
|
|
||||||
} RAMFBStandaloneState;
|
} RAMFBStandaloneState;
|
||||||
|
|
||||||
static void display_update_wrapper(void *dev)
|
static void display_update_wrapper(void *dev)
|
||||||
|
@ -37,22 +34,15 @@ static void ramfb_realizefn(DeviceState *dev, Error **errp)
|
||||||
RAMFBStandaloneState *ramfb = RAMFB(dev);
|
RAMFBStandaloneState *ramfb = RAMFB(dev);
|
||||||
|
|
||||||
ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
|
ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
|
||||||
ramfb->state = ramfb_setup(dev, errp);
|
ramfb->state = ramfb_setup(errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Property ramfb_properties[] = {
|
|
||||||
DEFINE_PROP_UINT32("xres", RAMFBStandaloneState, xres, 0),
|
|
||||||
DEFINE_PROP_UINT32("yres", RAMFBStandaloneState, yres, 0),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
|
||||||
};
|
|
||||||
|
|
||||||
static void ramfb_class_initfn(ObjectClass *klass, void *data)
|
static void ramfb_class_initfn(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
|
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
|
||||||
dc->realize = ramfb_realizefn;
|
dc->realize = ramfb_realizefn;
|
||||||
device_class_set_props(dc, ramfb_properties);
|
|
||||||
dc->desc = "ram framebuffer standalone device";
|
dc->desc = "ram framebuffer standalone device";
|
||||||
dc->user_creatable = true;
|
dc->user_creatable = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qemu/option.h"
|
|
||||||
#include "hw/loader.h"
|
#include "hw/loader.h"
|
||||||
#include "hw/display/ramfb.h"
|
#include "hw/display/ramfb.h"
|
||||||
|
#include "hw/display/bochs-vbe.h" /* for limits */
|
||||||
#include "ui/console.h"
|
#include "ui/console.h"
|
||||||
#include "sysemu/reset.h"
|
#include "sysemu/reset.h"
|
||||||
|
|
||||||
|
@ -31,9 +31,7 @@ struct QEMU_PACKED RAMFBCfg {
|
||||||
struct RAMFBState {
|
struct RAMFBState {
|
||||||
DisplaySurface *ds;
|
DisplaySurface *ds;
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
uint32_t starting_width, starting_height;
|
|
||||||
struct RAMFBCfg cfg;
|
struct RAMFBCfg cfg;
|
||||||
bool locked;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ramfb_unmap_display_surface(pixman_image_t *image, void *unused)
|
static void ramfb_unmap_display_surface(pixman_image_t *image, void *unused)
|
||||||
|
@ -46,25 +44,31 @@ static void ramfb_unmap_display_surface(pixman_image_t *image, void *unused)
|
||||||
|
|
||||||
static DisplaySurface *ramfb_create_display_surface(int width, int height,
|
static DisplaySurface *ramfb_create_display_surface(int width, int height,
|
||||||
pixman_format_code_t format,
|
pixman_format_code_t format,
|
||||||
int linesize, uint64_t addr)
|
hwaddr stride, hwaddr addr)
|
||||||
{
|
{
|
||||||
DisplaySurface *surface;
|
DisplaySurface *surface;
|
||||||
hwaddr size;
|
hwaddr size, mapsize, linesize;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
if (linesize == 0) {
|
if (width < 16 || width > VBE_DISPI_MAX_XRES ||
|
||||||
linesize = width * PIXMAN_FORMAT_BPP(format) / 8;
|
height < 16 || height > VBE_DISPI_MAX_YRES ||
|
||||||
|
format == 0 /* unknown format */)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
linesize = width * PIXMAN_FORMAT_BPP(format) / 8;
|
||||||
|
if (stride == 0) {
|
||||||
|
stride = linesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = (hwaddr)linesize * height;
|
mapsize = size = stride * (height - 1) + linesize;
|
||||||
data = cpu_physical_memory_map(addr, &size, false);
|
data = cpu_physical_memory_map(addr, &mapsize, false);
|
||||||
if (size != (hwaddr)linesize * height) {
|
if (size != mapsize) {
|
||||||
cpu_physical_memory_unmap(data, size, 0, 0);
|
cpu_physical_memory_unmap(data, mapsize, 0, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface = qemu_create_displaysurface_from(width, height,
|
surface = qemu_create_displaysurface_from(width, height,
|
||||||
format, linesize, data);
|
format, stride, data);
|
||||||
pixman_image_set_destroy_function(surface->image,
|
pixman_image_set_destroy_function(surface->image,
|
||||||
ramfb_unmap_display_surface, NULL);
|
ramfb_unmap_display_surface, NULL);
|
||||||
|
|
||||||
|
@ -74,27 +78,26 @@ static DisplaySurface *ramfb_create_display_surface(int width, int height,
|
||||||
static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len)
|
static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len)
|
||||||
{
|
{
|
||||||
RAMFBState *s = dev;
|
RAMFBState *s = dev;
|
||||||
|
DisplaySurface *surface;
|
||||||
uint32_t fourcc, format, width, height;
|
uint32_t fourcc, format, width, height;
|
||||||
hwaddr stride, addr;
|
hwaddr stride, addr;
|
||||||
|
|
||||||
width = be32_to_cpu(s->cfg.width);
|
width = be32_to_cpu(s->cfg.width);
|
||||||
height = be32_to_cpu(s->cfg.height);
|
height = be32_to_cpu(s->cfg.height);
|
||||||
stride = be32_to_cpu(s->cfg.stride);
|
stride = be32_to_cpu(s->cfg.stride);
|
||||||
fourcc = be32_to_cpu(s->cfg.fourcc);
|
fourcc = be32_to_cpu(s->cfg.fourcc);
|
||||||
addr = be64_to_cpu(s->cfg.addr);
|
addr = be64_to_cpu(s->cfg.addr);
|
||||||
format = qemu_drm_format_to_pixman(fourcc);
|
format = qemu_drm_format_to_pixman(fourcc);
|
||||||
|
|
||||||
fprintf(stderr, "%s: %dx%d @ 0x%" PRIx64 "\n", __func__,
|
surface = ramfb_create_display_surface(width, height,
|
||||||
width, height, addr);
|
format, stride, addr);
|
||||||
if (s->locked) {
|
if (!surface) {
|
||||||
fprintf(stderr, "%s: resolution locked, change rejected\n", __func__);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s->locked = true;
|
|
||||||
s->width = width;
|
s->width = width;
|
||||||
s->height = height;
|
s->height = height;
|
||||||
s->ds = ramfb_create_display_surface(s->width, s->height,
|
s->ds = surface;
|
||||||
format, stride, addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ramfb_display_update(QemuConsole *con, RAMFBState *s)
|
void ramfb_display_update(QemuConsole *con, RAMFBState *s)
|
||||||
|
@ -112,16 +115,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s)
|
||||||
dpy_gfx_update_full(con);
|
dpy_gfx_update_full(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ramfb_reset(void *opaque)
|
RAMFBState *ramfb_setup(Error **errp)
|
||||||
{
|
|
||||||
RAMFBState *s = (RAMFBState *)opaque;
|
|
||||||
s->locked = false;
|
|
||||||
memset(&s->cfg, 0, sizeof(s->cfg));
|
|
||||||
s->cfg.width = s->starting_width;
|
|
||||||
s->cfg.height = s->starting_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
RAMFBState *ramfb_setup(DeviceState* dev, Error **errp)
|
|
||||||
{
|
{
|
||||||
FWCfgState *fw_cfg = fw_cfg_find();
|
FWCfgState *fw_cfg = fw_cfg_find();
|
||||||
RAMFBState *s;
|
RAMFBState *s;
|
||||||
|
@ -133,22 +127,9 @@ RAMFBState *ramfb_setup(DeviceState* dev, Error **errp)
|
||||||
|
|
||||||
s = g_new0(RAMFBState, 1);
|
s = g_new0(RAMFBState, 1);
|
||||||
|
|
||||||
const char *s_fb_width = qemu_opt_get(dev->opts, "xres");
|
|
||||||
const char *s_fb_height = qemu_opt_get(dev->opts, "yres");
|
|
||||||
if (s_fb_width) {
|
|
||||||
s->cfg.width = atoi(s_fb_width);
|
|
||||||
s->starting_width = s->cfg.width;
|
|
||||||
}
|
|
||||||
if (s_fb_height) {
|
|
||||||
s->cfg.height = atoi(s_fb_height);
|
|
||||||
s->starting_height = s->cfg.height;
|
|
||||||
}
|
|
||||||
s->locked = false;
|
|
||||||
|
|
||||||
rom_add_vga("vgabios-ramfb.bin");
|
rom_add_vga("vgabios-ramfb.bin");
|
||||||
fw_cfg_add_file_callback(fw_cfg, "etc/ramfb",
|
fw_cfg_add_file_callback(fw_cfg, "etc/ramfb",
|
||||||
NULL, ramfb_fw_cfg_write, s,
|
NULL, ramfb_fw_cfg_write, s,
|
||||||
&s->cfg, sizeof(s->cfg), false);
|
&s->cfg, sizeof(s->cfg), false);
|
||||||
qemu_register_reset(ramfb_reset, s);
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,7 +353,7 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp)
|
||||||
&vfio_display_dmabuf_ops,
|
&vfio_display_dmabuf_ops,
|
||||||
vdev);
|
vdev);
|
||||||
if (vdev->enable_ramfb) {
|
if (vdev->enable_ramfb) {
|
||||||
vdev->dpy->ramfb = ramfb_setup(DEVICE(vdev), errp);
|
vdev->dpy->ramfb = ramfb_setup(errp);
|
||||||
}
|
}
|
||||||
vfio_display_edid_init(vdev);
|
vfio_display_edid_init(vdev);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -479,7 +479,7 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp)
|
||||||
&vfio_display_region_ops,
|
&vfio_display_region_ops,
|
||||||
vdev);
|
vdev);
|
||||||
if (vdev->enable_ramfb) {
|
if (vdev->enable_ramfb) {
|
||||||
vdev->dpy->ramfb = ramfb_setup(DEVICE(vdev), errp);
|
vdev->dpy->ramfb = ramfb_setup(errp);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/* ramfb.c */
|
/* ramfb.c */
|
||||||
typedef struct RAMFBState RAMFBState;
|
typedef struct RAMFBState RAMFBState;
|
||||||
void ramfb_display_update(QemuConsole *con, RAMFBState *s);
|
void ramfb_display_update(QemuConsole *con, RAMFBState *s);
|
||||||
RAMFBState *ramfb_setup(DeviceState *dev, Error **errp);
|
RAMFBState *ramfb_setup(Error **errp);
|
||||||
|
|
||||||
/* ramfb-standalone.c */
|
/* ramfb-standalone.c */
|
||||||
#define TYPE_RAMFB_DEVICE "ramfb"
|
#define TYPE_RAMFB_DEVICE "ramfb"
|
||||||
|
|
|
@ -6,7 +6,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RAMFBState *ramfb_setup(DeviceState* dev, Error **errp)
|
RAMFBState *ramfb_setup(Error **errp)
|
||||||
{
|
{
|
||||||
error_setg(errp, "ramfb support not available");
|
error_setg(errp, "ramfb support not available");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue