[PATCH 05/18] drm/amd/display: Return drm_connector from find_first_crtc_matching_connector

Alex Hung alex.hung at amd.com
Tue Sep 5 18:47:55 UTC 2023


Reviewed-by: Alex Hung <alex.hung at amd.com>

On 2023-08-16 15:26, Alex Hung wrote:
> From: Harry Wentland <harry.wentland at amd.com>
> 
> [WHY]
> We will be dealing with two types of connector: amdgpu_dm_connector
> and drm_writeback_connector.
> 
> [HOW]
> We want to find both and then cast to the appriopriate type afterwards.
> 
> Signed-off-by: Harry Wentland <harry.wentland at amd.com>
> Signed-off-by: Alex Hung <alex.hung at amd.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c         | 8 +++++---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h         | 2 +-
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c   | 4 +++-
>   3 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 363d91d49a3a..7bd3ec84ff2e 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -2630,7 +2630,7 @@ static int dm_suspend(void *handle)
>   	return 0;
>   }
>   
> -struct amdgpu_dm_connector *
> +struct drm_connector *
>   amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
>   					     struct drm_crtc *crtc)
>   {
> @@ -2643,7 +2643,7 @@ amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
>   		crtc_from_state = new_con_state->crtc;
>   
>   		if (crtc_from_state == crtc)
> -			return to_amdgpu_dm_connector(connector);
> +			return connector;
>   	}
>   
>   	return NULL;
> @@ -9263,6 +9263,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
>   	 * update changed items
>   	 */
>   	struct amdgpu_crtc *acrtc = NULL;
> +	struct drm_connector *connector = NULL;
>   	struct amdgpu_dm_connector *aconnector = NULL;
>   	struct drm_connector_state *drm_new_conn_state = NULL, *drm_old_conn_state = NULL;
>   	struct dm_connector_state *dm_new_conn_state = NULL, *dm_old_conn_state = NULL;
> @@ -9272,7 +9273,8 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
>   	dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
>   	dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
>   	acrtc = to_amdgpu_crtc(crtc);
> -	aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
> +	connector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
> +	aconnector = to_amdgpu_dm_connector(connector);
>   
>   	/* TODO This hack should go away */
>   	if (aconnector && enable) {
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> index a2d34be82613..5a8d07a27e9b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
> @@ -836,7 +836,7 @@ struct dc_stream_state *
>   int dm_atomic_get_state(struct drm_atomic_state *state,
>   			struct dm_atomic_state **dm_state);
>   
> -struct amdgpu_dm_connector *
> +struct drm_connector *
>   amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
>   					     struct drm_crtc *crtc);
>   
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> index 57230661132b..1975b9d96cb8 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> @@ -1494,14 +1494,16 @@ int pre_validate_dsc(struct drm_atomic_state *state,
>   		int ind = find_crtc_index_in_state_by_stream(state, stream);
>   
>   		if (ind >= 0) {
> +			struct drm_connector *connector;
>   			struct amdgpu_dm_connector *aconnector;
>   			struct drm_connector_state *drm_new_conn_state;
>   			struct dm_connector_state *dm_new_conn_state;
>   			struct dm_crtc_state *dm_old_crtc_state;
>   
> -			aconnector =
> +			connector =
>   				amdgpu_dm_find_first_crtc_matching_connector(state,
>   									     state->crtcs[ind].ptr);
> +			aconnector = to_amdgpu_dm_connector(connector);
>   			drm_new_conn_state =
>   				drm_atomic_get_new_connector_state(state,
>   								   &aconnector->base);


More information about the amd-gfx mailing list