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
              }
            ]}'

If no virtio_gpu_base_conf.outputs are provided, then
virtio_gpu_base_conf.xres/virtio_gpu_base_conf.yres will still be
respected, preserving backwards compatibility.

Otherwise, if any virtio_gpu_base_conf.outputs are provided, then
virtio_gpu_base_conf.outputs.xres/virtio_gpu_base_conf.outputs.yres
will take precedence. In this case,
virtio_gpu_base_conf.outputs.xres/virtio_gpu_base_conf.outputs.yres
must be non-zero.

Signed-off-by: Andrew Keesler <ankees...@google.com>
---
 hw/display/virtio-gpu-base.c | 12 ++++++++++++
 qapi/virtio.json             |  6 +++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 7269477a1c..1fc879cc93 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -206,6 +206,10 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
                        node->value->name, EDID_NAME_MAX_LENGTH);
             return false;
         }
+        if (node->value && !(node->value->xres && node->value->yres)) {
+            error_setg(errp, "invalid resolution == 0");
+            return false;
+        }
     }
 
     if (virtio_gpu_virgl_enabled(g->conf)) {
@@ -233,6 +237,14 @@ 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) {
+        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 =
diff --git a/qapi/virtio.json b/qapi/virtio.json
index 9d652fe4a8..36581690c7 100644
--- a/qapi/virtio.json
+++ b/qapi/virtio.json
@@ -970,11 +970,15 @@
 #
 # @name: the name of the output
 #
+# @xres: horizontal resolution of the output in pixels
+#
+# @yres: vertical resolution of the output in pixels
+#
 # Since: 10.1
 ##
 
 { 'struct': 'VirtIOGPUOutput',
-  'data': { 'name': 'str' } }
+  'data': { 'name': 'str', 'xres': 'uint16', 'yres': 'uint16' } }
 
 ##
 # @DummyVirtioForceArrays:
-- 
2.50.0.727.gbf7dc18ff4-goog


Reply via email to