diff -u xorg-server-1.20.11/debian/changelog xorg-server-1.20.11/debian/changelog --- xorg-server-1.20.11/debian/changelog +++ xorg-server-1.20.11/debian/changelog @@ -1,3 +1,11 @@ +xorg-server (2:1.20.11-1ubuntu2) hirsute; urgency=medium + + * 686-sync-present-to-slave-outputs.patch: Resolve issue of slow FPS with + external DisplayLink display. Patch cherry-picked from upstream. + - LP: #1875015 + + -- Dave Walker (Daviey) Wed, 30 Jun 2021 13:58:07 +0100 + xorg-server (2:1.20.11-1ubuntu1) hirsute; urgency=medium * Merge from Debian. diff -u xorg-server-1.20.11/debian/patches/series xorg-server-1.20.11/debian/patches/series --- xorg-server-1.20.11/debian/patches/series +++ xorg-server-1.20.11/debian/patches/series @@ -32,0 +33 @@ +686-sync-present-to-slave-outputs.patch only in patch2: unchanged: --- xorg-server-1.20.11.orig/debian/patches/686-sync-present-to-slave-outputs.patch +++ xorg-server-1.20.11/debian/patches/686-sync-present-to-slave-outputs.patch @@ -0,0 +1,813 @@ +From 464cbee1c625d60ac9e18b7f4e3d53bc83b0d585 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C5=81ukasz=20Spintzyk?= +Date: Fri, 18 Sep 2020 14:29:25 +0200 +Subject: [PATCH 1/6] modesetting: Initialize present extension despite glamor + is disabled +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Łukasz Spintzyk +(cherry picked from commit d03c0de77ba36bb5221d00ac84dcdd6aae0df453) +--- + hw/xfree86/drivers/modesetting/driver.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index 8ca3e897a..ec4189a2c 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -1747,10 +1747,6 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) + "Failed to initialize the DRI2 extension.\n"); + } + +- if (!(ms->drmmode.present_enable = ms_present_screen_init(pScreen))) { +- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, +- "Failed to initialize the Present extension.\n"); +- } + /* enable reverse prime if we are a GPU screen, and accelerated, and not + * i915, evdi or udl. i915 is happy scanning out from sysmem. + * evdi and udl are virtual drivers scanning out from sysmem +@@ -1781,6 +1777,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) + } + } + #endif ++ if (!(ms->drmmode.present_enable = ms_present_screen_init(pScreen))) { ++ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, ++ "Failed to initialize the Present extension.\n"); ++ } ++ + + pScrn->vtSema = TRUE; + +-- +GitLab + + +From 31544e68e605f0595e700bf4ce468b16e7b195ac Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C5=81ukasz=20Spintzyk?= +Date: Fri, 18 Sep 2020 14:31:25 +0200 +Subject: [PATCH 2/6] present: Use crtc's screen present operation for syncing +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Łukasz Spintzyk +(cherry picked from commit 908deb0895f9fe345d70be933d251ea10511d30a) +--- + present/present_scmd.c | 13 +++++++++++-- + present/present_vblank.c | 4 ++++ + 2 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/present/present_scmd.c b/present/present_scmd.c +index 3e3ae3477..72a4026ea 100644 +--- a/present/present_scmd.c ++++ b/present/present_scmd.c +@@ -82,6 +82,9 @@ present_check_flip(RRCrtcPtr crtc, + WindowPtr root = screen->root; + present_screen_priv_ptr screen_priv = present_screen_priv(screen); + ++ if (crtc) { ++ screen_priv = present_screen_priv(crtc->pScreen); ++ } + if (reason) + *reason = PRESENT_FLIP_REASON_UNKNOWN; + +@@ -181,11 +184,14 @@ static int + present_get_ust_msc(ScreenPtr screen, RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc) + { + present_screen_priv_ptr screen_priv = present_screen_priv(screen); ++ present_screen_priv_ptr crtc_screen_priv = screen_priv; ++ if (crtc) ++ crtc_screen_priv = present_screen_priv(crtc->pScreen); + + if (crtc == NULL) + return present_fake_get_ust_msc(screen, ust, msc); + else +- return (*screen_priv->info->get_ust_msc)(crtc, ust, msc); ++ return (*crtc_screen_priv->info->get_ust_msc)(crtc, ust, msc); + } + + static void +@@ -216,7 +222,7 @@ present_queue_vblank(ScreenPtr screen, + ret = present_fake_queue_vblank(screen, event_id, msc); + else + { +- present_screen_priv_ptr screen_priv = present_screen_priv(screen); ++ present_screen_priv_ptr screen_priv = present_screen_priv(crtc->pScreen); + ret = (*screen_priv->info->queue_vblank) (crtc, event_id, msc); + } + return ret; +@@ -541,6 +547,9 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc) + WindowPtr window = vblank->window; + ScreenPtr screen = window->drawable.pScreen; + present_screen_priv_ptr screen_priv = present_screen_priv(screen); ++ if (vblank && vblank->crtc) { ++ screen_priv=present_screen_priv(vblank->crtc->pScreen); ++ } + + if (present_execute_wait(vblank, crtc_msc)) + return; +diff --git a/present/present_vblank.c b/present/present_vblank.c +index af14fe134..b9f91c493 100644 +--- a/present/present_vblank.c ++++ b/present/present_vblank.c +@@ -66,6 +66,10 @@ present_vblank_create(WindowPtr window, + present_vblank_ptr vblank; + PresentFlipReason reason = PRESENT_FLIP_REASON_UNKNOWN; + ++ if (target_crtc) { ++ screen_priv = present_screen_priv(target_crtc->pScreen); ++ } ++ + vblank = calloc (1, sizeof (present_vblank_rec)); + if (!vblank) + return NULL; +-- +GitLab + + +From c7a2da7b994cdf829d805944c80f9fefd9246109 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C5=81ukasz=20Spintzyk?= +Date: Fri, 18 Sep 2020 14:31:34 +0200 +Subject: [PATCH 3/6] present: fix msc offset calculation in screen mode +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Instead of getting the current msc value from the window crtc, +which not exist take the last saved msc value saved in +the window_priv struct + +Signed-off-by: Łukasz Spintzyk +(cherry picked from commit d2dce22b6775c772282ac2c0e224ef9685ab34fa) +--- + configure.ac | 2 +- + hw/dmx/dmxextension.c | 3 --- + hw/dmx/dmxinit.c | 2 -- + present/present_scmd.c | 5 +++-- + randr/randrstr.h | 5 +++++ + randr/rrcrtc.c | 43 +++++++++++++++++++++++++++++++++++++++++- + randr/rrprovider.c | 2 +- + 7 files changed, 52 insertions(+), 10 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 7ba6d05ba..91fc5fdbf 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2236,7 +2236,7 @@ if test "x$DMX" = xyes; then + fi + DMX_INCLUDES="$XEXT_INC $RENDER_INC $RECORD_INC" + XDMX_CFLAGS="$DMXMODULES_CFLAGS" +- XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $RANDR_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB" ++ XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $RANDR_LIB $RENDER_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB" + XDMX_SYS_LIBS="$DMXMODULES_LIBS" + AC_SUBST([XDMX_CFLAGS]) + AC_SUBST([XDMX_LIBS]) +diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c +index 4f5ca7252..e5ec7fa54 100644 +--- a/hw/dmx/dmxextension.c ++++ b/hw/dmx/dmxextension.c +@@ -68,9 +68,6 @@ + * _any_ header files. */ + extern FontPtr defaultFont; + +-/* Hack to get Present to build (present requires RandR) */ +-RESTYPE RRCrtcType; +- + /** This routine provides information to the DMX protocol extension + * about a particular screen. */ + Bool +diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c +index ddb331090..eae40413c 100644 +--- a/hw/dmx/dmxinit.c ++++ b/hw/dmx/dmxinit.c +@@ -109,8 +109,6 @@ Bool dmxGLXSyncSwap = FALSE; + Bool dmxGLXFinishSwap = FALSE; + #endif + +-RESTYPE RRProviderType = 0; +- + Bool dmxIgnoreBadFontPaths = FALSE; + + Bool dmxAddRemoveScreens = FALSE; +diff --git a/present/present_scmd.c b/present/present_scmd.c +index 72a4026ea..3c68e690b 100644 +--- a/present/present_scmd.c ++++ b/present/present_scmd.c +@@ -239,11 +239,12 @@ present_window_to_crtc_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t window_msc + if (window_priv->crtc == PresentCrtcNeverSet) { + window_priv->msc_offset = 0; + } else { +- /* The old CRTC may have been turned off, in which case ++ /* The old CRTC may have been turned off or be destroyed, in which case + * we'll just use whatever previous MSC we'd seen from this CRTC + */ + +- if (present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success) ++ if (!RRCrtcExists(window->drawable.pScreen, window_priv->crtc) || ++ present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success) + old_msc = window_priv->msc; + + window_priv->msc_offset += new_msc - old_msc; +diff --git a/randr/randrstr.h b/randr/randrstr.h +index 2cede92e3..0b95d6e25 100644 +--- a/randr/randrstr.h ++++ b/randr/randrstr.h +@@ -642,6 +642,11 @@ extern _X_EXPORT void + */ + extern _X_EXPORT RRCrtcPtr RRCrtcCreate(ScreenPtr pScreen, void *devPrivate); + ++/* ++ * Tests if findCrtc belongs to pScreen or slave screens ++ */ ++extern _X_EXPORT Bool RRCrtcExists(ScreenPtr pScreen, RRCrtcPtr findCrtc); ++ + /* + * Set the allowed rotations on a CRTC + */ +diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c +index 7839a0eda..027a31a9e 100644 +--- a/randr/rrcrtc.c ++++ b/randr/rrcrtc.c +@@ -27,7 +27,7 @@ + + #include + +-RESTYPE RRCrtcType; ++RESTYPE RRCrtcType = 0; + + /* + * Notify the CRTC of some change +@@ -960,6 +960,47 @@ RRCrtcGammaGet(RRCrtcPtr crtc) + return ret; + } + ++static Bool RRCrtcInScreen(ScreenPtr pScreen, RRCrtcPtr findCrtc) ++{ ++ rrScrPrivPtr pScrPriv; ++ int c; ++ ++ if (pScreen == NULL) ++ return FALSE; ++ ++ if (findCrtc == NULL) ++ return FALSE; ++ ++ if (!dixPrivateKeyRegistered(rrPrivKey)) ++ return FALSE; ++ ++ pScrPriv = rrGetScrPriv(pScreen); ++ for (c = 0; c < pScrPriv->numCrtcs; c++) { ++ if (pScrPriv->crtcs[c] == findCrtc) ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ ++Bool RRCrtcExists(ScreenPtr pScreen, RRCrtcPtr findCrtc) ++{ ++ ScreenPtr slave= NULL; ++ ++ if (RRCrtcInScreen(pScreen, findCrtc)) ++ return TRUE; ++ ++ xorg_list_for_each_entry(slave, &pScreen->slave_list, slave_head) { ++ if (!slave->is_output_slave) ++ continue; ++ if (RRCrtcInScreen(slave, findCrtc)) ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ ++ + /* + * Notify the extension that the Crtc gamma has been changed + * The driver calls this whenever it has changed the gamma values +diff --git a/randr/rrprovider.c b/randr/rrprovider.c +index c430f7477..d90477235 100644 +--- a/randr/rrprovider.c ++++ b/randr/rrprovider.c +@@ -27,7 +27,7 @@ + + #include + +-RESTYPE RRProviderType; ++RESTYPE RRProviderType = 0; + + /* + * Initialize provider type error value +-- +GitLab + + +From 52eb801d048f63952ca48487d86ba089dfcbe131 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C5=81ukasz=20Spintzyk?= +Date: Fri, 18 Sep 2020 14:31:47 +0200 +Subject: [PATCH 4/6] modesetting: Find crtc on slave outputs as fallback + instead of returning primary crtc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Łukasz Spintzyk +(cherry picked from commit b923364c5ec8251e81b4aa5fd451d9d7bb038009) +--- + hw/xfree86/drivers/modesetting/vblank.c | 56 +++++++++++++------------ + 1 file changed, 30 insertions(+), 26 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c +index 50d2fd3a4..acff6b644 100644 +--- a/hw/xfree86/drivers/modesetting/vblank.c ++++ b/hw/xfree86/drivers/modesetting/vblank.c +@@ -104,6 +104,18 @@ static int ms_box_area(BoxPtr box) + 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 + ms_crtc_on(xf86CrtcPtr crtc) + { +@@ -219,13 +231,11 @@ ms_covering_xf86_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) + static RRCrtcPtr + ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) + { +- ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen); + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc, best_crtc; + int coverage, best_coverage; + int c; + BoxRec crtc_box, cover_box; +- Bool crtc_on; + + best_crtc = NULL; + 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++) { + 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 (!crtc_on) ++ if (!rr_crtc_on(crtc, screen_is_ms)) + continue; + + 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 slave outputs */ +- if (best_crtc == NULL && !pScreen->isGPU) { +- RROutputPtr primary_output = NULL; +- ScreenPtr slave; +- +- if (dixPrivateKeyRegistered(rrPrivKey)) +- primary_output = ms_first_output(scrn->pScreen); +- if (!primary_output || !primary_output->crtc) +- return NULL; ++ return best_crtc; ++} + +- crtc = primary_output->crtc; +- if (!ms_crtc_on((xf86CrtcPtr) crtc->devPrivate)) +- return NULL; ++static RRCrtcPtr ++ms_covering_randr_crtc_on_slave(ScreenPtr pScreen, BoxPtr box) ++{ ++ if (!pScreen->isGPU) { ++ ScreenPtr slave; ++ RRCrtcPtr crtc = NULL; + + xorg_list_for_each_entry(slave, &pScreen->slave_list, slave_head) { + if (!slave->is_output_slave) + continue; + +- if (ms_covering_randr_crtc(slave, box, FALSE)) { +- /* The drawable is on a slave output, return primary crtc */ ++ crtc = ms_covering_randr_crtc(slave, box, FALSE); ++ if (crtc) + return crtc; +- } + } + } + +- return best_crtc; ++ return NULL; + } + + xf86CrtcPtr +@@ -306,6 +305,7 @@ RRCrtcPtr + ms_randr_crtc_covering_drawable(DrawablePtr pDraw) + { + ScreenPtr pScreen = pDraw->pScreen; ++ RRCrtcPtr crtc = NULL; + BoxRec box; + + box.x1 = pDraw->x; +@@ -313,7 +313,11 @@ ms_randr_crtc_covering_drawable(DrawablePtr pDraw) + box.x2 = box.x1 + pDraw->width; + 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_slave(pScreen, &box); ++ } ++ return crtc; + } + + static Bool +-- +GitLab + + +From 321964443be6b6daae0f7c1097a34106782ae338 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C5=81ukasz=20Spintzyk?= +Date: Fri, 18 Sep 2020 14:31:53 +0200 +Subject: [PATCH 5/6] modesetting: remove unnecessary ms_covering_xf86_crtc dup + of ms_covering_randr_crtc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Łukasz Spintzyk +(cherry picked from commit c282be503e267afdd050df837d4cf61e0e7287b7) +--- + hw/xfree86/drivers/modesetting/vblank.c | 119 ++---------------------- + 1 file changed, 6 insertions(+), 113 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c +index acff6b644..7ad07dfd6 100644 +--- a/hw/xfree86/drivers/modesetting/vblank.c ++++ b/hw/xfree86/drivers/modesetting/vblank.c +@@ -64,19 +64,6 @@ static void ms_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b) + dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0; + } + +-static void ms_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box) +-{ +- if (crtc->enabled) { +- crtc_box->x1 = crtc->x; +- crtc_box->x2 = +- crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation); +- crtc_box->y1 = crtc->y; +- crtc_box->y2 = +- crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation); +- } else +- crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0; +-} +- + static void ms_randr_crtc_box(RRCrtcPtr crtc, BoxPtr crtc_box) + { + if (crtc->mode) { +@@ -124,110 +111,11 @@ ms_crtc_on(xf86CrtcPtr crtc) + return crtc->enabled && drmmode_crtc->dpms_mode == DPMSModeOn; + } + +-/* +- * Return the first output which is connected to an active CRTC on this screen. +- * +- * RRFirstOutput() will return an output from a slave screen if it is primary, +- * which is not the behavior that ms_covering_crtc() wants. +- */ +- +-static RROutputPtr ms_first_output(ScreenPtr pScreen) +-{ +- rrScrPriv(pScreen); +- RROutputPtr output; +- int i, j; +- +- if (!pScrPriv) +- return NULL; +- +- if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc && +- (pScrPriv->primaryOutput->pScreen == pScreen)) { +- return pScrPriv->primaryOutput; +- } +- +- for (i = 0; i < pScrPriv->numCrtcs; i++) { +- RRCrtcPtr crtc = pScrPriv->crtcs[i]; +- +- for (j = 0; j < pScrPriv->numOutputs; j++) { +- output = pScrPriv->outputs[j]; +- if (output->crtc == crtc) +- return output; +- } +- } +- return NULL; +-} + + /* + * Return the crtc covering 'box'. If two crtcs cover a portion of + * 'box', then prefer the crtc with greater coverage. + */ +- +-static xf86CrtcPtr +-ms_covering_xf86_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) +-{ +- ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen); +- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); +- xf86CrtcPtr crtc, best_crtc; +- int coverage, best_coverage; +- int c; +- BoxRec crtc_box, cover_box; +- Bool crtc_on; +- +- best_crtc = NULL; +- best_coverage = 0; +- +- if (!xf86_config) +- return NULL; +- +- for (c = 0; c < xf86_config->num_crtc; c++) { +- crtc = xf86_config->crtc[c]; +- +- if (screen_is_ms) +- crtc_on = ms_crtc_on(crtc); +- else +- crtc_on = crtc->enabled; +- +- /* If the CRTC is off, treat it as not covering */ +- if (!crtc_on) +- continue; +- +- ms_crtc_box(crtc, &crtc_box); +- ms_box_intersect(&cover_box, &crtc_box, box); +- coverage = ms_box_area(&cover_box); +- if (coverage > best_coverage) { +- best_crtc = crtc; +- best_coverage = coverage; +- } +- } +- +- /* Fallback to primary crtc for drawable's on slave outputs */ +- if (best_crtc == NULL && !pScreen->isGPU) { +- RROutputPtr primary_output = NULL; +- ScreenPtr slave; +- +- if (dixPrivateKeyRegistered(rrPrivKey)) +- primary_output = ms_first_output(scrn->pScreen); +- if (!primary_output || !primary_output->crtc) +- return NULL; +- +- crtc = primary_output->crtc->devPrivate; +- if (!ms_crtc_on(crtc)) +- return NULL; +- +- xorg_list_for_each_entry(slave, &pScreen->slave_list, slave_head) { +- if (!slave->is_output_slave) +- continue; +- +- if (ms_covering_xf86_crtc(slave, box, FALSE)) { +- /* The drawable is on a slave output, return primary crtc */ +- return crtc; +- } +- } +- } +- +- return best_crtc; +-} +- + static RRCrtcPtr + ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) + { +@@ -291,6 +179,7 @@ xf86CrtcPtr + ms_dri2_crtc_covering_drawable(DrawablePtr pDraw) + { + ScreenPtr pScreen = pDraw->pScreen; ++ RRCrtcPtr crtc = NULL; + BoxRec box; + + box.x1 = pDraw->x; +@@ -298,7 +187,11 @@ ms_dri2_crtc_covering_drawable(DrawablePtr pDraw) + box.x2 = box.x1 + pDraw->width; + box.y2 = box.y1 + pDraw->height; + +- return ms_covering_xf86_crtc(pScreen, &box, TRUE); ++ crtc = ms_covering_randr_crtc(pScreen, &box, TRUE); ++ if (crtc) { ++ return crtc->devPrivate; ++ } ++ return NULL; + } + + RRCrtcPtr +-- +GitLab + + +From 0086535e7a331f81823a0f4e578bc3346ee1c312 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C5=81ukasz=20Spintzyk?= +Date: Fri, 18 Sep 2020 14:32:01 +0200 +Subject: [PATCH 6/6] modesetting: Remove few common functions from ms + namespace +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +A lot of that code is the same as in xf86-amdgpu and xf86-nouveau drivers. By removing that functions from +ms namespace we can move that code to common implementation. + +Signed-off-by: Łukasz Spintzyk +(cherry picked from commit 5be3b80b8d084ca5721be8791910d5827d1b6014) +--- + hw/xfree86/drivers/modesetting/dri2.c | 2 +- + hw/xfree86/drivers/modesetting/driver.h | 2 +- + hw/xfree86/drivers/modesetting/pageflip.c | 2 +- + hw/xfree86/drivers/modesetting/present.c | 2 +- + hw/xfree86/drivers/modesetting/vblank.c | 34 +++++++++++------------ + 5 files changed, 21 insertions(+), 21 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c +index c0799896c..d89904b53 100644 +--- a/hw/xfree86/drivers/modesetting/dri2.c ++++ b/hw/xfree86/drivers/modesetting/dri2.c +@@ -549,7 +549,7 @@ can_exchange(ScrnInfoPtr scrn, DrawablePtr draw, + return FALSE; + #endif + +- if (ms_crtc_on(config->crtc[i])) ++ if (xf86_crtc_on(config->crtc[i])) + num_crtcs_on++; + } + +diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h +index f2e7889db..a99f37871 100644 +--- a/hw/xfree86/drivers/modesetting/driver.h ++++ b/hw/xfree86/drivers/modesetting/driver.h +@@ -146,7 +146,7 @@ void ms_drm_abort(ScrnInfoPtr scrn, + void *match_data); + void ms_drm_abort_seq(ScrnInfoPtr scrn, uint32_t seq); + +-Bool ms_crtc_on(xf86CrtcPtr crtc); ++Bool xf86_crtc_on(xf86CrtcPtr crtc); + + xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw); + RRCrtcPtr ms_randr_crtc_covering_drawable(DrawablePtr pDraw); +diff --git a/hw/xfree86/drivers/modesetting/pageflip.c b/hw/xfree86/drivers/modesetting/pageflip.c +index 9667f132d..1d54816e2 100644 +--- a/hw/xfree86/drivers/modesetting/pageflip.c ++++ b/hw/xfree86/drivers/modesetting/pageflip.c +@@ -301,7 +301,7 @@ ms_do_pageflip(ScreenPtr screen, + for (i = 0; i < config->num_crtc; i++) { + xf86CrtcPtr crtc = config->crtc[i]; + +- if (!ms_crtc_on(crtc)) ++ if (!xf86_crtc_on(crtc)) + continue; + + if (!queue_flip_on_crtc(screen, crtc, flipdata, +diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c +index 009a0790c..02671c594 100644 +--- a/hw/xfree86/drivers/modesetting/present.c ++++ b/hw/xfree86/drivers/modesetting/present.c +@@ -244,7 +244,7 @@ ms_present_check_unflip(RRCrtcPtr crtc, + if (drmmode_crtc->rotate_bo.gbm) + return FALSE; + +- if (ms_crtc_on(config->crtc[i])) ++ if (xf86_crtc_on(config->crtc[i])) + num_crtcs_on++; + } + +diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c +index 7ad07dfd6..bd203efc4 100644 +--- a/hw/xfree86/drivers/modesetting/vblank.c ++++ b/hw/xfree86/drivers/modesetting/vblank.c +@@ -49,7 +49,7 @@ + static struct xorg_list ms_drm_queue; + static uint32_t ms_drm_seq; + +-static void ms_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b) ++static void box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b) + { + dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1; + dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2; +@@ -64,7 +64,7 @@ static void ms_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b) + dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0; + } + +-static void ms_randr_crtc_box(RRCrtcPtr crtc, BoxPtr crtc_box) ++static void rr_crtc_box(RRCrtcPtr crtc, BoxPtr crtc_box) + { + if (crtc->mode) { + crtc_box->x1 = crtc->x; +@@ -86,25 +86,25 @@ static void ms_randr_crtc_box(RRCrtcPtr crtc, BoxPtr crtc_box) + crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0; + } + +-static int ms_box_area(BoxPtr box) ++static int box_area(BoxPtr box) + { + return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1); + } + +-static Bool rr_crtc_on(RRCrtcPtr crtc, Bool crtc_is_ms_hint) ++static Bool rr_crtc_on(RRCrtcPtr crtc, Bool crtc_is_xf86_hint) + { + if (!crtc) { + return FALSE; + } +- if (crtc_is_ms_hint && crtc->devPrivate) { +- return ms_crtc_on(crtc->devPrivate); ++ if (crtc_is_xf86_hint && crtc->devPrivate) { ++ return xf86_crtc_on(crtc->devPrivate); + } else { + return !!crtc->mode; + } + } + + Bool +-ms_crtc_on(xf86CrtcPtr crtc) ++xf86_crtc_on(xf86CrtcPtr crtc) + { + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + +@@ -117,7 +117,7 @@ ms_crtc_on(xf86CrtcPtr crtc) + * 'box', then prefer the crtc with greater coverage. + */ + static RRCrtcPtr +-ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) ++rr_crtc_covering_box(ScreenPtr pScreen, BoxPtr box, Bool screen_is_xf86_hint) + { + rrScrPrivPtr pScrPriv; + RRCrtcPtr crtc, best_crtc; +@@ -140,12 +140,12 @@ ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) + crtc = pScrPriv->crtcs[c]; + + /* If the CRTC is off, treat it as not covering */ +- if (!rr_crtc_on(crtc, screen_is_ms)) ++ if (!rr_crtc_on(crtc, screen_is_xf86_hint)) + continue; + +- ms_randr_crtc_box(crtc, &crtc_box); +- ms_box_intersect(&cover_box, &crtc_box, box); +- coverage = ms_box_area(&cover_box); ++ rr_crtc_box(crtc, &crtc_box); ++ box_intersect(&cover_box, &crtc_box, box); ++ coverage = box_area(&cover_box); + if (coverage > best_coverage) { + best_crtc = crtc; + best_coverage = coverage; +@@ -156,7 +156,7 @@ ms_covering_randr_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) + } + + static RRCrtcPtr +-ms_covering_randr_crtc_on_slave(ScreenPtr pScreen, BoxPtr box) ++rr_crtc_covering_box_on_slave(ScreenPtr pScreen, BoxPtr box) + { + if (!pScreen->isGPU) { + ScreenPtr slave; +@@ -166,7 +166,7 @@ ms_covering_randr_crtc_on_slave(ScreenPtr pScreen, BoxPtr box) + if (!slave->is_output_slave) + continue; + +- crtc = ms_covering_randr_crtc(slave, box, FALSE); ++ crtc = rr_crtc_covering_box(slave, box, FALSE); + if (crtc) + return crtc; + } +@@ -187,7 +187,7 @@ ms_dri2_crtc_covering_drawable(DrawablePtr pDraw) + box.x2 = box.x1 + pDraw->width; + box.y2 = box.y1 + pDraw->height; + +- crtc = ms_covering_randr_crtc(pScreen, &box, TRUE); ++ crtc = rr_crtc_covering_box(pScreen, &box, TRUE); + if (crtc) { + return crtc->devPrivate; + } +@@ -206,9 +206,9 @@ ms_randr_crtc_covering_drawable(DrawablePtr pDraw) + box.x2 = box.x1 + pDraw->width; + box.y2 = box.y1 + pDraw->height; + +- crtc = ms_covering_randr_crtc(pScreen, &box, TRUE); ++ crtc = rr_crtc_covering_box(pScreen, &box, TRUE); + if (!crtc) { +- crtc = ms_covering_randr_crtc_on_slave(pScreen, &box); ++ crtc = rr_crtc_covering_box_on_slave(pScreen, &box); + } + return crtc; + } +-- +GitLab +