]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm: add atomic_set_property wrappers
authorRob Clark <robdclark@gmail.com>
Thu, 18 Dec 2014 21:01:46 +0000 (16:01 -0500)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 18 Dec 2014 21:22:39 +0000 (22:22 +0100)
As we add properties for all the standard plane/crtc/connector
attributes (in preperation for the atomic ioctl), we are going to want
to handle core state in core (rather than per driver).  Intercepting the
core properties will be easier if the atomic_set_property vfuncs are not
called directly, but instead have a mandatory wrapper function (which
will later serve as the point to intercept core properties).

v2: more verbose comments and copypasta comment 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
drivers/gpu/drm/drm_atomic_helper.c
include/drm/drm_atomic.h
include/drm/drm_crtc.h

index cbd5e7240b6b4e6021e8a35cbbcd52fd6383c906..6f729d1bdea2e8448fdc876d90b29ed6254f4522 100644 (file)
@@ -216,6 +216,32 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 }
 EXPORT_SYMBOL(drm_atomic_get_crtc_state);
 
+/**
+ * drm_atomic_crtc_set_property - set property on CRTC
+ * @crtc: the drm CRTC to set a property on
+ * @state: the state object to update with the new property value
+ * @property: the property to set
+ * @val: the new property value
+ *
+ * Use this instead of calling crtc->atomic_set_property directly.
+ * This function handles generic/core properties and calls out to
+ * driver's ->atomic_set_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_set_property(struct drm_crtc *crtc,
+               struct drm_crtc_state *state, struct drm_property *property,
+               uint64_t val)
+{
+       if (crtc->funcs->atomic_set_property)
+               return crtc->funcs->atomic_set_property(crtc, state, property, val);
+       return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_crtc_set_property);
+
 /**
  * drm_atomic_get_plane_state - get plane state
  * @state: global atomic state object
@@ -271,6 +297,32 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
 }
 EXPORT_SYMBOL(drm_atomic_get_plane_state);
 
+/**
+ * drm_atomic_plane_set_property - set property on plane
+ * @plane: the drm plane to set a property on
+ * @state: the state object to update with the new property value
+ * @property: the property to set
+ * @val: the new property value
+ *
+ * Use this instead of calling plane->atomic_set_property directly.
+ * This function handles generic/core properties and calls out to
+ * driver's ->atomic_set_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_set_property(struct drm_plane *plane,
+               struct drm_plane_state *state, struct drm_property *property,
+               uint64_t val)
+{
+       if (plane->funcs->atomic_set_property)
+               return plane->funcs->atomic_set_property(plane, state, property, val);
+       return -EINVAL;
+}
+EXPORT_SYMBOL(drm_atomic_plane_set_property);
+
 /**
  * drm_atomic_get_connector_state - get connector state
  * @state: global atomic state object
@@ -342,6 +394,44 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
 }
 EXPORT_SYMBOL(drm_atomic_get_connector_state);
 
+/**
+ * drm_atomic_connector_set_property - set property on connector.
+ * @connector: the drm connector to set a property on
+ * @state: the state object to update with the new property value
+ * @property: the property to set
+ * @val: the new property value
+ *
+ * Use this instead of calling connector->atomic_set_property directly.
+ * This function handles generic/core properties and calls out to
+ * driver's ->atomic_set_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_set_property(struct drm_connector *connector,
+               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) {
+               /* setting DPMS property requires special handling, which
+                * is done in legacy setprop path for us.  Disallow (for
+                * now?) atomic writes to DPMS property:
+                */
+               return -EINVAL;
+       } else if (connector->funcs->atomic_set_property) {
+               return connector->funcs->atomic_set_property(connector,
+                               state, property, val);
+       } else {
+               return -EINVAL;
+       }
+}
+EXPORT_SYMBOL(drm_atomic_connector_set_property);
+
 /**
  * drm_atomic_set_crtc_for_plane - set crtc for plane
  * @plane_state: the plane whose incoming state to update
index 379d37acd5b53b44cfba2b77aa15bebac0ee9a2f..57e5540259cc41672239ed3b7cbc84ee40a95f10 100644 (file)
@@ -1613,8 +1613,8 @@ retry:
                goto fail;
        }
 
-       ret = crtc->funcs->atomic_set_property(crtc, crtc_state,
-                                              property, val);
+       ret = drm_atomic_crtc_set_property(crtc, crtc_state,
+                       property, val);
        if (ret)
                goto fail;
 
@@ -1672,8 +1672,8 @@ retry:
                goto fail;
        }
 
-       ret = plane->funcs->atomic_set_property(plane, plane_state,
-                                              property, val);
+       ret = drm_atomic_plane_set_property(plane, plane_state,
+                       property, val);
        if (ret)
                goto fail;
 
@@ -1731,8 +1731,8 @@ retry:
                goto fail;
        }
 
-       ret = connector->funcs->atomic_set_property(connector, connector_state,
-                                              property, val);
+       ret = drm_atomic_connector_set_property(connector, connector_state,
+                       property, val);
        if (ret)
                goto fail;
 
index e224ccfa11ca0ab2698bcad6126616040b997144..51168a8b723a2d45f4ff658eb27d2b54bd5f1d88 100644 (file)
@@ -38,12 +38,21 @@ void drm_atomic_state_free(struct drm_atomic_state *state);
 struct drm_crtc_state * __must_check
 drm_atomic_get_crtc_state(struct drm_atomic_state *state,
                          struct drm_crtc *crtc);
+int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
+               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);
 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 __must_check
 drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
index f7c0b7bb9d5fc8a5e309fbd001e3dfe3698c8eac..7f158963ef8725946d15cd236b9f06b638377558 100644 (file)
@@ -311,6 +311,7 @@ struct drm_crtc_state {
  * @atomic_duplicate_state: duplicate the atomic state for this CRTC
  * @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())
  *
  * 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
@@ -497,6 +498,7 @@ struct drm_connector_state {
  * @atomic_duplicate_state: duplicate the atomic state for this connector
  * @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())
  *
  * 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,
@@ -760,6 +762,7 @@ struct drm_plane_state {
  * @atomic_duplicate_state: duplicate the atomic state for this plane
  * @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())
  */
 struct drm_plane_funcs {
        int (*update_plane)(struct drm_plane *plane,