From: Maxime Ripard <mripard@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, Maxime Ripard <mripard@kernel.org>
Subject: [PATCH v2 04/16] drm/atomic-helper: Add private_obj atomic_create_state helper
Date: Tue, 14 Oct 2025 11:31:48 +0200 [thread overview]
Message-ID: <20251014-drm-private-obj-reset-v2-4-6dd60e985e9d@kernel.org> (raw)
In-Reply-To: <20251014-drm-private-obj-reset-v2-0-6dd60e985e9d@kernel.org>
Now that we have an atomic_create_state callback for drm_private_objs,
we can provide a helper for it.
It's somewhat different from the other similar helpers though, because
we definitely expect drm_private_obj to be subclassed. It wouldn't make
sense for a driver to use it as-is.
So we can't provide a straight implementation of the atomic_create_state
callback, but rather we provide the parts that will deal with the
drm_private_obj initialization, and we will leave the allocation and
initialization of the subclass to drivers.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 22 ++++++++++++++++++++++
include/drm/drm_atomic_state_helper.h | 3 +++
2 files changed, 25 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 7142e163e618ea0d7d9d828e1bd9ff2a6ec0dfeb..86e368051a21005ee867a555410bf94b1ab6a168 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -707,10 +707,32 @@ void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
__drm_atomic_helper_connector_destroy_state(state);
kfree(state);
}
EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
+/**
+ * __drm_atomic_helper_private_obj_create_state - initializes private object state
+ * @obj: private object
+ * @state: new state to initialize
+ *
+ * Initializes the newly allocated @state, usually required when
+ * initializing the drivers.
+ *
+ * @obj is assumed to be zeroed.
+ *
+ * This is useful for drivers that use private states.
+ */
+void __drm_atomic_helper_private_obj_create_state(struct drm_private_obj *obj,
+ struct drm_private_state *state)
+{
+ if (state)
+ state->obj = obj;
+
+ obj->state = state;
+}
+EXPORT_SYMBOL(__drm_atomic_helper_private_obj_create_state);
+
/**
* __drm_atomic_helper_private_obj_duplicate_state - copy atomic private state
* @obj: CRTC object
* @state: new private object state
*
diff --git a/include/drm/drm_atomic_state_helper.h b/include/drm/drm_atomic_state_helper.h
index b9740edb26586d58f99a5223902bb8e333ac75a2..900672c6ea90ba9cb87e38a7c84225972aee43c5 100644
--- a/include/drm/drm_atomic_state_helper.h
+++ b/include/drm/drm_atomic_state_helper.h
@@ -82,10 +82,13 @@ struct drm_connector_state *
drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
void
__drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state);
void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
struct drm_connector_state *state);
+
+void __drm_atomic_helper_private_obj_create_state(struct drm_private_obj *obj,
+ struct drm_private_state *state);
void __drm_atomic_helper_private_obj_duplicate_state(struct drm_private_obj *obj,
struct drm_private_state *state);
void __drm_atomic_helper_bridge_duplicate_state(struct drm_bridge *bridge,
struct drm_bridge_state *state);
--
2.51.0
next prev parent reply other threads:[~2025-10-14 12:00 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 9:31 [PATCH v2 00/16] drm/atomic: Allocate drm_private_state through a callback Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 01/16] drm/atomic: Add dev pointer to drm_private_obj Maxime Ripard
2025-10-21 8:16 ` Luca Ceresoli
2025-12-08 15:37 ` (subset) " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 02/16] drm/atomic: Make drm_atomic_private_obj_init fallible Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 03/16] drm/atomic: Add new atomic_create_state callback to drm_private_obj Maxime Ripard
2025-10-14 22:49 ` Dmitry Baryshkov
2025-10-15 0:17 ` Dmitry Baryshkov
2025-10-21 8:17 ` Luca Ceresoli
2025-12-08 15:48 ` Maxime Ripard
2025-10-14 9:31 ` Maxime Ripard [this message]
2025-10-15 0:16 ` [PATCH v2 04/16] drm/atomic-helper: Add private_obj atomic_create_state helper Dmitry Baryshkov
2025-10-14 9:31 ` [PATCH v2 05/16] drm/bridge: Switch private_obj initialization to atomic_create_state Maxime Ripard
2025-10-21 8:17 ` Luca Ceresoli
2025-12-08 15:43 ` Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 06/16] drm/dp_mst: " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 07/16] drm/dp_tunnel: " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 08/16] drm/amdgpu: " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 09/16] drm/arm: komeda: " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 10/16] drm/ingenic: " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 11/16] drm/msm: mdp5: " Maxime Ripard
2025-10-15 0:52 ` Dmitry Baryshkov
2025-10-14 9:31 ` [PATCH v2 12/16] drm/msm: dpu1: " Maxime Ripard
2025-10-15 0:52 ` Dmitry Baryshkov
2025-10-14 9:31 ` [PATCH v2 13/16] drm/omapdrm: " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 14/16] drm/tegra: " Maxime Ripard
2025-10-14 9:31 ` [PATCH v2 15/16] drm/vc4: " Maxime Ripard
2025-10-14 9:32 ` [PATCH v2 16/16] drm/atomic: Remove state argument to drm_atomic_private_obj_init Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251014-drm-private-obj-reset-v2-4-6dd60e985e9d@kernel.org \
--to=mripard@kernel.org \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox