summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
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: