summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Hoosier <matt.hoosier@garmin.com>2019-11-15 14:35:50 -0600
committerMatt Hoosier <matt.hoosier@garmin.com>2019-11-18 15:56:57 -0600
commitcc6e6b22af6b962a10eb862986ecbe1f135f2f7d (patch)
tree023bb4a36c94d7b1ba5290c7fd404d1d1cc075ce
parentf824cccac7311647a8bd22d193d3aac2b961a1dd (diff)
Allow making extframebuffer and dmabufframebuffer with modifiers
Many GPUs use bandwidth compression or tiling, and this information must be passed along to KMS when constructing the framebuffer object around the GEM handle or prime filedescriptor. Add an vector of modifiers as an optional parameter to both of these classes. Bump the minimum required version of libdrm to 2.4.17 to ensure drmModeAddFB2WithModifiers() is available. Signed-off-by: Matt Hoosier <matt.hoosier@garmin.com>
-rw-r--r--CMakeLists.txt2
-rw-r--r--kms++/inc/kms++/dmabufframebuffer.h3
-rw-r--r--kms++/inc/kms++/extframebuffer.h3
-rw-r--r--kms++/src/dmabufframebuffer.cpp21
-rw-r--r--kms++/src/extframebuffer.cpp14
5 files changed, 33 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 216f537..3f0084c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,7 +66,7 @@ if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
endif()
find_package(PkgConfig REQUIRED)
-pkg_check_modules(LIBDRM libdrm>=2.4.64 REQUIRED)
+pkg_check_modules(LIBDRM libdrm>=2.4.71 REQUIRED)
pkg_check_modules(LIBDRM_OMAP libdrm_omap)
if(LIBDRM_OMAP_FOUND)
diff --git a/kms++/inc/kms++/dmabufframebuffer.h b/kms++/inc/kms++/dmabufframebuffer.h
index 2a9182d..a17b1f1 100644
--- a/kms++/inc/kms++/dmabufframebuffer.h
+++ b/kms++/inc/kms++/dmabufframebuffer.h
@@ -11,7 +11,7 @@ class DmabufFramebuffer : public Framebuffer
{
public:
DmabufFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
- std::vector<int> fds, std::vector<uint32_t> pitches, std::vector<uint32_t> offsets);
+ std::vector<int> fds, std::vector<uint32_t> pitches, std::vector<uint32_t> offsets, std::vector<uint64_t> modifiers = {});
~DmabufFramebuffer() override;
uint32_t width() const override { return Framebuffer::width(); }
@@ -37,6 +37,7 @@ private:
uint32_t size;
uint32_t stride;
uint32_t offset;
+ uint64_t modifier;
uint8_t *map;
};
diff --git a/kms++/inc/kms++/extframebuffer.h b/kms++/inc/kms++/extframebuffer.h
index 5239a3d..f906fb2 100644
--- a/kms++/inc/kms++/extframebuffer.h
+++ b/kms++/inc/kms++/extframebuffer.h
@@ -11,7 +11,7 @@ class ExtFramebuffer : public Framebuffer
{
public:
ExtFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
- std::vector<uint32_t> handles, std::vector<uint32_t> pitches, std::vector<uint32_t> offsets);
+ std::vector<uint32_t> handles, std::vector<uint32_t> pitches, std::vector<uint32_t> offsets, std::vector<uint64_t> modifiers = {});
~ExtFramebuffer() override;
uint32_t width() const override { return Framebuffer::width(); }
@@ -31,6 +31,7 @@ private:
uint32_t size;
uint32_t stride;
uint32_t offset;
+ uint64_t modifier;
uint8_t *map;
};
diff --git a/kms++/src/dmabufframebuffer.cpp b/kms++/src/dmabufframebuffer.cpp
index d36eb89..1e8c914 100644
--- a/kms++/src/dmabufframebuffer.cpp
+++ b/kms++/src/dmabufframebuffer.cpp
@@ -17,7 +17,7 @@ namespace kms
{
DmabufFramebuffer::DmabufFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
- vector<int> fds, vector<uint32_t> pitches, vector<uint32_t> offsets)
+ vector<int> fds, vector<uint32_t> pitches, vector<uint32_t> offsets, vector<uint64_t> modifiers)
: Framebuffer(card, width, height)
{
int r;
@@ -42,6 +42,7 @@ DmabufFramebuffer::DmabufFramebuffer(Card& card, uint32_t width, uint32_t height
plane.stride = pitches[i];
plane.offset = offsets[i];
+ plane.modifier = modifiers.empty() ? 0 : modifiers[i];
plane.size = plane.stride * height;
plane.map = 0;
}
@@ -50,10 +51,20 @@ DmabufFramebuffer::DmabufFramebuffer(Card& card, uint32_t width, uint32_t height
uint32_t bo_handles[4] = { m_planes[0].handle, m_planes[1].handle, m_planes[2].handle, m_planes[3].handle };
pitches.resize(4);
offsets.resize(4);
- r = drmModeAddFB2(card.fd(), width, height, (uint32_t)format,
- bo_handles, pitches.data(), offsets.data(), &id, 0);
- if (r)
- throw invalid_argument(string("drmModeAddFB2 failed: ") + strerror(errno));
+
+ if (modifiers.empty()) {
+ r = drmModeAddFB2(card.fd(), width, height, (uint32_t)format,
+ bo_handles, pitches.data(), offsets.data(), &id, 0);
+ if (r)
+ throw invalid_argument(string("drmModeAddFB2 failed: ") + strerror(errno));
+ }
+ else {
+ modifiers.resize(4);
+ r = drmModeAddFB2WithModifiers(card.fd(), width, height, (uint32_t)format,
+ bo_handles, pitches.data(), offsets.data(), modifiers.data(), &id, DRM_MODE_FB_MODIFIERS);
+ if (r)
+ throw invalid_argument(string("drmModeAddFB2WithModifiers failed: ") + strerror(errno));
+ }
set_id(id);
}
diff --git a/kms++/src/extframebuffer.cpp b/kms++/src/extframebuffer.cpp
index 23aed50..4ea563c 100644
--- a/kms++/src/extframebuffer.cpp
+++ b/kms++/src/extframebuffer.cpp
@@ -15,7 +15,7 @@ namespace kms
{
ExtFramebuffer::ExtFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
- vector<uint32_t> handles, vector<uint32_t> pitches, vector<uint32_t> offsets)
+ vector<uint32_t> handles, vector<uint32_t> pitches, vector<uint32_t> offsets, vector<uint64_t> modifiers)
: Framebuffer(card, width, height)
{
m_format = format;
@@ -33,6 +33,7 @@ ExtFramebuffer::ExtFramebuffer(Card& card, uint32_t width, uint32_t height, Pixe
plane.handle = handles[i];
plane.stride = pitches[i];
plane.offset = offsets[i];
+ plane.modifier = modifiers.empty() ? 0 : modifiers[i];
plane.size = plane.stride * height;
plane.map = 0;
}
@@ -41,7 +42,16 @@ ExtFramebuffer::ExtFramebuffer(Card& card, uint32_t width, uint32_t height, Pixe
handles.resize(4);
pitches.resize(4);
offsets.resize(4);
- int r = drmModeAddFB2(card.fd(), width, height, (uint32_t)format, handles.data(), pitches.data(), offsets.data(), &id, 0);
+ int r;
+
+ if (modifiers.empty()) {
+ r = drmModeAddFB2(card.fd(), width, height, (uint32_t)format, handles.data(), pitches.data(), offsets.data(), &id, 0);
+ }
+ else {
+ modifiers.resize(4);
+ r = drmModeAddFB2WithModifiers(card.fd(), width, height, (uint32_t)format, handles.data(), pitches.data(), offsets.data(), modifiers.data(), &id, DRM_MODE_FB_MODIFIERS);
+ }
+
if (r)
throw std::invalid_argument(string("Failed to create ExtFramebuffer: ") + strerror(r));