drm: add atomic_get_property
authorRob Clark <robdclark@gmail.com>
Thu, 18 Dec 2014 21:01:47 +0000 (16:01 -0500)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 18 Dec 2014 21:22:46 +0000 (22:22 +0100)
Since we won't be using the obj->properties->values[] array to shadow
property values for atomic drivers, we are going to need a vfunc for
getting prop values.  Add that along w/ mandatory wrapper fxns.

v2: more comments and copypasta comment typo fix

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_atomic.c
include/drm/drm_atomic.h
include/drm/drm_crtc.h

index 6f729d1bdea2e8448fdc876d90b29ed6254f4522..9c4e149a61e2f7c138051a739baee434b3cdfd2a 100644 (file)
@@ -242,6 +242,32 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_atomic_crtc_set_property);
 
+/**
+ * drm_atomic_crtc_get_property - get property on CRTC
+ * @crtc: the drm CRTC to get a property on
+ * @state: the state object with the property value to read
+ * @property: the property to get
+ * @val: the property value (returned by reference)
+ *
+ * Use this instead of calling crtc->atomic_get_property directly.
+ * This function handles generic/core properties and calls out to
+ * driver's ->atomic_get_property() for driver properties.  To ensure
+ * consistent behavior you must call this function rather than the
+ * driver hook directly.
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_crtc_get_property(struct drm_crtc *crtc,
+               const struct drm_crtc_state *state,
+               struct drm_property *property, uint64_t *val)
+{
+       if (crtc->funcs->atomic_get_property)
+               return crtc->funcs->atomic_get_property(crtc, state, property, val);
+       return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_crtc_get_property);
+
 /**
  * drm_atomic_get_plane_state - get plane state
  * @state: global atomic state object
@@ -323,6 +349,32 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
 }
 EXPORT_SYMBOL(drm_atomic_plane_set_property);
 
+/**
+ * drm_atomic_plane_get_property - get property on plane
+ * @plane: the drm plane to get a property on
+ * @state: the state object with the property value to read
+ * @property: the property to get
+ * @val: the property value (returned by reference)
+ *
+ * Use this instead of calling plane->atomic_get_property directly.
+ * This function handles generic/core properties and calls out to
+ * driver's ->atomic_get_property() for driver properties.  To ensure
+ * consistent behavior you must call this function rather than the
+ * driver hook directly.
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_plane_get_property(struct drm_plane *plane,
+               const struct drm_plane_state *state,
+               struct drm_property *property, uint64_t *val)
+{
+       if (plane->funcs->atomic_get_property)
+               return plane->funcs->atomic_get_property(plane, state, property, val);
+       return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_plane_get_property);
+
 /**
  * drm_atomic_get_connector_state - get connector state
  * @state: global atomic state object
@@ -432,6 +484,42 @@ int drm_atomic_connector_set_property(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_atomic_connector_set_property);
 
+/**
+ * drm_atomic_connector_get_property - get property on connector
+ * @connector: the drm connector to get a property on
+ * @state: the state object with the property value to read
+ * @property: the property to get
+ * @val: the property value (returned by reference)
+ *
+ * Use this instead of calling connector->atomic_get_property directly.
+ * This function handles generic/core properties and calls out to
+ * driver's ->atomic_get_property() for driver properties.  To ensure
+ * consistent behavior you must call this function rather than the
+ * driver hook directly.
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_connector_get_property(struct drm_connector *connector,
+               const struct drm_connector_state *state,
+               struct drm_property *property, uint64_t *val)
+{
+       struct drm_device *dev = connector->dev;
+       struct drm_mode_config *config = &dev->mode_config;
+
+       if (property == config->dpms_property) {
+               *val = connector->dpms;
+       } else if (connector->funcs->atomic_get_property) {
+               return connector->funcs->atomic_get_property(connector,
+                               state, property, val);
+       } else {
+               return -EINVAL;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL(drm_atomic_connector_get_property);
+
 /**
  * drm_atomic_set_crtc_for_plane - set crtc for plane
  * @plane_state: the plane whose incoming state to update
index 51168a8b723a2d45f4ff658eb27d2b54bd5f1d88..d41233ccbc9e6489638c3b32dbc7290125977ed4 100644 (file)
@@ -41,18 +41,27 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
                struct drm_crtc_state *state, struct drm_property *property,
                uint64_t val);
+int drm_atomic_crtc_get_property(struct drm_crtc *crtc,
+               const struct drm_crtc_state *state,
+               struct drm_property *property, uint64_t *val);
 struct drm_plane_state * __must_check
 drm_atomic_get_plane_state(struct drm_atomic_state *state,
                           struct drm_plane *plane);
 int drm_atomic_plane_set_property(struct drm_plane *plane,
                struct drm_plane_state *state, struct drm_property *property,
                uint64_t val);
+int drm_atomic_plane_get_property(struct drm_plane *plane,
+               const struct drm_plane_state *state,
+               struct drm_property *property, uint64_t *val);
 struct drm_connector_state * __must_check
 drm_atomic_get_connector_state(struct drm_atomic_state *state,
                               struct drm_connector *connector);
 int drm_atomic_connector_set_property(struct drm_connector *connector,
                struct drm_connector_state *state, struct drm_property *property,
                uint64_t val);
+int drm_atomic_connector_get_property(struct drm_connector *connector,
+               const struct drm_connector_state *state,
+               struct drm_property *property, uint64_t *val);
 
 int __must_check
 drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
index 7f158963ef8725946d15cd236b9f06b638377558..e1f34694fcff14326a009bf551aab687b5a1517f 100644 (file)
@@ -312,6 +312,8 @@ struct drm_crtc_state {
  * @atomic_destroy_state: destroy an atomic state for this CRTC
  * @atomic_set_property: set a property on an atomic state for this CRTC
  *    (do not call directly, use drm_atomic_crtc_set_property())
+ * @atomic_get_property: get a property on an atomic state for this CRTC
+ *    (do not call directly, use drm_atomic_crtc_get_property())
  *
  * The drm_crtc_funcs structure is the central CRTC management structure
  * in the DRM.  Each CRTC controls one or more connectors (note that the name
@@ -371,6 +373,10 @@ struct drm_crtc_funcs {
                                   struct drm_crtc_state *state,
                                   struct drm_property *property,
                                   uint64_t val);
+       int (*atomic_get_property)(struct drm_crtc *crtc,
+                                  const struct drm_crtc_state *state,
+                                  struct drm_property *property,
+                                  uint64_t *val);
 };
 
 /**
@@ -499,6 +505,8 @@ struct drm_connector_state {
  * @atomic_destroy_state: destroy an atomic state for this connector
  * @atomic_set_property: set a property on an atomic state for this connector
  *    (do not call directly, use drm_atomic_connector_set_property())
+ * @atomic_get_property: get a property on an atomic state for this connector
+ *    (do not call directly, use drm_atomic_connector_get_property())
  *
  * Each CRTC may have one or more connectors attached to it.  The functions
  * below allow the core DRM code to control connectors, enumerate available modes,
@@ -532,6 +540,10 @@ struct drm_connector_funcs {
                                   struct drm_connector_state *state,
                                   struct drm_property *property,
                                   uint64_t val);
+       int (*atomic_get_property)(struct drm_connector *connector,
+                                  const struct drm_connector_state *state,
+                                  struct drm_property *property,
+                                  uint64_t *val);
 };
 
 /**
@@ -763,6 +775,8 @@ struct drm_plane_state {
  * @atomic_destroy_state: destroy an atomic state for this plane
  * @atomic_set_property: set a property on an atomic state for this plane
  *    (do not call directly, use drm_atomic_plane_set_property())
+ * @atomic_get_property: get a property on an atomic state for this plane
+ *    (do not call directly, use drm_atomic_plane_get_property())
  */
 struct drm_plane_funcs {
        int (*update_plane)(struct drm_plane *plane,
@@ -786,6 +800,10 @@ struct drm_plane_funcs {
                                   struct drm_plane_state *state,
                                   struct drm_property *property,
                                   uint64_t val);
+       int (*atomic_get_property)(struct drm_plane *plane,
+                                  const struct drm_plane_state *state,
+                                  struct drm_property *property,
+                                  uint64_t *val);
 };
 
 enum drm_plane_type {