[Spice-devel] [linux vdagent PATCH v2] x11-randr: do not assume each output has ncrtc=1
Uri Lublin
uril at redhat.com
Mon Apr 2 13:22:11 UTC 2018
Unlike virtual graphic cards, device-assigned graphic cards can
have more than one crtc per output.
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 at redhat.com>
---
changes since v1:
- commit log changed (Christophe)
- parenthesis + initialization (Victor)
===
BTW, I noticed that a smaller patch (not tested much)
may also work. Use ->crtc instead of looping all ->crtcs[j]
So basically
- crtc = crtc_from_id(x11, x11->randr.outputs[i]->crtcs[0]);
+ crtc = crtc_from_id(x11, x11->randr.outputs[i]->crtc);
---
src/vdagent/x11-randr.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index aade5ca..803cf73 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -58,6 +58,10 @@ 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];
@@ -652,7 +656,6 @@ static VDAgentMonitorsConfig *get_current_mon_config(struct vdagent_x11 *x11)
{
int i, num_of_monitors = 0;
XRRModeInfo *mode;
- XRRCrtcInfo *crtc;
XRRScreenResources *res = x11->randr.res;
VDAgentMonitorsConfig *mon_config;
@@ -663,12 +666,17 @@ static VDAgentMonitorsConfig *get_current_mon_config(struct vdagent_x11 *x11)
}
for (i = 0 ; i < res->noutput; i++) {
+ int j;
+ XRRCrtcInfo *crtc = NULL;
+
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; crtc == NULL && j < x11->randr.outputs[i]->ncrtc; j++) {
+ crtc = crtc_from_id(x11, x11->randr.outputs[i]->crtcs[j]);
+ }
if (!crtc)
goto error;
--
2.14.3
More information about the Spice-devel
mailing list