Merge tag 'locking-urgent-2020-08-15' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / include / drm / drm_damage_helper.h
blob40c34a5bf1498223760b99146dd99159697abb11
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /**************************************************************************
4 * Copyright (c) 2018 VMware, Inc., Palo Alto, CA., USA
5 * All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Authors:
28 * Deepak Rawat <drawat@vmware.com>
30 **************************************************************************/
32 #ifndef DRM_DAMAGE_HELPER_H_
33 #define DRM_DAMAGE_HELPER_H_
35 #include <drm/drm_atomic_helper.h>
37 /**
38 * drm_atomic_for_each_plane_damage - Iterator macro for plane damage.
39 * @iter: The iterator to advance.
40 * @rect: Return a rectangle in fb coordinate clipped to plane src.
42 * Note that if the first call to iterator macro return false then no need to do
43 * plane update. Iterator will return full plane src when damage is not passed
44 * by user-space.
46 #define drm_atomic_for_each_plane_damage(iter, rect) \
47 while (drm_atomic_helper_damage_iter_next(iter, rect))
49 /**
50 * struct drm_atomic_helper_damage_iter - Closure structure for damage iterator.
52 * This structure tracks state needed to walk the list of plane damage clips.
54 struct drm_atomic_helper_damage_iter {
55 /* private: Plane src in whole number. */
56 struct drm_rect plane_src;
57 /* private: Rectangles in plane damage blob. */
58 const struct drm_rect *clips;
59 /* private: Number of rectangles in plane damage blob. */
60 uint32_t num_clips;
61 /* private: Current clip iterator is advancing on. */
62 uint32_t curr_clip;
63 /* private: Whether need full plane update. */
64 bool full_update;
67 void drm_plane_enable_fb_damage_clips(struct drm_plane *plane);
68 void drm_atomic_helper_check_plane_damage(struct drm_atomic_state *state,
69 struct drm_plane_state *plane_state);
70 int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
71 struct drm_file *file_priv, unsigned int flags,
72 unsigned int color, struct drm_clip_rect *clips,
73 unsigned int num_clips);
74 void
75 drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
76 const struct drm_plane_state *old_state,
77 const struct drm_plane_state *new_state);
78 bool
79 drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,
80 struct drm_rect *rect);
81 bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state,
82 struct drm_plane_state *state,
83 struct drm_rect *rect);
85 /**
86 * drm_helper_get_plane_damage_clips - Returns damage clips in &drm_rect.
87 * @state: Plane state.
89 * Returns plane damage rectangles in internal &drm_rect. Currently &drm_rect
90 * can be obtained by simply typecasting &drm_mode_rect. This is because both
91 * are signed 32 and during drm_atomic_check_only() it is verified that damage
92 * clips are inside fb.
94 * Return: Clips in plane fb_damage_clips blob property.
96 static inline struct drm_rect *
97 drm_helper_get_plane_damage_clips(const struct drm_plane_state *state)
99 return (struct drm_rect *)drm_plane_get_damage_clips(state);
102 #endif