Commit dfe82f6e authored by Kristian H. Kristensen's avatar Kristian H. Kristensen Committed by Commit Bot

ozone/drm: Use DRM_FORMAT_MOD_INVALID to indicate absence of modifier

Upstream has allocated DRM_FORMAT_MOD_INVALID as a special modifier
that indicates the absence of a modifier. This is the legacy mode
where the kernel gets the tiling/layout information through back
channels, typically as a property of the BO.

It's a little more concise that passing addfb_flags around as we did
before and can be encoded into the NativePixmap handle as well.

Bug: b:70546200, b:71416883, chromium:789292, b:69238712, b:68003124
Change-Id: I4340355e56d4117afebb06e1d96d4f8b93900a6e
Reviewed-on: https://chromium-review.googlesource.com/885904
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532536}
parent 190a3e4a
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ui/ozone/platform/drm/gpu/gbm_buffer.h" #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
#include <drm.h> #include <drm.h>
#include <drm_fourcc.h>
#include <fcntl.h> #include <fcntl.h>
#include <gbm.h> #include <gbm.h>
#include <xf86drm.h> #include <xf86drm.h>
...@@ -33,7 +34,6 @@ GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, ...@@ -33,7 +34,6 @@ GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm,
uint32_t format, uint32_t format,
uint32_t flags, uint32_t flags,
uint64_t modifier, uint64_t modifier,
uint32_t addfb_flags,
std::vector<base::ScopedFD>&& fds, std::vector<base::ScopedFD>&& fds,
const gfx::Size& size, const gfx::Size& size,
...@@ -61,7 +61,7 @@ GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, ...@@ -61,7 +61,7 @@ GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm,
handles[i] = gbm_bo_get_plane_handle(bo, i).u32; handles[i] = gbm_bo_get_plane_handle(bo, i).u32;
strides[i] = gbm_bo_get_plane_stride(bo, i); strides[i] = gbm_bo_get_plane_stride(bo, i);
offsets[i] = gbm_bo_get_plane_offset(bo, i); offsets[i] = gbm_bo_get_plane_offset(bo, i);
if (addfb_flags & DRM_MODE_FB_MODIFIERS) if (modifier != DRM_FORMAT_MOD_INVALID)
modifiers[i] = modifier; modifiers[i] = modifier;
} }
...@@ -69,6 +69,8 @@ GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm, ...@@ -69,6 +69,8 @@ GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm,
// DRM_MODE_FB_MODIFIERS set. We only set that when we've created // DRM_MODE_FB_MODIFIERS set. We only set that when we've created
// a bo with modifiers, otherwise, we rely on the "no modifiers" // a bo with modifiers, otherwise, we rely on the "no modifiers"
// behavior doing the right thing. // behavior doing the right thing.
const uint32_t addfb_flags =
modifier != DRM_FORMAT_MOD_INVALID ? DRM_MODE_FB_MODIFIERS : 0;
bool ret = drm_->AddFramebuffer2( bool ret = drm_->AddFramebuffer2(
gbm_bo_get_width(bo), gbm_bo_get_height(bo), framebuffer_pixel_format_, gbm_bo_get_width(bo), gbm_bo_get_height(bo), framebuffer_pixel_format_,
handles, strides, offsets, modifiers, &framebuffer_, addfb_flags); handles, strides, offsets, modifiers, &framebuffer_, addfb_flags);
...@@ -188,8 +190,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferForBO( ...@@ -188,8 +190,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferForBO(
uint32_t format, uint32_t format,
const gfx::Size& size, const gfx::Size& size,
uint32_t flags, uint32_t flags,
uint64_t modifier, uint64_t modifier) {
uint32_t addfb_flags) {
DCHECK(bo); DCHECK(bo);
std::vector<base::ScopedFD> fds; std::vector<base::ScopedFD> fds;
std::vector<gfx::NativePixmapPlane> planes; std::vector<gfx::NativePixmapPlane> planes;
...@@ -210,13 +211,13 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferForBO( ...@@ -210,13 +211,13 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferForBO(
fds.emplace_back(std::move(fd)); fds.emplace_back(std::move(fd));
} }
planes.emplace_back( planes.emplace_back(gbm_bo_get_plane_stride(bo, i),
gbm_bo_get_plane_stride(bo, i), gbm_bo_get_plane_offset(bo, i), gbm_bo_get_plane_offset(bo, i),
gbm_bo_get_plane_size(bo, i), gbm_bo_get_plane_format_modifier(bo, i)); gbm_bo_get_plane_size(bo, i), modifier);
} }
scoped_refptr<GbmBuffer> buffer( scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, format, flags,
new GbmBuffer(gbm, bo, format, flags, modifier, addfb_flags, modifier, std::move(fds), size,
std::move(fds), size, std::move(planes))); std::move(planes)));
if (flags & GBM_BO_USE_SCANOUT && !buffer->GetFramebufferId()) if (flags & GBM_BO_USE_SCANOUT && !buffer->GetFramebufferId())
return nullptr; return nullptr;
...@@ -240,8 +241,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferWithModifiers( ...@@ -240,8 +241,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferWithModifiers(
return nullptr; return nullptr;
return CreateBufferForBO(gbm, bo, format, size, flags, return CreateBufferForBO(gbm, bo, format, size, flags,
gbm_bo_get_format_modifier(bo), gbm_bo_get_format_modifier(bo));
DRM_MODE_FB_MODIFIERS);
} }
// static // static
...@@ -258,8 +258,15 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( ...@@ -258,8 +258,15 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
if (!bo) if (!bo)
return nullptr; return nullptr;
// minigbm knows which modifier it chose for the bo it created, and will
// tell us if we ask. However, we have to track it as DRM_FORMAT_MOD_INVALID
// at this level so we don't try to pass it to addfb2, which may not support
// that. Only when the bo is created with modifiers
// (CreateBufferWithModifiers above) do we track the actual modifier, since
// we know we can pass it to addfb2 in that case.
return CreateBufferForBO(gbm, bo, format, size, flags, return CreateBufferForBO(gbm, bo, format, size, flags,
gbm_bo_get_format_modifier(bo), 0); DRM_FORMAT_MOD_INVALID);
} }
// static // static
...@@ -304,9 +311,8 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferFromFds( ...@@ -304,9 +311,8 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferFromFds(
} }
} }
scoped_refptr<GbmBuffer> buffer(new GbmBuffer(gbm, bo, format, gbm_flags, 0, scoped_refptr<GbmBuffer> buffer(new GbmBuffer(
0, std::move(fds), size, gbm, bo, format, gbm_flags, 0, std::move(fds), size, std::move(planes)));
std::move(planes)));
return buffer; return buffer;
} }
......
...@@ -69,7 +69,6 @@ class GbmBuffer : public ScanoutBuffer { ...@@ -69,7 +69,6 @@ class GbmBuffer : public ScanoutBuffer {
uint32_t format, uint32_t format,
uint32_t flags, uint32_t flags,
uint64_t modifier, uint64_t modifier,
uint32_t addfb_flags,
std::vector<base::ScopedFD>&& fds, std::vector<base::ScopedFD>&& fds,
const gfx::Size& size, const gfx::Size& size,
const std::vector<gfx::NativePixmapPlane>&& planes); const std::vector<gfx::NativePixmapPlane>&& planes);
...@@ -81,8 +80,7 @@ class GbmBuffer : public ScanoutBuffer { ...@@ -81,8 +80,7 @@ class GbmBuffer : public ScanoutBuffer {
uint32_t format, uint32_t format,
const gfx::Size& size, const gfx::Size& size,
uint32_t flags, uint32_t flags,
uint64_t modifiers, uint64_t modifier);
uint32_t addfb_flags);
scoped_refptr<GbmDevice> drm_; scoped_refptr<GbmDevice> drm_;
gbm_bo* bo_; gbm_bo* bo_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment