Skip to contentSkip to conversation

xf86drmMode: Create drmModeCreatePropertyBlobWithFlags

PATCH In review Mark Yacoub 2 participants 2 messages May 12, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xf86drmMode: Create drmModeCreatePropertyBlobWithFlags

[Why]
The kernel has support for creating a blob with flags, particularly write only flag.
The user space should use libdrm library to make use of the blob flags.

[How]
Create drmModeCreatePropertyBlobWithFlags which has the same implementation as the existing drmModeCreatePropertyBlob but with a flag argument.

---
 include/drm/drm_mode.h | 6 ++++++
 xf86drmMode.c          | 7 +++++++
 xf86drmMode.h          | 3 +++
 3 files changed, 16 insertions(+)
include/drm/drm_mode.h +6 -0
index 9b6722d4..b0df381f 100644
@@ -991,6 +991,9 @@ struct drm_format_modifier {
 	__u64 modifier;
 };
 
+#define DRM_MODE_CREATE_BLOB_WRITE_ONLY                                        \
+	(1 << 0) /* data of the blob can't be read by user space */
+
 /**
  * struct drm_mode_create_blob - Create New blob property
  *
@@ -1004,6 +1007,9 @@ struct drm_mode_create_blob {
 	__u32 length;
 	/** @blob_id: Return: new property ID. */
 	__u32 blob_id;
+	/** Flags for special handling. */
+	__u32 flags;
+	__u32 pad;
 };
 
 /**
xf86drmMode.c +7 -0
index 87e96603..072b395c 100644
@@ -1592,6 +1592,12 @@ drm_public int
 drmModeCreatePropertyBlob(int fd, const void *data, size_t length,
                                      uint32_t *id)
 {
+  	return drmModeCreatePropertyBlobWithFlags(fd, data, length, id, 0);
+}
+
+extern int drmModeCreatePropertyBlobWithFlags(int fd, const void *data,
+                                              size_t length, uint32_t *id,
+                                              uint32_t flags) {
 	struct drm_mode_create_blob create;
 	int ret;
 
@@ -1603,6 +1609,7 @@ drmModeCreatePropertyBlob(int fd, const void *data, size_t length,
 	create.length = length;
 	create.data = (uintptr_t) data;
 	create.blob_id = 0;
+	create.flags = flags;
 	*id = 0;
 
 	ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, &create);
xf86drmMode.h +3 -0
index 19bf91dd..f22b8174 100644
@@ -450,6 +450,9 @@ extern int drmModeAtomicCommit(int fd,
 
 extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size,
 				     uint32_t *id);
+extern int drmModeCreatePropertyBlobWithFlags(int fd, const void *data,
+                                              size_t size, uint32_t *id,
+                                              uint32_t flags);
 extern int drmModeDestroyPropertyBlob(int fd, uint32_t id);
 
 /*
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
#1 lore raw

Note, the headers in include/drm/ must be updated in a special manner from the kernel. See the README in the subdir for details.