From: Harry Wentland <harry.wentl...@amd.com>

With the introduction of the pre-blending color pipeline we
can no longer have color operations that don't have a clear
position in the color pipeline. We deprecate all existing
plane properties. For upstream drivers those are:
 - COLOR_ENCODING
 - COLOR_RANGE

Drivers are expected to ignore these properties when
programming the HW. DRM clients that register with
DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE will not be allowed to
set the COLOR_ENCODING and COLOR_RANGE properties.

Setting of the COLOR_PIPELINE plane property or drm_colorop
properties is only allowed for userspace that sets this
client cap.

Reviewed-by: Simon Ser <cont...@emersion.fr>
Signed-off-by: Alex Hung <alex.h...@amd.com>
Signed-off-by: Harry Wentland <harry.wentl...@amd.com>
Reviewed-by: Daniel Stone <dani...@collabora.com>
---
V9:
 - Fix typo in commit description (Shengyu Qu)

v8:
 - Disallow setting of COLOR_RANGE and COLOR_ENCODING when
   DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set

v5:
 - Fix kernel docs

v4:
 - Don't block setting of COLOR_RANGE and COLOR_ENCODING
   when client cap is set

 drivers/gpu/drm/drm_atomic_uapi.c | 23 ++++++++++++++++++++++-
 drivers/gpu/drm/drm_ioctl.c       |  7 +++++++
 include/drm/drm_file.h            |  7 +++++++
 include/uapi/drm/drm.h            | 15 +++++++++++++++
 4 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c 
b/drivers/gpu/drm/drm_atomic_uapi.c
index 0b2b3242c976..c0bcaec249de 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -567,10 +567,26 @@ static int drm_atomic_plane_set_property(struct drm_plane 
*plane,
        } else if (property == plane->zpos_property) {
                state->zpos = val;
        } else if (property == plane->color_encoding_property) {
+               if (file_priv->plane_color_pipeline) {
+                       drm_dbg_atomic(dev,
+                                      "Setting COLOR_ENCODING plane property 
not permitted with DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE client cap\n");
+                       return -EINVAL;
+               }
                state->color_encoding = val;
        } else if (property == plane->color_range_property) {
+               if (file_priv->plane_color_pipeline) {
+                       drm_dbg_atomic(dev,
+                                      "Setting COLOR_RANGE plane property not 
permitted with DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE client cap\n");
+                       return -EINVAL;
+               }
                state->color_range = val;
        } else if (property == plane->color_pipeline_property) {
+               if (!file_priv->plane_color_pipeline) {
+                       drm_dbg_atomic(dev,
+                                      "Setting COLOR_PIPELINE plane property 
not permitted unless DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set\n");
+                       return -EINVAL;
+               }
+
                /* find DRM colorop object */
                struct drm_colorop *colorop = NULL;
 
@@ -1200,6 +1216,12 @@ int drm_atomic_set_property(struct drm_atomic_state 
*state,
                break;
        }
        case DRM_MODE_OBJECT_COLOROP: {
+               if (!file_priv->plane_color_pipeline) {
+                       drm_dbg_atomic(prop->dev,
+                                      "[OBJECT:%d] is a colorop but 
DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE not set\n",
+                                      obj->id);
+                       ret = -EINVAL;
+               }
                struct drm_colorop *colorop = obj_to_colorop(obj);
                struct drm_colorop_state *colorop_state;
 
@@ -1212,7 +1234,6 @@ int drm_atomic_set_property(struct drm_atomic_state 
*state,
                ret = drm_atomic_colorop_set_property(colorop,
                                colorop_state, file_priv,
                                prop, prop_value);
-
                break;
        }
        default:
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index f593dc569d31..5c89c586da7c 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -373,6 +373,13 @@ drm_setclientcap(struct drm_device *dev, void *data, 
struct drm_file *file_priv)
                        return -EINVAL;
                file_priv->supports_virtualized_cursor_plane = req->value;
                break;
+       case DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE:
+               if (!file_priv->atomic)
+                       return -EINVAL;
+               if (req->value > 1)
+                       return -EINVAL;
+               file_priv->plane_color_pipeline = req->value;
+               break;
        default:
                return -EINVAL;
        }
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 94d365b22505..86929ca667aa 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -206,6 +206,13 @@ struct drm_file {
         */
        bool writeback_connectors;
 
+       /**
+        * @plane_color_pipeline:
+        *
+        * True if client understands plane color pipelines
+        */
+       bool plane_color_pipeline;
+
        /**
         * @was_master:
         *
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index e63a71d3c607..80c35ff7f21e 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -875,6 +875,21 @@ struct drm_get_cap {
  */
 #define DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT    6
 
+/**
+ * DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE
+ *
+ * If set to 1 the DRM core will allow setting the COLOR_PIPELINE
+ * property on a &drm_plane, as well as drm_colorop properties.
+ *
+ * Setting of these plane properties will be rejected when this client
+ * cap is set:
+ * - COLOR_ENCODING
+ * - COLOR_RANGE
+ *
+ * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
+ */
+#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE    7
+
 /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
 struct drm_set_client_cap {
        __u64 capability;
-- 
2.43.0

Reply via email to