[RFC] drm: add support for tiled/compressed/etc modifier in addfb2

Daniel Vetter daniel at ffwll.ch
Wed Dec 10 09:30:10 PST 2014


On Wed, Dec 10, 2014 at 12:17:51PM -0500, Rob Clark wrote:
> In DRM/KMS we are lacking a good way to deal with tiled/compressed
> formats.  Especially in the case of dmabuf/prime buffer sharing, where
> we cannot always rely on under-the-hood flags passed to driver specific
> gem-create ioctl to pass around these extra flags.
> 
> The proposal is to add a per-plane format modifier.  This allows to, if
> necessary, use different tiling patters for sub-sampled planes, etc.
> The format modifiers are added at the end of the ioctl struct, so for
> legacy userspace it will be zero padded.
> 
> TODO how best to deal with assignment of modifier token values?  The
> rough idea was to namespace things with an 8bit vendor-id, and then
> beyond that it is treated as an opaque value.  But that was a relatively
> arbitrary choice.  There are cases where same tiling pattern and/or
> compression is supported by various different vendors.  So we should
> standardize to use the vendor-id and value of the first one who
> documents the format?

8bits should be enough, will take a while until we have more than 250 gpu
drivers in the linux kernel ;-) I'm leaning a bit towards using 64bits
though to make sure that there's enough space in the bitfiel to encode
substrides and stuff like that, in case anyone needs it. For vendor ids
I'd just go with first come and starting at 1 (i.e. rename yours). That
way we make it clear that until a patch is merged upstream the id isn't
reserved yet. drm-next should be sufficient as registry imo.

> TODO move definition of tokens to drm_fourcc.h?

Seems orthogonal imo. Another todo is to add checking to all drivers to
reject it if it's not 0 with -EINVAL. Otherwise we have yet another case
of an ioctl with fields that can't actually be used everywhere.

But yeah I like this and in i915 we definitely need this. skl adds a bunch
of framebuffer layouts where we need to spec tiling in more detail.

Overall I like.

> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
>  include/uapi/drm/drm_mode.h | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index aae71cb..c43648c 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -330,6 +330,28 @@ struct drm_mode_fb_cmd {
>  
>  #define DRM_MODE_FB_INTERLACED	(1<<0) /* for interlaced framebuffers */
>  
> +/*
> + * Format Modifiers:
> + *
> + * Format modifiers describe, typically, a re-ordering or modification
> + * of the data in a plane of an FB.  This can be used to express tiled/
> + * swizzled formats, or compression, or a combination of the two.
> + *
> + * The upper 8 bits of the format modifier are a vendor-id as assigned
> + * below.  The lower 24 bits are assigned as vendor sees fit.
> + */
> +
> +/* Vendor Ids: */
> +#define DRM_FOURCC_MOD_VENDOR_SAMSUNG 0x03
> +/* ... more */
> +
> +#define DRM_FOURCC_MOD(vendor, name) (((DRM_FOURCC_MOD_VENDOR_## vendor) << 24) | val)

Maybe a mask for the lower 24 bits?
-Daniel

> +
> +/* Modifier values: */
> +/* 64x32 macroblock, ie NV12MT: */
> +#define DRM_FOURCC_MOD_SAMSUNG_64_32_TILE DRM_FOURCC_MOD(SAMSUNG, 123)
> +/* ... more */
> +
>  struct drm_mode_fb_cmd2 {
>  	__u32 fb_id;
>  	__u32 width, height;
> @@ -349,10 +371,18 @@ struct drm_mode_fb_cmd2 {
>  	 * So it would consist of Y as offsets[0] and UV as
>  	 * offsets[1].  Note that offsets[0] will generally
>  	 * be 0 (but this is not required).
> +	 *
> +	 * To accommodate tiled, compressed, etc formats, a per-plane
> +	 * modifier can be specified.  The default value of zero
> +	 * indicates "native" format as specified by the fourcc.
> +	 * Vendor specific modifier token.  This allows, for example,
> +	 * different tiling/swizzling pattern on different planes.
> +	 * See discussion above of DRM_FOURCC_MOD_xxx.
>  	 */
>  	__u32 handles[4];
>  	__u32 pitches[4]; /* pitch for each plane */
>  	__u32 offsets[4]; /* offset of each plane */
> +	__u32 modifier[4]; /* ie, tiling, compressed (per plane) */
>  };
>  
>  #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
> -- 
> 2.1.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list