Skip to contentSkip to conversation

libdrm: Atomic mode setting stuff

RFC PATCH New [email protected] 1 participant 3 messages May 25, 2012

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

cover libdrm: Atomic mode setting stuff

Here's the libdrm part of the atomic mode setting stuff.

There's a new object I christened drmModePropertySet. It's an opaque object which is used to keep track of property changes for the user. Internally it's just a linked list of object_id/property_id/property_value tuples. The list is sorted based on object_id and property_id to avoid duplicates.

The YUYV libkms patch is there just because my test app was more geared towards YUV than RGB, and I was too lazy to make the switch to RGB.

I also stripped out a bunch of gunk from my test app and pushed the result to gitorious [1]. What it does is move/resize the plane and flips the CRTC fb at the same time using the new API.

The app has a rudimentary keyboard control mechanism:
't' toggles an automatic test mode
's','z','x','c' move the plane
'S','Z','X','C' change the plane size
'f' fills the plane with a pattern, the color changes each time 'b' fills the plane with color bars
'l' loads a ppm (P6) image into the plane
'o' toggles the plane on/off
'q' quits

[1] https://gitorious.org/vsyrjala/plane

#1 lore raw

RFC PATCH 1/2 libkms: YUYV support

From: Ville Syrjälä <[email protected]>

---
 libkms/intel.c  |    6 +++++-
 libkms/libkms.h |    2 ++
 2 files changed, 7 insertions(+), 1 deletions(-)
libkms/intel.c +5 -1
index 8b8249b..8aeb6ae 100644
@@ -52,7 +52,7 @@ intel_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)
 {
 	switch (key) {
 	case KMS_BO_TYPE:
-		*out = KMS_BO_TYPE_SCANOUT_X8R8G8B8 | KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8;
+		*out = KMS_BO_TYPE_SCANOUT_X8R8G8B8 | KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 | KMS_BO_TYPE_SCANOUT_YUYV;
 		break;
 	default:
 		return -EINVAL;
@@ -100,6 +100,10 @@ intel_bo_create(struct kms_driver *kms,
 		pitch = width * 4;
 		pitch = (pitch + 512 - 1) & ~(512 - 1);
 		size = pitch * ((height + 4 - 1) & ~(4 - 1));
+	} else if (type == KMS_BO_TYPE_SCANOUT_YUYV) {
+		pitch = width * 2;
+		pitch = (pitch + 64 - 1) & ~(64 - 1);
+		size = pitch * height;
 	} else {
 		return -EINVAL;
 	}
libkms/libkms.h +2 -0
index 4664442..8cf3489 100644
@@ -59,6 +59,8 @@ enum kms_bo_type
 #define KMS_BO_TYPE_SCANOUT_X8R8G8B8 KMS_BO_TYPE_SCANOUT_X8R8G8B8
 	KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 =  (1 << 1),
 #define KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8
+	KMS_BO_TYPE_SCANOUT_YUYV = (1 << 2),
+#define KMS_BO_TYPE_SCANOUT_YUYV KMS_BO_TYPE_SCANOUT_YUYV
 };
 
 int kms_create(int fd, struct kms_driver **out);
Signature · 6 lines
1.7.3.4

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

RFC PATCH 2/2 libdrm: atomic mode set

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

---
 include/drm/drm.h      |    1 +
 include/drm/drm_mode.h |   13 +++
 xf86drmMode.c          |  270 ++++++++++++++++++++++++++++++++++++++++++++++++
 xf86drmMode.h          |   19 ++++
 4 files changed, 303 insertions(+), 0 deletions(-)
include/drm/drm.h +1 -0
index 5e6cd29..c3236e1 100644
@@ -733,6 +733,7 @@ struct drm_prime_handle {
 #define DRM_IOCTL_MODE_ADDFB2		DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
 #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_ATOMIC  DRM_IOWR(0xBB, struct drm_mode_atomic)
 
 /**
  * Device specific ioctls should only be in their respective headers
include/drm/drm_mode.h +13 -0
index 62ba997..5b2f294 100644
@@ -462,4 +462,17 @@ struct drm_mode_destroy_dumb {
 	__u32 handle;
 };
 
+#define DRM_MODE_ATOMIC_TEST_ONLY (1<<0)
+
+/* FIXME come up with some sane error reporting mechanism? */
+struct drm_mode_atomic {
+	__u32 flags;
+	__u32 count_objs;
+	__u64 objs_ptr;
+	__u64 count_props_ptr;
+	__u64 props_ptr;
+	__u64 prop_values_ptr;
+	__u64 blob_values_ptr;
+};
+
 #endif
xf86drmMode.c +270 -0

279 lines not on this page · raw message

xf86drmMode.h +19 -0
index 8e40034..3500616 100644
@@ -442,6 +442,25 @@ extern int drmModeObjectSetProperty(int fd, uint32_t object_id,
 				    uint32_t object_type, uint32_t property_id,
 				    uint64_t value);
 
+
+typedef struct _drmModePropertySet drmModePropertySet, *drmModePropertySetPtr;
+
+extern drmModePropertySetPtr drmModePropertySetAlloc(void);
+
+extern int drmModePropertySetAdd(drmModePropertySetPtr set,
+				 uint32_t object_id,
+				 uint32_t property_id,
+				 uint64_t value);
+extern int drmModePropertySetAddBlob(drmModePropertySetPtr set,
+				     uint32_t object_id,
+				     uint32_t property_id,
+				     uint64_t length,
+				     void *blob);
+
+extern int drmModePropertySetCommit(int fd, uint32_t flags, drmModePropertySetPtr set);
+
+extern void drmModePropertySetFree(drmModePropertySetPtr set);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
Signature · 6 lines
1.7.3.4

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel