add PageFlipHandler
authorTomi Valkeinen <tomi.valkeinen@iki.fi>
Sat, 3 Oct 2015 18:13:06 +0000 (21:13 +0300)
committerTomi Valkeinen <tomi.valkeinen@iki.fi>
Sat, 3 Oct 2015 19:41:49 +0000 (22:41 +0300)
libkms++/atomicreq.h
libkms++/card.cpp
libkms++/card.h
libkms++/crtc.h
libkms++/decls.h
libkms++/kms++.h
libkms++/pagefliphandler.h [new file with mode: 0644]

index 55dd7c9c53ead612870a66c27b1907b8f5456049..e3bd172a94b906f3dc15955b59bb40684d9533bf 100644 (file)
@@ -24,6 +24,7 @@ public:
 
        int test();
        int commit(void* data);
+       int commit(PageFlipHandlerBase* data) { return commit((void*)data); }
 
 private:
        Card& m_card;
index ae41f1070f59bbddd31a4b29c1b7c3ccfa3c1d89..8438629b96166c4af9c73256fbe45236edbb4fd5 100644 (file)
@@ -246,4 +246,24 @@ std::vector<kms::Pipeline> Card::get_connected_pipelines()
        return outputs;
 }
 
+static void page_flip_handler(int fd, unsigned int frame,
+                             unsigned int sec, unsigned int usec,
+                             void *data)
+{
+       auto handler = (PageFlipHandlerBase*)data;
+       double time = sec + usec / 1000000.0;
+       handler->handle_page_flip(frame, time);
+}
+
+void Card::call_page_flip_handlers()
+{
+       drmEventContext ev = {
+               .version = DRM_EVENT_CONTEXT_VERSION,
+               .vblank_handler = 0,
+               .page_flip_handler = page_flip_handler,
+       };
+
+       drmHandleEvent(fd(), &ev);
+}
+
 }
index 94e761aadb22ae2bfd4476e252d8395607bbb78f..e692dac40633cd389763a274110111e289f5c9fb 100644 (file)
@@ -41,6 +41,8 @@ public:
 
        std::vector<Pipeline> get_connected_pipelines();
 
+       void call_page_flip_handlers();
+
 private:
        void restore_modes();
 
index 1cbf4c45b55bdf0cf8e175c99cb8063a2994aadc..053c77d57c0c4bb027fe7d77149c72efaf397146 100644 (file)
@@ -25,7 +25,7 @@ public:
                      float src_x, float src_y, float src_w, float src_h);
 
        int page_flip(Framebuffer& fb, void *data);
-
+       int page_flip(Framebuffer& fb, PageFlipHandlerBase* data) { return page_flip(fb, (void*)data); }
 private:
        Crtc(Card& card, uint32_t id, uint32_t idx);
        ~Crtc();
index f9753f290b84eab26bffb5853c467e3a11b83111..851a8c27984d2b3e66add5877973d1097fd76633 100644 (file)
@@ -11,6 +11,7 @@ class Framebuffer;
 class DumbFramebuffer;
 class ExtFramebuffer;
 class DrmObject;
+class PageFlipHandlerBase;
 class Plane;
 class Property;
 class Videomode;
index c518a47ef9fe8d7dd0d223fea159ade148d1fd4b..291cf13c6281aae4ed194f32e1005c8bbf021d51 100644 (file)
@@ -11,3 +11,4 @@
 #include "plane.h"
 #include "property.h"
 #include "pipeline.h"
+#include "pagefliphandler.h"
diff --git a/libkms++/pagefliphandler.h b/libkms++/pagefliphandler.h
new file mode 100644 (file)
index 0000000..79cda0d
--- /dev/null
@@ -0,0 +1,11 @@
+#pragma once
+
+namespace kms {
+class PageFlipHandlerBase
+{
+public:
+       PageFlipHandlerBase() { }
+       virtual ~PageFlipHandlerBase() { }
+       virtual void handle_page_flip(uint32_t frame, double time) = 0;
+};
+}