[PATCH] drm/fourcc: add LINEAR modifiers with an exact pitch alignment

Thomas Zimmermann tzimmermann at suse.de
Tue Jan 14 13:46:48 UTC 2025


Hi


Am 15.12.24 um 21:53 schrieb Marek Olšák:
> The comment explains the problem with DRM_FORMAT_MOD_LINEAR.
>
> Signed-off-by: Marek Olšák <marek.olsak at amd.com>
>
> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> index 78abd819fd62e..8ec4163429014 100644
> --- a/include/uapi/drm/drm_fourcc.h
> +++ b/include/uapi/drm/drm_fourcc.h
> @@ -484,9 +484,27 @@ extern "C" {
>   * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 
> ioctl),
>   * which tells the driver to also take driver-internal information 
> into account
>   * and so might actually result in a tiled framebuffer.
> + *
> + * WARNING:
> + * There are drivers out there that expose DRM_FORMAT_MOD_LINEAR, but 
> only
> + * support a certain pitch alignment and can't import images with 
> this modifier
> + * if the pitch alignment isn't exactly the one supported. They can 
> however
> + * allocate images with this modifier and other drivers can import 
> them only
> + * if they support the same pitch alignment. Thus, 
> DRM_FORMAT_MOD_LINEAR is
> + * fundamentically incompatible across devices and is the only 
> modifier that
> + * has a chance of not working. The PITCH_ALIGN modifiers should be used
> + * instead.
>   */
>  #define DRM_FORMAT_MOD_LINEAR  fourcc_mod_code(NONE, 0)
>
> +/* Linear layout modifiers with an explicit pitch alignment in bytes.
> + * Exposing this modifier requires that the pitch alignment is exactly
> + * the number in the definition.
> + */
> +#define DRM_FORMAT_MOD_LINEAR_PITCH_ALIGN_64B fourcc_mod_code(NONE, 1)

I recently went through drivers and tried to harmonize some 
pitch-related code. There are essentially all cases from 2 to 256. See 
my series at

   https://patchwork.freedesktop.org/series/141168/

Sometimes the driver computes the pitch requirements from the 
bit-per-pixels. [1]

Hardware also has alignment requirements for framebuffer width (usually 
8 pixels).

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/v6.12.6/source/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c#L410

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)



More information about the dri-devel mailing list