[Intel-gfx] [PATCH] Use libdrm to lookup pipe for tear-free sync of XV

Carl Worth cworth at cworth.org
Wed Apr 29 23:43:56 CEST 2009


Previously, the code was trying to examine a driver_private field,
but those fields are only set by the userland-modesetting code so
would fail in the case of KMS. This fixes bug #21076:

[945GME] [KMS] XV_SYNC_TO_VBLANK does not prevent tearing of xv video
https://bugs.freedesktop.org/show_bug.cgi?id=21076
---

 The big question I have here is about compatibility with old
 libdrm. Presumably the driver will totally fail in that case,
 (bringing down the whole server with an unsatisfied symbol?). So
 should I be bumping the libdrm version number and doing a check for
 that version in the driver? At compile-time? Run-time?


 src/drmmode_display.c |    8 ++++++++
 src/i830.h            |    1 +
 src/i830_video.c      |   20 +++++++++++++-------
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 15ffc29..7df7b6f 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -920,3 +920,11 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp)
 
 	return TRUE;
 }
+
+int
+drmmode_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc)
+{
+	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+	return drm_intel_get_pipe_from_crtc_id (bufmgr, drmmode_crtc->mode_crtc->crtc_id);
+}
diff --git a/src/i830.h b/src/i830.h
index 207d4ec..f1657cd 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -678,6 +678,7 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen);
 void I830DRI2CloseScreen(ScreenPtr pScreen);
 
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp);
+extern int drmmode_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc);
 
 extern Bool I830AccelInit(ScreenPtr pScreen);
 extern void I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
diff --git a/src/i830_video.c b/src/i830_video.c
index 1e05e9c..64cea04 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -2495,15 +2495,21 @@ I830PutImage(ScrnInfoPtr pScrn,
         if (sync) {
 	    BoxPtr box;
 	    int y1, y2;
-            int event, pipe;
-	    I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
+            int pipe, event, load_scan_lines_pipe;
 
-	    if (intel_crtc->pipe == 0) {
+	    if (pI830->use_drm_mode)
+		pipe = drmmode_get_pipe_from_crtc_id(pI830->bufmgr, crtc);
+	    else {
+		I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
+		pipe = intel_crtc->pipe;
+	    }
+
+	    if (pipe == 0) {
 		event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
-		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
+		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
 	    } else {
 		event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
-		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
+		load_scan_lines_pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
 	    }
 
 	    box = REGION_EXTENTS(unused, clipBoxes);
@@ -2513,9 +2519,9 @@ I830PutImage(ScrnInfoPtr pScrn,
             BEGIN_BATCH(5);
 	    /* The documentation says that the LOAD_SCAN_LINES command
 	     * always comes in pairs. Don't ask me why. */
-	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
+	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
 	    OUT_BATCH((y1 << 16) | y2);
-	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
+	    OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | load_scan_lines_pipe);
 	    OUT_BATCH((y1 << 16) | y2);
             OUT_BATCH(MI_WAIT_FOR_EVENT | event);
             ADVANCE_BATCH();
-- 
1.6.2.1




More information about the Intel-gfx mailing list