drm: add atomic properties
authorRob Clark <robdclark@gmail.com>
Thu, 18 Dec 2014 21:01:50 +0000 (16:01 -0500)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 5 Jan 2015 12:54:38 +0000 (13:54 +0100)
Once a driver is using atomic helpers for modeset, the next step is to
switch over to atomic properties.  To do this, make sure that any
modeset objects have their ->atomic_{get,set}_property() vfuncs suitably
populated if they have custom properties (you did already remember to
plug in atomic-helper func for the legacy ->set_property() vfuncs,
right?), and then set DRIVER_ATOMIC bit in driver_features flag.

A new cap is introduced, DRM_CLIENT_CAP_ATOMIC, for the purposes of
shielding legacy userspace from atomic properties.  Mostly for the
benefit of legacy DDX drivers that do silly things like getting/setting
each property at startup (since some of the new atomic properties will
be able to trigger modeset).

Signed-off-by: Rob Clark <robdclark@gmail.com>
[danvet: Squash in fixup patch to check for DRM_MODE_PROP_ATOMIC
instaed of the CAP define when filtering properties. Reported by
Tvrtko Uruslin, acked by Rob.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Documentation/DocBook/drm.tmpl
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_ioctl.c
include/drm/drmP.h
include/drm/drm_atomic.h
include/drm/drm_crtc.h
include/uapi/drm/drm.h
include/uapi/drm/drm_mode.h

index 4b592ff..7fa4f98 100644 (file)
               Driver supports dedicated render nodes.
             </para></listitem>
           </varlistentry>
+          <varlistentry>
+            <term>DRIVER_ATOMIC</term>
+            <listitem><para>
+              Driver supports atomic properties.  In this case the driver
+              must implement appropriate obj->atomic_get_property() vfuncs
+              for any modeset objects with driver specific properties.
+            </para></listitem>
+          </varlistentry>
         </variablelist>
       </sect3>
       <sect3>
index 9c4e149..ce3c681 100644 (file)
@@ -520,6 +520,51 @@ int drm_atomic_connector_get_property(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_atomic_connector_get_property);
 
+/**
+ * drm_atomic_get_property - helper to read atomic property
+ * @obj: drm mode object whose property to read
+ * @property: the property to read
+ * @val: the read value, returned by reference
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+int drm_atomic_get_property(struct drm_mode_object *obj,
+               struct drm_property *property, uint64_t *val)
+{
+       struct drm_device *dev = property->dev;
+       int ret;
+
+       switch (obj->type) {
+       case DRM_MODE_OBJECT_CONNECTOR: {
+               struct drm_connector *connector = obj_to_connector(obj);
+               WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
+               ret = drm_atomic_connector_get_property(connector,
+                               connector->state, property, val);
+               break;
+       }
+       case DRM_MODE_OBJECT_CRTC: {
+               struct drm_crtc *crtc = obj_to_crtc(obj);
+               WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
+               ret = drm_atomic_crtc_get_property(crtc,
+                               crtc->state, property, val);
+               break;
+       }
+       case DRM_MODE_OBJECT_PLANE: {
+               struct drm_plane *plane = obj_to_plane(obj);
+               WARN_ON(!drm_modeset_is_locked(&plane->mutex));
+               ret = drm_atomic_plane_get_property(plane,
+                               plane->state, property, val);
+               break;
+       }
+       default:
+               ret = -EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
 /**
  * drm_atomic_set_crtc_for_plane - set crtc for plane
  * @plane_state: the plane whose incoming state to update
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge