summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-03-26 15:12:11 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-03-26 15:12:49 +0200
commitbef0109aa93971dd6cc6040661dc6494533e6bee (patch)
tree28c494db8fd4f2811592e665b1295153c0f1ef64 /libkms++
parenta85fd267fca64f7c1b6e2269a00922ba1326fe7d (diff)
add ExtFramebuffer ctr for fds
Diffstat (limited to 'libkms++')
-rw-r--r--libkms++/extframebuffer.cpp25
-rw-r--r--libkms++/extframebuffer.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/libkms++/extframebuffer.cpp b/libkms++/extframebuffer.cpp
index 35fead8..2dd2903 100644
--- a/libkms++/extframebuffer.cpp
+++ b/libkms++/extframebuffer.cpp
@@ -35,6 +35,31 @@ ExtFramebuffer::ExtFramebuffer(Card& card, uint32_t width, uint32_t height, Pixe
set_id(id);
}
+ExtFramebuffer::ExtFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
+ int fds[4], uint32_t pitches[4], uint32_t offsets[4])
+ : Framebuffer(card, width, height)
+{
+ int r;
+
+ const PixelFormatInfo& format_info = get_pixel_format_info(format);
+
+ uint32_t handles[4] = { 0 };
+
+ for (int i = 0; i < format_info.num_planes; ++i) {
+ r = drmPrimeFDToHandle(card.fd(), fds[i], &handles[i]);
+ if (r)
+ throw invalid_argument(string("drmPrimeFDToHandle: ") + strerror(errno));
+ }
+
+ uint32_t id;
+ r = drmModeAddFB2(card.fd(), width, height, (uint32_t)format,
+ handles, pitches, offsets, &id, 0);
+ if (r)
+ throw invalid_argument(string("drmModeAddFB2 failed: ") + strerror(errno));
+
+ set_id(id);
+}
+
ExtFramebuffer::~ExtFramebuffer()
{
drmModeRmFB(card().fd(), id());
diff --git a/libkms++/extframebuffer.h b/libkms++/extframebuffer.h
index 8c17a29..7ed3434 100644
--- a/libkms++/extframebuffer.h
+++ b/libkms++/extframebuffer.h
@@ -12,6 +12,8 @@ public:
ExtFramebuffer(Card& card, uint32_t width, uint32_t height, uint32_t depth, uint32_t bpp, uint32_t stride, uint32_t handle);
ExtFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
uint32_t handles[4], uint32_t pitches[4], uint32_t offsets[4]);
+ ExtFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
+ int fds[4], uint32_t pitches[4], uint32_t offsets[4]);
virtual ~ExtFramebuffer();
private: