[spice-vdagnet (linux) PATCH] x11-randr: do not assume each output has ncrtc=1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This was true for virtual graphic cards, but not true for
device-assigned graphic cards.
For example NVIDIA M2000 has 8.

Still we currently pick only a single crtc for each output
(but looping over them to find an active one)

Signed-off-by: Uri Lublin <uril@xxxxxxxxxx>
---
 src/vdagent/x11-randr.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index aade5ca..0c196de 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -58,6 +58,8 @@ static XRRCrtcInfo *crtc_from_id(struct vdagent_x11 *x11, int id)
 {
     int i;
 
+    if (id == 0)
+        return NULL;
     for (i = 0 ; i < x11->randr.res->ncrtc ; ++i) {
         if (id == x11->randr.res->crtcs[i]) {
             return x11->randr.crtcs[i];
@@ -650,7 +652,7 @@ static int config_size(int num_of_monitors)
 
 static VDAgentMonitorsConfig *get_current_mon_config(struct vdagent_x11 *x11)
 {
-    int i, num_of_monitors = 0;
+    int i, j, num_of_monitors = 0;
     XRRModeInfo *mode;
     XRRCrtcInfo *crtc;
     XRRScreenResources *res = x11->randr.res;
@@ -665,10 +667,15 @@ static VDAgentMonitorsConfig *get_current_mon_config(struct vdagent_x11 *x11)
     for (i = 0 ; i < res->noutput; i++) {
         if (x11->randr.outputs[i]->ncrtc == 0)
             continue; /* Monitor disabled, already zero-ed by calloc */
-        if (x11->randr.outputs[i]->ncrtc != 1)
-            goto error;
+        if (x11->randr.outputs[i]->crtc == 0)
+            continue; /* Monitor disabled */
 
-        crtc = crtc_from_id(x11, x11->randr.outputs[i]->crtcs[0]);
+        for (j=0; j<x11->randr.outputs[i]->ncrtc; j++) {
+            crtc = crtc_from_id(x11, x11->randr.outputs[i]->crtcs[j]);
+            if (crtc) {
+                break;
+            }
+        }
         if (!crtc)
             goto error;
 
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]