Support per-head resolutions with virtio-gpu
v2 cover Support per-head resolutions with virtio-gpu
In 454f4b0f, we started down the path of supporting separate configurations per display head (e.g., you have 2 heads - one with EDID name "AAA" and the other with EDID name "BBB").
In this change, we add resolution to this configuration surface (e.g., you have 2 heads - one with resolution 111x222 and the other with resolution 333x444).
-display vnc=localhost:0,id=aaa,display=vga,head=0 \
-display vnc=localhost:1,id=bbb,display=vga,head=1 \
-device '{"driver":"virtio-vga",
"max_outputs":2,
"id":"vga",
"outputs":[
{
"name":"AAA",
"xres":111,
"yres":222
},
{
"name":"BBB",
"xres":333,
"yres":444
}
]}'Here is the behavior matrix of the current resolution configuration surface (xres/yres) with the new resolution configuration surface (outputs[i].xres/yres).
Case: !(xres || yres) && !(outputs[i].xres || outputs[i].yres)
Behavior: current behavior - outputs[0] enabled with default xres/yres
Case: (xres || yres) && !(outputs[i].xres || outputs[i].yres)
Behavior: current behavior - outputs[0] enabled with xres/yres
Case: !(xres || yres) && (outputs[i].xres || outputs[i].yres)
Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres
Case: (xres || yres) && (outputs[i].xres || outputs[i].yres)
Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres
Changelist:
* v2: changes after v1 review + 10.2 rebase
* updated code, commit message, and cover letter to match new res config logic
* marked new VirtIOGPUOutput fields as optional and since 10.2
* v1: initial patch
Andrew Keesler (1):
Support per-head resolutions with virtio-gpu
hw/display/virtio-gpu-base.c | 10 ++++++++++ include/hw/virtio/virtio-gpu.h | 2 ++ qapi/virtio.json | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-)
Signature · 1 line
2.51.0.338.gd7d06c2dae-goog
PATCH v2 1/1 Support per-head resolutions with virtio-gpu
In 454f4b0f, we started down the path of supporting separate configurations per display head (e.g., you have 2 heads - one with EDID name "AAA" and the other with EDID name "BBB").
In this change, we add resolution to this configuration surface (e.g., you have 2 heads - one with resolution 111x222 and the other with resolution 333x444).
-display vnc=localhost:0,id=aaa,display=vga,head=0 \
-display vnc=localhost:1,id=bbb,display=vga,head=1 \
-device '{"driver":"virtio-vga",
"max_outputs":2,
"id":"vga",
"outputs":[
{
"name":"AAA",
"xres":111,
"yres":222
},
{
"name":"BBB",
"xres":333,
"yres":444
}
]}'Here is the behavior matrix of the current resolution configuration surface (xres/yres) with the new resolution configuration surface (outputs[i].xres/yres).
Case: !(xres || yres) && !(outputs[i].xres || outputs[i].yres)
Behavior: current behavior - outputs[0] enabled with default xres/yres
Case: (xres || yres) && !(outputs[i].xres || outputs[i].yres)
Behavior: current behavior - outputs[0] enabled with xres/yres
Case: !(xres || yres) && (outputs[i].xres || outputs[i].yres)
Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres
Case: (xres || yres) && (outputs[i].xres || outputs[i].yres)
Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres
--- hw/display/virtio-gpu-base.c | 10 ++++++++++ include/hw/virtio/virtio-gpu.h | 2 ++ qapi/virtio.json | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-)
hw/display/virtio-gpu-base.c +10 -0
@@ -233,6 +233,16 @@ virtio_gpu_base_device_realize(DeviceState *qdev, g->req_state[0 ].width = g->conf.xres; g->req_state[0 ].height = g->conf.yres; +for (output_idx =0 , node = g->conf.outputs; + node && output_idx < g->conf.max_outputs; + output_idx++, node = node->next) { +if (node->value->xres || node->value->yres) { + g->enabled_output_bitmask |= (1 << output_idx); + g->req_state[output_idx].width = node->value->xres; + g->req_state[output_idx].height = node->value->yres; + } + } + g->hw_ops = &virtio_gpu_ops;for (i =0 ; i < g->conf.max_outputs; i++) { g->scanout[i].con =
include/hw/virtio/virtio-gpu.h +2 -0
@@ -129,6 +129,8 @@ struct virtio_gpu_base_conf {uint32_t xres;uint32_t yres;uint64_t hostmem; +// If set, outputs[i].xres/yres takes precedent over xres/yres and enables +// the ith output. VirtIOGPUOutputList *outputs; };
qapi/virtio.json +5 -1
@@ -970,11 +970,15 @@ # # @name: the name of the output # +# @xres: horizontal resolution of the output in pixels (since 10.2) +# +# @yres: vertical resolution of the output in pixels (since 10.2) +# # Since: 10.1 ## { 'struct': 'VirtIOGPUOutput', - 'data': { 'name': 'str' } } + 'data': { 'name': 'str', '*xres': 'uint16', '*yres': 'uint16' } } ## # @DummyVirtioForceArrays:
Signature · 1 line
2.51.0.338.gd7d06c2dae-goog
Quoted 52 lines · Andrew Keesler
In
454f4b0f, we started down the path of supporting separate configurations per display head (e.g., you have 2 heads - one with EDID name "AAA" and the other with EDID name "BBB").In this change, we add resolution to this configuration surface (e.g., you have 2 heads - one with resolution 111x222 and the other with resolution 333x444).
-display vnc=localhost:0,id=aaa,display=vga,head=0 \ -display vnc=localhost:1,id=bbb,display=vga,head=1 \ -device '{"driver":"virtio-vga", "max_outputs":2, "id":"vga", "outputs":[ { "name":"AAA", "xres":111, "yres":222 }, { "name":"BBB", "xres":333, "yres":444 } ]}'Here is the behavior matrix of the current resolution configuration surface (xres/yres) with the new resolution configuration surface (outputs[i].xres/yres).
Case: !(xres || yres) && !(outputs[i].xres || outputs[i].yres)
Behavior: current behavior - outputs[0] enabled with default xres/yresCase: (xres || yres) && !(outputs[i].xres || outputs[i].yres)
Behavior: current behavior - outputs[0] enabled with xres/yresCase: !(xres || yres) && (outputs[i].xres || outputs[i].yres)
Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yresCase: (xres || yres) && (outputs[i].xres || outputs[i].yres)
Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres--- hw/display/virtio-gpu-base.c | 10 ++++++++++ include/hw/virtio/virtio-gpu.h | 2 ++ qapi/virtio.json | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-)hw/display/virtio-gpu-base.c +0
-0
hw/display/virtio-gpu-base.c virtio_gpu_base_device_realize(DeviceState *qdev, · line 239
Quoted 7 lines
hw/display/virtio-gpu-base.c +4
-0@@ -233,6 +233,16 @@ virtio_gpu_base_device_realize(DeviceState *qdev, g->req_state[0 ].width = g->conf.xres; g->req_state[0 ].height = g->conf.yres; +for (output_idx =0 , node = g->conf.outputs; + node && output_idx < g->conf.max_outputs; + output_idx++, node = node->next) { +if (node->value->xres || node->value->yres) {
This should be
if (node->value->has_xres && node->value->has_yres) {Quoted 14 lines
hw/display/virtio-gpu-base.c +6
-0+ g->enabled_output_bitmask |= (1 << output_idx); + g->req_state[output_idx].width = node->value->xres; + g->req_state[output_idx].height = node->value->yres; + } + } + g->hw_ops = &virtio_gpu_ops;for (i =0 ; i < g->conf.max_outputs; i++) { g->scanout[i].con =include/hw/virtio/virtio-gpu.h +0
-0
include/hw/virtio/virtio-gpu.h struct virtio_gpu_base_conf { · line 133
Quoted 5 lines
include/hw/virtio/virtio-gpu.h +2
-0@@ -129,6 +129,8 @@ struct virtio_gpu_base_conf {uint32_t xres;uint32_t yres;uint64_t hostmem; +// If set, outputs[i].xres/yres takes precedent over xres/yres and enables +// the ith output.
I mean for that doc to be in the virtio.json file, so it gets into the public QMP API documentation
Quoted 27 lines
include/hw/virtio/virtio-gpu.h +0
-0VirtIOGPUOutputList *outputs; };qapi/virtio.json +5
-1@@ -970,11 +970,15 @@ # # @name: the name of the output # +# @xres: horizontal resolution of the output in pixels (since 10.2) +# +# @yres: vertical resolution of the output in pixels (since 10.2) +# # Since: 10.1 ## { 'struct': 'VirtIOGPUOutput', - 'data': { 'name': 'str' } } + 'data': { 'name': 'str', '*xres': 'uint16', '*yres': 'uint16' } } ## # @DummyVirtioForceArrays:Signature · 1 line
2.51.0.338.gd7d06c2dae-goog
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|