/* SPDX-License-Identifier: GPL-2.0 OR MIT */1/**************************************************************************2*3* Copyright (c) 2018 VMware, Inc., Palo Alto, CA., USA4* All Rights Reserved.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the8* "Software"), to deal in the Software without restriction, including9* without limitation the rights to use, copy, modify, merge, publish,10* distribute, sub license, and/or sell copies of the Software, and to11* permit persons to whom the Software is furnished to do so, subject to12* the following conditions:13*14* The above copyright notice and this permission notice (including the15* next paragraph) shall be included in all copies or substantial portions16* of the Software.17*18* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR19* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,20* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL21* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,22* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR23* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE24* USE OR OTHER DEALINGS IN THE SOFTWARE.25*26* Authors:27* Deepak Rawat <[email protected]>28*29**************************************************************************/3031#ifndef DRM_DAMAGE_HELPER_H_32#define DRM_DAMAGE_HELPER_H_3334#include <drm/drm_atomic_helper.h>3536/**37* drm_atomic_for_each_plane_damage - Iterator macro for plane damage.38* @iter: The iterator to advance.39* @rect: Return a rectangle in fb coordinate clipped to plane src.40*41* Note that if the first call to iterator macro return false then no need to do42* plane update. Iterator will return full plane src when damage is not passed43* by user-space.44*/45#define drm_atomic_for_each_plane_damage(iter, rect) \46while (drm_atomic_helper_damage_iter_next(iter, rect))4748/**49* struct drm_atomic_helper_damage_iter - Closure structure for damage iterator.50*51* This structure tracks state needed to walk the list of plane damage clips.52*/53struct drm_atomic_helper_damage_iter {54/* private: Plane src in whole number. */55struct drm_rect plane_src;56/* private: Rectangles in plane damage blob. */57const struct drm_rect *clips;58/* private: Number of rectangles in plane damage blob. */59uint32_t num_clips;60/* private: Current clip iterator is advancing on. */61uint32_t curr_clip;62/* private: Whether need full plane update. */63bool full_update;64};6566void drm_atomic_helper_check_plane_damage(struct drm_atomic_state *state,67struct drm_plane_state *plane_state);68int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,69struct drm_file *file_priv, unsigned int flags,70unsigned int color, struct drm_clip_rect *clips,71unsigned int num_clips);72void73drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,74const struct drm_plane_state *old_state,75const struct drm_plane_state *new_state);76bool77drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,78struct drm_rect *rect);79bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state,80const struct drm_plane_state *state,81struct drm_rect *rect);8283#endif848586