[PATCH RESEND] drm/mediatek: Add valid modifier check

AngeloGioacchino Del Regno angelogioacchino.delregno at collabora.com
Tue Jul 25 06:56:02 UTC 2023


Il 24/07/23 19:58, Justin Green ha scritto:
> Add a check to mtk_drm_mode_fb_create() that rejects any modifier that
> is not the AFBC mode supported by MT8195's display overlays.
> 
> Tested by booting ChromeOS and verifying the UI works, and by running
> the ChromeOS kms_addfb_basic binary, which has a test called
> "addfb25-bad-modifier" that attempts to create a framebuffer with the
> modifier DRM_FORMAT_MOD_INVALID and verifies the ADDFB2 ioctl returns
> EINVAL.
> 
> Signed-off-by: Justin Green <greenjustin at chromium.org>
> ---
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cd5b18ef7951..2096e8a794ad 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -51,6 +51,13 @@ mtk_drm_mode_fb_create(struct drm_device *dev,
>   	if (info->num_planes != 1)
>   		return ERR_PTR(-EINVAL);
>   
> +	if (cmd->modifier[0] &&
> +	    cmd->modifier[0] != DRM_FORMAT_MOD_ARM_AFBC(
> +					AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 |
> +					AFBC_FORMAT_MOD_SPLIT |
> +					AFBC_FORMAT_MOD_SPARSE))
> +		return ERR_PTR(-EINVAL);

Would it make more sense to commmonize function mtk_plane_format_mod_supported()
and call that one here instead?

Regards,
Angelo

> +
>   	return drm_gem_fb_create(dev, file, cmd);
>   }
>   





More information about the dri-devel mailing list