Re: [PATCH v2 2/6] drm/atomic: Add __drm_atomic_helper_connector_reset, v2.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 04, 2016 at 12:53:16PM +0100, Maarten Lankhorst wrote:
> This is useful for drivers that subclass connector_state, like tegra.
> 
> Changes since v1:
> - Docbook updates.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
> ---
>  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 63f925b75357..27dd68f946e6 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2607,6 +2607,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);

It's a bit strange that we don't have __*reset functions for crtc/plane
now, especially since that would uncover that probably we should move
cleaning up the old state into this helper (to share more code). That can
be done by simply calling ->atomic_state_destroy. Callers would then only
allocate a suitable struct, call this func and init any driver-private
state.

But this here won't hurt, so merged it.
-Daniel

> +
> +/**
>   * drm_atomic_helper_connector_reset - default ->reset hook for connectors
>   * @connector: drm connector
>   *
> @@ -2616,11 +2638,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 a286cce98720..89d008dc08e2 100644
> --- a/include/drm/drm_atomic_helper.h
> +++ b/include/drm/drm_atomic_helper.h
> @@ -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,
> -- 
> 2.1.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux