summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarta Lofstedt <marta.lofstedt@intel.com>2016-11-02 09:38:26 +0200
committerMartin Peres <martin.peres@linux.intel.com>2017-01-23 10:27:11 +0200
commit6a6f1bc16ed7e9c0aefeb3603355b8f3ff6db851 (patch)
tree48364750636d72b5ff9997ce6dbbaea295fb87d0
parent7c9be67b0f41f69ef46398593802040b4e4c37c6 (diff)
drm: add a get_property callback for drm properties
This callback allows a driver to override the internal value of the drm property. Signed-off-by: Marta Lofstedt <marta.lofstedt@intel.com>]
-rw-r--r--drivers/gpu/drm/drm_mode_object.c20
-rw-r--r--include/drm/drm_property.h12
2 files changed, 30 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index 14543ff08c51..fedeca5e1cce 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -27,6 +27,11 @@
#include "drm_crtc_internal.h"
+static int _drm_object_property_get_value(struct drm_mode_object *obj,
+ struct drm_property *property,
+ uint64_t *val,
+ bool use_get_property);
+
/*
* Internal function to assign a slot in the object idr and optionally
* register the object into the idr.
@@ -268,6 +273,15 @@ EXPORT_SYMBOL(drm_object_property_set_value);
int drm_object_property_get_value(struct drm_mode_object *obj,
struct drm_property *property, uint64_t *val)
{
+ return _drm_object_property_get_value(obj, property, val, true);
+}
+EXPORT_SYMBOL(drm_object_property_get_value);
+
+static int _drm_object_property_get_value(struct drm_mode_object *obj,
+ struct drm_property *property,
+ uint64_t *val,
+ bool non_cached)
+{
int i;
/* read-only properties bypass atomic mechanism and still store
@@ -280,7 +294,10 @@ int drm_object_property_get_value(struct drm_mode_object *obj,
for (i = 0; i < obj->properties->count; i++) {
if (obj->properties->properties[i] == property) {
- *val = obj->properties->values[i];
+ if (property->get_property && non_cached)
+ *val = property->get_property(obj);
+ else
+ *val = obj->properties->values[i];
return 0;
}
@@ -288,7 +305,6 @@ int drm_object_property_get_value(struct drm_mode_object *obj,
return -EINVAL;
}
-EXPORT_SYMBOL(drm_object_property_get_value);
/* helper for getconnector and getproperties ioctls */
int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h
index 43c4b6a2046d..4931bab77424 100644
--- a/include/drm/drm_property.h
+++ b/include/drm/drm_property.h
@@ -185,6 +185,18 @@ struct drm_property {
* enum and bitmask values.
*/
struct list_head enum_list;
+
+ /**
+ * @get_property
+ *
+ * This callback allows a driver to override the internal value
+ * of the drm property. The callback is optional.
+ *
+ * RETURNS:
+ *
+ * The value of the property
+ */
+ uint64_t (*get_property)(struct drm_mode_object *obj);
};
/**