summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-03 21:13:06 +0300
committerTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-03 22:41:49 +0300
commit4832ae09005c5e2bb86b9ab378af000f2ab313f1 (patch)
tree1c9b047c2e07f27b2c1793512a20bc7d6115fef6 /libkms++
parent9e3f0a9c4b6790618637b4ed93d45092e84dd84b (diff)
add PageFlipHandler
Diffstat (limited to 'libkms++')
-rw-r--r--libkms++/atomicreq.h1
-rw-r--r--libkms++/card.cpp20
-rw-r--r--libkms++/card.h2
-rw-r--r--libkms++/crtc.h2
-rw-r--r--libkms++/decls.h1
-rw-r--r--libkms++/kms++.h1
-rw-r--r--libkms++/pagefliphandler.h11
7 files changed, 37 insertions, 1 deletions
diff --git a/libkms++/atomicreq.h b/libkms++/atomicreq.h
index 55dd7c9..e3bd172 100644
--- a/libkms++/atomicreq.h
+++ b/libkms++/atomicreq.h
@@ -24,6 +24,7 @@ public:
int test();
int commit(void* data);
+ int commit(PageFlipHandlerBase* data) { return commit((void*)data); }
private:
Card& m_card;
diff --git a/libkms++/card.cpp b/libkms++/card.cpp
index ae41f10..8438629 100644
--- a/libkms++/card.cpp
+++ b/libkms++/card.cpp
@@ -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);
+}
+
}
diff --git a/libkms++/card.h b/libkms++/card.h
index 94e761a..e692dac 100644
--- a/libkms++/card.h
+++ b/libkms++/card.h
@@ -41,6 +41,8 @@ public:
std::vector<Pipeline> get_connected_pipelines();
+ void call_page_flip_handlers();
+
private:
void restore_modes();
diff --git a/libkms++/crtc.h b/libkms++/crtc.h
index 1cbf4c4..053c77d 100644
--- a/libkms++/crtc.h
+++ b/libkms++/crtc.h
@@ -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();
diff --git a/libkms++/decls.h b/libkms++/decls.h
index f9753f2..851a8c2 100644
--- a/libkms++/decls.h
+++ b/libkms++/decls.h
@@ -11,6 +11,7 @@ class Framebuffer;
class DumbFramebuffer;
class ExtFramebuffer;
class DrmObject;
+class PageFlipHandlerBase;
class Plane;
class Property;
class Videomode;
diff --git a/libkms++/kms++.h b/libkms++/kms++.h
index c518a47..291cf13 100644
--- a/libkms++/kms++.h
+++ b/libkms++/kms++.h
@@ -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
index 0000000..79cda0d
--- /dev/null
+++ b/libkms++/pagefliphandler.h
@@ -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;
+};
+}