modesetting: Find crtc on secondary outputs as fallback instead of returning primary crtc

Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
This commit is contained in:
Łukasz Spintzyk 2020-09-18 14:31:47 +02:00 committed by Povilas Kanapickas
parent d2dce22b67
commit b923364c5e

View File

@ -104,6 +104,18 @@ static int ms_box_area(BoxPtr box)
return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1); return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
} }
static Bool rr_crtc_on(RRCrtcPtr crtc, Bool crtc_is_ms_hint)
{
if (!crtc) {
return FALSE;
}
if (crtc_is_ms_hint && crtc->devPrivate) {
return ms_crtc_on(crtc->devPrivate);
} else {
return !!crtc->mode;
}
}
Bool Bool
ms_crtc_on(xf86CrtcPtr crtc) ms_crtc_on(xf86CrtcPtr crtc)
{ {
@ -219,13 +231,11 @@ ms_covering_xf86_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms)
static RRCrtcPtr static RRCrtcPtr
ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms)
{ {
ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
RRCrtcPtr crtc, best_crtc; RRCrtcPtr crtc, best_crtc;
int coverage, best_coverage; int coverage, best_coverage;
int c; int c;
BoxRec crtc_box, cover_box; BoxRec crtc_box, cover_box;
Bool crtc_on;
best_crtc = NULL; best_crtc = NULL;
best_coverage = 0; best_coverage = 0;
@ -241,14 +251,8 @@ ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms)
for (c = 0; c < pScrPriv->numCrtcs; c++) { for (c = 0; c < pScrPriv->numCrtcs; c++) {
crtc = pScrPriv->crtcs[c]; crtc = pScrPriv->crtcs[c];
if (screen_is_ms) {
crtc_on = ms_crtc_on((xf86CrtcPtr) crtc->devPrivate);
} else {
crtc_on = !!crtc->mode;
}
/* If the CRTC is off, treat it as not covering */ /* If the CRTC is off, treat it as not covering */
if (!crtc_on) if (!rr_crtc_on(crtc, screen_is_ms))
continue; continue;
ms_randr_crtc_box(crtc, &crtc_box); ms_randr_crtc_box(crtc, &crtc_box);
@ -260,32 +264,27 @@ ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms)
} }
} }
/* Fallback to primary crtc for drawable's on secondary outputs */ return best_crtc;
if (best_crtc == NULL && !pScreen->isGPU) { }
RROutputPtr primary_output = NULL;
static RRCrtcPtr
ms_covering_randr_crtc_on_secondary(ScreenPtr pScreen, BoxPtr box)
{
if (!pScreen->isGPU) {
ScreenPtr secondary; ScreenPtr secondary;
RRCrtcPtr crtc = NULL;
if (dixPrivateKeyRegistered(rrPrivKey))
primary_output = ms_first_output(scrn->pScreen);
if (!primary_output || !primary_output->crtc)
return NULL;
crtc = primary_output->crtc;
if (!ms_crtc_on((xf86CrtcPtr) crtc->devPrivate))
return NULL;
xorg_list_for_each_entry(secondary, &pScreen->secondary_list, secondary_head) { xorg_list_for_each_entry(secondary, &pScreen->secondary_list, secondary_head) {
if (!secondary->is_output_secondary) if (!secondary->is_output_secondary)
continue; continue;
if (ms_covering_randr_crtc(secondary, box, FALSE)) { crtc = ms_covering_randr_crtc(secondary, box, FALSE);
/* The drawable is on a secondary output, return primary crtc */ if (crtc)
return crtc; return crtc;
}
} }
} }
return best_crtc; return NULL;
} }
xf86CrtcPtr xf86CrtcPtr
@ -306,6 +305,7 @@ RRCrtcPtr
ms_randr_crtc_covering_drawable(DrawablePtr pDraw) ms_randr_crtc_covering_drawable(DrawablePtr pDraw)
{ {
ScreenPtr pScreen = pDraw->pScreen; ScreenPtr pScreen = pDraw->pScreen;
RRCrtcPtr crtc = NULL;
BoxRec box; BoxRec box;
box.x1 = pDraw->x; box.x1 = pDraw->x;
@ -313,7 +313,11 @@ ms_randr_crtc_covering_drawable(DrawablePtr pDraw)
box.x2 = box.x1 + pDraw->width; box.x2 = box.x1 + pDraw->width;
box.y2 = box.y1 + pDraw->height; box.y2 = box.y1 + pDraw->height;
return ms_covering_randr_crtc(pScreen, &box, TRUE); crtc = ms_covering_randr_crtc(pScreen, &box, TRUE);
if (!crtc) {
crtc = ms_covering_randr_crtc_on_secondary(pScreen, &box);
}
return crtc;
} }
static Bool static Bool