diff options
author | Rob Clark <robdclark@gmail.com> | 2015-02-05 09:41:52 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-02-13 17:28:12 -0500 |
commit | e3eb3250d84ef97b766312345774367b6a310db8 (patch) | |
tree | 7220c957097ad78df34d6d2aeacc8afdadb1a9d4 /include/uapi | |
parent | 17d5538d54c9f9d6e2b44e07d4d577304e22c17a (diff) |
drm: add support for tiled/compressed/etc modifier in addfb2
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.
v1: original
v1.5: increase modifier to 64b
v2: Incorporate review comments from the big thread, plus a few more.
- Add a getcap so that userspace doesn't have to jump through hoops.
- Allow modifiers only when a flag is set. That way drivers know when
they're dealing with old userspace and need to fish out e.g. tiling
from other information.
- After rolling out checks for ->modifier to all drivers I've decided
that this is way too fragile and needs an explicit opt-in flag. So
do that instead.
- Add a define (just for documentation really) for the "NONE"
modifier. Imo we don't need to add mask #defines since drivers
really should only do exact matches against values defined with
fourcc_mod_code.
- Drop the Samsung tiling modifier on Rob's request since he's not yet
sure whether that one is accurate.
v3:
- Also add a new ->modifier[] array to struct drm_framebuffer and fill
it in drm_helper_mode_fill_fb_struct. Requested by Tvrkto Uruslin.
- Remove TODO in comment and add code comment that modifiers should be
properly documented, requested by Rob.
Cc: Rob Clark <robdclark@gmail.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Rob Clark <robdclark@gmail.com> (v1.5)
Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'include/uapi')
-rw-r--r-- | include/uapi/drm/drm.h | 1 | ||||
-rw-r--r-- | include/uapi/drm/drm_fourcc.h | 32 | ||||
-rw-r--r-- | include/uapi/drm/drm_mode.h | 9 |
3 files changed, 42 insertions, 0 deletions
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 01b2d6d0e355..ff6ef62d084b 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h | |||
@@ -630,6 +630,7 @@ struct drm_gem_open { | |||
630 | */ | 630 | */ |
631 | #define DRM_CAP_CURSOR_WIDTH 0x8 | 631 | #define DRM_CAP_CURSOR_WIDTH 0x8 |
632 | #define DRM_CAP_CURSOR_HEIGHT 0x9 | 632 | #define DRM_CAP_CURSOR_HEIGHT 0x9 |
633 | #define DRM_CAP_ADDFB2_MODIFIERS 0x10 | ||
633 | 634 | ||
634 | /** DRM_IOCTL_GET_CAP ioctl argument type */ | 635 | /** DRM_IOCTL_GET_CAP ioctl argument type */ |
635 | struct drm_get_cap { | 636 | struct drm_get_cap { |
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index 646ae5f39f42..622109677747 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h | |||
@@ -132,4 +132,36 @@ | |||
132 | #define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ | 132 | #define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ |
133 | #define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ | 133 | #define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ |
134 | 134 | ||
135 | |||
136 | /* | ||
137 | * Format Modifiers: | ||
138 | * | ||
139 | * Format modifiers describe, typically, a re-ordering or modification | ||
140 | * of the data in a plane of an FB. This can be used to express tiled/ | ||
141 | * swizzled formats, or compression, or a combination of the two. | ||
142 | * | ||
143 | * The upper 8 bits of the format modifier are a vendor-id as assigned | ||
144 | * below. The lower 56 bits are assigned as vendor sees fit. | ||
145 | */ | ||
146 | |||
147 | /* Vendor Ids: */ | ||
148 | #define DRM_FORMAT_MOD_NONE 0 | ||
149 | #define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 | ||
150 | #define DRM_FORMAT_MOD_VENDOR_AMD 0x02 | ||
151 | #define DRM_FORMAT_MOD_VENDOR_NV 0x03 | ||
152 | #define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 | ||
153 | #define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 | ||
154 | /* add more to the end as needed */ | ||
155 | |||
156 | #define fourcc_mod_code(vendor, val) \ | ||
157 | ((((u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffL)) | ||
158 | |||
159 | /* | ||
160 | * Format Modifier tokens: | ||
161 | * | ||
162 | * When adding a new token please document the layout with a code comment, | ||
163 | * similar to the fourcc codes above. drm_fourcc.h is considered the | ||
164 | * authoritative source for all of these. | ||
165 | */ | ||
166 | |||
135 | #endif /* DRM_FOURCC_H */ | 167 | #endif /* DRM_FOURCC_H */ |
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index ca788e01dab2..dbeba949462a 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h | |||
@@ -336,6 +336,7 @@ struct drm_mode_fb_cmd { | |||
336 | }; | 336 | }; |
337 | 337 | ||
338 | #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */ | 338 | #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */ |
339 | #define DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[] */ | ||
339 | 340 | ||
340 | struct drm_mode_fb_cmd2 { | 341 | struct drm_mode_fb_cmd2 { |
341 | __u32 fb_id; | 342 | __u32 fb_id; |
@@ -356,10 +357,18 @@ struct drm_mode_fb_cmd2 { | |||
356 | * So it would consist of Y as offsets[0] and UV as | 357 | * So it would consist of Y as offsets[0] and UV as |
357 | * offsets[1]. Note that offsets[0] will generally | 358 | * offsets[1]. Note that offsets[0] will generally |
358 | * be 0 (but this is not required). | 359 | * be 0 (but this is not required). |
360 | * | ||
361 | * To accommodate tiled, compressed, etc formats, a per-plane | ||
362 | * modifier can be specified. The default value of zero | ||
363 | * indicates "native" format as specified by the fourcc. | ||
364 | * Vendor specific modifier token. This allows, for example, | ||
365 | * different tiling/swizzling pattern on different planes. | ||
366 | * See discussion above of DRM_FORMAT_MOD_xxx. | ||
359 | */ | 367 | */ |
360 | __u32 handles[4]; | 368 | __u32 handles[4]; |
361 | __u32 pitches[4]; /* pitch for each plane */ | 369 | __u32 pitches[4]; /* pitch for each plane */ |
362 | __u32 offsets[4]; /* offset of each plane */ | 370 | __u32 offsets[4]; /* offset of each plane */ |
371 | __u64 modifier[4]; /* ie, tiling, compressed (per plane) */ | ||
363 | }; | 372 | }; |
364 | 373 | ||
365 | #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01 | 374 | #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01 |