Skip to contentSkip to conversation

Some additional drm properties patches

PATCH In review Rob Clark 2 participants 5 messages May 16, 2012

Subsystems (2)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

cover Some additional drm properties patches

From: Rob Clark <[email protected]>

These patches apply on top of Paulo's patches to add support for generic KMS object properties, and add support for plane properties, and a new property type suitable for flags/bitmasks.

Rob Clark (2):
drm: add bitmask property type
drm: add plane properties

 drivers/gpu/drm/drm_crtc.c |   65 ++++++++++++++++++++++++++++++++++++++++++--
 include/drm/drm_crtc.h     |    8 ++++++
 include/drm/drm_mode.h     |    1 +
 3 files changed, 71 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/2 drm: add bitmask property type

From: Rob Clark <[email protected]>

A bitmask property is similar to an enum. The enum value is a bit position (0-63), and valid property values consist of a mask of zero or more of (1 << enum_val[n]).

---
 drivers/gpu/drm/drm_crtc.c |   46 +++++++++++++++++++++++++++++++++++++++++---
 include/drm/drm_crtc.h     |    3 +++
 include/drm/drm_mode.h     |    1 +
 3 files changed, 47 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +43 -3
index 75661c8..022873e 100644
@@ -2707,6 +2707,33 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
 }
 EXPORT_SYMBOL(drm_property_create_enum);
 
+struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
+					 int flags, const char *name,
+					 const struct drm_prop_enum_list *props, int num_values)
+{
+	struct drm_property *property;
+	int i, ret;
+
+	flags |= DRM_MODE_PROP_BITMASK;
+
+	property = drm_property_create(dev, flags, name, num_values);
+	if (!property)
+		return NULL;
+
+	for (i = 0; i < num_values; i++) {
+		ret = drm_property_add_enum(property, i,
+				      props[i].type,
+				      props[i].name);
+		if (ret) {
+			drm_property_destroy(dev, property);
+			return NULL;
+		}
+	}
+
+	return property;
+}
+EXPORT_SYMBOL(drm_property_create_bitmask);
+
 struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
 					 const char *name,
 					 uint64_t min, uint64_t max)
@@ -2731,7 +2758,14 @@ int drm_property_add_enum(struct drm_property *property, int index,
 {
 	struct drm_property_enum *prop_enum;
 
-	if (!(property->flags & DRM_MODE_PROP_ENUM))
+	if (!(property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)))
+		return -EINVAL;
+
+	/*
+	 * Bitmask enum properties have the additional constraint of values
+	 * from 0 to 63
+	 */
+	if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63))
 		return -EINVAL;
 
 	if (!list_empty(&property->enum_blob_list)) {
@@ -2875,7 +2909,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
 	}
 	property = obj_to_property(obj);
 
-	if (property->flags & DRM_MODE_PROP_ENUM) {
+	if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) {
 		list_for_each_entry(prop_enum, &property->enum_blob_list, head)
 			enum_count++;
 	} else if (property->flags & DRM_MODE_PROP_BLOB) {
@@ -2900,7 +2934,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
 	}
 	out_resp->count_values = value_count;
 
-	if (property->flags & DRM_MODE_PROP_ENUM) {
+	if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) {
 		if ((out_resp->count_enum_blobs >= enum_count) && enum_count) {
 			copied = 0;
 			enum_ptr = (struct drm_mode_property_enum __user *)(unsigned long)out_resp->enum_blob_ptr;
@@ -3055,6 +3089,12 @@ static bool drm_property_change_is_valid(struct drm_property *property,
 		if (value < property->values[0] || value > property->values[1])
 			return false;
 		return true;
+	} else if (property->flags & DRM_MODE_PROP_BITMASK) {
+		int i;
+		__u64 valid_mask = 0;
+		for (i = 0; i < property->num_values; i++)
+			valid_mask |= (1LL << property->values[i]);
+		return !(value & ~valid_mask);
 	} else {
 		int i;
 		for (i = 0; i < property->num_values; i++)
include/drm/drm_crtc.h +3 -0
index e194c78..39e3e1c 100644
@@ -940,6 +940,9 @@ extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int
 					 const char *name,
 					 const struct drm_prop_enum_list *props,
 					 int num_values);
+struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
+					 int flags, const char *name,
+					 const struct drm_prop_enum_list *props, int num_values);
 struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
 					 const char *name,
 					 uint64_t min, uint64_t max);
include/drm/drm_mode.h +1 -0
index 326f2be..5581980 100644
@@ -230,6 +230,7 @@ struct drm_mode_get_connector {
 #define DRM_MODE_PROP_IMMUTABLE	(1<<2)
 #define DRM_MODE_PROP_ENUM	(1<<3) /* enumerated type with text strings */
 #define DRM_MODE_PROP_BLOB	(1<<4)
+#define DRM_MODE_PROP_BITMASK	(1<<5) /* bitmask of enumerated types */
 
 struct drm_mode_property_enum {
 	__u64 value;
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] drm: add bitmask property type

2012/5/16 Rob Clark <[email protected]>:

Quoted 7 lines

From: Rob Clark <[email protected]>

A bitmask property is similar to an enum.  The enum value is a bit position (0-63), and valid property values consist of a mask of zero or more of (1 << enum_val[n]).

<Bikeshedding>
"int num_values" appears after column 80 in 2 places </Bikeshedding>

Quoted 124 lines

---
 drivers/gpu/drm/drm_crtc.c |   46 +++++++++++++++++++++++++++++++++++++++++--- include/drm/drm_crtc.h     |    3 +++
 include/drm/drm_mode.h     |    1 +

 3 files changed, 47 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +43 -3
index 75661c8..022873e 100644
@@ -2707,6 +2707,33 @@ struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
  }
  EXPORT_SYMBOL(drm_property_create_enum);
 
+struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
+                                        int flags, const char *name,
+                                        const struct drm_prop_enum_list *props, int num_values)
+{
+       struct drm_property *property;
+       int i, ret;
+
+       flags |= DRM_MODE_PROP_BITMASK;
+
+       property = drm_property_create(dev, flags, name, num_values);
+       if (!property)
+               return NULL;
+
+       for (i = 0; i < num_values; i++) {
+               ret = drm_property_add_enum(property, i,
+                                     props[i].type,
+                                     props[i].name);
+               if (ret) {
+                       drm_property_destroy(dev, property);
+                       return NULL;
+               }
+       }
+
+       return property;
+}
+EXPORT_SYMBOL(drm_property_create_bitmask);
+
  struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
                                         const char *name,
                                         uint64_t min, uint64_t max)
@@ -2731,7 +2758,14 @@ int drm_property_add_enum(struct drm_property *property, int index,
  {
        struct drm_property_enum *prop_enum;
 
-       if (!(property->flags & DRM_MODE_PROP_ENUM))
+       if (!(property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)))
+               return -EINVAL;
+
+       /*
+        * Bitmask enum properties have the additional constraint of values
+        * from 0 to 63
+        */
+       if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63))
                return -EINVAL;
 
        if (!list_empty(&property->enum_blob_list)) {
@@ -2875,7 +2909,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
        }
        property = obj_to_property(obj);
 
-       if (property->flags & DRM_MODE_PROP_ENUM) {
+       if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) {
                list_for_each_entry(prop_enum, &property->enum_blob_list, head)
                        enum_count++;
        } else if (property->flags & DRM_MODE_PROP_BLOB) {
@@ -2900,7 +2934,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
        }
        out_resp->count_values = value_count;
 
-       if (property->flags & DRM_MODE_PROP_ENUM) {
+       if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) {
                if ((out_resp->count_enum_blobs >= enum_count) && enum_count) {
                        copied = 0;
                        enum_ptr = (struct drm_mode_property_enum __user *)(unsigned long)out_resp->enum_blob_ptr;
@@ -3055,6 +3089,12 @@ static bool drm_property_change_is_valid(struct drm_property *property,
                if (value < property->values[0] || value > property->values[1])
                        return false;
                return true;
+       } else if (property->flags & DRM_MODE_PROP_BITMASK) {
+               int i;
+               __u64 valid_mask = 0;
+               for (i = 0; i < property->num_values; i++)
+                       valid_mask |= (1LL << property->values[i]);
+               return !(value & ~valid_mask);
        } else {
                int i;
                for (i = 0; i < property->num_values; i++)
include/drm/drm_crtc.h +3 -0
index e194c78..39e3e1c 100644
@@ -940,6 +940,9 @@ extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int
                                         const char *name,
                                         const struct drm_prop_enum_list *props,
                                         int num_values);
+struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
+                                        int flags, const char *name,
+                                        const struct drm_prop_enum_list *props, int num_values);
  struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
                                         const char *name,
                                         uint64_t min, uint64_t max);
include/drm/drm_mode.h +1 -1
index 326f2be..5581980 100644
@@ -230,6 +230,7 @@ struct drm_mode_get_connector {
  #define DRM_MODE_PROP_IMMUTABLE        (1<<2)
  #define DRM_MODE_PROP_ENUM     (1<<3) /* enumerated type with text strings */
  #define DRM_MODE_PROP_BLOB     (1<<4)
+#define DRM_MODE_PROP_BITMASK  (1<<5) /* bitmask of enumerated types */
 
  struct drm_mode_property_enum {
        __u64 value;
--

1.7.9.5

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

Signature · 1 line
Paulo Zanoni
author
#3 lore raw

PATCH 2/2 drm: add plane properties

In reply to Rob Clark

From: Rob Clark <[email protected]>

The omapdrm driver uses this for setting per-overlay rotation. It is likely also useful for setting YUV->RGB colorspace conversion matrix, etc.

---
 drivers/gpu/drm/drm_crtc.c |   19 +++++++++++++++++++
 include/drm/drm_crtc.h     |    5 +++++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/drm_crtc.c +19 -0
index 022873e..a9b2b497 100644
@@ -606,6 +606,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
 	if (ret)
 		goto out;
 
+	plane->base.properties = &plane->properties;
 	plane->dev = dev;
 	plane->funcs = funcs;
 	plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
@@ -3155,6 +3156,21 @@ static int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
 	return ret;
 }
 
+static int drm_mode_plane_set_obj_prop(struct drm_mode_object *obj,
+				      struct drm_property *property,
+				      uint64_t value)
+{
+	int ret = -EINVAL;
+	struct drm_plane *plane = obj_to_plane(obj);
+
+	if (plane->funcs->set_property)
+		ret = plane->funcs->set_property(plane, property, value);
+	if (!ret)
+		drm_object_property_set_value(obj, property, value);
+
+	return ret;
+}
+
 int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
 				      struct drm_file *file_priv)
 {
@@ -3256,6 +3272,9 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
 	case DRM_MODE_OBJECT_CRTC:
 		ret = drm_mode_crtc_set_obj_prop(arg_obj, property, arg->value);
 		break;
+	case DRM_MODE_OBJECT_PLANE:
+		ret = drm_mode_plane_set_obj_prop(arg_obj, property, arg->value);
+		break;
 	}
 
 out:
include/drm/drm_crtc.h +5 -0
index 39e3e1c..c23789c 100644
@@ -618,6 +618,9 @@ struct drm_plane_funcs {
 			    uint32_t src_w, uint32_t src_h);
 	int (*disable_plane)(struct drm_plane *plane);
 	void (*destroy)(struct drm_plane *plane);
+
+	int (*set_property)(struct drm_plane *plane,
+			    struct drm_property *property, uint64_t val);
 };
 
 /**
@@ -657,6 +660,8 @@ struct drm_plane {
 
 	const struct drm_plane_funcs *funcs;
 	void *helper_private;
+
+	struct drm_object_properties properties;
 };
 
 /**
Signature · 1 line
1.7.9.5
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] drm: add plane properties

2012/5/16 Rob Clark <[email protected]>:

Quoted 7 lines

From: Rob Clark <[email protected]>

The omapdrm driver uses this for setting per-overlay rotation.  It is likely also useful for setting YUV->RGB colorspace conversion matrix, etc.

Please add comments inside include/drm/drm_crtc.h documenting the new added fields of drm_plane_funcs and drm_funcs (we already have descriptions of all the other fields).

With that:

Quoted 79 lines

---
 drivers/gpu/drm/drm_crtc.c |   19 +++++++++++++++++++ include/drm/drm_crtc.h     |    5 +++++

 2 files changed, 24 insertions(+)
drivers/gpu/drm/drm_crtc.c +16 -0
index 022873e..a9b2b497 100644
@@ -606,6 +606,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
        if (ret)
                goto out;
 
+       plane->base.properties = &plane->properties;
        plane->dev = dev;
        plane->funcs = funcs;
        plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
@@ -3155,6 +3156,21 @@ static int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
        return ret;
  }
 
+static int drm_mode_plane_set_obj_prop(struct drm_mode_object *obj,
+                                     struct drm_property *property,
+                                     uint64_t value)
+{
+       int ret = -EINVAL;
+       struct drm_plane *plane = obj_to_plane(obj);
+
+       if (plane->funcs->set_property)
+               ret = plane->funcs->set_property(plane, property, value);
+       if (!ret)
+               drm_object_property_set_value(obj, property, value);
+
+       return ret;
+}
+
  int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
                                      struct drm_file *file_priv)
  {
@@ -3256,6 +3272,9 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,

       case DRM_MODE_OBJECT_CRTC:
               ret = drm_mode_crtc_set_obj_prop(arg_obj, property, arg->value); break;
+       case DRM_MODE_OBJECT_PLANE:
+               ret = drm_mode_plane_set_obj_prop(arg_obj, property, arg->value);
+               break;
       }

 out:

include/drm/drm_crtc.h +5 -1
index 39e3e1c..c23789c 100644
@@ -618,6 +618,9 @@ struct drm_plane_funcs {
                            uint32_t src_w, uint32_t src_h);
        int (*disable_plane)(struct drm_plane *plane);
        void (*destroy)(struct drm_plane *plane);
+
+       int (*set_property)(struct drm_plane *plane,
+                           struct drm_property *property, uint64_t val);
  };
 
  /**
@@ -657,6 +660,8 @@ struct drm_plane {
 
        const struct drm_plane_funcs *funcs;
        void *helper_private;
+
+       struct drm_object_properties properties;
  };
 
  /**
--

1.7.9.5

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

Signature · 1 line
Paulo Zanoni