[PATCH] drm/ast: Inline drm_simple_encoder_init()

Jocelyn Falempe jfalempe at redhat.com
Tue Jun 25 13:55:09 UTC 2024



On 25/06/2024 15:18, Thomas Zimmermann wrote:
> The function drm_simple_encoder_init() is a trivial helper and
> deprecated. Replace it with the regular call to drm_encoder_init().
> Resolves the dependency on drm_simple_kms_helper.h. No functional
> changes.

Do you think it's possible to add a default to drm_encoder_init() to 
avoid having to declare the same struct for each encoder ?

something like:

drm_encoder_init(...)
{

if (!funcs)
	funcs = &drm_encoder_default_funcs;

So you can call it like this to get the default funcs:

drm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_DAC, NULL);


I don't see this pattern in other drm functions, so it might not fit the 
current coding style.

Best regards,

-- 

Jocelyn

> 
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
>   drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++----
>   1 file changed, 40 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 6695af70768f..2fd9c78eab73 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -45,7 +45,6 @@
>   #include <drm/drm_managed.h>
>   #include <drm/drm_panic.h>
>   #include <drm/drm_probe_helper.h>
> -#include <drm/drm_simple_kms_helper.h>
>   
>   #include "ast_ddc.h"
>   #include "ast_drv.h"
> @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)
>   	return 0;
>   }
>   
> +/*
> + * VGA Encoder
> + */
> +
> +static const struct drm_encoder_funcs ast_vga_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
>   /*
>    * VGA Connector
>    */
> @@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)
>   	struct drm_connector *connector = &ast->output.vga.connector;
>   	int ret;
>   
> -	ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_DAC);
> +	ret = drm_encoder_init(dev, encoder, &ast_vga_encoder_funcs,
> +			       DRM_MODE_ENCODER_DAC, NULL);
>   	if (ret)
>   		return ret;
>   	encoder->possible_crtcs = drm_crtc_mask(crtc);
> @@ -1427,6 +1435,14 @@ static int ast_vga_output_init(struct ast_device *ast)
>   	return 0;
>   }
>   
> +/*
> + * SIL164 Encoder
> + */
> +
> +static const struct drm_encoder_funcs ast_sil164_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
>   /*
>    * SIL164 Connector
>    */
> @@ -1480,7 +1496,8 @@ static int ast_sil164_output_init(struct ast_device *ast)
>   	struct drm_connector *connector = &ast->output.sil164.connector;
>   	int ret;
>   
> -	ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_TMDS);
> +	ret = drm_encoder_init(dev, encoder, &ast_sil164_encoder_funcs,
> +			       DRM_MODE_ENCODER_TMDS, NULL);
>   	if (ret)
>   		return ret;
>   	encoder->possible_crtcs = drm_crtc_mask(crtc);
> @@ -1496,6 +1513,14 @@ static int ast_sil164_output_init(struct ast_device *ast)
>   	return 0;
>   }
>   
> +/*
> + * DP501 Encoder
> + */
> +
> +static const struct drm_encoder_funcs ast_dp501_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
>   /*
>    * DP501 Connector
>    */
> @@ -1578,7 +1603,8 @@ static int ast_dp501_output_init(struct ast_device *ast)
>   	struct drm_connector *connector = &ast->output.dp501.connector;
>   	int ret;
>   
> -	ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_TMDS);
> +	ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs,
> +			       DRM_MODE_ENCODER_TMDS, NULL);
>   	if (ret)
>   		return ret;
>   	encoder->possible_crtcs = drm_crtc_mask(crtc);
> @@ -1594,6 +1620,14 @@ static int ast_dp501_output_init(struct ast_device *ast)
>   	return 0;
>   }
>   
> +/*
> + * ASPEED Display-Port Encoder
> + */
> +
> +static const struct drm_encoder_funcs ast_astdp_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
>   /*
>    * ASPEED Display-Port Connector
>    */
> @@ -1688,7 +1722,8 @@ static int ast_astdp_output_init(struct ast_device *ast)
>   	struct drm_connector *connector = &ast->output.astdp.connector;
>   	int ret;
>   
> -	ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_TMDS);
> +	ret = drm_encoder_init(dev, encoder, &ast_astdp_encoder_funcs,
> +			       DRM_MODE_ENCODER_TMDS, NULL);
>   	if (ret)
>   		return ret;
>   	encoder->possible_crtcs = drm_crtc_mask(crtc);



More information about the dri-devel mailing list