drm/atomic: Add __drm_atomic_helper_connector_reset, v2.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Mon, 4 Jan 2016 11:53:16 +0000 (12:53 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 5 Jan 2016 08:40:58 +0000 (09:40 +0100)
This is useful for drivers that subclass connector_state, like tegra.

Changes since v1:
- Docbook updates.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1451908400-25147-2-git-send-email-maarten.lankhorst@linux.intel.com
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_atomic_helper.c
include/drm/drm_atomic_helper.h

index 268d37f26960f681266790d41d104c4a353c11b6..26d258d0618b529cdbb05a21b90ad65885f4cf4e 100644 (file)
@@ -2605,6 +2605,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 - reset state on connector
+ * @connector: drm connector
+ * @conn_state: connector state to assign
+ *
+ * Initializes the newly allocated @conn_state and assigns it to
+ * #connector ->state, usually required 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
@@ -2615,11 +2637,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);
 
index a286cce98720fc46ac8b6cc981200f929e30b8bd..89d008dc08e2e2c6caa1d1d5eeb1ac3bdedd2474 100644 (file)
@@ -126,6 +126,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,