summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-09-02 15:38:32 -0500
committerDerek Foreman <derekf@osg.samsung.com>2016-09-08 13:55:24 -0500
commit0f534dc3bd12daaf7ae840c5a303a5aff0da1acf (patch)
tree76d0aedb74cf623bc53bc34bb63336db752d2e69 /src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
parentb4cbf860b9d483f7ad7a50c672a000927cb2b39f (diff)
ecore_evas_drm: Use pageflips, not vblanks, to drive animation
This should sort some timing problems.
Diffstat (limited to 'src/modules/ecore_evas/engines/drm/ecore_evas_drm.c')
-rw-r--r--src/modules/ecore_evas/engines/drm/ecore_evas_drm.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index 90a3444f37..d8709d6853 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -55,6 +55,7 @@ typedef struct _Ecore_Evas_Engine_Drm_Data
55 Ecore_Fd_Handler *hdlr; 55 Ecore_Fd_Handler *hdlr;
56 Ecore_Drm2_Device *dev; 56 Ecore_Drm2_Device *dev;
57 Ecore_Drm2_Output *output; 57 Ecore_Drm2_Output *output;
58 Eina_Bool pending : 1;
58 Eina_Bool ticking : 1; 59 Eina_Bool ticking : 1;
59} Ecore_Evas_Engine_Drm_Data; 60} Ecore_Evas_Engine_Drm_Data;
60 61
@@ -611,55 +612,36 @@ _cb_drm_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
611} 612}
612 613
613static void 614static void
614_tick_schedule(int fd, Ecore_Evas *ee)
615{
616 Ecore_Evas_Engine_Drm_Data *edata;
617
618 edata = ee->engine.data;
619 if (!edata->ticking) return;
620
621 drmVBlank vbl =
622 {
623 .request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT,
624 .request.sequence = 1,
625 .request.signal = (unsigned long)ee,
626 };
627
628 /* FIXME: On some systems this can fail, breaking ticking forever. */
629 drmWaitVBlank(fd, &vbl);
630}
631
632static void
633_cb_pageflip(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data) 615_cb_pageflip(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
634{ 616{
635 Ecore_Evas *ee; 617 Ecore_Evas *ee;
636 Ecore_Evas_Engine_Drm_Data *edata; 618 Ecore_Evas_Engine_Drm_Data *edata;
637 Ecore_Drm2_Fb *next; 619 int ret;
638 620
639 ee = data; 621 ee = data;
640 edata = ee->engine.data; 622 edata = ee->engine.data;
641 623
642 ecore_drm2_fb_flip_complete(edata->output); 624 ret = ecore_drm2_fb_flip_complete(edata->output);
625
626 edata->pending = EINA_FALSE;
643 627
644 next = ecore_drm2_output_next_fb_get(edata->output); 628 if (edata->ticking)
645 if (next)
646 { 629 {
647 ecore_drm2_output_next_fb_set(edata->output, NULL); 630 ecore_evas_animator_tick(ee, NULL);
648 ecore_drm2_fb_flip(next, edata->output); 631 ecore_drm2_fb_flip(NULL, edata->output);
649 } 632 }
633 else if (ret) ecore_drm2_fb_flip(NULL, edata->output);
650} 634}
651 635
652static void 636static void
653_cb_vblank(int fd, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data) 637_drm_evas_changed(Ecore_Evas *ee, Eina_Bool changed)
654{ 638{
655 Ecore_Evas *ee;
656 Ecore_Evas_Engine_Drm_Data *edata; 639 Ecore_Evas_Engine_Drm_Data *edata;
657 640
658 ee = data; 641 if (changed) return;
659 edata = ee->engine.data;
660 642
661 ecore_evas_animator_tick(ee, NULL); 643 edata = ee->engine.data;
662 if (edata->ticking) _tick_schedule(fd, ee); 644 if (edata->ticking && !edata->pending) ecore_drm2_fb_flip(NULL, edata->output);
663} 645}
664 646
665static void 647static void
@@ -669,7 +651,7 @@ _drm_animator_register(Ecore_Evas *ee)
669 651
670 edata = ee->engine.data; 652 edata = ee->engine.data;
671 edata->ticking = EINA_TRUE; 653 edata->ticking = EINA_TRUE;
672 _tick_schedule(edata->fd, ee); 654 if (!edata->pending) ecore_drm2_fb_flip(NULL, edata->output);
673} 655}
674 656
675static void 657static void
@@ -760,7 +742,7 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func =
760 _drm_animator_register, // animator_register 742 _drm_animator_register, // animator_register
761 _drm_animator_unregister, // animator_unregister 743 _drm_animator_unregister, // animator_unregister
762 744
763 NULL // evas_changed 745 _drm_evas_changed, // evas_changed
764}; 746};
765 747
766static Ecore_Evas * 748static Ecore_Evas *
@@ -906,7 +888,6 @@ _ecore_evas_new_internal(const char *device, int x, int y, int w, int h, Eina_Bo
906 /* setup vblank handler */ 888 /* setup vblank handler */
907 memset(&edata->ctx, 0, sizeof(edata->ctx)); 889 memset(&edata->ctx, 0, sizeof(edata->ctx));
908 edata->ctx.version = DRM_EVENT_CONTEXT_VERSION; 890 edata->ctx.version = DRM_EVENT_CONTEXT_VERSION;
909 edata->ctx.vblank_handler = _cb_vblank;
910 edata->ctx.page_flip_handler = _cb_pageflip; 891 edata->ctx.page_flip_handler = _cb_pageflip;
911 892
912 edata->hdlr = 893 edata->hdlr =