[PATCH 12/15] drm/ast: Inline ast_get_vbios_mode_info()

Jocelyn Falempe jfalempe at redhat.com
Mon Jan 27 14:50:35 UTC 2025


On 24/01/2025 08:57, Thomas Zimmermann wrote:
> The helper ast_get_vbios_mode_info() retrieves hardware-specific format
> and display-mode information. Inline the function into its only caller.
> 
> While at it, also replace a use of struct drm_format_info.cpp with the
> correct DRM 4CC codes.

Thanks, it looks good to me.

Reviewed-by: Jocelyn Falempe <jfalempe at redhat.com>

-- 

Jocelyn
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
>   drivers/gpu/drm/ast/ast_mode.c | 112 ++++++++++++++++-----------------
>   1 file changed, 54 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 372abff1c8673..a823dcbf73c4b 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -107,59 +107,6 @@ static void ast_crtc_set_gamma(struct ast_device *ast,
>   	}
>   }
>   
> -static bool ast_get_vbios_mode_info(struct ast_device *ast,
> -				    const struct drm_format_info *format,
> -				    const struct drm_display_mode *mode,
> -				    struct drm_display_mode *adjusted_mode,
> -				    struct ast_vbios_mode_info *vbios_mode)
> -{
> -	u32 hborder, vborder;
> -
> -	switch (format->cpp[0] * 8) {
> -	case 8:
> -		vbios_mode->std_table = &vbios_stdtable[VGAModeIndex];
> -		break;
> -	case 16:
> -		vbios_mode->std_table = &vbios_stdtable[HiCModeIndex];
> -		break;
> -	case 24:
> -	case 32:
> -		vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex];
> -		break;
> -	default:
> -		return false;
> -	}
> -
> -	vbios_mode->enh_table = ast_vbios_find_mode(ast, mode);
> -	if (!vbios_mode->enh_table)
> -		return false;
> -
> -	hborder = (vbios_mode->enh_table->flags & HBorder) ? 8 : 0;
> -	vborder = (vbios_mode->enh_table->flags & VBorder) ? 8 : 0;
> -
> -	adjusted_mode->crtc_hdisplay = vbios_mode->enh_table->hde;
> -	adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht;
> -	adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder;
> -	adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder;
> -	adjusted_mode->crtc_hsync_start = vbios_mode->enh_table->hde + hborder +
> -		vbios_mode->enh_table->hfp;
> -	adjusted_mode->crtc_hsync_end = (vbios_mode->enh_table->hde + hborder +
> -					 vbios_mode->enh_table->hfp +
> -					 vbios_mode->enh_table->hsync);
> -
> -	adjusted_mode->crtc_vdisplay = vbios_mode->enh_table->vde;
> -	adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt;
> -	adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder;
> -	adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder;
> -	adjusted_mode->crtc_vsync_start = vbios_mode->enh_table->vde + vborder +
> -		vbios_mode->enh_table->vfp;
> -	adjusted_mode->crtc_vsync_end = (vbios_mode->enh_table->vde + vborder +
> -					 vbios_mode->enh_table->vfp +
> -					 vbios_mode->enh_table->vsync);
> -
> -	return true;
> -}
> -
>   static void ast_set_vbios_color_reg(struct ast_device *ast,
>   				    const struct drm_format_info *format,
>   				    const struct ast_vbios_mode_info *vbios_mode)
> @@ -990,13 +937,17 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
>   					struct drm_atomic_state *state)
>   {
>   	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
> +	struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
>   	struct drm_crtc_state *old_crtc_state = drm_atomic_get_old_crtc_state(state, crtc);
>   	struct ast_crtc_state *old_ast_crtc_state = to_ast_crtc_state(old_crtc_state);
>   	struct drm_device *dev = crtc->dev;
>   	struct ast_device *ast = to_ast_device(dev);
>   	struct ast_crtc_state *ast_state;
>   	const struct drm_format_info *format;
> -	bool succ;
> +	struct ast_vbios_mode_info *vbios_mode;
> +	const struct ast_vbios_enhtable *vmode;
> +	unsigned int hborder = 0;
> +	unsigned int vborder = 0;
>   	int ret;
>   
>   	if (!crtc_state->enable)
> @@ -1028,11 +979,56 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
>   		}
>   	}
>   
> -	succ = ast_get_vbios_mode_info(ast, format, &crtc_state->mode,
> -				       &crtc_state->adjusted_mode,
> -				       &ast_state->vbios_mode_info);
> -	if (!succ)
> +	vbios_mode = &ast_state->vbios_mode_info;
> +
> +	/*
> +	 * Set register tables.
> +	 *
> +	 * TODO: These tables mix all kinds of fields and should
> +	 *       probably be resolved into various helper functions.
> +	 */
> +	switch (format->format) {
> +	case DRM_FORMAT_C8:
> +		vbios_mode->std_table = &vbios_stdtable[VGAModeIndex];
> +		break;
> +	case DRM_FORMAT_RGB565:
> +		vbios_mode->std_table = &vbios_stdtable[HiCModeIndex];
> +		break;
> +	case DRM_FORMAT_RGB888:
> +	case DRM_FORMAT_XRGB8888:
> +		vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex];
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * Find the VBIOS mode and adjust the DRM display mode accordingly.
> +	 */
> +
> +	vmode = ast_vbios_find_mode(ast, &crtc_state->mode);
> +	if (!vmode)
>   		return -EINVAL;
> +	ast_state->vbios_mode_info.enh_table = vmode;
> +
> +	if (vmode->flags & HBorder)
> +		hborder = 8;
> +	if (vmode->flags & VBorder)
> +		vborder = 8;
> +
> +	adjusted_mode->crtc_hdisplay = vmode->hde;
> +	adjusted_mode->crtc_hblank_start = vmode->hde + hborder;
> +	adjusted_mode->crtc_hblank_end = vmode->ht - hborder;
> +	adjusted_mode->crtc_hsync_start = vmode->hde + hborder + vmode->hfp;
> +	adjusted_mode->crtc_hsync_end = vmode->hde + hborder + vmode->hfp + vmode->hsync;
> +	adjusted_mode->crtc_htotal = vmode->ht;
> +
> +	adjusted_mode->crtc_vdisplay = vmode->vde;
> +	adjusted_mode->crtc_vblank_start = vmode->vde + vborder;
> +	adjusted_mode->crtc_vblank_end = vmode->vt - vborder;
> +	adjusted_mode->crtc_vsync_start = vmode->vde + vborder + vmode->vfp;
> +	adjusted_mode->crtc_vsync_end = vmode->vde + vborder + vmode->vfp + vmode->vsync;
> +	adjusted_mode->crtc_vtotal = vmode->vt;
>   
>   	return 0;
>   }



More information about the dri-devel mailing list