[RFC,2/4] drm: Add support for vendor specific DRM objects with custom properties

Message ID 1492679620-12792-3-git-send-email-m.szyprowski@samsung.com
State New
Headers show
Series
  • [RFC,1/4] drm: Export functions to create custom DRM objects
Related show

Commit Message

Marek Szyprowski April 20, 2017, 9:13 a.m.
Add a DRM_MODE_PROP_VENDOR flag, which allows to create DRM properties
for vendor, custom DRM objects. This allows to create OBJECT type properties,
which were reserved only for ATOMIC mode sets. This flag is also checked
in drm_object_property_get_value() function to let userspace to get
default value for such properties instead of calling the atomic path.

This change, together with ability of registering custom DRM objects from
the device drivers allows exposing some driver specific entities as DRM
objects, which can be then queried with standard
DRM_IOCTL_MODE_OBJ_GETPROPERTIES and DRM_IOCTL_MODE_GETPROPERTY ioctls.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/gpu/drm/drm_mode_object.c | 9 +++++----
 drivers/gpu/drm/drm_property.c    | 2 +-
 include/drm/drm_property.h        | 7 +++++++
 include/uapi/drm/drm_mode.h       | 1 +
 4 files changed, 14 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index 052dcabe26af..3cbefc1a7f4c 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -268,12 +268,13 @@  int drm_object_property_get_value(struct drm_mode_object *obj,
 {
 	int i;
 
-	/* read-only properties bypass atomic mechanism and still store
-	 * their value in obj->properties->values[].. mostly to avoid
-	 * having to deal w/ EDID and similar props in atomic paths:
+	/* custom vendor or read-only properties bypass atomic mechanism
+	 * and still store their value in obj->properties->values[].. mostly
+	 * to avoid having to deal w/ EDID and similar props in atomic paths:
 	 */
 	if (drm_drv_uses_atomic_modeset(property->dev) &&
-			!(property->flags & DRM_MODE_PROP_IMMUTABLE))
+			!(property->flags &
+			  (DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_VENDOR)))
 		return drm_atomic_get_property(obj, property, val);
 
 	for (i = 0; i < obj->properties->count; i++) {
diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index 3e88fa24eab3..a3fd496665de 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -318,7 +318,7 @@  struct drm_property *drm_property_create_object(struct drm_device *dev,
 
 	flags |= DRM_MODE_PROP_OBJECT;
 
-	if (WARN_ON(!(flags & DRM_MODE_PROP_ATOMIC)))
+	if (WARN_ON(!(flags & (DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_VENDOR))))
 		return NULL;
 
 	property = drm_property_create(dev, flags, name, 1);
diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h
index 13e8c17d1c79..d9a3d6450ffe 100644
--- a/include/drm/drm_property.h
+++ b/include/drm/drm_property.h
@@ -152,6 +152,13 @@  struct drm_property {
 	 *     properties. This is generally used to expose probe state to
 	 *     usersapce, e.g. the EDID, or the connector path property on DP
 	 *     MST sinks.
+	 *
+	 * DRM_MODE_PROP_VENDOR
+	 *     Set for vendor specific properties, for non-modeset vendor
+	 *     specific objects, which can be accessed by
+	 *     DRM_IOCTL_MODE_GETPROPERTY and DRM_IOCTL_MODE_OBJ_GETPROPERTIES,
+	 *     properties are not exposed to legacy userspace.
+	 *
 	 */
 	uint32_t flags;
 
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 8c67fc03d53d..2100afc1328a 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -322,6 +322,7 @@  struct drm_mode_get_connector {
  * witout being aware that this could be triggering a lengthy modeset.
  */
 #define DRM_MODE_PROP_ATOMIC        0x80000000
+#define DRM_MODE_PROP_VENDOR        0x40000000
 
 struct drm_mode_property_enum {
 	__u64 value;