From cc6e6b22af6b962a10eb862986ecbe1f135f2f7d Mon Sep 17 00:00:00 2001 From: Matt Hoosier Date: Fri, 15 Nov 2019 14:35:50 -0600 Subject: 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 --- kms++/src/extframebuffer.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'kms++/src/extframebuffer.cpp') 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 handles, vector pitches, vector offsets) + vector handles, vector pitches, vector offsets, vector 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)); -- cgit v1.2.3