xf86-video-intel: Branch 'dri2-swapbuffers' - src/drmmode_display.c
Jesse Barnes
jbarnes at kemper.freedesktop.org
Tue Jun 2 05:30:32 PDT 2009
src/drmmode_display.c | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
New commits:
commit a74249f465cd098d029a3b1e84c49d8ca753e896
Author: Jesse Barnes <jbarnes at jbarnes-x200.(none)>
Date: Tue Jun 2 13:30:01 2009 +0100
Initial hack for new page flip API
Uses the new flip API and blocks for completion.
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index aeb9af5..d5adf99 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -30,6 +30,7 @@
#endif
#include <errno.h>
+#include <poll.h>
#include "xorgVersion.h"
@@ -905,7 +906,9 @@ drmmode_do_pageflip(DrawablePtr pDraw, dri_bo *new_front, dri_bo *old_front)
drmmode_ptr drmmode = drmmode_crtc->drmmode;
unsigned int pitch = pScrn->displayWidth * pI830->cpp;
int i, old_fb_id;
- unsigned int crtc_ids[2], crtc_count = 0;
+ unsigned int crtc_id;
+ struct pollfd drmpoll;
+ drmEventContext handler = { .page_flip_handler = NULL };
/*
* Create a new handle for the back buffer
@@ -916,8 +919,15 @@ drmmode_do_pageflip(DrawablePtr pDraw, dri_bo *new_front, dri_bo *old_front)
new_front->handle, &drmmode->fb_id))
goto error_out;
- /* Queue flips on all enabled CRTCs */
- /* FIXME: cloned configs? */
+ /*
+ * Queue flips on all enabled CRTCs
+ * Note that if/when we get per-CRTC buffers, we'll have to update this.
+ * Right now it assumes a single shared fb across all CRTCs, with the
+ * kernel fixing up the offset of each CRTC as necessary.
+ *
+ * Also, flips queued on disabled or incorrectly configured displays
+ * may never complete; this is a configuration error.
+ */
for (i = 0; i < config->num_crtc; i++) {
xf86CrtcPtr crtc = config->crtc[i];
@@ -925,11 +935,26 @@ drmmode_do_pageflip(DrawablePtr pDraw, dri_bo *new_front, dri_bo *old_front)
continue;
drmmode_crtc = crtc->driver_private;
- crtc_ids[crtc_count++] = drmmode_crtc->mode_crtc->crtc_id;
+ crtc_id = drmmode_crtc->mode_crtc->crtc_id;
+ if (drmModePageFlip(drmmode->fd, crtc_id, drmmode->fb_id, NULL)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "flip queue failed: %s\n", strerror(errno));
+ goto error_undo;
+ }
}
- if (drmModePageFlip(drmmode->fd, crtc_ids, crtc_count, drmmode->fb_id))
+retry:
+ drmpoll.fd = drmmode->fd;
+ drmpoll.events = POLLIN;
+ if (poll(&drmpoll, 1, -1) < 0) {
+ if (errno == EINTR)
+ goto retry;
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "poll failed: %s\n",
+ strerror(errno));
goto error_undo;
+ }
+
+ drmHandleEvent(drmmode->fd, &handler);
dri_bo_pin(new_front, 0);
dri_bo_unpin(new_front);
@@ -987,7 +1012,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp)
xf86InitialConfiguration(pScrn, TRUE);
/* Check for swapbuffers support */
- ret = drmModePageFlip(drmmode->fd, &bad_crtc, 1, -1);
+ ret = drmModePageFlip(drmmode->fd, bad_crtc, 1, NULL);
if (ret < 0 && errno == ENOENT) { /* bad CRTC or FB number */
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Kernel page flipping support detected, enabling\n");
More information about the xorg-commit
mailing list