From 83a52a28622c782b40ddd68d0ccf5ca39fe5c056 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Dec 03 2022 06:06:59 +0000 Subject: Add patch for compatibility with older libdrm --- diff --git a/wlroots-0.16-libdrm-2.4.109-compat.patch b/wlroots-0.16-libdrm-2.4.109-compat.patch new file mode 100644 index 0000000..997cf49 --- /dev/null +++ b/wlroots-0.16-libdrm-2.4.109-compat.patch @@ -0,0 +1,241 @@ +From 05ec8d7a160aa5fb1a7fb47c6711e3e95348fbf7 Mon Sep 17 00:00:00 2001 +From: Aleksei Bavshin +Date: Tue, 8 Nov 2022 18:37:13 -0800 +Subject: [PATCH 1/2] Compatibility with libdrm 2.4.112 + +--- + meson.build | 2 +- + render/allocator/gbm.c | 7 ++----- + render/egl.c | 5 +---- + render/vulkan/pixel_format.c | 6 ++---- + types/output/render.c | 7 ++----- + 5 files changed, 8 insertions(+), 19 deletions(-) + +diff --git a/meson.build b/meson.build +index 5dd38e1a..b2fbcf33 100644 +--- a/meson.build ++++ b/meson.build +@@ -107,7 +107,7 @@ wayland_server = dependency('wayland-server', + ) + + drm = dependency('libdrm', +- version: '>=2.4.113', ++ version: '>=2.4.112', + fallback: 'libdrm', + default_options: [ + 'intel=disabled', +diff --git a/render/allocator/gbm.c b/render/allocator/gbm.c +index f77fedd8..805d80e3 100644 +--- a/render/allocator/gbm.c ++++ b/render/allocator/gbm.c +@@ -138,14 +138,11 @@ static struct wlr_gbm_buffer *create_buffer(struct wlr_gbm_allocator *alloc, + buffer->dmabuf.modifier = fallback_modifier; + } + +- char *format_name = drmGetFormatName(buffer->dmabuf.format); + char *modifier_name = drmGetFormatModifierName(buffer->dmabuf.modifier); + wlr_log(WLR_DEBUG, "Allocated %dx%d GBM buffer " +- "with format %s (0x%08"PRIX32"), modifier %s (0x%016"PRIX64")", +- buffer->base.width, buffer->base.height, +- format_name ? format_name : "", buffer->dmabuf.format, ++ "with format 0x%08"PRIX32", modifier %s (0x%016"PRIX64")", ++ buffer->base.width, buffer->base.height, buffer->dmabuf.format, + modifier_name ? modifier_name : "", buffer->dmabuf.modifier); +- free(format_name); + free(modifier_name); + + return buffer; +diff --git a/render/egl.c b/render/egl.c +index e3839c7d..13068fe2 100644 +--- a/render/egl.c ++++ b/render/egl.c +@@ -161,10 +161,7 @@ static void init_dmabuf_formats(struct wlr_egl *egl) { + } + + if (wlr_log_get_verbosity() >= WLR_DEBUG) { +- char *fmt_name = drmGetFormatName(fmt); +- wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")", +- fmt_name ? fmt_name : "", fmt); +- free(fmt_name); ++ wlr_log(WLR_DEBUG, " 0x%08"PRIX32"", fmt); + + log_modifier(DRM_FORMAT_MOD_INVALID, false); + if (modifiers_len == 0) { +diff --git a/render/vulkan/pixel_format.c b/render/vulkan/pixel_format.c +index f55063d7..d0008648 100644 +--- a/render/vulkan/pixel_format.c ++++ b/render/vulkan/pixel_format.c +@@ -234,10 +234,8 @@ void vulkan_format_props_query(struct wlr_vk_device *dev, + const struct wlr_vk_format *format) { + VkResult res; + +- char *format_name = drmGetFormatName(format->drm_format); +- wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")", +- format_name ? format_name : "", format->drm_format); +- free(format_name); ++ wlr_log(WLR_DEBUG, " %.4s (0x08%"PRIx32")", ++ (const char *)&format->drm_format, format->drm_format); + + // get general features and modifiers + VkFormatProperties2 fmtp = {0}; +diff --git a/types/output/render.c b/types/output/render.c +index 13d714e1..862f67f5 100644 +--- a/types/output/render.c ++++ b/types/output/render.c +@@ -4,7 +4,6 @@ + #include + #include + #include +-#include + #include "backend/backend.h" + #include "render/allocator/allocator.h" + #include "render/drm_format_set.h" +@@ -71,10 +70,8 @@ static bool output_create_swapchain(struct wlr_output *output, + return true; + } + +- char *format_name = drmGetFormatName(format->format); +- wlr_log(WLR_DEBUG, "Choosing primary buffer format %s (0x%08"PRIX32") for output '%s'", +- format_name ? format_name : "", format->format, output->name); +- free(format_name); ++ wlr_log(WLR_DEBUG, "Choosing primary buffer format 0x%"PRIX32" for output '%s'", ++ format->format, output->name); + + if (!allow_modifiers && (format->len != 1 || format->modifiers[0] != DRM_FORMAT_MOD_LINEAR)) { + if (!wlr_drm_format_has(format, DRM_FORMAT_MOD_INVALID)) { +-- +2.37.3 + + +From 99798f45c7a407c2a97c7ac2883c348b8e71c8c1 Mon Sep 17 00:00:00 2001 +From: Aleksei Bavshin +Date: Tue, 8 Nov 2022 18:37:51 -0800 +Subject: [PATCH 2/2] Compatibility with libdrm 2.4.109 + +--- + backend/drm/drm.c | 29 ++++++++++++++++++++--------- + backend/drm/util.c | 31 +++++++++++++++++++++++++++++++ + include/backend/drm/util.h | 2 ++ + meson.build | 2 +- + 4 files changed, 54 insertions(+), 10 deletions(-) + +diff --git a/backend/drm/drm.c b/backend/drm/drm.c +index 04994c68..9576de17 100644 +--- a/backend/drm/drm.c ++++ b/backend/drm/drm.c +@@ -1141,6 +1141,23 @@ static struct wlr_drm_crtc *connector_get_current_crtc( + return NULL; + } + ++static uint32_t get_possible_crtcs(int fd, const drmModeConnector *conn) { ++ uint32_t possible_crtcs = 0; ++ ++ for (int i = 0; i < conn->count_encoders; ++i) { ++ drmModeEncoder *enc = drmModeGetEncoder(fd, conn->encoders[i]); ++ if (!enc) { ++ continue; ++ } ++ ++ possible_crtcs |= enc->possible_crtcs; ++ ++ drmModeFreeEncoder(enc); ++ } ++ ++ return possible_crtcs; ++} ++ + static struct wlr_drm_connector *create_drm_connector(struct wlr_drm_backend *drm, + const drmModeConnector *drm_conn) { + struct wlr_drm_connector *wlr_conn = calloc(1, sizeof(*wlr_conn)); +@@ -1153,17 +1170,11 @@ static struct wlr_drm_connector *create_drm_connector(struct wlr_drm_backend *dr + wlr_conn->status = DRM_MODE_DISCONNECTED; + wlr_conn->id = drm_conn->connector_id; + +- const char *conn_name = +- drmModeGetConnectorTypeName(drm_conn->connector_type); +- if (conn_name == NULL) { +- conn_name = "Unknown"; +- } +- + snprintf(wlr_conn->name, sizeof(wlr_conn->name), +- "%s-%"PRIu32, conn_name, drm_conn->connector_type_id); ++ "%s-%"PRIu32, conn_get_name(drm_conn->connector_type), ++ drm_conn->connector_type_id); + +- wlr_conn->possible_crtcs = +- drmModeConnectorGetPossibleCrtcs(drm->fd, drm_conn); ++ wlr_conn->possible_crtcs = get_possible_crtcs(drm->fd, drm_conn); + if (wlr_conn->possible_crtcs == 0) { + wlr_drm_conn_log(wlr_conn, WLR_ERROR, "No CRTC possible"); + } +diff --git a/backend/drm/util.c b/backend/drm/util.c +index 03c4b0b4..6e0df7c5 100644 +--- a/backend/drm/util.c ++++ b/backend/drm/util.c +@@ -119,6 +119,37 @@ void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data) + } + } + ++const char *conn_get_name(uint32_t type_id) { ++ switch (type_id) { ++ case DRM_MODE_CONNECTOR_Unknown: return "Unknown"; ++ case DRM_MODE_CONNECTOR_VGA: return "VGA"; ++ case DRM_MODE_CONNECTOR_DVII: return "DVI-I"; ++ case DRM_MODE_CONNECTOR_DVID: return "DVI-D"; ++ case DRM_MODE_CONNECTOR_DVIA: return "DVI-A"; ++ case DRM_MODE_CONNECTOR_Composite: return "Composite"; ++ case DRM_MODE_CONNECTOR_SVIDEO: return "SVIDEO"; ++ case DRM_MODE_CONNECTOR_LVDS: return "LVDS"; ++ case DRM_MODE_CONNECTOR_Component: return "Component"; ++ case DRM_MODE_CONNECTOR_9PinDIN: return "DIN"; ++ case DRM_MODE_CONNECTOR_DisplayPort: return "DP"; ++ case DRM_MODE_CONNECTOR_HDMIA: return "HDMI-A"; ++ case DRM_MODE_CONNECTOR_HDMIB: return "HDMI-B"; ++ case DRM_MODE_CONNECTOR_TV: return "TV"; ++ case DRM_MODE_CONNECTOR_eDP: return "eDP"; ++ case DRM_MODE_CONNECTOR_VIRTUAL: return "Virtual"; ++ case DRM_MODE_CONNECTOR_DSI: return "DSI"; ++ case DRM_MODE_CONNECTOR_DPI: return "DPI"; ++ case DRM_MODE_CONNECTOR_WRITEBACK: return "Writeback"; ++#ifdef DRM_MODE_CONNECTOR_SPI ++ case DRM_MODE_CONNECTOR_SPI: return "SPI"; ++#endif ++#ifdef DRM_MODE_CONNECTOR_USB ++ case DRM_MODE_CONNECTOR_USB: return "USB"; ++#endif ++ default: return "Unknown"; ++ } ++} ++ + static bool is_taken(size_t n, const uint32_t arr[static n], uint32_t key) { + for (size_t i = 0; i < n; ++i) { + if (arr[i] == key) { +diff --git a/include/backend/drm/util.h b/include/backend/drm/util.h +index 9bfe5f8a..4979d906 100644 +--- a/include/backend/drm/util.h ++++ b/include/backend/drm/util.h +@@ -14,6 +14,8 @@ enum wlr_output_mode_aspect_ratio get_picture_aspect_ratio(const drmModeModeInfo + const char *get_pnp_manufacturer(uint16_t code); + // Populates the make/model/phys_{width,height} of output from the edid data + void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data); ++// Returns the string representation of a DRM output type ++const char *conn_get_name(uint32_t type_id); + + // Part of match_obj + enum { +diff --git a/meson.build b/meson.build +index b2fbcf33..b673ab20 100644 +--- a/meson.build ++++ b/meson.build +@@ -107,7 +107,7 @@ wayland_server = dependency('wayland-server', + ) + + drm = dependency('libdrm', +- version: '>=2.4.112', ++ version: '>=2.4.109', + fallback: 'libdrm', + default_options: [ + 'intel=disabled', +-- +2.37.3 + diff --git a/wlroots.spec b/wlroots.spec index d57bcc8..453cb67 100644 --- a/wlroots.spec +++ b/wlroots.spec @@ -42,6 +42,9 @@ Patch0: wlroots-0.16-backports.patch # Following patch is required for phoc. Patch10: Revert-layer-shell-error-on-0-dimension-without-anch.patch +# Patches for compatibility with older Fedora releases (module or copr builds) +Patch20: wlroots-0.16-libdrm-2.4.109-compat.patch + BuildRequires: gcc BuildRequires: glslang BuildRequires: gnupg2 @@ -50,7 +53,7 @@ BuildRequires: pkgconfig(egl) BuildRequires: pkgconfig(gbm) >= 17.1.0 BuildRequires: pkgconfig(glesv2) BuildRequires: pkgconfig(hwdata) -BuildRequires: pkgconfig(libdrm) >= 2.4.113 +BuildRequires: pkgconfig(libdrm) >= 2.4.109 %dnl # 2.4.113 without the compat patch BuildRequires: pkgconfig(libinput) >= 1.21.0 BuildRequires: pkgconfig(libseat) BuildRequires: pkgconfig(libudev) @@ -91,7 +94,13 @@ Development files for %{name}. %prep %{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' -%autosetup -p1 +%autosetup -N +# apply unconditional patches +%autopatch -p1 -M19 +# apply conditional patches +%if 0%{?fedora} && 0%{?fedora} < 37 +%patch20 -p1 -b .libdrm +%endif %build @@ -135,6 +144,7 @@ install -pm0644 -D '%{SOURCE3}' '%{buildroot}/%{_pkgdocdir}/examples/meson.build %changelog * Fri Dec 02 2022 Aleksei Bavshin - 0.16.0-1 - Update to 0.16.0 (#2142159) +- Add patch for compatibility with older libdrm * Mon Nov 14 2022 Aleksei Bavshin - 0.15.1-5 - Backport upstream crash fix (#2142447)