[RFC 9/9] drm: rcar-du: crtc: Enable 3D LUT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Enable the 3D LUT in rcar_du_crtc by first creating a property for
the supported 3d lut modes and by calling the drm_crtc_enable_lut3d()
helper.

Signed-off-by: Jacopo Mondi <jacopo.mondi@xxxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/rcar-du/rcar_cmm.h     | 14 ++++++++++++++
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 23 +++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_cmm.h b/drivers/gpu/drm/rcar-du/rcar_cmm.h
index 277b9e4d9cc4..eed9e480a96f 100644
--- a/drivers/gpu/drm/rcar-du/rcar_cmm.h
+++ b/drivers/gpu/drm/rcar-du/rcar_cmm.h
@@ -8,6 +8,8 @@
 #ifndef __RCAR_CMM_H__
 #define __RCAR_CMM_H__
 
+#include <drm/drm_fourcc.h>
+
 #define CM2_LUT_SIZE		256
 #define CM2_CLU_SIZE		(17 * 17 * 17)
 
@@ -43,6 +45,16 @@ void rcar_cmm_disable(struct platform_device *pdev);
 
 int rcar_cmm_setup(struct platform_device *pdev,
 		   const struct rcar_cmm_config *config);
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = {
+	{
+		.lut_size = 17,
+		.lut_stride = {17, 17, 17},
+		.bit_depth = 8,
+		.color_format = DRM_FORMAT_XRGB16161616,
+		.flags = 0,
+	},
+};
 #else
 static inline int rcar_cmm_init(struct platform_device *pdev)
 {
@@ -63,6 +75,8 @@ static inline int rcar_cmm_setup(struct platform_device *pdev,
 {
 	return 0;
 }
+
+static const struct drm_mode_lut3d_mode rcar_cmm_3dlut_modes[] = { };
 #endif /* IS_ENABLED(CONFIG_DRM_RCAR_CMM) */
 
 #endif /* __RCAR_CMM_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 895a23161f7b..126083d226d2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -571,6 +571,24 @@ static void rcar_du_cmm_setup(struct rcar_du_crtc *rcrtc,
 	rcar_cmm_setup(rcrtc->cmm, &cmm_config);
 }
 
+static int rcar_du_cmm_enable_color_mgmt(struct rcar_du_crtc *rcrtc)
+{
+	struct drm_crtc *crtc = &rcrtc->crtc;
+	int ret;
+
+	drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
+	drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+
+	ret = drm_crtc_create_lut3d_mode_property(crtc, rcar_cmm_3dlut_modes,
+						  ARRAY_SIZE(rcar_cmm_3dlut_modes));
+	if (ret)
+		return ret;
+
+	drm_crtc_enable_lut3d(crtc, 0);
+
+	return 0;
+}
+
 /* -----------------------------------------------------------------------------
  * Start/Stop and Suspend/Resume
  */
@@ -1355,8 +1373,9 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex,
 		rcrtc->cmm = rcdu->cmms[swindex];
 		rgrp->cmms_mask |= BIT(hwindex % 2);
 
-		drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
-		drm_crtc_enable_color_mgmt(crtc, 0, false, CM2_LUT_SIZE);
+		ret = rcar_du_cmm_enable_color_mgmt(rcrtc);
+		if (ret)
+			return ret;
 	}
 
 	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
-- 
2.40.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux