From d6de38c1d66bfd96426b82003e01978f1e585823 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 26 Aug 2021 18:36:52 +0200 Subject: [PATCH] platforms/drm: use drm formats instead of gbm formats There's no need to guard the code, gbm and drm format definitions are the same. Using GBM_BO_FORMAT_* even caused bugs, as that is an enum and not a proper format identifier. BUG: 441253 --- src/plugins/platforms/drm/drm_gpu.cpp | 7 ++++--- src/plugins/platforms/drm/drm_gpu.h | 2 +- src/plugins/platforms/drm/drm_object_plane.cpp | 11 +++-------- src/plugins/platforms/drm/egl_gbm_backend.cpp | 2 +- src/plugins/platforms/drm/gbm_dmabuf.cpp | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/plugins/platforms/drm/drm_gpu.cpp b/src/plugins/platforms/drm/drm_gpu.cpp index 920524f22f..080eea3a16 100644 --- a/src/plugins/platforms/drm/drm_gpu.cpp +++ b/src/plugins/platforms/drm/drm_gpu.cpp @@ -35,6 +35,7 @@ #include #include #include +#include namespace KWin { @@ -498,13 +499,13 @@ void DrmGpu::removeVirtualOutput(DrmVirtualOutput *output) } } -bool DrmGpu::isFormatSupported(uint32_t gbmFormat) const +bool DrmGpu::isFormatSupported(uint32_t drmFormat) const { if (!m_atomicModeSetting) { - return gbmFormat == GBM_BO_FORMAT_XRGB8888 || gbmFormat == GBM_BO_FORMAT_ARGB8888; + return drmFormat == DRM_FORMAT_XRGB8888 || drmFormat == DRM_FORMAT_ARGB8888; } else { for (const auto &plane : qAsConst(m_planes)) { - if (plane->type() == DrmPlane::TypeIndex::Primary && !plane->formats().contains(gbmFormat)) { + if (plane->type() == DrmPlane::TypeIndex::Primary && !plane->formats().contains(drmFormat)) { return false; } } diff --git a/src/plugins/platforms/drm/drm_gpu.h b/src/plugins/platforms/drm/drm_gpu.h index 1803739766..f554b5af28 100644 --- a/src/plugins/platforms/drm/drm_gpu.h +++ b/src/plugins/platforms/drm/drm_gpu.h @@ -98,7 +98,7 @@ public: void waitIdle(); DrmBackend *platform() const; const QVector pipelines() const; - bool isFormatSupported(uint32_t gbmFormat) const; + bool isFormatSupported(uint32_t drmFormat) const; DrmVirtualOutput *createVirtualOutput(); void removeVirtualOutput(DrmVirtualOutput *output); diff --git a/src/plugins/platforms/drm/drm_object_plane.cpp b/src/plugins/platforms/drm/drm_object_plane.cpp index 19596d2764..c2962e2e67 100644 --- a/src/plugins/platforms/drm/drm_object_plane.cpp +++ b/src/plugins/platforms/drm/drm_object_plane.cpp @@ -13,9 +13,7 @@ #include "logging.h" #include "config-kwin.h" -#if HAVE_GBM -#include -#endif +#include namespace KWin { @@ -101,14 +99,11 @@ bool DrmPlane::init() m_supportedFormats.insert(p->formats[i], {}); } } -#if HAVE_GBM if (m_supportedFormats.isEmpty()) { qCWarning(KWIN_DRM) << "Driver doesn't advertise any formats for this plane. Falling back to XRGB8888 and ARGB8888 without modifiers"; - m_supportedFormats.insert(GBM_BO_FORMAT_XRGB8888, {}); - m_supportedFormats.insert(GBM_BO_FORMAT_ARGB8888, {}); + m_supportedFormats.insert(DRM_FORMAT_XRGB8888, {}); + m_supportedFormats.insert(DRM_FORMAT_ARGB8888, {}); } -#endif - } return success; } diff --git a/src/plugins/platforms/drm/egl_gbm_backend.cpp b/src/plugins/platforms/drm/egl_gbm_backend.cpp index 92271bb418..8be45d4f76 100644 --- a/src/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/src/plugins/platforms/drm/egl_gbm_backend.cpp @@ -414,7 +414,7 @@ bool EglGbmBackend::initBufferConfigs() eglGetConfigAttrib(eglDisplay(), configs[i], EGL_ALPHA_SIZE, &alphaSize); // prefer XRGB8888 as it's most likely to be supported by secondary GPUs as well - if (gbmFormat == GBM_BO_FORMAT_XRGB8888) { + if (gbmFormat == GBM_FORMAT_XRGB8888) { m_gbmFormat = gbmFormat; setConfig(configs[i]); return true; diff --git a/src/plugins/platforms/drm/gbm_dmabuf.cpp b/src/plugins/platforms/drm/gbm_dmabuf.cpp index d6687458a7..10abe6b53f 100644 --- a/src/plugins/platforms/drm/gbm_dmabuf.cpp +++ b/src/plugins/platforms/drm/gbm_dmabuf.cpp @@ -35,7 +35,7 @@ KWin::GbmDmaBuf *GbmDmaBuf::createBuffer(const QSize &size, gbm_device *device) return nullptr; } - auto bo = gbm_bo_create(device, size.width(), size.height(), GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR); + auto bo = gbm_bo_create(device, size.width(), size.height(), GBM_FORMAT_ARGB8888, GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR); if (!bo) { gbm_bo_destroy(bo);