> -----Original Message-----
> From: dri-devel <dri-devel-boun...@lists.freedesktop.org> On Behalf Of
> Arun R Murthy
> Sent: Wednesday, January 8, 2025 11:09 AM
> To: dri-de...@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; intel-
> x...@lists.freedesktop.org
> Cc: Murthy, Arun R <arun.r.mur...@intel.com>
> Subject: [PATCH v3 5/5] drm/i915/display: Add function for
> format_mod_supported_async
> 
> Add driver specific function definition for the plane->funcs
> format_mod_supported_async to check if the provided format/modifier is
> supported for asynchronous flip.
> 
> Signed-off-by: Arun R Murthy <arun.r.mur...@intel.com>
> ---
>  drivers/gpu/drm/i915/display/skl_universal_plane.c | 62 ++++++++++++++++-
> -----
>  1 file changed, 47 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> index
> e5e47f2219dae62e76cbde2efb40266b047ab2b2..00aa254a3b4e992268c9159
> bc15687e54718dc43 100644
> --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> @@ -2526,30 +2526,62 @@ static bool
> tgl_plane_format_mod_supported(struct drm_plane *_plane,
>       }
>  }
> 
> +static bool intel_plane_format_mod_supported_async(struct drm_plane
> *_plane,
> +                                                u32 format, u64 modifier)
> +{
> +     struct intel_plane *plane = to_intel_plane(_plane);
> +     struct intel_display *display = to_intel_display(plane);
> +     int i, found = false;
> +     u64 *async_modifiers;
> +
> +     if (plane->id != 1)
> +             return false;
> +
> +     if (DISPLAY_VER(display) >= 12)
> +             async_modifiers = tgl_asyn_modifiers;
> +     else if (DISPLAY_VER(display) == 11)
> +             async_modifiers = icl_async_modifiers;
> +     else
> +             async_modifiers = skl_async_modifiers;
> +
> +     for (i = 0; i < sizeof(async_modifiers); i++) {

Array size check is incorrect.

> +             if (modifier == async_modifiers[i])
> +                     found = true;
> +     }
> +     if (!found)
> +             return false;
> +
> +     /* Async flip supported only on RGB formats */
> +     for (i = 0; i < sizeof(intel_async_formats); i++) {

Array size check is incorrect.

> +             if (format == intel_async_formats[i])
> +                     return true;
> +     }
> +     return false;
> +}
> +

It is better to implement this function in the switch case format that 
XXX_plane_format_mod_supported() functions are implemented.
Imagine a scenario where a modifier is supported for some formats but not 
others. This function won't be able to make the distinction.

Regards

Chaitanya

> +#define INTEL_PLANE_FUNCS \
> +     .update_plane = drm_atomic_helper_update_plane, \
> +     .disable_plane = drm_atomic_helper_disable_plane, \
> +     .destroy = intel_plane_destroy, \
> +     .atomic_duplicate_state = intel_plane_duplicate_state, \
> +     .atomic_destroy_state = intel_plane_destroy_state, \
> +     .format_mod_supported_async =
> intel_plane_format_mod_supported_async
> +
>  static const struct drm_plane_funcs skl_plane_funcs = {
> -     .update_plane = drm_atomic_helper_update_plane,
> -     .disable_plane = drm_atomic_helper_disable_plane,
> -     .destroy = intel_plane_destroy,
> -     .atomic_duplicate_state = intel_plane_duplicate_state,
> -     .atomic_destroy_state = intel_plane_destroy_state,
> +     INTEL_PLANE_FUNCS,
> +
>       .format_mod_supported = skl_plane_format_mod_supported,  };
> 
>  static const struct drm_plane_funcs icl_plane_funcs = {
> -     .update_plane = drm_atomic_helper_update_plane,
> -     .disable_plane = drm_atomic_helper_disable_plane,
> -     .destroy = intel_plane_destroy,
> -     .atomic_duplicate_state = intel_plane_duplicate_state,
> -     .atomic_destroy_state = intel_plane_destroy_state,
> +     INTEL_PLANE_FUNCS,
> +
>       .format_mod_supported = icl_plane_format_mod_supported,  };
> 
>  static const struct drm_plane_funcs tgl_plane_funcs = {
> -     .update_plane = drm_atomic_helper_update_plane,
> -     .disable_plane = drm_atomic_helper_disable_plane,
> -     .destroy = intel_plane_destroy,
> -     .atomic_duplicate_state = intel_plane_duplicate_state,
> -     .atomic_destroy_state = intel_plane_destroy_state,
> +     INTEL_PLANE_FUNCS,
> +
>       .format_mod_supported = tgl_plane_format_mod_supported,  };
> 
> 
> --
> 2.25.1

Reply via email to