Blob and atomic wrappers
Subsystems (2)
cover Blob and atomic wrappers
Hi,
Nothing big here, just the wrappers for the blob-property API, as well as the atomic API now it's been validated by Weston.
The blob work is my own, where the atomic work is a mega-squash of commits from Ville and Rob in particular, with my own changes to modify the user-facing API a little, and resync with the kernel interface.
Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/2 Support atomic modesetting ioctl
From: Ville Syrjälä <[email protected]>
Add support for the atomic modesetting ioctl through a property-set API.
[daniels: Squashed intermediate patches from Ville, Rob and myself.
Updated for current interface.]
--- include/drm/drm.h | 9 +++ include/drm/drm_mode.h | 16 +++++ xf86drmMode.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++ xf86drmMode.h | 14 ++++ 4 files changed, 225 insertions(+)
include/drm/drm.h +9 -0
@@ -635,6 +635,13 @@ struct drm_get_cap {*/ #define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2 +/** +* DRM_CLIENT_CAP_ATOMIC +* +* If set to 1, the DRM core will allow atomic modesetting requests. +*/ +#define DRM_CLIENT_CAP_ATOMIC 3 +/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap {__u64 capability;
@@ -758,6 +765,7 @@ struct drm_prime_handle {#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property)#define DRM_IOCTL_MODE_CURSOR2 DRM_IOWR(0xBB, struct drm_mode_cursor2) +#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBC, struct drm_mode_atomic)/** * Device specific ioctls should only be in their respective headers
@@ -806,6 +814,7 @@ struct drm_event_vblank {#define DRM_CAP_PRIME 0x5#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6#define DRM_CAP_ASYNC_PAGE_FLIP 0x7 +#define DRM_CAP_ATOMIC 0xa#define DRM_PRIME_CAP_IMPORT 0x1#define DRM_PRIME_CAP_EXPORT 0x2
include/drm/drm_mode.h +16 -0
@@ -507,4 +507,20 @@ struct drm_mode_destroy_dumb { __u32 handle; }; +/* page-flip flags are valid, plus: */ +#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100 +#define DRM_MODE_ATOMIC_NONBLOCK 0x0200 +#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400 + +struct drm_mode_atomic { +__u32 flags; +__u32 count_objs; +__u64 objs_ptr; +__u64 count_props_ptr; +__u64 props_ptr; +__u64 prop_values_ptr; +__u64 reserved; +__u64 user_data; +}; +#endif
xf86drmMode.c +186 -0
195 lines not on this page · raw message
xf86drmMode.h +14 -0
@@ -484,6 +484,20 @@ extern int drmModeObjectSetProperty(int fd, uint32_t object_id, uint32_t object_type, uint32_t property_id, uint64_t value); + +typedef struct _drmModeAtomicReq drmModeAtomicReq , *drmModeAtomicReqPtr ; + +extern drmModeAtomicReqPtr drmModeAtomicAlloc (void ); +extern int drmModeAtomicAddProperty (drmModeAtomicReqPtr req, +uint32_t object_id, +uint32_t property_id, +uint64_t value); +extern int drmModeAtomicCommit (int fd, +drmModeAtomicReqPtr req, +uint32_t flags, +void *user_data); +extern void drmModeAtomicFree (drmModeAtomicReqPtr req); +#if defined(__cplusplus) || defined(c_plusplus) }#endif
Signature · 6 lines
2.4.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 Add blob property create/destroy ioctl wrappers
In reply to Daniel Stone--- include/drm/drm.h | 2 ++ include/drm/drm_mode.h | 21 +++++++++++++++++++++ xf86drmMode.c | 31 +++++++++++++++++++++++++++++++ xf86drmMode.h | 5 +++++ 4 files changed, 59 insertions(+)
include/drm/drm.h +2 -0
@@ -766,6 +766,8 @@ struct drm_prime_handle {#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property)#define DRM_IOCTL_MODE_CURSOR2 DRM_IOWR(0xBB, struct drm_mode_cursor2)#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBC, struct drm_mode_atomic) +#define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob) +#define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob)/** * Device specific ioctls should only be in their respective headers
include/drm/drm_mode.h +21 -0
@@ -523,4 +523,25 @@ struct drm_mode_atomic { __u64 user_data; }; +/** +* Create a new 'blob' data property, copying length bytes from data pointer, +* and returning new blob ID. +*/ +struct drm_mode_create_blob { +/** Pointer to data to copy. */ +__u64 data; +/** Length of data to copy. */ +__u32 length; +/** Return: new property ID. */ +__u32 blob_id; +}; + +/** +* Destroy a user-created blob property. +*/ +struct drm_mode_destroy_blob { +__u32 blob_id; +}; + +#endif
xf86drmMode.c +31 -0
@@ -1333,3 +1333,34 @@ out:return ret; } + +int +drmModeCreatePropertyBlob (int fd,const void *data,size_t length,uint32_t *id) +{ +struct drm_mode_create_blob create; +int ret; + +if (length >=0xffffffff ) +return -ERANGE ; + + create.length = length; + create.data = (uintptr_t ) data; + create.blob_id =0 ; + *id =0 ; + + ret =DRM_IOCTL (fd,DRM_IOCTL_MODE_CREATEPROPBLOB , &create); +if (ret !=0 ) +return ret; + + *id = create.blob_id; +return 0 ; +} + +int +drmModeDestroyPropertyBlob (int fd,uint32_t id) +{ +struct drm_mode_destroy_blob destroy; + + destroy.blob_id = id; +return DRM_IOCTL (fd,DRM_IOCTL_MODE_DESTROYPROPBLOB , &destroy); +}
xf86drmMode.h +5 -0
@@ -498,6 +498,11 @@ extern int drmModeAtomicCommit(int fd, void *user_data);extern void drmModeAtomicFree (drmModeAtomicReqPtr req); +extern int drmModeCreatePropertyBlob (int fd,const void *data,size_t size, +uint32_t *id); +extern int drmModeDestroyPropertyBlob (int fd,uint32_t id); + +#if defined(__cplusplus) || defined(c_plusplus) }#endif
Signature · 6 lines
2.4.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 2/2] Add blob property create/destroy ioctl wrappers
Hi Daniel,
Quoted 1 line · Daniel Stone
Signed-off-by Daniel Stone <[email protected]>
There is a trivial suggestion inline, although I must say thank you ! Thank you for keeping the impl. details of struct _drmModeAtomicReqItem/_drmModeAtomicReq out of the public headers.
xf86drmMode.c out: · line 1340
Quoted 11 lines
xf86drmMode.c +5
-0@@ -1333,3 +1333,34 @@ out:return ret; } + +int +drmModeCreatePropertyBlob (int fd,const void *data,size_t length,uint32_t *id) +{ +struct drm_mode_create_blob create;
Please explicitly zero the struct - most places use memclear()
Quoted 12 lines
xf86drmMode.c +12
-0+int ret; + +if (length >=0xffffffff ) +return -ERANGE ; + + create.length = length; + create.data = (uintptr_t ) data; + create.blob_id =0 ; + *id =0 ; + + ret =DRM_IOCTL (fd,DRM_IOCTL_MODE_CREATEPROPBLOB , &create); +if (ret !=0 )
xf86drmMode.c out: · line 1362
Quoted 10 lines
xf86drmMode.c +10
-0+return ret; + + *id = create.blob_id; +return 0 ; +} + +int +drmModeDestroyPropertyBlob (int fd,uint32_t id) +{ +struct drm_mode_destroy_blob destroy;
Ditto.
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel