[PATCH v2 4/7] drm/ast: cursor: Add helpers for computing location in video memory
Jocelyn Falempe
jfalempe at redhat.com
Tue Mar 11 13:07:36 UTC 2025
On 05/03/2025 17:30, Thomas Zimmermann wrote:
> The ast drivers stores the cursor image at the end of the video memory.
> Add helpers to calculate the offset and size.
>
Thanks, it looks good to me.
Reviewed-by: Jocelyn Falempe <jfalempe at redhat.com>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
> drivers/gpu/drm/ast/ast_cursor.c | 21 +++++++++++++++++++--
> drivers/gpu/drm/ast/ast_drv.h | 1 +
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_cursor.c b/drivers/gpu/drm/ast/ast_cursor.c
> index 139ab00dee8f..05e297f30b4e 100644
> --- a/drivers/gpu/drm/ast/ast_cursor.c
> +++ b/drivers/gpu/drm/ast/ast_cursor.c
> @@ -45,6 +45,21 @@
> #define AST_HWC_SIGNATURE_HOTSPOTX 0x14
> #define AST_HWC_SIGNATURE_HOTSPOTY 0x18
>
> +static unsigned long ast_cursor_vram_size(void)
> +{
> + return AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE;
> +}
> +
> +long ast_cursor_vram_offset(struct ast_device *ast)
> +{
> + unsigned long size = ast_cursor_vram_size();
> +
> + if (size > ast->vram_size)
> + return -EINVAL;
> +
> + return PAGE_ALIGN_DOWN(ast->vram_size - size);
> +}
> +
> static u32 ast_cursor_calculate_checksum(const void *src, unsigned int width, unsigned int height)
> {
> u32 csum = 0;
> @@ -276,7 +291,7 @@ int ast_cursor_plane_init(struct ast_device *ast)
> struct drm_plane *cursor_plane = &ast_plane->base;
> size_t size;
> void __iomem *vaddr;
> - u64 offset;
> + long offset;
> int ret;
>
> /*
> @@ -290,7 +305,9 @@ int ast_cursor_plane_init(struct ast_device *ast)
> return -ENOMEM;
>
> vaddr = ast->vram + ast->vram_fb_available - size;
> - offset = ast->vram_fb_available - size;
> + offset = ast_cursor_vram_offset(ast);
> + if (offset < 0)
> + return offset;
>
> ret = ast_plane_init(dev, ast_plane, vaddr, offset, size,
> 0x01, &ast_cursor_plane_funcs,
> diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
> index 2c7861835cfb..ec9ec77260e9 100644
> --- a/drivers/gpu/drm/ast/ast_drv.h
> +++ b/drivers/gpu/drm/ast/ast_drv.h
> @@ -432,6 +432,7 @@ int ast_vga_output_init(struct ast_device *ast);
> int ast_sil164_output_init(struct ast_device *ast);
>
> /* ast_cursor.c */
> +long ast_cursor_vram_offset(struct ast_device *ast);
> int ast_cursor_plane_init(struct ast_device *ast);
>
> /* ast dp501 */
More information about the dri-devel
mailing list