diff options
author | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-02 21:27:55 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-03 16:59:19 +0300 |
commit | 2984c032ccef081c350f306c96e3c923126657c8 (patch) | |
tree | 9871d26164e5a93a0776cb9f71fa97c853b60f9f | |
parent | 89bfd9d567ced945bf2f4b3a927426c1ad2ee762 (diff) |
Add ExtFramebuffer
Add ExtFramebuffer for cases where the buffer have been allocated
externally.
-rw-r--r-- | libkms++/decls.h | 1 | ||||
-rw-r--r-- | libkms++/extframebuffer.cpp | 35 | ||||
-rw-r--r-- | libkms++/extframebuffer.h | 21 | ||||
-rw-r--r-- | libkms++/kms++.h | 1 |
4 files changed, 58 insertions, 0 deletions
diff --git a/libkms++/decls.h b/libkms++/decls.h index 1415f1f..f9753f2 100644 --- a/libkms++/decls.h +++ b/libkms++/decls.h @@ -9,6 +9,7 @@ class Crtc; class Encoder; class Framebuffer; class DumbFramebuffer; +class ExtFramebuffer; class DrmObject; class Plane; class Property; diff --git a/libkms++/extframebuffer.cpp b/libkms++/extframebuffer.cpp new file mode 100644 index 0000000..de9d737 --- /dev/null +++ b/libkms++/extframebuffer.cpp @@ -0,0 +1,35 @@ + +#include <cstring> +#include <stdexcept> +#include <sys/mman.h> +#include <xf86drm.h> +#include <xf86drmMode.h> + +#include "kms++.h" + +using namespace std; + +namespace kms +{ + +ExtFramebuffer::ExtFramebuffer(Card& card, uint32_t width, uint32_t height, uint32_t depth, uint32_t bpp, uint32_t stride, uint32_t handle) + :Framebuffer(card, width, height) +{ + uint32_t id; + int r = drmModeAddFB(card.fd(), width, height, depth, bpp, stride, handle, &id); + if (r) + throw invalid_argument("fob"); + m_id = id; +} + +ExtFramebuffer::~ExtFramebuffer() +{ + drmModeRmFB(card().fd(), id()); +} + +void ExtFramebuffer::print_short() const +{ + printf("Framebuffer %d\n", id()); +} + +} diff --git a/libkms++/extframebuffer.h b/libkms++/extframebuffer.h new file mode 100644 index 0000000..cc0863a --- /dev/null +++ b/libkms++/extframebuffer.h @@ -0,0 +1,21 @@ +#pragma once + +#include "framebuffer.h" + +namespace kms +{ + +class ExtFramebuffer : public Framebuffer +{ +public: + ExtFramebuffer(Card& card, uint32_t width, uint32_t height, uint32_t depth, uint32_t bpp, uint32_t stride, uint32_t handle); + virtual ~ExtFramebuffer(); + + void print_short() const; + +private: + uint32_t m_pitch; + uint32_t m_bpp; + uint32_t m_depth; +}; +} diff --git a/libkms++/kms++.h b/libkms++/kms++.h index c446a9e..c518a47 100644 --- a/libkms++/kms++.h +++ b/libkms++/kms++.h @@ -7,6 +7,7 @@ #include "encoder.h" #include "framebuffer.h" #include "dumbframebuffer.h" +#include "extframebuffer.h" #include "plane.h" #include "property.h" #include "pipeline.h" |