[Spice-devel] [linux vdagent PATCH v2] x11-randr: do not assume each output has ncrtc=1
Victor Toso
victortoso at redhat.com
Thu Apr 5 08:29:26 UTC 2018
Hi,
On Mon, Apr 02, 2018 at 04:22:11PM +0300, Uri Lublin wrote:
> 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>
Looks fine,
Acked-by: Victor Toso <victortoso 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);
I don't mind the current version
> ---
> 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
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180405/c80a1557/attachment.sig>
More information about the Spice-devel
mailing list