drm_damage_helper.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /**************************************************************************
  3. *
  4. * Copyright (c) 2018 VMware, Inc., Palo Alto, CA., USA
  5. * All Rights Reserved.
  6. *
  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:
  14. *
  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.
  18. *
  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.
  26. *
  27. * Authors:
  28. * Deepak Rawat <drawat@vmware.com>
  29. *
  30. **************************************************************************/
  31. #ifndef DRM_DAMAGE_HELPER_H_
  32. #define DRM_DAMAGE_HELPER_H_
  33. #include <drm/drm_atomic_helper.h>
  34. /**
  35. * drm_atomic_for_each_plane_damage - Iterator macro for plane damage.
  36. * @iter: The iterator to advance.
  37. * @rect: Return a rectangle in fb coordinate clipped to plane src.
  38. *
  39. * Note that if the first call to iterator macro return false then no need to do
  40. * plane update. Iterator will return full plane src when damage is not passed
  41. * by user-space.
  42. */
  43. #define drm_atomic_for_each_plane_damage(iter, rect) \
  44. while (drm_atomic_helper_damage_iter_next(iter, rect))
  45. /**
  46. * struct drm_atomic_helper_damage_iter - Closure structure for damage iterator.
  47. *
  48. * This structure tracks state needed to walk the list of plane damage clips.
  49. */
  50. struct drm_atomic_helper_damage_iter {
  51. /* private: Plane src in whole number. */
  52. struct drm_rect plane_src;
  53. /* private: Rectangles in plane damage blob. */
  54. const struct drm_rect *clips;
  55. /* private: Number of rectangles in plane damage blob. */
  56. uint32_t num_clips;
  57. /* private: Current clip iterator is advancing on. */
  58. uint32_t curr_clip;
  59. /* private: Whether need full plane update. */
  60. bool full_update;
  61. };
  62. void drm_plane_enable_fb_damage_clips(struct drm_plane *plane);
  63. void drm_atomic_helper_check_plane_damage(struct drm_atomic_state *state,
  64. struct drm_plane_state *plane_state);
  65. int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
  66. struct drm_file *file_priv, unsigned int flags,
  67. unsigned int color, struct drm_clip_rect *clips,
  68. unsigned int num_clips);
  69. void
  70. drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
  71. const struct drm_plane_state *old_state,
  72. const struct drm_plane_state *new_state);
  73. bool
  74. drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,
  75. struct drm_rect *rect);
  76. bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state,
  77. struct drm_plane_state *state,
  78. struct drm_rect *rect);
  79. /**
  80. * drm_helper_get_plane_damage_clips - Returns damage clips in &drm_rect.
  81. * @state: Plane state.
  82. *
  83. * Returns plane damage rectangles in internal &drm_rect. Currently &drm_rect
  84. * can be obtained by simply typecasting &drm_mode_rect. This is because both
  85. * are signed 32 and during drm_atomic_check_only() it is verified that damage
  86. * clips are inside fb.
  87. *
  88. * Return: Clips in plane fb_damage_clips blob property.
  89. */
  90. static inline struct drm_rect *
  91. drm_helper_get_plane_damage_clips(const struct drm_plane_state *state)
  92. {
  93. return (struct drm_rect *)drm_plane_get_damage_clips(state);
  94. }
  95. #endif