···629629/**
630630 * DRM_CAP_VBLANK_HIGH_CRTC
631631 *
632632- * If set to 1, the kernel supports specifying a CRTC index in the high bits of
633633- * &drm_wait_vblank_request.type.
632632+ * If set to 1, the kernel supports specifying a :ref:`CRTC index<crtc_index>`
633633+ * in the high bits of &drm_wait_vblank_request.type.
634634 *
635635 * Starting kernel version 2.6.39, this capability is always set to 1.
636636 */
···667667 * Bitfield of supported PRIME sharing capabilities. See &DRM_PRIME_CAP_IMPORT
668668 * and &DRM_PRIME_CAP_EXPORT.
669669 *
670670- * PRIME buffers are exposed as dma-buf file descriptors. See
671671- * Documentation/gpu/drm-mm.rst, section "PRIME Buffer Sharing".
670670+ * Starting from kernel version 6.6, both &DRM_PRIME_CAP_IMPORT and
671671+ * &DRM_PRIME_CAP_EXPORT are always advertised.
672672+ *
673673+ * PRIME buffers are exposed as dma-buf file descriptors.
674674+ * See :ref:`prime_buffer_sharing`.
672675 */
673676#define DRM_CAP_PRIME 0x5
674677/**
···676679 *
677680 * If this bit is set in &DRM_CAP_PRIME, the driver supports importing PRIME
678681 * buffers via the &DRM_IOCTL_PRIME_FD_TO_HANDLE ioctl.
682682+ *
683683+ * Starting from kernel version 6.6, this bit is always set in &DRM_CAP_PRIME.
679684 */
680685#define DRM_PRIME_CAP_IMPORT 0x1
681686/**
···683688 *
684689 * If this bit is set in &DRM_CAP_PRIME, the driver supports exporting PRIME
685690 * buffers via the &DRM_IOCTL_PRIME_HANDLE_TO_FD ioctl.
691691+ *
692692+ * Starting from kernel version 6.6, this bit is always set in &DRM_CAP_PRIME.
686693 */
687694#define DRM_PRIME_CAP_EXPORT 0x2
688695/**
···700707/**
701708 * DRM_CAP_ASYNC_PAGE_FLIP
702709 *
703703- * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC.
710710+ * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for legacy
711711+ * page-flips.
704712 */
705713#define DRM_CAP_ASYNC_PAGE_FLIP 0x7
706714/**
···750758/**
751759 * DRM_CAP_SYNCOBJ
752760 *
753753- * If set to 1, the driver supports sync objects. See
754754- * Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".
761761+ * If set to 1, the driver supports sync objects. See :ref:`drm_sync_objects`.
755762 */
756763#define DRM_CAP_SYNCOBJ 0x13
757764/**
758765 * DRM_CAP_SYNCOBJ_TIMELINE
759766 *
760767 * If set to 1, the driver supports timeline operations on sync objects. See
761761- * Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".
768768+ * :ref:`drm_sync_objects`.
762769 */
763770#define DRM_CAP_SYNCOBJ_TIMELINE 0x14
771771+/**
772772+ * DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP
773773+ *
774774+ * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for atomic
775775+ * commits.
776776+ */
777777+#define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15
764778765779/* DRM_IOCTL_GET_CAP ioctl argument type */
766780struct drm_get_cap {
···830844 */
831845#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5
832846847847+/**
848848+ * DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT
849849+ *
850850+ * Drivers for para-virtualized hardware (e.g. vmwgfx, qxl, virtio and
851851+ * virtualbox) have additional restrictions for cursor planes (thus
852852+ * making cursor planes on those drivers not truly universal,) e.g.
853853+ * they need cursor planes to act like one would expect from a mouse
854854+ * cursor and have correctly set hotspot properties.
855855+ * If this client cap is not set the DRM core will hide cursor plane on
856856+ * those virtualized drivers because not setting it implies that the
857857+ * client is not capable of dealing with those extra restictions.
858858+ * Clients which do set cursor hotspot and treat the cursor plane
859859+ * like a mouse cursor should set this property.
860860+ * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
861861+ *
862862+ * Setting this property on drivers which do not special case
863863+ * cursor planes (i.e. non-virtualized drivers) will return
864864+ * EOPNOTSUPP, which can be used by userspace to gauge
865865+ * requirements of the hardware/drivers they're running on.
866866+ *
867867+ * This capability is always supported for atomic-capable virtualized
868868+ * drivers starting from kernel version 6.6.
869869+ */
870870+#define DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT 6
871871+833872/* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
834873struct drm_set_client_cap {
835874 __u64 capability;
···881920#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)
882921#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
883922#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) /* wait for time point to become available */
923923+#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_DEADLINE (1 << 3) /* set fence deadline to deadline_nsec */
884924struct drm_syncobj_wait {
885925 __u64 handles;
886926 /* absolute timeout */
···889929 __u32 flags;
890930 __u32 first_signaled; /* only valid when not waiting all */
891931 __u32 pad;
932932+ /**
933933+ * @deadline_nsec - fence deadline hint
934934+ *
935935+ * Deadline hint, in absolute CLOCK_MONOTONIC, to set on backing
936936+ * fence(s) if the DRM_SYNCOBJ_WAIT_FLAGS_WAIT_DEADLINE flag is
937937+ * set.
938938+ */
939939+ __u64 deadline_nsec;
892940};
893941894942struct drm_syncobj_timeline_wait {
···901949 __u32 flags;
902950 __u32 first_signaled; /* only valid when not waiting all */
903951 __u32 pad;
952952+ /**
953953+ * @deadline_nsec - fence deadline hint
954954+ *
955955+ * Deadline hint, in absolute CLOCK_MONOTONIC, to set on backing
956956+ * fence(s) if the DRM_SYNCOBJ_WAIT_FLAGS_WAIT_DEADLINE flag is
957957+ * set.
958958+ */
959959+ __u64 deadline_nsec;
960960+};
961961+962962+/**
963963+ * struct drm_syncobj_eventfd
964964+ * @handle: syncobj handle.
965965+ * @flags: Zero to wait for the point to be signalled, or
966966+ * &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE to wait for a fence to be
967967+ * available for the point.
968968+ * @point: syncobj timeline point (set to zero for binary syncobjs).
969969+ * @fd: Existing eventfd to sent events to.
970970+ * @pad: Must be zero.
971971+ *
972972+ * Register an eventfd to be signalled by a syncobj. The eventfd counter will
973973+ * be incremented by one.
974974+ */
975975+struct drm_syncobj_eventfd {
976976+ __u32 handle;
977977+ __u32 flags;
978978+ __u64 point;
979979+ __s32 fd;
980980+ __u32 pad;
904981};
905982906983···9661043#define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, struct drm_stats)
9671044#define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, struct drm_set_version)
9681045#define DRM_IOCTL_MODESET_CTL DRM_IOW(0x08, struct drm_modeset_ctl)
10461046+/**
10471047+ * DRM_IOCTL_GEM_CLOSE - Close a GEM handle.
10481048+ *
10491049+ * GEM handles are not reference-counted by the kernel. User-space is
10501050+ * responsible for managing their lifetime. For example, if user-space imports
10511051+ * the same memory object twice on the same DRM file description, the same GEM
10521052+ * handle is returned by both imports, and user-space needs to ensure
10531053+ * &DRM_IOCTL_GEM_CLOSE is performed once only. The same situation can happen
10541054+ * when a memory object is allocated, then exported and imported again on the
10551055+ * same DRM file description. The &DRM_IOCTL_MODE_GETFB2 IOCTL is an exception
10561056+ * and always returns fresh new GEM handles even if an existing GEM handle
10571057+ * already refers to the same memory object before the IOCTL is performed.
10581058+ */
9691059#define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close)
9701060#define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink)
9711061#define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open)
···10061096#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock)
10071097#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock)
1008109810991099+/**
11001100+ * DRM_IOCTL_PRIME_HANDLE_TO_FD - Convert a GEM handle to a DMA-BUF FD.
11011101+ *
11021102+ * User-space sets &drm_prime_handle.handle with the GEM handle to export and
11031103+ * &drm_prime_handle.flags, and gets back a DMA-BUF file descriptor in
11041104+ * &drm_prime_handle.fd.
11051105+ *
11061106+ * The export can fail for any driver-specific reason, e.g. because export is
11071107+ * not supported for this specific GEM handle (but might be for others).
11081108+ *
11091109+ * Support for exporting DMA-BUFs is advertised via &DRM_PRIME_CAP_EXPORT.
11101110+ */
10091111#define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle)
11121112+/**
11131113+ * DRM_IOCTL_PRIME_FD_TO_HANDLE - Convert a DMA-BUF FD to a GEM handle.
11141114+ *
11151115+ * User-space sets &drm_prime_handle.fd with a DMA-BUF file descriptor to
11161116+ * import, and gets back a GEM handle in &drm_prime_handle.handle.
11171117+ * &drm_prime_handle.flags is unused.
11181118+ *
11191119+ * If an existing GEM handle refers to the memory object backing the DMA-BUF,
11201120+ * that GEM handle is returned. Therefore user-space which needs to handle
11211121+ * arbitrary DMA-BUFs must have a user-space lookup data structure to manually
11221122+ * reference-count duplicated GEM handles. For more information see
11231123+ * &DRM_IOCTL_GEM_CLOSE.
11241124+ *
11251125+ * The import can fail for any driver-specific reason, e.g. because import is
11261126+ * only supported for DMA-BUFs allocated on this DRM device.
11271127+ *
11281128+ * Support for importing DMA-BUFs is advertised via &DRM_PRIME_CAP_IMPORT.
11291129+ */
10101130#define DRM_IOCTL_PRIME_FD_TO_HANDLE DRM_IOWR(0x2e, struct drm_prime_handle)
1011113110121132#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
···10441164#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob)
10451165#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
10461166#define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
11671167+/**
11681168+ * DRM_IOCTL_MODE_RMFB - Remove a framebuffer.
11691169+ *
11701170+ * This removes a framebuffer previously added via ADDFB/ADDFB2. The IOCTL
11711171+ * argument is a framebuffer object ID.
11721172+ *
11731173+ * Warning: removing a framebuffer currently in-use on an enabled plane will
11741174+ * disable that plane. The CRTC the plane is linked to may also be disabled
11751175+ * (depending on driver capabilities).
11761176+ */
10471177#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int)
10481178#define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)
10491179#define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)
1050118011811181+/**
11821182+ * DRM_IOCTL_MODE_CREATE_DUMB - Create a new dumb buffer object.
11831183+ *
11841184+ * KMS dumb buffers provide a very primitive way to allocate a buffer object
11851185+ * suitable for scanout and map it for software rendering. KMS dumb buffers are
11861186+ * not suitable for hardware-accelerated rendering nor video decoding. KMS dumb
11871187+ * buffers are not suitable to be displayed on any other device than the KMS
11881188+ * device where they were allocated from. Also see
11891189+ * :ref:`kms_dumb_buffer_objects`.
11901190+ *
11911191+ * The IOCTL argument is a struct drm_mode_create_dumb.
11921192+ *
11931193+ * User-space is expected to create a KMS dumb buffer via this IOCTL, then add
11941194+ * it as a KMS framebuffer via &DRM_IOCTL_MODE_ADDFB and map it via
11951195+ * &DRM_IOCTL_MODE_MAP_DUMB.
11961196+ *
11971197+ * &DRM_CAP_DUMB_BUFFER indicates whether this IOCTL is supported.
11981198+ * &DRM_CAP_DUMB_PREFERRED_DEPTH and &DRM_CAP_DUMB_PREFER_SHADOW indicate
11991199+ * driver preferences for dumb buffers.
12001200+ */
10511201#define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)
10521202#define DRM_IOCTL_MODE_MAP_DUMB DRM_IOWR(0xB3, struct drm_mode_map_dumb)
10531203#define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
···10801230#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)
10811231#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)
1082123212331233+/**
12341234+ * DRM_IOCTL_MODE_GETFB2 - Get framebuffer metadata.
12351235+ *
12361236+ * This queries metadata about a framebuffer. User-space fills
12371237+ * &drm_mode_fb_cmd2.fb_id as the input, and the kernels fills the rest of the
12381238+ * struct as the output.
12391239+ *
12401240+ * If the client is DRM master or has &CAP_SYS_ADMIN, &drm_mode_fb_cmd2.handles
12411241+ * will be filled with GEM buffer handles. Fresh new GEM handles are always
12421242+ * returned, even if another GEM handle referring to the same memory object
12431243+ * already exists on the DRM file description. The caller is responsible for
12441244+ * removing the new handles, e.g. via the &DRM_IOCTL_GEM_CLOSE IOCTL. The same
12451245+ * new handle will be returned for multiple planes in case they use the same
12461246+ * memory object. Planes are valid until one has a zero handle -- this can be
12471247+ * used to compute the number of planes.
12481248+ *
12491249+ * Otherwise, &drm_mode_fb_cmd2.handles will be zeroed and planes are valid
12501250+ * until one has a zero &drm_mode_fb_cmd2.pitches.
12511251+ *
12521252+ * If the framebuffer has a format modifier, &DRM_MODE_FB_MODIFIERS will be set
12531253+ * in &drm_mode_fb_cmd2.flags and &drm_mode_fb_cmd2.modifier will contain the
12541254+ * modifier. Otherwise, user-space must ignore &drm_mode_fb_cmd2.modifier.
12551255+ *
12561256+ * To obtain DMA-BUF FDs for each plane without leaking GEM handles, user-space
12571257+ * can export each handle via &DRM_IOCTL_PRIME_HANDLE_TO_FD, then immediately
12581258+ * close each unique handle via &DRM_IOCTL_GEM_CLOSE, making sure to not
12591259+ * double-close handles which are specified multiple times in the array.
12601260+ */
10831261#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
1084126212631263+#define DRM_IOCTL_SYNCOBJ_EVENTFD DRM_IOWR(0xCF, struct drm_syncobj_eventfd)
12641264+12651265+/**
12661266+ * DRM_IOCTL_MODE_CLOSEFB - Close a framebuffer.
12671267+ *
12681268+ * This closes a framebuffer previously added via ADDFB/ADDFB2. The IOCTL
12691269+ * argument is a framebuffer object ID.
12701270+ *
12711271+ * This IOCTL is similar to &DRM_IOCTL_MODE_RMFB, except it doesn't disable
12721272+ * planes and CRTCs. As long as the framebuffer is used by a plane, it's kept
12731273+ * alive. When the plane no longer uses the framebuffer (because the
12741274+ * framebuffer is replaced with another one, or the plane is disabled), the
12751275+ * framebuffer is cleaned up.
12761276+ *
12771277+ * This is useful to implement flicker-free transitions between two processes.
12781278+ *
12791279+ * Depending on the threat model, user-space may want to ensure that the
12801280+ * framebuffer doesn't expose any sensitive user information: closed
12811281+ * framebuffers attached to a plane can be read back by the next DRM master.
12821282+ */
12831283+#define DRM_IOCTL_MODE_CLOSEFB DRM_IOWR(0xD0, struct drm_mode_closefb)
12841284+10851285/*
10861286 * Device specific ioctls should only be in their respective headers
10871287 * The device specific ioctl range is from 0x40 to 0x9f.
···10931293#define DRM_COMMAND_BASE 0x40
10941294#define DRM_COMMAND_END 0xA0
1095129510961096-/*
10971097- * Header for events written back to userspace on the drm fd. The
10981098- * type defines the type of event, the length specifies the total
10991099- * length of the event (including the header), and user_data is
11001100- * typically a 64 bit value passed with the ioctl that triggered the
11011101- * event. A read on the drm fd will always only return complete
11021102- * events, that is, if for example the read buffer is 100 bytes, and
11031103- * there are two 64 byte events pending, only one will be returned.
12961296+/**
12971297+ * struct drm_event - Header for DRM events
12981298+ * @type: event type.
12991299+ * @length: total number of payload bytes (including header).
13001300+ *
13011301+ * This struct is a header for events written back to user-space on the DRM FD.
13021302+ * A read on the DRM FD will always only return complete events: e.g. if the
13031303+ * read buffer is 100 bytes large and there are two 64 byte events pending,
13041304+ * only one will be returned.
11041305 *
11051105- * Event types 0 - 0x7fffffff are generic drm events, 0x80000000 and
11061106- * up are chipset specific.
13061306+ * Event types 0 - 0x7fffffff are generic DRM events, 0x80000000 and
13071307+ * up are chipset specific. Generic DRM events include &DRM_EVENT_VBLANK,
13081308+ * &DRM_EVENT_FLIP_COMPLETE and &DRM_EVENT_CRTC_SEQUENCE.
11071309 */
11081310struct drm_event {
11091311 __u32 type;
11101312 __u32 length;
11111313};
1112131413151315+/**
13161316+ * DRM_EVENT_VBLANK - vertical blanking event
13171317+ *
13181318+ * This event is sent in response to &DRM_IOCTL_WAIT_VBLANK with the
13191319+ * &_DRM_VBLANK_EVENT flag set.
13201320+ *
13211321+ * The event payload is a struct drm_event_vblank.
13221322+ */
11131323#define DRM_EVENT_VBLANK 0x01
13241324+/**
13251325+ * DRM_EVENT_FLIP_COMPLETE - page-flip completion event
13261326+ *
13271327+ * This event is sent in response to an atomic commit or legacy page-flip with
13281328+ * the &DRM_MODE_PAGE_FLIP_EVENT flag set.
13291329+ *
13301330+ * The event payload is a struct drm_event_vblank.
13311331+ */
11141332#define DRM_EVENT_FLIP_COMPLETE 0x02
13331333+/**
13341334+ * DRM_EVENT_CRTC_SEQUENCE - CRTC sequence event
13351335+ *
13361336+ * This event is sent in response to &DRM_IOCTL_CRTC_QUEUE_SEQUENCE.
13371337+ *
13381338+ * The event payload is a struct drm_event_crtc_sequence.
13391339+ */
11151340#define DRM_EVENT_CRTC_SEQUENCE 0x03
1116134111171342struct drm_event_vblank {