From c4b962611716c32be44315d97b7ab32b79910aca Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 30 Aug 2022 08:30:01 +0000 Subject: [PATCH] backends/drm: replace manual IN_FORMATS parsing with libdrm functions !2819 reminded me that it's time to replace this mess with libdrm functions Upstream MR: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146 --- CMakeLists.txt | 2 +- src/backends/drm/drm_object_plane.cpp | 22 +++------------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4033ec255..8f036b59b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,7 +247,7 @@ set_package_properties(UDev PROPERTIES PURPOSE "Required for input handling on Wayland." ) -find_package(Libdrm 2.4.62) +find_package(Libdrm 2.4.108) set_package_properties(Libdrm PROPERTIES TYPE REQUIRED PURPOSE "Required for drm output on Wayland.") find_package(gbm) diff --git a/src/backends/drm/drm_object_plane.cpp b/src/backends/drm/drm_object_plane.cpp index 5633c0cd21..dc615a39f4 100644 --- a/src/backends/drm/drm_object_plane.cpp +++ b/src/backends/drm/drm_object_plane.cpp @@ -68,25 +68,9 @@ bool DrmPlane::init() // read formats from blob if available and if modifiers are supported, and from the plane object if not if (const auto formatProp = getProp(PropertyIndex::In_Formats); formatProp && formatProp->immutableBlob() && gpu()->addFB2ModifiersSupported()) { - auto blob = static_cast(formatProp->immutableBlob()->data); - auto modifiers = reinterpret_cast(reinterpret_cast(blob) + blob->modifiers_offset); - uint32_t *formatarr = reinterpret_cast(reinterpret_cast(blob) + blob->formats_offset); - - for (uint32_t f = 0; f < blob->count_formats; f++) { - auto format = formatarr[f]; - QVector mods; - for (uint32_t m = 0; m < blob->count_modifiers; m++) { - auto modifier = &modifiers[m]; - // The modifier advertisement blob is partitioned into groups of 64 formats - if (m < modifier->offset || m > modifier->offset + 63) { - continue; - } - if (!(modifier->formats & (1 << (f - modifier->offset)))) { - continue; - } - mods << modifier->modifier; - } - m_supportedFormats.insert(format, mods); + drmModeFormatModifierIterator iterator{}; + while (drmModeFormatModifierBlobIterNext(formatProp->immutableBlob(), &iterator)) { + m_supportedFormats[iterator.fmt].push_back(iterator.mod); } } else { for (uint32_t i = 0; i < p->count_formats; i++) {