[cogl/wip/wayland-for-demo: 3/3] cogl-winsys-egl-kms: Fall back to SetCrtc if page-flipping fails



commit 7fb7d6be899a650f821b1aa5908fb957a4e9951d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Mar 4 13:42:32 2014 -0500

    cogl-winsys-egl-kms: Fall back to SetCrtc if page-flipping fails

 cogl/winsys/cogl-winsys-egl-kms.c |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c
index 41954ef..aedca68 100644
--- a/cogl/winsys/cogl-winsys-egl-kms.c
+++ b/cogl/winsys/cogl-winsys-egl-kms.c
@@ -50,6 +50,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
+#include <errno.h>
 
 #include "cogl-winsys-egl-kms-private.h"
 #include "cogl-winsys-egl-private.h"
@@ -564,22 +565,34 @@ flip_all_crtcs (CoglDisplay *display, CoglFlipKMS *flip, int fb_id)
   for (l = kms_display->crtcs; l; l = l->next)
     {
       CoglKmsCrtc *crtc = l->data;
-      int ret;
 
       if (crtc->count == 0)
         continue;
 
-      ret = drmModePageFlip (kms_renderer->fd,
-                             crtc->id, fb_id,
-                             DRM_MODE_PAGE_FLIP_EVENT, flip);
-
-      if (ret)
+      if (drmModePageFlip (kms_renderer->fd,
+                           crtc->id, fb_id,
+                           DRM_MODE_PAGE_FLIP_EVENT, flip) == 0)
         {
-          g_warning ("Failed to flip: %m");
-          continue;
+          flip->pending++;
+        }
+      else if (errno == EINVAL)
+        {
+          /* If page flipping fails with EINVAL, this likely means
+           * the driver doesn't have support for page flipping.
+           * Try falling back to SetCrtc. */
+          if (drmModeSetCrtc (kms_renderer->fd,
+                              crtc->id, fb_id,
+                              crtc->x, crtc->y,
+                              crtc->connectors, crtc->count,
+                              &crtc->mode) < 0)
+            {
+              g_warning ("Failed to set CRTC during page flip: %m");
+            }
+        }
+      else
+        {
+          g_warning ("Failed to page flip: %m");
         }
-
-      flip->pending++;
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]