virtio-vga: reset fix, bigendian fix.

virtio-vga+spice: set monitor dimension via edid.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABCgAGBQJfcwTtAAoJEEy22O7T6HE46FYP+wSv4WscQ3iKNKVva8ZCip6V
 rd5D2UkI0/m6YUPCh0Ql0YdicakDmaMbDy0KMTCx4XTN60Sz66vn882eS0MMdGWp
 x8H8lh0irssrilgczVDM23aLtDxHM8mHomLDcRaHiq4imGBPZkPZYJ1oyUrWsvzd
 6oumi6ysy2k6e3r2A6/hCpFDZUaXFO63+Z28BXhK6P5w5cnKzqhDKKN44Ux9Feyk
 YqJtVSqXMy7Pc1JEhNGYIz0XrGJuIDVcd7QqrH1O1GDKXj5E7+LAOzC+Vz6zWs/O
 d5PldX8YHk21qWxnIl+1HHSk8ktSVz84shfl2gKMrDxSz12F25/FHPi1LZUJheNT
 8OOtxuatA1y8JLw5q+UOMU7a08avEcvfQ8cVpl4pGNpvZpFpd2O/KK6Bor5zrpSt
 m33dpa+K2tlE6m83YMx1tJXrrBhTUP0MWz8hEM9W40zuR+RjLRe3oGIPNkAnqYUo
 8auLgV0zndzO77RPnbvr+JXSk/RR0E8qroTeT8QoKNi5TVbf4ZEIfwsH0DjR7U7Q
 M7ZP0kGIKNpuMl9Gbrhp0wiZbI5CzposrBKv8BeSOR4zHUb8CWJeTRJZDbitNW4x
 3JhgTSl4NtAsoLzPm1gvuWwJ3p0hhLmeCOZeWM1PnRs+R0TWOCWnXIn2iQA8gyHE
 XTZMJ1e90o7XaGwF9RWW
 =IMNR
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200929-pull-request' into staging

virtio-vga: reset fix, bigendian fix.
virtio-vga+spice: set monitor dimension via edid.

# gpg: Signature made Tue 29 Sep 2020 10:57:01 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-20200929-pull-request:
  ppc/pseries: enable big-endian-framebuffer quirk for bochs-display and virtio-vga
  virtio-vga: implement big-endian-framebuffer property
  virtio-gpu: set physical dimensions for EDID
  spice: get monitors physical dimension
  spice: remove the single monitor config logic
  ui: add getter for UIInfo
  edid: use physical dimensions if available
  edid: fix physical display size computation
  virtio-gpu-3d: fix abnormal display after a warm reboot

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-09-29 12:03:06 +01:00
commit 5663ac2aa0
12 changed files with 88 additions and 38 deletions

View File

@ -205,12 +205,8 @@ static void edid_desc_dummy(uint8_t *desc)
static void edid_desc_timing(uint8_t *desc,
uint32_t xres, uint32_t yres,
uint32_t dpi)
uint32_t xmm, uint32_t ymm)
{
/* physical display size */
uint32_t xmm = xres * dpi / 254;
uint32_t ymm = yres * dpi / 254;
/* pull some realistic looking timings out of thin air */
uint32_t xfront = xres * 25 / 100;
uint32_t xsync = xres * 3 / 100;
@ -290,12 +286,24 @@ static void edid_colorspace(uint8_t *edid,
edid[34] = white_y >> 2;
}
static uint32_t qemu_edid_dpi_from_mm(uint32_t mm, uint32_t res)
{
return res * 254 / 10 / mm;
}
uint32_t qemu_edid_dpi_to_mm(uint32_t dpi, uint32_t res)
{
return res * 254 / 10 / dpi;
}
void qemu_edid_generate(uint8_t *edid, size_t size,
qemu_edid_info *info)
{
uint32_t desc = 54;
uint8_t *xtra3 = NULL;
uint8_t *dta = NULL;
uint32_t width_mm, height_mm;
uint32_t dpi = 100; /* if no width_mm/height_mm */
/* =============== set defaults =============== */
@ -305,15 +313,20 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
if (!info->name) {
info->name = "QEMU Monitor";
}
if (!info->dpi) {
info->dpi = 100;
}
if (!info->prefx) {
info->prefx = 1024;
}
if (!info->prefy) {
info->prefy = 768;
}
if (info->width_mm && info->height_mm) {
width_mm = info->width_mm;
height_mm = info->height_mm;
dpi = qemu_edid_dpi_from_mm(width_mm, info->prefx);
} else {
width_mm = qemu_edid_dpi_to_mm(dpi, info->prefx);
height_mm = qemu_edid_dpi_to_mm(dpi, info->prefy);
}
/* =============== extensions =============== */
@ -360,8 +373,8 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
edid[20] = 0xa5;
/* screen size: undefined */
edid[21] = info->prefx * 254 / 100 / info->dpi;
edid[22] = info->prefy * 254 / 100 / info->dpi;
edid[21] = width_mm / 10;
edid[22] = height_mm / 10;
/* display gamma: 2.2 */
edid[23] = 220 - 100;
@ -387,7 +400,8 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
/* =============== descriptor blocks =============== */
edid_desc_timing(edid + desc, info->prefx, info->prefy, info->dpi);
edid_desc_timing(edid + desc, info->prefx, info->prefy,
width_mm, height_mm);
desc += 18;
edid_desc_ranges(edid + desc);

View File

@ -595,7 +595,7 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
{
int i;
/* virgl_renderer_reset() ??? */
virgl_renderer_reset();
for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
if (i != 0) {
dpy_gfx_replace_surface(g->parent_obj.scanout[i].con, NULL);

View File

@ -82,6 +82,8 @@ static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
g->req_state[idx].y = info->yoff;
g->req_state[idx].width = info->width;
g->req_state[idx].height = info->height;
g->req_state[idx].width_mm = info->width_mm;
g->req_state[idx].height_mm = info->height_mm;
if (info->width && info->height) {
g->enabled_output_bitmask |= (1 << idx);

View File

@ -212,6 +212,8 @@ virtio_gpu_generate_edid(VirtIOGPU *g, int scanout,
{
VirtIOGPUBase *b = VIRTIO_GPU_BASE(g);
qemu_edid_info info = {
.width_mm = b->req_state[scanout].width_mm,
.height_mm = b->req_state[scanout].height_mm,
.prefx = b->req_state[scanout].width,
.prefy = b->req_state[scanout].height,
};

View File

@ -168,6 +168,20 @@ static void virtio_vga_base_reset(DeviceState *dev)
vga_dirty_log_start(&vvga->vga);
}
static bool virtio_vga_get_big_endian_fb(Object *obj, Error **errp)
{
VirtIOVGABase *d = VIRTIO_VGA_BASE(obj);
return d->vga.big_endian_fb;
}
static void virtio_vga_set_big_endian_fb(Object *obj, bool value, Error **errp)
{
VirtIOVGABase *d = VIRTIO_VGA_BASE(obj);
d->vga.big_endian_fb = value;
}
static Property virtio_vga_base_properties[] = {
DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
DEFINE_PROP_END_OF_LIST(),
@ -190,6 +204,11 @@ static void virtio_vga_base_class_init(ObjectClass *klass, void *data)
k->realize = virtio_vga_base_realize;
pcidev_k->romfile = "vgabios-virtio.bin";
pcidev_k->class_id = PCI_CLASS_DISPLAY_VGA;
/* Expose framebuffer byteorder via QOM */
object_class_property_add_bool(klass, "big-endian-framebuffer",
virtio_vga_get_big_endian_fb,
virtio_vga_set_big_endian_fb);
}
static TypeInfo virtio_vga_base_info = {

View File

@ -2464,7 +2464,9 @@ static int spapr_switch_one_vga(DeviceState *dev, void *opaque)
bool be = *(bool *)opaque;
if (object_dynamic_cast(OBJECT(dev), "VGA")
|| object_dynamic_cast(OBJECT(dev), "secondary-vga")) {
|| object_dynamic_cast(OBJECT(dev), "secondary-vga")
|| object_dynamic_cast(OBJECT(dev), "bochs-display")
|| object_dynamic_cast(OBJECT(dev), "virtio-vga")) {
object_property_set_bool(OBJECT(dev), "big-endian-framebuffer", be,
&error_abort);
}

View File

@ -5,7 +5,8 @@ typedef struct qemu_edid_info {
const char *vendor; /* http://www.uefi.org/pnp_id_list */
const char *name;
const char *serial;
uint32_t dpi;
uint16_t width_mm;
uint16_t height_mm;
uint32_t prefx;
uint32_t prefy;
uint32_t maxx;
@ -18,6 +19,8 @@ size_t qemu_edid_size(uint8_t *edid);
void qemu_edid_region_io(MemoryRegion *region, Object *owner,
uint8_t *edid, size_t size);
uint32_t qemu_edid_dpi_to_mm(uint32_t dpi, uint32_t res);
#define DEFINE_EDID_PROPERTIES(_state, _edid_info) \
DEFINE_PROP_UINT32("xres", _state, _edid_info.prefx, 0), \
DEFINE_PROP_UINT32("yres", _state, _edid_info.prefy, 0), \

View File

@ -62,6 +62,7 @@ struct virtio_gpu_scanout {
};
struct virtio_gpu_requested_state {
uint16_t width_mm, height_mm;
uint32_t width, height;
int x, y;
};

View File

@ -119,6 +119,9 @@ typedef struct DisplaySurface {
} DisplaySurface;
typedef struct QemuUIInfo {
/* physical dimension */
uint16_t width_mm;
uint16_t height_mm;
/* geometry */
int xoff;
int yoff;
@ -264,6 +267,7 @@ void update_displaychangelistener(DisplayChangeListener *dcl,
void unregister_displaychangelistener(DisplayChangeListener *dcl);
bool dpy_ui_info_supported(QemuConsole *con);
const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con);
int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info);
void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h);

View File

@ -9,7 +9,10 @@
#include "qemu/cutils.h"
#include "hw/display/edid.h"
static qemu_edid_info info;
static qemu_edid_info info = (qemu_edid_info) {
.prefx = 1024,
.prefy = 768,
};
static void usage(FILE *out)
{
@ -39,6 +42,7 @@ int main(int argc, char *argv[])
{
FILE *outfile = NULL;
uint8_t blob[256];
uint32_t dpi = 100;
int rc;
for (;;) {
@ -83,7 +87,7 @@ int main(int argc, char *argv[])
}
break;
case 'd':
if (qemu_strtoui(optarg, NULL, 10, &info.dpi) < 0) {
if (qemu_strtoui(optarg, NULL, 10, &dpi) < 0) {
fprintf(stderr, "not a number: %s\n", optarg);
exit(1);
}
@ -110,6 +114,9 @@ int main(int argc, char *argv[])
outfile = stdout;
}
info.width_mm = qemu_edid_dpi_to_mm(dpi, info.prefx);
info.height_mm = qemu_edid_dpi_to_mm(dpi, info.prefy);
memset(blob, 0, sizeof(blob));
qemu_edid_generate(blob, sizeof(blob), &info);
fwrite(blob, sizeof(blob), 1, outfile);

View File

@ -1516,6 +1516,13 @@ bool dpy_ui_info_supported(QemuConsole *con)
return con->hw_ops->ui_info != NULL;
}
const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con)
{
assert(con != NULL);
return &con->ui_info;
}
int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info)
{
assert(con != NULL);

View File

@ -672,30 +672,19 @@ static int interface_client_monitors_config(QXLInstance *sin,
return 1;
}
memset(&info, 0, sizeof(info));
info = *dpy_get_ui_info(ssd->dcl.con);
if (mc->num_of_monitors == 1) {
/*
* New spice-server version which filters the list of monitors
* to only include those that belong to our display channel.
*
* single-head configuration (where filtering doesn't matter)
* takes this code path too.
*/
info.width = mc->monitors[0].width;
info.height = mc->monitors[0].height;
} else {
/*
* Old spice-server which gives us all monitors, so we have to
* figure ourself which entry we need. Array index is the
* channel_id, which is the qemu console index, see
* qemu_spice_add_display_interface().
*/
head = qemu_console_get_index(ssd->dcl.con);
if (mc->num_of_monitors > head) {
info.width = mc->monitors[head].width;
info.height = mc->monitors[head].height;
head = qemu_console_get_index(ssd->dcl.con);
if (mc->num_of_monitors > head) {
info.width = mc->monitors[head].width;
info.height = mc->monitors[head].height;
#if SPICE_SERVER_VERSION >= 0x000e04 /* release 0.14.4 */
if (mc->flags & VD_AGENT_CONFIG_MONITORS_FLAG_PHYSICAL_SIZE) {
VDAgentMonitorMM *mm = (void *)&mc->monitors[mc->num_of_monitors];
info.width_mm = mm[head].width;
info.height_mm = mm[head].height;
}
#endif
}
trace_qemu_spice_ui_info(ssd->qxl.id, info.width, info.height);