* [Qemu-devel] [PATCH v2 0/4] vga: make display size configurable
@ 2017-03-09 8:38 Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 1/4] virtio-gpu: add xres and yres properties Gerd Hoffmann
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2017-03-09 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Hi,
Next attempt, this time using device properties (xres and yres) instead
of extending the usage of the -g switch, as suggested by paolo. This
series has support for virtio, qxl and stdvga. For stdvga the virtual
hardware is updated with additional (read-only) registers.
cheers,
Gerd
Gerd Hoffmann (4):
virtio-gpu: add xres and yres properties
qxl: add xres and yres properties
stdvga: move common properties to common base class
[RfC] stdvga: add xres and yres properties.
hw/display/qxl.c | 34 ++++++++++++++++-------
hw/display/qxl.h | 2 ++
hw/display/vga-pci.c | 63 +++++++++++++++++++++++++++---------------
hw/display/vga_int.h | 6 ++--
hw/display/virtio-gpu.c | 6 ++--
hw/display/virtio-vga.c | 3 +-
include/hw/virtio/virtio-gpu.h | 2 ++
7 files changed, 78 insertions(+), 38 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 1/4] virtio-gpu: add xres and yres properties
2017-03-09 8:38 [Qemu-devel] [PATCH v2 0/4] vga: make display size configurable Gerd Hoffmann
@ 2017-03-09 8:38 ` Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 2/4] qxl: " Gerd Hoffmann
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2017-03-09 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Michael S. Tsirkin
So the default resolution is configurable.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/display/virtio-gpu.c | 6 ++++--
include/hw/virtio/virtio-gpu.h | 2 ++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 9b530ab..01bceb4 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1170,8 +1170,8 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU,
g->config_size);
- g->req_state[0].width = 1024;
- g->req_state[0].height = 768;
+ g->req_state[0].width = g->conf.xres;
+ g->req_state[0].height = g->conf.yres;
if (virtio_gpu_virgl_enabled(g->conf)) {
/* use larger control queue in 3d mode */
@@ -1291,6 +1291,8 @@ static Property virtio_gpu_properties[] = {
DEFINE_PROP_BIT("stats", VirtIOGPU, conf.flags,
VIRTIO_GPU_FLAG_STATS_ENABLED, false),
#endif
+ DEFINE_PROP_UINT32("xres", VirtIOGPU, conf.xres, 1024),
+ DEFINE_PROP_UINT32("yres", VirtIOGPU, conf.yres, 768),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index f3a98a3..f3ffdce 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -72,6 +72,8 @@ struct virtio_gpu_conf {
uint64_t max_hostmem;
uint32_t max_outputs;
uint32_t flags;
+ uint32_t xres;
+ uint32_t yres;
};
struct virtio_gpu_ctrl_command {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 2/4] qxl: add xres and yres properties
2017-03-09 8:38 [Qemu-devel] [PATCH v2 0/4] vga: make display size configurable Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 1/4] virtio-gpu: add xres and yres properties Gerd Hoffmann
@ 2017-03-09 8:38 ` Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 3/4] stdvga: move common properties to common base class Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 4/4] [RfC] stdvga: add xres and yres properties Gerd Hoffmann
3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2017-03-09 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Add properties for the default display resolution, pass
on that information to the guest so the driver can use it.
Also move up qxl_crc32() function so we don't need a
forward declaration.
Additionally guest driver updates are needed so the
guest driver will actually pick this up, which will
probably land in linux kernel 4.12.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/display/qxl.c | 34 ++++++++++++++++++++++++----------
hw/display/qxl.h | 2 ++
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index af4c0ca..3bb8159 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -304,6 +304,16 @@ void qxl_spice_reset_cursor(PCIQXLDevice *qxl)
qxl->ssd.cursor = cursor_builtin_hidden();
}
+static uint32_t qxl_crc32(const uint8_t *p, unsigned len)
+{
+ /*
+ * zlib xors the seed with 0xffffffff, and xors the result
+ * again with 0xffffffff; Both are not done with linux's crc32,
+ * which we want to be compatible with, so undo that.
+ */
+ return crc32(0xffffffff, p, len) ^ 0xffffffff;
+}
+
static ram_addr_t qxl_rom_size(void)
{
#define QXL_REQUIRED_SZ (sizeof(QXLRom) + sizeof(QXLModes) + sizeof(qxl_modes))
@@ -368,6 +378,18 @@ static void init_qxl_rom(PCIQXLDevice *d)
rom->num_pages = cpu_to_le32(num_pages);
rom->ram_header_offset = cpu_to_le32(d->vga.vram_size - ram_header_size);
+ if (d->xres && d->yres) {
+ /* needs linux kernel 4.12+ to work */
+ rom->client_monitors_config.count = 1;
+ rom->client_monitors_config.heads[0].left = 0;
+ rom->client_monitors_config.heads[0].top = 0;
+ rom->client_monitors_config.heads[0].right = cpu_to_le32(d->xres);
+ rom->client_monitors_config.heads[0].bottom = cpu_to_le32(d->yres);
+ rom->client_monitors_config_crc = qxl_crc32(
+ (const uint8_t *)&rom->client_monitors_config,
+ sizeof(rom->client_monitors_config));
+ }
+
d->shadow_rom = *rom;
d->rom = rom;
d->modes = modes;
@@ -981,16 +1003,6 @@ static void interface_set_client_capabilities(QXLInstance *sin,
qxl_send_events(qxl, QXL_INTERRUPT_CLIENT);
}
-static uint32_t qxl_crc32(const uint8_t *p, unsigned len)
-{
- /*
- * zlib xors the seed with 0xffffffff, and xors the result
- * again with 0xffffffff; Both are not done with linux's crc32,
- * which we want to be compatible with, so undo that.
- */
- return crc32(0xffffffff, p, len) ^ 0xffffffff;
-}
-
static bool qxl_rom_monitors_config_changed(QXLRom *rom,
VDAgentMonitorsConfig *monitors_config,
unsigned int max_outputs)
@@ -2360,6 +2372,8 @@ static Property qxl_properties[] = {
#if SPICE_SERVER_VERSION >= 0x000c06 /* release 0.12.6 */
DEFINE_PROP_UINT16("max_outputs", PCIQXLDevice, max_outputs, 0),
#endif
+ DEFINE_PROP_UINT32("xres", PCIQXLDevice, xres, 0),
+ DEFINE_PROP_UINT32("yres", PCIQXLDevice, yres, 0),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
index d2d49dd..cfc0410 100644
--- a/hw/display/qxl.h
+++ b/hw/display/qxl.h
@@ -118,6 +118,8 @@ typedef struct PCIQXLDevice {
uint32_t vram_size_mb;
uint32_t vram32_size_mb;
uint32_t vgamem_size_mb;
+ uint32_t xres;
+ uint32_t yres;
/* qxl_render_update state */
int render_update_cookie_num;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 3/4] stdvga: move common properties to common base class
2017-03-09 8:38 [Qemu-devel] [PATCH v2 0/4] vga: make display size configurable Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 1/4] virtio-gpu: add xres and yres properties Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 2/4] qxl: " Gerd Hoffmann
@ 2017-03-09 8:38 ` Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 4/4] [RfC] stdvga: add xres and yres properties Gerd Hoffmann
3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2017-03-09 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/display/vga-pci.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index ac9a764..8500362 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -306,15 +306,12 @@ static void pci_secondary_vga_reset(DeviceState *dev)
vga_common_reset(&d->vga);
}
-static Property vga_pci_properties[] = {
- DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
+static Property vga_pci_primary_properties[] = {
DEFINE_PROP_BIT("mmio", PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_MMIO, true),
- DEFINE_PROP_BIT("qemu-extended-regs",
- PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true),
DEFINE_PROP_END_OF_LIST(),
};
-static Property secondary_pci_properties[] = {
+static Property vga_pci_common_properties[] = {
DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
DEFINE_PROP_BIT("qemu-extended-regs",
PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true),
@@ -329,6 +326,7 @@ static void vga_pci_class_init(ObjectClass *klass, void *data)
k->vendor_id = PCI_VENDOR_ID_QEMU;
k->device_id = PCI_DEVICE_ID_QEMU_VGA;
dc->vmsd = &vmstate_vga_pci;
+ dc->props = vga_pci_common_properties;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
}
@@ -348,7 +346,7 @@ static void vga_class_init(ObjectClass *klass, void *data)
k->realize = pci_std_vga_realize;
k->romfile = "vgabios-stdvga.bin";
k->class_id = PCI_CLASS_DISPLAY_VGA;
- dc->props = vga_pci_properties;
+ dc->props = vga_pci_primary_properties;
dc->hotpluggable = false;
}
@@ -359,7 +357,6 @@ static void secondary_class_init(ObjectClass *klass, void *data)
k->realize = pci_secondary_vga_realize;
k->class_id = PCI_CLASS_DISPLAY_OTHER;
- dc->props = secondary_pci_properties;
dc->reset = pci_secondary_vga_reset;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 4/4] [RfC] stdvga: add xres and yres properties.
2017-03-09 8:38 [Qemu-devel] [PATCH v2 0/4] vga: make display size configurable Gerd Hoffmann
` (2 preceding siblings ...)
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 3/4] stdvga: move common properties to common base class Gerd Hoffmann
@ 2017-03-09 8:38 ` Gerd Hoffmann
2017-03-09 21:03 ` Hervé Poussineau
3 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2017-03-09 8:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Michael S. Tsirkin
Add two new registers to the qemu extended register range, carrying the
suggested width and height of the display device. In case the xres and
yres properties are set, fill these new registers accordingly.
Additionally guest driver updates are needed to support the new
registers. These changes will probably land in linux kernel 4.12.
TODO: add compat properties to turn off qemu-display-size for machine
types older than 2.10
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/display/vga-pci.c | 52 ++++++++++++++++++++++++++++++++++---------------
hw/display/vga_int.h | 6 ++++--
hw/display/virtio-vga.c | 3 ++-
3 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index 8500362..10b1832 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -31,23 +31,28 @@
#include "ui/pixel_ops.h"
#include "qemu/timer.h"
#include "hw/loader.h"
+#include "sysemu/sysemu.h"
#define PCI_VGA_IOPORT_OFFSET 0x400
#define PCI_VGA_IOPORT_SIZE (0x3e0 - 0x3c0)
#define PCI_VGA_BOCHS_OFFSET 0x500
#define PCI_VGA_BOCHS_SIZE (0x0b * 2)
#define PCI_VGA_QEXT_OFFSET 0x600
-#define PCI_VGA_QEXT_SIZE (2 * 4)
+#define PCI_VGA_QEXT_SIZE_V1 (2 * 4)
+#define PCI_VGA_QEXT_SIZE_V2 (4 * 4)
#define PCI_VGA_MMIO_SIZE 0x1000
#define PCI_VGA_QEXT_REG_SIZE (0 * 4)
#define PCI_VGA_QEXT_REG_BYTEORDER (1 * 4)
#define PCI_VGA_QEXT_LITTLE_ENDIAN 0x1e1e1e1e
#define PCI_VGA_QEXT_BIG_ENDIAN 0xbebebebe
+#define PCI_VGA_QEXT_REG_WIDTH (2 * 4)
+#define PCI_VGA_QEXT_REG_HEIGHT (3 * 4)
enum vga_pci_flags {
- PCI_VGA_FLAG_ENABLE_MMIO = 1,
- PCI_VGA_FLAG_ENABLE_QEXT = 2,
+ PCI_VGA_FLAG_ENABLE_MMIO = 1,
+ PCI_VGA_FLAG_ENABLE_QEXT = 2,
+ PCI_VGA_FLAG_ENABLE_QEXT_V2 = 3,
};
typedef struct PCIVGAState {
@@ -157,10 +162,14 @@ static uint64_t pci_vga_qext_read(void *ptr, hwaddr addr, unsigned size)
switch (addr) {
case PCI_VGA_QEXT_REG_SIZE:
- return PCI_VGA_QEXT_SIZE;
+ return s->qext_size;
case PCI_VGA_QEXT_REG_BYTEORDER:
return s->big_endian_fb ?
PCI_VGA_QEXT_BIG_ENDIAN : PCI_VGA_QEXT_LITTLE_ENDIAN;
+ case PCI_VGA_QEXT_REG_WIDTH:
+ return s->xres;
+ case PCI_VGA_QEXT_REG_HEIGHT:
+ return s->yres;
default:
return 0;
}
@@ -207,8 +216,7 @@ static const MemoryRegionOps pci_vga_qext_ops = {
void pci_std_vga_mmio_region_init(VGACommonState *s,
MemoryRegion *parent,
- MemoryRegion *subs,
- bool qext)
+ MemoryRegion *subs)
{
memory_region_init_io(&subs[0], NULL, &pci_vga_ioport_ops, s,
"vga ioports remapped", PCI_VGA_IOPORT_SIZE);
@@ -220,9 +228,9 @@ void pci_std_vga_mmio_region_init(VGACommonState *s,
memory_region_add_subregion(parent, PCI_VGA_BOCHS_OFFSET,
&subs[1]);
- if (qext) {
+ if (s->qext_size) {
memory_region_init_io(&subs[2], NULL, &pci_vga_qext_ops, s,
- "qemu extended regs", PCI_VGA_QEXT_SIZE);
+ "qemu extended regs", s->qext_size);
memory_region_add_subregion(parent, PCI_VGA_QEXT_OFFSET,
&subs[2]);
}
@@ -232,7 +240,6 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
{
PCIVGAState *d = PCI_VGA(dev);
VGACommonState *s = &d->vga;
- bool qext = false;
/* vga + console init */
vga_common_init(s, OBJECT(dev), true);
@@ -249,10 +256,15 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
memory_region_init(&d->mmio, NULL, "vga.mmio", 4096);
if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
- qext = true;
- pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+ if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT_V2)) {
+ s->qext_size = PCI_VGA_QEXT_SIZE_V2;
+ pci_set_byte(&d->dev.config[PCI_REVISION_ID], 3);
+ } else {
+ s->qext_size = PCI_VGA_QEXT_SIZE_V1;
+ pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+ }
}
- pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
+ pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
}
@@ -274,7 +286,6 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
{
PCIVGAState *d = PCI_VGA(dev);
VGACommonState *s = &d->vga;
- bool qext = false;
/* vga + console init */
vga_common_init(s, OBJECT(dev), false);
@@ -284,10 +295,15 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
memory_region_init(&d->mmio, OBJECT(dev), "vga.mmio", 4096);
if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
- qext = true;
- pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+ if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT_V2)) {
+ s->qext_size = PCI_VGA_QEXT_SIZE_V2;
+ pci_set_byte(&d->dev.config[PCI_REVISION_ID], 3);
+ } else {
+ s->qext_size = PCI_VGA_QEXT_SIZE_V1;
+ pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
+ }
}
- pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
+ pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs);
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
@@ -315,6 +331,10 @@ static Property vga_pci_common_properties[] = {
DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
DEFINE_PROP_BIT("qemu-extended-regs",
PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true),
+ DEFINE_PROP_BIT("qemu-display-size",
+ PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT_V2, true),
+ DEFINE_PROP_UINT32("xres", PCIVGAState, vga.xres, 0),
+ DEFINE_PROP_UINT32("yres", PCIVGAState, vga.yres, 0),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index dd6c958..1e9b0ff 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -162,6 +162,9 @@ typedef struct VGACommonState {
bool full_update_gfx;
bool big_endian_fb;
bool default_endian_fb;
+ uint32_t qext_size;
+ uint32_t xres;
+ uint32_t yres;
/* hardware mouse cursor support */
uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32];
uint32_t hw_cursor_x;
@@ -223,7 +226,6 @@ extern const MemoryRegionOps vga_mem_ops;
/* vga-pci.c */
void pci_std_vga_mmio_region_init(VGACommonState *s,
MemoryRegion *parent,
- MemoryRegion *subs,
- bool qext);
+ MemoryRegion *subs);
#endif
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index f9b017d..8684dc0 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -153,8 +153,9 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
}
/* add stdvga mmio regions */
+ vga->qext_size = 2 * 4; /* PCI_VGA_QEXT_SIZE_V1 */
pci_std_vga_mmio_region_init(vga, &vpci_dev->modern_bar,
- vvga->vga_mrs, true);
+ vvga->vga_mrs);
vga->con = g->scanout[0].con;
graphic_console_set_hwops(vga->con, &virtio_vga_ops, vvga);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/4] [RfC] stdvga: add xres and yres properties.
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 4/4] [RfC] stdvga: add xres and yres properties Gerd Hoffmann
@ 2017-03-09 21:03 ` Hervé Poussineau
2017-03-13 15:17 ` Gerd Hoffmann
0 siblings, 1 reply; 7+ messages in thread
From: Hervé Poussineau @ 2017-03-09 21:03 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel; +Cc: Michael S. Tsirkin
Le 09/03/2017 à 09:38, Gerd Hoffmann a écrit :
> Add two new registers to the qemu extended register range, carrying the
> suggested width and height of the display device. In case the xres and
> yres properties are set, fill these new registers accordingly.
>
> Additionally guest driver updates are needed to support the new
> registers. These changes will probably land in linux kernel 4.12.
Is it possible to provide a mecanism to tell guest that the preferred default size changed?
For example, the user can resize the VM window on host, and guest will auto-adapt to new size/resolution.
It is already working like this on VirtualBox with VM Additions.
Regards,
Hervé
>
> TODO: add compat properties to turn off qemu-display-size for machine
> types older than 2.10
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/display/vga-pci.c | 52 ++++++++++++++++++++++++++++++++++---------------
> hw/display/vga_int.h | 6 ++++--
> hw/display/virtio-vga.c | 3 ++-
> 3 files changed, 42 insertions(+), 19 deletions(-)
>
> diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
> index 8500362..10b1832 100644
> --- a/hw/display/vga-pci.c
> +++ b/hw/display/vga-pci.c
> @@ -31,23 +31,28 @@
> #include "ui/pixel_ops.h"
> #include "qemu/timer.h"
> #include "hw/loader.h"
> +#include "sysemu/sysemu.h"
>
> #define PCI_VGA_IOPORT_OFFSET 0x400
> #define PCI_VGA_IOPORT_SIZE (0x3e0 - 0x3c0)
> #define PCI_VGA_BOCHS_OFFSET 0x500
> #define PCI_VGA_BOCHS_SIZE (0x0b * 2)
> #define PCI_VGA_QEXT_OFFSET 0x600
> -#define PCI_VGA_QEXT_SIZE (2 * 4)
> +#define PCI_VGA_QEXT_SIZE_V1 (2 * 4)
> +#define PCI_VGA_QEXT_SIZE_V2 (4 * 4)
> #define PCI_VGA_MMIO_SIZE 0x1000
>
> #define PCI_VGA_QEXT_REG_SIZE (0 * 4)
> #define PCI_VGA_QEXT_REG_BYTEORDER (1 * 4)
> #define PCI_VGA_QEXT_LITTLE_ENDIAN 0x1e1e1e1e
> #define PCI_VGA_QEXT_BIG_ENDIAN 0xbebebebe
> +#define PCI_VGA_QEXT_REG_WIDTH (2 * 4)
> +#define PCI_VGA_QEXT_REG_HEIGHT (3 * 4)
>
> enum vga_pci_flags {
> - PCI_VGA_FLAG_ENABLE_MMIO = 1,
> - PCI_VGA_FLAG_ENABLE_QEXT = 2,
> + PCI_VGA_FLAG_ENABLE_MMIO = 1,
> + PCI_VGA_FLAG_ENABLE_QEXT = 2,
> + PCI_VGA_FLAG_ENABLE_QEXT_V2 = 3,
> };
>
> typedef struct PCIVGAState {
> @@ -157,10 +162,14 @@ static uint64_t pci_vga_qext_read(void *ptr, hwaddr addr, unsigned size)
>
> switch (addr) {
> case PCI_VGA_QEXT_REG_SIZE:
> - return PCI_VGA_QEXT_SIZE;
> + return s->qext_size;
> case PCI_VGA_QEXT_REG_BYTEORDER:
> return s->big_endian_fb ?
> PCI_VGA_QEXT_BIG_ENDIAN : PCI_VGA_QEXT_LITTLE_ENDIAN;
> + case PCI_VGA_QEXT_REG_WIDTH:
> + return s->xres;
> + case PCI_VGA_QEXT_REG_HEIGHT:
> + return s->yres;
> default:
> return 0;
> }
> @@ -207,8 +216,7 @@ static const MemoryRegionOps pci_vga_qext_ops = {
>
> void pci_std_vga_mmio_region_init(VGACommonState *s,
> MemoryRegion *parent,
> - MemoryRegion *subs,
> - bool qext)
> + MemoryRegion *subs)
> {
> memory_region_init_io(&subs[0], NULL, &pci_vga_ioport_ops, s,
> "vga ioports remapped", PCI_VGA_IOPORT_SIZE);
> @@ -220,9 +228,9 @@ void pci_std_vga_mmio_region_init(VGACommonState *s,
> memory_region_add_subregion(parent, PCI_VGA_BOCHS_OFFSET,
> &subs[1]);
>
> - if (qext) {
> + if (s->qext_size) {
> memory_region_init_io(&subs[2], NULL, &pci_vga_qext_ops, s,
> - "qemu extended regs", PCI_VGA_QEXT_SIZE);
> + "qemu extended regs", s->qext_size);
> memory_region_add_subregion(parent, PCI_VGA_QEXT_OFFSET,
> &subs[2]);
> }
> @@ -232,7 +240,6 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
> {
> PCIVGAState *d = PCI_VGA(dev);
> VGACommonState *s = &d->vga;
> - bool qext = false;
>
> /* vga + console init */
> vga_common_init(s, OBJECT(dev), true);
> @@ -249,10 +256,15 @@ static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
> memory_region_init(&d->mmio, NULL, "vga.mmio", 4096);
>
> if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
> - qext = true;
> - pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
> + if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT_V2)) {
> + s->qext_size = PCI_VGA_QEXT_SIZE_V2;
> + pci_set_byte(&d->dev.config[PCI_REVISION_ID], 3);
> + } else {
> + s->qext_size = PCI_VGA_QEXT_SIZE_V1;
> + pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
> + }
> }
> - pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
> + pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs);
>
> pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
> }
> @@ -274,7 +286,6 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
> {
> PCIVGAState *d = PCI_VGA(dev);
> VGACommonState *s = &d->vga;
> - bool qext = false;
>
> /* vga + console init */
> vga_common_init(s, OBJECT(dev), false);
> @@ -284,10 +295,15 @@ static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
> memory_region_init(&d->mmio, OBJECT(dev), "vga.mmio", 4096);
>
> if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) {
> - qext = true;
> - pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
> + if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT_V2)) {
> + s->qext_size = PCI_VGA_QEXT_SIZE_V2;
> + pci_set_byte(&d->dev.config[PCI_REVISION_ID], 3);
> + } else {
> + s->qext_size = PCI_VGA_QEXT_SIZE_V1;
> + pci_set_byte(&d->dev.config[PCI_REVISION_ID], 2);
> + }
> }
> - pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs, qext);
> + pci_std_vga_mmio_region_init(s, &d->mmio, d->mrs);
>
> pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
> pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
> @@ -315,6 +331,10 @@ static Property vga_pci_common_properties[] = {
> DEFINE_PROP_UINT32("vgamem_mb", PCIVGAState, vga.vram_size_mb, 16),
> DEFINE_PROP_BIT("qemu-extended-regs",
> PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT, true),
> + DEFINE_PROP_BIT("qemu-display-size",
> + PCIVGAState, flags, PCI_VGA_FLAG_ENABLE_QEXT_V2, true),
> + DEFINE_PROP_UINT32("xres", PCIVGAState, vga.xres, 0),
> + DEFINE_PROP_UINT32("yres", PCIVGAState, vga.yres, 0),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
> index dd6c958..1e9b0ff 100644
> --- a/hw/display/vga_int.h
> +++ b/hw/display/vga_int.h
> @@ -162,6 +162,9 @@ typedef struct VGACommonState {
> bool full_update_gfx;
> bool big_endian_fb;
> bool default_endian_fb;
> + uint32_t qext_size;
> + uint32_t xres;
> + uint32_t yres;
> /* hardware mouse cursor support */
> uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32];
> uint32_t hw_cursor_x;
> @@ -223,7 +226,6 @@ extern const MemoryRegionOps vga_mem_ops;
> /* vga-pci.c */
> void pci_std_vga_mmio_region_init(VGACommonState *s,
> MemoryRegion *parent,
> - MemoryRegion *subs,
> - bool qext);
> + MemoryRegion *subs);
>
> #endif
> diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
> index f9b017d..8684dc0 100644
> --- a/hw/display/virtio-vga.c
> +++ b/hw/display/virtio-vga.c
> @@ -153,8 +153,9 @@ static void virtio_vga_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
> }
>
> /* add stdvga mmio regions */
> + vga->qext_size = 2 * 4; /* PCI_VGA_QEXT_SIZE_V1 */
> pci_std_vga_mmio_region_init(vga, &vpci_dev->modern_bar,
> - vvga->vga_mrs, true);
> + vvga->vga_mrs);
>
> vga->con = g->scanout[0].con;
> graphic_console_set_hwops(vga->con, &virtio_vga_ops, vvga);
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH v2 4/4] [RfC] stdvga: add xres and yres properties.
2017-03-09 21:03 ` Hervé Poussineau
@ 2017-03-13 15:17 ` Gerd Hoffmann
0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2017-03-13 15:17 UTC (permalink / raw)
To: Hervé Poussineau; +Cc: qemu-devel, Michael S. Tsirkin
On Do, 2017-03-09 at 22:03 +0100, Hervé Poussineau wrote:
> Le 09/03/2017 à 09:38, Gerd Hoffmann a écrit :
> > Add two new registers to the qemu extended register range, carrying the
> > suggested width and height of the display device. In case the xres and
> > yres properties are set, fill these new registers accordingly.
> >
> > Additionally guest driver updates are needed to support the new
> > registers. These changes will probably land in linux kernel 4.12.
>
> Is it possible to provide a mecanism to tell guest that the preferred
> default size changed?
> For example, the user can resize the VM window on host, and guest will
> auto-adapt to new size/resolution.
> It is already working like this on VirtualBox with VM Additions.
Well, sure, we can pimp the virtual hardware even more. Adding such a
notification is pretty invasive though. We'll have to add irq support
to stdvga, on both guest and host.
So the question is: Is it worth the effort? How far we want take it
and why?
For linux this would require a pretty recent guest kernel with the (to
be written) driver changes added. If you have a recent guest kernel
anyway you can just switch to virtio-gpu where this works today (gtk ui,
or spice with guest agent active). So I see little reason to put too
much effort into stdvga, for linux guests.
For non-linux guests (where no virtio-gpu driver is available) better
stdvga support might be more useful. Do you have specific guests in
mind? Looking at your email address I suspect that is the case ...
While being at it: We might also consider adding hardware cursor
support. Seems that is standard these days. Wayland has no software
cursor support any more, therefore you have no mouse pointer when
running wayland on stdvga (again: on virtio-gpu it'll work just fine).
cheers,
Gerd
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-03-13 15:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-09 8:38 [Qemu-devel] [PATCH v2 0/4] vga: make display size configurable Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 1/4] virtio-gpu: add xres and yres properties Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 2/4] qxl: " Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 3/4] stdvga: move common properties to common base class Gerd Hoffmann
2017-03-09 8:38 ` [Qemu-devel] [PATCH v2 4/4] [RfC] stdvga: add xres and yres properties Gerd Hoffmann
2017-03-09 21:03 ` Hervé Poussineau
2017-03-13 15:17 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).