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

Christophe de Dinechin dinechin at redhat.com
Wed Mar 21 09:19:54 UTC 2018


Typo in the subject line, spice-vdagent.

> On 20 Mar 2018, at 16:24, Uri Lublin <uril at redhat.com> wrote:
> 
> This was true for virtual graphic cards, but not true for
> device-assigned graphic cards.

I would rephrase without referring to the subject line, e.g.
“Unlike virtual graphic cards, device-assigned graphic cards can
have more than one crtc per output."

> 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)

Out of curiosity, what is the mapping with physical outputs? I’m asking because you said the M2000 has 8, but it has only 4 outputs.

> 
> Signed-off-by: Uri Lublin <uril at redhat.com>
> ---
> 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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



More information about the Spice-devel mailing list