From 7d6f9f4edbf9c5cd6a33e238535c1cdb17bcb4e2 Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Thu, 28 Mar 2024 17:09:59 +0800 Subject: [PATCH] drm/verisilicon: add format_mod_supported to plane Otherwise IN_FORMATS blob is corrupted. Signed-off-by: Icenowy Zheng Signed-off-by: Han Gao --- drivers/gpu/drm/verisilicon/vs_plane.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/verisilicon/vs_plane.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/gpu/drm/verisilicon/vs_plane.c b/drivers/gpu/drm/verisilicon/vs_plane.c index 0a4dde2c17a0ca..1e516ef4c31e58 100644 --- a/drivers/gpu/drm/verisilicon/vs_plane.c +++ b/drivers/gpu/drm/verisilicon/vs_plane.c @@ -196,6 +196,27 @@ static int vs_plane_atomic_get_property(struct drm_plane *plane, return 0; } +static bool vs_plane_format_mod_supported(struct drm_plane *plane, + uint32_t format, + uint64_t modifier) +{ + struct vs_plane *vs_plane = to_vs_plane(plane); + int i; + + for(i = 0; i < vs_plane->info->num_modifiers; i++) { + if (vs_plane->info->modifiers[i] == modifier) + break; + } + if (i && i == vs_plane->info->num_modifiers) + return false; + + for(i = 0; i < vs_plane->info->num_formats; i++) { + if (vs_plane->info->formats[i] == format) + return true; + } + return false; +} + const struct drm_plane_funcs vs_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, @@ -205,6 +226,7 @@ const struct drm_plane_funcs vs_plane_funcs = { .atomic_destroy_state = vs_plane_atomic_destroy_state, .atomic_set_property = vs_plane_atomic_set_property, .atomic_get_property = vs_plane_atomic_get_property, + .format_mod_supported = vs_plane_format_mod_supported, }; static unsigned char vs_get_plane_number(struct drm_framebuffer *fb) @@ -303,6 +325,8 @@ struct vs_plane *vs_plane_create(struct drm_device *drm_dev, if (!plane) return NULL; + plane->info = info; + ret = drm_universal_plane_init(drm_dev, &plane->base, possible_crtcs, &vs_plane_funcs, info->formats, info->num_formats, info->modifiers, info->type, diff --git a/drivers/gpu/drm/verisilicon/vs_plane.h b/drivers/gpu/drm/verisilicon/vs_plane.h index baf53364364ba5..036c8401e712d1 100644 --- a/drivers/gpu/drm/verisilicon/vs_plane.h +++ b/drivers/gpu/drm/verisilicon/vs_plane.h @@ -47,6 +47,7 @@ struct vs_plane { struct drm_plane base; u8 id; dma_addr_t dma_addr[MAX_NUM_PLANES]; + struct vs_plane_info *info; struct drm_property *degamma_mode; struct drm_property *watermark_prop;