1d3b21767SLukasz Spintzyk /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2d3b21767SLukasz Spintzyk /************************************************************************** 3d3b21767SLukasz Spintzyk * 4d3b21767SLukasz Spintzyk * Copyright (c) 2018 VMware, Inc., Palo Alto, CA., USA 5d3b21767SLukasz Spintzyk * All Rights Reserved. 6d3b21767SLukasz Spintzyk * 7d3b21767SLukasz Spintzyk * Permission is hereby granted, free of charge, to any person obtaining a 8d3b21767SLukasz Spintzyk * copy of this software and associated documentation files (the 9d3b21767SLukasz Spintzyk * "Software"), to deal in the Software without restriction, including 10d3b21767SLukasz Spintzyk * without limitation the rights to use, copy, modify, merge, publish, 11d3b21767SLukasz Spintzyk * distribute, sub license, and/or sell copies of the Software, and to 12d3b21767SLukasz Spintzyk * permit persons to whom the Software is furnished to do so, subject to 13d3b21767SLukasz Spintzyk * the following conditions: 14d3b21767SLukasz Spintzyk * 15d3b21767SLukasz Spintzyk * The above copyright notice and this permission notice (including the 16d3b21767SLukasz Spintzyk * next paragraph) shall be included in all copies or substantial portions 17d3b21767SLukasz Spintzyk * of the Software. 18d3b21767SLukasz Spintzyk * 19d3b21767SLukasz Spintzyk * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20d3b21767SLukasz Spintzyk * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21d3b21767SLukasz Spintzyk * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 22d3b21767SLukasz Spintzyk * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 23d3b21767SLukasz Spintzyk * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 24d3b21767SLukasz Spintzyk * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25d3b21767SLukasz Spintzyk * USE OR OTHER DEALINGS IN THE SOFTWARE. 26d3b21767SLukasz Spintzyk * 27d3b21767SLukasz Spintzyk * Authors: 28d3b21767SLukasz Spintzyk * Deepak Rawat <drawat@vmware.com> 29d3b21767SLukasz Spintzyk * 30d3b21767SLukasz Spintzyk **************************************************************************/ 31d3b21767SLukasz Spintzyk 32d3b21767SLukasz Spintzyk #ifndef DRM_DAMAGE_HELPER_H_ 33d3b21767SLukasz Spintzyk #define DRM_DAMAGE_HELPER_H_ 34d3b21767SLukasz Spintzyk 35d3b21767SLukasz Spintzyk #include <drm/drm_atomic_helper.h> 36d3b21767SLukasz Spintzyk 37d2780b1fSDeepak Rawat /** 38d2780b1fSDeepak Rawat * drm_atomic_for_each_plane_damage - Iterator macro for plane damage. 39d2780b1fSDeepak Rawat * @iter: The iterator to advance. 40d2780b1fSDeepak Rawat * @rect: Return a rectangle in fb coordinate clipped to plane src. 41d2780b1fSDeepak Rawat * 42d2780b1fSDeepak Rawat * Note that if the first call to iterator macro return false then no need to do 43d2780b1fSDeepak Rawat * plane update. Iterator will return full plane src when damage is not passed 44d2780b1fSDeepak Rawat * by user-space. 45d2780b1fSDeepak Rawat */ 46d2780b1fSDeepak Rawat #define drm_atomic_for_each_plane_damage(iter, rect) \ 47d2780b1fSDeepak Rawat while (drm_atomic_helper_damage_iter_next(iter, rect)) 48d2780b1fSDeepak Rawat 49d2780b1fSDeepak Rawat /** 50d2780b1fSDeepak Rawat * struct drm_atomic_helper_damage_iter - Closure structure for damage iterator. 51d2780b1fSDeepak Rawat * 52d2780b1fSDeepak Rawat * This structure tracks state needed to walk the list of plane damage clips. 53d2780b1fSDeepak Rawat */ 54d2780b1fSDeepak Rawat struct drm_atomic_helper_damage_iter { 55d2780b1fSDeepak Rawat /* private: Plane src in whole number. */ 56d2780b1fSDeepak Rawat struct drm_rect plane_src; 57d2780b1fSDeepak Rawat /* private: Rectangles in plane damage blob. */ 58d2780b1fSDeepak Rawat const struct drm_rect *clips; 59d2780b1fSDeepak Rawat /* private: Number of rectangles in plane damage blob. */ 60d2780b1fSDeepak Rawat uint32_t num_clips; 61d2780b1fSDeepak Rawat /* private: Current clip iterator is advancing on. */ 62d2780b1fSDeepak Rawat uint32_t curr_clip; 63d2780b1fSDeepak Rawat /* private: Whether need full plane update. */ 64d2780b1fSDeepak Rawat bool full_update; 65d2780b1fSDeepak Rawat }; 66d2780b1fSDeepak Rawat 67d9778b40SDeepak Rawat void drm_atomic_helper_check_plane_damage(struct drm_atomic_state *state, 68d9778b40SDeepak Rawat struct drm_plane_state *plane_state); 69b9fc5e01SRob Clark int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb, 70b9fc5e01SRob Clark struct drm_file *file_priv, unsigned int flags, 71b9fc5e01SRob Clark unsigned int color, struct drm_clip_rect *clips, 72b9fc5e01SRob Clark unsigned int num_clips); 73d2780b1fSDeepak Rawat void 74d2780b1fSDeepak Rawat drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, 75d2780b1fSDeepak Rawat const struct drm_plane_state *old_state, 76d2780b1fSDeepak Rawat const struct drm_plane_state *new_state); 77d2780b1fSDeepak Rawat bool 78d2780b1fSDeepak Rawat drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, 79d2780b1fSDeepak Rawat struct drm_rect *rect); 80255f6fe7SNoralf Trønnes bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, 81255f6fe7SNoralf Trønnes struct drm_plane_state *state, 82255f6fe7SNoralf Trønnes struct drm_rect *rect); 83d2780b1fSDeepak Rawat 84d3b21767SLukasz Spintzyk #endif 85