[PATCH v2 13/21] drm/bridge: Patch atomic hooks to take a drm_bridge_state

Neil Armstrong narmstrong at baylibre.com
Tue Aug 27 07:29:37 UTC 2019


On 26/08/2019 17:26, Boris Brezillon wrote:
> Instead of a drm_atomic_state. The only driver implementing those hooks
> is patched too.
> 
> While at it, adjust the documentation and argument names to clarify the
> fact that the state being passed to those functions/hooks is the old
> state.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>

Reviewed-by: Neil Armstrong <narmstrong at baylibre.com>

> ---
> Changes in v2:
> * Pass the old bridge state
> ---
>  .../drm/bridge/analogix/analogix_dp_core.c    | 12 ++-
>  drivers/gpu/drm/drm_bridge.c                  | 73 ++++++++++++++-----
>  include/drm/drm_bridge.h                      | 23 ++++--
>  3 files changed, 76 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index bb411fe52ae8..e438e757f2ce 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1290,8 +1290,9 @@ struct drm_crtc *analogix_dp_get_new_crtc(struct analogix_dp_device *dp,
>  }
>  
>  static void analogix_dp_bridge_atomic_pre_enable(struct drm_bridge *bridge,
> -						 struct drm_atomic_state *state)
> +						 struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *old_crtc_state;
> @@ -1367,8 +1368,9 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp)
>  }
>  
>  static void analogix_dp_bridge_atomic_enable(struct drm_bridge *bridge,
> -					     struct drm_atomic_state *state)
> +					     struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *old_crtc_state;
> @@ -1441,8 +1443,9 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)
>  }
>  
>  static void analogix_dp_bridge_atomic_disable(struct drm_bridge *bridge,
> -					      struct drm_atomic_state *state)
> +					      struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *new_crtc_state = NULL;
> @@ -1465,8 +1468,9 @@ static void analogix_dp_bridge_atomic_disable(struct drm_bridge *bridge,
>  
>  static
>  void analogix_dp_bridge_atomic_post_disable(struct drm_bridge *bridge,
> -					    struct drm_atomic_state *state)
> +					    struct drm_bridge_state *bstate)
>  {
> +	struct drm_atomic_state *state = bstate->base.state;
>  	struct analogix_dp_device *dp = bridge->driver_private;
>  	struct drm_crtc *crtc;
>  	struct drm_crtc_state *new_crtc_state;
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 6c2d7691455b..5c83cac7975e 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -437,7 +437,7 @@ EXPORT_SYMBOL(drm_bridge_chain_enable);
>  /**
>   * drm_atomic_bridge_chain_disable - disables all bridges in the encoder chain
>   * @bridge: bridge control structure
> - * @state: atomic state being committed
> + * @old_state: old atomic state
>   *
>   * Calls &drm_bridge_funcs.atomic_disable (falls back on
>   * &drm_bridge_funcs.disable) op for all the bridges in the encoder chain,
> @@ -447,16 +447,24 @@ EXPORT_SYMBOL(drm_bridge_chain_enable);
>   * Note: the bridge passed should be the one closest to the encoder
>   */
>  void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge,
> -				     struct drm_atomic_state *state)
> +				     struct drm_atomic_state *old_state)
>  {
>  	struct drm_encoder *encoder = bridge->encoder;
>  	struct drm_bridge *iter;
>  
>  	list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
> -		if (iter->funcs->atomic_disable)
> -			iter->funcs->atomic_disable(iter, state);
> -		else if (iter->funcs->disable)
> +		if (iter->funcs->atomic_disable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_old_bridge_state(old_state,
> +								       iter);
> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			iter->funcs->atomic_disable(iter, bridge_state);
> +		} else if (iter->funcs->disable) {
>  			iter->funcs->disable(iter);
> +		}
>  
>  		if (iter == bridge)
>  			break;
> @@ -468,7 +476,7 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_disable);
>   * drm_atomic_bridge_chain_post_disable - cleans up after disabling all bridges
>   *					  in the encoder chain
>   * @bridge: bridge control structure
> - * @state: atomic state being committed
> + * @old_state: old atomic state
>   *
>   * Calls &drm_bridge_funcs.atomic_post_disable (falls back on
>   * &drm_bridge_funcs.post_disable) op for all the bridges in the encoder chain,
> @@ -478,15 +486,24 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_disable);
>   * Note: the bridge passed should be the one closest to the encoder
>   */
>  void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
> -					  struct drm_atomic_state *state)
> +					  struct drm_atomic_state *old_state)
>  {
>  	struct drm_encoder *encoder = bridge->encoder;
>  
>  	list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
> -		if (bridge->funcs->atomic_post_disable)
> -			bridge->funcs->atomic_post_disable(bridge, state);
> -		else if (bridge->funcs->post_disable)
> +		if (bridge->funcs->atomic_post_disable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_old_bridge_state(old_state,
> +								       bridge);
> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			bridge->funcs->atomic_post_disable(bridge,
> +							   bridge_state);
> +		} else if (bridge->funcs->post_disable) {
>  			bridge->funcs->post_disable(bridge);
> +		}
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable);
> @@ -495,7 +512,7 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable);
>   * drm_atomic_bridge_chain_pre_enable - prepares for enabling all bridges in
>   *					the encoder chain
>   * @bridge: bridge control structure
> - * @state: atomic state being committed
> + * @old_state: old atomic state
>   *
>   * Calls &drm_bridge_funcs.atomic_pre_enable (falls back on
>   * &drm_bridge_funcs.pre_enable) op for all the bridges in the encoder chain,
> @@ -505,16 +522,24 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable);
>   * Note: the bridge passed should be the one closest to the encoder
>   */
>  void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
> -					struct drm_atomic_state *state)
> +					struct drm_atomic_state *old_state)
>  {
>  	struct drm_encoder *encoder = bridge->encoder;
>  	struct drm_bridge *iter;
>  
>  	list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
> -		if (iter->funcs->atomic_pre_enable)
> -			iter->funcs->atomic_pre_enable(iter, state);
> -		else if (iter->funcs->pre_enable)
> +		if (iter->funcs->atomic_pre_enable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_old_bridge_state(old_state,
> +								       iter);
> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			iter->funcs->atomic_pre_enable(iter, bridge_state);
> +		} else if (iter->funcs->pre_enable) {
>  			iter->funcs->pre_enable(iter);
> +		}
>  
>  		if (iter == bridge)
>  			break;
> @@ -525,7 +550,7 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_pre_enable);
>  /**
>   * drm_atomic_bridge_chain_enable - enables all bridges in the encoder chain
>   * @bridge: bridge control structure
> - * @state: atomic state being committed
> + * @old_state: old atomic state
>   *
>   * Calls &drm_bridge_funcs.atomic_enable (falls back on
>   * &drm_bridge_funcs.enable) op for all the bridges in the encoder chain,
> @@ -535,15 +560,23 @@ EXPORT_SYMBOL(drm_atomic_bridge_chain_pre_enable);
>   * Note: the bridge passed should be the one closest to the encoder
>   */
>  void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,
> -				    struct drm_atomic_state *state)
> +				    struct drm_atomic_state *old_state)
>  {
>  	struct drm_encoder *encoder = bridge->encoder;
>  
>  	list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
> -		if (bridge->funcs->atomic_enable)
> -			bridge->funcs->atomic_enable(bridge, state);
> -		else if (bridge->funcs->enable)
> +		if (bridge->funcs->atomic_enable) {
> +			struct drm_bridge_state *bridge_state;
> +
> +			bridge_state = drm_atomic_get_old_bridge_state(old_state,
> +								       bridge);
> +			if (WARN_ON(!bridge_state))
> +				return;
> +
> +			bridge->funcs->atomic_enable(bridge, bridge_state);
> +		} else if (bridge->funcs->enable) {
>  			bridge->funcs->enable(bridge);
> +		}
>  	}
>  }
>  EXPORT_SYMBOL(drm_atomic_bridge_chain_enable);
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index 11b20e2a9fc6..231f62cd681d 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -264,7 +264,8 @@ struct drm_bridge_funcs {
>  	 * preceding element is a bridge this means it's called before that
>  	 * bridge's @atomic_pre_enable or @pre_enable function. If the preceding
>  	 * element is a &drm_encoder it's called right before the encoder's
> -	 * &drm_encoder_helper_funcs.atomic_enable hook.
> +	 * &drm_encoder_helper_funcs.atomic_enable hook. This hook is passed the
> +	 * old bridge state (the new one can be retrieved from bridge->state).
>  	 *
>  	 * The display pipe (i.e. clocks and timing signals) feeding this bridge
>  	 * will not yet be running when this callback is called. The bridge must
> @@ -280,7 +281,7 @@ struct drm_bridge_funcs {
>  	 * The @atomic_pre_enable callback is optional.
>  	 */
>  	void (*atomic_pre_enable)(struct drm_bridge *bridge,
> -				  struct drm_atomic_state *state);
> +				  struct drm_bridge_state *old_bridge_state);
>  
>  	/**
>  	 * @atomic_enable:
> @@ -290,7 +291,9 @@ struct drm_bridge_funcs {
>  	 * preceding element is a bridge this means it's called after that
>  	 * bridge's @atomic_enable or @enable function. If the preceding element
>  	 * is a &drm_encoder it's called right after the encoder's
> -	 * &drm_encoder_helper_funcs.atomic_enable hook.
> +	 * &drm_encoder_helper_funcs.atomic_enable hook. This hook is passed
> +	 * the old bridge state (the new one can be retrieved from
> +	 * bridge->state).
>  	 *
>  	 * The bridge can assume that the display pipe (i.e. clocks and timing
>  	 * signals) feeding it is running when this callback is called. This
> @@ -305,7 +308,7 @@ struct drm_bridge_funcs {
>  	 * The enable callback is optional.
>  	 */
>  	void (*atomic_enable)(struct drm_bridge *bridge,
> -			      struct drm_atomic_state *state);
> +			      struct drm_bridge_state *old_bridge_state);
>  	/**
>  	 * @atomic_disable:
>  	 *
> @@ -314,7 +317,9 @@ struct drm_bridge_funcs {
>  	 * preceding element is a bridge this means it's called before that
>  	 * bridge's @atomic_disable or @disable vfunc. If the preceding element
>  	 * is a &drm_encoder it's called right before the
> -	 * &drm_encoder_helper_funcs.atomic_disable hook.
> +	 * &drm_encoder_helper_funcs.atomic_disable hook. This hook is passed
> +	 * the old bridge state (the new one can be retrieved from
> +	 * bridge->state).
>  	 *
>  	 * The bridge can assume that the display pipe (i.e. clocks and timing
>  	 * signals) feeding it is still running when this callback is called.
> @@ -328,7 +333,7 @@ struct drm_bridge_funcs {
>  	 * The disable callback is optional.
>  	 */
>  	void (*atomic_disable)(struct drm_bridge *bridge,
> -			       struct drm_atomic_state *state);
> +			       struct drm_bridge_state *old_bridge_state);
>  
>  	/**
>  	 * @atomic_post_disable:
> @@ -338,7 +343,9 @@ struct drm_bridge_funcs {
>  	 * element is a bridge this means it's called after that bridge's
>  	 * @atomic_post_disable or @post_disable function. If the preceding
>  	 * element is a &drm_encoder it's called right after the encoder's
> -	 * &drm_encoder_helper_funcs.atomic_disable hook.
> +	 * &drm_encoder_helper_funcs.atomic_disable hook. This hook is passed
> +	 * the old bridge state (the new one can be retrieved from
> +	 * bridge->state).
>  	 *
>  	 * The bridge must assume that the display pipe (i.e. clocks and timing
>  	 * signals) feeding it is no longer running when this callback is
> @@ -354,7 +361,7 @@ struct drm_bridge_funcs {
>  	 * The post_disable callback is optional.
>  	 */
>  	void (*atomic_post_disable)(struct drm_bridge *bridge,
> -				    struct drm_atomic_state *state);
> +				    struct drm_bridge_state *old_bridge_state);
>  
>  	/**
>  	 * @atomic_duplicate_state:
> 



More information about the dri-devel mailing list