aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2024-02-14 15:32:07 +0100
committerSimon Ser <contact@emersion.fr>2024-02-14 17:13:25 +0100
commit9a685cefa9701f3aa25bf5fe2188ab894c06a759 (patch)
tree7caddf3b34017656ce1eede15915dcfe75ceef42 /backend
parent741aaa3f761a7175f622150defac514da8f2fed6 (diff)
backend/drm: add destroy_blob()
Centralizes the logic to destroy a DRM blob: check whether it's zero, and print a nice error message.
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/atomic.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
index 60f20e03..dcad7d3d 100644
--- a/backend/drm/atomic.c
+++ b/backend/drm/atomic.c
@@ -201,14 +201,21 @@ static uint64_t pick_max_bpc(struct wlr_drm_connector *conn, struct wlr_drm_fb *
return target_bpc;
}
+static void destroy_blob(struct wlr_drm_backend *drm, uint32_t id) {
+ if (id == 0) {
+ return;
+ }
+ if (drmModeDestroyPropertyBlob(drm->fd, id) != 0) {
+ wlr_log_errno(WLR_ERROR, "Failed to destroy blob");
+ }
+}
+
static void commit_blob(struct wlr_drm_backend *drm,
uint32_t *current, uint32_t next) {
if (*current == next) {
return;
}
- if (*current != 0) {
- drmModeDestroyPropertyBlob(drm->fd, *current);
- }
+ destroy_blob(drm, *current);
*current = next;
}
@@ -217,9 +224,7 @@ static void rollback_blob(struct wlr_drm_backend *drm,
if (*current == next) {
return;
}
- if (next != 0) {
- drmModeDestroyPropertyBlob(drm->fd, next);
- }
+ destroy_blob(drm, next);
}
static void plane_disable(struct atomic *atom, struct wlr_drm_plane *plane) {
@@ -382,11 +387,7 @@ static bool atomic_crtc_commit(struct wlr_drm_connector *conn,
rollback_blob(drm, &crtc->mode_id, mode_id);
rollback_blob(drm, &crtc->gamma_lut, gamma_lut);
}
-
- if (fb_damage_clips != 0 &&
- drmModeDestroyPropertyBlob(drm->fd, fb_damage_clips) != 0) {
- wlr_log_errno(WLR_ERROR, "Failed to destroy FB_DAMAGE_CLIPS property blob");
- }
+ destroy_blob(drm, fb_damage_clips);
return ok;
}