drm/uapi: document kernel capabilities
Subsystems (2)
PATCH 1/1 drm/uapi: document kernel capabilities
Document all of the DRM_CAP_* defines.
--- include/uapi/drm/drm.h | 100 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-)
include/uapi/drm/drm.h +96 -4
@@ -625,30 +625,122 @@ struct drm_gem_open {__u64 size; }; +/** +* DRM_CAP_DUMB_BUFFER +* +* If set to 1, the driver supports creating dumb buffers via the +* &DRM_IOCTL_MODE_CREATE_DUMB ioctl. +*/ #define DRM_CAP_DUMB_BUFFER 0x1 +/** +* DRM_CAP_VBLANK_HIGH_CRTC +* +* If set to 1, the kernel supports specifying a CRTC index in the high bits of +* &drm_wait_vblank_request.type. +*/ #define DRM_CAP_VBLANK_HIGH_CRTC 0x2 +/** +* DRM_CAP_DUMB_PREFERRED_DEPTH +* +* The preferred depth (in bits) for dumb buffers. +*/ #define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3 +/** +* DRM_CAP_DUMB_PREFER_SHADOW +* +* If set to 1, the driver prefers userspace to render to a shadow buffer +* instead of directly rendering to a dumb buffer. +*/ #define DRM_CAP_DUMB_PREFER_SHADOW 0x4 +/** +* DRM_CAP_PRIME +* +* Bitfield of supported PRIME sharing capabilities. See &DRM_PRIME_CAP_IMPORT +* and &DRM_PRIME_CAP_EXPORT. +*/ #define DRM_CAP_PRIME 0x5 +/** +* DRM_PRIME_CAP_IMPORT +* +* If this bit is set in &DRM_CAP_PRIME, the driver supports importing PRIME +* buffers. +*/ #define DRM_PRIME_CAP_IMPORT 0x1 +/** +* DRM_PRIME_CAP_EXPORT +* +* If this bit is set in &DRM_CAP_PRIME, the driver supports exporting PRIME +* buffers. +*/ #define DRM_PRIME_CAP_EXPORT 0x2 +/** +* DRM_CAP_TIMESTAMP_MONOTONIC +* +* If set to 0, the kernel will report timestamps with the realtime clock in +* struct drm_event_vblank. If set to 1, the kernel will report timestamps with +* the monotonic clock. +*/ #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 +/** +* DRM_CAP_ASYNC_PAGE_FLIP +* +* If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC. +*/ #define DRM_CAP_ASYNC_PAGE_FLIP 0x7 -/* -* The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight -* combination for the hardware cursor. The intention is that a hardware -* agnostic userspace can query a cursor plane size to use. +/** +* DRM_CAP_CURSOR_WIDTH +* +* The ``CURSOR_WIDTH`` and ``CURSOR_HEIGHT`` capabilities return a valid +* width x height combination for the hardware cursor. The intention is that a +* hardware agnostic userspace can query a cursor plane size to use. * * Note that the cross-driver contract is to merely return a valid size; * drivers are free to attach another meaning on top, eg. i915 returns the * maximum plane size. */ #define DRM_CAP_CURSOR_WIDTH 0x8 +/** +* DRM_CAP_CURSOR_HEIGHT +* +* See &DRM_CAP_CURSOR_WIDTH. +*/ #define DRM_CAP_CURSOR_HEIGHT 0x9 +/** +* DRM_CAP_ADDFB2_MODIFIERS +* +* If set to 1, the driver supports supplying modifiers in the +* &DRM_IOCTL_MODE_ADDFB2 ioctl. +*/ #define DRM_CAP_ADDFB2_MODIFIERS 0x10 +/** +* DRM_CAP_PAGE_FLIP_TARGET +* +* If set to 1, the driver supports the &DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE and +* &DRM_MODE_PAGE_FLIP_TARGET_RELATIVE flags in +* &drm_mode_crtc_page_flip_target.flags for the &DRM_IOCTL_MODE_PAGE_FLIP +* ioctl. +*/ #define DRM_CAP_PAGE_FLIP_TARGET 0x11 +/** +* DRM_CAP_CRTC_IN_VBLANK_EVENT +* +* If set to 1, the kernel supports reporting the CRTC ID in +* &drm_event_vblank.crtc_id. +*/ #define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12 +/** +* DRM_CAP_SYNCOBJ +* +* If set to 1, the driver supports sync objects. See +* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects". +*/ #define DRM_CAP_SYNCOBJ 0x13 +/** +* DRM_CAP_SYNCOBJ_TIMELINE +* +* If set to 1, the driver supports timeline operations on sync objects. See +* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects". +*/ #define DRM_CAP_SYNCOBJ_TIMELINE 0x14/* DRM_IOCTL_GET_CAP ioctl argument type */
Signature · 6 lines
2.30.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 25 lines · On Thu, 4 Mar 2021 23:10:57 +0100 Simon Ser <[email protected]> wrote:
Document all of the DRM_CAP_* defines.
Signed-off-by Simon Ser <[email protected]>Cc Daniel Vetter <[email protected]>Cc Pekka Paalanen <[email protected]>--- include/uapi/drm/drm.h | 100 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-)include/uapi/drm/drm.h +7
-0@@ -625,30 +625,122 @@ struct drm_gem_open {__u64 size; }; +/** +* DRM_CAP_DUMB_BUFFER +* +* If set to 1, the driver supports creating dumb buffers via the +* &DRM_IOCTL_MODE_CREATE_DUMB ioctl. +*/ #define DRM_CAP_DUMB_BUFFER 0x1 +/**
include/uapi/drm/drm.h struct drm_gem_open { · line 645
Quoted 10 lines
include/uapi/drm/drm.h +9
-0+* DRM_CAP_VBLANK_HIGH_CRTC +* +* If set to 1, the kernel supports specifying a CRTC index in the high bits of +* &drm_wait_vblank_request.type. +*/ #define DRM_CAP_VBLANK_HIGH_CRTC 0x2 +/** +* DRM_CAP_DUMB_PREFERRED_DEPTH +* +* The preferred depth (in bits) for dumb buffers.
Hi,
this is literally depth, not bits per pixel, right?
include/uapi/drm/drm.h struct drm_gem_open { · line 652
Quoted 7 lines
include/uapi/drm/drm.h +6
-0+*/ #define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3 +/** +* DRM_CAP_DUMB_PREFER_SHADOW +* +* If set to 1, the driver prefers userspace to render to a shadow buffer +* instead of directly rendering to a dumb buffer.
Maybe add something like:
For best speed, userspace should do streaming ordered memory copies into the dumb buffer and never read from it.
Isn't that correct?
Quoted 4 lines
include/uapi/drm/drm.h +3
-0+*/ #define DRM_CAP_DUMB_PREFER_SHADOW 0x4 +/** +* DRM_CAP_PRIME
include/uapi/drm/drm.h struct drm_gem_open { · line 666
Quoted 10 lines
include/uapi/drm/drm.h +9
-0+* +* Bitfield of supported PRIME sharing capabilities. See &DRM_PRIME_CAP_IMPORT +* and &DRM_PRIME_CAP_EXPORT. +*/ #define DRM_CAP_PRIME 0x5 +/** +* DRM_PRIME_CAP_IMPORT +* +* If this bit is set in &DRM_CAP_PRIME, the driver supports importing PRIME +* buffers.
What are PRIME buffers?
include/uapi/drm/drm.h struct drm_gem_open { · line 673
Quoted 7 lines
include/uapi/drm/drm.h +6
-0+*/ #define DRM_PRIME_CAP_IMPORT 0x1 +/** +* DRM_PRIME_CAP_EXPORT +* +* If this bit is set in &DRM_CAP_PRIME, the driver supports exporting PRIME +* buffers.
What's the export API? HandleToFD()?
include/uapi/drm/drm.h struct drm_gem_open { · line 681
Quoted 8 lines
include/uapi/drm/drm.h +7
-0+*/ #define DRM_PRIME_CAP_EXPORT 0x2 +/** +* DRM_CAP_TIMESTAMP_MONOTONIC +* +* If set to 0, the kernel will report timestamps with the realtime clock in +* struct drm_event_vblank. If set to 1, the kernel will report timestamps with +* the monotonic clock.
I think it would be more explicit to say CLOCK_REALTIME and CLOCK_MONOTONIC, because there are things like CLOCK_MONOTONIC_RAW which is different. Mention clock_gettime()?
include/uapi/drm/drm.h struct drm_gem_open { · line 687
Quoted 6 lines
include/uapi/drm/drm.h +5
-0+*/ #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 +/** +* DRM_CAP_ASYNC_PAGE_FLIP +* +* If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC.
Does this apply equally to both legacy and atomic KMS API?
Quoted 35 lines
include/uapi/drm/drm.h +22
-4+*/ #define DRM_CAP_ASYNC_PAGE_FLIP 0x7 -/* -* The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight -* combination for the hardware cursor. The intention is that a hardware -* agnostic userspace can query a cursor plane size to use. +/** +* DRM_CAP_CURSOR_WIDTH +* +* The ``CURSOR_WIDTH`` and ``CURSOR_HEIGHT`` capabilities return a valid +* width x height combination for the hardware cursor. The intention is that a +* hardware agnostic userspace can query a cursor plane size to use. * * Note that the cross-driver contract is to merely return a valid size; * drivers are free to attach another meaning on top, eg. i915 returns the * maximum plane size. */ #define DRM_CAP_CURSOR_WIDTH 0x8 +/** +* DRM_CAP_CURSOR_HEIGHT +* +* See &DRM_CAP_CURSOR_WIDTH. +*/ #define DRM_CAP_CURSOR_HEIGHT 0x9 +/** +* DRM_CAP_ADDFB2_MODIFIERS +* +* If set to 1, the driver supports supplying modifiers in the +* &DRM_IOCTL_MODE_ADDFB2 ioctl. +*/ #define DRM_CAP_ADDFB2_MODIFIERS 0x10 +/** +* DRM_CAP_PAGE_FLIP_TARGET +* +* If set to 1, the driver supports the &DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE and
include/uapi/drm/drm.h struct drm_gem_open { · line 728
Quoted 10 lines
include/uapi/drm/drm.h +9
-0+* &DRM_MODE_PAGE_FLIP_TARGET_RELATIVE flags in +* &drm_mode_crtc_page_flip_target.flags for the &DRM_IOCTL_MODE_PAGE_FLIP +* ioctl. +*/ #define DRM_CAP_PAGE_FLIP_TARGET 0x11 +/** +* DRM_CAP_CRTC_IN_VBLANK_EVENT +* +* If set to 1, the kernel supports reporting the CRTC ID in +* &drm_event_vblank.crtc_id.
Does this not apply also to the pageflip / atomic completion event?
Quoted 8 lines
include/uapi/drm/drm.h +7
-0+*/ #define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12 +/** +* DRM_CAP_SYNCOBJ +* +* If set to 1, the driver supports sync objects. See +* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects". +*/
include/uapi/drm/drm.h struct drm_gem_open { · line 746
Quoted 10 lines
include/uapi/drm/drm.h +6
-0#define DRM_CAP_SYNCOBJ 0x13 +/** +* DRM_CAP_SYNCOBJ_TIMELINE +* +* If set to 1, the driver supports timeline operations on sync objects. See +* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects". +*/ #define DRM_CAP_SYNCOBJ_TIMELINE 0x14/* DRM_IOCTL_GET_CAP ioctl argument type */
I'm so happy seeing this doc appear! :-)
Sorry for trolling you into it. ;-)
Thanks,
pq
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Pekka Paalanen
Quoted 4 lines
+/**
+ *DRM_CAP_DUMB_PREFERRED_DEPTH
+ *
+ * The preferred depth (in bits) for dumb buffers.this is literally depth, not bits per pixel, right?
"Depth" is pretty ambiguous [1]. Maybe we should be more explicit here and say that it's the number of bits used to indicate the color of a single pixel? And maybe add a note that it's different from bits per pixel?
[1]: https://en.wikipedia.org/wiki/Color_depth
Quoted 8 lines
Quoted 7 lines
+ */
#defineDRM_CAP_DUMB_PREFERRED_DEPTH0x3
+/**
+ *DRM_CAP_DUMB_PREFER_SHADOW
+ *
+ * If set to 1, the driver prefers userspace to render to a shadow buffer
+ * instead of directly rendering to a dumb buffer.
Quoted 6 lines
Maybe add something like:
For best speed, userspace should do streaming ordered memory copies into the dumb buffer and never read from it.
Isn't that correct?
Good call, will add.
Quoted 8 lines
Quoted 8 lines
+ */
#defineDRM_CAP_DUMB_PREFER_SHADOW0x4
+/**
+ *DRM_CAP_PRIME
+ *
+ * Bitfield of supported PRIME sharing capabilities. See&DRM_PRIME_CAP_IMPORT
+ * and&DRM_PRIME_CAP_EXPORT.
+ */
Quoted 8 lines
Quoted 6 lines
#define
DRM_CAP_PRIME0x5
+/**
+ *DRM_PRIME_CAP_IMPORT
+ *
+ * If this bit is set in&DRM_CAP_PRIME, the driver supports importing PRIME
+ * buffers.What are PRIME buffers?
Will add something like:
PRIME buffers are exposed as dma-buf file descriptors. See Documentation/gpu/drm-mm.rst, section "PRIME Buffer Sharing".
Quoted 9 lines
Quoted 7 lines
+ */
#defineDRM_PRIME_CAP_IMPORT0x1
+/**
+ *DRM_PRIME_CAP_EXPORT
+ *
+ * If this bit is set in&DRM_CAP_PRIME, the driver supports exporting PRIME
+ * buffers.What's the export API?
HandleToFD()?
Yes. Will add a note about it. Same for import.
Quoted 9 lines
Quoted 8 lines
+ */
#defineDRM_PRIME_CAP_EXPORT0x2
+/**
+ *DRM_CAP_TIMESTAMP_MONOTONIC
+ *
+ * If set to 0, the kernel will report timestamps with the realtime clock in
+ * structdrm_event_vblank. If set to 1, the kernel will report timestamps with
+ * the monotonic clock.
Quoted 3 lines
I think it would be more explicit to say
CLOCK_REALTIMEandCLOCK_MONOTONIC, because there are things likeCLOCK_MONOTONIC_RAWwhich is different. Mentionclock_gettime()?
Ack, better be explicit here.
Quoted 8 lines
Quoted 6 lines
+ */
#defineDRM_CAP_TIMESTAMP_MONOTONIC0x6
+/**
+ *DRM_CAP_ASYNC_PAGE_FLIP
+ *
+ * If set to 1, the driver supports&DRM_MODE_PAGE_FLIP_ASYNC.Does this apply equally to both legacy and atomic KMS API?
Yes (it's included in DRM_MODE_ATOMIC_FLAGS), but I heard that some drivers get it wrong.
Quoted 39 lines
Quoted 39 lines
+ */
#defineDRM_CAP_ASYNC_PAGE_FLIP0x7include/uapi/drm/drm.h +25
-4-/* -* The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight -* combination for the hardware cursor. The intention is that a hardware -* agnostic userspace can query a cursor plane size to use. +/** +* DRM_CAP_CURSOR_WIDTH +* +* The ``CURSOR_WIDTH`` and ``CURSOR_HEIGHT`` capabilities return a valid +* width x height combination for the hardware cursor. The intention is that a +* hardware agnostic userspace can query a cursor plane size to use. * * Note that the cross-driver contract is to merely return a valid size; * drivers are free to attach another meaning on top, eg. i915 returns the * maximum plane size. */ #define DRM_CAP_CURSOR_WIDTH 0x8 +/** +* DRM_CAP_CURSOR_HEIGHT +* +* See &DRM_CAP_CURSOR_WIDTH. +*/ #define DRM_CAP_CURSOR_HEIGHT 0x9 +/** +* DRM_CAP_ADDFB2_MODIFIERS +* +* If set to 1, the driver supports supplying modifiers in the +* &DRM_IOCTL_MODE_ADDFB2 ioctl. +*/ #define DRM_CAP_ADDFB2_MODIFIERS 0x10 +/** +* DRM_CAP_PAGE_FLIP_TARGET +* +* If set to 1, the driver supports the &DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE and +* &DRM_MODE_PAGE_FLIP_TARGET_RELATIVE flags in +* &drm_mode_crtc_page_flip_target.flags for the &DRM_IOCTL_MODE_PAGE_FLIP +* ioctl. +*/
Quoted 8 lines
Quoted 6 lines
#define
DRM_CAP_PAGE_FLIP_TARGET0x11
+/**
+ *DRM_CAP_CRTC_IN_VBLANK_EVENT
+ *
+ * If set to 1, the kernel supports reporting the CRTC ID in
+ * &drm_event_vblank.crtc_id.Does this not apply also to the pageflip / atomic completion event?
Both DRM_EVENT_VBLANK and DRM_EVENT_FLIP_COMPLETE use the struct drm_event_vblank, so yes. I'll mention these two events explicitly.
Quoted 17 lines
Quoted 17 lines
+ */
#defineDRM_CAP_CRTC_IN_VBLANK_EVENT0x12include/uapi/drm/drm.h +12
-0+/** +* DRM_CAP_SYNCOBJ +* +* If set to 1, the driver supports sync objects. See +* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects". +*/ #define DRM_CAP_SYNCOBJ 0x13 +/** +* DRM_CAP_SYNCOBJ_TIMELINE +* +* If set to 1, the driver supports timeline operations on sync objects. See +* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects". +*/ #define DRM_CAP_SYNCOBJ_TIMELINE 0x14
Quoted 4 lines
Quoted 1 line
/*
DRM_IOCTL_GET_CAPioctl argument type */I'm so happy seeing this doc appear! :-)
Sorry for trolling you into it. ;-)
Np :)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · On Sat, 06 Mar 2021 10:56:49 +0000 Simon Ser <[email protected]> wrote:
Quoted 5 lines · Pekka Paalanen
Quoted 4 lines
+/**
+ *DRM_CAP_DUMB_PREFERRED_DEPTH
+ *
+ * The preferred depth (in bits) for dumb buffers.
Quoted 5 lines
Quoted 1 line
this is literally depth, not bits per pixel, right?
"Depth" is pretty ambiguous [1]. Maybe we should be more explicit here and say that it's the number of bits used to indicate the color of a single pixel? And maybe add a note that it's different from bits per pixel?
Yes, indeed. I was already assuming the meaning of "depth" in drmModeAddFB().
Quoted 18 lines
[1]: https://en.wikipedia.org/wiki/Color_depth
Quoted 6 lines
Quoted 6 lines
+/**
+ *DRM_CAP_PRIME
+ *
+ * Bitfield of supported PRIME sharing capabilities. See&DRM_PRIME_CAP_IMPORT
+ * and&DRM_PRIME_CAP_EXPORT.
+ */Quoted 8 lines
Quoted 6 lines
#define
DRM_CAP_PRIME0x5
+/**
+ *DRM_PRIME_CAP_IMPORT
+ *
+ * If this bit is set in&DRM_CAP_PRIME, the driver supports importing PRIME
+ * buffers.What are PRIME buffers?
Quoted 4 lines
Will add something like:
PRIME buffers are exposed as dma-buf file descriptors. See
Documentation/gpu/drm-mm.rst, section "PRIME Buffer Sharing".
Sounds good.
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
+ */
#defineDRM_PRIME_CAP_IMPORT0x1
+/**
+ *DRM_PRIME_CAP_EXPORT
+ *
+ * If this bit is set in&DRM_CAP_PRIME, the driver supports exporting PRIME
+ * buffers.What's the export API?
HandleToFD()?Yes. Will add a note about it. Same for import.
Cool.
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
+/**
+ *DRM_CAP_CRTC_IN_VBLANK_EVENT
+ *
+ * If set to 1, the kernel supports reporting the CRTC ID in
+ * &drm_event_vblank.crtc_id.Does this not apply also to the pageflip / atomic completion event?
Both
DRM_EVENT_VBLANKandDRM_EVENT_FLIP_COMPLETEuse the structdrm_event_vblank, so yes. I'll mention these two events explicitly.
They do? Seems like I have been spoiled by the libdrm API that uses drmEventContext with different callbacks for these things.
Thanks,
pq
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Pekka Paalanen
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
+/**
+ *DRM_CAP_CRTC_IN_VBLANK_EVENT
+ *
+ * If set to 1, the kernel supports reporting the CRTC ID in
+ * &drm_event_vblank.crtc_id.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Does this not apply also to the pageflip / atomic completion event?
Both
DRM_EVENT_VBLANKandDRM_EVENT_FLIP_COMPLETEuse the structdrm_event_vblank, so yes. I'll mention these two events explicitly.They do? Seems like I have been spoiled by the libdrm API that uses drmEventContext with different callbacks for these things.
Yeah, see drmHandleEvent [1] in libdrm.
[1]: https://gitlab.freedesktop.org/mesa/drm/-/blob/7d6a1759900ffde0a7aac2fa0cbd7c2bf4989476/xf86drmMode.c#L922
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel