kmscube: pageflip for all displays in modeset
authorSubhajit Paul <subhajit_paul@ti.com>
Tue, 17 Oct 2017 12:08:34 +0000 (12:08 +0000)
committerKarthik Ramanan <a0393906@ti.com>
Mon, 30 Oct 2017 06:13:42 +0000 (11:43 +0530)
When kmscube is launched on all displays using kmscube -a,
drmModeSetCrtc is called on all CRTCs. It is required to
call drmModePageFlip for all the CRTCs as well.

Signed-off-by: Subhajit Paul <subhajit_paul@ti.com>
kmscube.c

index e8c90d4b1f0969c6686fa2312fb7e58e9de50805..f0b1d6e4a3b9e17585c2fa571e85a3f0838dcf75 100644 (file)
--- a/kmscube.c
+++ b/kmscube.c
@@ -826,7 +826,7 @@ static void page_flip_handler(int fd, unsigned int frame,
                  unsigned int sec, unsigned int usec, void *data)
 {
        int *waiting_for_flip = data;
-       *waiting_for_flip = 0;
+       *waiting_for_flip = *waiting_for_flip - 1;
 }
 
 void print_usage()
@@ -955,7 +955,8 @@ int main(int argc, char *argv[])
 
        while (frame_count != 0) {
                struct gbm_bo *next_bo;
-               int waiting_for_flip = 1;
+               int waiting_for_flip;
+               int cc;
 
                draw(i++);
 
@@ -968,11 +969,24 @@ int main(int argc, char *argv[])
                 * hw composition
                 */
 
-               ret = drmModePageFlip(drm.fd, drm.crtc_id[DISP_ID], fb->fb_id,
-                               DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip);
-               if (ret) {
-                       printf("failed to queue page flip: %s\n", strerror(errno));
-                       return -1;
+               if (all_display) {
+                       for (cc=0;cc<drm.ndisp; cc++) {
+                               ret = drmModePageFlip(drm.fd, drm.crtc_id[cc], fb->fb_id,
+                                       DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip);
+                               if (ret) {
+                                       printf("failed to queue page flip: %s\n", strerror(errno));
+                                       return -1;
+                               }
+                       }
+                       waiting_for_flip = drm.ndisp;
+               } else {
+                       ret = drmModePageFlip(drm.fd, drm.crtc_id[DISP_ID], fb->fb_id,
+                                       DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip);
+                       if (ret) {
+                               printf("failed to queue page flip: %s\n", strerror(errno));
+                               return -1;
+                       }
+                       waiting_for_flip = 1;
                }
 
                while (waiting_for_flip) {