aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_damage_helper.c
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2019-01-15 05:36:40 +0100
committerNoralf Trønnes <noralf@tronnes.org>2019-01-17 10:56:54 +0100
commit255f6fe736f4ed78e0f0eac1d6188137db798b51 (patch)
tree59077b0d104922d61645011f04e299914216f3aa /drivers/gpu/drm/drm_damage_helper.c
parentdrm/gem-fb-helper: Add drm_gem_fb_create_with_dirty() (diff)
downloadlinux-dev-255f6fe736f4ed78e0f0eac1d6188137db798b51.tar.xz
linux-dev-255f6fe736f4ed78e0f0eac1d6188137db798b51.zip
drm/damage-helper: Add drm_atomic_helper_damage_merged()
Useful for drivers that only care about the combined damage. v2: Remove unnecessary clearing of damage clips Cc: Deepak Rawat <drawat@vmware.com> Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20190115043643.2364-3-noralf@tronnes.org
Diffstat (limited to 'drivers/gpu/drm/drm_damage_helper.c')
-rw-r--r--drivers/gpu/drm/drm_damage_helper.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c
index 31032407254d..e16aa5ae00b4 100644
--- a/drivers/gpu/drm/drm_damage_helper.c
+++ b/drivers/gpu/drm/drm_damage_helper.c
@@ -333,3 +333,44 @@ drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,
return ret;
}
EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next);
+
+/**
+ * drm_atomic_helper_damage_merged - Merged plane damage
+ * @old_state: Old plane state for validation.
+ * @state: Plane state from which to iterate the damage clips.
+ * @rect: Returns the merged damage rectangle
+ *
+ * This function merges any valid plane damage clips into one rectangle and
+ * returns it in @rect.
+ *
+ * For details see: drm_atomic_helper_damage_iter_init() and
+ * drm_atomic_helper_damage_iter_next().
+ *
+ * Returns:
+ * True if there is valid plane damage otherwise false.
+ */
+bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state,
+ struct drm_plane_state *state,
+ struct drm_rect *rect)
+{
+ struct drm_atomic_helper_damage_iter iter;
+ struct drm_rect clip;
+ bool valid = false;
+
+ rect->x1 = INT_MAX;
+ rect->y1 = INT_MAX;
+ rect->x2 = 0;
+ rect->y2 = 0;
+
+ drm_atomic_helper_damage_iter_init(&iter, old_state, state);
+ drm_atomic_for_each_plane_damage(&iter, &clip) {
+ rect->x1 = min(rect->x1, clip.x1);
+ rect->y1 = min(rect->y1, clip.y1);
+ rect->x2 = max(rect->x2, clip.x2);
+ rect->y2 = max(rect->y2, clip.y2);
+ valid = true;
+ }
+
+ return valid;
+}
+EXPORT_SYMBOL(drm_atomic_helper_damage_merged);