[RFC PATCH v2 15/20] drm/drm_ioctl: guard DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE

Melissa Wen <[email protected]>
Newsgroups org.freedesktop.lists.amd-gfx,org.freedesktop.lists.dri-devel
Message-ID <[email protected]>
If the driver doesn't support post-blend colorop, refuse attempts from
usersapce to set it. Same approach is taken for pre-blend colorop.

Signed-off-by: Melissa Wen <[email protected]>
---
 drivers/gpu/drm/drm_ioctl.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ae374733e154..82d4f1bfc557 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -380,13 +380,26 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
 			return -EINVAL;
 		file_priv->plane_color_pipeline = req->value;
 		break;
-	case DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE:
+	case DRM_CLIENT_CAP_CRTC_COLOR_PIPELINE: {
+		struct drm_crtc *crtc;
+		bool has_crtc_with_color_pipeline = false;
+
 		if (!file_priv->atomic)
 			return -EINVAL;
 		if (req->value > 1)
 			return -EINVAL;
+		drm_for_each_crtc(crtc, dev) {
+			if (crtc->color_pipeline_property) {
+				has_crtc_with_color_pipeline = true;
+				break;
+			}
+		}
+		if (req->value == 1 && !has_crtc_with_color_pipeline)
+			return -EOPNOTSUPP;
+
 		file_priv->crtc_color_pipeline = req->value;
 		break;
+	}
 	default:
 		return -EINVAL;
 	}
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.