To support drm_panic, most drivers need to find the current primary
visible plane with a framebuffer attached.

Signed-off-by: Jocelyn Falempe <jfale...@redhat.com>
---
 include/drm/drm_plane.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index c6565a6f9324..41c08a2ddf8d 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -948,6 +948,21 @@ static inline struct drm_plane *drm_plane_find(struct 
drm_device *dev,
        list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
                for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY)
 
+/**
+ * drm_for_each_primary_visible_plane - iterate over all primary visible planes
+ * @plane: the loop cursor
+ * @dev: the DRM device
+ *
+ * Iterate over all primary, visible plane, with a framebuffer.
+ * This is useful for drm_panic, to find the current scanout buffer.
+ */
+#define drm_for_each_primary_visible_plane(plane, dev) \
+       list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
+               for_each_if((plane)->type == DRM_PLANE_TYPE_PRIMARY && \
+                           (plane)->state && \
+                           (plane)->state->fb && \
+                           (plane)->state->visible)
+
 /**
  * drm_for_each_plane - iterate over all planes
  * @plane: the loop cursor
-- 
2.43.0

Reply via email to