drm: writeback: Add client capability for exposing writeback connectors
authorLiviu Dudau <Liviu.Dudau@arm.com>
Wed, 28 Feb 2018 14:11:23 +0000 (14:11 +0000)
committerLiviu Dudau <Liviu.Dudau@arm.com>
Wed, 20 Jun 2018 14:30:20 +0000 (15:30 +0100)
Due to the fact that writeback connectors behave in a special way
in DRM (they always report being disconnected) we might confuse some
userspace. Add a client capability for writeback connectors that will
filter them out for clients that don't understand the capability.

Changelog:
 - only accept the capability if the client has already set the
DRM_CLIENT_CAP_ATOMIC one.

Cc: Sean Paul <seanpaul@chromium.org>
Cc: Brian Starkey <brian.starkey@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Link: https://patchwork.freedesktop.org/patch/229038/
drivers/gpu/drm/drm_ioctl.c
drivers/gpu/drm/drm_mode_config.c
include/drm/drm_file.h
include/uapi/drm/drm.h

index 0d4cfb232576fc1b2d325cfa185a1477070e30c8..fe49fb0356b5abba563dc30e8409701ecb7a8170 100644 (file)
@@ -334,6 +334,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
                        return -EINVAL;
                file_priv->aspect_ratio_allowed = req->value;
                break;
+       case DRM_CLIENT_CAP_WRITEBACK_CONNECTORS:
+               if (!file_priv->atomic)
+                       return -EINVAL;
+               if (req->value > 1)
+                       return -EINVAL;
+               file_priv->writeback_connectors = req->value;
+               break;
        default:
                return -EINVAL;
        }
index e5c653357024dc5ea522706df1a03be1f12d094d..21e353bd3948ece25235c844da7fd4e3689abe35 100644 (file)
@@ -145,6 +145,11 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
        count = 0;
        connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
        drm_for_each_connector_iter(connector, &conn_iter) {
+               /* only expose writeback connectors if userspace understands them */
+               if (!file_priv->writeback_connectors &&
+                   (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))
+                       continue;
+
                if (drm_lease_held(file_priv, connector->base.id)) {
                        if (count < card_res->count_connectors &&
                            put_user(connector->base.id, connector_id + count)) {
index 027ac16da3d15fb99655ad3724562ae8cf222190..26485acc51d7944697ce96f0988c2803f4d8c581 100644 (file)
@@ -192,6 +192,13 @@ struct drm_file {
         */
        unsigned aspect_ratio_allowed:1;
 
+       /**
+        * @writeback_connectors:
+        *
+        * True if client understands writeback connectors
+        */
+       unsigned writeback_connectors:1;
+
        /**
         * @is_master:
         *
index 9c660e1688abe1cd6bf0e22bf709515e8a463e0d..300f336633f28ea20493570f80a73e30d87cd087 100644 (file)
@@ -687,6 +687,15 @@ struct drm_get_cap {
  */
 #define DRM_CLIENT_CAP_ASPECT_RATIO    4
 
+/**
+ * DRM_CLIENT_CAP_WRITEBACK_CONNECTORS
+ *
+ * If set to 1, the DRM core will expose special connectors to be used for
+ * writing back to memory the scene setup in the commit. Depends on client
+ * also supporting DRM_CLIENT_CAP_ATOMIC
+ */
+#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS    5
+
 /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
 struct drm_set_client_cap {
        __u64 capability;