[PATCH xf86-video-amdgpu 2/7] Only add main fb if necessary

Michel Dänzer michel at daenzer.net
Wed Jun 22 08:50:26 UTC 2016


From: Hans de Goede <hdegoede at redhat.com>

If we're doing reverse-prime; or doing rotation the main fb is not used,
and there is no reason to add it in this case.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
(Ported from xserver commit 4313122dea0df9affc280ee698e929489061ccc6)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/drmmode_display.c | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 379bbea..403a6e6 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -656,24 +656,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	drmModeModeInfo kmode;
 	uint32_t bo_handle;
 
-	if (drmmode->fb_id == 0) {
-		if (!amdgpu_bo_get_handle(info->front_buffer, &bo_handle)) {
-			ErrorF("failed to get BO handle for FB\n");
-			return FALSE;
-		}
-
-		ret = drmModeAddFB(pAMDGPUEnt->fd,
-				   pScrn->virtualX,
-				   pScrn->virtualY,
-				   pScrn->depth, pScrn->bitsPerPixel,
-				   pScrn->displayWidth * info->pixel_bytes,
-				   bo_handle, &drmmode->fb_id);
-		if (ret < 0) {
-			ErrorF("failed to add fb\n");
-			return FALSE;
-		}
-	}
-
 	saved_mode = crtc->mode;
 	saved_x = crtc->x;
 	saved_y = crtc->y;
@@ -783,6 +765,27 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 			}
 		}
 
+		if (fb_id == 0) {
+			if (!amdgpu_bo_get_handle(info->front_buffer, &bo_handle)) {
+				ErrorF("failed to get BO handle for FB\n");
+				ret = FALSE;
+				goto done;
+			}
+
+			if (drmModeAddFB(pAMDGPUEnt->fd,
+				   pScrn->virtualX,
+				   pScrn->virtualY,
+				   pScrn->depth, pScrn->bitsPerPixel,
+				   pScrn->displayWidth * info->pixel_bytes,
+				   bo_handle, &drmmode->fb_id) < 0) {
+				ErrorF("failed to add fb\n");
+				ret = FALSE;
+				goto done;
+			}
+
+			fb_id = drmmode->fb_id;
+		}
+
 		/* Wait for any pending flip to finish */
 		do {} while (drmmode_crtc->flip_pending &&
 			     drmHandleEvent(pAMDGPUEnt->fd,
-- 
2.8.1



More information about the amd-gfx mailing list