diff mbox

[2/3] drm/atomic: Add __drm_atomic_helper_connector_reset.

Message ID 1448372134-26367-2-git-send-email-maarten.lankhorst@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maarten Lankhorst Nov. 24, 2015, 1:35 p.m. UTC
This is useful for drivers that subclass connector_state, like tegra.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 30 ++++++++++++++++++++++++++----
 include/drm/drm_atomic_helper.h     |  2 ++
 2 files changed, 28 insertions(+), 4 deletions(-)

Comments

Thierry Reding Dec. 7, 2015, 9:58 a.m. UTC | #1
On Tue, Nov 24, 2015 at 02:35:33PM +0100, Maarten Lankhorst wrote:
> This is useful for drivers that subclass connector_state, like tegra.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 30 ++++++++++++++++++++++++++----
>  include/drm/drm_atomic_helper.h     |  2 ++
>  2 files changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index cee31d43cd1c..5d23f818faec 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2359,6 +2359,28 @@ void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,
>  EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state);
>  
>  /**
> + * __drm_atomic_helper_connector_reset - default ->reset hook for connectors

That's misleading because you can't use this as a ->reset() hook as-is.
Maybe something like this would be better as a synopsis:

	__drm_atomic_helper_connector_reset - reset connector state

Then the description below gives the details about what it does and when
to use it, which looks fine to me.

> + * @connector: drm connector
> + * @conn_state: connector state to assign
> + *
> + * Initializes conn_state and assigns it to connector->state, usually
> + * required at when initializing the drivers or when called from the

s/required at/required/

Thierry
Thierry Reding Dec. 7, 2015, 9:58 a.m. UTC | #2
On Tue, Nov 24, 2015 at 02:35:33PM +0100, Maarten Lankhorst wrote:
> This is useful for drivers that subclass connector_state, like tegra.

One more nit: s/tegra/Tegra/

Thierry
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index cee31d43cd1c..5d23f818faec 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2359,6 +2359,28 @@  void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,
 EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state);
 
 /**
+ * __drm_atomic_helper_connector_reset - default ->reset hook for connectors
+ * @connector: drm connector
+ * @conn_state: connector state to assign
+ *
+ * Initializes conn_state and assigns it to connector->state, usually
+ * required at when initializing the drivers or when called from the
+ * ->reset hook.
+ *
+ * This is useful for drivers that subclass the connector state.
+ */
+void
+__drm_atomic_helper_connector_reset(struct drm_connector *connector,
+				    struct drm_connector_state *conn_state)
+{
+	if (conn_state)
+		conn_state->connector = connector;
+
+	connector->state = conn_state;
+}
+EXPORT_SYMBOL(__drm_atomic_helper_connector_reset);
+
+/**
  * drm_atomic_helper_connector_reset - default ->reset hook for connectors
  * @connector: drm connector
  *
@@ -2368,11 +2390,11 @@  EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state);
  */
 void drm_atomic_helper_connector_reset(struct drm_connector *connector)
 {
-	kfree(connector->state);
-	connector->state = kzalloc(sizeof(*connector->state), GFP_KERNEL);
+	struct drm_connector_state *conn_state =
+		kzalloc(sizeof(*conn_state), GFP_KERNEL);
 
-	if (connector->state)
-		connector->state->connector = connector;
+	kfree(connector->state);
+	__drm_atomic_helper_connector_reset(connector, conn_state);
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_reset);
 
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 8cba54a2a0a0..3e00faeea3d0 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -118,6 +118,8 @@  void __drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,
 void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,
 					  struct drm_plane_state *state);
 
+void __drm_atomic_helper_connector_reset(struct drm_connector *connector,
+					 struct drm_connector_state *conn_state);
 void drm_atomic_helper_connector_reset(struct drm_connector *connector);
 void
 __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,