aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-07-21 15:58:01 +0200
committerSimon Ser <contact@emersion.fr>2021-08-18 20:59:25 +0200
commit46c42e55c6e0b08d9e7db989d6a10f073525e999 (patch)
tree01e377dd7b83a044e7a7fbd5f2cc26cf16f0ebc6 /backend/drm
parent109405729b5a384b08f2faf6196e8a31041eab8f (diff)
backend/drm: add support for FB_DAMAGE_CLIPS
This allows the kernel to access our buffer damage. Some drivers can take advantage of this, e.g. for PSR2 panels (Panel Self Refresh) or for transfer over USB. Closes: https://github.com/swaywm/wlroots/issues/1267
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/atomic.c21
-rw-r--r--backend/drm/properties.c1
2 files changed, 22 insertions, 0 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
index 35dca7d4..a1774f9c 100644
--- a/backend/drm/atomic.c
+++ b/backend/drm/atomic.c
@@ -201,6 +201,18 @@ static bool atomic_crtc_commit(struct wlr_drm_connector *conn,
}
}
+ uint32_t fb_damage_clips = 0;
+ if ((state->committed & WLR_OUTPUT_STATE_DAMAGE) &&
+ crtc->primary->props.fb_damage_clips != 0) {
+ int rects_len;
+ const pixman_box32_t *rects = pixman_region32_rectangles(
+ (pixman_region32_t *)&state->damage, &rects_len);
+ if (drmModeCreatePropertyBlob(drm->fd, rects,
+ sizeof(*rects) * rects_len, &fb_damage_clips) != 0) {
+ wlr_log_errno(WLR_ERROR, "Failed to create FB_DAMAGE_CLIPS property blob");
+ }
+ }
+
bool prev_vrr_enabled =
output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED;
bool vrr_enabled = prev_vrr_enabled;
@@ -235,6 +247,10 @@ static bool atomic_crtc_commit(struct wlr_drm_connector *conn,
atomic_add(&atom, crtc->id, crtc->props.vrr_enabled, vrr_enabled);
}
set_plane_props(&atom, drm, crtc->primary, crtc->id, 0, 0);
+ if (crtc->primary->props.fb_damage_clips != 0) {
+ atomic_add(&atom, crtc->primary->id,
+ crtc->primary->props.fb_damage_clips, fb_damage_clips);
+ }
if (crtc->cursor) {
if (drm_connector_is_cursor_visible(conn)) {
set_plane_props(&atom, drm, crtc->cursor, crtc->id,
@@ -269,6 +285,11 @@ static bool atomic_crtc_commit(struct wlr_drm_connector *conn,
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");
+ }
+
return ok;
}
diff --git a/backend/drm/properties.c b/backend/drm/properties.c
index 5581a130..637eb4bd 100644
--- a/backend/drm/properties.c
+++ b/backend/drm/properties.c
@@ -47,6 +47,7 @@ static const struct prop_info plane_info[] = {
{ "CRTC_W", INDEX(crtc_w) },
{ "CRTC_X", INDEX(crtc_x) },
{ "CRTC_Y", INDEX(crtc_y) },
+ { "FB_DAMAGE_CLIPS", INDEX(fb_damage_clips) },
{ "FB_ID", INDEX(fb_id) },
{ "IN_FORMATS", INDEX(in_formats) },
{ "SRC_H", INDEX(src_h) },