Am 02.09.25 um 10:32 schrieb Maxime Ripard:
We currently have a helper to print the new states associated to a
drm_atomic_state, but we don't have a variant to print the old state.

It's somewhat expected, since we almost never care about what the new
state looks like when we commit a new state, but we're about to change
that.

Signed-off-by: Maxime Ripard <mrip...@kernel.org>

Reviewed-by: Thomas Zimmermann <tzimmerm...@suse.de>

I assume something later in the series uses this code?

---
  drivers/gpu/drm/drm_atomic.c        | 45 +++++++++++++++++++++++++++++++++++++
  drivers/gpu/drm/drm_crtc_internal.h |  2 ++
  2 files changed, 47 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 
9b198610791d19c7fd276ca59264a961d21caf43..38f2b2633fa992b3543e8c425c7faeab1ce69765
 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1875,10 +1875,55 @@ void drm_atomic_print_new_state(const struct 
drm_atomic_state *state,
        for_each_new_private_obj_in_state(state, obj, obj_state, i)
                drm_atomic_private_obj_print_state(p, obj_state);
  }
  EXPORT_SYMBOL(drm_atomic_print_new_state);
+/**
+ * drm_atomic_print_old_state - prints drm atomic state
+ * @state: atomic configuration to check
+ * @p: drm printer
+ *
+ * This functions prints the drm atomic state snapshot using the drm printer
+ * which is passed to it. This snapshot can be used for debugging purposes.
+ *
+ * Note that this function looks into the old state objects and hence its not
+ * safe to be used after the call to drm_atomic_helper_commit_hw_done().
+ */
+void drm_atomic_print_old_state(const struct drm_atomic_state *state,
+               struct drm_printer *p)
+{
+       struct drm_plane *plane;
+       struct drm_plane_state *plane_state;
+       struct drm_crtc *crtc;
+       struct drm_crtc_state *crtc_state;
+       struct drm_connector *connector;
+       struct drm_connector_state *connector_state;
+       struct drm_private_obj *obj;
+       struct drm_private_state *obj_state;
+       int i;
+
+       if (!p) {
+               drm_err(state->dev, "invalid drm printer\n");
+               return;
+       }
+
+       drm_dbg_atomic(state->dev, "checking %p\n", state);
+
+       for_each_old_plane_in_state(state, plane, plane_state, i)
+               drm_atomic_plane_print_state(p, plane_state);
+
+       for_each_old_crtc_in_state(state, crtc, crtc_state, i)
+               drm_atomic_crtc_print_state(p, crtc_state);
+
+       for_each_old_connector_in_state(state, connector, connector_state, i)
+               drm_atomic_connector_print_state(p, connector_state);
+
+       for_each_old_private_obj_in_state(state, obj, obj_state, i)
+               drm_atomic_private_obj_print_state(p, obj_state);
+}
+EXPORT_SYMBOL(drm_atomic_print_old_state);
+
  static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
                             bool take_locks)
  {
        struct drm_mode_config *config = &dev->mode_config;
        struct drm_plane *plane;
diff --git a/drivers/gpu/drm/drm_crtc_internal.h 
b/drivers/gpu/drm/drm_crtc_internal.h
index 
89706aa8232fc0b2830af67c7588985a29653299..a8139fda1a1015c2ac8d8af3b12c5ac0b00cfc1a
 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -249,10 +249,12 @@ int __drm_atomic_helper_disable_plane(struct drm_plane 
*plane,
  int __drm_atomic_helper_set_config(struct drm_mode_set *set,
                                   struct drm_atomic_state *state);
void drm_atomic_print_new_state(const struct drm_atomic_state *state,
                struct drm_printer *p);
+void drm_atomic_print_old_state(const struct drm_atomic_state *state,
+                               struct drm_printer *p);
/* drm_atomic_uapi.c */
  int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,
                                     struct drm_connector *connector,
                                     int mode);


--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


Reply via email to